]>
Commit | Line | Data |
---|---|---|
5a5a1232 | 1 | // $Header$ |
2 | ||
3 | //__________________________________________________________________________ | |
4 | // ITSDigitsInfo | |
5 | // | |
6 | // | |
3d598e88 | 7 | #include <TMath.h> |
8 | #include <TVector3.h> | |
5a5a1232 | 9 | |
84aff7a4 | 10 | #include <TEveTreeTools.h> |
11 | #include <TEveTrans.h> | |
5a5a1232 | 12 | |
13 | #include "ITSDigitsInfo.h" | |
5a5a1232 | 14 | #include <AliITSCalibrationSDD.h> |
15 | #include <AliITSdigit.h> | |
16 | #include <AliITSdigitSPD.h> | |
17 | ||
b3bc5327 | 18 | #include <AliRawReader.h> |
19 | #include <AliITSRawStreamSPD.h> | |
20 | #include <AliITSRawStreamSDD.h> | |
21 | #include <AliITSRawStreamSSD.h> | |
5a5a1232 | 22 | using namespace Alieve; |
23 | using namespace std; | |
24 | ||
3d598e88 | 25 | |
26 | ClassImp(ITSModuleSelection) | |
27 | ||
28 | ITSModuleSelection::ITSModuleSelection(): | |
29 | fType(-1), | |
30 | fLayer(-1), | |
32e219c2 | 31 | fMinPhi(-TMath::Pi()), |
32 | fMaxPhi(TMath::Pi()), | |
33 | fMinTheta(-TMath::Pi()), | |
34 | fMaxTheta(TMath::Pi()) | |
b3bc5327 | 35 | {} |
36 | ||
3d598e88 | 37 | |
5a5a1232 | 38 | ClassImp(ITSDigitsInfo) |
39 | ||
40 | /**************************************************************************/ | |
41 | ||
265ecb21 | 42 | ITSDigitsInfo::ITSDigitsInfo() : |
43 | TObject(), | |
84aff7a4 | 44 | TEveRefCnt(), |
265ecb21 | 45 | fSPDmap(), fSDDmap(), fSSDmap(), |
46 | fTree (0), | |
47 | fGeom (0), | |
48 | fSegSPD(0), fSegSDD(0), fSegSSD(0) | |
5a5a1232 | 49 | { |
b3bc5327 | 50 | InitInternals(); |
5a5a1232 | 51 | } |
52 | ||
b3bc5327 | 53 | void ITSDigitsInfo::InitInternals() |
5a5a1232 | 54 | { |
84aff7a4 | 55 | static const TEveException eH("ITSDigitsInfo::InitInternals "); |
5a5a1232 | 56 | |
b3bc5327 | 57 | fGeom = new AliITSgeom(); |
58 | fGeom->ReadNewFile("$REVESYS/alice-data/ITSgeometry.det"); | |
59 | if(fGeom == 0) | |
60 | throw(eH + "can not load ITS geometry \n"); | |
5a5a1232 | 61 | |
62 | SetITSSegmentation(); | |
d4b6a94c | 63 | |
5a5a1232 | 64 | // create tables for scaling |
d4b6a94c | 65 | fSPDMinVal = 0; |
66 | fSDDMinVal = 5; | |
67 | fSSDMinVal = 2; | |
68 | ||
69 | fSPDMaxVal = 1; | |
70 | fSDDMaxVal = 80; | |
71 | fSSDMaxVal = 100; | |
72 | ||
32e219c2 | 73 | fSPDHighLim = 1; |
74 | fSDDHighLim = 512; | |
75 | fSSDHighLim = 1024; | |
d4b6a94c | 76 | |
d54c094e | 77 | // lowest scale factor refers to unscaled ITS module |
78 | fSPDScaleX[0] = 1; | |
79 | fSPDScaleZ[0] = 1; | |
80 | fSDDScaleX[0] = 1; | |
81 | fSDDScaleZ[0] = 1; | |
82 | fSSDScale [0] = 1; | |
d4b6a94c | 83 | |
b3bc5327 | 84 | // spd lowest resolution |
5a5a1232 | 85 | Int_t nx = 8; // fSegSPD->Npx()/8; // 32 |
86 | Int_t nz = 6; // fSegSPD->Npz()/2; // 128 | |
5a5a1232 | 87 | fSPDScaleX[1] = Int_t(nx); |
88 | fSPDScaleZ[1] = Int_t(nz); | |
89 | fSPDScaleX[2] = Int_t(nx*2); | |
90 | fSPDScaleZ[2] = Int_t(nz*2); | |
91 | fSPDScaleX[3] = Int_t(nx*3); | |
92 | fSPDScaleZ[3] = Int_t(nz*3); | |
93 | fSPDScaleX[4] = Int_t(nx*4); | |
94 | fSPDScaleZ[4] = Int_t(nz*4); | |
95 | ||
5a5a1232 | 96 | fSDDScaleX[1] = 2; |
97 | fSDDScaleZ[1] = 2; | |
98 | fSDDScaleX[2] = 8; | |
99 | fSDDScaleZ[2] = 8; | |
100 | fSDDScaleX[3] = 16; | |
101 | fSDDScaleZ[3] = 16; | |
102 | fSDDScaleX[4] = 25; | |
103 | fSDDScaleZ[4] = 25; | |
104 | ||
105 | fSSDScale[1] = 3; | |
106 | fSSDScale[2] = 9; | |
107 | fSSDScale[3] = 20; | |
108 | fSSDScale[4] = 30; | |
5a5a1232 | 109 | } |
110 | ||
111 | /**************************************************************************/ | |
112 | ||
b3bc5327 | 113 | ITSDigitsInfo:: ~ITSDigitsInfo() |
114 | { | |
115 | map<Int_t, TClonesArray*>::iterator j; | |
116 | for(j = fSPDmap.begin(); j != fSPDmap.end(); ++j) | |
117 | delete j->second; | |
118 | for(j = fSDDmap.begin(); j != fSDDmap.end(); ++j) | |
119 | delete j->second; | |
120 | for(j = fSSDmap.begin(); j != fSSDmap.end(); ++j) | |
121 | delete j->second; | |
122 | ||
123 | delete fSegSPD; delete fSegSDD; delete fSegSSD; | |
124 | delete fGeom; | |
125 | delete fTree; | |
126 | } | |
127 | ||
128 | /**************************************************************************/ | |
129 | ||
130 | void ITSDigitsInfo::SetTree(TTree* tree) | |
131 | { | |
132 | // Set digit-tree to be used for digit retrieval. Data is loaded on | |
133 | // demand. | |
134 | ||
135 | fTree = tree; | |
136 | } | |
137 | ||
540e156e | 138 | void ITSDigitsInfo::ReadRaw(AliRawReader* raw, Int_t mode) |
b3bc5327 | 139 | { |
140 | // Read raw-data into internal structures. AliITSdigit is used to | |
141 | // store raw-adata for all sub-detectors. | |
142 | ||
540e156e | 143 | if ((mode & 1) || (mode & 2)){ |
b3bc5327 | 144 | AliITSRawStreamSPD inputSPD(raw); |
145 | TClonesArray* digits = 0; | |
b3bc5327 | 146 | while (inputSPD.Next()) |
147 | { | |
148 | Int_t module = inputSPD.GetModuleID(); | |
149 | Int_t column = inputSPD.GetColumn(); | |
150 | Int_t row = inputSPD.GetRow(); | |
151 | ||
152 | if (inputSPD.IsNewModule()) | |
153 | { | |
f8495fba | 154 | digits = fSPDmap[module]; |
155 | if (digits == 0) | |
156 | fSPDmap[module] = digits = new TClonesArray("AliITSdigit", 16); | |
b3bc5327 | 157 | } |
158 | ||
f8495fba | 159 | AliITSdigit* d = new ((*digits)[digits->GetEntriesFast()]) AliITSdigit(); |
b3bc5327 | 160 | d->SetCoord1(column); |
161 | d->SetCoord2(row); | |
162 | d->SetSignal(1); | |
b3bc5327 | 163 | |
164 | // printf("SPD: %d %d %d\n",module,column,row); | |
165 | } | |
b3bc5327 | 166 | raw->Reset(); |
167 | } | |
168 | ||
540e156e | 169 | if ((mode & 4) || (mode & 8)){ |
b3bc5327 | 170 | AliITSRawStreamSDD input(raw); |
171 | TClonesArray* digits = 0; | |
b3bc5327 | 172 | while (input.Next()) |
173 | { | |
174 | Int_t module = input.GetModuleID(); | |
175 | Int_t anode = input.GetAnode(); | |
176 | Int_t time = input.GetTime(); | |
177 | Int_t signal = input.GetSignal(); | |
178 | ||
179 | if (input.IsNewModule()) | |
180 | { | |
f8495fba | 181 | digits = fSDDmap[module]; |
182 | if (digits == 0) | |
183 | fSDDmap[module] = digits = new TClonesArray("AliITSdigit", 0); | |
b3bc5327 | 184 | } |
185 | ||
f8495fba | 186 | AliITSdigit* d = new ((*digits)[digits->GetEntriesFast()]) AliITSdigit(); |
b3bc5327 | 187 | d->SetCoord1(anode); |
188 | d->SetCoord2(time); | |
189 | d->SetSignal(signal); | |
b3bc5327 | 190 | |
191 | // printf("SDD: %d %d %d %d\n",module,anode,time,signal); | |
192 | } | |
b3bc5327 | 193 | raw->Reset(); |
194 | } | |
195 | ||
540e156e | 196 | if ((mode & 16) || (mode & 32)){ |
b3bc5327 | 197 | AliITSRawStreamSSD input(raw); |
198 | TClonesArray* digits = 0; | |
b3bc5327 | 199 | while (input.Next()) |
200 | { | |
201 | Int_t module = input.GetModuleID(); | |
202 | Int_t side = input.GetSideFlag(); | |
203 | Int_t strip = input.GetStrip(); | |
204 | Int_t signal = input.GetSignal(); | |
205 | ||
206 | if (input.IsNewModule()) | |
207 | { | |
f8495fba | 208 | digits = fSSDmap[module]; |
209 | if (digits == 0) | |
210 | fSSDmap[module] = digits = new TClonesArray("AliITSdigit", 0); | |
b3bc5327 | 211 | } |
212 | ||
f8495fba | 213 | AliITSdigit* d = new ((*digits)[digits->GetEntriesFast()]) AliITSdigit(); |
b3bc5327 | 214 | d->SetCoord1(side); |
215 | d->SetCoord2(strip); | |
216 | d->SetSignal(signal); | |
b3bc5327 | 217 | |
218 | // printf("SSD: %d %d %d %d\n",module,side,strip,signal); | |
219 | } | |
b3bc5327 | 220 | raw->Reset(); |
221 | } | |
222 | } | |
223 | ||
224 | /**************************************************************************/ | |
225 | ||
5a5a1232 | 226 | void ITSDigitsInfo::SetITSSegmentation() |
227 | { | |
228 | // SPD | |
229 | fSegSPD = new AliITSsegmentationSPD(fGeom); | |
230 | //SPD geometry | |
231 | Int_t m; | |
232 | Float_t fNzSPD=160; | |
233 | Float_t fZ1pitchSPD=0.0425; Float_t fZ2pitchSPD=0.0625; | |
234 | Float_t fHlSPD=3.48; | |
235 | ||
236 | fSPDZCoord[0]=fZ1pitchSPD -fHlSPD; | |
237 | for (m=1; m<fNzSPD; m++) { | |
238 | Double_t dz=fZ1pitchSPD; | |
239 | if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 || | |
240 | m==127 || m==128) dz=fZ2pitchSPD; | |
241 | fSPDZCoord[m]=fSPDZCoord[m-1]+dz; | |
242 | } | |
243 | ||
244 | for (m=0; m<fNzSPD; m++) { | |
245 | Double_t dz=1.*fZ1pitchSPD; | |
246 | if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 || | |
247 | m==127 || m==128) dz=1.*fZ2pitchSPD; | |
248 | fSPDZCoord[m]-=dz; | |
249 | } | |
250 | ||
251 | // end of SPD geometry | |
252 | ||
253 | // SDD | |
b85e8cbd | 254 | fSegSDD = new AliITSsegmentationSDD(fGeom); |
5a5a1232 | 255 | |
256 | // SSD | |
257 | fSegSSD = new AliITSsegmentationSSD(fGeom); | |
258 | } | |
259 | ||
260 | void ITSDigitsInfo::GetSPDLocalZ(Int_t j, Float_t& z) | |
261 | { | |
262 | z = fSPDZCoord[j]; | |
263 | } | |
264 | ||
265 | /**************************************************************************/ | |
266 | ||
267 | TClonesArray* ITSDigitsInfo::GetDigits(Int_t mod, Int_t subdet) | |
268 | { | |
269 | switch(subdet) { | |
6ddaaee3 | 270 | case 0: { |
271 | TClonesArray* digitsSPD = 0; | |
272 | map<Int_t, TClonesArray*>::iterator i = fSPDmap.find(mod); | |
273 | if(i == fSPDmap.end()) { | |
540e156e | 274 | if (fTree) { |
275 | TBranch* br = fTree->GetBranch("ITSDigitsSPD"); | |
276 | br->SetAddress(&digitsSPD); | |
277 | br->GetEntry(mod); | |
278 | fSPDmap[mod] = digitsSPD; | |
279 | return digitsSPD; | |
280 | } | |
281 | else | |
282 | return NULL; | |
6ddaaee3 | 283 | } else { |
284 | return i->second; | |
285 | } | |
286 | break; | |
5a5a1232 | 287 | } |
6ddaaee3 | 288 | case 1: { |
289 | TClonesArray* digitsSDD = 0; | |
290 | map<Int_t, TClonesArray*>::iterator i = fSDDmap.find(mod); | |
291 | if(i == fSDDmap.end()) { | |
540e156e | 292 | if (fTree) { |
293 | TBranch* br = fTree->GetBranch("ITSDigitsSDD"); | |
294 | br->SetAddress(&digitsSDD); | |
295 | br->GetEntry(mod); | |
296 | fSDDmap[mod] = digitsSDD; | |
297 | return digitsSDD; | |
298 | } | |
299 | else | |
300 | return NULL; | |
301 | } else { | |
6ddaaee3 | 302 | return i->second; |
303 | } | |
304 | break; | |
5a5a1232 | 305 | } |
6ddaaee3 | 306 | case 2: { |
307 | TClonesArray* digitsSSD = 0; | |
308 | map<Int_t, TClonesArray*>::iterator i = fSSDmap.find(mod); | |
309 | if(i == fSSDmap.end()) { | |
540e156e | 310 | if (fTree) { |
311 | TBranch* br = fTree->GetBranch("ITSDigitsSSD"); | |
312 | br->SetAddress(&digitsSSD); | |
313 | br->GetEntry(mod); | |
314 | ||
315 | fSSDmap[mod] = digitsSSD; | |
316 | return digitsSSD; | |
317 | } | |
318 | else | |
319 | return NULL; | |
320 | } else { | |
6ddaaee3 | 321 | return i->second; |
322 | } | |
323 | break; | |
5a5a1232 | 324 | } |
6ddaaee3 | 325 | default: |
326 | return 0; | |
5a5a1232 | 327 | } //end switch |
03ecfe88 | 328 | return 0; |
5a5a1232 | 329 | } |
330 | ||
3d598e88 | 331 | /**************************************************************************/ |
332 | void ITSDigitsInfo::GetModuleIDs(ITSModuleSelection* sel, std::vector<UInt_t>& ids) | |
333 | { | |
334 | // loop SPD | |
335 | Int_t idx0 = 0, idx1 = 0; | |
336 | switch(sel->fType) | |
337 | { | |
338 | case 0: | |
339 | idx0 = 0; | |
340 | idx1 = fGeom->GetLastSPD(); | |
341 | break; | |
342 | case 1: | |
32e219c2 | 343 | idx0 = fGeom->GetLastSPD()+1; |
3d598e88 | 344 | idx1 = fGeom->GetLastSDD(); |
345 | break; | |
346 | case 2: | |
32e219c2 | 347 | idx0 = fGeom->GetLastSDD()+1; |
3d598e88 | 348 | idx1 = fGeom->GetLastSSD(); |
349 | break; | |
350 | default: | |
351 | idx1 = 0; | |
352 | idx1 = fGeom->GetLastSSD(); | |
353 | } | |
354 | ||
355 | TVector3 v; | |
356 | Double_t x[9]; | |
357 | Int_t lay, lad, det; | |
84aff7a4 | 358 | TEveTrans mx; |
3d598e88 | 359 | for(Int_t id = idx0; id<idx1; id++){ |
360 | fGeom->GetModuleId(id, lay, lad, det); | |
361 | if(sel->fLayer==lay || sel->fLayer==-1) | |
362 | { | |
363 | // check data from matrix | |
364 | mx.UnitTrans(); | |
365 | fGeom->GetRotMatrix(id, x); | |
366 | mx.SetBaseVec(1, x[0], x[3], x[6]); | |
367 | mx.SetBaseVec(2, x[1], x[4], x[7]); | |
368 | mx.SetBaseVec(3, x[2], x[5], x[8]); | |
369 | fGeom->GetTrans(id, x); | |
370 | mx.SetBaseVec(4, x); | |
371 | mx.GetPos(v); | |
32e219c2 | 372 | if(v.Phi()<=sel->fMaxPhi && v.Phi()>=sel->fMinPhi && |
373 | v.Theta()<=sel->fMaxTheta && v.Theta()>=sel->fMinTheta ) | |
3d598e88 | 374 | ids.push_back(id); |
375 | } | |
376 | } | |
377 | } | |
5a5a1232 | 378 | |
379 | /**************************************************************************/ | |
380 | ||
381 | void ITSDigitsInfo::Print(Option_t* ) const | |
382 | { | |
383 | printf("*********************************************************\n"); | |
384 | printf("SPD module dimension (%f,%f) \n",fSegSPD->Dx()*0.0001, fSegSPD->Dz()*0.0001); | |
385 | printf("SPD first,last module:: %d,%d \n", fGeom->GetStartSPD(),fGeom->GetLastSPD() ); | |
386 | printf("SPD num cells per module (x::%d,z::%d)\n",fSegSPD->Npx(), fSegSPD->Npz()); | |
387 | Int_t iz=0,ix = 0; | |
388 | printf("SPD dimesion of (%d,%d) in pixel(%f,%f) \n", ix,iz, fSegSPD->Dpx(ix), fSegSPD->Dpz(iz)); | |
389 | iz = 32; | |
390 | printf("SPD dimesion of pixel (%d,%d) are (%f,%f) \n", ix,iz, fSegSPD->Dpx(ix)*0.001, fSegSPD->Dpz(iz)*0.001); | |
391 | ||
392 | printf("*********************************************************\n"); | |
393 | printf("SDD module dimension (%f,%f) \n",fSegSDD->Dx()*0.0001, fSegSDD->Dz()*0.0001); | |
394 | printf("SDD first,last module:: %d,%d \n", fGeom->GetStartSDD(),fGeom->GetLastSDD() ); | |
395 | printf("SDD num cells per module (x::%d,z::%d)\n",fSegSDD->Npx(), fSegSDD->Npz()); | |
396 | printf("SDD dimesion of pixel are (%f,%f) \n", fSegSDD->Dpx(1)*0.001,fSegSDD->Dpz(1)*0.001); | |
397 | printf("*********************************************************\n"); | |
398 | printf("SSD module dimension (%f,%f) \n",fSegSSD->Dx()*0.0001, fSegSSD->Dz()*0.0001); | |
399 | printf("SSD first,last module:: %d,%d \n", fGeom->GetStartSSD(),fGeom->GetLastSSD() ); | |
400 | printf("SSD strips in module %d \n",fSegSSD->Npx()); | |
401 | printf("SSD strip sizes are (%f,%f) \n", fSegSSD->Dpx(1),fSegSSD->Dpz(1)); | |
402 | fSegSSD->SetLayer(5); Float_t ap,an; fSegSSD->Angles(ap,an); | |
403 | printf("SSD layer 5 stereoP %f stereoN %f angle \n",ap,an); | |
404 | fSegSSD->SetLayer(6); fSegSSD->Angles(ap,an); | |
405 | printf("SSD layer 6 stereoP %f stereoN %f angle \n",ap,an); | |
406 | } | |
407 | ||
408 | ||
409 | /* | |
410 | printf("num cells %d,%d scaled %d,%d \n",fSegSPD->Npz(),fSegSPD->Npx(),Nz,Nx); | |
411 | printf("%d digits in ITSModule %d\n",ne, module); | |
412 | Float_t zn = i*(3.48*2)/Nz - 3.48 ; | |
413 | Float_t xo = -fSegSPD->Dx()*0.00005 + fSegSPD->Dpx(0)*od->GetCoord2()*0.0001; | |
414 | Float_t xn = -fSegSPD->Dx()*0.00005 + j*0.0001*fSegSPD->Dx()/Nx; | |
415 | Float_t dpx = 0.0001*fSegSPD->Dx()/Nx; | |
416 | Float_t dpz = 3.48*2/Nz; | |
417 | printf("Z::original (%3f) scaled (%3f, %3f) \n", zo, zn-dpz/2, zn+dpz/2); | |
418 | printf("X::original (%3f) scaled (%3f, %3f) \n", xo, xn-dpx/2, xn+dpx/2); | |
419 | printf("%d,%d maped to %d,%d \n", od->GetCoord1(), od->GetCoord2(), i,j ); | |
420 | */ |