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 **************************************************************************/
18 //___________________________________________________________________
20 // The classes defined here, are utility classes for reading in data
21 // for the FMD. They are put in a seperate library to not polute the
22 // normal libraries. The classes are intended to be used as base
23 // classes for customized class that do some sort of analysis on the
24 // various types of data produced by the FMD.
26 // Latest changes by Christian Holm Christensen
28 #include "AliFMDDisplay.h" // ALIFMDDISPLAY_H
29 #include "AliFMDHit.h" // ALIFMDHIT_H
30 #include "AliFMDDigit.h" // ALIFMDDIGIT_H
31 #include "AliFMDRecPoint.h" // ALIFMDRECPOINT_H
32 #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
33 #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
34 #include <AliESDFMD.h> // ALIESDFMD_H
38 #include <TMarker3DBox.h>
39 #include <TGeoManager.h>
41 #include <TApplication.h>
43 #include <TParticle.h>
46 #include <TVirtualX.h>
48 //____________________________________________________________________
49 ClassImp(AliFMDDisplay)
51 ; // This is here to keep Emacs for indenting the next line
54 //____________________________________________________________________
55 AliFMDDisplay* AliFMDDisplay::fgInstance = 0;
57 //____________________________________________________________________
59 AliFMDDisplay::Instance()
64 //____________________________________________________________________
65 AliFMDDisplay::AliFMDDisplay(const char* gAliceFile)
66 : AliFMDInput(gAliceFile),
75 // Constructor of an FMD display object.
77 fMarkers = new TObjArray;
78 fHits = new TObjArray;
79 fMarkers->SetOwner(kTRUE);
80 fHits->SetOwner(kFALSE);
84 //____________________________________________________________________
86 AliFMDDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
88 AliInfo(Form("Event %d, at (%d,%d)", px, py));
89 if (px == 0 && py == 0) return;
90 if (!fZoomMode && fPad->GetView()) {
91 fPad->GetView()->ExecuteRotateView(event, px, py);
94 fPad->SetCursor(kCross);
97 fPad->TAttLine::Modify();
98 fX0 = fPad->AbsPixeltoX(px);
99 fY0 = fPad->AbsPixeltoY(py);
100 fXPixel = fOldXPixel = px;
101 fYPixel = fOldYPixel = py;
106 gVirtualX->DrawBox(fXPixel, fYPixel, fOldXPixel, fOldYPixel,
111 gVirtualX->DrawBox(fXPixel, fYPixel, fOldXPixel, fOldYPixel,
115 fPad->GetCanvas()->FeedbackMode(kFALSE);
116 if (px == fXPixel || py == fYPixel) return;
117 fX1 = fPad->AbsPixeltoX(px);
118 fY1 = fPad->AbsPixeltoY(py);
119 if (fX1 < fX0) std::swap(fX0, fX1);
120 if (fY1 < fY0) std::swap(fY0, fY1);
121 fPad->Range(fX0, fY0, fX1, fY1);
127 //____________________________________________________________________
129 AliFMDDisplay::DistanceToPrimitive(Int_t px, Int_t py)
131 AliInfo(Form("@ (%d,%d)", px, py));
132 fPad->SetCursor(kCross);
133 Float_t xmin = fPad->GetX1();
134 Float_t xmax = fPad->GetX2();
135 Float_t dx = .02 * (xmax - xmin);
136 Float_t x = fPad->AbsPixeltoX(px);
137 if (x < xmin + dx || x > xmax - dx) return 9999;
138 return (fZoomMode ? 0 : 7);
140 //____________________________________________________________________
142 AliFMDDisplay::Init()
144 if (!AliFMDInput::Init()) return kFALSE;
145 AliFMDGeometry* geom = AliFMDGeometry::Instance();
147 geom->InitTransformations();
148 // AliFMDParameters* parm = AliFMDParameters::Instance();
152 //____________________________________________________________________
154 AliFMDDisplay::Begin(Int_t event)
157 gStyle->SetPalette(1);
158 fCanvas = new TCanvas("display", "Display", 700, 700);
159 fCanvas->SetFillColor(1);
160 fCanvas->ToggleEventStatus();
161 fPad = new TPad("view3D", "3DView", 0.0, 0.05, 1.0, 1.0, 1, 0, 0);
167 fButton = new TButton("Continue", "AliFMDDisplay::Instance()->Continue()",
170 fZoom = new TButton("Zoom", "AliFMDDisplay::Instance()->Zoom()",
173 fPick = new TButton("Pick", "AliFMDDisplay::Instance()->Pick()",
177 AliInfo("Clearing canvas");
180 Warning("End", "No geometry manager");
183 AliInfo("Drawing geometry");
185 fGeoManager->GetTopVolume()->Draw();
186 AliInfo("Adjusting view");
188 if (fPad->GetView()) {
189 fPad->GetView()->SetView(-200, -40, 80, irep);
190 fPad->GetView()->Zoom();
194 return AliFMDInput::Begin(event);
197 //____________________________________________________________________
206 fCanvas->Modified(kTRUE);
211 gApplication->StartIdleing();
212 gSystem->InnerLoop();
213 gApplication->StopIdleing();
215 AliInfo("After idle loop");
218 AliInfo("After clearing caches");
219 return AliFMDInput::End();
222 //____________________________________________________________________
224 AliFMDDisplay::LookupColor(Float_t x, Float_t max) const
226 Int_t idx = Int_t(x / max * gStyle->GetNumberOfColors());
227 return gStyle->GetColorPalette(idx);
231 //____________________________________________________________________
233 AliFMDDisplay::ProcessHit(AliFMDHit* hit, TParticle* p)
235 if (!hit) { AliError("No hit"); return kFALSE; }
236 if (!p) { AliError("No track"); return kFALSE; }
240 Float_t pt = TMath::Sqrt(hit->Py()*hit->Py()+hit->Px()*hit->Px());
241 Float_t theta = TMath::ATan2(pt, hit->Pz());
242 Float_t phi = TMath::ATan2(hit->Py(), hit->Px());
243 TMarker3DBox* marker = new TMarker3DBox(hit->X(), hit->Y(), hit->Z(),
244 size, size, size, theta, phi);
245 marker->SetLineColor(LookupColor(hit->Edep(), 1));
246 marker->SetRefObject(hit);
247 fMarkers->Add(marker);
251 //____________________________________________________________________
253 AliFMDDisplay::ProcessDigit(AliFMDDigit* digit)
255 if (!digit) { AliError("No digit"); return kFALSE; }
258 AliFMDGeometry* geom = AliFMDGeometry::Instance();
259 AliFMDParameters* parm = AliFMDParameters::Instance();
260 Double_t threshold = (parm->GetPedestal(digit->Detector(),
264 + 4 * parm->GetPedestalWidth(digit->Detector(),
268 if (digit->Counts() < threshold) return kTRUE;
270 geom->Detector2XYZ(digit->Detector(), digit->Ring(), digit->Sector(),
271 digit->Strip(), x, y, z);
273 Float_t r = TMath::Sqrt(x * x + y * y);
274 Float_t theta = TMath::ATan2(r, z);
275 Float_t phi = TMath::ATan2(y, x);
276 TMarker3DBox* marker = new TMarker3DBox(x,y,z,size,size,size,theta,phi);
277 marker->SetRefObject(digit);
278 marker->SetLineColor(LookupColor(digit->Counts(), 1024));
279 fMarkers->Add(marker);
283 //____________________________________________________________________
285 AliFMDDisplay::ProcessRecPoint(AliFMDRecPoint* recpoint)
287 if (!recpoint) { AliError("No recpoint"); return kFALSE; }
288 if (recpoint->Particles() < .1) return kTRUE;
289 fHits->Add(recpoint);
291 AliFMDGeometry* geom = AliFMDGeometry::Instance();
292 geom->Detector2XYZ(recpoint->Detector(), recpoint->Ring(),
293 recpoint->Sector(), recpoint->Strip(), x, y, z);
296 Float_t r = TMath::Sqrt(x * x + y * y);
297 Float_t theta = TMath::ATan2(r, z);
298 Float_t phi = TMath::ATan2(y, x);
299 TMarker3DBox* marker = new TMarker3DBox(x,y,z,size,size,size,theta,phi);
300 marker->SetRefObject(recpoint);
301 marker->SetLineColor(LookupColor(recpoint->Particles(), 20));
302 fMarkers->Add(marker);
306 //____________________________________________________________________