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 **************************************************************************/
10 #include "AliEveITSModule.h"
12 #include <AliITSgeomTGeo.h>
13 #include <AliITSsegmentationSPD.h>
14 #include <AliITSsegmentationSDD.h>
15 #include <AliITSsegmentationSSD.h>
17 #include <AliITSdigitSPD.h>
18 #include <AliITSdigitSDD.h>
19 #include <AliITSdigitSSD.h>
21 #include <TEveTrans.h>
22 #include <TClonesArray.h>
26 //______________________________________________________________________________
28 // Visualization of an ITS module.
30 ClassImp(AliEveITSModule)
32 Bool_t AliEveITSModule::fgStaticInitDone = kFALSE;
34 TEveFrameBox* AliEveITSModule::fgSPDFrameBox = 0;
35 TEveFrameBox* AliEveITSModule::fgSPDFrameBoxDead = 0;
36 TEveFrameBox* AliEveITSModule::fgSDDFrameBox = 0;
37 TEveFrameBox* AliEveITSModule::fgSDDFrameBoxDead = 0;
38 TEveFrameBox* AliEveITSModule::fgSSDFrameBox = 0;
39 TEveFrameBox* AliEveITSModule::fgSSDFrameBoxDead = 0;
41 TEveRGBAPalette* AliEveITSModule::fgSPDPalette = 0;
42 TEveRGBAPalette* AliEveITSModule::fgSDDPalette = 0;
43 TEveRGBAPalette* AliEveITSModule::fgSSDPalette = 0;
45 /******************************************************************************/
47 AliEveITSModule::AliEveITSModule(const Text_t* n, const Text_t* t) :
51 fLayer(-1), fLadder(-1), fDet(-1),
52 fDx(0), fDz(0), fDy(0)
57 AliEveITSModule::AliEveITSModule(Int_t gid, AliEveITSDigitsInfo* info) :
58 TEveQuadSet(Form("ITS module %d", gid)),
61 fLayer(-1), fLadder(-1), fDet(-1),
62 fDx(0), fDz(0), fDy(0)
64 // Constructor with module id and data-source.
70 AliEveITSModule::~AliEveITSModule()
74 if (fInfo) fInfo->DecRefCount();
77 /******************************************************************************/
79 void AliEveITSModule::InitStatics(AliEveITSDigitsInfo* info)
81 // Initialize static variables.
83 // Warning all sensor sizes are in microns, here we transform them
84 // to cm. In Eve half-lengths/widths are used, hence another 1/2.
86 if (fgStaticInitDone) return;
87 fgStaticInitDone = kTRUE;
90 Float_t dx = info->fSegSPD->Dx()*0.00005;
91 Float_t dz = info->fSegSPD->Dz()*0.00005;
93 fgSPDFrameBox = new TEveFrameBox();
94 fgSPDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
95 fgSPDFrameBox->SetFrameColor(Color_t(31));
96 fgSPDFrameBox->SetFrameFill(kTRUE);
97 fgSPDFrameBox->IncRefCount();
98 fgSPDPalette = new TEveRGBAPalette(info->fSPDMinVal,info->fSPDMaxVal);
99 fgSPDPalette->IncRefCount();
101 fgSPDFrameBoxDead = new TEveFrameBox();
102 fgSPDFrameBoxDead->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
103 fgSPDFrameBoxDead->SetFrameColor(kRed);
104 fgSPDFrameBoxDead->SetFrameFill(kTRUE);
105 fgSPDFrameBoxDead->IncRefCount();
109 Float_t dx = info->fSegSDD->Dx()*0.0001;
110 Float_t dz = info->fSegSDD->Dz()*0.00005;
112 fgSDDFrameBox = new TEveFrameBox();
113 fgSDDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
114 fgSDDFrameBox->SetFrameColor(Color_t(32));
115 fgSDDFrameBox->SetFrameFill(kTRUE);
116 fgSDDFrameBox->IncRefCount();
117 fgSDDPalette = new TEveRGBAPalette(info->fSDDMinVal,info->fSDDMaxVal);
118 fgSDDPalette->SetLimits(0, info->fSDDHighLim); // Set proper ADC range.
119 fgSDDPalette->IncRefCount();
121 fgSDDFrameBoxDead = new TEveFrameBox();
122 fgSDDFrameBoxDead->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
123 fgSDDFrameBoxDead->SetFrameColor(kRed);
124 fgSDDFrameBoxDead->SetFrameFill(kTRUE);
125 fgSDDFrameBoxDead->IncRefCount();
129 Float_t dx = info->fSegSSD->Dx()*0.00005;
130 Float_t dz = info->fSegSSD->Dz()*0.00005;
132 fgSSDFrameBox = new TEveFrameBox();
133 fgSSDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
134 fgSSDFrameBox->SetFrameColor(Color_t(33));
135 fgSSDFrameBox->SetFrameFill(kTRUE);
136 fgSSDFrameBox->IncRefCount();
137 fgSSDPalette = new TEveRGBAPalette(info->fSSDMinVal,info->fSSDMaxVal);
138 fgSSDPalette->SetLimits(0, info->fSSDHighLim); // Set proper ADC range.
139 fgSSDPalette->IncRefCount();
141 fgSSDFrameBoxDead = new TEveFrameBox();
142 fgSSDFrameBoxDead->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
143 fgSSDFrameBoxDead->SetFrameColor(kRed);
144 fgSSDFrameBoxDead->SetFrameFill(kTRUE);
145 fgSSDFrameBoxDead->IncRefCount();
150 /******************************************************************************/
152 void AliEveITSModule::SetDigitsInfo(AliEveITSDigitsInfo* info)
154 // Set data and geometry source.
156 if (fInfo == info) return;
157 if (fInfo) fInfo->DecRefCount();
159 if (fInfo) fInfo->IncRefCount();
162 /******************************************************************************/
164 void AliEveITSModule::SetID(Int_t gid, Bool_t trans)
168 static const TEveException kEH("AliEveITSModule::SetID ");
171 throw(kEH + "AliEveITSDigitsInfo not set.");
173 Int_t firstSPD = AliITSgeomTGeo::GetModuleIndex(1,1,1);
174 Int_t lastSSD = AliITSgeomTGeo::GetNModules() - 1;
175 if (gid < firstSPD || gid > lastSSD)
177 throw(kEH + Form("%d is not valid. ID range from %d to %d", gid,
178 firstSPD, lastSSD ));
183 if (!fgStaticInitDone)
188 AliITSgeomTGeo::GetModuleId(fID, fLayer, fLadder, fDet);
189 TString strLadder = "Ladder";
190 TString strSensor = "Sensor";
192 Int_t id, nsector, nstave, nladder, rest;
194 if (fID <= (AliITSgeomTGeo::GetModuleIndex(3,1,1) - 1))
200 SetFrame(fInfo->IsDead(fID, fDetID) ? fgSPDFrameBoxDead : fgSPDFrameBox);
201 SetPalette(fgSPDPalette);
203 symname += strLadder;
207 rest = fID - 8*nsector;
214 rest = id - 8*nsector;
217 if (rest < 4) nstave = 0;
221 fDx = fInfo->fSegSPD->Dx()*0.00005;
223 fDy = fInfo->fSegSPD->Dy()*0.00005;
225 else if (fID <= (AliITSgeomTGeo::GetModuleIndex(5,1,1) - 1))
231 SetFrame(fInfo->IsDead(fID, fDetID) ? fgSDDFrameBoxDead : fgSDDFrameBox);
232 SetPalette(fgSDDPalette);
234 symname += strSensor;
239 rest = id - 6*nladder;
245 rest = id - 8*nladder;
249 fDx = fInfo->fSegSDD->Dx()*0.0001;
250 fDz = fInfo->fSegSDD->Dz()*0.00005;
251 fDy = fInfo->fSegSDD->Dy()*0.00005;
259 SetFrame(fInfo->IsDead(fID, fDetID) ? fgSSDFrameBoxDead : fgSSDFrameBox);
260 SetPalette(fgSSDPalette);
262 symname += strSensor;
267 rest = id - nladder*22;
273 rest = id - nladder*25;
277 fInfo->fSegSSD->SetLayer(fLayer);
278 fDx = fInfo->fSegSSD->Dx()*0.00005;
279 fDz = fInfo->fSegSSD->Dz()*0.00005;
280 fDy = fInfo->fSegSSD->Dy()*0.00005;
292 void AliEveITSModule::LoadQuads()
294 // Read module data from source and create low-level objects for
295 // visualization - called quads.
297 TClonesArray *digits = fInfo->GetDigits(fID, fDetID);
298 Int_t ndigits = digits ? digits->GetEntriesFast() : 0;
300 Float_t x, z, dpx, dpz;
307 AliITSsegmentationSPD* seg = fInfo->fSegSPD;
309 Reset(kQT_RectangleXZFixedY, kFALSE, 32);
311 for (Int_t k=0; k<ndigits; ++k)
313 AliITSdigit *d = (AliITSdigit*) digits->UncheckedAt(k);
316 x = -0.5*seg->Dx() + i*seg->Dpx(0);
318 fInfo->GetSPDLocalZ(j, z);
319 dpx = seg->Dpx(i)*0.0001;
320 dpz = seg->Dpz(j)*0.0001;
322 AddQuad(x, z, dpx, dpz);
323 QuadValue(1); // In principle could have color based on number of neigbours
331 AliITSsegmentationSDD *seg = fInfo->fSegSDD;
333 Reset(kQT_RectangleXZFixedY, kFALSE, 32);
335 for (Int_t k=0; k<ndigits; ++k)
337 AliITSdigit* d = (AliITSdigit*) digits->UncheckedAt(k);
341 seg->DetToLocal(i, j, x, z);
342 dpx = seg->Dpx(i)*0.0001;
343 dpz = seg->Dpz(j)*0.0001;
345 AddQuad(x-2*dpx, z - dpz*0.5, 4*dpx, dpz);
346 QuadValue(d->GetSignal());
354 AliITSsegmentationSSD* seg = fInfo->fSegSSD;
356 Reset(kQT_LineXZFixedY, kFALSE, 32);
358 Float_t ap, an; // positive/negative angles -> offsets
360 ap = TMath::Tan(ap) * fDz;
361 an = - TMath::Tan(an) * fDz;
363 for (Int_t k=0; k<ndigits; ++k)
365 AliITSdigit *d = (AliITSdigit*) digits->UncheckedAt(k);
369 // !!!! The following function complains about not being verified.
370 // !!!! Experts should check.
371 seg->DetToLocal(i,j,x,z);
373 Float_t a = (d->GetCoord1() == 1) ? ap : an;
375 AddLine(x-a, -fDz, 2*a, 2*fDz);
376 QuadValue(d->GetSignal());
378 // printf("%3d -> %3d -> %8x\n", d->GetSignal(), ci, fQuads.back().color);
386 /******************************************************************************/
388 void AliEveITSModule::SetTrans()
390 // Set transformation matrix based on module id (use geometry to
391 // retrieve this information).
393 fMainTrans->SetFrom(*AliITSgeomTGeo::GetMatrix(fID));
396 /******************************************************************************/
398 void AliEveITSModule::DigitSelected(Int_t idx)
400 // Override secondary select (alt-click) from TEveQuadSet.
402 DigitBase_t *qb = GetDigit(idx);
403 TObject *obj = GetId(idx);
404 AliITSdigit *d = dynamic_cast<AliITSdigit*>(obj);
405 printf("AliEveITSModule::QuadSelected "); Print();
406 printf(" idx=%d, value=%d, obj=0x%lx, digit=0x%lx\n",
407 idx, qb->fValue, (ULong_t)obj, (ULong_t)d);
409 printf(" coord1=%3d coord2=%3d signal=%d\n",
410 d->GetCoord1(), d->GetCoord2(), d->GetSignal());
414 /******************************************************************************/
416 void AliEveITSModule::Print(Option_t* ) const
418 // Print object summary information.
420 printf("AliEveITSModule: ID %d, layer %d, ladder %d, det %d\n",
421 fID, fLayer, fLadder, fDetID);