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