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