2 // Main authors: Matevz Tadel & Alja Mrak-Tadel & Bogdan Vulpescu: 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 **************************************************************************/
9 #include "AliEveMUONChamber.h"
11 #include <EveDet/AliEveMUONData.h>
12 #include <EveDet/AliEveMUONChamberData.h>
14 #include <TBuffer3D.h>
15 #include <TBuffer3DTypes.h>
16 #include <TVirtualPad.h>
17 #include <TVirtualViewer3D.h>
21 //______________________________________________________________________________
25 ClassImp(AliEveMUONChamber)
27 //______________________________________________________________________________
28 AliEveMUONChamber::AliEveMUONChamber(Int_t id, const Text_t* n, const Text_t* t) :
29 TEveElement(fFrameColor),
51 sprintf(name,"Chamber %02d (trac)",id);
53 sprintf(name,"Chamber %02d (trig)",id);
61 //______________________________________________________________________________
62 AliEveMUONChamber::~AliEveMUONChamber()
68 if(fMUONData) fMUONData->DecRefCount();
72 //______________________________________________________________________________
73 void AliEveMUONChamber::ComputeBBox()
79 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2)
92 Float_t* b1 = fQuadSet1.AssertBBox();
93 for(Int_t i=0; i<6; ++i) { b1[i] = fBBox[i]; }
94 Float_t* b2 = fQuadSet2.AssertBBox();
95 for(Int_t i=0; i<6; ++i) { b2[i] = fBBox[i]; }
96 Float_t* b3 = fPointSet1.AssertBBox();
97 for(Int_t i=0; i<6; ++i) { b3[i] = fBBox[i]; }
98 Float_t* b4 = fPointSet2.AssertBBox();
99 for(Int_t i=0; i<6; ++i) { b4[i] = fBBox[i]; }
103 //______________________________________________________________________________
104 void AliEveMUONChamber::Paint(Option_t*)
110 if(fRnrSelf == kFALSE)
113 TBuffer3D buffer(TBuffer3DTypes::kGeneric);
117 buffer.fTransparency = 0;
118 buffer.fLocalFrame = 0;
120 buffer.SetSectionsValid(TBuffer3D::kCore);
121 Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer);
122 if (reqSections == TBuffer3D::kNone) {
123 //printf("AliEveMUONChamber::Paint viewer was happy with Core buff3d.\n");
127 printf("AliEveMUONChamber::Paint only GL supported.\n");
132 //______________________________________________________________________________
133 void AliEveMUONChamber::SetThreshold(Short_t t)
136 // digits amplitude threshold
139 fThreshold = TMath::Min(t, (Short_t)(fMaxVal - 1));
145 //______________________________________________________________________________
146 void AliEveMUONChamber::SetMaxVal(Int_t mv)
149 // digits amplitude maximum value
152 fMaxVal = TMath::Max(mv, (Int_t)(fThreshold + 1));
158 //______________________________________________________________________________
159 void AliEveMUONChamber::SetClusterSize(Int_t size)
162 // cluster point size
165 fClusterSize = TMath::Max(1, size);
170 //______________________________________________________________________________
171 void AliEveMUONChamber::SetHitSize(Int_t size)
177 fHitSize = TMath::Max(1, size);
182 //______________________________________________________________________________
183 void AliEveMUONChamber::SetupColor(Int_t val, UChar_t* pixel) const
186 // RGBA color for amplitude "val"
189 Float_t div = TMath::Max(1, fMaxVal - fThreshold);
190 Int_t nCol = gStyle->GetNumberOfColors();
191 Int_t cBin = (Int_t) TMath::Nint(nCol*(val - fThreshold)/div);
193 TEveUtil::TEveUtil::ColorFromIdx(gStyle->GetColorPalette(TMath::Min(nCol - 1, cBin)), pixel);
197 //______________________________________________________________________________
198 Int_t AliEveMUONChamber::ColorIndex(Int_t val) const
204 if(val < fThreshold) val = fThreshold;
205 if(val > fMaxVal) val = fMaxVal;
207 Float_t div = TMath::Max(1, fMaxVal - fThreshold);
208 Int_t nCol = gStyle->GetNumberOfColors();
209 Int_t cBin = (Int_t) TMath::Nint(nCol*(val - fThreshold)/div);
211 return gStyle->GetColorPalette(TMath::Min(nCol - 1, cBin));
215 //______________________________________________________________________________
216 void AliEveMUONChamber::SetupColorArray() const
219 // build array of colors
225 fColorArray = new UChar_t [4 * (fMaxVal - fThreshold + 1)];
226 UChar_t* p = fColorArray;
227 for(Int_t v=fThreshold; v<=fMaxVal; ++v, p+=4)
232 //______________________________________________________________________________
233 void AliEveMUONChamber::ClearColorArray()
236 // delete array of colors
240 delete [] fColorArray;
245 //______________________________________________________________________________
246 void AliEveMUONChamber::SetDataSource(AliEveMUONData* data)
248 // Set source of data.
250 if (data == fMUONData) return;
251 if(fMUONData) fMUONData->DecRefCount();
253 if(fMUONData) fMUONData->IncRefCount();
257 //______________________________________________________________________________
258 AliEveMUONChamberData* AliEveMUONChamber::GetChamberData() const
260 // Return source of data.
262 return fMUONData ? fMUONData->GetChamberData(fChamberID) : 0;
265 //______________________________________________________________________________
266 void AliEveMUONChamber::UpdateQuads()
268 // Update digit representation.
270 fQuadSet1.Reset(TEveQuadSet::kQT_RectangleXY, kTRUE, 32);
271 fQuadSet2.Reset(TEveQuadSet::kQT_RectangleXY, kTRUE, 32);
275 AliEveMUONChamberData* data = GetChamberData();
278 Float_t x0, y0, z, w, h, clsq;
279 Int_t charge, cathode, nDigits, nClusters, nHits, oldSize, ic1, ic2;
280 Double_t clsX, clsY, clsZ;
281 Float_t hitX, hitY, hitZ;
289 nDigits = data->GetNDigits();
291 for (Int_t id = 0; id < nDigits; id++) {
293 buffer = data->GetDigitBuffer(id);
295 x0 = buffer[0]-buffer[2];
296 y0 = buffer[1]-buffer[3];
300 charge = (Int_t)buffer[5];
301 cathode = (Int_t)buffer[6];
303 if (charge <= fThreshold) continue;
307 fQuadSet1.AddQuad(x0, y0, z, w, h);
308 fQuadSet1.QuadColor(ColorIndex(charge));
314 fQuadSet2.AddQuad(x0, y0, z, w, h);
315 fQuadSet2.QuadColor(ColorIndex(charge));
323 nClusters = data->GetNClusters()/2; // only one cathode plane
324 oldSize = fPointSet1.GrowFor(nClusters);
326 for (Int_t ic = 0; ic < (nClusters*2); ic++) {
328 buffer = data->GetClusterBuffer(ic);
330 clsX = (Double_t)buffer[0];
331 clsY = (Double_t)buffer[1];
332 clsZ = (Double_t)buffer[2];
334 cathode = (Int_t)buffer[4];
337 fPointSet1.SetPoint(ic1,clsX,clsY,clsZ);
341 } // end clusters loop
345 nHits = data->GetNHits();
346 oldSize = fPointSet2.GrowFor(nHits);
347 for (Int_t ih = 0; ih < nHits; ih++) {
348 buffer = data->GetHitBuffer(ih);
352 fPointSet2.SetPoint(ih,hitX,hitY,hitZ);
359 //______________________________________________________________________________
360 void AliEveMUONChamber::SetChamberID(Int_t id)
362 // Set id of chamber to display.
365 if (id > 13) id = 13;