]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Alieve/AliEveITSModule.cxx
Put all classes in Alieve/ sub-module out of the Alieve namespace and
[u/mrichter/AliRoot.git] / EVE / Alieve / AliEveITSModule.cxx
CommitLineData
d810d0de 1// $Id$
2// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
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 **************************************************************************/
9#include "AliEveITSModule.h"
5a5a1232 10
11#include <AliITSdigitSPD.h>
12#include <AliITSdigitSDD.h>
13#include <AliITSdigitSSD.h>
14
15#include <TStyle.h>
5a5a1232 16
9efc978d 17
9efc978d 18
d810d0de 19Bool_t AliEveITSModule::fgStaticInitDone = kFALSE;
20
21TEveFrameBox* AliEveITSModule::fgSPDFrameBox = 0;
22TEveFrameBox* AliEveITSModule::fgSDDFrameBox = 0;
23TEveFrameBox* AliEveITSModule::fgSSDFrameBox = 0;
9efc978d 24
d810d0de 25TEveRGBAPalette* AliEveITSModule::fgSPDPalette = 0;
26TEveRGBAPalette* AliEveITSModule::fgSDDPalette = 0;
27TEveRGBAPalette* AliEveITSModule::fgSSDPalette = 0;
9efc978d 28
29//__________________________________________________________________________
d810d0de 30// AliEveITSModule
9efc978d 31//
32//
5a5a1232 33
d810d0de 34ClassImp(AliEveITSModule)
5a5a1232 35
36/**************************************************************************/
37
d810d0de 38AliEveITSModule::AliEveITSModule(const Text_t* n, const Text_t* t) :
84aff7a4 39 TEveQuadSet(n, t),
265ecb21 40 fInfo(0),
41 fID(-1), fDetID(-1),
42 fLayer(-1), fLadder(-1), fDet(-1),
9efc978d 43 fDx(0), fDz(0), fDy(0)
27db2029 44{}
5a5a1232 45
d810d0de 46AliEveITSModule::AliEveITSModule(Int_t gid, AliEveITSDigitsInfo* info) :
84aff7a4 47 TEveQuadSet(Form("ITS module %d", gid)),
27db2029 48 fInfo (0),
265ecb21 49 fID(-1), fDetID(-1),
50 fLayer(-1), fLadder(-1), fDet(-1),
9efc978d 51 fDx(0), fDz(0), fDy(0)
5a5a1232 52{
27db2029 53 SetDigitsInfo(info);
9c8221e9 54 SetID(gid);
5a5a1232 55}
56
d810d0de 57AliEveITSModule::~AliEveITSModule()
5a5a1232 58{
59 if(fInfo) fInfo->DecRefCount();
60}
61
62/**************************************************************************/
63
d810d0de 64void AliEveITSModule::InitStatics(AliEveITSDigitsInfo* info)
9efc978d 65{
66 if (fgStaticInitDone) return;
9c8221e9 67 fgStaticInitDone = kTRUE;
9efc978d 68
69 {
70 Float_t dx = info->fSegSPD->Dx()*0.00005;
97e1e1bc 71 Float_t dz = 3.50;
9efc978d 72
84aff7a4 73 fgSPDFrameBox = new TEveFrameBox();
9efc978d 74 fgSPDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
75 fgSPDFrameBox->SetFrameColor((Color_t) 31);
32e219c2 76 fgSPDFrameBox->SetFrameFill(kTRUE);
77 fgSPDFrameBox->IncRefCount();
84aff7a4 78 fgSPDPalette = new TEveRGBAPalette(info->fSPDMinVal,info->fSPDMaxVal);
32e219c2 79 fgSPDPalette->IncRefCount();
9efc978d 80 }
81
82 {
83 Float_t dx = info->fSegSDD->Dx()*0.0001;
84 Float_t dz = info->fSegSDD->Dz()*0.00005;
85
84aff7a4 86 fgSDDFrameBox = new TEveFrameBox();
9efc978d 87 fgSDDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
88 fgSDDFrameBox->SetFrameColor((Color_t) 32);
32e219c2 89 fgSDDFrameBox->SetFrameFill(kTRUE);
90 fgSDDFrameBox->IncRefCount();
84aff7a4 91 fgSDDPalette = new TEveRGBAPalette(info->fSDDMinVal,info->fSDDMaxVal);
32e219c2 92 fgSDDPalette->SetLimits(0, info->fSDDHighLim); // Set proper ADC range.
93 fgSDDPalette->IncRefCount();
9efc978d 94 }
95
96 {
97 Float_t dx = info->fSegSSD->Dx()*0.00005;
98 Float_t dz = info->fSegSSD->Dz()*0.00005;
99
84aff7a4 100 fgSSDFrameBox = new TEveFrameBox();
9efc978d 101 fgSSDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
102 fgSSDFrameBox->SetFrameColor((Color_t) 33);
32e219c2 103 fgSSDFrameBox->SetFrameFill(kTRUE);
104 fgSSDFrameBox->IncRefCount();
84aff7a4 105 fgSSDPalette = new TEveRGBAPalette(info->fSSDMinVal,info->fSSDMaxVal);
32e219c2 106 fgSSDPalette->SetLimits(0, info->fSSDHighLim); // Set proper ADC range.
107 fgSSDPalette->IncRefCount();
9efc978d 108 }
109
110}
111
112/**************************************************************************/
113
d810d0de 114void AliEveITSModule::SetDigitsInfo(AliEveITSDigitsInfo* info)
5a5a1232 115{
9c8221e9 116 if (fInfo == info) return;
117 if (fInfo) fInfo->DecRefCount();
118 fInfo = info;
119 if (fInfo) fInfo->IncRefCount();
120}
121
122/**************************************************************************/
123
d810d0de 124void AliEveITSModule::SetID(Int_t gid, Bool_t trans)
9c8221e9 125{
d810d0de 126 static const TEveException eH("AliEveITSModule::SetID ");
9efc978d 127
9c8221e9 128 if(fInfo == 0)
d810d0de 129 throw(eH + "AliEveITSDigitsInfo not set.");
9c8221e9 130
131 if (gid < fInfo->fGeom->GetStartSPD() || gid > fInfo->fGeom->GetLastSSD())
132 throw(eH + Form("%d is not valid. ID range from %d to %d", gid,
1d3c2b09 133 fInfo->fGeom->GetStartSPD(), fInfo->fGeom->GetLastSSD()));
9c8221e9 134
135 fID = gid;
136
1d3c2b09 137 if (!fgStaticInitDone) {
138 InitStatics(fInfo);
139
140 fgSPDFrameBox->IncRefCount(this);
141 fgSPDPalette->IncRefCount();
142
143 fgSDDFrameBox->IncRefCount(this);
144 fgSDDPalette->IncRefCount();
145
146 fgSSDFrameBox->IncRefCount(this);
147 fgSSDPalette->IncRefCount();
148 }
9c8221e9 149
150 fInfo->fGeom->GetModuleId(fID, fLayer, fLadder, fDet);
ba6cfb13 151 TString strLadder = "Ladder";
152 TString strSensor = "Sensor";
153 TString symname;
9c8221e9 154 Int_t id, nsector, nstave, nladder, rest;
ba6cfb13 155
9efc978d 156 if (fID <= fInfo->fGeom->GetLastSPD())
157 {
158 // SPD
159
9c8221e9 160 SetFrame(fgSPDFrameBox);
161 SetPalette(fgSPDPalette);
162
9efc978d 163 symname += strLadder;
164 if (fID < 80)
165 {
ba6cfb13 166 nsector = fID/8;
9efc978d 167 rest = fID - 8*nsector;
168 nstave = 1;
169 }
170 else
171 {
172 id = fID - 80;
ba6cfb13 173 nsector = id/8;
9efc978d 174 rest = id - 8*nsector;
175 nstave = 1;
ba6cfb13 176 }
9efc978d 177 if (rest < 4) nstave = 0;
178 rest -= 4*nstave;
179 symname += rest;
180 SetName(symname);
181 fDetID = 0;
182 fDx = fInfo->fSegSPD->Dx()*0.00005;
97e1e1bc 183 fDz = 3.50;
9efc978d 184 fDy = fInfo->fSegSPD->Dy()*0.00005;
185
5a5a1232 186 }
9efc978d 187 else if (fID <= fInfo->fGeom->GetLastSDD())
188 {
189 // SDD
190
9c8221e9 191 SetFrame(fgSDDFrameBox);
192 SetPalette(fgSDDPalette);
193
9efc978d 194 symname += strSensor;
195 if (fID < 324)
196 {
197 id = fID - 240;
ba6cfb13 198 nladder = id/6;
9efc978d 199 rest = id - 6*nladder;
200 }
201 else
202 {
203 id = fID - 324;
ba6cfb13 204 nladder = id/8;
9efc978d 205 rest = id - 8*nladder;
ba6cfb13 206 }
9efc978d 207 symname += rest;
208 SetName(symname);
209 fDetID = 1;
210 fDx = fInfo->fSegSDD->Dx()*0.0001;
211 fDz = fInfo->fSegSDD->Dz()*0.00005;
212 fDy = fInfo->fSegSDD->Dy()*0.00005;
213
5a5a1232 214 }
9efc978d 215 else
216 {
217 // SSD
218
9c8221e9 219 SetFrame(fgSSDFrameBox);
220 SetPalette(fgSSDPalette);
221
9efc978d 222 symname += strSensor;
223 if (fID < 1248)
224 {
225 id = fID - 500;
ba6cfb13 226 nladder = id/22;
9efc978d 227 rest = id - nladder*22;
228 }
229 else
230 {
231 id = fID - 1248;
ba6cfb13 232 nladder = id/25;
9efc978d 233 rest = id - nladder*25;
ba6cfb13 234 }
9efc978d 235 symname += rest;
236 SetName(symname);
237 fDetID = 2;
238 fInfo->fSegSSD->SetLayer(fLayer);
239 fDx = fInfo->fSegSSD->Dx()*0.00005;
240 fDz = fInfo->fSegSSD->Dz()*0.00005;
241 fDy = fInfo->fSegSSD->Dy()*0.00005;
242
5a5a1232 243 }
244
245 LoadQuads();
246 ComputeBBox();
97e1e1bc 247 if (trans)
248 SetTrans();
5a5a1232 249}
250
d810d0de 251void AliEveITSModule::LoadQuads()
5a5a1232 252{
9efc978d 253 // Here we still use 'z' for the name of axial coordinates.
254 // The transforamtion matrix aplied rotates y -> z.
84aff7a4 255 // We need this as TEveQuadSet offers optimized treatment for
9efc978d 256 // quads in the x-y plane.
257
5a5a1232 258 // printf("its module load quads \n");
9efc978d 259
b3bc5327 260 TClonesArray *digits = fInfo->GetDigits(fID, fDetID);
261 Int_t ndigits = digits ? digits->GetEntriesFast() : 0;
262
9efc978d 263 Float_t x, z, dpx, dpz;
b3bc5327 264 Int_t i, j;
5a5a1232 265
9efc978d 266 switch(fDetID)
267 {
268
269 case 0: { // SPD
270 AliITSsegmentationSPD* seg = fInfo->fSegSPD;
271
84aff7a4 272 Reset(kQT_RectangleXZFixedY, kFALSE, 32);
5a5a1232 273
9efc978d 274 for (Int_t k=0; k<ndigits; ++k)
275 {
b3bc5327 276 AliITSdigit *d = (AliITSdigit*) digits->UncheckedAt(k);
5a5a1232 277 j = d->GetCoord1();
278 i = d->GetCoord2();
9efc978d 279 x = -0.5*seg->Dx() + i*seg->Dpx(0);
280 x *= 0.0001;
281 fInfo->GetSPDLocalZ(j, z);
5a5a1232 282 dpx = seg->Dpx(i)*0.0001;
283 dpz = seg->Dpz(j)*0.0001;
284
9efc978d 285 AddQuad(x, z, dpx, dpz);
286 QuadValue(1); // In principle could have color based on number of neigbours
ffa36681 287 QuadId(d);
5a5a1232 288 }
9efc978d 289 break;
5a5a1232 290 }
5a5a1232 291
9efc978d 292 case 1: { // SDD
293 AliITSsegmentationSDD *seg = fInfo->fSegSDD;
5a5a1232 294
84aff7a4 295 Reset(kQT_RectangleXZFixedY, kFALSE, 32);
9efc978d 296
297 for (Int_t k=0; k<ndigits; ++k)
298 {
b3bc5327 299 AliITSdigit* d = (AliITSdigit*) digits->UncheckedAt(k);
9efc978d 300
301 // if (d->GetSignal() > fgSDDThreshold)
302 {
303 j = d->GetCoord1();
304 i = d->GetCoord2();
305 seg->DetToLocal(i, j, x, z);
306 dpx = seg->Dpx(i)*0.0001;
307 dpz = seg->Dpz(j)*0.0001;
308
97e1e1bc 309 AddQuad(x-2*dpx, z - dpz*0.5, 4*dpx, dpz);
9efc978d 310 QuadValue(d->GetSignal());
ffa36681 311 QuadId(d);
5a5a1232 312 }
9efc978d 313 }
314 break;
315 }
316
317 case 2: { // SSD
318 AliITSsegmentationSSD* seg = fInfo->fSegSSD;
319
84aff7a4 320 Reset(kQT_LineXZFixedY, kFALSE, 32);
9efc978d 321
322 Float_t ap, an; // positive/negative angles -> offsets
323 seg->Angles(ap, an);
324 ap = TMath::Tan(ap) * fDz;
325 an = - TMath::Tan(an) * fDz;
326
327 for (Int_t k=0; k<ndigits; ++k)
328 {
b3bc5327 329 AliITSdigit *d = (AliITSdigit*) digits->UncheckedAt(k);
9efc978d 330 // if(d->GetSignal() > fgSSDThreshold)
331 {
332 j = d->GetCoord1();
333 i = d->GetCoord2();
334 seg->DetToLocal(i,j,x,z);
335
336 Float_t a = ( d->GetCoord1() == 1) ? ap : an;
337
e974c097 338 AddLine(x-a, -fDz, 2*a, 2*fDz);
9efc978d 339 QuadValue(d->GetSignal());
ffa36681 340 QuadId(d);
9efc978d 341 // printf("%3d -> %3d -> %8x\n", d->GetSignal(), ci, fQuads.back().color);
5a5a1232 342 }
5a5a1232 343 }
9efc978d 344 break;
5a5a1232 345 }
5a5a1232 346
9efc978d 347 } // end switch
348
349 RefitPlex();
5a5a1232 350}
351
352/**************************************************************************/
353
d810d0de 354void AliEveITSModule::SetTrans()
5a5a1232 355{
4852ff6f 356 // Set transformation matrix based on module id (use geometry to
357 // retrieve this information).
358
9efc978d 359 Double_t x[9];
360 fHMTrans.UnitTrans();
361
4852ff6f 362 // !!!! Here should use AliITSgeomTGeo ... but can i be sure
363 // the geometry has been loaded?
364
365 // column major
9efc978d 366 fInfo->fGeom->GetRotMatrix(fID, x);
367 fHMTrans.SetBaseVec(1, x[0], x[3], x[6]);
368 fHMTrans.SetBaseVec(2, x[1], x[4], x[7]);
369 fHMTrans.SetBaseVec(3, x[2], x[5], x[8]);
370 // translation
371 fInfo->fGeom->GetTrans(fID, x);
372 fHMTrans.SetBaseVec(4, x);
5a5a1232 373}
374
375/**************************************************************************/
376
d810d0de 377void AliEveITSModule::DigitSelected(Int_t idx)
ffa36681 378{
84aff7a4 379 // Override control-click from TEveQuadSet
ffa36681 380
84aff7a4 381 DigitBase_t* qb = GetDigit(idx);
ffa36681 382 TObject* obj = qb->fId.GetObject();
383 AliITSdigit* d = dynamic_cast<AliITSdigit*>(obj);
d810d0de 384 printf("AliEveITSModule::QuadSelected "); Print();
ffa36681 385 printf(" idx=%d, value=%d, obj=0x%lx, digit=0x%lx\n",
386 idx, qb->fValue, (ULong_t)obj, (ULong_t)d);
387 if (d)
388 printf(" coord1=%3d coord2=%3d signal=%d\n",
389 d->GetCoord1(), d->GetCoord2(), d->GetSignal());
390
391}
392
393/**************************************************************************/
394
d810d0de 395void AliEveITSModule::Print(Option_t* ) const
5a5a1232 396{
397 printf("ID %d, layer %d, ladder %d, det %d \n", fID, fLayer, fLadder, fDetID);
398}