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