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 <AliEveMUONData.h>
12 #include <AliEveMUONChamberData.h>
14 #include <TBuffer3D.h>
15 #include <TBuffer3DTypes.h>
16 #include <TVirtualPad.h>
17 #include <TVirtualViewer3D.h>
22 //______________________________________________________________________________
26 ClassImp(AliEveMUONChamber)
28 //______________________________________________________________________________
29 AliEveMUONChamber::AliEveMUONChamber(Int_t id, const Text_t* n, const Text_t* t) :
30 TEveElement(fFrameColor),
52 snprintf(name,256,"Chamber %02d (trac)",id);
54 snprintf(name,256,"Chamber %02d (trig)",id);
62 //______________________________________________________________________________
63 AliEveMUONChamber::~AliEveMUONChamber()
69 if(fMUONData) fMUONData->DecRefCount();
73 //______________________________________________________________________________
74 void AliEveMUONChamber::ComputeBBox()
80 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2)
93 Float_t* b1 = fQuadSet1.AssertBBox();
94 for(Int_t i=0; i<6; ++i) { b1[i] = fBBox[i]; }
95 Float_t* b2 = fQuadSet2.AssertBBox();
96 for(Int_t i=0; i<6; ++i) { b2[i] = fBBox[i]; }
97 Float_t* b3 = fPointSet1.AssertBBox();
98 for(Int_t i=0; i<6; ++i) { b3[i] = fBBox[i]; }
99 Float_t* b4 = fPointSet2.AssertBBox();
100 for(Int_t i=0; i<6; ++i) { b4[i] = fBBox[i]; }
104 //______________________________________________________________________________
105 void AliEveMUONChamber::Paint(Option_t*)
111 if(fRnrSelf == kFALSE)
114 TBuffer3D buffer(TBuffer3DTypes::kGeneric);
118 buffer.fTransparency = 0;
119 buffer.fLocalFrame = 0;
121 buffer.SetSectionsValid(TBuffer3D::kCore);
122 Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer);
123 if (reqSections == TBuffer3D::kNone) {
124 //printf("AliEveMUONChamber::Paint viewer was happy with Core buff3d.\n");
128 printf("AliEveMUONChamber::Paint only GL supported.\n");
133 //______________________________________________________________________________
134 void AliEveMUONChamber::SetThreshold(Short_t t)
137 // digits amplitude threshold
140 fThreshold = TMath::Min(t, (Short_t)(fMaxVal - 1));
146 //______________________________________________________________________________
147 void AliEveMUONChamber::SetMaxVal(Int_t mv)
150 // digits amplitude maximum value
153 fMaxVal = TMath::Max(mv, (Int_t)(fThreshold + 1));
159 //______________________________________________________________________________
160 void AliEveMUONChamber::SetClusterSize(Int_t size)
163 // cluster point size
166 fClusterSize = TMath::Max(1, size);
171 //______________________________________________________________________________
172 void AliEveMUONChamber::SetHitSize(Int_t size)
178 fHitSize = TMath::Max(1, size);
183 //______________________________________________________________________________
184 void AliEveMUONChamber::SetupColor(Int_t val, UChar_t* pixel) const
187 // RGBA color for amplitude "val"
190 Float_t div = TMath::Max(1, fMaxVal - fThreshold);
191 Int_t nCol = gStyle->GetNumberOfColors();
192 Int_t cBin = (Int_t) TMath::Nint(nCol*(val - fThreshold)/div);
194 TEveUtil::TEveUtil::ColorFromIdx(gStyle->GetColorPalette(TMath::Min(nCol - 1, cBin)), pixel);
198 //______________________________________________________________________________
199 Int_t AliEveMUONChamber::ColorIndex(Int_t val) const
205 if(val < fThreshold) val = fThreshold;
206 if(val > fMaxVal) val = fMaxVal;
208 Float_t div = TMath::Max(1, fMaxVal - fThreshold);
209 Int_t nCol = gStyle->GetNumberOfColors();
210 Int_t cBin = (Int_t) TMath::Nint(nCol*(val - fThreshold)/div);
212 return gStyle->GetColorPalette(TMath::Min(nCol - 1, cBin));
216 //______________________________________________________________________________
217 void AliEveMUONChamber::SetupColorArray() const
220 // build array of colors
226 fColorArray = new UChar_t [4 * (fMaxVal - fThreshold + 1)];
227 UChar_t* p = fColorArray;
228 for(Int_t v=fThreshold; v<=fMaxVal; ++v, p+=4)
233 //______________________________________________________________________________
234 void AliEveMUONChamber::ClearColorArray()
237 // delete array of colors
241 delete [] fColorArray;
246 //______________________________________________________________________________
247 void AliEveMUONChamber::SetDataSource(AliEveMUONData* data)
249 // Set source of data.
251 if (data == fMUONData) return;
252 if(fMUONData) fMUONData->DecRefCount();
254 if(fMUONData) fMUONData->IncRefCount();
258 //______________________________________________________________________________
259 AliEveMUONChamberData* AliEveMUONChamber::GetChamberData() const
261 // Return source of data.
263 return fMUONData ? fMUONData->GetChamberData(fChamberID) : 0;
266 //______________________________________________________________________________
267 void AliEveMUONChamber::UpdateQuads()
269 // Update digit representation.
271 fQuadSet1.Reset(TEveQuadSet::kQT_RectangleXY, kTRUE, 32);
272 fQuadSet2.Reset(TEveQuadSet::kQT_RectangleXY, kTRUE, 32);
276 AliEveMUONChamberData* data = GetChamberData();
279 Float_t x0, y0, z, w, h, clsq;
280 Int_t charge, cathode, nDigits, nClusters, nHits, oldSize, ic1, ic2;
281 Double_t clsX, clsY, clsZ;
282 Float_t hitX, hitY, hitZ;
290 nDigits = data->GetNDigits();
292 for (Int_t id = 0; id < nDigits; id++) {
294 buffer = data->GetDigitBuffer(id);
296 x0 = buffer[0]-buffer[2];
297 y0 = buffer[1]-buffer[3];
301 charge = (Int_t)buffer[5];
302 cathode = (Int_t)buffer[6];
304 if (charge <= fThreshold) continue;
308 fQuadSet1.AddQuad(x0, y0, z, w, h);
309 fQuadSet1.QuadColor(ColorIndex(charge));
315 fQuadSet2.AddQuad(x0, y0, z, w, h);
316 fQuadSet2.QuadColor(ColorIndex(charge));
324 nClusters = data->GetNClusters()/2; // only one cathode plane
325 oldSize = fPointSet1.GrowFor(nClusters);
327 for (Int_t ic = 0; ic < (nClusters*2); ic++) {
329 buffer = data->GetClusterBuffer(ic);
331 clsX = (Double_t)buffer[0];
332 clsY = (Double_t)buffer[1];
333 clsZ = (Double_t)buffer[2];
335 cathode = (Int_t)buffer[4];
338 fPointSet1.SetPoint(ic1,clsX,clsY,clsZ);
342 } // end clusters loop
346 nHits = data->GetNHits();
347 oldSize = fPointSet2.GrowFor(nHits);
348 for (Int_t ih = 0; ih < nHits; ih++) {
349 buffer = data->GetHitBuffer(ih);
353 fPointSet2.SetPoint(ih,hitX,hitY,hitZ);
360 //______________________________________________________________________________
361 void AliEveMUONChamber::SetChamberID(Int_t id)
363 // Set id of chamber to display.
366 if (id > 13) id = 13;