2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
4 /**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
13 #include <TEveTreeTools.h>
14 #include <TEveTrans.h>
16 #include "AliEveITSDigitsInfo.h"
17 #include <AliITSCalibrationSDD.h>
18 #include <AliITSdigit.h>
19 #include <AliITSdigitSPD.h>
21 #include <AliRawReader.h>
22 #include <AliITSRawStreamSPD.h>
23 #include <AliITSRawStreamSDD.h>
24 #include <AliITSRawStreamSSD.h>
26 //______________________________________________________________________________
28 // Helper for selecting a range of ITS modules by type, layer, phi and
29 // theta. Taken as an argument to AliEveITSDigitsInfo::GetModuleIDs().
31 ClassImp(AliEveITSModuleSelection)
33 AliEveITSModuleSelection::AliEveITSModuleSelection():
36 fMinPhi(-TMath::Pi()),
38 fMinTheta(-TMath::Pi()),
39 fMaxTheta(TMath::Pi())
45 //______________________________________________________________________________
47 // Stores ITS geometry information and event-data in format suitable
50 ClassImp(AliEveITSDigitsInfo)
52 /******************************************************************************/
54 AliEveITSDigitsInfo::AliEveITSDigitsInfo() :
57 fSPDmap(), fSDDmap(), fSSDmap(),
60 fSegSPD (0), fSegSDD (0), fSegSSD (0),
61 fSPDMinVal (0), fSSDMinVal (0), fSDDMinVal (0),
62 fSPDMaxVal (0), fSSDMaxVal (0), fSDDMaxVal (0),
63 fSPDHighLim (0), fSDDHighLim (0), fSSDHighLim (0)
65 // Default constructor.
70 void AliEveITSDigitsInfo::InitInternals()
72 // Initialize internal geometry structures, in particular the
73 // module-id to transformation-matrix mapping and segmentation
74 // classes and data-structures.
76 static const TEveException eH("AliEveITSDigitsInfo::InitInternals ");
78 fGeom = new AliITSgeom();
79 fGeom->ReadNewFile("$REVESYS/alice-data/ITSgeometry.det");
81 throw(eH + "can not load ITS geometry \n");
85 // create tables for scaling
98 // lowest scale factor refers to unscaled ITS module
105 // spd lowest resolution
106 Int_t nx = 8; // fSegSPD->Npx()/8; // 32
107 Int_t nz = 6; // fSegSPD->Npz()/2; // 128
108 fSPDScaleX[1] = Int_t(nx);
109 fSPDScaleZ[1] = Int_t(nz);
110 fSPDScaleX[2] = Int_t(nx*2);
111 fSPDScaleZ[2] = Int_t(nz*2);
112 fSPDScaleX[3] = Int_t(nx*3);
113 fSPDScaleZ[3] = Int_t(nz*3);
114 fSPDScaleX[4] = Int_t(nx*4);
115 fSPDScaleZ[4] = Int_t(nz*4);
132 /******************************************************************************/
134 AliEveITSDigitsInfo:: ~AliEveITSDigitsInfo()
137 // Deletes the data-maps and the tree.
139 std::map<Int_t, TClonesArray*>::iterator j;
140 for(j = fSPDmap.begin(); j != fSPDmap.end(); ++j)
142 for(j = fSDDmap.begin(); j != fSDDmap.end(); ++j)
144 for(j = fSSDmap.begin(); j != fSSDmap.end(); ++j)
147 delete fSegSPD; delete fSegSDD; delete fSegSSD;
152 /******************************************************************************/
154 void AliEveITSDigitsInfo::SetTree(TTree* tree)
156 // Set digit-tree to be used for digit retrieval. Data is loaded on
162 void AliEveITSDigitsInfo::ReadRaw(AliRawReader* raw, Int_t mode)
164 // Read raw-data into internal structures. AliITSdigit is used to
165 // store raw-adata for all sub-detectors.
167 if ((mode & 1) || (mode & 2)){
168 AliITSRawStreamSPD inputSPD(raw);
169 TClonesArray* digits = 0;
170 while (inputSPD.Next())
172 Int_t module = inputSPD.GetModuleID();
173 Int_t column = inputSPD.GetColumn();
174 Int_t row = inputSPD.GetRow();
176 if (inputSPD.IsNewModule())
178 digits = fSPDmap[module];
180 fSPDmap[module] = digits = new TClonesArray("AliITSdigit", 16);
183 AliITSdigit* d = new ((*digits)[digits->GetEntriesFast()]) AliITSdigit();
184 d->SetCoord1(column);
188 // printf("SPD: %d %d %d\n",module,column,row);
193 if ((mode & 4) || (mode & 8)){
194 AliITSRawStreamSDD input(raw);
195 TClonesArray* digits = 0;
198 Int_t module = input.GetModuleID();
199 Int_t anode = input.GetAnode();
200 Int_t time = input.GetTime();
201 Int_t signal = input.GetSignal();
203 if (input.IsNewModule())
205 digits = fSDDmap[module];
207 fSDDmap[module] = digits = new TClonesArray("AliITSdigit", 0);
210 AliITSdigit* d = new ((*digits)[digits->GetEntriesFast()]) AliITSdigit();
213 d->SetSignal(signal);
215 // printf("SDD: %d %d %d %d\n",module,anode,time,signal);
220 if ((mode & 16) || (mode & 32)){
221 AliITSRawStreamSSD input(raw);
222 TClonesArray* digits = 0;
225 Int_t module = input.GetModuleID();
226 Int_t side = input.GetSideFlag();
227 Int_t strip = input.GetStrip();
228 Int_t signal = input.GetSignal();
230 if (input.IsNewModule())
232 digits = fSSDmap[module];
234 fSSDmap[module] = digits = new TClonesArray("AliITSdigit", 0);
237 AliITSdigit* d = new ((*digits)[digits->GetEntriesFast()]) AliITSdigit();
240 d->SetSignal(signal);
242 // printf("SSD: %d %d %d %d\n",module,side,strip,signal);
248 /******************************************************************************/
250 void AliEveITSDigitsInfo::SetITSSegmentation()
252 // Create the segmentation objects and fill internal
256 fSegSPD = new AliITSsegmentationSPD(fGeom);
260 Float_t fZ1pitchSPD=0.0425; Float_t fZ2pitchSPD=0.0625;
263 fSPDZCoord[0]=fZ1pitchSPD -fHlSPD;
264 for (m=1; m<fNzSPD; m++) {
265 Double_t dz=fZ1pitchSPD;
266 if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 ||
267 m==127 || m==128) dz=fZ2pitchSPD;
268 fSPDZCoord[m]=fSPDZCoord[m-1]+dz;
271 for (m=0; m<fNzSPD; m++) {
272 Double_t dz=1.*fZ1pitchSPD;
273 if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 ||
274 m==127 || m==128) dz=1.*fZ2pitchSPD;
279 fSegSDD = new AliITSsegmentationSDD(fGeom);
282 fSegSSD = new AliITSsegmentationSSD(fGeom);
285 /******************************************************************************/
287 TClonesArray* AliEveITSDigitsInfo::GetDigits(Int_t mod, Int_t subdet)
289 // Return TClonesArray of digits for specified module and sub-detector-id.
295 TClonesArray* digitsSPD = 0;
296 std::map<Int_t, TClonesArray*>::iterator i = fSPDmap.find(mod);
297 if (i == fSPDmap.end()) {
299 TBranch* br = fTree->GetBranch("ITSDigitsSPD");
300 br->SetAddress(&digitsSPD);
302 fSPDmap[mod] = digitsSPD;
314 TClonesArray* digitsSDD = 0;
315 std::map<Int_t, TClonesArray*>::iterator i = fSDDmap.find(mod);
316 if (i == fSDDmap.end()) {
318 TBranch* br = fTree->GetBranch("ITSDigitsSDD");
319 br->SetAddress(&digitsSDD);
321 fSDDmap[mod] = digitsSDD;
333 TClonesArray* digitsSSD = 0;
334 std::map<Int_t, TClonesArray*>::iterator i = fSSDmap.find(mod);
335 if (i == fSSDmap.end()) {
337 TBranch* br = fTree->GetBranch("ITSDigitsSSD");
338 br->SetAddress(&digitsSSD);
341 fSSDmap[mod] = digitsSSD;
357 /******************************************************************************/
359 void AliEveITSDigitsInfo::GetModuleIDs(AliEveITSModuleSelection* sel,
360 std::vector<UInt_t>& ids)
362 // Fill the id-vector with ids of modules that satisfy conditions
363 // given by the AliEveITSModuleSelection object.
365 Int_t idx0 = 0, idx1 = 0;
366 switch(sel->GetType())
370 idx1 = fGeom->GetLastSPD();
373 idx0 = fGeom->GetLastSPD()+1;
374 idx1 = fGeom->GetLastSDD();
377 idx0 = fGeom->GetLastSDD()+1;
378 idx1 = fGeom->GetLastSSD();
382 idx1 = fGeom->GetLastSSD();
390 for (Int_t id = idx0; id<idx1; ++id)
392 fGeom->GetModuleId(id, lay, lad, det);
393 if (sel->GetLayer() == lay || sel->GetLayer() == -1)
395 // check data from matrix
397 fGeom->GetRotMatrix(id, x);
398 mx.SetBaseVec(1, x[0], x[3], x[6]);
399 mx.SetBaseVec(2, x[1], x[4], x[7]);
400 mx.SetBaseVec(3, x[2], x[5], x[8]);
401 fGeom->GetTrans(id, x);
404 if (v.Phi() <= sel->GetMaxPhi() && v.Phi() >= sel->GetMinPhi() &&
405 v.Theta() <= sel->GetMaxTheta() && v.Theta() >= sel->GetMinTheta())
413 /******************************************************************************/
415 void AliEveITSDigitsInfo::Print(Option_t* ) const
417 // Print information about stored geometry and segmentation.
419 printf("*********************************************************\n");
420 printf("SPD module dimension (%f,%f)\n", fSegSPD->Dx()*0.0001, fSegSPD->Dz()*0.0001);
421 printf("SPD first,last module:: %d,%d\n", fGeom->GetStartSPD(), fGeom->GetLastSPD() );
422 printf("SPD num cells per module (x::%d,z::%d)\n", fSegSPD->Npx(), fSegSPD->Npz());
423 Int_t iz = 0, ix = 0;
424 printf("SPD dimesion of (%d,%d) in pixel(%f,%f)\n", ix, iz, fSegSPD->Dpx(ix), fSegSPD->Dpz(iz));
426 printf("SPD dimesion of pixel (%d,%d) are (%f,%f)\n", ix, iz, fSegSPD->Dpx(ix)*0.001, fSegSPD->Dpz(iz)*0.001);
428 printf("*********************************************************\n");
429 printf("SDD module dimension (%f,%f)\n", fSegSDD->Dx()*0.0001, fSegSDD->Dz()*0.0001);
430 printf("SDD first,last module:: %d,%d\n", fGeom->GetStartSDD(), fGeom->GetLastSDD());
431 printf("SDD num cells per module (x::%d,z::%d)\n", fSegSDD->Npx(), fSegSDD->Npz());
432 printf("SDD dimesion of pixel are (%f,%f)\n", fSegSDD->Dpx(1)*0.001, fSegSDD->Dpz(1)*0.001);
435 printf("*********************************************************\n");
436 printf("SSD module dimension (%f,%f)\n", fSegSSD->Dx()*0.0001, fSegSSD->Dz()*0.0001);
437 printf("SSD first,last module:: %d,%d\n", fGeom->GetStartSSD(), fGeom->GetLastSSD() );
438 printf("SSD strips in module %d\n", fSegSSD->Npx());
439 printf("SSD strip sizes are (%f,%f)\n", fSegSSD->Dpx(1), fSegSSD->Dpz(1));
440 fSegSSD->SetLayer(5); fSegSSD->Angles(ap,an);
441 printf("SSD layer 5 stereoP %f stereoN %f angle\n", ap, an);
442 fSegSSD->SetLayer(6); fSegSSD->Angles(ap,an);
443 printf("SSD layer 6 stereoP %f stereoN %f angle\n", ap, an);
448 printf("num cells %d,%d scaled %d,%d \n",fSegSPD->Npz(),fSegSPD->Npx(),Nz,Nx);
449 printf("%d digits in AliEveITSModule %d\n",ne, module);
450 Float_t zn = i*(3.48*2)/Nz - 3.48 ;
451 Float_t xo = -fSegSPD->Dx()*0.00005 + fSegSPD->Dpx(0)*od->GetCoord2()*0.0001;
452 Float_t xn = -fSegSPD->Dx()*0.00005 + j*0.0001*fSegSPD->Dx()/Nx;
453 Float_t dpx = 0.0001*fSegSPD->Dx()/Nx;
454 Float_t dpz = 3.48*2/Nz;
455 printf("Z::original (%3f) scaled (%3f, %3f) \n", zo, zn-dpz/2, zn+dpz/2);
456 printf("X::original (%3f) scaled (%3f, %3f) \n", xo, xn-dpx/2, xn+dpx/2);
457 printf("%d,%d maped to %d,%d \n", od->GetCoord1(), od->GetCoord2(), i,j );