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 "AliEveTPCSectorViz.h"
12 #include <EveDet/AliEveTPCData.h>
13 #include <EveDet/AliEveTPCSectorData.h>
15 #include <TEveTrans.h>
19 //==============================================================================
20 //==============================================================================
22 //==============================================================================
24 //______________________________________________________________________________
26 // Base class for TPC raw-data visualization.
27 // See AliEveTPCSector2D and AliEveTPCSector3D for concrete implementations.
29 ClassImp(AliEveTPCSectorViz)
31 /******************************************************************************/
33 AliEveTPCSectorViz::AliEveTPCSectorViz(const Text_t* n, const Text_t* t) :
34 TEveElement(fFrameColor),
61 AliEveTPCSectorViz::~AliEveTPCSectorViz()
65 if (fTPCData) fTPCData->DecRefCount();
66 delete [] fColorArray;
69 void AliEveTPCSectorViz::CopyVizParams(const TEveElement* el)
71 // Copy basic viualization parameters from another TPCSectorViz.
73 const AliEveTPCSectorViz* v = dynamic_cast<const AliEveTPCSectorViz*>(el);
75 fMinTime = v->fMinTime;
76 fMaxTime = v->fMaxTime;
77 fThreshold = v->fThreshold;
81 fRnrOut1 = v->fRnrOut1;
82 fRnrOut2 = v->fRnrOut2;
86 /******************************************************************************/
88 void AliEveTPCSectorViz::SetDataSource(AliEveTPCData* data)
90 // Set the data source.
92 if (data == fTPCData) return;
93 if (fTPCData) fTPCData->DecRefCount();
95 if (fTPCData) fTPCData->IncRefCount();
99 void AliEveTPCSectorViz::SetSectorID(Int_t id)
104 if (id > 35) id = 35;
107 SetAutoTrans(kTRUE); // Force repositioning.
111 AliEveTPCSectorData* AliEveTPCSectorViz::GetSectorData() const
115 return fTPCData ? fTPCData->GetSectorData(fSectorID) : 0;
118 /******************************************************************************/
120 void AliEveTPCSectorViz::SetThreshold(Short_t t)
122 // Set visualization threshold.
124 fThreshold = TMath::Min(t, (Short_t)(fMaxVal - 1));
129 void AliEveTPCSectorViz::SetMaxVal(Int_t mv)
131 // Set visualization max signal value.
132 // Signals above this will have the same color.
134 fMaxVal = TMath::Max(mv, (Int_t)(fThreshold + 1));
139 /******************************************************************************/
141 void AliEveTPCSectorViz::SetAutoTrans(Bool_t trans)
143 // Set automatic update of transformation matrix.
144 // The position is calculated immediately.
149 using namespace TMath;
150 Float_t c = Cos((fSectorID + 0.5)*20*Pi()/180 - PiOver2());
151 Float_t s = Sin((fSectorID + 0.5)*20*Pi()/180 - PiOver2());
152 Float_t z = AliEveTPCSectorData::GetZLength();
155 TEveTrans& t = RefMainTrans();
157 if (fSectorID < 18) {
159 t[0] = -c; t[1] = -s;
171 void AliEveTPCSectorViz::SetUseTrans(Bool_t t)
173 // Set flag spcifying if transformation matrix should be applied.
175 RefMainTrans().SetUseTrans(t);
178 /******************************************************************************/
180 void AliEveTPCSectorViz::SetupColor(Int_t val, UChar_t* pixel) const
182 // Set pixel color to represent signal val from the current palette.
184 Float_t div = TMath::Max(1, fMaxVal - fThreshold);
185 Int_t nCol = gStyle->GetNumberOfColors();
186 Int_t cBin = TMath::Nint(nCol*(val - fThreshold)/div);
188 TEveUtil::ColorFromIdx(gStyle->GetColorPalette(TMath::Min(nCol - 1, cBin)), pixel);
191 void AliEveTPCSectorViz::ClearColorArray()
193 // Clear cached color array.
196 delete [] fColorArray;
201 void AliEveTPCSectorViz::SetupColorArray() const
203 // Initialize cached color array.
208 fColorArray = new UChar_t [4 * (fMaxVal - fThreshold + 1)];
209 UChar_t* p = fColorArray;
210 for (Int_t v=fThreshold; v<=fMaxVal; ++v, p+=4)