2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
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 **************************************************************************/
10 #include "AliEveTOFStrip.h"
12 #include <TEveManager.h>
14 #include <AliTOFdigit.h>
15 #include <AliTOFGeometry.h>
19 Bool_t AliEveTOFStrip::fgStaticInitDone = kFALSE;
20 TEveFrameBox* AliEveTOFStrip::fgTOFstripFrameBox = 0;
21 TEveRGBAPalette* AliEveTOFStrip::fgTOFstripPalette = 0;
23 //_______________________________________________________
24 ClassImp(AliEveTOFStrip)
26 /* ************************************************************************ */
28 AliEveTOFStrip::AliEveTOFStrip(const Text_t* n, const Text_t* t) :
30 fTOFgeometry(new AliTOFGeometry()),
32 fThreshold (5), fMaxVal (80),
33 fSector(-1), fPlate(-1), fStrip(-1),
38 //fGeoManager = (TGeoManager*)gEve->GetGeometry("$REVESYS/alice-data/alice_fullgeo.root");
39 if (!fGeoManager) printf("ERROR: no TGeo\n");
42 /* ************************************************************************ */
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()),
49 fThreshold (5), fMaxVal (80),
50 fSector(nSector), fPlate(nPlate), fStrip(nStrip),
52 fGeoManager(localGeoManager)
55 //if (!fGeoManager) printf("ERROR: no TGeo\n");
60 /* ************************************************************************ */
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()),
68 fThreshold (5), fMaxVal (80),
69 fSector(nSector), fPlate(nPlate), fStrip(nStrip),
71 fGeoManager(localGeoManager)
77 /* ************************************************************************ */
79 AliEveTOFStrip::~AliEveTOFStrip()
90 /* ************************************************************************ */
92 void AliEveTOFStrip::SetDigitsInfo(AliEveTOFDigitsInfo* info)
94 if(fInfo) fInfo->DecRefCount();
96 if(fInfo) fInfo->IncRefCount();
100 /* ************************************************************************ */
101 void AliEveTOFStrip::InitStatics()
103 if (fgStaticInitDone) return;
107 fgTOFstripFrameBox = new TEveFrameBox();
109 fgTOFstripFrameBox->SetAAQuadXZ(-dx*0.5, 0, -dz*0.5, dx, dz);
110 fgTOFstripFrameBox->SetFrameColor((Color_t) 32);//31);
112 //fgTOFstripPalette = new TEveRGBAPalette(0, 2048); // TOT
113 fgTOFstripPalette = new TEveRGBAPalette(0, 8192); // TDC
114 fgTOFstripPalette->SetOverflowAction(0);
116 fgStaticInitDone = kTRUE;
119 /* ************************************************************************ */
120 void AliEveTOFStrip::InitModule()
123 fDx = fTOFgeometry->XPad()*fTOFgeometry->NpadX();
124 fDz = fTOFgeometry->ZPad()*fTOFgeometry->NpadZ();
126 if (!fgStaticInitDone) InitStatics();
128 SetFrame(fgTOFstripFrameBox);
129 SetPalette(fgTOFstripPalette);
130 //fFrame = fgTOFstripFrameBox;
131 //fPalette = fgTOFstripPalette;
139 /* ************************************************************************ */
140 void AliEveTOFStrip::LoadQuads()
143 //Int_t n_col = gStyle->GetNumberOfColors();
152 Reset(kQT_RectangleXZFixedY, kFALSE, 32);
154 AliTOFdigit *tofDigit;
156 //printf(" fTOFarray->GetEntries() = %4i \n",fTOFarray->GetEntries());
158 for (Int_t ii=0; ii<fTOFarray->GetEntries(); ii++) {
160 tofDigit = (AliTOFdigit*)fTOFarray->UncheckedAt(ii);
162 iPadX = tofDigit->GetPadx();
163 iPadZ = tofDigit->GetPadz();
165 tot = tofDigit->GetToT();
166 tdc = tofDigit->GetTdc();
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);
171 fTOFgeometry->DetToStripRF(iPadX, iPadZ, x, z);
173 AddQuad(x, z, 2.5, 3.5);
174 //AddQuad(-2.5*0.5, -3.5*0.5, 2.5, 3.5);
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);
182 //if (fSector==4 && fPlate==2 && fStrip==0) printf(" %1i %2i %f %f \n", iPadZ, iPadX, x, z);
190 /* ************************************************************ */
191 void AliEveTOFStrip::SetTrans()
193 //Int_t det[5] = {fSector, fPlate, fStrip, -1, -1};
195 //fTOFgeometry->GetVolumePath(det,path);
196 fTOFgeometry->GetVolumePath(fSector, fPlate, fStrip, path);
198 fGeoManager->cd(path);
199 SetTransMatrix(*fGeoManager->GetCurrentMatrix());
202 /******************************************************************************/
203 void AliEveTOFStrip::SetThreshold(Short_t t)
205 fThreshold = TMath::Min(t, (Short_t)(fMaxVal - 1));
206 // ClearColorArray();
209 /******************************************************************************/
211 void AliEveTOFStrip::SetMaxVal(Int_t mv)
213 fMaxVal = TMath::Max(mv, (Int_t)(fThreshold + 1));
217 /******************************************************************************/
219 void AliEveTOFStrip::DigitSelected(Int_t idx)
221 // Override control-click from TEveQuadSet
223 DigitBase_t* qb = GetDigit(idx);
224 TObject* obj = qb->fId.GetObject();
225 AliTOFdigit* digs = dynamic_cast<AliTOFdigit*>(obj);
226 // printf("AliEveTOFStrip::QuadSelected "); Print();
228 printf(" idx = %5i, value = %5d, obj = 0x%lx, digit = 0x%lx ",
229 idx, qb->fValue, (ULong_t)obj, (ULong_t)digs);
232 printf("\n Sector = %2i Plate = %1i Strip = %2i PadZ = %1i PadX = %2i ToT = %3i Tof = %5i\n",
233 fSector , fPlate, fStrip, digs->GetPadz(), digs->GetPadx(), digs->GetToT(), digs->GetTdc());
238 /******************************************************************************/