]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveDet/AliEveTOFStrip.cxx
ac53ca32bea55753c0b947801e083fa6988c8ff7
[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   fSector(-1), fPlate(-1), fStrip(-1),
33   fDx(0), fDz(0),
34   fGeoManager(0)
35 {
36
37   fGeoManager = (TGeoManager*)gEve->GetGeometry("$REVESYS/alice-data/alice_fullgeo.root");
38   if (!fGeoManager) printf("ERROR: no TGeo\n");
39
40 }
41 /* ************************************************************************ */
42
43 AliEveTOFStrip::AliEveTOFStrip(TGeoManager *localGeoManager,
44                                Int_t nSector, Int_t nPlate, Int_t nStrip) :
45   TEveQuadSet(Form("Strip%i", nStrip)),
46   fTOFgeometry(new AliTOFGeometry()),
47   fTOFarray(0),
48   fSector(nSector), fPlate(nPlate), fStrip(nStrip),
49   fDx(0), fDz(0),
50   fGeoManager(localGeoManager)
51 {
52
53   //if (!fGeoManager) printf("ERROR: no TGeo\n");
54
55   InitModule();
56
57 }
58 /* ************************************************************************ */
59
60 AliEveTOFStrip::AliEveTOFStrip(TGeoManager *localGeoManager,
61                                Int_t nSector, Int_t nPlate, Int_t nStrip,
62                                TClonesArray *tofArray) :
63   TEveQuadSet(Form("Strip%i", nStrip)),
64   fTOFgeometry(new AliTOFGeometry()),
65   fTOFarray(tofArray),
66   fSector(nSector), fPlate(nPlate), fStrip(nStrip),
67   fDx(0), fDz(0),
68   fGeoManager(localGeoManager)
69 {
70
71   InitModule();
72
73 }
74 /* ************************************************************************ */
75
76 AliEveTOFStrip::~AliEveTOFStrip()
77 {
78
79   fGeoManager = 0x0;
80   delete fGeoManager;
81
82   fTOFarray = 0x0;
83   delete fTOFarray;
84
85 }
86
87 /* ************************************************************************ */
88 /*
89 void AliEveTOFStrip::SetDigitsInfo(AliEveTOFDigitsInfo* info)
90 {
91   if(fInfo) fInfo->DecRefCount();
92   fInfo = info;
93   if(fInfo) fInfo->IncRefCount();
94
95 }
96 */
97 /* ************************************************************************ */
98 void AliEveTOFStrip::InitStatics()
99 {
100   if (fgStaticInitDone) return;
101
102   Float_t dx = 2.5*48;
103   Float_t dz = 3.5*2;
104   fgTOFstripFrameBox = new TEveFrameBox();
105
106   fgTOFstripFrameBox->SetAAQuadXZ(-dx*0.5, 0, -dz*0.5, dx, dz);
107   fgTOFstripFrameBox->SetFrameColor((Color_t) 32);//31);
108
109   //fgTOFstripPalette  = new TEveRGBAPalette(0, 2048); // TOT
110   fgTOFstripPalette  = new TEveRGBAPalette(0, 8192); // TDC
111
112   fgStaticInitDone = kTRUE;
113 }
114
115 /* ************************************************************************ */
116 void AliEveTOFStrip::InitModule()
117 {
118
119   fDx = fTOFgeometry->XPad()*fTOFgeometry->NpadX();
120   fDz = fTOFgeometry->ZPad()*fTOFgeometry->NpadZ();
121
122   if (!fgStaticInitDone) InitStatics();
123
124   SetFrame(fgTOFstripFrameBox);
125   SetPalette(fgTOFstripPalette);
126   //fFrame   = fgTOFstripFrameBox;
127   //fPalette = fgTOFstripPalette;
128
129   LoadQuads();
130   ComputeBBox();
131   SetTrans();
132
133 }
134
135 /* ************************************************************************ */
136 void AliEveTOFStrip::LoadQuads()
137 {
138
139   //Int_t n_col = gStyle->GetNumberOfColors();
140
141   Int_t iPadX = -1;
142   Int_t iPadZ = -1;
143   Int_t tdc = -1;
144   Int_t tot = -1;
145   Float_t x = -1;
146   Float_t z = -1;
147
148   Reset(kQT_RectangleXZFixedY, kFALSE, 32);
149
150   AliTOFdigit *tofDigit;
151
152   //printf(" fTOFarray->GetEntries() = %4i \n",fTOFarray->GetEntries());
153
154   for (Int_t ii=0; ii<fTOFarray->GetEntries(); ii++) {
155
156     tofDigit = (AliTOFdigit*)fTOFarray->UncheckedAt(ii);
157
158     iPadX = tofDigit->GetPadx();
159     iPadZ = tofDigit->GetPadz();
160
161     tot = tofDigit->GetToT();
162     tdc = tofDigit->GetTdc();
163
164     //if (fSector==4 && fPlate==2 && fStrip==0) printf(" %2i  %1i\n", iPadX, iPadZ);
165     //if (iPadX==23 || iPadX==24) printf(" %2i  %1i %2i \n", fSector, fPlate, fStrip);
166
167     fTOFgeometry->DetToStripRF(iPadX, iPadZ, x, z);
168
169     AddQuad(x, z, 2.5, 3.5);
170     //AddQuad(-2.5*0.5, -3.5*0.5, 2.5, 3.5);
171
172     // In principle could have color based on number of neigbours. We
173     // can insert the time-of-flight value for each pad
174     //QuadValue((Int_t)tot);
175     QuadValue((Int_t)tdc);
176
177     //if (fSector==4 && fPlate==2  && fStrip==0) printf("  %1i   %2i    %f  %f \n", iPadZ, iPadX, x, z);
178
179   }
180
181   RefitPlex();
182
183 }
184
185 /* ************************************************************ */
186 void AliEveTOFStrip::SetTrans()
187 {
188
189   fHMTrans.UnitTrans();
190
191   //Int_t det[5] = {fSector, fPlate, fStrip, -1, -1};
192   Char_t path[100];
193   //fTOFgeometry->GetVolumePath(det,path);
194   fTOFgeometry->GetVolumePath(fSector, fPlate, fStrip, path);
195
196   fGeoManager->cd(path);
197   TGeoHMatrix global = *fGeoManager->GetCurrentMatrix();
198   Double_t *rotMat = global.GetRotationMatrix();
199
200   /*
201   // ok till 19 April 2007
202   fHMTrans.SetBaseVec(1, rotMat[0], rotMat[1], rotMat[2]);
203   fHMTrans.SetBaseVec(2, rotMat[3], rotMat[4], rotMat[5]);
204   fHMTrans.SetBaseVec(3, rotMat[6], rotMat[7], rotMat[8]);
205   */
206
207   fHMTrans.SetBaseVec(1, rotMat[0], rotMat[3], rotMat[6]);
208   fHMTrans.SetBaseVec(2, rotMat[1], rotMat[4], rotMat[7]);
209   fHMTrans.SetBaseVec(3, rotMat[2], rotMat[5], rotMat[8]);
210
211   Double_t *tr = global.GetTranslation();
212   fHMTrans.SetBaseVec(4, tr);
213
214 }