]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveDet/AliEveTOFStrip.cxx
From Massimo: remove usage of AliITSgeom, use AliITSgeomTGeo instead.
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveTOFStrip.cxx
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
10 #include "AliEveTOFStrip.h"
11
12 #include <TEveManager.h>
13
14 #include <AliTOFdigit.h>
15 #include <AliTOFGeometry.h>
16
17 #include <TStyle.h>
18
19 Bool_t           AliEveTOFStrip::fgStaticInitDone   = kFALSE;
20 TEveFrameBox*    AliEveTOFStrip::fgTOFstripFrameBox = 0;
21 TEveRGBAPalette* AliEveTOFStrip::fgTOFstripPalette  = 0;
22
23 //_______________________________________________________
24 ClassImp(AliEveTOFStrip)
25
26 /* ************************************************************************ */
27
28 AliEveTOFStrip::AliEveTOFStrip(const Text_t* n, const Text_t* t) :
29   TEveQuadSet(n, t),
30   fTOFgeometry(new AliTOFGeometry()),
31   fTOFarray(0),
32   fThreshold (5), fMaxVal (80),
33   fSector(-1), fPlate(-1), fStrip(-1),
34   fDx(0), fDz(0),
35   fGeoManager(0)
36 {
37
38   //fGeoManager = (TGeoManager*)gEve->GetGeometry("$REVESYS/alice-data/alice_fullgeo.root");
39   if (!fGeoManager) printf("ERROR: no TGeo\n");
40
41 }
42 /* ************************************************************************ */
43
44 AliEveTOFStrip::AliEveTOFStrip(TGeoManager *localGeoManager,
45                                Int_t nSector, Int_t nPlate, Int_t nStrip) :
46   TEveQuadSet(Form("Strip%i", nStrip)),
47   fTOFgeometry(new AliTOFGeometry()),
48   fTOFarray(0),
49   fThreshold (5), fMaxVal (80),
50   fSector(nSector), fPlate(nPlate), fStrip(nStrip),
51   fDx(0), fDz(0),
52   fGeoManager(localGeoManager)
53 {
54
55   //if (!fGeoManager) printf("ERROR: no TGeo\n");
56
57   InitModule();
58
59 }
60 /* ************************************************************************ */
61
62 AliEveTOFStrip::AliEveTOFStrip(TGeoManager *localGeoManager,
63                                Int_t nSector, Int_t nPlate, Int_t nStrip,
64                                TClonesArray *tofArray) :
65   TEveQuadSet(Form("Strip%i", nStrip)),
66   fTOFgeometry(new AliTOFGeometry()),
67   fTOFarray(tofArray),
68   fThreshold (5), fMaxVal (80),
69   fSector(nSector), fPlate(nPlate), fStrip(nStrip),
70   fDx(0), fDz(0),
71   fGeoManager(localGeoManager)
72 {
73
74   InitModule();
75
76 }
77 /* ************************************************************************ */
78
79 AliEveTOFStrip::~AliEveTOFStrip()
80 {
81
82   fGeoManager = 0x0;
83   delete fGeoManager;
84
85   fTOFarray = 0x0;
86   delete fTOFarray;
87
88 }
89
90 /* ************************************************************************ */
91 /*
92 void AliEveTOFStrip::SetDigitsInfo(AliEveTOFDigitsInfo* info)
93 {
94   if(fInfo) fInfo->DecRefCount();
95   fInfo = info;
96   if(fInfo) fInfo->IncRefCount();
97
98 }
99 */
100 /* ************************************************************************ */
101 void AliEveTOFStrip::InitStatics()
102 {
103   if (fgStaticInitDone) return;
104
105   Float_t dx = 2.5*48;
106   Float_t dz = 3.5*2;
107   fgTOFstripFrameBox = new TEveFrameBox();
108
109   fgTOFstripFrameBox->SetAAQuadXZ(-dx*0.5, 0, -dz*0.5, dx, dz);
110   fgTOFstripFrameBox->SetFrameColor((Color_t) 32);//31);
111
112   //fgTOFstripPalette  = new TEveRGBAPalette(0, 2048); // TOT
113   fgTOFstripPalette  = new TEveRGBAPalette(0, 8192); // TDC
114   fgTOFstripPalette->SetOverflowAction(0);
115
116   fgStaticInitDone = kTRUE;
117 }
118
119 /* ************************************************************************ */
120 void AliEveTOFStrip::InitModule()
121 {
122
123   fDx = fTOFgeometry->XPad()*fTOFgeometry->NpadX();
124   fDz = fTOFgeometry->ZPad()*fTOFgeometry->NpadZ();
125
126   if (!fgStaticInitDone) InitStatics();
127
128   SetFrame(fgTOFstripFrameBox);
129   SetPalette(fgTOFstripPalette);
130   //fFrame   = fgTOFstripFrameBox;
131   //fPalette = fgTOFstripPalette;
132
133   LoadQuads();
134   ComputeBBox();
135   SetTrans();
136
137 }
138
139 /* ************************************************************************ */
140 void AliEveTOFStrip::LoadQuads()
141 {
142
143   //Int_t n_col = gStyle->GetNumberOfColors();
144
145   Int_t iPadX = -1;
146   Int_t iPadZ = -1;
147   Int_t tdc = -1;
148   Int_t tot = -1;
149   Float_t x = -1;
150   Float_t z = -1;
151
152   Reset(kQT_RectangleXZFixedY, kFALSE, 32);
153
154   AliTOFdigit *tofDigit;
155
156   //printf(" fTOFarray->GetEntries() = %4i \n",fTOFarray->GetEntries());
157
158   for (Int_t ii=0; ii<fTOFarray->GetEntries(); ii++) {
159
160     tofDigit = (AliTOFdigit*)fTOFarray->UncheckedAt(ii);
161
162     iPadX = tofDigit->GetPadx();
163     iPadZ = tofDigit->GetPadz();
164
165     tot = tofDigit->GetToT();
166     tdc = tofDigit->GetTdc();
167
168     //if (fSector==4 && fPlate==2 && fStrip==0) printf(" %2i  %1i\n", iPadX, iPadZ);
169     //if (iPadX==23 || iPadX==24) printf(" %2i  %1i %2i \n", fSector, fPlate, fStrip);
170
171     fTOFgeometry->DetToStripRF(iPadX, iPadZ, x, z);
172
173     AddQuad(x, z, 2.5, 3.5);
174     //AddQuad(-2.5*0.5, -3.5*0.5, 2.5, 3.5);
175
176     // In principle could have color based on number of neigbours. We
177     // can insert the time-of-flight value for each pad
178     //QuadValue((Int_t)tot);
179     QuadValue((Int_t)tdc);
180     QuadId(tofDigit);
181
182     //if (fSector==4 && fPlate==2  && fStrip==0) printf("  %1i   %2i    %f  %f \n", iPadZ, iPadX, x, z);
183
184   }
185
186   RefitPlex();
187
188 }
189
190 /* ************************************************************ */
191 void AliEveTOFStrip::SetTrans()
192 {
193
194   fHMTrans.UnitTrans();
195
196   //Int_t det[5] = {fSector, fPlate, fStrip, -1, -1};
197   Char_t path[100];
198   //fTOFgeometry->GetVolumePath(det,path);
199   fTOFgeometry->GetVolumePath(fSector, fPlate, fStrip, path);
200
201   fGeoManager->cd(path);
202   TGeoHMatrix global = *fGeoManager->GetCurrentMatrix();
203   Double_t *rotMat = global.GetRotationMatrix();
204
205   /*
206   // ok till 19 April 2007
207   fHMTrans.SetBaseVec(1, rotMat[0], rotMat[1], rotMat[2]);
208   fHMTrans.SetBaseVec(2, rotMat[3], rotMat[4], rotMat[5]);
209   fHMTrans.SetBaseVec(3, rotMat[6], rotMat[7], rotMat[8]);
210   */
211
212   fHMTrans.SetBaseVec(1, rotMat[0], rotMat[3], rotMat[6]);
213   fHMTrans.SetBaseVec(2, rotMat[1], rotMat[4], rotMat[7]);
214   fHMTrans.SetBaseVec(3, rotMat[2], rotMat[5], rotMat[8]);
215
216   Double_t *tr = global.GetTranslation();
217   fHMTrans.SetBaseVec(4, tr);
218
219 }
220
221 /******************************************************************************/
222 void AliEveTOFStrip::SetThreshold(Short_t t)
223 {
224   fThreshold = TMath::Min(t, (Short_t)(fMaxVal - 1));
225   // ClearColorArray();
226 }
227
228 /******************************************************************************/
229
230 void AliEveTOFStrip::SetMaxVal(Int_t mv)
231 {
232   fMaxVal = TMath::Max(mv, (Int_t)(fThreshold + 1));
233   //ClearColorArray();
234 }
235
236 /******************************************************************************/
237
238 void AliEveTOFStrip::DigitSelected(Int_t idx)
239 {
240   // Override control-click from TEveQuadSet
241
242   DigitBase_t* qb   = GetDigit(idx);
243   TObject* obj   = qb->fId.GetObject();
244   AliTOFdigit* digs = dynamic_cast<AliTOFdigit*>(obj);
245   // printf("AliEveTOFStrip::QuadSelected "); Print();
246   /*
247   printf("  idx = %5i, value = %5d, obj = 0x%lx, digit = 0x%lx  ",
248          idx, qb->fValue, (ULong_t)obj, (ULong_t)digs);
249   */
250   if (digs)
251     printf("\n Sector = %2i  Plate = %1i  Strip = %2i  PadZ = %1i PadX = %2i  ToT = %3i  Tof = %5i\n",
252            fSector , fPlate, fStrip, digs->GetPadz(), digs->GetPadx(), digs->GetToT(), digs->GetTdc());
253   else printf("\n");
254
255 }
256
257 /******************************************************************************/