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)
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 //____________________________________________________________________
207 // fCanvas->Modified(kTRUE);
213 gApplication->StartIdleing();
214 gSystem->InnerLoop();
215 gApplication->StopIdleing();
217 AliInfo("After idle loop");
220 AliInfo("After clearing caches");
221 return AliFMDInput::End();
224 //____________________________________________________________________
226 AliFMDDisplay::LookupColor(Float_t x, Float_t max) const
228 Int_t idx = Int_t(x / max * gStyle->GetNumberOfColors());
229 return gStyle->GetColorPalette(idx);
233 //____________________________________________________________________
235 AliFMDDisplay::ProcessHit(AliFMDHit* hit, TParticle* p)
237 if (!hit) { AliError("No hit"); return kFALSE; }
238 if (!p) { AliError("No track"); return kFALSE; }
242 Float_t pt = TMath::Sqrt(hit->Py()*hit->Py()+hit->Px()*hit->Px());
243 Float_t theta = TMath::ATan2(pt, hit->Pz());
244 Float_t phi = TMath::ATan2(hit->Py(), hit->Px());
245 TMarker3DBox* marker = new TMarker3DBox(hit->X(), hit->Y(), hit->Z(),
246 size, size, size, theta, phi);
247 marker->SetLineColor(LookupColor(hit->Edep(), 1));
248 marker->SetRefObject(hit);
249 fMarkers->Add(marker);
253 //____________________________________________________________________
255 AliFMDDisplay::ProcessDigit(AliFMDDigit* digit)
257 if (!digit) { AliError("No digit"); return kFALSE; }
260 AliFMDGeometry* geom = AliFMDGeometry::Instance();
261 AliFMDParameters* parm = AliFMDParameters::Instance();
262 Double_t threshold = (parm->GetPedestal(digit->Detector(),
266 + 4 * parm->GetPedestalWidth(digit->Detector(),
270 if (digit->Counts() < threshold) return kTRUE;
272 geom->Detector2XYZ(digit->Detector(), digit->Ring(), digit->Sector(),
273 digit->Strip(), x, y, z);
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 TMarker3DBox* marker = new TMarker3DBox(x,y,z,size,size,size,theta,phi);
279 marker->SetRefObject(digit);
280 marker->SetLineColor(LookupColor(digit->Counts(), 1024));
281 fMarkers->Add(marker);
285 //____________________________________________________________________
287 AliFMDDisplay::ProcessRecPoint(AliFMDRecPoint* recpoint)
289 if (!recpoint) { AliError("No recpoint"); return kFALSE; }
290 if (recpoint->Particles() < .1) return kTRUE;
291 fHits->Add(recpoint);
293 AliFMDGeometry* geom = AliFMDGeometry::Instance();
294 geom->Detector2XYZ(recpoint->Detector(), recpoint->Ring(),
295 recpoint->Sector(), recpoint->Strip(), x, y, z);
298 Float_t r = TMath::Sqrt(x * x + y * y);
299 Float_t theta = TMath::ATan2(r, z);
300 Float_t phi = TMath::ATan2(y, x);
301 TMarker3DBox* marker = new TMarker3DBox(x,y,z,size,size,size,theta,phi);
302 marker->SetRefObject(recpoint);
303 marker->SetLineColor(LookupColor(recpoint->Particles(), 20));
304 fMarkers->Add(marker);
308 //____________________________________________________________________