]>
Commit | Line | Data |
---|---|---|
bf000c32 | 1 | /************************************************************************** |
2 | * Copyright(c) 2004, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
bf000c32 | 15 | /* $Id$ */ |
c2fc1258 | 16 | /** @file AliFMDDisplay.cxx |
17 | @author Christian Holm Christensen <cholm@nbi.dk> | |
18 | @date Mon Mar 27 12:39:09 2006 | |
19 | @brief FMD Event display | |
20 | */ | |
bf000c32 | 21 | //___________________________________________________________________ |
22 | // | |
23 | // The classes defined here, are utility classes for reading in data | |
24 | // for the FMD. They are put in a seperate library to not polute the | |
25 | // normal libraries. The classes are intended to be used as base | |
26 | // classes for customized class that do some sort of analysis on the | |
27 | // various types of data produced by the FMD. | |
28 | // | |
29 | // Latest changes by Christian Holm Christensen | |
30 | // | |
9edefa04 | 31 | |
d1ddc9bd | 32 | #include <TSystem.h> |
9edefa04 | 33 | #include <TApplication.h> |
34 | #include <TButton.h> | |
35 | #include <TCanvas.h> | |
36 | #include <TGeoManager.h> | |
37 | #include <TH1D.h> | |
38 | #include <TMarker3DBox.h> | |
39 | #include <TMath.h> | |
40 | #include <TSlider.h> | |
d98fbfa5 | 41 | #include <TSliderBox.h> |
9edefa04 | 42 | #include <TStyle.h> |
43 | #include <TView.h> | |
44 | #include <TVirtualX.h> | |
d98fbfa5 | 45 | #include <TVirtualViewer3D.h> |
46 | #include <TList.h> | |
9edefa04 | 47 | // #include <TArrayF.h> |
48 | // #include <TParticle.h> | |
49 | ||
bf000c32 | 50 | #include "AliFMDDisplay.h" // ALIFMDDISPLAY_H |
51 | #include "AliFMDHit.h" // ALIFMDHIT_H | |
52 | #include "AliFMDDigit.h" // ALIFMDDIGIT_H | |
42f1b2f5 | 53 | #include "AliFMDSDigit.h" // ALIFMDSDIGIT_H |
bf000c32 | 54 | #include "AliFMDRecPoint.h" // ALIFMDRECPOINT_H |
55 | #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H | |
56 | #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H | |
15b17c89 | 57 | #include <AliESDFMD.h> // ALIESDFMD_H |
f95a63c4 | 58 | // #include <AliLog.h> |
59 | #include "AliFMDDebug.h" // Better debug macros | |
bf000c32 | 60 | |
61 | //____________________________________________________________________ | |
62 | ClassImp(AliFMDDisplay) | |
63 | #if 0 | |
64 | ; // This is here to keep Emacs for indenting the next line | |
65 | #endif | |
66 | ||
67 | //____________________________________________________________________ | |
68 | AliFMDDisplay* AliFMDDisplay::fgInstance = 0; | |
69 | ||
70 | //____________________________________________________________________ | |
71 | AliFMDDisplay* | |
72 | AliFMDDisplay::Instance() | |
73 | { | |
02a27b50 | 74 | // Return static instance |
5c96b03f | 75 | // If the instance does not exist |
76 | // it is not created! | |
bf000c32 | 77 | return fgInstance; |
78 | } | |
79 | ||
80 | //____________________________________________________________________ | |
a9579262 | 81 | AliFMDDisplay::~AliFMDDisplay() |
82 | { | |
5c96b03f | 83 | // Destructor. |
84 | // Cleans | |
85 | // up | |
a9579262 | 86 | if (fMarkers) { |
87 | fMarkers->Delete(); | |
88 | delete fMarkers; | |
89 | } | |
90 | if (fHits) { | |
91 | fHits->Clear(); | |
92 | delete fHits; | |
93 | } | |
94 | if (fPad) delete fPad; | |
95 | fButtons.Delete(); | |
96 | if (fSlider) delete fSlider; | |
97 | if (fCanvas) delete fCanvas; | |
98 | } | |
99 | ||
100 | //____________________________________________________________________ | |
101 | AliFMDDisplay::AliFMDDisplay(Bool_t onlyFMD, const char* gAliceFile) | |
bf000c32 | 102 | : AliFMDInput(gAliceFile), |
103 | fWait(kFALSE), | |
b5ee4425 | 104 | fMarkers(0), |
105 | fHits(0), | |
bf000c32 | 106 | fCanvas(0), |
107 | fPad(0), | |
17e542eb | 108 | fButtons(0), |
a9579262 | 109 | fSlider(0), |
d98fbfa5 | 110 | fFactor(0), |
b5ee4425 | 111 | fZoomMode(kFALSE), |
112 | fX0(0), | |
113 | fY0(0), | |
114 | fX1(0), | |
115 | fY1(0), | |
b5ee4425 | 116 | fXPixel(0), |
117 | fYPixel(0), | |
118 | fOldXPixel(0), | |
119 | fOldYPixel(0), | |
a9579262 | 120 | fLineDrawn(0), |
17e542eb | 121 | fOnlyFMD(onlyFMD), |
122 | fSpec(0), | |
123 | fSpecCut(0), | |
d98fbfa5 | 124 | fAux(0), |
125 | fReturn(kFALSE) | |
bf000c32 | 126 | { |
127 | // Constructor of an FMD display object. | |
5c96b03f | 128 | // Must be called |
129 | // before Instance | |
42f1b2f5 | 130 | SetName("AliFMDDisplay"); |
131 | SetTitle("3D Display of various kinds of FMD data"); | |
bf000c32 | 132 | AddLoad(kGeometry); |
a9579262 | 133 | if (fgInstance) delete fgInstance; |
bf000c32 | 134 | fgInstance = this; |
135 | } | |
136 | ||
a9579262 | 137 | //____________________________________________________________________ |
138 | void | |
139 | AliFMDDisplay::MakeCanvas(const char** which) | |
140 | { | |
5c96b03f | 141 | // Make a canvas |
142 | // Parameters: | |
143 | // which Which button to put up. | |
a9579262 | 144 | gStyle->SetPalette(1); |
d98fbfa5 | 145 | // gStyle->SetCanvasPreferGL(kTRUE); |
a9579262 | 146 | Double_t y1 = .10; |
147 | Int_t w = 700; | |
42f1b2f5 | 148 | fCanvas = new TCanvas(Form("gl%s", GetName()), |
149 | Form("%s - Display", GetTitle()), | |
150 | w, Int_t(w / (1-y1))); | |
a9579262 | 151 | fCanvas->SetFillColor(1); |
152 | fCanvas->ToggleEventStatus(); | |
153 | fCanvas->cd(); | |
d98fbfa5 | 154 | fPad = new TPad("glview", "3DView", 0.0, y1, 1.0, 1.0, 1, 0, 0); |
a9579262 | 155 | fPad->Draw(); |
d98fbfa5 | 156 | |
157 | const char** p = which; | |
158 | const char* m; | |
159 | Int_t n = 0; | |
160 | Int_t j = 0; | |
161 | while (*(p++)) n++; | |
162 | AliInfo(Form("Got %d buttons", n)); | |
163 | if (n <= 0) return; | |
a9579262 | 164 | |
165 | Double_t yb = 0; | |
d98fbfa5 | 166 | Double_t xb = 1; |
a9579262 | 167 | fCanvas->cd(); |
d98fbfa5 | 168 | if (TESTBIT(fTreeMask, kDigits)) { |
169 | yb = .05; | |
170 | xb = .66; | |
171 | fFactor = new TSlider("pedFactor", "Pedestal Factor", xb+.01, 0, 1, yb); | |
172 | fFactor->SetMethod("AliFMDDisplay::Instance()->ChangeFactor()"); | |
173 | fFactor->SetRange(3./10, 1); | |
174 | fFactor->Draw(); | |
175 | TSliderBox *sbox = | |
176 | static_cast<TSliderBox*>(fFactor->GetListOfPrimitives()-> | |
177 | FindObject("TSliderBox")); | |
178 | if (sbox) { | |
179 | sbox->SetToolTipText("Adjust the noise suppression factor by moving " | |
180 | "lower limit"); | |
181 | } | |
182 | } | |
42f1b2f5 | 183 | if (TESTBIT(fTreeMask, kHits) || |
184 | TESTBIT(fTreeMask, kESD) || | |
185 | TESTBIT(fTreeMask, kDigits) || | |
186 | TESTBIT(fTreeMask, kSDigits) || | |
a9579262 | 187 | TESTBIT(fTreeMask, kRaw)) { |
188 | yb = .05; | |
d98fbfa5 | 189 | fSlider = new TSlider("genCut", "Multiplicity cut", 0, 0, xb, yb); |
a9579262 | 190 | fSlider->SetMethod("AliFMDDisplay::Instance()->ChangeCut()"); |
d98fbfa5 | 191 | fSlider->SetRange(0,1); |
a9579262 | 192 | fSlider->Draw(); |
d98fbfa5 | 193 | TSliderBox *sbox = |
194 | static_cast<TSliderBox*>(fSlider->GetListOfPrimitives()-> | |
195 | FindObject("TSliderBox")); | |
196 | if (sbox) { | |
197 | sbox->SetToolTipText("Adjust lower and upper limit on data signal"); | |
198 | } | |
a9579262 | 199 | } |
a9579262 | 200 | Float_t x0 = 0; |
201 | Float_t dx = 1. / n; | |
202 | p = which; | |
203 | while ((m = *(p++))) { | |
204 | fCanvas->cd(); | |
205 | AliInfo(Form("Adding button %s", m)); | |
206 | TButton* b = new TButton(m, Form("AliFMDDisplay::Instance()->%s()", m), | |
d98fbfa5 | 207 | x0, yb, TMath::Min(x0 + dx,.999F), y1); |
a9579262 | 208 | b->Draw(); |
209 | fButtons.Add(b); | |
210 | x0 += dx; | |
211 | j++; | |
212 | } | |
213 | } | |
214 | ||
215 | //____________________________________________________________________ | |
216 | void | |
217 | AliFMDDisplay::ShowOnlyFMD() | |
218 | { | |
5c96b03f | 219 | // Show only the FMD |
220 | // Do not show | |
221 | // other volumes | |
a9579262 | 222 | if (!fGeoManager) return; |
223 | static bool once = false; | |
224 | if (once) return; | |
225 | once = true; | |
226 | AliInfo("Will only show the FMD"); | |
227 | TGeoVolume* top = gGeoManager->GetTopVolume(); | |
228 | top->InvisibleAll(kTRUE); | |
229 | TGeoIterator next(top); | |
230 | TGeoNode* node; | |
231 | TGeoVolume* v = 0; | |
232 | Bool_t hasFMD1 = kFALSE; | |
233 | Bool_t hasFMD2 = kFALSE; | |
234 | Bool_t hasFMD3 = kFALSE; | |
d98fbfa5 | 235 | AliInfo("Getting material FMD_Si$"); |
236 | TGeoMaterial* si = gGeoManager->GetMaterial("FMD_Si$"); // kRed | |
237 | AliInfo("Getting material FMD_Carbon$"); | |
238 | TGeoMaterial* c = gGeoManager->GetMaterial("FMD_Carbon$"); // kGray | |
239 | AliInfo("Getting material FMD_Aluminum$"); | |
240 | TGeoMaterial* al = gGeoManager->GetMaterial("FMD_Aluminum$");// kGray-2 | |
241 | AliInfo("Getting material FMD_Copper$"); | |
242 | TGeoMaterial* cu = gGeoManager->GetMaterial("FMD_Copper$"); // kGreen-2 | |
243 | AliInfo("Getting material FMD_PCB$"); | |
244 | TGeoMaterial* pcb = gGeoManager->GetMaterial("FMD_PCB$"); // kGreen+2 | |
245 | AliInfo("Getting material FMD_PCB$"); | |
246 | TGeoMaterial* chip = gGeoManager->GetMaterial("FMD_Si Chip$");// kGreen+2 | |
247 | TObjArray toshow; | |
a9579262 | 248 | while ((node = static_cast<TGeoNode*>(next()))) { |
249 | const char* name = node->GetName(); | |
250 | if (!name) continue; | |
251 | if (!(v = node->GetVolume())) continue; | |
252 | ||
253 | if (name[0] == 'F') { | |
d98fbfa5 | 254 | TGeoMaterial* m = (v->IsAssembly() ? 0 : v->GetMaterial()); |
255 | Int_t col = -1; | |
256 | if (m == si) col = kRed; | |
257 | else if (m == c) col = kGray; | |
258 | else if (m == al) col = kYellow+4; | |
259 | else if (m == cu) col = kRed+6; | |
260 | else if (m == pcb) col = kGreen+2; | |
261 | else if (m == chip) col = kGreen+4; | |
262 | if (col >= 0) { | |
263 | v->SetLineColor(col); | |
264 | v->SetFillColor(col); | |
265 | } | |
a9579262 | 266 | if (name[2] == 'M' && (name[3] == 'T' || name[3] == 'B')) { |
267 | // Virtual Master half-ring volume - top-level | |
268 | Int_t det = node->GetNumber(); | |
269 | switch (det) { | |
270 | case 1: hasFMD1 = true; break; | |
271 | case 2: hasFMD2 = true; break; | |
272 | case 3: hasFMD3 = true; break; | |
273 | default: continue; | |
274 | } | |
275 | toshow.Add(v); | |
276 | } | |
277 | else if (name[3] == 'V' && (name[2] == 'T' || name[2] == 'B')) | |
278 | toshow.Add(v); // Virtual Half-ring, bare detectors | |
d98fbfa5 | 279 | else if (name[3] == 'H' && (name[2] == 'F' || name[2] == 'B')) |
280 | toshow.Add(v); // Virtual Hybrid container | |
281 | else if (name[2] == 'S' && name[3] == 'U') | |
282 | toshow.Add(v); // Virtual support structre | |
a9579262 | 283 | // else if (name[3] == 'H' && (name[2] == 'F' || name[2] == 'B')) |
284 | // toshow.Add(v); // Virtual Hybrid container | |
285 | } | |
286 | v->SetVisibility(kFALSE); | |
287 | v->SetVisDaughters(kFALSE); | |
288 | v->InvisibleAll(kTRUE); | |
289 | } | |
290 | TIter i(&toshow); | |
291 | while ((v = static_cast<TGeoVolume*>(i()))) { | |
d98fbfa5 | 292 | if (!v->IsAssembly()) |
293 | v->SetVisibility(kTRUE); | |
a9579262 | 294 | v->InvisibleAll(kFALSE); |
d98fbfa5 | 295 | v->SetVisDaughters(kTRUE); |
296 | ||
a9579262 | 297 | } |
298 | } | |
299 | ||
300 | ||
bf000c32 | 301 | //____________________________________________________________________ |
1e8f773e | 302 | void |
bf000c32 | 303 | AliFMDDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py) |
304 | { | |
5c96b03f | 305 | // Execute an event on canvas |
306 | // Parameters: | |
307 | // event What happened | |
308 | // px, py Pixel coordinates | |
bf000c32 | 309 | if (px == 0 && py == 0) return; |
310 | if (!fZoomMode && fPad->GetView()) { | |
311 | fPad->GetView()->ExecuteRotateView(event, px, py); | |
312 | return; | |
313 | } | |
314 | fPad->SetCursor(kCross); | |
315 | switch (event) { | |
316 | case kButton1Down: | |
317 | fPad->TAttLine::Modify(); | |
318 | fX0 = fPad->AbsPixeltoX(px); | |
319 | fY0 = fPad->AbsPixeltoY(py); | |
320 | fXPixel = fOldXPixel = px; | |
321 | fYPixel = fOldYPixel = py; | |
322 | fLineDrawn = kFALSE; | |
323 | return; | |
324 | case kButton1Motion: | |
325 | if (fLineDrawn) | |
326 | gVirtualX->DrawBox(fXPixel, fYPixel, fOldXPixel, fOldYPixel, | |
327 | TVirtualX::kHollow); | |
328 | fOldXPixel = px; | |
329 | fOldYPixel = py; | |
330 | fLineDrawn = kTRUE; | |
331 | gVirtualX->DrawBox(fXPixel, fYPixel, fOldXPixel, fOldYPixel, | |
332 | TVirtualX::kHollow); | |
333 | return; | |
334 | case kButton1Up: | |
335 | fPad->GetCanvas()->FeedbackMode(kFALSE); | |
336 | if (px == fXPixel || py == fYPixel) return; | |
337 | fX1 = fPad->AbsPixeltoX(px); | |
338 | fY1 = fPad->AbsPixeltoY(py); | |
339 | if (fX1 < fX0) std::swap(fX0, fX1); | |
340 | if (fY1 < fY0) std::swap(fY0, fY1); | |
341 | fPad->Range(fX0, fY0, fX1, fY1); | |
342 | fPad->Modified(); | |
343 | return; | |
344 | } | |
345 | } | |
346 | ||
347 | //____________________________________________________________________ | |
1e8f773e | 348 | Int_t |
349 | AliFMDDisplay::DistancetoPrimitive(Int_t px, Int_t) | |
bf000c32 | 350 | { |
5c96b03f | 351 | // Calculate the distance from point to |
352 | // something in the canvas. | |
353 | // Depends on the zoom mode. | |
bf000c32 | 354 | fPad->SetCursor(kCross); |
355 | Float_t xmin = fPad->GetX1(); | |
356 | Float_t xmax = fPad->GetX2(); | |
357 | Float_t dx = .02 * (xmax - xmin); | |
358 | Float_t x = fPad->AbsPixeltoX(px); | |
359 | if (x < xmin + dx || x > xmax - dx) return 9999; | |
360 | return (fZoomMode ? 0 : 7); | |
361 | } | |
362 | //____________________________________________________________________ | |
363 | Bool_t | |
364 | AliFMDDisplay::Init() | |
365 | { | |
5c96b03f | 366 | // Initialize. GEt transforms and such, |
367 | // so that we can draw thins properly | |
368 | // Returns true on success | |
bf000c32 | 369 | if (!AliFMDInput::Init()) return kFALSE; |
370 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
371 | geom->Init(); | |
372 | geom->InitTransformations(); | |
97b4001e | 373 | if (TESTBIT(fTreeMask, kDigits) || TESTBIT(fTreeMask, kRaw)) |
374 | AliFMDParameters::Instance()->Init(); | |
375 | ||
a9579262 | 376 | fMarkers = new TObjArray; |
377 | fHits = new TObjArray; | |
378 | fMarkers->SetOwner(kTRUE); | |
379 | fHits->SetOwner(kFALSE); | |
bf000c32 | 380 | return kTRUE; |
381 | } | |
a9579262 | 382 | |
383 | //____________________________________________________________________ | |
384 | void | |
385 | AliFMDDisplay::MakeAux() | |
386 | { | |
5c96b03f | 387 | // MAke the aux canvas |
388 | // This is used to display spectra | |
389 | // etc, | |
a9579262 | 390 | if ((TESTBIT(fTreeMask, kESD) || |
391 | TESTBIT(fTreeMask, kDigits) || | |
392 | TESTBIT(fTreeMask, kRaw))) { | |
393 | if (!fAux) { | |
394 | fAux = new TCanvas("aux", "Aux"); | |
395 | fAux->SetLogy(); | |
396 | if (TESTBIT(fTreeMask, kESD)) | |
97b4001e | 397 | fSpec = new TH1D("spec", "Mult spectra", 500, 0, 10); |
a9579262 | 398 | else |
399 | fSpec = new TH1D("spec", "Adc spectra", 1024, -.5, 1023.5); | |
400 | fSpecCut = static_cast<TH1*>(fSpec->Clone("specCut")); | |
401 | fSpec->SetFillColor(2); | |
402 | fSpec->SetFillStyle(3001); | |
403 | fSpecCut->SetFillColor(4); | |
404 | fSpecCut->SetFillStyle(3001); | |
405 | } | |
406 | else { | |
407 | fSpec->Reset(); | |
408 | fSpecCut->Reset(); | |
409 | } | |
410 | } | |
411 | } | |
412 | ||
413 | //____________________________________________________________________ | |
414 | void | |
415 | AliFMDDisplay::DrawAux() | |
416 | { | |
5c96b03f | 417 | // Draw in the Aux the canvas |
418 | // For example draw the spectra | |
419 | // or such stuff | |
a9579262 | 420 | if (!fAux) return; |
421 | fAux->cd(); | |
422 | fAux->Clear(); | |
423 | fSpec->Draw(); | |
424 | fSpecCut->Draw("same"); | |
425 | fAux->Modified(); | |
426 | fAux->Update(); | |
427 | fAux->cd(); | |
428 | } | |
429 | ||
bf000c32 | 430 | //____________________________________________________________________ |
431 | Bool_t | |
432 | AliFMDDisplay::Begin(Int_t event) | |
433 | { | |
02a27b50 | 434 | // Begin of event. Make canvas is not already done |
5c96b03f | 435 | // Parameters: |
436 | // event The event number | |
bf000c32 | 437 | if (!fCanvas) { |
d98fbfa5 | 438 | const char* m[] = { "Continue", |
439 | "Break", | |
440 | "Zoom", | |
441 | "Pick", | |
442 | "Redisplay", | |
443 | "Render", | |
444 | 0 }; | |
a9579262 | 445 | MakeCanvas(m); |
bf000c32 | 446 | } |
97b4001e | 447 | MakeAux(); |
d98fbfa5 | 448 | fReturn = kFALSE; |
449 | ||
a9579262 | 450 | // AliInfo("Clearing canvas"); |
bf000c32 | 451 | // fCanvas->Clear(); |
452 | if (!fGeoManager) { | |
453 | Warning("End", "No geometry manager"); | |
454 | return kFALSE; | |
455 | } | |
456 | AliInfo("Drawing geometry"); | |
457 | fPad->cd(); | |
458 | fGeoManager->GetTopVolume()->Draw(); | |
a9579262 | 459 | if (fOnlyFMD) ShowOnlyFMD(); |
bf000c32 | 460 | AliInfo("Adjusting view"); |
461 | Int_t irep; | |
462 | if (fPad->GetView()) { | |
463 | fPad->GetView()->SetView(-200, -40, 80, irep); | |
464 | fPad->GetView()->Zoom(); | |
465 | fPad->Modified(); | |
466 | fPad->cd(); | |
467 | } | |
468 | return AliFMDInput::Begin(event); | |
469 | } | |
470 | ||
471 | //____________________________________________________________________ | |
a9579262 | 472 | void |
473 | AliFMDDisplay::AtEnd() | |
bf000c32 | 474 | { |
5c96b03f | 475 | // Called at of the event. |
476 | // Draw stuff. | |
477 | // Draw spectrum. | |
bf000c32 | 478 | fPad->cd(); |
479 | fMarkers->Draw(); | |
1e8f773e | 480 | fPad->cd(); |
bf000c32 | 481 | AppendPad(); |
bf000c32 | 482 | fPad->cd(); |
a9579262 | 483 | DrawAux(); |
484 | } | |
485 | ||
486 | //____________________________________________________________________ | |
487 | void | |
488 | AliFMDDisplay::Idle() | |
489 | { | |
5c96b03f | 490 | // Idle loop. |
491 | // Sends the ROOT loop into the idle loop, | |
492 | // so that we can go on. | |
bf000c32 | 493 | fWait = kTRUE; |
494 | while (fWait) { | |
495 | gApplication->StartIdleing(); | |
496 | gSystem->InnerLoop(); | |
497 | gApplication->StopIdleing(); | |
498 | } | |
499 | AliInfo("After idle loop"); | |
a9579262 | 500 | if (fMarkers) fMarkers->Delete(); |
501 | if (fHits) fHits->Clear(); | |
bf000c32 | 502 | AliInfo("After clearing caches"); |
a9579262 | 503 | } |
504 | ||
505 | //____________________________________________________________________ | |
506 | Bool_t | |
507 | AliFMDDisplay::End() | |
508 | { | |
509 | // End of event. Draw everything | |
510 | AtEnd(); | |
511 | Idle(); | |
d98fbfa5 | 512 | if (fReturn) return kFALSE; |
bf000c32 | 513 | return AliFMDInput::End(); |
514 | } | |
515 | ||
516 | //____________________________________________________________________ | |
517 | Int_t | |
d98fbfa5 | 518 | AliFMDDisplay::LookupColor(Float_t x, Float_t min, Float_t max) const |
bf000c32 | 519 | { |
5c96b03f | 520 | // Look-up color. |
521 | // Get a colour from the current palette depending | |
522 | // on the ratio x/max | |
d98fbfa5 | 523 | Float_t range = (max-min); |
524 | Float_t l = fSlider->GetMinimum(); | |
525 | Float_t h = fSlider->GetMaximum(); | |
526 | if (l == h) { l = 0; h = 1; } | |
527 | Float_t cmin = range * l; | |
528 | Float_t cmax = range * h; | |
529 | Float_t crange = (cmax-cmin); | |
530 | Int_t idx = Int_t((x-cmin) / crange * gStyle->GetNumberOfColors()); | |
bf000c32 | 531 | return gStyle->GetColorPalette(idx); |
d98fbfa5 | 532 | } |
bf000c32 | 533 | |
a9579262 | 534 | //____________________________________________________________________ |
535 | void | |
536 | AliFMDDisplay::ChangeCut() | |
537 | { | |
5c96b03f | 538 | // Change the cut on the slider. |
539 | // The factor depends on what is | |
540 | // drawn in the AUX canvas | |
d98fbfa5 | 541 | AliInfo(Form("Range is now %3.1f - %3.1f", fSlider->GetMinimum(), |
542 | fSlider->GetMaximum())); | |
543 | Redisplay(); | |
544 | } | |
545 | //____________________________________________________________________ | |
546 | void | |
547 | AliFMDDisplay::ChangeFactor() | |
548 | { | |
549 | // Change the cut on the slider. | |
550 | // The factor depends on what is | |
551 | // drawn in the AUX canvas | |
552 | AliInfo(Form("Noise factor is now %4.1f, pedestal factor %3.1f", | |
42f1b2f5 | 553 | 10*fFactor->GetMinimum(),fFactor->GetMaximum())); |
a9579262 | 554 | Redisplay(); |
555 | } | |
556 | ||
557 | //____________________________________________________________________ | |
558 | void | |
559 | AliFMDDisplay::Redisplay() | |
560 | { | |
5c96b03f | 561 | // Redisplay stuff. |
562 | // Redraw markers, hits, | |
563 | // spectra | |
a9579262 | 564 | if (fMarkers) fMarkers->Delete(); |
565 | if (fHits) fHits->Clear(); | |
566 | if (fSpec) fSpec->Reset(); | |
567 | if (fSpecCut) fSpecCut->Reset(); | |
568 | Event(); | |
569 | AtEnd(); | |
570 | } | |
d98fbfa5 | 571 | //____________________________________________________________________ |
572 | void | |
573 | AliFMDDisplay::Break() | |
574 | { | |
575 | // Redisplay stuff. | |
576 | // Redraw markers, hits, | |
577 | // spectra | |
578 | if (fMarkers) fMarkers->Delete(); | |
579 | if (fHits) fHits->Clear(); | |
580 | if (fSpec) fSpec->Reset(); | |
581 | if (fSpecCut) fSpecCut->Reset(); | |
582 | fReturn = kTRUE; | |
583 | fWait = kFALSE; | |
584 | } | |
585 | //____________________________________________________________________ | |
586 | void | |
587 | AliFMDDisplay::Render() | |
588 | { | |
589 | fPad->cd(); | |
590 | TVirtualViewer3D* viewer = fPad->GetViewer3D("ogl"); | |
591 | if (!viewer) return; | |
592 | } | |
a9579262 | 593 | |
15b17c89 | 594 | //____________________________________________________________________ |
595 | void | |
d98fbfa5 | 596 | AliFMDDisplay::AddMarker(Float_t x, Float_t y, Float_t z, |
597 | TObject* o, Float_t s, Float_t min, Float_t max) | |
15b17c89 | 598 | { |
599 | // Add a marker to the display | |
600 | // | |
601 | // det Detector | |
602 | // rng Ring | |
603 | // sec Sector | |
604 | // str Strip | |
605 | // o Object to refer to | |
606 | // s Signal | |
607 | // max Maximum of signal | |
608 | // | |
15b17c89 | 609 | Float_t size = .1; |
d98fbfa5 | 610 | Float_t zsize = (s - min) / (max-min) * 10; |
15b17c89 | 611 | Float_t r = TMath::Sqrt(x * x + y * y); |
612 | Float_t theta = TMath::ATan2(r, z); | |
613 | Float_t phi = TMath::ATan2(y, x); | |
614 | Float_t rz = z + (z < 0 ? 1 : -1) * zsize; | |
615 | TMarker3DBox* marker = new TMarker3DBox(x,y,rz,size,size,zsize,theta,phi); | |
616 | if (o) marker->SetRefObject(o); | |
d98fbfa5 | 617 | marker->SetLineColor(LookupColor(s, min, max)); |
15b17c89 | 618 | fMarkers->Add(marker); |
619 | } | |
d98fbfa5 | 620 | //____________________________________________________________________ |
621 | void | |
622 | AliFMDDisplay::AddMarker(UShort_t det, Char_t rng, UShort_t sec, UShort_t str, | |
623 | TObject* o, Float_t s, Float_t min, Float_t max) | |
624 | { | |
625 | // Add a marker to the display | |
626 | // | |
627 | // det Detector | |
628 | // rng Ring | |
629 | // sec Sector | |
630 | // str Strip | |
631 | // o Object to refer to | |
632 | // s Signal | |
633 | // max Maximum of signal | |
634 | // | |
635 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
636 | Double_t x, y, z; | |
637 | geom->Detector2XYZ(det, rng, sec, str, x, y, z); | |
638 | AddMarker(x,y,z,o,s,min,max); | |
639 | } | |
15b17c89 | 640 | |
d98fbfa5 | 641 | //____________________________________________________________________ |
642 | Bool_t | |
643 | AliFMDDisplay::InsideCut(Float_t val, const Float_t& min, | |
644 | const Float_t& max) const | |
645 | { | |
646 | Float_t r = max - min; | |
647 | Float_t l = fSlider->GetMinimum(); | |
648 | Float_t h = fSlider->GetMaximum(); | |
649 | if (l == h) { l = 0; h = 1; } | |
650 | if (val < r * l + min || val > r * h + min) return kFALSE; | |
651 | return kTRUE; | |
652 | } | |
653 | ||
bf000c32 | 654 | |
655 | //____________________________________________________________________ | |
656 | Bool_t | |
a9579262 | 657 | AliFMDDisplay::ProcessHit(AliFMDHit* hit, TParticle* /* p */) |
bf000c32 | 658 | { |
5c96b03f | 659 | // Process a hit. |
660 | // Parameters: | |
661 | // hit Hit data | |
d98fbfa5 | 662 | |
663 | static const Float_t rMin = 0; | |
664 | static const Float_t rMax = .1; | |
665 | ||
bf000c32 | 666 | if (!hit) { AliError("No hit"); return kFALSE; } |
a9579262 | 667 | // if (!p) { AliError("No track"); return kFALSE; } |
bf000c32 | 668 | |
a9579262 | 669 | if (fHits) fHits->Add(hit); |
d98fbfa5 | 670 | Float_t edep = hit->Edep(); |
671 | ||
672 | if (!InsideCut(edep, rMin, rMax)) return kTRUE; | |
673 | ||
674 | AddMarker(hit->X(), hit->Y(), hit->Z(), hit, edep, rMin, rMax); | |
bf000c32 | 675 | return kTRUE; |
676 | } | |
677 | ||
678 | //____________________________________________________________________ | |
679 | Bool_t | |
680 | AliFMDDisplay::ProcessDigit(AliFMDDigit* digit) | |
681 | { | |
02a27b50 | 682 | // Process a digit |
5c96b03f | 683 | // Parameters: |
684 | // digit Digit information | |
d98fbfa5 | 685 | |
686 | static const Float_t rMin = 0; | |
687 | static const Float_t rMax = 1023; | |
bf000c32 | 688 | if (!digit) { AliError("No digit"); return kFALSE; } |
689 | ||
bf000c32 | 690 | AliFMDParameters* parm = AliFMDParameters::Instance(); |
15b17c89 | 691 | UShort_t det = digit->Detector(); |
692 | Char_t ring = digit->Ring(); | |
693 | UShort_t sec = digit->Sector(); | |
694 | UShort_t str = digit->Strip(); | |
695 | Double_t ped = parm->GetPedestal(det,ring, sec, str); | |
696 | Double_t pedW = parm->GetPedestalWidth(det,ring, sec, str); | |
d98fbfa5 | 697 | Double_t threshold = (ped * fFactor->GetMaximum() |
698 | + pedW * fFactor->GetMinimum()); | |
97b4001e | 699 | Float_t counts = digit->Counts(); |
d98fbfa5 | 700 | |
701 | if (fHits) fHits->Add(digit); | |
702 | if (fSpec) fSpec->Fill(counts); | |
703 | if (!InsideCut(counts-threshold, rMin, rMax)) return kTRUE; | |
704 | if (fSpecCut) fSpecCut->Fill(counts); | |
705 | ||
706 | ||
707 | AddMarker(det, ring, sec, str, digit, counts, rMin, rMax); | |
bf000c32 | 708 | return kTRUE; |
709 | } | |
710 | ||
42f1b2f5 | 711 | //____________________________________________________________________ |
712 | Bool_t | |
713 | AliFMDDisplay::ProcessSDigit(AliFMDSDigit* sdigit) | |
714 | { | |
715 | // Process a sdigit | |
716 | // Parameters: | |
717 | // sdigit Digit information | |
718 | ||
719 | static const Float_t rMin = 0; | |
720 | static const Float_t rMax = 1023; | |
721 | if (!sdigit) { AliError("No sdigit"); return kFALSE; } | |
722 | ||
723 | UShort_t det = sdigit->Detector(); | |
724 | Char_t ring = sdigit->Ring(); | |
725 | UShort_t sec = sdigit->Sector(); | |
726 | UShort_t str = sdigit->Strip(); | |
727 | Float_t counts = sdigit->Counts(); | |
728 | ||
729 | if (fHits) fHits->Add(sdigit); | |
730 | if (fSpec) fSpec->Fill(counts); | |
731 | if (!InsideCut(counts, rMin, rMax)) return kTRUE; | |
732 | if (fSpecCut) fSpecCut->Fill(counts); | |
733 | ||
734 | ||
735 | AddMarker(det, ring, sec, str, sdigit, counts, rMin, rMax); | |
736 | return kTRUE; | |
737 | } | |
738 | ||
d760ea03 | 739 | //____________________________________________________________________ |
740 | Bool_t | |
741 | AliFMDDisplay::ProcessRaw(AliFMDDigit* digit) | |
742 | { | |
02a27b50 | 743 | // PRocess raw data |
5c96b03f | 744 | // Parameters: |
745 | // digit Digit information | |
d760ea03 | 746 | return ProcessDigit(digit); |
747 | } | |
748 | ||
bf000c32 | 749 | //____________________________________________________________________ |
750 | Bool_t | |
751 | AliFMDDisplay::ProcessRecPoint(AliFMDRecPoint* recpoint) | |
752 | { | |
02a27b50 | 753 | // Process reconstructed point |
5c96b03f | 754 | // Parameters: |
755 | // recpoint Reconstructed multiplicity/energy | |
d98fbfa5 | 756 | static const Float_t rMin = 0; |
757 | static const Float_t rMax = 20; | |
758 | ||
bf000c32 | 759 | if (!recpoint) { AliError("No recpoint"); return kFALSE; } |
d98fbfa5 | 760 | |
761 | if (!InsideCut(recpoint->Particles(), rMin, rMax)) return kTRUE; | |
762 | ||
a9579262 | 763 | if (fHits) fHits->Add(recpoint); |
15b17c89 | 764 | AddMarker(recpoint->Detector(), recpoint->Ring(), recpoint->Sector(), |
d98fbfa5 | 765 | recpoint->Strip(), recpoint, recpoint->Particles(), rMin, rMax); |
15b17c89 | 766 | return kTRUE; |
767 | } | |
bf000c32 | 768 | |
15b17c89 | 769 | //____________________________________________________________________ |
770 | Bool_t | |
a9579262 | 771 | AliFMDDisplay::ProcessESD(UShort_t det, Char_t rng, UShort_t sec, UShort_t str, |
97b4001e | 772 | Float_t, Float_t mult) |
15b17c89 | 773 | { |
5c96b03f | 774 | // Process data from ESD |
775 | // Parameters | |
776 | // det,rng,sec,str Detector coordinates. | |
777 | // mult Multiplicity. | |
d98fbfa5 | 778 | static const Float_t rMin = 0; |
779 | static const Float_t rMax = 20; | |
780 | ||
97b4001e | 781 | Double_t cmult = mult; |
a9579262 | 782 | if (fSpec) fSpec->Fill(cmult); |
d98fbfa5 | 783 | if (!InsideCut(cmult, rMin, rMax) || cmult == AliESDFMD::kInvalidMult) |
784 | return kTRUE; | |
785 | ||
786 | AddMarker(det,rng,sec,str, 0, cmult, rMin, rMax); | |
787 | ||
a9579262 | 788 | if (fSpecCut) fSpecCut->Fill(cmult); |
d98fbfa5 | 789 | |
bf000c32 | 790 | return kTRUE; |
791 | } | |
792 | ||
793 | //____________________________________________________________________ | |
794 | // | |
795 | // EOF | |
796 | // |