]>
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), | |
43 | fTrans (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; | |
83 | if(fTrans) | |
84 | SetTrans(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 | ||
092578a7 | 111 | void TPCSectorViz::SetTrans(Bool_t trans) |
112 | { | |
113 | fTrans = trans; | |
114 | if(fTrans) { | |
115 | for (Int_t k=0; k<16; ++k) | |
116 | fMatrix[k] = 0.; | |
117 | ||
118 | using namespace TMath; | |
119 | Float_t c = Cos((fSectorID + 0.5)*20*Pi()/180 - PiOver2()); | |
120 | Float_t s = Sin((fSectorID + 0.5)*20*Pi()/180 - PiOver2()); | |
7e02899d | 121 | Float_t z = TPCSectorData::GetZLength(); |
122 | Float_t d = -1; | |
123 | if(fSectorID >= 18) { | |
124 | z = -z; | |
125 | d = -d; | |
126 | } | |
092578a7 | 127 | |
128 | // column major | |
129 | fMatrix[0] = -c; | |
130 | fMatrix[1] = -s; | |
131 | fMatrix[4] = -s; | |
132 | fMatrix[5] = c; | |
7e02899d | 133 | fMatrix[10] = d; |
092578a7 | 134 | fMatrix[14] = z; |
135 | fMatrix[15] = 1; | |
136 | } | |
137 | } | |
138 | ||
139 | /**************************************************************************/ | |
140 | ||
141 | void TPCSectorViz::SetupColor(Int_t val, UChar_t* pixel) const | |
142 | { | |
143 | using namespace TMath; | |
144 | Float_t div = Max(1, fMaxVal - fThreshold); | |
145 | Int_t nCol = gStyle->GetNumberOfColors(); | |
146 | Int_t cBin = (Int_t) Nint(nCol*(val - fThreshold)/div); | |
147 | ||
148 | ColorFromIdx(gStyle->GetColorPalette(Min(nCol - 1, cBin)), pixel); | |
149 | } | |
bd73c30b | 150 | |
151 | void TPCSectorViz::ClearColorArray() | |
152 | { | |
153 | if(fColorArray) { | |
154 | delete [] fColorArray; | |
155 | fColorArray = 0; | |
156 | } | |
157 | } | |
158 | ||
159 | void TPCSectorViz::SetupColorArray() const | |
160 | { | |
161 | if(fColorArray) | |
162 | return; | |
163 | ||
164 | fColorArray = new UChar_t [4 * (fMaxVal - fThreshold + 1)]; | |
165 | UChar_t* p = fColorArray; | |
166 | for(Int_t v=fThreshold; v<=fMaxVal; ++v, p+=4) | |
167 | SetupColor(v, p); | |
168 | } |