5a5a1232 |
1 | // $Header$ |
2 | |
3 | //__________________________________________________________________________ |
4 | // ITSDigitsInfo |
5 | // |
6 | // |
3d598e88 |
7 | #include <TMath.h> |
8 | #include <TVector3.h> |
5a5a1232 |
9 | |
10 | #include <Reve/TTreeTools.h> |
3d598e88 |
11 | #include <Reve/ZTrans.h> |
5a5a1232 |
12 | |
13 | #include "ITSDigitsInfo.h" |
5a5a1232 |
14 | #include <AliITSCalibrationSDD.h> |
15 | #include <AliITSdigit.h> |
16 | #include <AliITSdigitSPD.h> |
17 | |
3d598e88 |
18 | |
5a5a1232 |
19 | using namespace Reve; |
20 | using namespace Alieve; |
21 | using namespace std; |
22 | |
3d598e88 |
23 | |
24 | ClassImp(ITSModuleSelection) |
25 | |
26 | ITSModuleSelection::ITSModuleSelection(): |
27 | fType(-1), |
28 | fLayer(-1), |
29 | fMinPhi(0), |
30 | fMaxPhi(2*TMath::Pi()), |
31 | fMinTheta(0), |
32 | fMaxTheta(2*TMath::Pi()) |
33 | { |
34 | } |
35 | |
5a5a1232 |
36 | ClassImp(ITSDigitsInfo) |
37 | |
38 | /**************************************************************************/ |
39 | |
265ecb21 |
40 | ITSDigitsInfo::ITSDigitsInfo() : |
41 | TObject(), |
d54c094e |
42 | ReferenceCount(), |
265ecb21 |
43 | fSPDmap(), fSDDmap(), fSSDmap(), |
44 | fTree (0), |
45 | fGeom (0), |
46 | fSegSPD(0), fSegSDD(0), fSegSSD(0) |
47 | {} |
5a5a1232 |
48 | |
49 | /**************************************************************************/ |
50 | |
51 | ITSDigitsInfo:: ~ITSDigitsInfo() |
52 | { |
d54c094e |
53 | map<Int_t, TClonesArray*>::iterator j; |
54 | for(j = fSPDmap.begin(); j != fSPDmap.end(); ++j) |
5a5a1232 |
55 | delete j->second; |
d54c094e |
56 | for(j = fSDDmap.begin(); j != fSDDmap.end(); ++j) |
5a5a1232 |
57 | delete j->second; |
d54c094e |
58 | for(j = fSSDmap.begin(); j != fSSDmap.end(); ++j) |
5a5a1232 |
59 | delete j->second; |
d54c094e |
60 | |
5a5a1232 |
61 | delete fSegSPD; delete fSegSDD; delete fSegSSD; |
62 | delete fGeom; |
63 | delete fTree; |
64 | } |
65 | |
66 | /**************************************************************************/ |
67 | |
68 | void ITSDigitsInfo::SetTree(TTree* tree) |
69 | { |
70 | static const Exc_t eH("ITSDigitsInfo::SetTree "); |
71 | |
72 | if(fGeom == 0) { |
73 | fGeom = new AliITSgeom(); |
74 | fGeom->ReadNewFile("$REVESYS/alice-data/ITSgeometry.det"); |
75 | if(fGeom == 0) |
76 | throw(eH + "can not load ITS geometry \n"); |
77 | } |
78 | |
79 | fTree = tree; |
80 | |
81 | SetITSSegmentation(); |
d4b6a94c |
82 | |
5a5a1232 |
83 | // create tables for scaling |
d4b6a94c |
84 | fSPDMinVal = 0; |
85 | fSDDMinVal = 5; |
86 | fSSDMinVal = 2; |
87 | |
88 | fSPDMaxVal = 1; |
89 | fSDDMaxVal = 80; |
90 | fSSDMaxVal = 100; |
91 | |
92 | fSPDMaxOcc = 0.15; |
93 | fSDDMaxOcc = 0.15; |
94 | fSSDMaxOcc = 0.3; |
95 | |
d54c094e |
96 | // lowest scale factor refers to unscaled ITS module |
97 | fSPDScaleX[0] = 1; |
98 | fSPDScaleZ[0] = 1; |
99 | fSDDScaleX[0] = 1; |
100 | fSDDScaleZ[0] = 1; |
101 | fSSDScale [0] = 1; |
d4b6a94c |
102 | |
d54c094e |
103 | // spd lows resolution is in the level of 8x2 readout chips |
5a5a1232 |
104 | Int_t nx = 8; // fSegSPD->Npx()/8; // 32 |
105 | Int_t nz = 6; // fSegSPD->Npz()/2; // 128 |
106 | |
107 | fSPDScaleX[1] = Int_t(nx); |
108 | fSPDScaleZ[1] = Int_t(nz); |
109 | fSPDScaleX[2] = Int_t(nx*2); |
110 | fSPDScaleZ[2] = Int_t(nz*2); |
111 | fSPDScaleX[3] = Int_t(nx*3); |
112 | fSPDScaleZ[3] = Int_t(nz*3); |
113 | fSPDScaleX[4] = Int_t(nx*4); |
114 | fSPDScaleZ[4] = Int_t(nz*4); |
115 | |
5a5a1232 |
116 | fSDDScaleX[1] = 2; |
117 | fSDDScaleZ[1] = 2; |
118 | fSDDScaleX[2] = 8; |
119 | fSDDScaleZ[2] = 8; |
120 | fSDDScaleX[3] = 16; |
121 | fSDDScaleZ[3] = 16; |
122 | fSDDScaleX[4] = 25; |
123 | fSDDScaleZ[4] = 25; |
124 | |
125 | fSSDScale[1] = 3; |
126 | fSSDScale[2] = 9; |
127 | fSSDScale[3] = 20; |
128 | fSSDScale[4] = 30; |
5a5a1232 |
129 | } |
130 | |
131 | /**************************************************************************/ |
132 | |
133 | void ITSDigitsInfo::SetITSSegmentation() |
134 | { |
135 | // SPD |
136 | fSegSPD = new AliITSsegmentationSPD(fGeom); |
137 | //SPD geometry |
138 | Int_t m; |
139 | Float_t fNzSPD=160; |
140 | Float_t fZ1pitchSPD=0.0425; Float_t fZ2pitchSPD=0.0625; |
141 | Float_t fHlSPD=3.48; |
142 | |
143 | fSPDZCoord[0]=fZ1pitchSPD -fHlSPD; |
144 | for (m=1; m<fNzSPD; m++) { |
145 | Double_t dz=fZ1pitchSPD; |
146 | if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 || |
147 | m==127 || m==128) dz=fZ2pitchSPD; |
148 | fSPDZCoord[m]=fSPDZCoord[m-1]+dz; |
149 | } |
150 | |
151 | for (m=0; m<fNzSPD; m++) { |
152 | Double_t dz=1.*fZ1pitchSPD; |
153 | if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 || |
154 | m==127 || m==128) dz=1.*fZ2pitchSPD; |
155 | fSPDZCoord[m]-=dz; |
156 | } |
157 | |
158 | // end of SPD geometry |
159 | |
160 | // SDD |
161 | // response replaced by Calibration (March 2006). |
162 | AliITSresponseSDD* resp1 = new AliITSresponseSDD(); |
163 | AliITSCalibrationSDD* cal1 = new AliITSCalibrationSDD; |
164 | cal1->SetResponse(resp1); |
165 | fSegSDD = new AliITSsegmentationSDD(fGeom, cal1); |
166 | |
167 | // SSD |
168 | fSegSSD = new AliITSsegmentationSSD(fGeom); |
169 | } |
170 | |
171 | void ITSDigitsInfo::GetSPDLocalZ(Int_t j, Float_t& z) |
172 | { |
173 | z = fSPDZCoord[j]; |
174 | } |
175 | |
176 | /**************************************************************************/ |
177 | |
178 | TClonesArray* ITSDigitsInfo::GetDigits(Int_t mod, Int_t subdet) |
179 | { |
180 | switch(subdet) { |
6ddaaee3 |
181 | case 0: { |
182 | TClonesArray* digitsSPD = 0; |
183 | map<Int_t, TClonesArray*>::iterator i = fSPDmap.find(mod); |
184 | if(i == fSPDmap.end()) { |
185 | TBranch* br = fTree->GetBranch("ITSDigitsSPD"); |
186 | br->SetAddress(&digitsSPD); |
187 | br->GetEntry(mod); |
188 | fSPDmap[mod] = digitsSPD; |
189 | return digitsSPD; |
190 | } else { |
191 | return i->second; |
192 | } |
193 | break; |
5a5a1232 |
194 | } |
6ddaaee3 |
195 | case 1: { |
196 | TClonesArray* digitsSDD = 0; |
197 | map<Int_t, TClonesArray*>::iterator i = fSDDmap.find(mod); |
198 | if(i == fSDDmap.end()) { |
199 | TBranch* br = fTree->GetBranch("ITSDigitsSDD"); |
200 | br->SetAddress(&digitsSDD); |
201 | br->GetEntry(mod); |
202 | fSDDmap[mod] = digitsSDD; |
203 | return digitsSDD; |
204 | } else { |
205 | return i->second; |
206 | } |
207 | break; |
5a5a1232 |
208 | } |
6ddaaee3 |
209 | case 2: { |
210 | TClonesArray* digitsSSD = 0; |
211 | map<Int_t, TClonesArray*>::iterator i = fSSDmap.find(mod); |
212 | if(i == fSSDmap.end()) { |
213 | TBranch* br = fTree->GetBranch("ITSDigitsSSD"); |
214 | br->SetAddress(&digitsSSD); |
215 | br->GetEntry(mod); |
216 | |
217 | fSSDmap[mod] = digitsSSD; |
218 | return digitsSSD; |
219 | } else { |
220 | return i->second; |
221 | } |
222 | break; |
5a5a1232 |
223 | } |
6ddaaee3 |
224 | default: |
225 | return 0; |
5a5a1232 |
226 | } //end switch |
03ecfe88 |
227 | return 0; |
5a5a1232 |
228 | } |
229 | |
3d598e88 |
230 | /**************************************************************************/ |
231 | void ITSDigitsInfo::GetModuleIDs(ITSModuleSelection* sel, std::vector<UInt_t>& ids) |
232 | { |
233 | // loop SPD |
234 | Int_t idx0 = 0, idx1 = 0; |
235 | switch(sel->fType) |
236 | { |
237 | case 0: |
238 | idx0 = 0; |
239 | idx1 = fGeom->GetLastSPD(); |
240 | break; |
241 | case 1: |
242 | idx0 = fGeom->GetLastSPD(); |
243 | idx1 = fGeom->GetLastSDD(); |
244 | break; |
245 | case 2: |
246 | idx0 = fGeom->GetLastSDD(); |
247 | idx1 = fGeom->GetLastSSD(); |
248 | break; |
249 | default: |
250 | idx1 = 0; |
251 | idx1 = fGeom->GetLastSSD(); |
252 | } |
253 | |
254 | TVector3 v; |
255 | Double_t x[9]; |
256 | Int_t lay, lad, det; |
257 | ZTrans mx; |
258 | for(Int_t id = idx0; id<idx1; id++){ |
259 | fGeom->GetModuleId(id, lay, lad, det); |
260 | if(sel->fLayer==lay || sel->fLayer==-1) |
261 | { |
262 | // check data from matrix |
263 | mx.UnitTrans(); |
264 | fGeom->GetRotMatrix(id, x); |
265 | mx.SetBaseVec(1, x[0], x[3], x[6]); |
266 | mx.SetBaseVec(2, x[1], x[4], x[7]); |
267 | mx.SetBaseVec(3, x[2], x[5], x[8]); |
268 | fGeom->GetTrans(id, x); |
269 | mx.SetBaseVec(4, x); |
270 | mx.GetPos(v); |
271 | if(v.Phi()<sel->fMaxPhi && v.Phi()>sel->fMinPhi && |
272 | v.Theta()<sel->fMaxTheta && v.Theta()>sel->fMinTheta ) |
273 | ids.push_back(id); |
274 | } |
275 | } |
276 | } |
5a5a1232 |
277 | |
278 | /**************************************************************************/ |
279 | |
280 | void ITSDigitsInfo::Print(Option_t* ) const |
281 | { |
282 | printf("*********************************************************\n"); |
283 | printf("SPD module dimension (%f,%f) \n",fSegSPD->Dx()*0.0001, fSegSPD->Dz()*0.0001); |
284 | printf("SPD first,last module:: %d,%d \n", fGeom->GetStartSPD(),fGeom->GetLastSPD() ); |
285 | printf("SPD num cells per module (x::%d,z::%d)\n",fSegSPD->Npx(), fSegSPD->Npz()); |
286 | Int_t iz=0,ix = 0; |
287 | printf("SPD dimesion of (%d,%d) in pixel(%f,%f) \n", ix,iz, fSegSPD->Dpx(ix), fSegSPD->Dpz(iz)); |
288 | iz = 32; |
289 | printf("SPD dimesion of pixel (%d,%d) are (%f,%f) \n", ix,iz, fSegSPD->Dpx(ix)*0.001, fSegSPD->Dpz(iz)*0.001); |
290 | |
291 | printf("*********************************************************\n"); |
292 | printf("SDD module dimension (%f,%f) \n",fSegSDD->Dx()*0.0001, fSegSDD->Dz()*0.0001); |
293 | printf("SDD first,last module:: %d,%d \n", fGeom->GetStartSDD(),fGeom->GetLastSDD() ); |
294 | printf("SDD num cells per module (x::%d,z::%d)\n",fSegSDD->Npx(), fSegSDD->Npz()); |
295 | printf("SDD dimesion of pixel are (%f,%f) \n", fSegSDD->Dpx(1)*0.001,fSegSDD->Dpz(1)*0.001); |
296 | printf("*********************************************************\n"); |
297 | printf("SSD module dimension (%f,%f) \n",fSegSSD->Dx()*0.0001, fSegSSD->Dz()*0.0001); |
298 | printf("SSD first,last module:: %d,%d \n", fGeom->GetStartSSD(),fGeom->GetLastSSD() ); |
299 | printf("SSD strips in module %d \n",fSegSSD->Npx()); |
300 | printf("SSD strip sizes are (%f,%f) \n", fSegSSD->Dpx(1),fSegSSD->Dpz(1)); |
301 | fSegSSD->SetLayer(5); Float_t ap,an; fSegSSD->Angles(ap,an); |
302 | printf("SSD layer 5 stereoP %f stereoN %f angle \n",ap,an); |
303 | fSegSSD->SetLayer(6); fSegSSD->Angles(ap,an); |
304 | printf("SSD layer 6 stereoP %f stereoN %f angle \n",ap,an); |
305 | } |
306 | |
307 | |
308 | /* |
309 | printf("num cells %d,%d scaled %d,%d \n",fSegSPD->Npz(),fSegSPD->Npx(),Nz,Nx); |
310 | printf("%d digits in ITSModule %d\n",ne, module); |
311 | Float_t zn = i*(3.48*2)/Nz - 3.48 ; |
312 | Float_t xo = -fSegSPD->Dx()*0.00005 + fSegSPD->Dpx(0)*od->GetCoord2()*0.0001; |
313 | Float_t xn = -fSegSPD->Dx()*0.00005 + j*0.0001*fSegSPD->Dx()/Nx; |
314 | Float_t dpx = 0.0001*fSegSPD->Dx()/Nx; |
315 | Float_t dpz = 3.48*2/Nz; |
316 | printf("Z::original (%3f) scaled (%3f, %3f) \n", zo, zn-dpz/2, zn+dpz/2); |
317 | printf("X::original (%3f) scaled (%3f, %3f) \n", xo, xn-dpx/2, xn+dpx/2); |
318 | printf("%d,%d maped to %d,%d \n", od->GetCoord1(), od->GetCoord2(), i,j ); |
319 | */ |