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
31 #include "AliFMDFancy.h" // ALIFMDDISPLAY_H
32 #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
33 #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
36 #include <TApplication.h>
44 #include "AliFMDRing.h"
45 #include "AliFMDDetector.h"
46 #include "AliFMDHit.h"
53 //____________________________________________________________________
56 ; // This is here to keep Emacs for indenting the next line
59 //____________________________________________________________________
60 AliFMDFancy::AliFMDFancy(const char* gAliceFile)
61 : AliFMDDisplay(kTRUE, gAliceFile),
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: ")
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);
87 //____________________________________________________________________
88 AliFMDFancy::Detector::Detector(UShort_t id)
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);
101 //____________________________________________________________________
102 AliFMDFancy::Detector::~Detector()
105 if (fFrame) delete fFrame;
108 //____________________________________________________________________
109 AliFMDFancy::~AliFMDFancy()
112 //____________________________________________________________________
114 AliFMDFancy::Detector::AddHistogram(TGraph2D& g, const char* opt)
116 TH2* h = g.GetHistogram(opt);
118 h->SetBins(1, -fMaxR, fMaxR, 1, -fMaxR, fMaxR);
119 h->GetZaxis()->SetRangeUser(fMinZ, fMaxZ);
124 //____________________________________________________________________
126 AliFMDFancy::Detector::Init()
128 AliFMDGeometry* geom = AliFMDGeometry::Instance();
129 AliFMDDetector* det = geom->GetDetector(fId);
131 Char_t rs[] = { 'I' , 'O', '\0' };
135 Double_t minZ = 10000;
136 Double_t maxZ = -10000;
138 while ((r = *(rp++))) {
139 AliFMDRing* ring = det->GetRing(r);
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());
163 //g->SetPoint(nv, x0, y0, z0);
165 g->SetFillStyle(3002);
171 fMinZ = (minZ > 0 ? 0.95 * minZ : 1.05 * minZ);
172 fMaxZ = (maxZ > 0 ? 1.05 * maxZ : 0.95 * maxZ);
174 TIter next(&fShapes);
176 while ((g = static_cast<TGraph2D*>(next()))) AddHistogram(*g);
177 if (det->GetInner()) AddHistogram(fInnerHits);
178 if (det->GetOuter()) AddHistogram(fOuterHits);
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);
190 //____________________________________________________________________
194 // Initialize. GEt transforms and such,
195 if (!AliFMDInput::Init()) return kFALSE;
196 AliFMDGeometry* geom = AliFMDGeometry::Instance();
198 geom->InitTransformations();
206 //____________________________________________________________________
208 AliFMDFancy::Detector::Begin(Int_t /* event */)
210 TIter next(&fShapes);
212 fFrame->Draw("surf fb");
213 fFrame->GetZaxis()->SetRangeUser(fMinZ, fMaxZ);
214 while ((g = static_cast<TGraph2D*>(next()))) g->Draw("tri2 FB same");
217 //____________________________________________________________________
219 AliFMDFancy::Detector::Clear(Int_t /* event */)
226 //____________________________________________________________________
228 AliFMDFancy::Begin(Int_t event)
231 const char* which[] = { "Continue", "Redisplay", 0 };
234 AliFMDGeometry* geom = AliFMDGeometry::Instance();
236 if ((det = geom->GetDetector(1))) {
238 fFMD1Pad = new TPad("FMD1", "FMD1", 0.0, 0.50, 0.5, 1.0, 0, 0);
243 if ((det = geom->GetDetector(2))) {
245 fFMD2Pad = new TPad("FMD2", "FMD2", 0.5, 0.50, 1.0, 1.0, 0, 0);
250 if ((det = geom->GetDetector(3))) {
252 fFMD3Pad = new TPad("FMD3", "FMD3", 0.0, 0.05, .5, .5, 0, 0);
258 fSummary = new TPad("display", "Display", 0.5, 0.05, 1.0, 0.5, 0, 0);
270 fEvent.SetTitle(Form("Event # %6d", event));
278 return AliFMDInput::Begin(event);
281 //____________________________________________________________________
283 AliFMDFancy::Detector::End()
285 Char_t rs[] = { 'I', 'O', '\0' };
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;
297 AddHistogram(g, "empty");
301 //____________________________________________________________________
305 AliFMDGeometry* geom = AliFMDGeometry::Instance();
308 if ((det = geom->GetDetector(1))) {
311 fFMD1Pad->Modified();
312 fFMD1IHits.SetTitle(Form("# hits in FMD1I: %5d", fFMD1.fNInnerHits));
313 total += fFMD1.fNInnerHits;
315 if ((det = geom->GetDetector(2))) {
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;
324 if ((det = geom->GetDetector(3))) {
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;
333 fTotal.SetTitle(Form("Total: %5d/51200 (%3d%%)",
334 total, Int_t(100. / 51200 * total)));
335 fSummary->Modified();
341 gApplication->StartIdleing();
342 gSystem->InnerLoop();
343 gApplication->StopIdleing();
345 return AliFMDInput::End();
348 //____________________________________________________________________
350 AliFMDFancy::ProcessHit(AliFMDHit* hit, TParticle*)
352 AddMarker(hit->Detector(), hit->Ring(), hit->Sector(), hit->Strip(),
353 hit, hit->Edep(), 0);
356 //____________________________________________________________________
358 AliFMDFancy::Detector::AddMarker(Char_t rng, UShort_t sec, UShort_t str,
361 AliFMDGeometry* geom = AliFMDGeometry::Instance();
363 geom->Detector2XYZ(fId, rng, sec, str, x, y, z);
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);
375 case 'i': fInnerHits.SetPoint(fNInnerHits++, x, y, z); break;
377 case 'o': fOuterHits.SetPoint(fNOuterHits++, x, y, z); break;
384 //____________________________________________________________________
386 AliFMDFancy::AddMarker(UShort_t det, Char_t rng, UShort_t sec, UShort_t str,
387 TObject*, Float_t, Float_t)
389 // Add a marker to the display
395 // o Object to refer to
397 // max Maximum of signal
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;
406 //____________________________________________________________________