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