]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveDet/AliEveTOFStrip.cxx
EveBase and EveDet
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveTOFStrip.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
3  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
4  * full copyright notice.                                                 *
5  **************************************************************************/
6
7 // $Id$
8 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
9
10 //
11 // Class to visualize the TOF digit information
12 // in TOF sector frame
13 //
14 // Author: A. De Caro (email: decaro@sa.infn.t)
15 //
16
17 #include <TStyle.h>
18
19 #include <TGeoManager.h>
20 #include <TClonesArray.h>
21
22 #include <TEveManager.h>
23 #include <TEveRGBAPalette.h>
24 #include <TEveFrameBox.h>
25
26 #include <AliTOFdigit.h>
27 #include <AliTOFGeometry.h>
28
29 #include "AliEveTOFStrip.h"
30
31 Bool_t           AliEveTOFStrip::fgStaticInitDone   = kFALSE;
32 TEveFrameBox*    AliEveTOFStrip::fgTOFstripFrameBox = 0;
33 TEveRGBAPalette* AliEveTOFStrip::fgTOFstripPalette  = 0;
34
35 //_______________________________________________________
36 ClassImp(AliEveTOFStrip)
37
38 /* ************************************************************************ */
39
40 AliEveTOFStrip::AliEveTOFStrip(const Text_t* n, const Text_t* t) :
41   TEveQuadSet(n, t),
42   fTOFgeometry(new AliTOFGeometry()),
43   fTOFarray(0),
44   fThreshold (5), fMaxVal (80),
45   fSector(-1), fPlate(-1), fStrip(-1),
46   fDx(0), fDz(0),
47   fGeoManager(0)
48 {
49   // ctr
50
51   //fGeoManager = AliEveEventManager::AssertGeometry();
52   if (!fGeoManager) printf("ERROR: no TGeo\n");
53
54 }
55 /* ************************************************************************ */
56
57 AliEveTOFStrip::AliEveTOFStrip(TGeoManager *localGeoManager,
58                                Int_t nSector, Int_t nPlate, Int_t nStrip) :
59   TEveQuadSet(Form("Strip%i", nStrip)),
60   fTOFgeometry(new AliTOFGeometry()),
61   fTOFarray(0),
62   fThreshold (5), fMaxVal (80),
63   fSector(nSector), fPlate(nPlate), fStrip(nStrip),
64   fDx(0), fDz(0),
65   fGeoManager(localGeoManager)
66 {
67   // ctr
68
69   //if (!fGeoManager) printf("ERROR: no TGeo\n");
70
71   InitModule();
72
73 }
74 /* ************************************************************************ */
75
76 AliEveTOFStrip::AliEveTOFStrip(TGeoManager *localGeoManager,
77                                Int_t nSector, Int_t nPlate, Int_t nStrip,
78                                TClonesArray *tofArray) :
79   TEveQuadSet(Form("Strip%i", nStrip)),
80   fTOFgeometry(new AliTOFGeometry()),
81   fTOFarray(tofArray),
82   fThreshold (5), fMaxVal (80),
83   fSector(nSector), fPlate(nPlate), fStrip(nStrip),
84   fDx(0), fDz(0),
85   fGeoManager(localGeoManager)
86 {
87   // ctr
88
89   InitModule();
90
91 }
92 /* ************************************************************************ */
93
94 AliEveTOFStrip::~AliEveTOFStrip()
95 {
96   // dtr
97
98   fGeoManager = 0x0;
99   delete fGeoManager;
100
101   fTOFarray = 0x0;
102   delete fTOFarray;
103
104 }
105
106 /* ************************************************************************ */
107 /*
108 void AliEveTOFStrip::SetDigitsInfo(AliEveTOFDigitsInfo* info)
109 {
110   if(fInfo) fInfo->DecRefCount();
111   fInfo = info;
112   if(fInfo) fInfo->IncRefCount();
113
114 }
115 */
116 /* ************************************************************************ */
117 void AliEveTOFStrip::InitStatics()
118 {
119   //
120   // To initialize statistic variables
121   //
122
123   if (fgStaticInitDone) return;
124
125   Float_t dx = 2.5*48;
126   Float_t dz = 3.5*2;
127   fgTOFstripFrameBox = new TEveFrameBox();
128
129   fgTOFstripFrameBox->SetAAQuadXZ(-dx*0.5, 0, -dz*0.5, dx, dz);
130   fgTOFstripFrameBox->SetFrameColor(Color_t(32));
131   fgTOFstripFrameBox->IncRefCount();
132
133   //fgTOFstripPalette  = new TEveRGBAPalette(0, 2048); // TOT
134   //fgTOFstripPalette  = new TEveRGBAPalette(0, 192); // TDC
135   fgTOFstripPalette  = new TEveRGBAPalette(0, 100000); // TDC
136   fgTOFstripPalette->SetOverflowAction(2);
137   fgTOFstripPalette->SetUnderflowAction(2);
138   fgTOFstripPalette->IncRefCount();
139
140   fgStaticInitDone = kTRUE;
141 }
142
143 /* ************************************************************************ */
144 void AliEveTOFStrip::InitModule()
145 {
146   //
147   // To initialize TOF strip frame variables
148   //
149
150   fDx = fTOFgeometry->XPad()*fTOFgeometry->NpadX();
151   fDz = fTOFgeometry->ZPad()*fTOFgeometry->NpadZ();
152
153   if (!fgStaticInitDone) InitStatics();
154
155   SetFrame(fgTOFstripFrameBox);
156   SetPalette(fgTOFstripPalette);
157   //fFrame   = fgTOFstripFrameBox;
158   //fPalette = fgTOFstripPalette;
159
160   LoadQuads();
161   ComputeBBox();
162   SetTrans();
163
164 }
165
166 /* ************************************************************************ */
167 void AliEveTOFStrip::LoadQuads()
168 {
169   //
170   // Load TOF digit as illuminated pad
171   //
172
173   Int_t iPadX = -1;
174   Int_t iPadZ = -1;
175   Int_t tdc = -1;
176   Int_t tot = -1;
177   Float_t x = -1;
178   Float_t z = -1;
179
180   Reset(kQT_RectangleXZFixedY, kFALSE, 32);
181
182   AliTOFdigit *tofDigit;
183
184   //printf(" fTOFarray->GetEntries() = %4i \n",fTOFarray->GetEntries());
185
186   for (Int_t ii=0; ii<fTOFarray->GetEntries(); ii++) {
187
188     tofDigit = (AliTOFdigit*)fTOFarray->UncheckedAt(ii);
189
190     iPadX = tofDigit->GetPadx();
191     iPadZ = tofDigit->GetPadz();
192
193     tot = tofDigit->GetToT();
194     tdc = tofDigit->GetTdc();
195
196     //if (fSector==4 && fPlate==2 && fStrip==0) printf(" %2i  %1i\n", iPadX, iPadZ);
197     //if (iPadX==23 || iPadX==24) printf(" %2i  %1i %2i \n", fSector, fPlate, fStrip);
198
199     fTOFgeometry->DetToStripRF(iPadX, iPadZ, x, z);
200
201     AddQuad(x, z, 2.5, 3.5);
202     //AddQuad(-2.5*0.5, -3.5*0.5, 2.5, 3.5);
203
204     // In principle could have color based on number of neigbours. We
205     // can insert the time-of-flight value for each pad
206     //QuadValue((Int_t)tot);
207     QuadValue((Int_t)tdc);
208     QuadId(tofDigit);
209
210     //if (fSector==4 && fPlate==2  && fStrip==0) printf("  %1i   %2i    %f  %f \n", iPadZ, iPadX, x, z);
211
212   }
213
214   RefitPlex();
215
216 }
217
218 /* ************************************************************ */
219 void AliEveTOFStrip::SetTrans()
220 {
221   //
222   // Set the translation matrix for TOF sector
223   //
224
225   //Int_t det[5] = {fSector, fPlate, fStrip, -1, -1};
226   Char_t path[200];
227   //fTOFgeometry->GetVolumePath(det,path);
228   fTOFgeometry->GetVolumePath(fSector, fPlate, fStrip, path);
229
230   fGeoManager->cd(path);
231   SetTransMatrix(*fGeoManager->GetCurrentMatrix());
232 }
233
234 /******************************************************************************/
235 void AliEveTOFStrip::SetThreshold(Short_t t)
236 {
237   //
238   // Set visualization threshold
239   //
240
241   fThreshold = TMath::Min(t, (Short_t)(fMaxVal - 1));
242   // ClearColorArray();
243 }
244
245 /******************************************************************************/
246
247 void AliEveTOFStrip::SetMaxVal(Int_t mv)
248 {
249   //
250   // Set visualization max value
251   //
252
253   fMaxVal = TMath::Max(mv, (Int_t)(fThreshold + 1));
254   //ClearColorArray();
255 }
256
257 /******************************************************************************/
258
259 void AliEveTOFStrip::DigitSelected(Int_t idx)
260 {
261   //
262   // Printout infos for TOF digit number idx
263   //
264
265   // Override control-click from TEveQuadSet
266
267   TObject* obj = GetId(idx);
268   AliTOFdigit* digs = dynamic_cast<AliTOFdigit*>(obj);
269   // printf("AliEveTOFStrip::QuadSelected "); Print();
270
271   if (digs)
272     printf("\n Sector = %2i  Plate = %1i  Strip = %2i  PadZ = %1i PadX = %2i  ToT = %3i  Tof = %5i\n",
273            fSector , fPlate, fStrip, digs->GetPadz(), digs->GetPadx(), digs->GetToT(), digs->GetTdc());
274   else printf("\n");
275
276 }
277
278 /******************************************************************************/