]>
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 | **************************************************************************/ | |
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 | |
15b17c89 | 37 | #include <AliESDFMD.h> // ALIESDFMD_H |
bf000c32 | 38 | #include <AliLog.h> |
39 | #include <TStyle.h> | |
02a27b50 | 40 | // #include <TArrayF.h> |
bf000c32 | 41 | #include <TMarker3DBox.h> |
42 | #include <TGeoManager.h> | |
02a27b50 | 43 | // #include <TMath.h> |
bf000c32 | 44 | #include <TApplication.h> |
45 | #include <TButton.h> | |
02a27b50 | 46 | // #include <TParticle.h> |
bf000c32 | 47 | #include <TCanvas.h> |
48 | #include <TView.h> | |
49 | #include <TVirtualX.h> | |
50 | ||
51 | //____________________________________________________________________ | |
52 | ClassImp(AliFMDDisplay) | |
53 | #if 0 | |
54 | ; // This is here to keep Emacs for indenting the next line | |
55 | #endif | |
56 | ||
57 | //____________________________________________________________________ | |
58 | AliFMDDisplay* AliFMDDisplay::fgInstance = 0; | |
59 | ||
60 | //____________________________________________________________________ | |
61 | AliFMDDisplay* | |
62 | AliFMDDisplay::Instance() | |
63 | { | |
02a27b50 | 64 | // Return static instance |
bf000c32 | 65 | return fgInstance; |
66 | } | |
67 | ||
68 | //____________________________________________________________________ | |
69 | AliFMDDisplay::AliFMDDisplay(const char* gAliceFile) | |
70 | : AliFMDInput(gAliceFile), | |
71 | fWait(kFALSE), | |
b5ee4425 | 72 | fMarkers(0), |
73 | fHits(0), | |
bf000c32 | 74 | fCanvas(0), |
75 | fPad(0), | |
76 | fButton(0), | |
77 | fZoom(0), | |
78 | fPick(0), | |
b5ee4425 | 79 | fZoomMode(kFALSE), |
80 | fX0(0), | |
81 | fY0(0), | |
82 | fX1(0), | |
83 | fY1(0), | |
84 | fMultCut(0), | |
85 | fPedestalFactor(0), | |
86 | fXPixel(0), | |
87 | fYPixel(0), | |
88 | fOldXPixel(0), | |
89 | fOldYPixel(0), | |
90 | fLineDrawn(0) | |
bf000c32 | 91 | { |
92 | // Constructor of an FMD display object. | |
93 | AddLoad(kGeometry); | |
94 | fMarkers = new TObjArray; | |
95 | fHits = new TObjArray; | |
96 | fMarkers->SetOwner(kTRUE); | |
97 | fHits->SetOwner(kFALSE); | |
98 | fgInstance = this; | |
15b17c89 | 99 | SetMultiplicityCut(); |
100 | SetPedestalFactor(); | |
bf000c32 | 101 | } |
102 | ||
103 | //____________________________________________________________________ | |
1e8f773e | 104 | void |
bf000c32 | 105 | AliFMDDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py) |
106 | { | |
1e8f773e | 107 | // AliInfo(Form("Event %d, at (%d,%d)", px, py)); |
bf000c32 | 108 | if (px == 0 && py == 0) return; |
109 | if (!fZoomMode && fPad->GetView()) { | |
110 | fPad->GetView()->ExecuteRotateView(event, px, py); | |
111 | return; | |
112 | } | |
113 | fPad->SetCursor(kCross); | |
114 | switch (event) { | |
115 | case kButton1Down: | |
116 | fPad->TAttLine::Modify(); | |
117 | fX0 = fPad->AbsPixeltoX(px); | |
118 | fY0 = fPad->AbsPixeltoY(py); | |
119 | fXPixel = fOldXPixel = px; | |
120 | fYPixel = fOldYPixel = py; | |
121 | fLineDrawn = kFALSE; | |
122 | return; | |
123 | case kButton1Motion: | |
124 | if (fLineDrawn) | |
125 | gVirtualX->DrawBox(fXPixel, fYPixel, fOldXPixel, fOldYPixel, | |
126 | TVirtualX::kHollow); | |
127 | fOldXPixel = px; | |
128 | fOldYPixel = py; | |
129 | fLineDrawn = kTRUE; | |
130 | gVirtualX->DrawBox(fXPixel, fYPixel, fOldXPixel, fOldYPixel, | |
131 | TVirtualX::kHollow); | |
132 | return; | |
133 | case kButton1Up: | |
134 | fPad->GetCanvas()->FeedbackMode(kFALSE); | |
135 | if (px == fXPixel || py == fYPixel) return; | |
136 | fX1 = fPad->AbsPixeltoX(px); | |
137 | fY1 = fPad->AbsPixeltoY(py); | |
138 | if (fX1 < fX0) std::swap(fX0, fX1); | |
139 | if (fY1 < fY0) std::swap(fY0, fY1); | |
140 | fPad->Range(fX0, fY0, fX1, fY1); | |
141 | fPad->Modified(); | |
142 | return; | |
143 | } | |
144 | } | |
145 | ||
146 | //____________________________________________________________________ | |
1e8f773e | 147 | Int_t |
148 | AliFMDDisplay::DistancetoPrimitive(Int_t px, Int_t) | |
bf000c32 | 149 | { |
1e8f773e | 150 | // AliInfo(Form("@ (%d,%d)", px, py)); |
bf000c32 | 151 | fPad->SetCursor(kCross); |
152 | Float_t xmin = fPad->GetX1(); | |
153 | Float_t xmax = fPad->GetX2(); | |
154 | Float_t dx = .02 * (xmax - xmin); | |
155 | Float_t x = fPad->AbsPixeltoX(px); | |
156 | if (x < xmin + dx || x > xmax - dx) return 9999; | |
157 | return (fZoomMode ? 0 : 7); | |
158 | } | |
159 | //____________________________________________________________________ | |
160 | Bool_t | |
161 | AliFMDDisplay::Init() | |
162 | { | |
02a27b50 | 163 | // Initialize. GEt transforms and such, |
bf000c32 | 164 | if (!AliFMDInput::Init()) return kFALSE; |
165 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
166 | geom->Init(); | |
167 | geom->InitTransformations(); | |
168 | // AliFMDParameters* parm = AliFMDParameters::Instance(); | |
169 | // parm->Init(); | |
170 | return kTRUE; | |
171 | } | |
172 | //____________________________________________________________________ | |
173 | Bool_t | |
174 | AliFMDDisplay::Begin(Int_t event) | |
175 | { | |
02a27b50 | 176 | // Begin of event. Make canvas is not already done |
bf000c32 | 177 | if (!fCanvas) { |
178 | gStyle->SetPalette(1); | |
179 | fCanvas = new TCanvas("display", "Display", 700, 700); | |
180 | fCanvas->SetFillColor(1); | |
181 | fCanvas->ToggleEventStatus(); | |
182 | fPad = new TPad("view3D", "3DView", 0.0, 0.05, 1.0, 1.0, 1, 0, 0); | |
183 | fCanvas->cd(); | |
184 | fPad->Draw(); | |
185 | } | |
186 | if (!fButton) { | |
187 | fCanvas->cd(); | |
188 | fButton = new TButton("Continue", "AliFMDDisplay::Instance()->Continue()", | |
189 | 0, 0, .5, .05); | |
190 | fButton->Draw(); | |
191 | fZoom = new TButton("Zoom", "AliFMDDisplay::Instance()->Zoom()", | |
192 | .5, 0, .75, .05); | |
193 | fZoom->Draw(); | |
194 | fPick = new TButton("Pick", "AliFMDDisplay::Instance()->Pick()", | |
195 | .75, 0, 1, .05); | |
196 | fPick->Draw(); | |
197 | } | |
198 | AliInfo("Clearing canvas"); | |
199 | // fCanvas->Clear(); | |
200 | if (!fGeoManager) { | |
201 | Warning("End", "No geometry manager"); | |
202 | return kFALSE; | |
203 | } | |
204 | AliInfo("Drawing geometry"); | |
205 | fPad->cd(); | |
206 | fGeoManager->GetTopVolume()->Draw(); | |
207 | AliInfo("Adjusting view"); | |
208 | Int_t irep; | |
209 | if (fPad->GetView()) { | |
210 | fPad->GetView()->SetView(-200, -40, 80, irep); | |
211 | fPad->GetView()->Zoom(); | |
212 | fPad->Modified(); | |
213 | fPad->cd(); | |
214 | } | |
215 | return AliFMDInput::Begin(event); | |
216 | } | |
217 | ||
218 | //____________________________________________________________________ | |
219 | Bool_t | |
220 | AliFMDDisplay::End() | |
221 | { | |
02a27b50 | 222 | // End of event. Draw everything |
bf000c32 | 223 | fPad->cd(); |
224 | fMarkers->Draw(); | |
1e8f773e | 225 | fPad->cd(); |
bf000c32 | 226 | AppendPad(); |
1e8f773e | 227 | // fPad->Update(); |
bf000c32 | 228 | fPad->cd(); |
1e8f773e | 229 | // fCanvas->Modified(kTRUE); |
230 | //fCanvas->Update(); | |
231 | // fCanvas->cd(); | |
232 | // fPad->cd(); | |
bf000c32 | 233 | fWait = kTRUE; |
234 | while (fWait) { | |
235 | gApplication->StartIdleing(); | |
236 | gSystem->InnerLoop(); | |
237 | gApplication->StopIdleing(); | |
238 | } | |
239 | AliInfo("After idle loop"); | |
240 | fMarkers->Delete(); | |
241 | fHits->Clear(); | |
242 | AliInfo("After clearing caches"); | |
243 | return AliFMDInput::End(); | |
244 | } | |
245 | ||
246 | //____________________________________________________________________ | |
247 | Int_t | |
248 | AliFMDDisplay::LookupColor(Float_t x, Float_t max) const | |
249 | { | |
02a27b50 | 250 | // Look-up color |
bf000c32 | 251 | Int_t idx = Int_t(x / max * gStyle->GetNumberOfColors()); |
252 | return gStyle->GetColorPalette(idx); | |
253 | } | |
254 | ||
15b17c89 | 255 | //____________________________________________________________________ |
256 | void | |
257 | AliFMDDisplay::AddMarker(UShort_t det, Char_t rng, UShort_t sec, UShort_t str, | |
258 | TObject* o, Float_t s, Float_t max) | |
259 | { | |
260 | // Add a marker to the display | |
261 | // | |
262 | // det Detector | |
263 | // rng Ring | |
264 | // sec Sector | |
265 | // str Strip | |
266 | // o Object to refer to | |
267 | // s Signal | |
268 | // max Maximum of signal | |
269 | // | |
270 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
271 | Double_t x, y, z; | |
272 | geom->Detector2XYZ(det, rng, sec, str, x, y, z); | |
273 | Float_t size = .1; | |
274 | Float_t zsize = s / max * 10; | |
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 | Float_t rz = z + (z < 0 ? 1 : -1) * zsize; | |
279 | TMarker3DBox* marker = new TMarker3DBox(x,y,rz,size,size,zsize,theta,phi); | |
280 | if (o) marker->SetRefObject(o); | |
281 | marker->SetLineColor(LookupColor(s, max)); | |
282 | fMarkers->Add(marker); | |
283 | } | |
284 | ||
bf000c32 | 285 | |
286 | //____________________________________________________________________ | |
287 | Bool_t | |
288 | AliFMDDisplay::ProcessHit(AliFMDHit* hit, TParticle* p) | |
289 | { | |
02a27b50 | 290 | // Process a hit |
bf000c32 | 291 | if (!hit) { AliError("No hit"); return kFALSE; } |
292 | if (!p) { AliError("No track"); return kFALSE; } | |
293 | ||
294 | fHits->Add(hit); | |
295 | Float_t size = .1; | |
15b17c89 | 296 | Float_t zsize = hit->Edep() * 10; |
297 | Float_t z = hit->Z() + (hit->Z() < 0 ? 1 : -1) * zsize; | |
bf000c32 | 298 | Float_t pt = TMath::Sqrt(hit->Py()*hit->Py()+hit->Px()*hit->Px()); |
299 | Float_t theta = TMath::ATan2(pt, hit->Pz()); | |
300 | Float_t phi = TMath::ATan2(hit->Py(), hit->Px()); | |
15b17c89 | 301 | TMarker3DBox* marker = new TMarker3DBox(hit->X(), hit->Y(), z, |
302 | size, size, zsize, theta, phi); | |
bf000c32 | 303 | marker->SetLineColor(LookupColor(hit->Edep(), 1)); |
304 | marker->SetRefObject(hit); | |
305 | fMarkers->Add(marker); | |
306 | return kTRUE; | |
307 | } | |
308 | ||
309 | //____________________________________________________________________ | |
310 | Bool_t | |
311 | AliFMDDisplay::ProcessDigit(AliFMDDigit* digit) | |
312 | { | |
02a27b50 | 313 | // Process a digit |
bf000c32 | 314 | if (!digit) { AliError("No digit"); return kFALSE; } |
315 | ||
bf000c32 | 316 | AliFMDParameters* parm = AliFMDParameters::Instance(); |
15b17c89 | 317 | UShort_t det = digit->Detector(); |
318 | Char_t ring = digit->Ring(); | |
319 | UShort_t sec = digit->Sector(); | |
320 | UShort_t str = digit->Strip(); | |
321 | Double_t ped = parm->GetPedestal(det,ring, sec, str); | |
322 | Double_t pedW = parm->GetPedestalWidth(det,ring, sec, str); | |
323 | Double_t threshold = ped * fPedestalFactor * pedW; | |
324 | Float_t counts = digit->Counts(); | |
325 | if (counts < threshold) return kTRUE; | |
bf000c32 | 326 | fHits->Add(digit); |
15b17c89 | 327 | |
328 | AddMarker(det, ring, sec, str, digit, counts, 1024); | |
bf000c32 | 329 | return kTRUE; |
330 | } | |
331 | ||
d760ea03 | 332 | //____________________________________________________________________ |
333 | Bool_t | |
334 | AliFMDDisplay::ProcessRaw(AliFMDDigit* digit) | |
335 | { | |
02a27b50 | 336 | // PRocess raw data |
d760ea03 | 337 | return ProcessDigit(digit); |
338 | } | |
339 | ||
bf000c32 | 340 | //____________________________________________________________________ |
341 | Bool_t | |
342 | AliFMDDisplay::ProcessRecPoint(AliFMDRecPoint* recpoint) | |
343 | { | |
02a27b50 | 344 | // Process reconstructed point |
bf000c32 | 345 | if (!recpoint) { AliError("No recpoint"); return kFALSE; } |
15b17c89 | 346 | if (recpoint->Particles() < fMultCut) return kTRUE; |
bf000c32 | 347 | fHits->Add(recpoint); |
15b17c89 | 348 | AddMarker(recpoint->Detector(), recpoint->Ring(), recpoint->Sector(), |
349 | recpoint->Strip(), recpoint, recpoint->Particles(), 20); | |
350 | return kTRUE; | |
351 | } | |
bf000c32 | 352 | |
15b17c89 | 353 | //____________________________________________________________________ |
354 | Bool_t | |
355 | AliFMDDisplay::ProcessESD(AliESDFMD* esd) | |
356 | { | |
357 | // Process event summary data | |
358 | for (UShort_t det = 1; det <= 3; det++) { | |
359 | Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' }; | |
360 | for (Char_t* rng = rings; *rng != '\0'; rng++) { | |
361 | UShort_t nsec = (*rng == 'I' ? 20 : 40); | |
362 | UShort_t nstr = (*rng == 'O' ? 512 : 256); | |
363 | for (UShort_t sec = 0; sec < nsec; sec++) { | |
364 | for (UShort_t str = 0; str < nstr; str++) { | |
365 | Float_t mult = esd->Multiplicity(det,*rng,sec,str); | |
366 | if (mult < fMultCut) continue; | |
367 | AddMarker(det,*rng,sec,str, 0, mult, 20); | |
368 | } | |
369 | } | |
370 | } | |
371 | } | |
bf000c32 | 372 | return kTRUE; |
373 | } | |
374 | ||
375 | //____________________________________________________________________ | |
376 | // | |
377 | // EOF | |
378 | // |