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>
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"
57 //____________________________________________________________________
60 ; // This is here to keep Emacs for indenting the next line
63 //____________________________________________________________________
64 AliFMDFancy::AliFMDFancy(const char* gAliceFile)
65 : AliFMDDisplay(kTRUE, gAliceFile),
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: ")
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::Detector::Detector(UShort_t id)
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);
105 //____________________________________________________________________
106 AliFMDFancy::Detector::~Detector()
109 if (fFrame) delete fFrame;
112 //____________________________________________________________________
113 AliFMDFancy::~AliFMDFancy()
116 //____________________________________________________________________
118 AliFMDFancy::Detector::AddHistogram(TGraph2D& g, const char* opt)
120 TH2* h = g.GetHistogram(opt);
122 h->SetBins(1, -fMaxR, fMaxR, 1, -fMaxR, fMaxR);
123 h->GetZaxis()->SetRangeUser(fMinZ, fMaxZ);
128 //____________________________________________________________________
130 AliFMDFancy::Detector::Init()
132 AliFMDGeometry* geom = AliFMDGeometry::Instance();
133 AliFMDDetector* det = geom->GetDetector(fId);
135 Char_t rs[] = { 'I' , 'O', '\0' };
139 Double_t minZ = 10000;
140 Double_t maxZ = -10000;
142 while ((r = *(rp++))) {
143 AliFMDRing* ring = det->GetRing(r);
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());
167 //g->SetPoint(nv, x0, y0, z0);
169 g->SetFillStyle(3002);
175 fMinZ = (minZ > 0 ? 0.95 * minZ : 1.05 * minZ);
176 fMaxZ = (maxZ > 0 ? 1.05 * maxZ : 0.95 * maxZ);
178 TIter next(&fShapes);
180 while ((g = static_cast<TGraph2D*>(next()))) AddHistogram(*g);
181 if (det->GetInner()) AddHistogram(fInnerHits);
182 if (det->GetOuter()) AddHistogram(fOuterHits);
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);
194 //____________________________________________________________________
198 // Initialize. GEt transforms and such,
199 if (!AliFMDInput::Init()) return kFALSE;
200 AliFMDGeometry* geom = AliFMDGeometry::Instance();
202 geom->InitTransformations();
210 //____________________________________________________________________
212 AliFMDFancy::Detector::Begin(Int_t /* event */)
214 TIter next(&fShapes);
216 fFrame->Draw("surf fb");
217 fFrame->GetZaxis()->SetRangeUser(fMinZ, fMaxZ);
218 while ((g = static_cast<TGraph2D*>(next()))) g->Draw("tri2 FB same");
221 //____________________________________________________________________
223 AliFMDFancy::Detector::Clear(Int_t /* event */)
230 //____________________________________________________________________
232 AliFMDFancy::Begin(Int_t event)
235 const char* which[] = { "Continue", "Redisplay", 0 };
238 AliFMDGeometry* geom = AliFMDGeometry::Instance();
240 if ((det = geom->GetDetector(1))) {
242 fFMD1Pad = new TPad("FMD1", "FMD1", 0.0, 0.50, 0.5, 1.0, 0, 0);
247 if ((det = geom->GetDetector(2))) {
249 fFMD2Pad = new TPad("FMD2", "FMD2", 0.5, 0.50, 1.0, 1.0, 0, 0);
254 if ((det = geom->GetDetector(3))) {
256 fFMD3Pad = new TPad("FMD3", "FMD3", 0.0, 0.05, .5, .5, 0, 0);
262 fSummary = new TPad("display", "Display", 0.5, 0.05, 1.0, 0.5, 0, 0);
274 fEvent.SetTitle(Form("Event # %6d", event));
282 return AliFMDInput::Begin(event);
285 //____________________________________________________________________
287 AliFMDFancy::Detector::End()
289 Char_t rs[] = { 'I', 'O', '\0' };
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;
301 AddHistogram(g, "empty");
305 //____________________________________________________________________
309 AliFMDGeometry* geom = AliFMDGeometry::Instance();
312 if ((det = geom->GetDetector(1))) {
315 fFMD1Pad->Modified();
316 fFMD1IHits.SetTitle(Form("# hits in FMD1I: %5d", fFMD1.fNInnerHits));
317 total += fFMD1.fNInnerHits;
319 if ((det = geom->GetDetector(2))) {
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;
328 if ((det = geom->GetDetector(3))) {
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;
337 fTotal.SetTitle(Form("Total: %5d/51200 (%3d%%)",
338 total, Int_t(100. / 51200 * total)));
339 fSummary->Modified();
345 gApplication->StartIdleing();
346 gSystem->InnerLoop();
347 gApplication->StopIdleing();
349 return AliFMDInput::End();
352 //____________________________________________________________________
354 AliFMDFancy::ProcessHit(AliFMDHit* hit, TParticle*)
356 AddMarker(hit->Detector(), hit->Ring(), hit->Sector(), hit->Strip(),
357 hit, hit->Edep(), 0);
360 //____________________________________________________________________
362 AliFMDFancy::Detector::AddMarker(Char_t rng, UShort_t sec, UShort_t str,
365 AliFMDGeometry* geom = AliFMDGeometry::Instance();
367 geom->Detector2XYZ(fId, rng, sec, str, x, y, z);
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);
379 case 'i': fInnerHits.SetPoint(fNInnerHits++, x, y, z); break;
381 case 'o': fOuterHits.SetPoint(fNOuterHits++, x, y, z); break;
388 //____________________________________________________________________
390 AliFMDFancy::AddMarker(UShort_t det, Char_t rng, UShort_t sec, UShort_t str,
391 TObject*, Float_t, Float_t)
393 // Add a marker to the display
399 // o Object to refer to
401 // max Maximum of signal
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;
410 //____________________________________________________________________