]>
Commit | Line | Data |
---|---|---|
092578a7 | 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> | |
092578a7 | 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) : | |
84aff7a4 | 24 | TEveElement(fFrameColor), |
27db2029 | 25 | TNamed(n, t), |
092578a7 | 26 | |
27 | fTPCData (0), | |
28 | fSectorID (0), | |
29 | ||
30 | fMinTime (0), | |
31 | fMaxTime (450), | |
32 | fThreshold (5), | |
6124fec9 | 33 | fMaxVal (128), |
092578a7 | 34 | |
35 | fRnrInn (kTRUE), | |
36 | fRnrOut1 (kTRUE), | |
37 | fRnrOut2 (kTRUE), | |
38 | ||
39 | fFrameColor ((Color_t) 4), | |
32e219c2 | 40 | fRnrFrame (kTRUE), |
41 | fAutoTrans (kFALSE), | |
42 | fRTS (1), | |
bd73c30b | 43 | |
44 | fColorArray (0) | |
092578a7 | 45 | {} |
46 | ||
47 | TPCSectorViz::~TPCSectorViz() | |
48 | { | |
49 | if(fTPCData) fTPCData->DecRefCount(); | |
bd73c30b | 50 | delete [] fColorArray; |
092578a7 | 51 | } |
52 | ||
45664536 | 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 | ||
092578a7 | 65 | /**************************************************************************/ |
66 | ||
092578a7 | 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 | ||
45664536 | 76 | void TPCSectorViz::SetSectorID(Int_t id) |
092578a7 | 77 | { |
45664536 | 78 | if(id < 0) id = 0; |
79 | if(id > 35) id = 35; | |
80 | fSectorID = id; | |
fbb1b08d | 81 | if(fAutoTrans) |
82 | SetAutoTrans(kTRUE); // Force repositioning. | |
092578a7 | 83 | IncRTS(); |
84 | } | |
85 | ||
86 | TPCSectorData* TPCSectorViz::GetSectorData() const | |
87 | { | |
88 | return fTPCData ? fTPCData->GetSectorData(fSectorID) : 0; | |
89 | } | |
90 | ||
91 | /**************************************************************************/ | |
92 | ||
bd73c30b | 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 | ||
fbb1b08d | 109 | void TPCSectorViz::SetAutoTrans(Bool_t trans) |
092578a7 | 110 | { |
fbb1b08d | 111 | fAutoTrans = trans; |
112 | if(fAutoTrans) { | |
113 | fHMTrans.UnitTrans(); | |
092578a7 | 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()); | |
7e02899d | 118 | Float_t z = TPCSectorData::GetZLength(); |
119 | Float_t d = -1; | |
120 | if(fSectorID >= 18) { | |
121 | z = -z; | |
122 | d = -d; | |
123 | } | |
fbb1b08d | 124 | |
092578a7 | 125 | // column major |
fbb1b08d | 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; | |
092578a7 | 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 | ||
84aff7a4 | 145 | TEveUtil::ColorFromIdx(gStyle->GetColorPalette(Min(nCol - 1, cBin)), pixel); |
092578a7 | 146 | } |
bd73c30b | 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 | } |