]>
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 AliFMDFancy.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 | |
32 | #include <iomanip> | |
33 | #include <iostream> | |
34 | ||
a9579262 | 35 | #include <TApplication.h> |
36 | #include <TButton.h> | |
37 | #include <TCanvas.h> | |
a9579262 | 38 | #include <TH2F.h> |
39 | #include <TH3F.h> | |
9edefa04 | 40 | #include <TLatex.h> |
41 | #include <TLine.h> | |
42 | #include <TMath.h> | |
43 | #include <TRandom.h> | |
44 | #include <TStyle.h> | |
a9579262 | 45 | #include <TSystem.h> |
46 | #include <TVector2.h> | |
9edefa04 | 47 | #include <TView.h> |
48 | ||
a9579262 | 49 | #include "AliFMDDetector.h" |
9edefa04 | 50 | #include "AliFMDFancy.h" // ALIFMDDISPLAY_H |
51 | #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H | |
a9579262 | 52 | #include "AliFMDHit.h" |
9edefa04 | 53 | #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H |
54 | #include "AliFMDRing.h" | |
55 | #include <AliLog.h> | |
a9579262 | 56 | |
57 | //____________________________________________________________________ | |
58 | ClassImp(AliFMDFancy) | |
59 | #if 0 | |
60 | ; // This is here to keep Emacs for indenting the next line | |
61 | #endif | |
62 | ||
63 | //____________________________________________________________________ | |
64 | AliFMDFancy::AliFMDFancy(const char* gAliceFile) | |
65 | : AliFMDDisplay(kTRUE, gAliceFile), | |
66 | fFMD1Pad(0), | |
67 | fFMD1(1), | |
68 | fFMD2Pad(0), | |
69 | fFMD2(2), | |
70 | fFMD3Pad(0), | |
71 | fFMD3(3), | |
72 | fEvent(.1, .8, "Event #"), | |
73 | fFMD1IHits(.2, .7, "# in FMD1I: "), | |
74 | fFMD2IHits(.2, .6, "# in FMD2I: "), | |
75 | fFMD2OHits(.2, .5, "# in FMD2O: "), | |
76 | fFMD3IHits(.2, .4, "# in FMD3I: "), | |
77 | fFMD3OHits(.2, .3, "# in FMD3O: "), | |
78 | fLine(.15, .27, .85, .27), | |
79 | fTotal(.2, .15, "Total: ") | |
80 | { | |
81 | fEvent.SetBit(TLatex::kTextNDC); | |
82 | fFMD1IHits.SetBit(TLatex::kTextNDC); | |
83 | fFMD2IHits.SetBit(TLatex::kTextNDC); | |
84 | fFMD2OHits.SetBit(TLatex::kTextNDC); | |
85 | fFMD3IHits.SetBit(TLatex::kTextNDC); | |
86 | fFMD3OHits.SetBit(TLatex::kTextNDC); | |
87 | fLine.SetBit(TLine::kLineNDC); | |
88 | fTotal.SetBit(TLatex::kTextNDC); | |
89 | } | |
90 | ||
91 | //____________________________________________________________________ | |
92 | AliFMDFancy::Detector::Detector(UShort_t id) | |
93 | : fId(id) | |
94 | { | |
95 | fInnerHits.SetName(Form("FMD%dI", id)); | |
96 | fInnerHits.SetMarkerStyle(1); // 20); | |
97 | fInnerHits.SetMarkerSize(.2); | |
98 | fInnerHits.SetMarkerColor(50); // 12); | |
99 | fOuterHits.SetName(Form("FMD%dO", id)); | |
100 | fOuterHits.SetMarkerStyle(1); // 20); | |
101 | fOuterHits.SetMarkerSize(.2); | |
102 | fOuterHits.SetMarkerColor(50); // 12); | |
103 | } | |
104 | ||
105 | //____________________________________________________________________ | |
106 | AliFMDFancy::Detector::~Detector() | |
107 | { | |
108 | fShapes.Delete(); | |
109 | if (fFrame) delete fFrame; | |
110 | } | |
111 | ||
112 | //____________________________________________________________________ | |
113 | AliFMDFancy::~AliFMDFancy() | |
114 | {} | |
115 | ||
116 | //____________________________________________________________________ | |
117 | void | |
118 | AliFMDFancy::Detector::AddHistogram(TGraph2D& g, const char* opt) | |
119 | { | |
120 | TH2* h = g.GetHistogram(opt); | |
121 | if (!h) return; | |
122 | h->SetBins(1, -fMaxR, fMaxR, 1, -fMaxR, fMaxR); | |
123 | h->GetZaxis()->SetRangeUser(fMinZ, fMaxZ); | |
124 | } | |
125 | ||
126 | ||
127 | ||
128 | //____________________________________________________________________ | |
129 | void | |
130 | AliFMDFancy::Detector::Init() | |
131 | { | |
132 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
133 | AliFMDDetector* det = geom->GetDetector(fId); | |
134 | if (!det) return; | |
135 | Char_t rs[] = { 'I' , 'O', '\0' }; | |
136 | Char_t* rp = rs; | |
137 | Char_t r; | |
138 | Double_t maxR = 0; | |
139 | Double_t minZ = 10000; | |
140 | Double_t maxZ = -10000; | |
141 | Int_t ns = 0; | |
142 | while ((r = *(rp++))) { | |
143 | AliFMDRing* ring = det->GetRing(r); | |
144 | if (!ring) continue; | |
145 | // if (r == 'O') continue; | |
146 | const TObjArray& vs = ring->GetVerticies(); | |
147 | Int_t nm = ring->GetNModules(); | |
148 | Double_t zd = (r == 'I' ? det->GetInnerZ() : det->GetOuterZ()); | |
149 | for (Int_t m = 0; m < nm; m++) { | |
150 | Int_t nv = vs.GetEntries(); | |
151 | Double_t a = TMath::Pi() / 180 * (m * 2 + 1) * ring->GetTheta(); | |
152 | TGraph2D* g = new TGraph2D(nv); | |
153 | Double_t x0 = 0, y0 = 0, z0 = 0; | |
154 | Double_t z = zd + (m % 2==0 ? 0 : | |
155 | TMath::Sign(ring->GetModuleSpacing(), zd)); | |
156 | minZ = TMath::Min(minZ, z); | |
157 | maxZ = TMath::Max(maxZ, z); | |
158 | g->SetName(Form("FMD%d%cM%02d", fId, r, m)); | |
159 | fShapes.AddAtAndExpand(g, ns++); | |
160 | for (Int_t c = 0; c < nv; c++) { | |
161 | TVector2* v = static_cast<TVector2*>(vs.At(nv - 1 - c)); | |
162 | TVector2 w(v->Rotate(a)); | |
163 | if (c == 0) { x0 = w.X(); y0 = w.Y(); z0 = z; } | |
164 | g->SetPoint(c, w.X(), w.Y(), z); | |
165 | maxR = TMath::Max(maxR, v->Mod()); | |
166 | } | |
167 | //g->SetPoint(nv, x0, y0, z0); | |
168 | g->SetFillColor(2); | |
169 | g->SetFillStyle(3002); | |
170 | g->SetLineColor(2); | |
171 | g->SetLineWidth(1); | |
172 | } | |
173 | } | |
174 | fMaxR = 1.05 * maxR; | |
175 | fMinZ = (minZ > 0 ? 0.95 * minZ : 1.05 * minZ); | |
176 | fMaxZ = (maxZ > 0 ? 1.05 * maxZ : 0.95 * maxZ); | |
177 | ||
178 | TIter next(&fShapes); | |
179 | TGraph2D* g = 0; | |
180 | while ((g = static_cast<TGraph2D*>(next()))) AddHistogram(*g); | |
181 | if (det->GetInner()) AddHistogram(fInnerHits); | |
182 | if (det->GetOuter()) AddHistogram(fOuterHits); | |
183 | ||
184 | fFrame = new TH2F(Form("FMD%d", fId), Form("FMD%d", fId), | |
185 | 1, -fMaxR, fMaxR, 1, -fMaxR, fMaxR); | |
186 | fFrame->SetStats(kFALSE); | |
187 | fFrame->GetXaxis()->SetTitle("x [cm]"); | |
188 | fFrame->GetYaxis()->SetTitle("y [cm]"); | |
189 | fFrame->GetZaxis()->SetTitle("z [cm]"); | |
190 | fFrame->SetDirectory(0); | |
191 | } | |
192 | ||
193 | ||
194 | //____________________________________________________________________ | |
195 | Bool_t | |
196 | AliFMDFancy::Init() | |
197 | { | |
198 | // Initialize. GEt transforms and such, | |
199 | if (!AliFMDInput::Init()) return kFALSE; | |
200 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
201 | geom->Init(); | |
202 | geom->InitTransformations(); | |
203 | ||
204 | fFMD1.Init(); | |
205 | fFMD2.Init(); | |
206 | fFMD3.Init(); | |
207 | return kTRUE; | |
208 | } | |
209 | ||
210 | //____________________________________________________________________ | |
211 | void | |
212 | AliFMDFancy::Detector::Begin(Int_t /* event */) | |
213 | { | |
214 | TIter next(&fShapes); | |
215 | TGraph2D* g = 0; | |
216 | fFrame->Draw("surf fb"); | |
217 | fFrame->GetZaxis()->SetRangeUser(fMinZ, fMaxZ); | |
218 | while ((g = static_cast<TGraph2D*>(next()))) g->Draw("tri2 FB same"); | |
219 | } | |
220 | ||
221 | //____________________________________________________________________ | |
222 | void | |
223 | AliFMDFancy::Detector::Clear(Int_t /* event */) | |
224 | { | |
225 | fNInnerHits = 0; | |
226 | fNOuterHits = 0; | |
227 | } | |
228 | ||
229 | ||
230 | //____________________________________________________________________ | |
231 | Bool_t | |
232 | AliFMDFancy::Begin(Int_t event) | |
233 | { | |
234 | if (!fCanvas) { | |
235 | const char* which[] = { "Continue", "Redisplay", 0 }; | |
236 | MakeCanvas(which); | |
237 | ||
238 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
239 | AliFMDDetector* det; | |
240 | if ((det = geom->GetDetector(1))) { | |
241 | fPad->cd(); | |
242 | fFMD1Pad = new TPad("FMD1", "FMD1", 0.0, 0.50, 0.5, 1.0, 0, 0); | |
243 | fFMD1Pad->Draw(); | |
244 | fFMD1Pad->cd(); | |
245 | fFMD1.Begin(event); | |
246 | } | |
247 | if ((det = geom->GetDetector(2))) { | |
248 | fPad->cd(); | |
249 | fFMD2Pad = new TPad("FMD2", "FMD2", 0.5, 0.50, 1.0, 1.0, 0, 0); | |
250 | fFMD2Pad->Draw(); | |
251 | fFMD2Pad->cd(); | |
252 | fFMD2.Begin(event); | |
253 | } | |
254 | if ((det = geom->GetDetector(3))) { | |
255 | fPad->cd(); | |
256 | fFMD3Pad = new TPad("FMD3", "FMD3", 0.0, 0.05, .5, .5, 0, 0); | |
257 | fFMD3Pad->Draw(); | |
258 | fFMD3Pad->cd(); | |
259 | fFMD3.Begin(event); | |
260 | } | |
261 | fPad->cd(); | |
262 | fSummary = new TPad("display", "Display", 0.5, 0.05, 1.0, 0.5, 0, 0); | |
263 | fSummary->Draw(); | |
264 | fSummary->cd(); | |
265 | fEvent.Draw(); | |
266 | fFMD1IHits.Draw(); | |
267 | fFMD2IHits.Draw(); | |
268 | fFMD2OHits.Draw(); | |
269 | fFMD3IHits.Draw(); | |
270 | fFMD3OHits.Draw(); | |
271 | fLine.Draw(); | |
272 | fTotal.Draw(); | |
273 | } | |
274 | fEvent.SetTitle(Form("Event # %6d", event)); | |
275 | // fEvent.Modify(); | |
276 | fCanvas->Modified(); | |
277 | fCanvas->Update(); | |
278 | fCanvas->cd(); | |
279 | fFMD1.Clear(event); | |
280 | fFMD2.Clear(event); | |
281 | fFMD3.Clear(event); | |
282 | return AliFMDInput::Begin(event); | |
283 | } | |
284 | ||
285 | //____________________________________________________________________ | |
286 | void | |
287 | AliFMDFancy::Detector::End() | |
288 | { | |
289 | Char_t rs[] = { 'I', 'O', '\0' }; | |
290 | Char_t* rp = rs; | |
291 | Char_t r; | |
292 | while ((r = *(rp++))) { | |
293 | TGraph2D& g = (r == 'I' ? fInnerHits : fOuterHits); | |
294 | Int_t& n = (r == 'I' ? fNInnerHits : fNOuterHits); | |
295 | Int_t m = (r == 'I' ? 512 * 10 * 2 : 256 * 20 * 2); | |
296 | if (n == 0) continue; | |
297 | for (Int_t i = n; i < g.GetN(); i++) g.RemovePoint(i); | |
298 | std::cout << g.GetName() << " has " << std::setw(4) << n << "/" | |
299 | << std::setw(5) << m << " points" << std::endl; | |
300 | g.Draw("same fb p"); | |
301 | AddHistogram(g, "empty"); | |
302 | } | |
303 | } | |
304 | ||
305 | //____________________________________________________________________ | |
306 | Bool_t | |
307 | AliFMDFancy::End() | |
308 | { | |
309 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
310 | AliFMDDetector* det; | |
311 | Int_t total = 0; | |
312 | if ((det = geom->GetDetector(1))) { | |
313 | fFMD1Pad->cd(); | |
314 | fFMD1.End(); | |
315 | fFMD1Pad->Modified(); | |
316 | fFMD1IHits.SetTitle(Form("# hits in FMD1I: %5d", fFMD1.fNInnerHits)); | |
317 | total += fFMD1.fNInnerHits; | |
318 | } | |
319 | if ((det = geom->GetDetector(2))) { | |
320 | fFMD2Pad->cd(); | |
321 | fFMD2.End(); | |
322 | fFMD2Pad->Modified(); | |
323 | fFMD2IHits.SetTitle(Form("# hits in FMD2I: %5d", fFMD2.fNInnerHits)); | |
324 | fFMD2OHits.SetTitle(Form("# hits in FMD2O: %5d", fFMD2.fNOuterHits)); | |
325 | total += fFMD2.fNInnerHits; | |
326 | total += fFMD2.fNOuterHits; | |
327 | } | |
328 | if ((det = geom->GetDetector(3))) { | |
329 | fFMD3Pad->cd(); | |
330 | fFMD3.End(); | |
331 | fFMD3Pad->Modified(); | |
332 | fFMD3IHits.SetTitle(Form("# hits in FMD3I: %5d", fFMD3.fNInnerHits)); | |
333 | fFMD3OHits.SetTitle(Form("# hits in FMD3O: %5d", fFMD3.fNOuterHits)); | |
334 | total += fFMD3.fNInnerHits; | |
335 | total += fFMD3.fNOuterHits; | |
336 | } | |
337 | fTotal.SetTitle(Form("Total: %5d/51200 (%3d%%)", | |
338 | total, Int_t(100. / 51200 * total))); | |
339 | fSummary->Modified(); | |
340 | fCanvas->Modified(); | |
341 | fCanvas->Update(); | |
342 | fCanvas->cd(); | |
343 | fWait = kTRUE; | |
344 | while (fWait) { | |
345 | gApplication->StartIdleing(); | |
346 | gSystem->InnerLoop(); | |
347 | gApplication->StopIdleing(); | |
348 | } | |
349 | return AliFMDInput::End(); | |
350 | } | |
351 | ||
352 | //____________________________________________________________________ | |
353 | Bool_t | |
354 | AliFMDFancy::ProcessHit(AliFMDHit* hit, TParticle*) | |
355 | { | |
356 | AddMarker(hit->Detector(), hit->Ring(), hit->Sector(), hit->Strip(), | |
357 | hit, hit->Edep(), 0); | |
358 | return kTRUE; | |
359 | } | |
360 | //____________________________________________________________________ | |
361 | void | |
362 | AliFMDFancy::Detector::AddMarker(Char_t rng, UShort_t sec, UShort_t str, | |
363 | Float_t, Float_t) | |
364 | { | |
365 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
366 | Double_t x, y, z; | |
367 | geom->Detector2XYZ(fId, rng, sec, str, x, y, z); | |
368 | if (true) { | |
369 | AliFMDRing* r = geom->GetRing(rng); | |
370 | Double_t t = .9 * r->GetTheta() / 2; | |
371 | Double_t a = gRandom->Uniform(-t,t) * TMath::Pi() / 180; | |
372 | Double_t x1 = x * TMath::Cos(a) - y * TMath::Sin(a); | |
373 | Double_t y1 = x * TMath::Sin(a) + y * TMath::Cos(a); | |
374 | x = x1; | |
375 | y = y1; | |
376 | } | |
377 | switch (rng) { | |
378 | case 'I': | |
379 | case 'i': fInnerHits.SetPoint(fNInnerHits++, x, y, z); break; | |
380 | case 'O': | |
381 | case 'o': fOuterHits.SetPoint(fNOuterHits++, x, y, z); break; | |
382 | default: return; | |
383 | } | |
384 | } | |
385 | ||
386 | ||
387 | ||
388 | //____________________________________________________________________ | |
389 | void | |
390 | AliFMDFancy::AddMarker(UShort_t det, Char_t rng, UShort_t sec, UShort_t str, | |
391 | TObject*, Float_t, Float_t) | |
392 | { | |
393 | // Add a marker to the display | |
394 | // | |
395 | // det Detector | |
396 | // rng Ring | |
397 | // sec Sector | |
398 | // str Strip | |
399 | // o Object to refer to | |
400 | // s Signal | |
401 | // max Maximum of signal | |
402 | // | |
403 | switch (det) { | |
404 | case 1: fFMD1.AddMarker(rng,sec,str,0,0); break; | |
405 | case 2: fFMD2.AddMarker(rng,sec,str,0,0); break; | |
406 | case 3: fFMD3.AddMarker(rng,sec,str,0,0); break; | |
407 | } | |
408 | } | |
409 | ||
410 | //____________________________________________________________________ | |
411 | // | |
412 | // EOF | |
413 | // |