]>
Commit | Line | Data |
---|---|---|
a9579262 | 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 | /* $Id$ */ | |
16 | /** @file AliFMDPattern.cxx | |
17 | @author Christian Holm Christensen <cholm@nbi.dk> | |
18 | @date Mon Mar 27 12:39:09 2006 | |
19 | @brief FMD 2D Event display | |
20 | */ | |
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 | // | |
9edefa04 | 31 | |
f95a63c4 | 32 | // #include <iostream> |
9edefa04 | 33 | |
f95a63c4 | 34 | // #include <TApplication.h> |
35 | // #include <TButton.h> | |
9edefa04 | 36 | #include <TCanvas.h> |
37 | #include <TH2F.h> | |
38 | #include <TMath.h> | |
39 | #include <TPad.h> | |
40 | #include <TRandom.h> | |
f95a63c4 | 41 | // #include <TSlider.h> |
9edefa04 | 42 | #include <TStyle.h> |
f95a63c4 | 43 | // #include <TSystem.h> |
9edefa04 | 44 | #include <TVector2.h> |
f95a63c4 | 45 | // #include <TView.h> |
46 | #include <TGraph.h> | |
a9579262 | 47 | #include "AliFMDPattern.h" // ALIFMDDISPLAY_H |
48 | #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H | |
f95a63c4 | 49 | //#include "AliFMDParameters.h" // ALIFMDPARAMETERS_H |
a9579262 | 50 | #include "AliFMDRing.h" |
f95a63c4 | 51 | // #include "AliFMDDetector.h" |
a9579262 | 52 | #include "AliFMDHit.h" |
f95a63c4 | 53 | // #include <AliLog.h> |
54 | #include "AliFMDDebug.h" // Better debug macros | |
55 | class AliFMDDetector; | |
a9579262 | 56 | |
57 | //____________________________________________________________________ | |
58 | ClassImp(AliFMDPattern) | |
59 | #if 0 | |
60 | ; // This is here to keep Emacs for indenting the next line | |
61 | #endif | |
62 | ||
63 | //____________________________________________________________________ | |
f95a63c4 | 64 | AliFMDPattern::AliFMDPatternDetector::AliFMDPatternDetector(UShort_t id) |
a9579262 | 65 | : fId(id), |
66 | fCounts(0), | |
67 | fGraphs(0), | |
68 | fFrame(0) | |
f95a63c4 | 69 | { |
70 | // CTOR | |
71 | // | |
72 | // Parameters: | |
73 | // | |
74 | // ID Identifier | |
75 | } | |
a9579262 | 76 | |
77 | //____________________________________________________________________ | |
f95a63c4 | 78 | AliFMDPattern::AliFMDPatternDetector::~AliFMDPatternDetector() |
a9579262 | 79 | { |
f95a63c4 | 80 | // DTOR |
81 | // Destructor - | |
82 | // deletes mother frame | |
a9579262 | 83 | if (fFrame) delete fFrame; |
84 | } | |
85 | ||
86 | //____________________________________________________________________ | |
87 | void | |
f95a63c4 | 88 | AliFMDPattern::AliFMDPatternDetector::DrawShape(TObjArray& a) |
a9579262 | 89 | { |
f95a63c4 | 90 | // Draw all shapes. |
91 | // | |
92 | // Paramters | |
93 | // | |
94 | // a Array of shapes | |
95 | // | |
a9579262 | 96 | TIter next(&a); |
97 | TGraph* g = 0; | |
98 | while ((g = static_cast<TGraph*>(next()))) { | |
99 | g->DrawClone("f same"); | |
100 | g->DrawClone("l same"); | |
101 | } | |
102 | } | |
103 | ||
104 | //____________________________________________________________________ | |
105 | void | |
f95a63c4 | 106 | AliFMDPattern::AliFMDPatternDetector::Begin(Int_t nlevel, Double_t r, |
a9579262 | 107 | TObjArray& inners, TObjArray& outers) |
108 | { | |
f95a63c4 | 109 | // Start of a run. |
110 | // | |
111 | // Parameters | |
112 | // | |
113 | // nlevel Number of levels | |
114 | // r Radius | |
115 | // inners Array of inner shapes | |
116 | // outers Array of outer shapes | |
117 | // | |
118 | ||
119 | // To make code-checker shut up | |
120 | TStyle* style = gStyle; | |
121 | if (nlevel < 1) nlevel = style->GetNumberOfColors(); | |
a9579262 | 122 | fCounts.Set(nlevel); |
123 | if (!fFrame) { | |
f95a63c4 | 124 | // The code-checker thinks this is not using the declaration of |
125 | // TH2F - what a morron! | |
a9579262 | 126 | fFrame = new TH2F(Form("fmd%dFrame", fId), Form("FMD%d", fId), |
127 | 10, -r, r, 10, -r, r); | |
128 | fFrame->SetStats(kFALSE); | |
129 | fFrame->Draw(); | |
130 | } | |
131 | DrawShape(inners); | |
132 | if (fId != 1) DrawShape(outers); | |
133 | for (Int_t i = 0; i < nlevel; i++) { | |
134 | TGraph* g = new TGraph; | |
f95a63c4 | 135 | Int_t idx = Int_t(Float_t(i) / nlevel * style->GetNumberOfColors()); |
136 | Int_t col = style->GetColorPalette(idx); | |
a9579262 | 137 | g->SetName(Form("FMD%d_L%02d", fId, i)); |
138 | g->SetMarkerColor(col); | |
139 | g->SetLineColor(col); | |
140 | g->SetFillColor(col); | |
141 | g->SetMarkerSize(i * .2 + .2); | |
142 | g->SetMarkerStyle(2); | |
143 | g->Draw("same p"); | |
144 | fGraphs.AddAtAndExpand(g, i); | |
145 | } | |
146 | TIter next(&fGraphs); | |
147 | } | |
148 | ||
149 | //____________________________________________________________________ | |
150 | void | |
f95a63c4 | 151 | AliFMDPattern::AliFMDPatternDetector::Clear() |
a9579262 | 152 | { |
f95a63c4 | 153 | // Clear this display. |
154 | // Simply reset counters to zero. | |
155 | // Avoid deleting memory. | |
a9579262 | 156 | fCounts.Reset(0); |
157 | } | |
158 | ||
159 | //____________________________________________________________________ | |
160 | void | |
f95a63c4 | 161 | AliFMDPattern::AliFMDPatternDetector::End() |
a9579262 | 162 | { |
f95a63c4 | 163 | // Called when displaying the data. |
164 | // Simply resets number of points at each level to | |
165 | // the seen number of hits at that level. | |
166 | // Avoid deleting memory. | |
a9579262 | 167 | TIter next(&fGraphs); |
168 | TGraph* g = 0; | |
169 | Int_t i = 0; | |
170 | while ((g = static_cast<TGraph*>(next()))) g->Set(fCounts[i++]); | |
171 | } | |
172 | //____________________________________________________________________ | |
173 | void | |
f95a63c4 | 174 | AliFMDPattern::AliFMDPatternDetector::AddMarker(Double_t x, Double_t y, Float_t s, |
a9579262 | 175 | Float_t max) |
176 | { | |
f95a63c4 | 177 | // Add a marker at (X,Y,Z). The marker color and size is chosen |
178 | // relative to the MAX argument. | |
179 | // | |
180 | // Parameters | |
181 | // | |
182 | // X,Y,Z Coordiantes | |
183 | // MAX Maximum value. | |
184 | // | |
185 | /** Sigh, for some odd reason, the code-checker does not recognise | |
186 | this a usage of the TMath namespace declaration! Idiot */ | |
187 | Int_t i = TMath::Min(Int_t(fCounts.fN * s / max), | |
a9579262 | 188 | Int_t(fGraphs.GetEntries()-1)); |
189 | TGraph* g = static_cast<TGraph*>(fGraphs.At(i)); | |
190 | if (!g) return; | |
191 | g->SetPoint(fCounts[i]++, x, y); | |
192 | } | |
193 | ||
194 | ||
195 | //____________________________________________________________________ | |
196 | AliFMDPattern::AliFMDPattern(const char* gAliceFile) | |
197 | : AliFMDDisplay(kTRUE, gAliceFile), | |
198 | fInnerMax(0), | |
199 | fOuterMax(0), | |
200 | fFMD1Pad(0), | |
201 | fFMD1(1), | |
202 | fFMD2Pad(0), | |
203 | fFMD2(2), | |
204 | fFMD3Pad(0), | |
205 | fFMD3(3), | |
206 | fEvent(.1, .8, "Event #"), | |
207 | fFMD1Sum(.2, .7, "# in FMD1: "), | |
208 | fFMD2Sum(.2, .6, "# in FMD2: "), | |
209 | fFMD3Sum(.2, .5, "# in FMD3: "), | |
210 | fLine(.15, .47, .85, .47), | |
211 | fTotal(.2, .35, "Total: ") | |
212 | { | |
f95a63c4 | 213 | // Constructor. |
214 | // | |
215 | // Parameters | |
216 | // | |
217 | // gAliceFile The galice.root file to use - if any. | |
218 | // | |
219 | ||
a9579262 | 220 | // RemoveLoad(kGeometry); |
221 | fEvent.SetBit(TLatex::kTextNDC); | |
222 | fFMD1Sum.SetBit(TLatex::kTextNDC); | |
223 | fFMD2Sum.SetBit(TLatex::kTextNDC); | |
224 | fFMD3Sum.SetBit(TLatex::kTextNDC); | |
225 | fLine.SetBit(TLine::kLineNDC); | |
226 | fTotal.SetBit(TLatex::kTextNDC); | |
227 | } | |
228 | ||
229 | //____________________________________________________________________ | |
230 | AliFMDPattern::~AliFMDPattern() | |
231 | { | |
f95a63c4 | 232 | // DTOR |
233 | // Free all allocated shapes. | |
234 | // note, that most members are real objects, so we do not need to | |
235 | // deal with them here. | |
a9579262 | 236 | fInners.Delete(); |
237 | fOuters.Delete(); | |
238 | } | |
239 | ||
240 | ||
241 | //____________________________________________________________________ | |
242 | Bool_t | |
243 | AliFMDPattern::Init() | |
244 | { | |
f95a63c4 | 245 | // Initialize. Get transforms and such, |
a9579262 | 246 | if (!AliFMDInput::Init()) return kFALSE; |
247 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
69893a66 | 248 | if (!geom) return kFALSE; |
a9579262 | 249 | geom->Init(); |
250 | geom->InitTransformations(); | |
251 | ||
252 | Char_t rs[] = { 'I' , 'O', '\0' }; | |
253 | Char_t *r = rs; | |
254 | do { | |
255 | AliFMDRing* ring = geom->GetRing(*r); | |
256 | if (!ring) continue; | |
257 | const TObjArray& vs = ring->GetVerticies(); | |
258 | TObjArray& gs = (*r == 'I' ? fInners : fOuters); | |
259 | Float_t& mr = (*r == 'I' ? fInnerMax : fOuterMax); | |
260 | Int_t nm = ring->GetNModules(); | |
261 | AliInfo(Form("Making %d modules for %c", nm, *r)); | |
262 | for (Int_t m = 0; m < nm; m++) { | |
263 | Int_t nv = vs.GetEntries(); | |
264 | Double_t a = TMath::Pi() / 180 * (m * 2 + 1) * ring->GetTheta(); | |
265 | TGraph* g = new TGraph(nv+1); | |
266 | Double_t x0 = 0, y0 = 0; | |
267 | gs.AddAtAndExpand(g, m); | |
268 | for (Int_t c = 0; c < nv; c++) { | |
269 | TVector2* v = static_cast<TVector2*>(vs.At(c)); | |
270 | mr = TMath::Max(mr, Float_t(v->Mod())); | |
271 | TVector2 w(v->Rotate(a)); | |
272 | if (c == 0) { x0 = w.X(); y0 = w.Y(); } | |
273 | g->SetPoint(c, w.X(), w.Y()); | |
274 | } | |
275 | g->SetName(Form("FMDX%c_%02d", *r, m)); | |
276 | g->SetPoint(nv, x0, y0); | |
277 | g->SetFillColor((*rs == 'I' ? | |
278 | (m % 2 == 0 ? 18 : 17) : | |
279 | (m % 2 == 0 ? 20 : 23))); | |
280 | g->SetFillStyle(3001); | |
281 | g->SetLineColor(1); | |
282 | g->SetLineWidth(1); | |
283 | g->SetLineStyle(2); | |
284 | } | |
285 | } while (*(++r)); | |
286 | ||
287 | return kTRUE; | |
288 | } | |
289 | ||
290 | //____________________________________________________________________ | |
291 | Bool_t | |
292 | AliFMDPattern::Begin(Int_t event) | |
293 | { | |
f95a63c4 | 294 | // Called at the begining of an event. |
295 | // | |
296 | // Parameters | |
297 | // | |
298 | // EVENT The event number | |
299 | // | |
97b4001e | 300 | MakeAux(); |
a9579262 | 301 | if (!fCanvas) { |
302 | const char* which[] = { "Continue", "Redisplay", 0 }; | |
303 | MakeCanvas(which); | |
a9579262 | 304 | |
305 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
f95a63c4 | 306 | // AliFMDDetector* det; |
307 | if ((/* det = */ geom->GetDetector(1))) { | |
a9579262 | 308 | fPad->cd(); |
309 | fFMD1Pad = new TPad("FMD1", "FMD1", 0.0, 0.50, 0.5, 1.0, 0, 0); | |
310 | fFMD1Pad->Draw(); | |
311 | fFMD1Pad->cd(); | |
97b4001e | 312 | fFMD1.Begin(-1, fInnerMax, fInners, fOuters); |
a9579262 | 313 | } |
f95a63c4 | 314 | if ((/* det = */ geom->GetDetector(2))) { |
a9579262 | 315 | fPad->cd(); |
316 | fFMD2Pad = new TPad("FMD2", "FMD2", 0.5, 0.50, 1.0, 1.0, 0, 0); | |
317 | fFMD2Pad->Draw(); | |
318 | fFMD2Pad->cd(); | |
97b4001e | 319 | fFMD2.Begin(-1, fOuterMax, fInners, fOuters); |
a9579262 | 320 | } |
f95a63c4 | 321 | if ((/* det = */ geom->GetDetector(3))) { |
a9579262 | 322 | fPad->cd(); |
323 | fFMD3Pad = new TPad("FMD3", "FMD3", 0.0, 0.0, .5, .5, 0, 0); | |
324 | fFMD3Pad->Draw(); | |
325 | fFMD3Pad->cd(); | |
97b4001e | 326 | fFMD3.Begin(-1, fOuterMax, fInners, fOuters); |
a9579262 | 327 | } |
328 | fPad->cd(); | |
329 | fSummary = new TPad("display", "Display", 0.5, 0.0, 1.0, 0.5, 0, 0); | |
330 | fSummary->Draw(); | |
331 | fSummary->cd(); | |
332 | fEvent.Draw(); | |
333 | fFMD1Sum.Draw(); | |
334 | fFMD2Sum.Draw(); | |
335 | fFMD3Sum.Draw(); | |
336 | fLine.Draw(); | |
337 | fTotal.Draw(); | |
338 | } | |
339 | fEvent.SetTitle(Form("Event # %6d", event)); | |
340 | ||
341 | fCanvas->Modified(); | |
342 | fCanvas->Update(); | |
343 | fCanvas->cd(); | |
344 | fFMD1.Clear(); | |
345 | fFMD2.Clear(); | |
346 | fFMD3.Clear(); | |
347 | return AliFMDInput::Begin(event); | |
348 | } | |
349 | ||
350 | //____________________________________________________________________ | |
351 | void | |
352 | AliFMDPattern::Redisplay() | |
353 | { | |
f95a63c4 | 354 | // Redraw the displayu |
a9579262 | 355 | fFMD1.Clear(); |
356 | fFMD2.Clear(); | |
357 | fFMD3.Clear(); | |
358 | AliFMDDisplay::Redisplay(); | |
359 | } | |
360 | ||
361 | //____________________________________________________________________ | |
362 | void | |
363 | AliFMDPattern::AtEnd() | |
364 | { | |
f95a63c4 | 365 | // Called at the end of an event. |
a9579262 | 366 | DrawAux(); |
367 | ||
368 | Int_t total = 0; | |
369 | ||
370 | fFMD1.End(); | |
371 | fFMD1Pad->Modified(); | |
372 | fFMD1Sum.SetTitle(Form("# hits in FMD1: %5d", fFMD1.Total())); | |
373 | total += fFMD1.Total(); | |
374 | ||
375 | fFMD2.End(); | |
376 | fFMD2Pad->Modified(); | |
377 | fFMD2Sum.SetTitle(Form("# hits in FMD2: %5d", fFMD2.Total())); | |
378 | total += fFMD2.Total(); | |
379 | ||
380 | fFMD3.End(); | |
381 | fFMD3Pad->Modified(); | |
382 | fFMD3Sum.SetTitle(Form("# hits in FMD3: %5d", fFMD3.Total())); | |
383 | total += fFMD3.Total(); | |
384 | ||
385 | fTotal.SetTitle(Form("Total: %5d/51200 (%3d%%)", | |
386 | total, Int_t(100. / 51200 * total))); | |
387 | fSummary->Modified(); | |
388 | fCanvas->Modified(); | |
389 | fCanvas->Update(); | |
390 | fCanvas->cd(); | |
391 | } | |
392 | ||
393 | //____________________________________________________________________ | |
394 | Bool_t | |
395 | AliFMDPattern::ProcessHit(AliFMDHit* hit, TParticle*) | |
396 | { | |
f95a63c4 | 397 | // Process a hit. |
398 | // | |
399 | // Parameters | |
400 | // | |
401 | // HIT The hit to process. | |
402 | // | |
403 | // The TParticle argument is never used. | |
a9579262 | 404 | switch (hit->Detector()) { |
405 | case 1: fFMD1.AddMarker(hit->X(), hit->Y(), hit->Edep(), 1); break; | |
406 | case 2: fFMD2.AddMarker(hit->X(), hit->Y(), hit->Edep(), 1); break; | |
407 | case 3: fFMD3.AddMarker(hit->X(), hit->Y(), hit->Edep(), 1); break; | |
408 | } | |
409 | return kTRUE; | |
410 | } | |
411 | ||
412 | ||
413 | //____________________________________________________________________ | |
414 | void | |
f95a63c4 | 415 | AliFMDPattern::AddMarker(UShort_t det, Char_t rng, |
416 | UShort_t sec, UShort_t str, | |
a9579262 | 417 | TObject*, Float_t s, Float_t max) |
418 | { | |
419 | // Add a marker to the display | |
420 | // | |
421 | // det Detector | |
422 | // rng Ring | |
423 | // sec Sector | |
424 | // str Strip | |
425 | // o Object to refer to | |
426 | // s Signal | |
427 | // max Maximum of signal | |
428 | // | |
f95a63c4 | 429 | AliFMDPatternDetector* d = 0; |
a9579262 | 430 | switch (det) { |
431 | case 1: d = &fFMD1; break; | |
432 | case 2: d = &fFMD2; break; | |
433 | case 3: d = &fFMD3; break; | |
434 | } | |
435 | if (!d) return; | |
436 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
437 | Double_t x, y, z; | |
438 | geom->Detector2XYZ(det, rng, sec, str, x, y, z); | |
f95a63c4 | 439 | // Make code-checker shut the f**k up |
440 | TRandom* rand = gRandom; | |
a9579262 | 441 | if (true) { |
442 | AliFMDRing* r = geom->GetRing(rng); | |
443 | Double_t t = .9 * r->GetTheta() / 2; | |
f95a63c4 | 444 | Double_t a = rand->Uniform(-t,t) * TMath::Pi() / 180; |
a9579262 | 445 | Double_t x1 = x * TMath::Cos(a) - y * TMath::Sin(a); |
446 | Double_t y1 = x * TMath::Sin(a) + y * TMath::Cos(a); | |
447 | x = x1; | |
448 | y = y1; | |
449 | } | |
450 | d->AddMarker(x, y, s, max); | |
451 | } | |
452 | ||
453 | //____________________________________________________________________ | |
454 | // | |
455 | // EOF | |
456 | // |