]>
Commit | Line | Data |
---|---|---|
d810d0de | 1 | // $Id$ |
fafff680 | 2 | // Main authors: Matevz Tadel & Alja Mrak-Tadel & Bogdan Vulpescu: 2006, 2007 |
3626c858 | 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 | **************************************************************************/ |
9 | #include "AliEveMUONChamber.h" | |
10 | ||
cb4245bb | 11 | #include <EveDet/AliEveMUONData.h> |
12 | #include <EveDet/AliEveMUONChamberData.h> | |
3626c858 | 13 | |
14 | #include <TBuffer3D.h> | |
15 | #include <TBuffer3DTypes.h> | |
16 | #include <TVirtualPad.h> | |
17 | #include <TVirtualViewer3D.h> | |
3626c858 | 18 | #include <TStyle.h> |
3626c858 | 19 | |
3626c858 | 20 | |
57ffa5fb | 21 | //______________________________________________________________________________ |
d810d0de | 22 | // AliEveMUONChamber |
3626c858 | 23 | // |
24 | ||
d810d0de | 25 | ClassImp(AliEveMUONChamber) |
3626c858 | 26 | |
57ffa5fb | 27 | //______________________________________________________________________________ |
d810d0de | 28 | AliEveMUONChamber::AliEveMUONChamber(Int_t id, const Text_t* n, const Text_t* t) : |
fd31e9de | 29 | TEveElement(fFrameColor), |
30 | TNamed(n,t), | |
31 | fMUONData(0), | |
fbc350a3 | 32 | fFrameColor(2), |
fd31e9de | 33 | fRTS(1), |
34 | fChamberID(0), | |
35 | fQuadSet1(n,t), | |
36 | fQuadSet2(n,t), | |
37 | fPointSet1(n), | |
38 | fPointSet2(n), | |
39 | fThreshold(0), | |
40 | fMaxVal(4096), | |
41 | fClusterSize(5), | |
42 | fHitSize(5), | |
43 | fColorArray(0) | |
3626c858 | 44 | { |
45 | // | |
46 | // constructor | |
47 | // | |
48 | ||
eadce74d | 49 | Char_t name[256]; |
50 | if (id < 10) { | |
51 | sprintf(name,"Chamber %02d (trac)",id); | |
52 | } else { | |
53 | sprintf(name,"Chamber %02d (trig)",id); | |
54 | } | |
55 | SetName(name); | |
56 | ||
3626c858 | 57 | ComputeBBox(); |
58 | ||
59 | } | |
60 | ||
57ffa5fb | 61 | //______________________________________________________________________________ |
d810d0de | 62 | AliEveMUONChamber::~AliEveMUONChamber() |
3626c858 | 63 | { |
64 | // | |
65 | // destructor | |
66 | // | |
67 | ||
68 | if(fMUONData) fMUONData->DecRefCount(); | |
69 | ||
70 | } | |
71 | ||
57ffa5fb | 72 | //______________________________________________________________________________ |
d810d0de | 73 | void AliEveMUONChamber::ComputeBBox() |
3626c858 | 74 | { |
75 | // | |
76 | // bounding box | |
77 | // | |
78 | ||
79 | #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2) | |
80 | bbox_init(); | |
81 | #else | |
82 | BBoxInit(); | |
83 | #endif | |
51346b82 | 84 | |
eadce74d | 85 | fBBox[0] = - 400.0; |
86 | fBBox[1] = + 400.0; | |
87 | fBBox[2] = - 400.0; | |
88 | fBBox[3] = + 400.0; | |
3626c858 | 89 | fBBox[4] = -1800.0; |
eadce74d | 90 | fBBox[5] = + 500.0; |
3626c858 | 91 | |
92 | Float_t* b1 = fQuadSet1.AssertBBox(); | |
93 | for(Int_t i=0; i<6; ++i) { b1[i] = fBBox[i]; } | |
94 | Float_t* b2 = fQuadSet2.AssertBBox(); | |
95 | for(Int_t i=0; i<6; ++i) { b2[i] = fBBox[i]; } | |
eadce74d | 96 | Float_t* b3 = fPointSet1.AssertBBox(); |
97 | for(Int_t i=0; i<6; ++i) { b3[i] = fBBox[i]; } | |
98 | Float_t* b4 = fPointSet2.AssertBBox(); | |
99 | for(Int_t i=0; i<6; ++i) { b4[i] = fBBox[i]; } | |
51346b82 | 100 | |
3626c858 | 101 | } |
102 | ||
57ffa5fb | 103 | //______________________________________________________________________________ |
d810d0de | 104 | void AliEveMUONChamber::Paint(Option_t*) |
3626c858 | 105 | { |
106 | // | |
107 | // draw... | |
108 | // | |
109 | ||
2caed564 | 110 | if(fRnrSelf == kFALSE) |
3626c858 | 111 | return; |
112 | ||
113 | TBuffer3D buffer(TBuffer3DTypes::kGeneric); | |
114 | ||
115 | buffer.fID = this; | |
116 | buffer.fColor = 2; | |
117 | buffer.fTransparency = 0; | |
118 | buffer.fLocalFrame = 0; | |
119 | ||
120 | buffer.SetSectionsValid(TBuffer3D::kCore); | |
121 | Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer); | |
122 | if (reqSections == TBuffer3D::kNone) { | |
d810d0de | 123 | //printf("AliEveMUONChamber::Paint viewer was happy with Core buff3d.\n"); |
3626c858 | 124 | return; |
125 | } | |
126 | ||
d810d0de | 127 | printf("AliEveMUONChamber::Paint only GL supported.\n"); |
3626c858 | 128 | return; |
129 | ||
130 | } | |
131 | ||
57ffa5fb | 132 | //______________________________________________________________________________ |
d810d0de | 133 | void AliEveMUONChamber::SetThreshold(Short_t t) |
3626c858 | 134 | { |
135 | // | |
136 | // digits amplitude threshold | |
137 | // | |
138 | ||
139 | fThreshold = TMath::Min(t, (Short_t)(fMaxVal - 1)); | |
140 | ClearColorArray(); | |
141 | IncRTS(); | |
142 | ||
143 | } | |
144 | ||
57ffa5fb | 145 | //______________________________________________________________________________ |
d810d0de | 146 | void AliEveMUONChamber::SetMaxVal(Int_t mv) |
3626c858 | 147 | { |
148 | // | |
149 | // digits amplitude maximum value | |
150 | // | |
151 | ||
152 | fMaxVal = TMath::Max(mv, (Int_t)(fThreshold + 1)); | |
153 | ClearColorArray(); | |
154 | IncRTS(); | |
155 | ||
156 | } | |
157 | ||
57ffa5fb | 158 | //______________________________________________________________________________ |
d810d0de | 159 | void AliEveMUONChamber::SetClusterSize(Int_t size) |
eadce74d | 160 | { |
161 | // | |
162 | // cluster point size | |
163 | // | |
164 | ||
165 | fClusterSize = TMath::Max(1, size); | |
166 | IncRTS(); | |
167 | ||
168 | } | |
169 | ||
57ffa5fb | 170 | //______________________________________________________________________________ |
d810d0de | 171 | void AliEveMUONChamber::SetHitSize(Int_t size) |
eadce74d | 172 | { |
173 | // | |
174 | // hit point size | |
175 | // | |
176 | ||
177 | fHitSize = TMath::Max(1, size); | |
178 | IncRTS(); | |
179 | ||
180 | } | |
181 | ||
57ffa5fb | 182 | //______________________________________________________________________________ |
d810d0de | 183 | void AliEveMUONChamber::SetupColor(Int_t val, UChar_t* pixel) const |
3626c858 | 184 | { |
185 | // | |
186 | // RGBA color for amplitude "val" | |
187 | // | |
188 | ||
189 | Float_t div = TMath::Max(1, fMaxVal - fThreshold); | |
190 | Int_t nCol = gStyle->GetNumberOfColors(); | |
191 | Int_t cBin = (Int_t) TMath::Nint(nCol*(val - fThreshold)/div); | |
192 | ||
d810d0de | 193 | TEveUtil::TEveUtil::ColorFromIdx(gStyle->GetColorPalette(TMath::Min(nCol - 1, cBin)), pixel); |
3626c858 | 194 | |
195 | } | |
196 | ||
57ffa5fb | 197 | //______________________________________________________________________________ |
d810d0de | 198 | Int_t AliEveMUONChamber::ColorIndex(Int_t val) const |
3626c858 | 199 | { |
200 | // | |
51346b82 | 201 | // index color |
3626c858 | 202 | // |
203 | ||
204 | if(val < fThreshold) val = fThreshold; | |
205 | if(val > fMaxVal) val = fMaxVal; | |
206 | ||
207 | Float_t div = TMath::Max(1, fMaxVal - fThreshold); | |
208 | Int_t nCol = gStyle->GetNumberOfColors(); | |
209 | Int_t cBin = (Int_t) TMath::Nint(nCol*(val - fThreshold)/div); | |
210 | ||
211 | return gStyle->GetColorPalette(TMath::Min(nCol - 1, cBin)); | |
212 | ||
213 | } | |
214 | ||
57ffa5fb | 215 | //______________________________________________________________________________ |
d810d0de | 216 | void AliEveMUONChamber::SetupColorArray() const |
3626c858 | 217 | { |
218 | // | |
219 | // build array of colors | |
220 | // | |
221 | ||
222 | if(fColorArray) | |
223 | return; | |
224 | ||
225 | fColorArray = new UChar_t [4 * (fMaxVal - fThreshold + 1)]; | |
226 | UChar_t* p = fColorArray; | |
227 | for(Int_t v=fThreshold; v<=fMaxVal; ++v, p+=4) | |
228 | SetupColor(v, p); | |
229 | ||
230 | } | |
231 | ||
57ffa5fb | 232 | //______________________________________________________________________________ |
d810d0de | 233 | void AliEveMUONChamber::ClearColorArray() |
3626c858 | 234 | { |
235 | // | |
236 | // delete array of colors | |
237 | // | |
238 | ||
239 | if(fColorArray) { | |
240 | delete [] fColorArray; | |
241 | fColorArray = 0; | |
242 | } | |
243 | } | |
244 | ||
57ffa5fb | 245 | //______________________________________________________________________________ |
d810d0de | 246 | void AliEveMUONChamber::SetDataSource(AliEveMUONData* data) |
3626c858 | 247 | { |
a15e6d7d | 248 | // Set source of data. |
3626c858 | 249 | |
250 | if (data == fMUONData) return; | |
251 | if(fMUONData) fMUONData->DecRefCount(); | |
252 | fMUONData = data; | |
253 | if(fMUONData) fMUONData->IncRefCount(); | |
254 | IncRTS(); | |
3626c858 | 255 | } |
256 | ||
57ffa5fb | 257 | //______________________________________________________________________________ |
d810d0de | 258 | AliEveMUONChamberData* AliEveMUONChamber::GetChamberData() const |
3626c858 | 259 | { |
a15e6d7d | 260 | // Return source of data. |
51346b82 | 261 | |
3626c858 | 262 | return fMUONData ? fMUONData->GetChamberData(fChamberID) : 0; |
3626c858 | 263 | } |
264 | ||
57ffa5fb | 265 | //______________________________________________________________________________ |
d810d0de | 266 | void AliEveMUONChamber::UpdateQuads() |
3626c858 | 267 | { |
a15e6d7d | 268 | // Update digit representation. |
3626c858 | 269 | |
84aff7a4 | 270 | fQuadSet1.Reset(TEveQuadSet::kQT_RectangleXY, kTRUE, 32); |
271 | fQuadSet2.Reset(TEveQuadSet::kQT_RectangleXY, kTRUE, 32); | |
eadce74d | 272 | fPointSet1.Reset(); |
273 | fPointSet2.Reset(); | |
3626c858 | 274 | |
d810d0de | 275 | AliEveMUONChamberData* data = GetChamberData(); |
51346b82 | 276 | |
3626c858 | 277 | Float_t *buffer; |
84aff7a4 | 278 | Float_t x0, y0, z, w, h, clsq; |
eadce74d | 279 | Int_t charge, cathode, nDigits, nClusters, nHits, oldSize, ic1, ic2; |
280 | Double_t clsX, clsY, clsZ; | |
281 | Float_t hitX, hitY, hitZ; | |
51346b82 | 282 | |
3626c858 | 283 | if (data != 0) { |
284 | ||
285 | SetupColorArray(); | |
286 | ||
eadce74d | 287 | // digits |
288 | ||
289 | nDigits = data->GetNDigits(); | |
51346b82 | 290 | |
eadce74d | 291 | for (Int_t id = 0; id < nDigits; id++) { |
3626c858 | 292 | |
293 | buffer = data->GetDigitBuffer(id); | |
294 | ||
295 | x0 = buffer[0]-buffer[2]; | |
296 | y0 = buffer[1]-buffer[3]; | |
84aff7a4 | 297 | w = 2*buffer[2]; |
298 | h = 2*buffer[3]; | |
3626c858 | 299 | z = buffer[4]; |
300 | charge = (Int_t)buffer[5]; | |
301 | cathode = (Int_t)buffer[6]; | |
51346b82 | 302 | |
eadce74d | 303 | if (charge <= fThreshold) continue; |
304 | ||
3626c858 | 305 | if (cathode == 0) { |
306 | ||
84aff7a4 | 307 | fQuadSet1.AddQuad(x0, y0, z, w, h); |
308 | fQuadSet1.QuadColor(ColorIndex(charge)); | |
51346b82 | 309 | |
3626c858 | 310 | } |
311 | ||
312 | if (cathode == 1) { | |
313 | ||
84aff7a4 | 314 | fQuadSet2.AddQuad(x0, y0, z, w, h); |
315 | fQuadSet2.QuadColor(ColorIndex(charge)); | |
51346b82 | 316 | |
3626c858 | 317 | } |
318 | ||
319 | } // end digits loop | |
320 | ||
eadce74d | 321 | // clusters |
51346b82 | 322 | |
eadce74d | 323 | nClusters = data->GetNClusters()/2; // only one cathode plane |
324 | oldSize = fPointSet1.GrowFor(nClusters); | |
325 | ic1 = ic2 = 0; | |
326 | for (Int_t ic = 0; ic < (nClusters*2); ic++) { | |
327 | ||
328 | buffer = data->GetClusterBuffer(ic); | |
329 | ||
330 | clsX = (Double_t)buffer[0]; | |
331 | clsY = (Double_t)buffer[1]; | |
332 | clsZ = (Double_t)buffer[2]; | |
51346b82 | 333 | clsq = buffer[3]; |
eadce74d | 334 | cathode = (Int_t)buffer[4]; |
335 | ||
336 | if (cathode == 0) { | |
337 | fPointSet1.SetPoint(ic1,clsX,clsY,clsZ); | |
338 | ic1++; | |
339 | } | |
340 | ||
341 | } // end clusters loop | |
342 | ||
343 | // hits | |
344 | ||
345 | nHits = data->GetNHits(); | |
346 | oldSize = fPointSet2.GrowFor(nHits); | |
347 | for (Int_t ih = 0; ih < nHits; ih++) { | |
348 | buffer = data->GetHitBuffer(ih); | |
349 | hitX = buffer[0]; | |
350 | hitY = buffer[1]; | |
351 | hitZ = buffer[2]; | |
352 | fPointSet2.SetPoint(ih,hitX,hitY,hitZ); | |
353 | } | |
354 | ||
355 | } // end data | |
3626c858 | 356 | |
357 | } | |
358 | ||
57ffa5fb | 359 | //______________________________________________________________________________ |
d810d0de | 360 | void AliEveMUONChamber::SetChamberID(Int_t id) |
3626c858 | 361 | { |
a15e6d7d | 362 | // Set id of chamber to display. |
3626c858 | 363 | |
364 | if (id < 0) id = 0; | |
365 | if (id > 13) id = 13; | |
366 | ||
367 | fChamberID = id; | |
368 | IncRTS(); | |
3626c858 | 369 | } |
370 |