]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Alieve/TPCSectorViz.cxx
Remove EVE/Reve/ sub-module.
[u/mrichter/AliRoot.git] / EVE / Alieve / TPCSectorViz.cxx
1 // $Header$
2
3 #include "TPCSectorViz.h"
4
5 #include <Alieve/TPCData.h>
6 #include <Alieve/TPCSectorData.h>
7 #include <AliTPCParam.h>
8
9 #include <TStyle.h>
10 #include <TColor.h>
11 using namespace Alieve;
12
13 //______________________________________________________________________
14 // TPCSectorViz
15 //
16 // Base class for TPC raw-data visualization.
17 // See TPCSector2D and TPCSector3D for concrete implementations.
18
19 ClassImp(TPCSectorViz)
20
21 /**************************************************************************/
22
23 TPCSectorViz::TPCSectorViz(const Text_t* n, const Text_t* t) :
24   TEveElement(fFrameColor),
25   TNamed(n, t),
26
27   fTPCData  (0),
28   fSectorID (0),
29
30   fMinTime   (0),
31   fMaxTime   (450),
32   fThreshold (5),
33   fMaxVal    (128),
34
35   fRnrInn   (kTRUE),
36   fRnrOut1  (kTRUE),
37   fRnrOut2  (kTRUE),
38
39   fFrameColor ((Color_t) 4),
40   fRnrFrame   (kTRUE),
41   fAutoTrans  (kFALSE),
42   fRTS        (1),
43
44   fColorArray (0)
45 {}
46
47 TPCSectorViz::~TPCSectorViz()
48 {
49   if(fTPCData) fTPCData->DecRefCount();
50   delete [] fColorArray;
51 }
52
53 void TPCSectorViz::CopyVizParams(const TPCSectorViz& v)
54 {
55   fMinTime   = v.fMinTime;
56   fMaxTime   = v.fMaxTime;
57   fThreshold = v.fThreshold;
58   fMaxVal    = v.fMaxVal;
59
60   fRnrInn    = v.fRnrInn;
61   fRnrOut1   = v.fRnrOut1;
62   fRnrOut2   = v.fRnrOut2;
63 }
64
65 /**************************************************************************/
66
67 void TPCSectorViz::SetDataSource(TPCData* data)
68 {
69   if(data == fTPCData) return;
70   if(fTPCData) fTPCData->DecRefCount();
71   fTPCData = data;
72   if(fTPCData) fTPCData->IncRefCount();
73   IncRTS();
74 }
75
76 void TPCSectorViz::SetSectorID(Int_t id)
77 {
78   if(id < 0)  id = 0;
79   if(id > 35) id = 35;
80   fSectorID = id;
81   if(fAutoTrans)
82     SetAutoTrans(kTRUE); // Force repositioning.
83   IncRTS();
84 }
85
86 TPCSectorData* TPCSectorViz::GetSectorData() const
87 {
88   return fTPCData ? fTPCData->GetSectorData(fSectorID) : 0;
89 }
90
91 /**************************************************************************/
92
93 void TPCSectorViz::SetThreshold(Short_t t)
94 {
95   fThreshold = TMath::Min(t, (Short_t)(fMaxVal - 1));
96   ClearColorArray();
97   IncRTS();
98 }
99
100 void TPCSectorViz::SetMaxVal(Int_t mv)
101 {
102   fMaxVal = TMath::Max(mv, (Int_t)(fThreshold + 1));
103   ClearColorArray();
104   IncRTS();
105 }
106
107 /**************************************************************************/
108
109 void TPCSectorViz::SetAutoTrans(Bool_t trans) 
110 {
111   fAutoTrans = trans;
112   if(fAutoTrans) {
113     fHMTrans.UnitTrans();
114
115     using namespace TMath;
116     Float_t c = Cos((fSectorID + 0.5)*20*Pi()/180 - PiOver2());
117     Float_t s = Sin((fSectorID + 0.5)*20*Pi()/180 - PiOver2());
118     Float_t z = TPCSectorData::GetZLength();
119     Float_t d = -1;
120     if(fSectorID >= 18) {
121       z = -z;
122       d = -d;
123     }
124
125     // column major
126     fHMTrans[0]  = -c;
127     fHMTrans[1]  = -s;
128     fHMTrans[4]  = -s;
129     fHMTrans[5]  =  c;
130     fHMTrans[10] =  d;
131     fHMTrans[14] =  z;
132     fHMTrans[15] =  1;
133   }
134 }
135
136 /**************************************************************************/
137
138 void TPCSectorViz::SetupColor(Int_t val, UChar_t* pixel) const
139 {
140   using namespace TMath;
141   Float_t div  = Max(1, fMaxVal - fThreshold);
142   Int_t   nCol = gStyle->GetNumberOfColors();
143   Int_t   cBin = (Int_t) Nint(nCol*(val - fThreshold)/div);
144
145   TEveUtil::ColorFromIdx(gStyle->GetColorPalette(Min(nCol - 1, cBin)), pixel);
146 }
147
148 void TPCSectorViz::ClearColorArray()
149 {
150   if(fColorArray) {
151     delete [] fColorArray;
152     fColorArray = 0;
153   }
154 }
155
156 void TPCSectorViz::SetupColorArray() const
157 {
158   if(fColorArray)
159     return;
160
161   fColorArray = new UChar_t [4 * (fMaxVal - fThreshold + 1)];
162   UChar_t* p = fColorArray;
163   for(Int_t v=fThreshold; v<=fMaxVal; ++v, p+=4)
164     SetupColor(v, p);
165 }