]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDDisplay.cxx
Cache flag initialized to kTRUE. Run number initialized to -1 (A.Colla)
[u/mrichter/AliRoot.git] / FMD / AliFMDDisplay.cxx
CommitLineData
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//
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
38#include <AliLog.h>
39#include <TStyle.h>
40#include <TArrayF.h>
41#include <TMarker3DBox.h>
42#include <TGeoManager.h>
43#include <TMath.h>
44#include <TApplication.h>
45#include <TButton.h>
46#include <TParticle.h>
47#include <TCanvas.h>
48#include <TView.h>
49#include <TVirtualX.h>
50
51//____________________________________________________________________
52ClassImp(AliFMDDisplay)
53#if 0
54 ; // This is here to keep Emacs for indenting the next line
55#endif
56
57//____________________________________________________________________
58AliFMDDisplay* AliFMDDisplay::fgInstance = 0;
59
60//____________________________________________________________________
61AliFMDDisplay*
62AliFMDDisplay::Instance()
63{
64 return fgInstance;
65}
66
67//____________________________________________________________________
68AliFMDDisplay::AliFMDDisplay(const char* gAliceFile)
69 : AliFMDInput(gAliceFile),
70 fWait(kFALSE),
71 fCanvas(0),
72 fPad(0),
73 fButton(0),
74 fZoom(0),
75 fPick(0),
76 fZoomMode(kFALSE)
77{
78 // Constructor of an FMD display object.
79 AddLoad(kGeometry);
80 fMarkers = new TObjArray;
81 fHits = new TObjArray;
82 fMarkers->SetOwner(kTRUE);
83 fHits->SetOwner(kFALSE);
84 fgInstance = this;
85}
86
87//____________________________________________________________________
1e8f773e 88void
bf000c32 89AliFMDDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
90{
1e8f773e 91 // AliInfo(Form("Event %d, at (%d,%d)", px, py));
bf000c32 92 if (px == 0 && py == 0) return;
93 if (!fZoomMode && fPad->GetView()) {
94 fPad->GetView()->ExecuteRotateView(event, px, py);
95 return;
96 }
97 fPad->SetCursor(kCross);
98 switch (event) {
99 case kButton1Down:
100 fPad->TAttLine::Modify();
101 fX0 = fPad->AbsPixeltoX(px);
102 fY0 = fPad->AbsPixeltoY(py);
103 fXPixel = fOldXPixel = px;
104 fYPixel = fOldYPixel = py;
105 fLineDrawn = kFALSE;
106 return;
107 case kButton1Motion:
108 if (fLineDrawn)
109 gVirtualX->DrawBox(fXPixel, fYPixel, fOldXPixel, fOldYPixel,
110 TVirtualX::kHollow);
111 fOldXPixel = px;
112 fOldYPixel = py;
113 fLineDrawn = kTRUE;
114 gVirtualX->DrawBox(fXPixel, fYPixel, fOldXPixel, fOldYPixel,
115 TVirtualX::kHollow);
116 return;
117 case kButton1Up:
118 fPad->GetCanvas()->FeedbackMode(kFALSE);
119 if (px == fXPixel || py == fYPixel) return;
120 fX1 = fPad->AbsPixeltoX(px);
121 fY1 = fPad->AbsPixeltoY(py);
122 if (fX1 < fX0) std::swap(fX0, fX1);
123 if (fY1 < fY0) std::swap(fY0, fY1);
124 fPad->Range(fX0, fY0, fX1, fY1);
125 fPad->Modified();
126 return;
127 }
128}
129
130//____________________________________________________________________
1e8f773e 131Int_t
132AliFMDDisplay::DistancetoPrimitive(Int_t px, Int_t)
bf000c32 133{
1e8f773e 134 // AliInfo(Form("@ (%d,%d)", px, py));
bf000c32 135 fPad->SetCursor(kCross);
136 Float_t xmin = fPad->GetX1();
137 Float_t xmax = fPad->GetX2();
138 Float_t dx = .02 * (xmax - xmin);
139 Float_t x = fPad->AbsPixeltoX(px);
140 if (x < xmin + dx || x > xmax - dx) return 9999;
141 return (fZoomMode ? 0 : 7);
142}
143//____________________________________________________________________
144Bool_t
145AliFMDDisplay::Init()
146{
147 if (!AliFMDInput::Init()) return kFALSE;
148 AliFMDGeometry* geom = AliFMDGeometry::Instance();
149 geom->Init();
150 geom->InitTransformations();
151 // AliFMDParameters* parm = AliFMDParameters::Instance();
152 // parm->Init();
153 return kTRUE;
154}
155//____________________________________________________________________
156Bool_t
157AliFMDDisplay::Begin(Int_t event)
158{
159 if (!fCanvas) {
160 gStyle->SetPalette(1);
161 fCanvas = new TCanvas("display", "Display", 700, 700);
162 fCanvas->SetFillColor(1);
163 fCanvas->ToggleEventStatus();
164 fPad = new TPad("view3D", "3DView", 0.0, 0.05, 1.0, 1.0, 1, 0, 0);
165 fCanvas->cd();
166 fPad->Draw();
167 }
168 if (!fButton) {
169 fCanvas->cd();
170 fButton = new TButton("Continue", "AliFMDDisplay::Instance()->Continue()",
171 0, 0, .5, .05);
172 fButton->Draw();
173 fZoom = new TButton("Zoom", "AliFMDDisplay::Instance()->Zoom()",
174 .5, 0, .75, .05);
175 fZoom->Draw();
176 fPick = new TButton("Pick", "AliFMDDisplay::Instance()->Pick()",
177 .75, 0, 1, .05);
178 fPick->Draw();
179 }
180 AliInfo("Clearing canvas");
181 // fCanvas->Clear();
182 if (!fGeoManager) {
183 Warning("End", "No geometry manager");
184 return kFALSE;
185 }
186 AliInfo("Drawing geometry");
187 fPad->cd();
188 fGeoManager->GetTopVolume()->Draw();
189 AliInfo("Adjusting view");
190 Int_t irep;
191 if (fPad->GetView()) {
192 fPad->GetView()->SetView(-200, -40, 80, irep);
193 fPad->GetView()->Zoom();
194 fPad->Modified();
195 fPad->cd();
196 }
197 return AliFMDInput::Begin(event);
198}
199
200//____________________________________________________________________
201Bool_t
202AliFMDDisplay::End()
203{
204 fPad->cd();
205 fMarkers->Draw();
1e8f773e 206 fPad->cd();
bf000c32 207 AppendPad();
1e8f773e 208 // fPad->Update();
bf000c32 209 fPad->cd();
1e8f773e 210 // fCanvas->Modified(kTRUE);
211 //fCanvas->Update();
212 // fCanvas->cd();
213 // fPad->cd();
bf000c32 214 fWait = kTRUE;
215 while (fWait) {
216 gApplication->StartIdleing();
217 gSystem->InnerLoop();
218 gApplication->StopIdleing();
219 }
220 AliInfo("After idle loop");
221 fMarkers->Delete();
222 fHits->Clear();
223 AliInfo("After clearing caches");
224 return AliFMDInput::End();
225}
226
227//____________________________________________________________________
228Int_t
229AliFMDDisplay::LookupColor(Float_t x, Float_t max) const
230{
231 Int_t idx = Int_t(x / max * gStyle->GetNumberOfColors());
232 return gStyle->GetColorPalette(idx);
233}
234
235
236//____________________________________________________________________
237Bool_t
238AliFMDDisplay::ProcessHit(AliFMDHit* hit, TParticle* p)
239{
240 if (!hit) { AliError("No hit"); return kFALSE; }
241 if (!p) { AliError("No track"); return kFALSE; }
242
243 fHits->Add(hit);
244 Float_t size = .1;
245 Float_t pt = TMath::Sqrt(hit->Py()*hit->Py()+hit->Px()*hit->Px());
246 Float_t theta = TMath::ATan2(pt, hit->Pz());
247 Float_t phi = TMath::ATan2(hit->Py(), hit->Px());
248 TMarker3DBox* marker = new TMarker3DBox(hit->X(), hit->Y(), hit->Z(),
249 size, size, size, theta, phi);
250 marker->SetLineColor(LookupColor(hit->Edep(), 1));
251 marker->SetRefObject(hit);
252 fMarkers->Add(marker);
253 return kTRUE;
254}
255
256//____________________________________________________________________
257Bool_t
258AliFMDDisplay::ProcessDigit(AliFMDDigit* digit)
259{
260 if (!digit) { AliError("No digit"); return kFALSE; }
261
262 Double_t x, y, z;
263 AliFMDGeometry* geom = AliFMDGeometry::Instance();
264 AliFMDParameters* parm = AliFMDParameters::Instance();
265 Double_t threshold = (parm->GetPedestal(digit->Detector(),
266 digit->Ring(),
267 digit->Sector(),
268 digit->Strip())
269 + 4 * parm->GetPedestalWidth(digit->Detector(),
270 digit->Ring(),
271 digit->Sector(),
272 digit->Strip()));
273 if (digit->Counts() < threshold) return kTRUE;
274 fHits->Add(digit);
275 geom->Detector2XYZ(digit->Detector(), digit->Ring(), digit->Sector(),
276 digit->Strip(), x, y, z);
277 Float_t size = .1;
278 Float_t r = TMath::Sqrt(x * x + y * y);
279 Float_t theta = TMath::ATan2(r, z);
280 Float_t phi = TMath::ATan2(y, x);
281 TMarker3DBox* marker = new TMarker3DBox(x,y,z,size,size,size,theta,phi);
282 marker->SetRefObject(digit);
283 marker->SetLineColor(LookupColor(digit->Counts(), 1024));
284 fMarkers->Add(marker);
285 return kTRUE;
286}
287
d760ea03 288//____________________________________________________________________
289Bool_t
290AliFMDDisplay::ProcessRaw(AliFMDDigit* digit)
291{
292 return ProcessDigit(digit);
293}
294
bf000c32 295//____________________________________________________________________
296Bool_t
297AliFMDDisplay::ProcessRecPoint(AliFMDRecPoint* recpoint)
298{
299 if (!recpoint) { AliError("No recpoint"); return kFALSE; }
300 if (recpoint->Particles() < .1) return kTRUE;
301 fHits->Add(recpoint);
302 Double_t x, y, z;
303 AliFMDGeometry* geom = AliFMDGeometry::Instance();
304 geom->Detector2XYZ(recpoint->Detector(), recpoint->Ring(),
305 recpoint->Sector(), recpoint->Strip(), x, y, z);
306
307 Float_t size = .1;
308 Float_t r = TMath::Sqrt(x * x + y * y);
309 Float_t theta = TMath::ATan2(r, z);
310 Float_t phi = TMath::ATan2(y, x);
311 TMarker3DBox* marker = new TMarker3DBox(x,y,z,size,size,size,theta,phi);
312 marker->SetRefObject(recpoint);
313 marker->SetLineColor(LookupColor(recpoint->Particles(), 20));
314 fMarkers->Add(marker);
315 return kTRUE;
316}
317
318//____________________________________________________________________
319//
320// EOF
321//