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