]>
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 | //____________________________________________________________________ | |
1e8f773e | 85 | void |
bf000c32 | 86 | AliFMDDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py) |
87 | { | |
1e8f773e | 88 | // AliInfo(Form("Event %d, at (%d,%d)", px, py)); |
bf000c32 | 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 | //____________________________________________________________________ | |
1e8f773e | 128 | Int_t |
129 | AliFMDDisplay::DistancetoPrimitive(Int_t px, Int_t) | |
bf000c32 | 130 | { |
1e8f773e | 131 | // AliInfo(Form("@ (%d,%d)", px, py)); |
bf000c32 | 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(); | |
1e8f773e | 203 | fPad->cd(); |
bf000c32 | 204 | AppendPad(); |
1e8f773e | 205 | // fPad->Update(); |
bf000c32 | 206 | fPad->cd(); |
1e8f773e | 207 | // fCanvas->Modified(kTRUE); |
208 | //fCanvas->Update(); | |
209 | // fCanvas->cd(); | |
210 | // fPad->cd(); | |
bf000c32 | 211 | fWait = kTRUE; |
212 | while (fWait) { | |
213 | gApplication->StartIdleing(); | |
214 | gSystem->InnerLoop(); | |
215 | gApplication->StopIdleing(); | |
216 | } | |
217 | AliInfo("After idle loop"); | |
218 | fMarkers->Delete(); | |
219 | fHits->Clear(); | |
220 | AliInfo("After clearing caches"); | |
221 | return AliFMDInput::End(); | |
222 | } | |
223 | ||
224 | //____________________________________________________________________ | |
225 | Int_t | |
226 | AliFMDDisplay::LookupColor(Float_t x, Float_t max) const | |
227 | { | |
228 | Int_t idx = Int_t(x / max * gStyle->GetNumberOfColors()); | |
229 | return gStyle->GetColorPalette(idx); | |
230 | } | |
231 | ||
232 | ||
233 | //____________________________________________________________________ | |
234 | Bool_t | |
235 | AliFMDDisplay::ProcessHit(AliFMDHit* hit, TParticle* p) | |
236 | { | |
237 | if (!hit) { AliError("No hit"); return kFALSE; } | |
238 | if (!p) { AliError("No track"); return kFALSE; } | |
239 | ||
240 | fHits->Add(hit); | |
241 | Float_t size = .1; | |
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); | |
250 | return kTRUE; | |
251 | } | |
252 | ||
253 | //____________________________________________________________________ | |
254 | Bool_t | |
255 | AliFMDDisplay::ProcessDigit(AliFMDDigit* digit) | |
256 | { | |
257 | if (!digit) { AliError("No digit"); return kFALSE; } | |
258 | ||
259 | Double_t x, y, z; | |
260 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
261 | AliFMDParameters* parm = AliFMDParameters::Instance(); | |
262 | Double_t threshold = (parm->GetPedestal(digit->Detector(), | |
263 | digit->Ring(), | |
264 | digit->Sector(), | |
265 | digit->Strip()) | |
266 | + 4 * parm->GetPedestalWidth(digit->Detector(), | |
267 | digit->Ring(), | |
268 | digit->Sector(), | |
269 | digit->Strip())); | |
270 | if (digit->Counts() < threshold) return kTRUE; | |
271 | fHits->Add(digit); | |
272 | geom->Detector2XYZ(digit->Detector(), digit->Ring(), digit->Sector(), | |
273 | digit->Strip(), x, y, z); | |
274 | Float_t size = .1; | |
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); | |
282 | return kTRUE; | |
283 | } | |
284 | ||
285 | //____________________________________________________________________ | |
286 | Bool_t | |
287 | AliFMDDisplay::ProcessRecPoint(AliFMDRecPoint* recpoint) | |
288 | { | |
289 | if (!recpoint) { AliError("No recpoint"); return kFALSE; } | |
290 | if (recpoint->Particles() < .1) return kTRUE; | |
291 | fHits->Add(recpoint); | |
292 | Double_t x, y, z; | |
293 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
294 | geom->Detector2XYZ(recpoint->Detector(), recpoint->Ring(), | |
295 | recpoint->Sector(), recpoint->Strip(), x, y, z); | |
296 | ||
297 | Float_t size = .1; | |
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); | |
305 | return kTRUE; | |
306 | } | |
307 | ||
308 | //____________________________________________________________________ | |
309 | // | |
310 | // EOF | |
311 | // |