1 /**************************************************************************
2 * Copyright(c) 2004, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
21 //___________________________________________________________________
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.
29 // Latest changes by Christian Holm Christensen
31 #include "AliFMDDisplay.h" // ALIFMDDISPLAY_H
32 #include "AliFMDHit.h" // ALIFMDHIT_H
33 #include "AliFMDDigit.h" // ALIFMDDIGIT_H
34 #include "AliFMDRecPoint.h" // ALIFMDRECPOINT_H
35 #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
36 #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
37 #include <AliESDFMD.h> // ALIESDFMD_H
40 // #include <TArrayF.h>
41 #include <TMarker3DBox.h>
42 #include <TGeoManager.h>
44 #include <TApplication.h>
46 // #include <TParticle.h>
49 #include <TVirtualX.h>
51 //____________________________________________________________________
52 ClassImp(AliFMDDisplay)
54 ; // This is here to keep Emacs for indenting the next line
57 //____________________________________________________________________
58 AliFMDDisplay* AliFMDDisplay::fgInstance = 0;
60 //____________________________________________________________________
62 AliFMDDisplay::Instance()
64 // Return static instance
68 //____________________________________________________________________
69 AliFMDDisplay::AliFMDDisplay(const char* gAliceFile)
70 : AliFMDInput(gAliceFile),
92 // Constructor of an FMD display object.
94 fMarkers = new TObjArray;
95 fHits = new TObjArray;
96 fMarkers->SetOwner(kTRUE);
97 fHits->SetOwner(kFALSE);
103 //____________________________________________________________________
105 AliFMDDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
107 // AliInfo(Form("Event %d, at (%d,%d)", px, py));
108 if (px == 0 && py == 0) return;
109 if (!fZoomMode && fPad->GetView()) {
110 fPad->GetView()->ExecuteRotateView(event, px, py);
113 fPad->SetCursor(kCross);
116 fPad->TAttLine::Modify();
117 fX0 = fPad->AbsPixeltoX(px);
118 fY0 = fPad->AbsPixeltoY(py);
119 fXPixel = fOldXPixel = px;
120 fYPixel = fOldYPixel = py;
125 gVirtualX->DrawBox(fXPixel, fYPixel, fOldXPixel, fOldYPixel,
130 gVirtualX->DrawBox(fXPixel, fYPixel, fOldXPixel, fOldYPixel,
134 fPad->GetCanvas()->FeedbackMode(kFALSE);
135 if (px == fXPixel || py == fYPixel) return;
136 fX1 = fPad->AbsPixeltoX(px);
137 fY1 = fPad->AbsPixeltoY(py);
138 if (fX1 < fX0) std::swap(fX0, fX1);
139 if (fY1 < fY0) std::swap(fY0, fY1);
140 fPad->Range(fX0, fY0, fX1, fY1);
146 //____________________________________________________________________
148 AliFMDDisplay::DistancetoPrimitive(Int_t px, Int_t)
150 // AliInfo(Form("@ (%d,%d)", px, py));
151 fPad->SetCursor(kCross);
152 Float_t xmin = fPad->GetX1();
153 Float_t xmax = fPad->GetX2();
154 Float_t dx = .02 * (xmax - xmin);
155 Float_t x = fPad->AbsPixeltoX(px);
156 if (x < xmin + dx || x > xmax - dx) return 9999;
157 return (fZoomMode ? 0 : 7);
159 //____________________________________________________________________
161 AliFMDDisplay::Init()
163 // Initialize. GEt transforms and such,
164 if (!AliFMDInput::Init()) return kFALSE;
165 AliFMDGeometry* geom = AliFMDGeometry::Instance();
167 geom->InitTransformations();
168 // AliFMDParameters* parm = AliFMDParameters::Instance();
172 //____________________________________________________________________
174 AliFMDDisplay::Begin(Int_t event)
176 // Begin of event. Make canvas is not already done
178 gStyle->SetPalette(1);
179 fCanvas = new TCanvas("display", "Display", 700, 700);
180 fCanvas->SetFillColor(1);
181 fCanvas->ToggleEventStatus();
182 fPad = new TPad("view3D", "3DView", 0.0, 0.05, 1.0, 1.0, 1, 0, 0);
188 fButton = new TButton("Continue", "AliFMDDisplay::Instance()->Continue()",
191 fZoom = new TButton("Zoom", "AliFMDDisplay::Instance()->Zoom()",
194 fPick = new TButton("Pick", "AliFMDDisplay::Instance()->Pick()",
198 AliInfo("Clearing canvas");
201 Warning("End", "No geometry manager");
204 AliInfo("Drawing geometry");
206 fGeoManager->GetTopVolume()->Draw();
207 AliInfo("Adjusting view");
209 if (fPad->GetView()) {
210 fPad->GetView()->SetView(-200, -40, 80, irep);
211 fPad->GetView()->Zoom();
215 return AliFMDInput::Begin(event);
218 //____________________________________________________________________
222 // End of event. Draw everything
229 // fCanvas->Modified(kTRUE);
235 gApplication->StartIdleing();
236 gSystem->InnerLoop();
237 gApplication->StopIdleing();
239 AliInfo("After idle loop");
242 AliInfo("After clearing caches");
243 return AliFMDInput::End();
246 //____________________________________________________________________
248 AliFMDDisplay::LookupColor(Float_t x, Float_t max) const
251 Int_t idx = Int_t(x / max * gStyle->GetNumberOfColors());
252 return gStyle->GetColorPalette(idx);
255 //____________________________________________________________________
257 AliFMDDisplay::AddMarker(UShort_t det, Char_t rng, UShort_t sec, UShort_t str,
258 TObject* o, Float_t s, Float_t max)
260 // Add a marker to the display
266 // o Object to refer to
268 // max Maximum of signal
270 AliFMDGeometry* geom = AliFMDGeometry::Instance();
272 geom->Detector2XYZ(det, rng, sec, str, x, y, z);
274 Float_t zsize = s / max * 10;
275 Float_t r = TMath::Sqrt(x * x + y * y);
276 Float_t theta = TMath::ATan2(r, z);
277 Float_t phi = TMath::ATan2(y, x);
278 Float_t rz = z + (z < 0 ? 1 : -1) * zsize;
279 TMarker3DBox* marker = new TMarker3DBox(x,y,rz,size,size,zsize,theta,phi);
280 if (o) marker->SetRefObject(o);
281 marker->SetLineColor(LookupColor(s, max));
282 fMarkers->Add(marker);
286 //____________________________________________________________________
288 AliFMDDisplay::ProcessHit(AliFMDHit* hit, TParticle* p)
291 if (!hit) { AliError("No hit"); return kFALSE; }
292 if (!p) { AliError("No track"); return kFALSE; }
296 Float_t zsize = hit->Edep() * 10;
297 Float_t z = hit->Z() + (hit->Z() < 0 ? 1 : -1) * zsize;
298 Float_t pt = TMath::Sqrt(hit->Py()*hit->Py()+hit->Px()*hit->Px());
299 Float_t theta = TMath::ATan2(pt, hit->Pz());
300 Float_t phi = TMath::ATan2(hit->Py(), hit->Px());
301 TMarker3DBox* marker = new TMarker3DBox(hit->X(), hit->Y(), z,
302 size, size, zsize, theta, phi);
303 marker->SetLineColor(LookupColor(hit->Edep(), 1));
304 marker->SetRefObject(hit);
305 fMarkers->Add(marker);
309 //____________________________________________________________________
311 AliFMDDisplay::ProcessDigit(AliFMDDigit* digit)
314 if (!digit) { AliError("No digit"); return kFALSE; }
316 AliFMDParameters* parm = AliFMDParameters::Instance();
317 UShort_t det = digit->Detector();
318 Char_t ring = digit->Ring();
319 UShort_t sec = digit->Sector();
320 UShort_t str = digit->Strip();
321 Double_t ped = parm->GetPedestal(det,ring, sec, str);
322 Double_t pedW = parm->GetPedestalWidth(det,ring, sec, str);
323 Double_t threshold = ped * fPedestalFactor * pedW;
324 Float_t counts = digit->Counts();
325 if (counts < threshold) return kTRUE;
328 AddMarker(det, ring, sec, str, digit, counts, 1024);
332 //____________________________________________________________________
334 AliFMDDisplay::ProcessRaw(AliFMDDigit* digit)
337 return ProcessDigit(digit);
340 //____________________________________________________________________
342 AliFMDDisplay::ProcessRecPoint(AliFMDRecPoint* recpoint)
344 // Process reconstructed point
345 if (!recpoint) { AliError("No recpoint"); return kFALSE; }
346 if (recpoint->Particles() < fMultCut) return kTRUE;
347 fHits->Add(recpoint);
348 AddMarker(recpoint->Detector(), recpoint->Ring(), recpoint->Sector(),
349 recpoint->Strip(), recpoint, recpoint->Particles(), 20);
353 //____________________________________________________________________
355 AliFMDDisplay::ProcessESD(AliESDFMD* esd)
357 // Process event summary data
358 for (UShort_t det = 1; det <= 3; det++) {
359 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
360 for (Char_t* rng = rings; *rng != '\0'; rng++) {
361 UShort_t nsec = (*rng == 'I' ? 20 : 40);
362 UShort_t nstr = (*rng == 'O' ? 512 : 256);
363 for (UShort_t sec = 0; sec < nsec; sec++) {
364 for (UShort_t str = 0; str < nstr; str++) {
365 Float_t mult = esd->Multiplicity(det,*rng,sec,str);
366 if (mult < fMultCut) continue;
367 AddMarker(det,*rng,sec,str, 0, mult, 20);
375 //____________________________________________________________________