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