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 AliFMDPattern.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 "AliFMDPattern.h" // ALIFMDDISPLAY_H
32 #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
33 #include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
34 #include "AliFMDRing.h"
35 #include "AliFMDDetector.h"
36 #include "AliFMDHit.h"
39 #include <TApplication.h>
51 //____________________________________________________________________
52 ClassImp(AliFMDPattern)
54 ; // This is here to keep Emacs for indenting the next line
57 //____________________________________________________________________
58 AliFMDPattern::Detector::Detector(UShort_t id)
65 //____________________________________________________________________
66 AliFMDPattern::Detector::~Detector()
68 if (fFrame) delete fFrame;
71 //____________________________________________________________________
73 AliFMDPattern::Detector::DrawShape(TObjArray& a)
77 while ((g = static_cast<TGraph*>(next()))) {
78 g->DrawClone("f same");
79 g->DrawClone("l same");
83 //____________________________________________________________________
85 AliFMDPattern::Detector::Begin(Int_t nlevel, Double_t r,
86 TObjArray& inners, TObjArray& outers)
90 fFrame = new TH2F(Form("fmd%dFrame", fId), Form("FMD%d", fId),
91 10, -r, r, 10, -r, r);
92 fFrame->SetStats(kFALSE);
96 if (fId != 1) DrawShape(outers);
97 for (Int_t i = 0; i < nlevel; i++) {
98 TGraph* g = new TGraph;
99 Int_t idx = Int_t(Float_t(i) / nlevel * gStyle->GetNumberOfColors());
100 Int_t col = gStyle->GetColorPalette(idx);
101 g->SetName(Form("FMD%d_L%02d", fId, i));
102 g->SetMarkerColor(col);
103 g->SetLineColor(col);
104 g->SetFillColor(col);
105 g->SetMarkerSize(i * .2 + .2);
106 g->SetMarkerStyle(2);
108 fGraphs.AddAtAndExpand(g, i);
110 TIter next(&fGraphs);
113 //____________________________________________________________________
115 AliFMDPattern::Detector::Clear()
120 //____________________________________________________________________
122 AliFMDPattern::Detector::End()
124 TIter next(&fGraphs);
127 while ((g = static_cast<TGraph*>(next()))) g->Set(fCounts[i++]);
129 //____________________________________________________________________
131 AliFMDPattern::Detector::AddMarker(Double_t x, Double_t y, Float_t s,
134 Int_t i = TMath::Min(Int_t(fCounts.fN * s / max),
135 Int_t(fGraphs.GetEntries()-1));
136 TGraph* g = static_cast<TGraph*>(fGraphs.At(i));
138 g->SetPoint(fCounts[i]++, x, y);
142 //____________________________________________________________________
143 AliFMDPattern::AliFMDPattern(const char* gAliceFile)
144 : AliFMDDisplay(kTRUE, gAliceFile),
153 fEvent(.1, .8, "Event #"),
154 fFMD1Sum(.2, .7, "# in FMD1: "),
155 fFMD2Sum(.2, .6, "# in FMD2: "),
156 fFMD3Sum(.2, .5, "# in FMD3: "),
157 fLine(.15, .47, .85, .47),
158 fTotal(.2, .35, "Total: ")
160 // RemoveLoad(kGeometry);
161 fEvent.SetBit(TLatex::kTextNDC);
162 fFMD1Sum.SetBit(TLatex::kTextNDC);
163 fFMD2Sum.SetBit(TLatex::kTextNDC);
164 fFMD3Sum.SetBit(TLatex::kTextNDC);
165 fLine.SetBit(TLine::kLineNDC);
166 fTotal.SetBit(TLatex::kTextNDC);
169 //____________________________________________________________________
170 AliFMDPattern::~AliFMDPattern()
177 //____________________________________________________________________
179 AliFMDPattern::Init()
181 // Initialize. GEt transforms and such,
182 if (!AliFMDInput::Init()) return kFALSE;
183 AliFMDGeometry* geom = AliFMDGeometry::Instance();
185 geom->InitTransformations();
187 Char_t rs[] = { 'I' , 'O', '\0' };
190 AliFMDRing* ring = geom->GetRing(*r);
192 const TObjArray& vs = ring->GetVerticies();
193 TObjArray& gs = (*r == 'I' ? fInners : fOuters);
194 Float_t& mr = (*r == 'I' ? fInnerMax : fOuterMax);
195 Int_t nm = ring->GetNModules();
196 AliInfo(Form("Making %d modules for %c", nm, *r));
197 for (Int_t m = 0; m < nm; m++) {
198 Int_t nv = vs.GetEntries();
199 Double_t a = TMath::Pi() / 180 * (m * 2 + 1) * ring->GetTheta();
200 TGraph* g = new TGraph(nv+1);
201 Double_t x0 = 0, y0 = 0;
202 gs.AddAtAndExpand(g, m);
203 for (Int_t c = 0; c < nv; c++) {
204 TVector2* v = static_cast<TVector2*>(vs.At(c));
205 mr = TMath::Max(mr, Float_t(v->Mod()));
206 TVector2 w(v->Rotate(a));
207 if (c == 0) { x0 = w.X(); y0 = w.Y(); }
208 g->SetPoint(c, w.X(), w.Y());
210 g->SetName(Form("FMDX%c_%02d", *r, m));
211 g->SetPoint(nv, x0, y0);
212 g->SetFillColor((*rs == 'I' ?
213 (m % 2 == 0 ? 18 : 17) :
214 (m % 2 == 0 ? 20 : 23)));
215 g->SetFillStyle(3001);
225 //____________________________________________________________________
227 AliFMDPattern::Begin(Int_t event)
230 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);
241 fFMD1.Begin(10, fInnerMax, fInners, fOuters);
243 if ((det = geom->GetDetector(2))) {
245 fFMD2Pad = new TPad("FMD2", "FMD2", 0.5, 0.50, 1.0, 1.0, 0, 0);
248 fFMD2.Begin(10, fOuterMax, fInners, fOuters);
250 if ((det = geom->GetDetector(3))) {
252 fFMD3Pad = new TPad("FMD3", "FMD3", 0.0, 0.0, .5, .5, 0, 0);
255 fFMD3.Begin(10, fOuterMax, fInners, fOuters);
258 fSummary = new TPad("display", "Display", 0.5, 0.0, 1.0, 0.5, 0, 0);
268 fEvent.SetTitle(Form("Event # %6d", event));
276 return AliFMDInput::Begin(event);
279 //____________________________________________________________________
281 AliFMDPattern::Redisplay()
286 AliFMDDisplay::Redisplay();
289 //____________________________________________________________________
291 AliFMDPattern::AtEnd()
298 fFMD1Pad->Modified();
299 fFMD1Sum.SetTitle(Form("# hits in FMD1: %5d", fFMD1.Total()));
300 total += fFMD1.Total();
303 fFMD2Pad->Modified();
304 fFMD2Sum.SetTitle(Form("# hits in FMD2: %5d", fFMD2.Total()));
305 total += fFMD2.Total();
308 fFMD3Pad->Modified();
309 fFMD3Sum.SetTitle(Form("# hits in FMD3: %5d", fFMD3.Total()));
310 total += fFMD3.Total();
312 fTotal.SetTitle(Form("Total: %5d/51200 (%3d%%)",
313 total, Int_t(100. / 51200 * total)));
314 fSummary->Modified();
320 //____________________________________________________________________
322 AliFMDPattern::ProcessHit(AliFMDHit* hit, TParticle*)
324 switch (hit->Detector()) {
325 case 1: fFMD1.AddMarker(hit->X(), hit->Y(), hit->Edep(), 1); break;
326 case 2: fFMD2.AddMarker(hit->X(), hit->Y(), hit->Edep(), 1); break;
327 case 3: fFMD3.AddMarker(hit->X(), hit->Y(), hit->Edep(), 1); break;
333 //____________________________________________________________________
335 AliFMDPattern::AddMarker(UShort_t det, Char_t rng, UShort_t sec, UShort_t str,
336 TObject*, Float_t s, Float_t max)
338 // Add a marker to the display
344 // o Object to refer to
346 // max Maximum of signal
350 case 1: d = &fFMD1; break;
351 case 2: d = &fFMD2; break;
352 case 3: d = &fFMD3; break;
355 AliFMDGeometry* geom = AliFMDGeometry::Instance();
357 geom->Detector2XYZ(det, rng, sec, str, x, y, z);
359 AliFMDRing* r = geom->GetRing(rng);
360 Double_t t = .9 * r->GetTheta() / 2;
361 Double_t a = gRandom->Uniform(-t,t) * TMath::Pi() / 180;
362 Double_t x1 = x * TMath::Cos(a) - y * TMath::Sin(a);
363 Double_t y1 = x * TMath::Sin(a) + y * TMath::Cos(a);
367 d->AddMarker(x, y, s, max);
370 //____________________________________________________________________