]>
Commit | Line | Data |
---|---|---|
d810d0de | 1 | // $Id$ |
2 | // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 | |
092578a7 | 3 | |
d810d0de | 4 | /************************************************************************** |
5 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * | |
6 | * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * | |
51346b82 | 7 | * full copyright notice. * |
d810d0de | 8 | **************************************************************************/ |
092578a7 | 9 | |
d810d0de | 10 | #include "AliEveTPCSectorViz.h" |
11 | ||
cb4245bb | 12 | #include <EveDet/AliEveTPCData.h> |
13 | #include <EveDet/AliEveTPCSectorData.h> | |
092578a7 | 14 | |
a15e6d7d | 15 | #include <TEveTrans.h> |
092578a7 | 16 | #include <TStyle.h> |
a15e6d7d | 17 | #include <TMath.h> |
d810d0de | 18 | |
a15e6d7d | 19 | //============================================================================== |
20 | //============================================================================== | |
21 | // AliEveTPCSectorViz | |
22 | //============================================================================== | |
092578a7 | 23 | |
57ffa5fb | 24 | //______________________________________________________________________________ |
092578a7 | 25 | // |
26 | // Base class for TPC raw-data visualization. | |
d810d0de | 27 | // See AliEveTPCSector2D and AliEveTPCSector3D for concrete implementations. |
092578a7 | 28 | |
d810d0de | 29 | ClassImp(AliEveTPCSectorViz) |
092578a7 | 30 | |
57ffa5fb | 31 | /******************************************************************************/ |
092578a7 | 32 | |
d810d0de | 33 | AliEveTPCSectorViz::AliEveTPCSectorViz(const Text_t* n, const Text_t* t) : |
84aff7a4 | 34 | TEveElement(fFrameColor), |
27db2029 | 35 | TNamed(n, t), |
092578a7 | 36 | |
37 | fTPCData (0), | |
38 | fSectorID (0), | |
39 | ||
40 | fMinTime (0), | |
41 | fMaxTime (450), | |
42 | fThreshold (5), | |
6124fec9 | 43 | fMaxVal (128), |
092578a7 | 44 | |
45 | fRnrInn (kTRUE), | |
46 | fRnrOut1 (kTRUE), | |
47 | fRnrOut2 (kTRUE), | |
48 | ||
fbc350a3 | 49 | fFrameColor (4), |
32e219c2 | 50 | fRnrFrame (kTRUE), |
51 | fAutoTrans (kFALSE), | |
52 | fRTS (1), | |
bd73c30b | 53 | |
54 | fColorArray (0) | |
a97abca8 | 55 | { |
56 | // Constructor. | |
a15e6d7d | 57 | |
58 | InitMainTrans(); | |
a97abca8 | 59 | } |
092578a7 | 60 | |
d810d0de | 61 | AliEveTPCSectorViz::~AliEveTPCSectorViz() |
092578a7 | 62 | { |
a97abca8 | 63 | // Destructor. |
64 | ||
65 | if (fTPCData) fTPCData->DecRefCount(); | |
bd73c30b | 66 | delete [] fColorArray; |
092578a7 | 67 | } |
68 | ||
5aec5309 | 69 | void AliEveTPCSectorViz::CopyVizParams(const TEveElement* el) |
45664536 | 70 | { |
a97abca8 | 71 | // Copy basic viualization parameters from another TPCSectorViz. |
72 | ||
5aec5309 | 73 | const AliEveTPCSectorViz* v = dynamic_cast<const AliEveTPCSectorViz*>(el); |
74 | if (v) { | |
75 | fMinTime = v->fMinTime; | |
76 | fMaxTime = v->fMaxTime; | |
77 | fThreshold = v->fThreshold; | |
78 | fMaxVal = v->fMaxVal; | |
79 | ||
80 | fRnrInn = v->fRnrInn; | |
81 | fRnrOut1 = v->fRnrOut1; | |
82 | fRnrOut2 = v->fRnrOut2; | |
83 | } | |
45664536 | 84 | } |
85 | ||
57ffa5fb | 86 | /******************************************************************************/ |
092578a7 | 87 | |
d810d0de | 88 | void AliEveTPCSectorViz::SetDataSource(AliEveTPCData* data) |
092578a7 | 89 | { |
a97abca8 | 90 | // Set the data source. |
91 | ||
92 | if (data == fTPCData) return; | |
93 | if (fTPCData) fTPCData->DecRefCount(); | |
092578a7 | 94 | fTPCData = data; |
a97abca8 | 95 | if (fTPCData) fTPCData->IncRefCount(); |
092578a7 | 96 | IncRTS(); |
97 | } | |
98 | ||
d810d0de | 99 | void AliEveTPCSectorViz::SetSectorID(Int_t id) |
092578a7 | 100 | { |
a97abca8 | 101 | // Set sector id. |
102 | ||
103 | if (id < 0) id = 0; | |
104 | if (id > 35) id = 35; | |
45664536 | 105 | fSectorID = id; |
a97abca8 | 106 | if (fAutoTrans) |
fbb1b08d | 107 | SetAutoTrans(kTRUE); // Force repositioning. |
092578a7 | 108 | IncRTS(); |
109 | } | |
110 | ||
d810d0de | 111 | AliEveTPCSectorData* AliEveTPCSectorViz::GetSectorData() const |
092578a7 | 112 | { |
a97abca8 | 113 | // Get sector-data. |
114 | ||
092578a7 | 115 | return fTPCData ? fTPCData->GetSectorData(fSectorID) : 0; |
116 | } | |
117 | ||
57ffa5fb | 118 | /******************************************************************************/ |
092578a7 | 119 | |
d810d0de | 120 | void AliEveTPCSectorViz::SetThreshold(Short_t t) |
bd73c30b | 121 | { |
a97abca8 | 122 | // Set visualization threshold. |
123 | ||
bd73c30b | 124 | fThreshold = TMath::Min(t, (Short_t)(fMaxVal - 1)); |
125 | ClearColorArray(); | |
126 | IncRTS(); | |
127 | } | |
128 | ||
d810d0de | 129 | void AliEveTPCSectorViz::SetMaxVal(Int_t mv) |
bd73c30b | 130 | { |
a97abca8 | 131 | // Set visualization max signal value. |
132 | // Signals above this will have the same color. | |
133 | ||
bd73c30b | 134 | fMaxVal = TMath::Max(mv, (Int_t)(fThreshold + 1)); |
135 | ClearColorArray(); | |
136 | IncRTS(); | |
137 | } | |
138 | ||
57ffa5fb | 139 | /******************************************************************************/ |
bd73c30b | 140 | |
51346b82 | 141 | void AliEveTPCSectorViz::SetAutoTrans(Bool_t trans) |
092578a7 | 142 | { |
a97abca8 | 143 | // Set automatic update of transformation matrix. |
144 | // The position is calculated immediately. | |
145 | ||
fbb1b08d | 146 | fAutoTrans = trans; |
a15e6d7d | 147 | if (fAutoTrans) |
148 | { | |
092578a7 | 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()); | |
d810d0de | 152 | Float_t z = AliEveTPCSectorData::GetZLength(); |
7e02899d | 153 | Float_t d = -1; |
a97abca8 | 154 | if (fSectorID >= 18) { |
7e02899d | 155 | z = -z; |
156 | d = -d; | |
157 | } | |
fbb1b08d | 158 | |
092578a7 | 159 | // column major |
a15e6d7d | 160 | InitMainTrans(); |
161 | TEveTrans& t = RefMainTrans(); | |
162 | t[0] = -c; t[1] = -s; | |
163 | t[4] = -s; t[5] = c; | |
164 | t[10] = d; t[14] = z; | |
092578a7 | 165 | } |
166 | } | |
a15e6d7d | 167 | void AliEveTPCSectorViz::SetUseTrans(Bool_t t) |
168 | { | |
169 | // Set flag spcifying if transformation matrix should be applied. | |
170 | ||
171 | RefMainTrans().SetUseTrans(t); | |
172 | } | |
092578a7 | 173 | |
57ffa5fb | 174 | /******************************************************************************/ |
092578a7 | 175 | |
d810d0de | 176 | void AliEveTPCSectorViz::SetupColor(Int_t val, UChar_t* pixel) const |
092578a7 | 177 | { |
a97abca8 | 178 | // Set pixel color to represent signal val from the current palette. |
179 | ||
092578a7 | 180 | using namespace TMath; |
181 | Float_t div = Max(1, fMaxVal - fThreshold); | |
182 | Int_t nCol = gStyle->GetNumberOfColors(); | |
183 | Int_t cBin = (Int_t) Nint(nCol*(val - fThreshold)/div); | |
184 | ||
a97abca8 | 185 | TEveUtil::ColorFromIdx(gStyle->GetColorPalette(Min(nCol - 1, cBin)), pixel); |
092578a7 | 186 | } |
bd73c30b | 187 | |
d810d0de | 188 | void AliEveTPCSectorViz::ClearColorArray() |
bd73c30b | 189 | { |
a97abca8 | 190 | // Clear cached color array. |
191 | ||
192 | if (fColorArray) { | |
bd73c30b | 193 | delete [] fColorArray; |
194 | fColorArray = 0; | |
195 | } | |
196 | } | |
197 | ||
d810d0de | 198 | void AliEveTPCSectorViz::SetupColorArray() const |
bd73c30b | 199 | { |
a97abca8 | 200 | // Initialize cached color array. |
201 | ||
202 | if (fColorArray) | |
bd73c30b | 203 | return; |
204 | ||
205 | fColorArray = new UChar_t [4 * (fMaxVal - fThreshold + 1)]; | |
206 | UChar_t* p = fColorArray; | |
a97abca8 | 207 | for (Int_t v=fThreshold; v<=fMaxVal; ++v, p+=4) |
bd73c30b | 208 | SetupColor(v, p); |
209 | } |