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),
79 // Constructor of an FMD display object.
81 fMarkers = new TObjArray;
82 fHits = new TObjArray;
83 fMarkers->SetOwner(kTRUE);
84 fHits->SetOwner(kFALSE);
90 //____________________________________________________________________
92 AliFMDDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
94 // AliInfo(Form("Event %d, at (%d,%d)", px, py));
95 if (px == 0 && py == 0) return;
96 if (!fZoomMode && fPad->GetView()) {
97 fPad->GetView()->ExecuteRotateView(event, px, py);
100 fPad->SetCursor(kCross);
103 fPad->TAttLine::Modify();
104 fX0 = fPad->AbsPixeltoX(px);
105 fY0 = fPad->AbsPixeltoY(py);
106 fXPixel = fOldXPixel = px;
107 fYPixel = fOldYPixel = py;
112 gVirtualX->DrawBox(fXPixel, fYPixel, fOldXPixel, fOldYPixel,
117 gVirtualX->DrawBox(fXPixel, fYPixel, fOldXPixel, fOldYPixel,
121 fPad->GetCanvas()->FeedbackMode(kFALSE);
122 if (px == fXPixel || py == fYPixel) return;
123 fX1 = fPad->AbsPixeltoX(px);
124 fY1 = fPad->AbsPixeltoY(py);
125 if (fX1 < fX0) std::swap(fX0, fX1);
126 if (fY1 < fY0) std::swap(fY0, fY1);
127 fPad->Range(fX0, fY0, fX1, fY1);
133 //____________________________________________________________________
135 AliFMDDisplay::DistancetoPrimitive(Int_t px, Int_t)
137 // AliInfo(Form("@ (%d,%d)", px, py));
138 fPad->SetCursor(kCross);
139 Float_t xmin = fPad->GetX1();
140 Float_t xmax = fPad->GetX2();
141 Float_t dx = .02 * (xmax - xmin);
142 Float_t x = fPad->AbsPixeltoX(px);
143 if (x < xmin + dx || x > xmax - dx) return 9999;
144 return (fZoomMode ? 0 : 7);
146 //____________________________________________________________________
148 AliFMDDisplay::Init()
150 // Initialize. GEt transforms and such,
151 if (!AliFMDInput::Init()) return kFALSE;
152 AliFMDGeometry* geom = AliFMDGeometry::Instance();
154 geom->InitTransformations();
155 // AliFMDParameters* parm = AliFMDParameters::Instance();
159 //____________________________________________________________________
161 AliFMDDisplay::Begin(Int_t event)
163 // Begin of event. Make canvas is not already done
165 gStyle->SetPalette(1);
166 fCanvas = new TCanvas("display", "Display", 700, 700);
167 fCanvas->SetFillColor(1);
168 fCanvas->ToggleEventStatus();
169 fPad = new TPad("view3D", "3DView", 0.0, 0.05, 1.0, 1.0, 1, 0, 0);
175 fButton = new TButton("Continue", "AliFMDDisplay::Instance()->Continue()",
178 fZoom = new TButton("Zoom", "AliFMDDisplay::Instance()->Zoom()",
181 fPick = new TButton("Pick", "AliFMDDisplay::Instance()->Pick()",
185 AliInfo("Clearing canvas");
188 Warning("End", "No geometry manager");
191 AliInfo("Drawing geometry");
193 fGeoManager->GetTopVolume()->Draw();
194 AliInfo("Adjusting view");
196 if (fPad->GetView()) {
197 fPad->GetView()->SetView(-200, -40, 80, irep);
198 fPad->GetView()->Zoom();
202 return AliFMDInput::Begin(event);
205 //____________________________________________________________________
209 // End of event. Draw everything
216 // fCanvas->Modified(kTRUE);
222 gApplication->StartIdleing();
223 gSystem->InnerLoop();
224 gApplication->StopIdleing();
226 AliInfo("After idle loop");
229 AliInfo("After clearing caches");
230 return AliFMDInput::End();
233 //____________________________________________________________________
235 AliFMDDisplay::LookupColor(Float_t x, Float_t max) const
238 Int_t idx = Int_t(x / max * gStyle->GetNumberOfColors());
239 return gStyle->GetColorPalette(idx);
242 //____________________________________________________________________
244 AliFMDDisplay::AddMarker(UShort_t det, Char_t rng, UShort_t sec, UShort_t str,
245 TObject* o, Float_t s, Float_t max)
247 // Add a marker to the display
253 // o Object to refer to
255 // max Maximum of signal
257 AliFMDGeometry* geom = AliFMDGeometry::Instance();
259 geom->Detector2XYZ(det, rng, sec, str, x, y, z);
261 Float_t zsize = s / max * 10;
262 Float_t r = TMath::Sqrt(x * x + y * y);
263 Float_t theta = TMath::ATan2(r, z);
264 Float_t phi = TMath::ATan2(y, x);
265 Float_t rz = z + (z < 0 ? 1 : -1) * zsize;
266 TMarker3DBox* marker = new TMarker3DBox(x,y,rz,size,size,zsize,theta,phi);
267 if (o) marker->SetRefObject(o);
268 marker->SetLineColor(LookupColor(s, max));
269 fMarkers->Add(marker);
273 //____________________________________________________________________
275 AliFMDDisplay::ProcessHit(AliFMDHit* hit, TParticle* p)
278 if (!hit) { AliError("No hit"); return kFALSE; }
279 if (!p) { AliError("No track"); return kFALSE; }
283 Float_t zsize = hit->Edep() * 10;
284 Float_t z = hit->Z() + (hit->Z() < 0 ? 1 : -1) * zsize;
285 Float_t pt = TMath::Sqrt(hit->Py()*hit->Py()+hit->Px()*hit->Px());
286 Float_t theta = TMath::ATan2(pt, hit->Pz());
287 Float_t phi = TMath::ATan2(hit->Py(), hit->Px());
288 TMarker3DBox* marker = new TMarker3DBox(hit->X(), hit->Y(), z,
289 size, size, zsize, theta, phi);
290 marker->SetLineColor(LookupColor(hit->Edep(), 1));
291 marker->SetRefObject(hit);
292 fMarkers->Add(marker);
296 //____________________________________________________________________
298 AliFMDDisplay::ProcessDigit(AliFMDDigit* digit)
301 if (!digit) { AliError("No digit"); return kFALSE; }
303 AliFMDParameters* parm = AliFMDParameters::Instance();
304 UShort_t det = digit->Detector();
305 Char_t ring = digit->Ring();
306 UShort_t sec = digit->Sector();
307 UShort_t str = digit->Strip();
308 Double_t ped = parm->GetPedestal(det,ring, sec, str);
309 Double_t pedW = parm->GetPedestalWidth(det,ring, sec, str);
310 Double_t threshold = ped * fPedestalFactor * pedW;
311 Float_t counts = digit->Counts();
312 if (counts < threshold) return kTRUE;
315 AddMarker(det, ring, sec, str, digit, counts, 1024);
319 //____________________________________________________________________
321 AliFMDDisplay::ProcessRaw(AliFMDDigit* digit)
324 return ProcessDigit(digit);
327 //____________________________________________________________________
329 AliFMDDisplay::ProcessRecPoint(AliFMDRecPoint* recpoint)
331 // Process reconstructed point
332 if (!recpoint) { AliError("No recpoint"); return kFALSE; }
333 if (recpoint->Particles() < fMultCut) return kTRUE;
334 fHits->Add(recpoint);
335 AddMarker(recpoint->Detector(), recpoint->Ring(), recpoint->Sector(),
336 recpoint->Strip(), recpoint, recpoint->Particles(), 20);
340 //____________________________________________________________________
342 AliFMDDisplay::ProcessESD(AliESDFMD* esd)
344 // Process event summary data
345 for (UShort_t det = 1; det <= 3; det++) {
346 Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
347 for (Char_t* rng = rings; *rng != '\0'; rng++) {
348 UShort_t nsec = (*rng == 'I' ? 20 : 40);
349 UShort_t nstr = (*rng == 'O' ? 512 : 256);
350 for (UShort_t sec = 0; sec < nsec; sec++) {
351 for (UShort_t str = 0; str < nstr; str++) {
352 Float_t mult = esd->Multiplicity(det,*rng,sec,str);
353 if (mult < fMultCut) continue;
354 AddMarker(det,*rng,sec,str, 0, mult, 20);
362 //____________________________________________________________________