Line data Source code
1 : #include <stdio.h>
2 :
3 : #include "TMath.h"
4 :
5 : #include "AliTRDltuParam.h"
6 :
7 : // definition of geometry constants
8 : Float_t AliTRDltuParam::fgZrow[6][5] = {
9 : {301, 177, 53, -57, -181},
10 : {301, 177, 53, -57, -181},
11 : {315, 184, 53, -57, -188},
12 : {329, 191, 53, -57, -195},
13 : {343, 198, 53, -57, -202},
14 : {347, 200, 53, -57, -204}};
15 : Float_t AliTRDltuParam::fgX[6] =
16 : {300.65, 313.25, 325.85, 338.45, 351.05, 363.65};
17 : Float_t AliTRDltuParam::fgTiltingAngle[6] =
18 : {-2., 2., -2., 2., -2., 2.};
19 : Int_t AliTRDltuParam::fgDyMax = 63;
20 : Int_t AliTRDltuParam::fgDyMin = -64;
21 : Float_t AliTRDltuParam::fgBinDy = 140e-4;
22 : Float_t AliTRDltuParam::fgWidthPad[6] =
23 : {0.635, 0.665, 0.695, 0.725, 0.755, 0.785};
24 : Float_t AliTRDltuParam::fgLengthInnerPadC1[6] =
25 : {7.5, 7.5, 8.0, 8.5, 9.0, 9.0};
26 : Float_t AliTRDltuParam::fgLengthOuterPadC1[6] =
27 : {7.5, 7.5, 7.5, 7.5, 7.5, 8.5};
28 : Float_t AliTRDltuParam::fgLengthInnerPadC0 = 9.0;
29 : Float_t AliTRDltuParam::fgLengthOuterPadC0 = 8.0;
30 : Float_t AliTRDltuParam::fgScalePad = 256. * 32.;
31 : Float_t AliTRDltuParam::fgDriftLength = 3.;
32 :
33 : AliTRDltuParam::AliTRDltuParam() :
34 1 : TObject(),
35 1 : fMagField(0.),
36 1 : fOmegaTau(0.),
37 1 : fPtMin(0.1),
38 1 : fNtimebins(20 << 5),
39 1 : fScaleQ0(0),
40 1 : fScaleQ1(0),
41 1 : fPidTracklengthCorr(kFALSE),
42 1 : fTiltCorr(kFALSE),
43 1 : fPidGainCorr(kFALSE)
44 5 : {
45 : // default constructor
46 2 : }
47 :
48 : AliTRDltuParam::~AliTRDltuParam()
49 2 : {
50 : // destructor
51 3 : }
52 :
53 : Int_t AliTRDltuParam::GetDyCorrection(Int_t det, Int_t rob, Int_t mcm) const
54 : {
55 : // calculate the correction of the deflection
56 : // i.e. Lorentz angle and tilt correction (if active)
57 :
58 131328 : Int_t layer = det % 6;
59 :
60 196992 : Float_t dyTilt = ( fgDriftLength * TMath::Tan(fgTiltingAngle[layer] * TMath::Pi()/180.) *
61 131328 : GetLocalZ(det, rob, mcm) / fgX[layer] );
62 :
63 : // calculate Lorentz correction
64 65664 : Float_t dyCorr = - fOmegaTau * fgDriftLength;
65 :
66 65664 : if(fTiltCorr)
67 0 : dyCorr += dyTilt; // add tilt correction
68 :
69 65664 : return (int) TMath::Nint(dyCorr * fgScalePad / fgWidthPad[layer]);
70 : }
71 :
72 : void AliTRDltuParam::GetDyRange(Int_t det, Int_t rob, Int_t mcm, Int_t ch,
73 : Int_t &dyMinInt, Int_t &dyMaxInt) const
74 : {
75 : // calculate the deflection range in which tracklets are accepted
76 :
77 2363904 : dyMinInt = fgDyMin;
78 1181952 : dyMaxInt = fgDyMax;
79 :
80 : // deflection cut is considered for |B| > 0.1 T only
81 1181952 : if (TMath::Abs(fMagField) < 0.1)
82 : return;
83 :
84 : Float_t e = 0.30;
85 :
86 0 : Float_t maxDeflTemp = GetPerp(det, rob, mcm, ch)/2. * // Sekante/2 (cm)
87 0 : (e * 1e-2 * TMath::Abs(fMagField) / fPtMin); // 1/R (1/cm)
88 :
89 : Float_t maxDeflAngle = 0.;
90 :
91 0 : Float_t phi = GetPhi(det, rob, mcm, ch);
92 0 : if (maxDeflTemp < TMath::Cos(phi)) {
93 0 : maxDeflAngle = TMath::ASin(maxDeflTemp);
94 :
95 0 : Float_t dyMin = ( fgDriftLength *
96 0 : TMath::Tan(phi - maxDeflAngle) );
97 :
98 0 : dyMinInt = Int_t(dyMin / fgBinDy);
99 : // clipping to allowed range
100 0 : if (dyMinInt < fgDyMin)
101 0 : dyMinInt = fgDyMin;
102 0 : else if (dyMinInt > fgDyMax)
103 0 : dyMinInt = fgDyMax;
104 :
105 0 : Float_t dyMax = ( fgDriftLength *
106 0 : TMath::Tan(phi + maxDeflAngle) );
107 :
108 0 : dyMaxInt = Int_t(dyMax / fgBinDy);
109 : // clipping to allowed range
110 0 : if (dyMaxInt > fgDyMax)
111 0 : dyMaxInt = fgDyMax;
112 0 : else if (dyMaxInt < fgDyMin)
113 0 : dyMaxInt = fgDyMin;
114 0 : }
115 0 : else if (maxDeflTemp < 0.) {
116 : // this must not happen
117 0 : printf("Inconsistent calculation of sin(alpha): %f\n", maxDeflTemp);
118 0 : }
119 : else {
120 : // TRD is not reached at the given pt threshold
121 : // max range
122 : }
123 :
124 0 : if ((dyMaxInt - dyMinInt) <= 0) {
125 0 : printf("strange dy range: [%i,%i], using max range now\n", dyMinInt, dyMaxInt);
126 0 : dyMaxInt = fgDyMax;
127 0 : dyMinInt = fgDyMin;
128 0 : }
129 1181952 : }
130 :
131 : Float_t AliTRDltuParam::GetElongation(Int_t det, Int_t rob, Int_t mcm, Int_t ch) const
132 : {
133 : // calculate the ratio of the distance to the primary vertex and the
134 : // distance in x-direction for the given ADC channel
135 :
136 0 : Int_t layer = det % 6;
137 :
138 0 : Float_t elongation = TMath::Abs(GetDist(det, rob, mcm, ch) / fgX[layer]);
139 :
140 : // sanity check
141 0 : if(elongation<0.001) {
142 : elongation=1.;
143 0 : }
144 0 : return elongation;
145 : }
146 :
147 : void AliTRDltuParam::GetCorrectionFactors(Int_t det, Int_t rob, Int_t mcm, Int_t ch,
148 : UInt_t &cor0, UInt_t &cor1, Float_t gain) const
149 : {
150 : // calculate the gain correction factors for the given ADC channel
151 :
152 131328 : if (fPidGainCorr==kFALSE)
153 : gain=1;
154 :
155 131328 : if (fPidTracklengthCorr == kTRUE ) {
156 65664 : cor0 = UInt_t ((1.0*fScaleQ0* (1./GetElongation(det, rob, mcm, ch))) / gain );
157 0 : cor1 = UInt_t ((1.0*fScaleQ1* (1./GetElongation(det, rob, mcm, ch))) / gain );
158 0 : }
159 : else {
160 65664 : cor0 = UInt_t (fScaleQ0 / gain);
161 65664 : cor1 = UInt_t ( fScaleQ1 / gain);
162 : }
163 65664 : }
164 :
165 : Int_t AliTRDltuParam::GetNtimebins() const
166 : {
167 : // return the number of timebins used
168 :
169 1080 : return fNtimebins;
170 : }
171 :
172 : Float_t AliTRDltuParam::GetX(Int_t det, Int_t /* rob */, Int_t /* mcm */) const
173 : {
174 : // return the distance to the beam axis in x-direction
175 :
176 0 : Int_t layer = det%6;
177 0 : return fgX[layer];
178 : }
179 :
180 : Float_t AliTRDltuParam::GetLocalY(Int_t det, Int_t rob, Int_t mcm, Int_t ch) const
181 : {
182 : // get local y-position (r-phi) w.r.t. the chamber centre
183 :
184 0 : Int_t layer = det%6;
185 : // calculate the pad position as in the TRAP
186 0 : Float_t ypos = (-4 + 1 + (rob&0x1) * 4 + (mcm&0x3)) * 18 - ch - 0.5; // y position in bins of pad widths
187 0 : return ypos*fgWidthPad[layer];
188 : }
189 :
190 : Float_t AliTRDltuParam::GetLocalZ(Int_t det, Int_t rob, Int_t mcm) const
191 : {
192 : // get local z-position w.r.t. to the chamber boundary
193 :
194 131328 : Int_t stack = (det%30) / 6;
195 65664 : Int_t layer = det % 6;
196 65664 : Int_t row = (rob/2) * 4 + mcm/4;
197 :
198 131328 : if (stack == 2) {
199 76032 : if (row == 0)
200 864 : return (fgZrow[layer][stack] - 0.5 * fgLengthOuterPadC0);
201 19008 : else if (row == 11)
202 10368 : return (fgZrow[layer][stack] - 1.5 * fgLengthOuterPadC0 - (row - 1) * fgLengthInnerPadC0);
203 : else
204 8640 : return (fgZrow[layer][stack] - fgLengthOuterPadC0 - (row - 0.5) * fgLengthInnerPadC0);
205 : }
206 : else {
207 55296 : if (row == 0)
208 3456 : return (fgZrow[layer][stack] - 0.5 * fgLengthOuterPadC1[layer]);
209 103680 : else if (row == 15)
210 55296 : return (fgZrow[layer][stack] - 1.5 * fgLengthOuterPadC1[layer] - (row - 1) * fgLengthInnerPadC1[layer]);
211 : else
212 48384 : return (fgZrow[layer][stack] - fgLengthOuterPadC1[layer] - (row - 0.5) * fgLengthInnerPadC1[layer]);
213 : }
214 65664 : }
215 :
216 : Float_t AliTRDltuParam::GetPerp(Int_t det, Int_t rob, Int_t mcm, Int_t ch) const
217 : {
218 : // get transverse distance to the beam axis
219 :
220 0 : return TMath::Sqrt(GetLocalY(det, rob, mcm, ch)*GetLocalY(det, rob, mcm, ch) +
221 0 : GetX(det, rob, mcm)*GetX(det, rob, mcm) );
222 : }
223 :
224 : Float_t AliTRDltuParam::GetPhi(Int_t det, Int_t rob, Int_t mcm, Int_t ch) const
225 : {
226 : // calculate the azimuthal angle for the given ADC channel
227 :
228 0 : return TMath::ATan2(GetLocalY(det, rob, mcm, ch), GetX(det, rob, mcm));
229 : }
230 :
231 : Float_t AliTRDltuParam::GetDist(Int_t det, Int_t rob, Int_t mcm, Int_t ch) const
232 : {
233 : // calculate the distance from the origin for the given ADC channel
234 :
235 0 : return TMath::Sqrt(GetLocalY(det, rob, mcm, ch)*GetLocalY(det, rob, mcm, ch) +
236 0 : GetX(det, rob, mcm)*GetX(det, rob, mcm) +
237 0 : GetLocalZ(det, rob, mcm)*GetLocalZ(det, rob, mcm) );
238 : }
|