]>
Commit | Line | Data |
---|---|---|
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 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //___________________________________________________________________ | |
19 | // | |
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. | |
25 | // | |
26 | // Latest changes by Christian Holm Christensen | |
27 | // | |
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 | |
35 | #include <AliLog.h> | |
36 | #include <TStyle.h> | |
37 | #include <TArrayF.h> | |
38 | #include <TMarker3DBox.h> | |
39 | #include <TGeoManager.h> | |
40 | #include <TMath.h> | |
41 | #include <TApplication.h> | |
42 | #include <TButton.h> | |
43 | #include <TParticle.h> | |
44 | #include <TCanvas.h> | |
45 | #include <TView.h> | |
46 | #include <TVirtualX.h> | |
47 | ||
48 | //____________________________________________________________________ | |
49 | ClassImp(AliFMDDisplay) | |
50 | #if 0 | |
51 | ; // This is here to keep Emacs for indenting the next line | |
52 | #endif | |
53 | ||
54 | //____________________________________________________________________ | |
55 | AliFMDDisplay* AliFMDDisplay::fgInstance = 0; | |
56 | ||
57 | //____________________________________________________________________ | |
58 | AliFMDDisplay* | |
59 | AliFMDDisplay::Instance() | |
60 | { | |
61 | return fgInstance; | |
62 | } | |
63 | ||
64 | //____________________________________________________________________ | |
65 | AliFMDDisplay::AliFMDDisplay(const char* gAliceFile) | |
66 | : AliFMDInput(gAliceFile), | |
67 | fWait(kFALSE), | |
68 | fCanvas(0), | |
69 | fPad(0), | |
70 | fButton(0), | |
71 | fZoom(0), | |
72 | fPick(0), | |
73 | fZoomMode(kFALSE) | |
74 | { | |
75 | // Constructor of an FMD display object. | |
76 | AddLoad(kGeometry); | |
77 | fMarkers = new TObjArray; | |
78 | fHits = new TObjArray; | |
79 | fMarkers->SetOwner(kTRUE); | |
80 | fHits->SetOwner(kFALSE); | |
81 | fgInstance = this; | |
82 | } | |
83 | ||
84 | //____________________________________________________________________ | |
85 | void | |
86 | AliFMDDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py) | |
87 | { | |
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); | |
92 | return; | |
93 | } | |
94 | fPad->SetCursor(kCross); | |
95 | switch (event) { | |
96 | case kButton1Down: | |
97 | fPad->TAttLine::Modify(); | |
98 | fX0 = fPad->AbsPixeltoX(px); | |
99 | fY0 = fPad->AbsPixeltoY(py); | |
100 | fXPixel = fOldXPixel = px; | |
101 | fYPixel = fOldYPixel = py; | |
102 | fLineDrawn = kFALSE; | |
103 | return; | |
104 | case kButton1Motion: | |
105 | if (fLineDrawn) | |
106 | gVirtualX->DrawBox(fXPixel, fYPixel, fOldXPixel, fOldYPixel, | |
107 | TVirtualX::kHollow); | |
108 | fOldXPixel = px; | |
109 | fOldYPixel = py; | |
110 | fLineDrawn = kTRUE; | |
111 | gVirtualX->DrawBox(fXPixel, fYPixel, fOldXPixel, fOldYPixel, | |
112 | TVirtualX::kHollow); | |
113 | return; | |
114 | case kButton1Up: | |
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); | |
122 | fPad->Modified(); | |
123 | return; | |
124 | } | |
125 | } | |
126 | ||
127 | //____________________________________________________________________ | |
128 | Int_t | |
129 | AliFMDDisplay::DistanceToPrimitive(Int_t px, Int_t py) | |
130 | { | |
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); | |
139 | } | |
140 | //____________________________________________________________________ | |
141 | Bool_t | |
142 | AliFMDDisplay::Init() | |
143 | { | |
144 | if (!AliFMDInput::Init()) return kFALSE; | |
145 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
146 | geom->Init(); | |
147 | geom->InitTransformations(); | |
148 | // AliFMDParameters* parm = AliFMDParameters::Instance(); | |
149 | // parm->Init(); | |
150 | return kTRUE; | |
151 | } | |
152 | //____________________________________________________________________ | |
153 | Bool_t | |
154 | AliFMDDisplay::Begin(Int_t event) | |
155 | { | |
156 | if (!fCanvas) { | |
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); | |
162 | fCanvas->cd(); | |
163 | fPad->Draw(); | |
164 | } | |
165 | if (!fButton) { | |
166 | fCanvas->cd(); | |
167 | fButton = new TButton("Continue", "AliFMDDisplay::Instance()->Continue()", | |
168 | 0, 0, .5, .05); | |
169 | fButton->Draw(); | |
170 | fZoom = new TButton("Zoom", "AliFMDDisplay::Instance()->Zoom()", | |
171 | .5, 0, .75, .05); | |
172 | fZoom->Draw(); | |
173 | fPick = new TButton("Pick", "AliFMDDisplay::Instance()->Pick()", | |
174 | .75, 0, 1, .05); | |
175 | fPick->Draw(); | |
176 | } | |
177 | AliInfo("Clearing canvas"); | |
178 | // fCanvas->Clear(); | |
179 | if (!fGeoManager) { | |
180 | Warning("End", "No geometry manager"); | |
181 | return kFALSE; | |
182 | } | |
183 | AliInfo("Drawing geometry"); | |
184 | fPad->cd(); | |
185 | fGeoManager->GetTopVolume()->Draw(); | |
186 | AliInfo("Adjusting view"); | |
187 | Int_t irep; | |
188 | if (fPad->GetView()) { | |
189 | fPad->GetView()->SetView(-200, -40, 80, irep); | |
190 | fPad->GetView()->Zoom(); | |
191 | fPad->Modified(); | |
192 | fPad->cd(); | |
193 | } | |
194 | return AliFMDInput::Begin(event); | |
195 | } | |
196 | ||
197 | //____________________________________________________________________ | |
198 | Bool_t | |
199 | AliFMDDisplay::End() | |
200 | { | |
201 | fPad->cd(); | |
202 | fMarkers->Draw(); | |
203 | AppendPad(); | |
204 | fPad->Update(); | |
205 | fPad->cd(); | |
206 | fCanvas->Modified(kTRUE); | |
207 | fCanvas->Update(); | |
208 | fCanvas->cd(); | |
209 | fWait = kTRUE; | |
210 | while (fWait) { | |
211 | gApplication->StartIdleing(); | |
212 | gSystem->InnerLoop(); | |
213 | gApplication->StopIdleing(); | |
214 | } | |
215 | AliInfo("After idle loop"); | |
216 | fMarkers->Delete(); | |
217 | fHits->Clear(); | |
218 | AliInfo("After clearing caches"); | |
219 | return AliFMDInput::End(); | |
220 | } | |
221 | ||
222 | //____________________________________________________________________ | |
223 | Int_t | |
224 | AliFMDDisplay::LookupColor(Float_t x, Float_t max) const | |
225 | { | |
226 | Int_t idx = Int_t(x / max * gStyle->GetNumberOfColors()); | |
227 | return gStyle->GetColorPalette(idx); | |
228 | } | |
229 | ||
230 | ||
231 | //____________________________________________________________________ | |
232 | Bool_t | |
233 | AliFMDDisplay::ProcessHit(AliFMDHit* hit, TParticle* p) | |
234 | { | |
235 | if (!hit) { AliError("No hit"); return kFALSE; } | |
236 | if (!p) { AliError("No track"); return kFALSE; } | |
237 | ||
238 | fHits->Add(hit); | |
239 | Float_t size = .1; | |
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); | |
248 | return kTRUE; | |
249 | } | |
250 | ||
251 | //____________________________________________________________________ | |
252 | Bool_t | |
253 | AliFMDDisplay::ProcessDigit(AliFMDDigit* digit) | |
254 | { | |
255 | if (!digit) { AliError("No digit"); return kFALSE; } | |
256 | ||
257 | Double_t x, y, z; | |
258 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
259 | AliFMDParameters* parm = AliFMDParameters::Instance(); | |
260 | Double_t threshold = (parm->GetPedestal(digit->Detector(), | |
261 | digit->Ring(), | |
262 | digit->Sector(), | |
263 | digit->Strip()) | |
264 | + 4 * parm->GetPedestalWidth(digit->Detector(), | |
265 | digit->Ring(), | |
266 | digit->Sector(), | |
267 | digit->Strip())); | |
268 | if (digit->Counts() < threshold) return kTRUE; | |
269 | fHits->Add(digit); | |
270 | geom->Detector2XYZ(digit->Detector(), digit->Ring(), digit->Sector(), | |
271 | digit->Strip(), x, y, z); | |
272 | Float_t size = .1; | |
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); | |
280 | return kTRUE; | |
281 | } | |
282 | ||
283 | //____________________________________________________________________ | |
284 | Bool_t | |
285 | AliFMDDisplay::ProcessRecPoint(AliFMDRecPoint* recpoint) | |
286 | { | |
287 | if (!recpoint) { AliError("No recpoint"); return kFALSE; } | |
288 | if (recpoint->Particles() < .1) return kTRUE; | |
289 | fHits->Add(recpoint); | |
290 | Double_t x, y, z; | |
291 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
292 | geom->Detector2XYZ(recpoint->Detector(), recpoint->Ring(), | |
293 | recpoint->Sector(), recpoint->Strip(), x, y, z); | |
294 | ||
295 | Float_t size = .1; | |
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); | |
303 | return kTRUE; | |
304 | } | |
305 | ||
306 | //____________________________________________________________________ | |
307 | // | |
308 | // EOF | |
309 | // |