1 /**************************************************************************
2 * Copyright(c) 2004, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
21 //___________________________________________________________________
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.
29 // Latest changes by Christian Holm Christensen
35 #include <TApplication.h>
36 // #include <TButton.h>
44 // #include <TStyle.h>
49 #include "AliFMDDetector.h"
50 #include "AliFMDFancy.h" // ALIFMDDISPLAY_H
51 #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
52 #include "AliFMDHit.h"
53 // #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
54 #include "AliFMDRing.h"
56 //____________________________________________________________________
59 ; // This is here to keep Emacs for indenting the next line
62 //____________________________________________________________________
63 AliFMDFancy::AliFMDFancy(const char* gAliceFile)
64 : AliFMDDisplay(kTRUE, gAliceFile),
71 fEvent(.1, .8, "Event #"),
72 fFMD1IHits(.2, .7, "# in FMD1I: "),
73 fFMD2IHits(.2, .6, "# in FMD2I: "),
74 fFMD2OHits(.2, .5, "# in FMD2O: "),
75 fFMD3IHits(.2, .4, "# in FMD3I: "),
76 fFMD3OHits(.2, .3, "# in FMD3O: "),
77 fLine(.15, .27, .85, .27),
78 fTotal(.2, .15, "Total: ")
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);
91 //____________________________________________________________________
92 AliFMDFancy::AliFancyDetector::AliFancyDetector(UShort_t id)
96 fInnerHits.SetName(Form("FMD%dI", id));
97 fInnerHits.SetMarkerStyle(1); // 20);
98 fInnerHits.SetMarkerSize(.2);
99 fInnerHits.SetMarkerColor(50); // 12);
100 fOuterHits.SetName(Form("FMD%dO", id));
101 fOuterHits.SetMarkerStyle(1); // 20);
102 fOuterHits.SetMarkerSize(.2);
103 fOuterHits.SetMarkerColor(50); // 12);
106 //____________________________________________________________________
107 AliFMDFancy::AliFancyDetector::~AliFancyDetector()
111 if (fFrame) delete fFrame;
114 //____________________________________________________________________
115 AliFMDFancy::~AliFMDFancy()
120 //____________________________________________________________________
122 AliFMDFancy::AliFancyDetector::AddHistogram(TGraph2D& g, const char* opt)
125 TH2* h = g.GetHistogram(opt);
127 // Code checker doesn't think this using the TH2 interface -
129 h->SetBins(1, -fMaxR, fMaxR, 1, -fMaxR, fMaxR);
130 h->GetZaxis()->SetRangeUser(fMinZ, fMaxZ);
135 //____________________________________________________________________
137 AliFMDFancy::AliFancyDetector::Init()
140 AliFMDGeometry* geom = AliFMDGeometry::Instance();
141 AliFMDDetector* det = geom->GetDetector(fId);
143 Char_t rs[] = { 'I' , 'O', '\0' };
147 Double_t minZ = 10000;
148 Double_t maxZ = -10000;
150 while ((r = *(rp++))) {
151 AliFMDRing* ring = det->GetRing(r);
153 // if (r == 'O') continue;
154 const TObjArray& vs = ring->GetVerticies();
155 Int_t nm = ring->GetNModules();
156 Double_t zd = (r == 'I' ? det->GetInnerZ() : det->GetOuterZ());
157 for (Int_t m = 0; m < nm; m++) {
158 Int_t nv = vs.GetEntries();
159 Double_t a = TMath::Pi() / 180 * (m * 2 + 1) * ring->GetTheta();
160 TGraph2D* g = new TGraph2D(nv);
161 Double_t x0 = 0, y0 = 0, z0 = 0;
162 Double_t z = zd + (m % 2==0 ? 0 :
163 TMath::Sign(ring->GetModuleSpacing(), zd));
164 minZ = TMath::Min(minZ, z);
165 maxZ = TMath::Max(maxZ, z);
166 g->SetName(Form("FMD%d%cM%02d", fId, r, m));
167 fShapes.AddAtAndExpand(g, ns++);
168 for (Int_t c = 0; c < nv; c++) {
169 TVector2* v = static_cast<TVector2*>(vs.At(nv - 1 - c));
170 TVector2 w(v->Rotate(a));
171 if (c == 0) { x0 = w.X(); y0 = w.Y(); z0 = z; }
172 g->SetPoint(c, w.X(), w.Y(), z);
173 maxR = TMath::Max(maxR, v->Mod());
175 //g->SetPoint(nv, x0, y0, z0);
177 g->SetFillStyle(3002);
183 fMinZ = (minZ > 0 ? 0.95 * minZ : 1.05 * minZ);
184 fMaxZ = (maxZ > 0 ? 1.05 * maxZ : 0.95 * maxZ);
186 TIter next(&fShapes);
188 while ((g = static_cast<TGraph2D*>(next()))) AddHistogram(*g);
189 if (det->GetInner()) AddHistogram(fInnerHits);
190 if (det->GetOuter()) AddHistogram(fOuterHits);
192 fFrame = new TH2F(Form("FMD%d", fId), Form("FMD%d", fId),
193 1, -fMaxR, fMaxR, 1, -fMaxR, fMaxR);
194 fFrame->SetStats(kFALSE);
195 fFrame->GetXaxis()->SetTitle("x [cm]");
196 fFrame->GetYaxis()->SetTitle("y [cm]");
197 fFrame->GetZaxis()->SetTitle("z [cm]");
198 fFrame->SetDirectory(0);
202 //____________________________________________________________________
206 // Initialize. GEt transforms and such,
207 if (!AliFMDInput::Init()) return kFALSE;
208 AliFMDGeometry* geom = AliFMDGeometry::Instance();
210 geom->InitTransformations();
218 //____________________________________________________________________
220 AliFMDFancy::AliFancyDetector::Begin(Int_t /* event */)
222 // Called at the begining of an event.
223 TIter next(&fShapes);
225 fFrame->Draw("surf fb");
226 fFrame->GetZaxis()->SetRangeUser(fMinZ, fMaxZ);
227 while ((g = static_cast<TGraph2D*>(next()))) g->Draw("tri2 FB same");
230 //____________________________________________________________________
232 AliFMDFancy::AliFancyDetector::Clear(Int_t /* event */)
240 //____________________________________________________________________
242 AliFMDFancy::Begin(Int_t event)
244 // Called at the begining of an event
246 const char* which[] = { "Continue", "Redisplay", 0 };
249 AliFMDGeometry* geom = AliFMDGeometry::Instance();
251 if ((det = geom->GetDetector(1))) {
253 fFMD1Pad = new TPad("FMD1", "FMD1", 0.0, 0.50, 0.5, 1.0, 0, 0);
258 if ((det = geom->GetDetector(2))) {
260 fFMD2Pad = new TPad("FMD2", "FMD2", 0.5, 0.50, 1.0, 1.0, 0, 0);
265 if ((det = geom->GetDetector(3))) {
267 fFMD3Pad = new TPad("FMD3", "FMD3", 0.0, 0.05, .5, .5, 0, 0);
273 fSummary = new TPad("display", "Display", 0.5, 0.05, 1.0, 0.5, 0, 0);
285 fEvent.SetTitle(Form("Event # %6d", event));
293 return AliFMDInput::Begin(event);
296 //____________________________________________________________________
298 AliFMDFancy::AliFancyDetector::End()
300 // Called at the end of an event
301 Char_t rs[] = { 'I', 'O', '\0' };
304 while ((r = *(rp++))) {
305 TGraph2D& g = (r == 'I' ? fInnerHits : fOuterHits);
306 Int_t& n = (r == 'I' ? fNInnerHits : fNOuterHits);
307 Int_t m = (r == 'I' ? 512 * 10 * 2 : 256 * 20 * 2);
308 if (n == 0) continue;
309 for (Int_t i = n; i < g.GetN(); i++) g.RemovePoint(i);
310 // The code checker thinks this is not using declarations from
311 // iostram and iomanip - that's just silly.
312 std::cout << g.GetName() << " has " << std::setw(4) << n << "/"
313 << std::setw(5) << m << " points" << std::endl;
315 AddHistogram(g, "empty");
319 //____________________________________________________________________
323 // Called at the end of an event
324 AliFMDGeometry* geom = AliFMDGeometry::Instance();
327 if ((det = geom->GetDetector(1))) {
330 fFMD1Pad->Modified();
331 fFMD1IHits.SetTitle(Form("# hits in FMD1I: %5d", fFMD1.fNInnerHits));
332 total += fFMD1.fNInnerHits;
334 if ((det = geom->GetDetector(2))) {
337 fFMD2Pad->Modified();
338 fFMD2IHits.SetTitle(Form("# hits in FMD2I: %5d", fFMD2.fNInnerHits));
339 fFMD2OHits.SetTitle(Form("# hits in FMD2O: %5d", fFMD2.fNOuterHits));
340 total += fFMD2.fNInnerHits;
341 total += fFMD2.fNOuterHits;
343 if ((det = geom->GetDetector(3))) {
346 fFMD3Pad->Modified();
347 fFMD3IHits.SetTitle(Form("# hits in FMD3I: %5d", fFMD3.fNInnerHits));
348 fFMD3OHits.SetTitle(Form("# hits in FMD3O: %5d", fFMD3.fNOuterHits));
349 total += fFMD3.fNInnerHits;
350 total += fFMD3.fNOuterHits;
352 fTotal.SetTitle(Form("Total: %5d/51200 (%3d%%)",
353 total, Int_t(100. / 51200 * total)));
354 fSummary->Modified();
360 // Hmm - code checker doesn't believe this is using the
361 // TApplication or TSystem declaration - morron. Thank God for
362 // optimising compilers.
363 TApplication* a = gApplication;
364 TSystem* s = gSystem;
369 return AliFMDInput::End();
372 //____________________________________________________________________
374 AliFMDFancy::ProcessHit(AliFMDHit* hit, TParticle*)
377 AddMarker(hit->Detector(), hit->Ring(), hit->Sector(), hit->Strip(),
378 hit, hit->Edep(), 0);
381 //____________________________________________________________________
383 AliFMDFancy::AliFancyDetector::AddMarker(Char_t rng, UShort_t sec,
384 UShort_t str, Float_t, Float_t)
386 // Add a marker to the display
387 AliFMDGeometry* geom = AliFMDGeometry::Instance();
389 geom->Detector2XYZ(fId, rng, sec, str, x, y, z);
390 // Trick the code-checker to think that we're using the TRandom
391 // interface. The silly code checker also thinks that TMath is a
392 // class and not a namespace - sigh!
393 TRandom* rand = gRandom;
395 AliFMDRing* r = geom->GetRing(rng);
396 Double_t t = .9 * r->GetTheta() / 2;
397 Double_t a = rand->Uniform(-t,t) * TMath::Pi() / 180;
398 Double_t x1 = x * TMath::Cos(a) - y * TMath::Sin(a);
399 Double_t y1 = x * TMath::Sin(a) + y * TMath::Cos(a);
405 case 'i': fInnerHits.SetPoint(fNInnerHits++, x, y, z); break;
407 case 'o': fOuterHits.SetPoint(fNOuterHits++, x, y, z); break;
414 //____________________________________________________________________
416 AliFMDFancy::AddMarker(UShort_t det, Char_t rng, UShort_t sec, UShort_t str,
417 TObject*, Float_t, Float_t)
419 // Add a marker to the display
425 // o Object to refer to
427 // max Maximum of signal
430 case 1: fFMD1.AddMarker(rng,sec,str,0,0); break;
431 case 2: fFMD2.AddMarker(rng,sec,str,0,0); break;
432 case 3: fFMD3.AddMarker(rng,sec,str,0,0); break;
436 //____________________________________________________________________