]>
Commit | Line | Data |
---|---|---|
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 * | |
51346b82 | 7 | * full copyright notice. * |
d810d0de | 8 | **************************************************************************/ |
9 | #include "AliEveTOFSector.h" | |
8616d353 | 10 | |
84aff7a4 | 11 | #include <TEveManager.h> |
8616d353 | 12 | |
13 | #include <AliTOFdigit.h> | |
28a21457 | 14 | #include <AliTOFGeometry.h> |
8616d353 | 15 | |
16 | #include <TStyle.h> | |
d810d0de | 17 | |
fd31e9de | 18 | Bool_t AliEveTOFSector::fgStaticInitDone = kFALSE; |
d810d0de | 19 | TEveFrameBox* AliEveTOFSector::fgTOFsectorFrameBox = 0; |
20 | TEveRGBAPalette* AliEveTOFSector::fgTOFsectorPalette = 0; | |
8616d353 | 21 | |
22 | //_______________________________________________________ | |
d810d0de | 23 | ClassImp(AliEveTOFSector) |
8616d353 | 24 | |
25 | /* ************************************************************************ */ | |
26 | ||
d810d0de | 27 | AliEveTOFSector::AliEveTOFSector(const Text_t* n, const Text_t* t) : |
84aff7a4 | 28 | TEveQuadSet(n, t), |
28a21457 | 29 | fTOFgeometry(new AliTOFGeometry()), |
8616d353 | 30 | fTOFarray(0x0), |
31 | fTOFtree(0x0), | |
32 | fSector(-1), | |
33 | fDx(0), fDy(0), fDz(0), | |
34 | fAutoTrans (kTRUE), | |
ee9d8eca | 35 | //fMinTime (0), fMaxTime (0), |
36 | fThreshold (5), fMaxVal (80), | |
8616d353 | 37 | fSectorID (0), |
ee9d8eca | 38 | //fPlateFlag0(kTRUE), fPlateFlag1(kTRUE), fPlateFlag2(kTRUE), fPlateFlag3(kTRUE), fPlateFlag4(kTRUE), |
39 | fPlateFlag (0x0), | |
40 | //fFrameColor(4), | |
41 | //fRnrFrame (kFALSE), | |
8616d353 | 42 | fGeoManager(0) |
43 | { | |
44 | ||
45 | fPlateFlag = new Bool_t[5]; | |
46 | for (Int_t ii=0; ii<5; ii++) fPlateFlag[ii]=kTRUE; | |
47 | ||
ee9d8eca | 48 | |
49 | //fGeoManager = (TGeoManager*)gEve->GetGeometry("$REVESYS/alice-data/alice_fullgeo.root"); | |
8616d353 | 50 | if (!fGeoManager) { |
51 | printf("ERROR: no TGeo\n"); | |
52 | } | |
fd31e9de | 53 | |
ee9d8eca | 54 | } |
8616d353 | 55 | /* ************************************************************************ */ |
56 | ||
ee9d8eca | 57 | AliEveTOFSector::AliEveTOFSector(TGeoManager *localGeoManager, |
58 | Int_t nSector) | |
59 | : | |
60 | TEveQuadSet(Form("Sector%i",nSector)), | |
28a21457 | 61 | fTOFgeometry(new AliTOFGeometry()), |
8616d353 | 62 | fTOFarray(0x0), |
63 | fTOFtree(0x0), | |
64 | fSector(nSector), | |
65 | fDx(0), fDy(0), fDz(0), | |
66 | fAutoTrans (kTRUE), | |
ee9d8eca | 67 | //fMinTime (0), fMaxTime (0), |
fd31e9de | 68 | fThreshold (5), fMaxVal (80), |
8616d353 | 69 | fSectorID (nSector), |
ee9d8eca | 70 | //fPlateFlag0(kTRUE), fPlateFlag1(kTRUE), fPlateFlag2(kTRUE), fPlateFlag3(kTRUE), fPlateFlag4(kTRUE), |
71 | fPlateFlag (0x0), | |
72 | //fFrameColor(4), | |
73 | //fRnrFrame (kFALSE), | |
8616d353 | 74 | fGeoManager(localGeoManager) |
75 | { | |
76 | ||
77 | fPlateFlag = new Bool_t[5]; | |
78 | for (Int_t ii=0; ii<5; ii++) fPlateFlag[ii]=kTRUE; | |
79 | ||
80 | /* | |
81 | if (!fGeoManager) { | |
82 | printf("ERROR: no TGeo\n"); | |
83 | } | |
84 | */ | |
85 | ||
86 | InitModule(); | |
fd31e9de | 87 | |
ee9d8eca | 88 | } |
8616d353 | 89 | /* ************************************************************************ */ |
90 | ||
d810d0de | 91 | AliEveTOFSector::AliEveTOFSector(TGeoManager *localGeoManager, |
8616d353 | 92 | Int_t nSector, |
93 | TClonesArray *tofArray) | |
94 | : | |
84aff7a4 | 95 | TEveQuadSet(Form("Sector%i",nSector)), |
28a21457 | 96 | fTOFgeometry(new AliTOFGeometry()), |
8616d353 | 97 | fTOFarray(tofArray), |
98 | fTOFtree(0x0), | |
99 | fSector(nSector), | |
100 | fDx(0), fDy(0), fDz(0), | |
101 | fAutoTrans (kTRUE), | |
ee9d8eca | 102 | //fMinTime (0), fMaxTime (0), |
103 | fThreshold (5), fMaxVal (80), | |
8616d353 | 104 | fSectorID (nSector), |
ee9d8eca | 105 | //fPlateFlag0(kTRUE), fPlateFlag1(kTRUE), fPlateFlag2(kTRUE), fPlateFlag3(kTRUE), fPlateFlag4(kTRUE), |
106 | fPlateFlag (0x0), | |
107 | //fFrameColor(4), | |
108 | //fRnrFrame (kFALSE), | |
8616d353 | 109 | fGeoManager(localGeoManager) |
110 | { | |
111 | ||
112 | fPlateFlag = new Bool_t[5]; | |
113 | for (Int_t ii=0; ii<5; ii++) fPlateFlag[ii]=kTRUE; | |
114 | ||
115 | InitModule(); | |
116 | ||
117 | } | |
118 | /* ************************************************************************ */ | |
119 | ||
ee9d8eca | 120 | AliEveTOFSector::AliEveTOFSector(TGeoManager *localGeoManager, |
121 | Int_t nSector, | |
122 | TTree *tofTree) | |
123 | : | |
124 | TEveQuadSet(Form("Sector%i",nSector)), | |
28a21457 | 125 | fTOFgeometry(new AliTOFGeometry()), |
8616d353 | 126 | fTOFarray(0x0), |
127 | fTOFtree(tofTree), | |
128 | fSector(nSector), | |
129 | fDx(0), fDy(0), fDz(0), | |
130 | fAutoTrans (kTRUE), | |
ee9d8eca | 131 | //fMinTime (0), fMaxTime (0), |
132 | fThreshold (5), fMaxVal (80), | |
8616d353 | 133 | fSectorID (nSector), |
ee9d8eca | 134 | //fPlateFlag0(kTRUE), fPlateFlag1(kTRUE), fPlateFlag2(kTRUE), fPlateFlag3(kTRUE), fPlateFlag4(kTRUE), |
135 | fPlateFlag (0x0), | |
136 | //fFrameColor(4), | |
137 | //fRnrFrame (kFALSE), | |
8616d353 | 138 | fGeoManager(localGeoManager) |
139 | { | |
140 | ||
141 | fPlateFlag = new Bool_t[5]; | |
142 | for (Int_t ii=0; ii<5; ii++) fPlateFlag[ii]=kTRUE; | |
143 | ||
144 | InitModule(); | |
145 | ||
146 | } | |
147 | /* ************************************************************************ */ | |
148 | ||
d810d0de | 149 | AliEveTOFSector::~AliEveTOFSector() |
8616d353 | 150 | { |
151 | /* | |
152 | fGeoManager = 0x0; | |
153 | delete fGeoManager; | |
154 | ||
155 | delete fTOFarray; | |
156 | fTOFarray = 0x0; | |
157 | */ | |
158 | delete fPlateFlag; | |
159 | ||
160 | } | |
161 | ||
162 | /* ************************************************************************ */ | |
163 | /* | |
d810d0de | 164 | void AliEveTOFSector::SetDigitsInfo(AliEveTOFDigitsInfo* info) |
8616d353 | 165 | { |
166 | if(fInfo) fInfo->DecRefCount(); | |
167 | fInfo = info; | |
168 | if(fInfo) fInfo->IncRefCount(); | |
169 | ||
170 | } | |
171 | */ | |
172 | /* ************************************************************************ */ | |
d810d0de | 173 | void AliEveTOFSector::InitStatics() |
8616d353 | 174 | { |
175 | if (fgStaticInitDone) return; | |
176 | ||
177 | Float_t dx = 124.5; | |
178 | Float_t dz = 29.; | |
179 | Float_t dy = 370.6*2.; | |
84aff7a4 | 180 | fgTOFsectorFrameBox = new TEveFrameBox(); |
8616d353 | 181 | |
182 | fgTOFsectorFrameBox->SetAABox(-dx*0.5, -dy*0.5, -dz*0.5, dx, dy, dz); | |
183 | fgTOFsectorFrameBox->SetFrameColor((Color_t) 32);//31); | |
184 | ||
84aff7a4 | 185 | //fgTOFsectorPalette = new TEveRGBAPalette(0, 2048); // TOT |
ee9d8eca | 186 | //fgTOFsectorPalette->SetLimits(0, 2048); |
187 | fgTOFsectorPalette = new TEveRGBAPalette(0, 8192); // TDC | |
188 | //fgTOFsectorPalette->SetLimits(0, 8192); | |
8616d353 | 189 | |
190 | fgStaticInitDone = kTRUE; | |
191 | } | |
192 | ||
193 | /* ************************************************************************ */ | |
d810d0de | 194 | void AliEveTOFSector::InitModule() |
8616d353 | 195 | { |
196 | ||
197 | fDx = fTOFgeometry->XPad()*fTOFgeometry->NpadX(); | |
198 | //fDy = fTOFgeometry->XPad()*fTOFgeometry->NpadX(); | |
199 | fDz = fTOFgeometry->ZPad()*fTOFgeometry->NpadZ(); | |
200 | ||
201 | if (!fgStaticInitDone) InitStatics(); | |
202 | ||
203 | SetFrame(fgTOFsectorFrameBox); | |
204 | SetPalette(fgTOFsectorPalette); | |
205 | //fFrame = fgTOFsectorFrameBox; | |
206 | //fPalette = fgTOFsectorPalette; | |
207 | ||
51346b82 | 208 | LoadQuads(); |
8616d353 | 209 | ComputeBBox(); |
210 | SetTrans(); | |
211 | ||
212 | } | |
213 | ||
214 | /* ************************************************************************ */ | |
d810d0de | 215 | void AliEveTOFSector::LoadQuads() |
8616d353 | 216 | { |
217 | ||
8616d353 | 218 | //Int_t n_col = gStyle->GetNumberOfColors(); |
219 | ||
220 | Int_t vol[5] = {fSectorID, -1, -1, -1, -1}; | |
221 | Int_t informations[4] = {-1, -1, -1, -1}; | |
222 | Int_t dummy[3] = {-1, -1, -1}; | |
223 | Int_t tdc = -1; | |
224 | Int_t tot = -1; | |
225 | ||
226 | Double_t **coord = new Double_t*[4]; | |
227 | for (Int_t ii=0; ii<4; ii++) coord[ii] = new Double_t[3]; | |
228 | ||
ee9d8eca | 229 | Reset(kQT_FreeQuad, kFALSE, 32); |
230 | ||
8616d353 | 231 | //printf(" fTOFarray->GetEntries() = %4i \n",fTOFarray->GetEntries()); |
232 | ||
233 | if (fTOFtree && !fTOFarray) { | |
234 | //printf("Hello world\n"); | |
235 | TClonesArray* digitsTOFnew = new TClonesArray("AliTOFdigit", 300); | |
236 | ||
237 | fTOFarray = new TClonesArray("AliTOFdigit", 300); | |
238 | TClonesArray &ldigits = *fTOFarray; | |
239 | Int_t newCounter = 0; | |
240 | ||
241 | AliTOFdigit *digs; | |
242 | ||
243 | fTOFtree->SetBranchAddress("TOF",&digitsTOFnew); | |
244 | fTOFtree->GetEntry(0); | |
245 | for (Int_t digitNumber=0; digitNumber<digitsTOFnew->GetEntries(); digitNumber++) { | |
246 | ||
247 | //if (digitNumber==digitsTOF->GetEntries()-1) printf(" Hello 4 -> %3i digit of %i \n", digitNumber+1, digitsTOF->GetEntries()); | |
51346b82 | 248 | |
8616d353 | 249 | digs = (AliTOFdigit*)digitsTOFnew->UncheckedAt(digitNumber); |
250 | ||
251 | if (digs->GetSector()!=fSectorID) continue; | |
252 | ||
253 | vol[1] = digs->GetPlate(); // Plate Number (0-4) | |
254 | vol[2] = digs->GetStrip(); // Strip Number (0-14/18) | |
ee9d8eca | 255 | vol[3] = digs->GetPadx(); // Pad Number in x direction (0-47) |
256 | vol[4] = digs->GetPadz(); // Pad Number in z direction (0-1) | |
8616d353 | 257 | |
258 | informations[0] = digs->GetTdc(); | |
259 | informations[1] = digs->GetAdc(); | |
260 | informations[2] = digs->GetToT(); | |
261 | informations[3] = digs->GetTdcND(); | |
262 | new (ldigits[newCounter++]) AliTOFdigit(dummy, vol, informations); | |
263 | } | |
264 | } | |
265 | ||
266 | AliTOFdigit *tofDigit; | |
267 | //printf(" 0x%lx\n",fTOFarray); | |
268 | for (Int_t ii=0; ii<fTOFarray->GetEntries(); ii++) { | |
269 | ||
270 | tofDigit = (AliTOFdigit*)fTOFarray->UncheckedAt(ii); | |
51346b82 | 271 | |
8616d353 | 272 | if (fPlateFlag[tofDigit->GetPlate()]) { |
273 | ||
274 | vol[1] = tofDigit->GetPlate(); | |
275 | vol[2] = tofDigit->GetStrip(); | |
276 | vol[3] = tofDigit->GetPadz(); | |
277 | vol[4] = tofDigit->GetPadx(); | |
278 | ||
279 | tot = tofDigit->GetToT(); | |
280 | tdc = tofDigit->GetTdc(); | |
281 | ||
282 | //if (fSector==4 && fPlate==2 && fStrip==0) printf(" %2i %1i\n", iPadX, iPadZ); | |
283 | //if (iPadX==23 || iPadX==24) printf(" %2i %1i %2i \n", fSector, fPlate, fStrip); | |
284 | //if (vol[0]==4 && vol[1]==2 && vol[2]==7) { | |
285 | ||
286 | for (Int_t kk=0; kk<4; kk++) for (Int_t jj=0; jj<3; jj++) coord[kk][jj]=0.; | |
287 | ||
288 | fTOFgeometry->DetToSectorRF(vol, coord); | |
289 | /* | |
290 | printf("\n"); | |
291 | printf(" %1i %2i, %f %f %f \n", vol[3], vol[4], coord[0][0], coord[0][1], coord[0][2]); | |
292 | printf(" %1i %2i, %f %f %f \n", vol[3], vol[4], coord[1][0], coord[1][1], coord[1][2]); | |
293 | printf(" %1i %2i, %f %f %f \n", vol[3], vol[4], coord[2][0], coord[2][1], coord[2][2]); | |
294 | printf(" %1i %2i, %f %f %f \n", vol[3], vol[4], coord[3][0], coord[3][1], coord[3][2]); | |
295 | */ | |
296 | Float_t vertices[12]={(Float_t)coord[0][0], (Float_t)coord[0][1], (Float_t)coord[0][2], | |
297 | (Float_t)coord[1][0], (Float_t)coord[1][1], (Float_t)coord[1][2], | |
298 | (Float_t)coord[2][0], (Float_t)coord[2][1], (Float_t)coord[2][2], | |
299 | (Float_t)coord[3][0], (Float_t)coord[3][1], (Float_t)coord[3][2]}; | |
51346b82 | 300 | |
8616d353 | 301 | AddQuad(vertices); |
302 | //AddQuad((Float_t*)coord); | |
303 | //AddQuad(coord[0], coord[1], coord[2], 2.5, 3.5); | |
304 | //AddQuad(-2.5*0.5, -3.5*0.5, 2.5, 3.5); | |
305 | ||
306 | // In principle could have color based on number of neigbours. We | |
307 | // can insert the time-of-flight value for each pad | |
ee9d8eca | 308 | |
8616d353 | 309 | //QuadValue((Int_t)tot); |
310 | QuadValue((Int_t)tdc); | |
311 | QuadId(tofDigit); | |
51346b82 | 312 | |
8616d353 | 313 | //} |
314 | } // closed if control on plates switched on | |
315 | } // closed loop on TOF sector digits | |
316 | ||
317 | RefitPlex(); | |
318 | ||
319 | fTOFarray = 0x0; | |
51346b82 | 320 | |
8616d353 | 321 | } |
322 | ||
323 | /* ************************************************************ */ | |
d810d0de | 324 | void AliEveTOFSector::SetTrans() |
8616d353 | 325 | { |
326 | fHMTrans.UnitTrans(); | |
327 | ||
328 | //Int_t det[5] = {fSector, -1, -1, -1, -1}; | |
329 | Char_t path[100]; | |
330 | ||
331 | Int_t localSector = fSector; | |
332 | if (!fAutoTrans) localSector = 4; | |
333 | ||
334 | //fTOFgeometry->GetVolumePath(det,path); | |
335 | fTOFgeometry->GetVolumePath(localSector,path); | |
336 | fGeoManager->cd(path); | |
337 | TGeoHMatrix global = *fGeoManager->GetCurrentMatrix(); | |
338 | Double_t *rotMat = global.GetRotationMatrix(); | |
339 | Double_t *tr = global.GetTranslation(); | |
340 | ||
341 | fHMTrans.SetBaseVec(1, rotMat[0], rotMat[3], rotMat[6]); | |
342 | fHMTrans.SetBaseVec(2, rotMat[1], rotMat[4], rotMat[7]); | |
343 | fHMTrans.SetBaseVec(3, rotMat[2], rotMat[5], rotMat[8]); | |
344 | ||
345 | fHMTrans.SetBaseVec(4, tr); | |
346 | } | |
347 | ||
348 | //----------------------------------------------------- | |
349 | ||
d810d0de | 350 | void AliEveTOFSector::SetSectorID(Int_t id) |
8616d353 | 351 | { |
352 | fSectorID = id; | |
353 | fSector = id; | |
354 | if (fAutoTrans) | |
355 | SetTrans(); // Force repositioning. | |
356 | ||
357 | LoadQuads(); | |
358 | } | |
359 | ||
360 | //----------------------------------------------------- | |
361 | ||
d810d0de | 362 | void AliEveTOFSector::SetPlate(Int_t nPlate, Bool_t r) |
8616d353 | 363 | { |
364 | ||
365 | fPlateFlag[nPlate] = r; | |
366 | ||
367 | //printf(" HELLO World ! %i %i %i \n", nPlate, r, fPlateFlag[nPlate]); | |
368 | } | |
369 | ||
57ffa5fb | 370 | /******************************************************************************/ |
8616d353 | 371 | |
d810d0de | 372 | void AliEveTOFSector::SetThreshold(Short_t t) |
8616d353 | 373 | { |
374 | fThreshold = TMath::Min(t, (Short_t)(fMaxVal - 1)); | |
375 | // ClearColorArray(); | |
376 | } | |
377 | ||
57ffa5fb | 378 | /******************************************************************************/ |
8616d353 | 379 | |
d810d0de | 380 | void AliEveTOFSector::SetMaxVal(Int_t mv) |
8616d353 | 381 | { |
382 | fMaxVal = TMath::Max(mv, (Int_t)(fThreshold + 1)); | |
383 | //ClearColorArray(); | |
384 | } | |
385 | ||
57ffa5fb | 386 | /******************************************************************************/ |
8616d353 | 387 | |
d810d0de | 388 | void AliEveTOFSector::DigitSelected(Int_t idx) |
8616d353 | 389 | { |
ee9d8eca | 390 | // Override control-click from TEveQuadSet |
8616d353 | 391 | |
84aff7a4 | 392 | DigitBase_t* qb = GetDigit(idx); |
8616d353 | 393 | TObject* obj = qb->fId.GetObject(); |
394 | AliTOFdigit* digs = dynamic_cast<AliTOFdigit*>(obj); | |
d810d0de | 395 | // printf("AliEveTOFSector::QuadSelected "); Print(); |
ee9d8eca | 396 | /* |
8616d353 | 397 | printf(" idx = %5i, value = %5d, obj = 0x%lx, digit = 0x%lx ", |
398 | idx, qb->fValue, (ULong_t)obj, (ULong_t)digs); | |
ee9d8eca | 399 | */ |
8616d353 | 400 | if (digs) |
ee9d8eca | 401 | printf("\n Sector = %2i Plate = %1i Strip = %2i PadZ = %1i PadX = %2i ToT = %3i Tof = %5i\n", |
402 | fSector , digs->GetPlate(), digs->GetStrip(), digs->GetPadz(), digs->GetPadx(), digs->GetToT(), digs->GetTdc()); | |
8616d353 | 403 | else printf("\n"); |
404 | ||
405 | } | |
406 | ||
57ffa5fb | 407 | /******************************************************************************/ |