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)
62 // Default constructor.
67 void AliEveITSDigitsInfo::InitInternals()
69 // Initialize internal geometry structures, in particular the
70 // module-id to transformation-matrix mapping and segmentation
71 // classes and data-structures.
73 static const TEveException eH("AliEveITSDigitsInfo::InitInternals ");
75 fGeom = new AliITSgeom();
76 fGeom->ReadNewFile("$REVESYS/alice-data/ITSgeometry.det");
78 throw(eH + "can not load ITS geometry \n");
82 // create tables for scaling
95 // lowest scale factor refers to unscaled ITS module
102 // spd lowest resolution
103 Int_t nx = 8; // fSegSPD->Npx()/8; // 32
104 Int_t nz = 6; // fSegSPD->Npz()/2; // 128
105 fSPDScaleX[1] = Int_t(nx);
106 fSPDScaleZ[1] = Int_t(nz);
107 fSPDScaleX[2] = Int_t(nx*2);
108 fSPDScaleZ[2] = Int_t(nz*2);
109 fSPDScaleX[3] = Int_t(nx*3);
110 fSPDScaleZ[3] = Int_t(nz*3);
111 fSPDScaleX[4] = Int_t(nx*4);
112 fSPDScaleZ[4] = Int_t(nz*4);
129 /******************************************************************************/
131 AliEveITSDigitsInfo:: ~AliEveITSDigitsInfo()
134 // Deletes the data-maps and the tree.
136 map<Int_t, TClonesArray*>::iterator j;
137 for(j = fSPDmap.begin(); j != fSPDmap.end(); ++j)
139 for(j = fSDDmap.begin(); j != fSDDmap.end(); ++j)
141 for(j = fSSDmap.begin(); j != fSSDmap.end(); ++j)
144 delete fSegSPD; delete fSegSDD; delete fSegSSD;
149 /******************************************************************************/
151 void AliEveITSDigitsInfo::SetTree(TTree* tree)
153 // Set digit-tree to be used for digit retrieval. Data is loaded on
159 void AliEveITSDigitsInfo::ReadRaw(AliRawReader* raw, Int_t mode)
161 // Read raw-data into internal structures. AliITSdigit is used to
162 // store raw-adata for all sub-detectors.
164 if ((mode & 1) || (mode & 2)){
165 AliITSRawStreamSPD inputSPD(raw);
166 TClonesArray* digits = 0;
167 while (inputSPD.Next())
169 Int_t module = inputSPD.GetModuleID();
170 Int_t column = inputSPD.GetColumn();
171 Int_t row = inputSPD.GetRow();
173 if (inputSPD.IsNewModule())
175 digits = fSPDmap[module];
177 fSPDmap[module] = digits = new TClonesArray("AliITSdigit", 16);
180 AliITSdigit* d = new ((*digits)[digits->GetEntriesFast()]) AliITSdigit();
181 d->SetCoord1(column);
185 // printf("SPD: %d %d %d\n",module,column,row);
190 if ((mode & 4) || (mode & 8)){
191 AliITSRawStreamSDD input(raw);
192 TClonesArray* digits = 0;
195 Int_t module = input.GetModuleID();
196 Int_t anode = input.GetAnode();
197 Int_t time = input.GetTime();
198 Int_t signal = input.GetSignal();
200 if (input.IsNewModule())
202 digits = fSDDmap[module];
204 fSDDmap[module] = digits = new TClonesArray("AliITSdigit", 0);
207 AliITSdigit* d = new ((*digits)[digits->GetEntriesFast()]) AliITSdigit();
210 d->SetSignal(signal);
212 // printf("SDD: %d %d %d %d\n",module,anode,time,signal);
217 if ((mode & 16) || (mode & 32)){
218 AliITSRawStreamSSD input(raw);
219 TClonesArray* digits = 0;
222 Int_t module = input.GetModuleID();
223 Int_t side = input.GetSideFlag();
224 Int_t strip = input.GetStrip();
225 Int_t signal = input.GetSignal();
227 if (input.IsNewModule())
229 digits = fSSDmap[module];
231 fSSDmap[module] = digits = new TClonesArray("AliITSdigit", 0);
234 AliITSdigit* d = new ((*digits)[digits->GetEntriesFast()]) AliITSdigit();
237 d->SetSignal(signal);
239 // printf("SSD: %d %d %d %d\n",module,side,strip,signal);
245 /******************************************************************************/
247 void AliEveITSDigitsInfo::SetITSSegmentation()
249 // Create the segmentation objects and fill internal
253 fSegSPD = new AliITSsegmentationSPD(fGeom);
257 Float_t fZ1pitchSPD=0.0425; Float_t fZ2pitchSPD=0.0625;
260 fSPDZCoord[0]=fZ1pitchSPD -fHlSPD;
261 for (m=1; m<fNzSPD; m++) {
262 Double_t dz=fZ1pitchSPD;
263 if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 ||
264 m==127 || m==128) dz=fZ2pitchSPD;
265 fSPDZCoord[m]=fSPDZCoord[m-1]+dz;
268 for (m=0; m<fNzSPD; m++) {
269 Double_t dz=1.*fZ1pitchSPD;
270 if (m==31 || m==32 || m==63 || m==64 || m==95 || m==96 ||
271 m==127 || m==128) dz=1.*fZ2pitchSPD;
276 fSegSDD = new AliITSsegmentationSDD(fGeom);
279 fSegSSD = new AliITSsegmentationSSD(fGeom);
282 /******************************************************************************/
284 TClonesArray* AliEveITSDigitsInfo::GetDigits(Int_t mod, Int_t subdet)
286 // Return TClonesArray of digits for specified module and sub-detector-id.
292 TClonesArray* digitsSPD = 0;
293 map<Int_t, TClonesArray*>::iterator i = fSPDmap.find(mod);
294 if (i == fSPDmap.end()) {
296 TBranch* br = fTree->GetBranch("ITSDigitsSPD");
297 br->SetAddress(&digitsSPD);
299 fSPDmap[mod] = digitsSPD;
311 TClonesArray* digitsSDD = 0;
312 map<Int_t, TClonesArray*>::iterator i = fSDDmap.find(mod);
313 if (i == fSDDmap.end()) {
315 TBranch* br = fTree->GetBranch("ITSDigitsSDD");
316 br->SetAddress(&digitsSDD);
318 fSDDmap[mod] = digitsSDD;
330 TClonesArray* digitsSSD = 0;
331 map<Int_t, TClonesArray*>::iterator i = fSSDmap.find(mod);
332 if (i == fSSDmap.end()) {
334 TBranch* br = fTree->GetBranch("ITSDigitsSSD");
335 br->SetAddress(&digitsSSD);
338 fSSDmap[mod] = digitsSSD;
354 /******************************************************************************/
356 void AliEveITSDigitsInfo::GetModuleIDs(AliEveITSModuleSelection* sel,
357 std::vector<UInt_t>& ids)
359 // Fill the id-vector with ids of modules that satisfy conditions
360 // given by the AliEveITSModuleSelection object.
362 Int_t idx0 = 0, idx1 = 0;
363 switch(sel->GetType())
367 idx1 = fGeom->GetLastSPD();
370 idx0 = fGeom->GetLastSPD()+1;
371 idx1 = fGeom->GetLastSDD();
374 idx0 = fGeom->GetLastSDD()+1;
375 idx1 = fGeom->GetLastSSD();
379 idx1 = fGeom->GetLastSSD();
387 for (Int_t id = idx0; id<idx1; ++id)
389 fGeom->GetModuleId(id, lay, lad, det);
390 if (sel->GetLayer() == lay || sel->GetLayer() == -1)
392 // check data from matrix
394 fGeom->GetRotMatrix(id, x);
395 mx.SetBaseVec(1, x[0], x[3], x[6]);
396 mx.SetBaseVec(2, x[1], x[4], x[7]);
397 mx.SetBaseVec(3, x[2], x[5], x[8]);
398 fGeom->GetTrans(id, x);
401 if (v.Phi() <= sel->GetMaxPhi() && v.Phi() >= sel->GetMinPhi() &&
402 v.Theta() <= sel->GetMaxTheta() && v.Theta() >= sel->GetMinTheta())
410 /******************************************************************************/
412 void AliEveITSDigitsInfo::Print(Option_t* ) const
414 // Print information about stored geometry and segmentation.
416 printf("*********************************************************\n");
417 printf("SPD module dimension (%f,%f)\n", fSegSPD->Dx()*0.0001, fSegSPD->Dz()*0.0001);
418 printf("SPD first,last module:: %d,%d\n", fGeom->GetStartSPD(), fGeom->GetLastSPD() );
419 printf("SPD num cells per module (x::%d,z::%d)\n", fSegSPD->Npx(), fSegSPD->Npz());
420 Int_t iz = 0, ix = 0;
421 printf("SPD dimesion of (%d,%d) in pixel(%f,%f)\n", ix, iz, fSegSPD->Dpx(ix), fSegSPD->Dpz(iz));
423 printf("SPD dimesion of pixel (%d,%d) are (%f,%f)\n", ix, iz, fSegSPD->Dpx(ix)*0.001, fSegSPD->Dpz(iz)*0.001);
425 printf("*********************************************************\n");
426 printf("SDD module dimension (%f,%f)\n", fSegSDD->Dx()*0.0001, fSegSDD->Dz()*0.0001);
427 printf("SDD first,last module:: %d,%d\n", fGeom->GetStartSDD(), fGeom->GetLastSDD());
428 printf("SDD num cells per module (x::%d,z::%d)\n", fSegSDD->Npx(), fSegSDD->Npz());
429 printf("SDD dimesion of pixel are (%f,%f)\n", fSegSDD->Dpx(1)*0.001, fSegSDD->Dpz(1)*0.001);
432 printf("*********************************************************\n");
433 printf("SSD module dimension (%f,%f)\n", fSegSSD->Dx()*0.0001, fSegSSD->Dz()*0.0001);
434 printf("SSD first,last module:: %d,%d\n", fGeom->GetStartSSD(), fGeom->GetLastSSD() );
435 printf("SSD strips in module %d\n", fSegSSD->Npx());
436 printf("SSD strip sizes are (%f,%f)\n", fSegSSD->Dpx(1), fSegSSD->Dpz(1));
437 fSegSSD->SetLayer(5); fSegSSD->Angles(ap,an);
438 printf("SSD layer 5 stereoP %f stereoN %f angle\n", ap, an);
439 fSegSSD->SetLayer(6); fSegSSD->Angles(ap,an);
440 printf("SSD layer 6 stereoP %f stereoN %f angle\n", ap, an);
445 printf("num cells %d,%d scaled %d,%d \n",fSegSPD->Npz(),fSegSPD->Npx(),Nz,Nx);
446 printf("%d digits in AliEveITSModule %d\n",ne, module);
447 Float_t zn = i*(3.48*2)/Nz - 3.48 ;
448 Float_t xo = -fSegSPD->Dx()*0.00005 + fSegSPD->Dpx(0)*od->GetCoord2()*0.0001;
449 Float_t xn = -fSegSPD->Dx()*0.00005 + j*0.0001*fSegSPD->Dx()/Nx;
450 Float_t dpx = 0.0001*fSegSPD->Dx()/Nx;
451 Float_t dpz = 3.48*2/Nz;
452 printf("Z::original (%3f) scaled (%3f, %3f) \n", zo, zn-dpz/2, zn+dpz/2);
453 printf("X::original (%3f) scaled (%3f, %3f) \n", xo, xn-dpx/2, xn+dpx/2);
454 printf("%d,%d maped to %d,%d \n", od->GetCoord1(), od->GetCoord2(), i,j );