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)
88 if (nlevel < 1) nlevel = gStyle->GetNumberOfColors();
91 fFrame = new TH2F(Form("fmd%dFrame", fId), Form("FMD%d", fId),
92 10, -r, r, 10, -r, r);
93 fFrame->SetStats(kFALSE);
97 if (fId != 1) DrawShape(outers);
98 for (Int_t i = 0; i < nlevel; i++) {
99 TGraph* g = new TGraph;
100 Int_t idx = Int_t(Float_t(i) / nlevel * gStyle->GetNumberOfColors());
101 Int_t col = gStyle->GetColorPalette(idx);
102 g->SetName(Form("FMD%d_L%02d", fId, i));
103 g->SetMarkerColor(col);
104 g->SetLineColor(col);
105 g->SetFillColor(col);
106 g->SetMarkerSize(i * .2 + .2);
107 g->SetMarkerStyle(2);
109 fGraphs.AddAtAndExpand(g, i);
111 TIter next(&fGraphs);
114 //____________________________________________________________________
116 AliFMDPattern::Detector::Clear()
121 //____________________________________________________________________
123 AliFMDPattern::Detector::End()
125 TIter next(&fGraphs);
128 while ((g = static_cast<TGraph*>(next()))) g->Set(fCounts[i++]);
130 //____________________________________________________________________
132 AliFMDPattern::Detector::AddMarker(Double_t x, Double_t y, Float_t s,
135 Int_t i = TMath::Min(Int_t(fCounts.fN * s / max),
136 Int_t(fGraphs.GetEntries()-1));
137 TGraph* g = static_cast<TGraph*>(fGraphs.At(i));
139 g->SetPoint(fCounts[i]++, x, y);
143 //____________________________________________________________________
144 AliFMDPattern::AliFMDPattern(const char* gAliceFile)
145 : AliFMDDisplay(kTRUE, gAliceFile),
154 fEvent(.1, .8, "Event #"),
155 fFMD1Sum(.2, .7, "# in FMD1: "),
156 fFMD2Sum(.2, .6, "# in FMD2: "),
157 fFMD3Sum(.2, .5, "# in FMD3: "),
158 fLine(.15, .47, .85, .47),
159 fTotal(.2, .35, "Total: ")
161 // RemoveLoad(kGeometry);
162 fEvent.SetBit(TLatex::kTextNDC);
163 fFMD1Sum.SetBit(TLatex::kTextNDC);
164 fFMD2Sum.SetBit(TLatex::kTextNDC);
165 fFMD3Sum.SetBit(TLatex::kTextNDC);
166 fLine.SetBit(TLine::kLineNDC);
167 fTotal.SetBit(TLatex::kTextNDC);
170 //____________________________________________________________________
171 AliFMDPattern::~AliFMDPattern()
178 //____________________________________________________________________
180 AliFMDPattern::Init()
182 // Initialize. GEt transforms and such,
183 if (!AliFMDInput::Init()) return kFALSE;
184 AliFMDGeometry* geom = AliFMDGeometry::Instance();
186 geom->InitTransformations();
188 Char_t rs[] = { 'I' , 'O', '\0' };
191 AliFMDRing* ring = geom->GetRing(*r);
193 const TObjArray& vs = ring->GetVerticies();
194 TObjArray& gs = (*r == 'I' ? fInners : fOuters);
195 Float_t& mr = (*r == 'I' ? fInnerMax : fOuterMax);
196 Int_t nm = ring->GetNModules();
197 AliInfo(Form("Making %d modules for %c", nm, *r));
198 for (Int_t m = 0; m < nm; m++) {
199 Int_t nv = vs.GetEntries();
200 Double_t a = TMath::Pi() / 180 * (m * 2 + 1) * ring->GetTheta();
201 TGraph* g = new TGraph(nv+1);
202 Double_t x0 = 0, y0 = 0;
203 gs.AddAtAndExpand(g, m);
204 for (Int_t c = 0; c < nv; c++) {
205 TVector2* v = static_cast<TVector2*>(vs.At(c));
206 mr = TMath::Max(mr, Float_t(v->Mod()));
207 TVector2 w(v->Rotate(a));
208 if (c == 0) { x0 = w.X(); y0 = w.Y(); }
209 g->SetPoint(c, w.X(), w.Y());
211 g->SetName(Form("FMDX%c_%02d", *r, m));
212 g->SetPoint(nv, x0, y0);
213 g->SetFillColor((*rs == 'I' ?
214 (m % 2 == 0 ? 18 : 17) :
215 (m % 2 == 0 ? 20 : 23)));
216 g->SetFillStyle(3001);
226 //____________________________________________________________________
228 AliFMDPattern::Begin(Int_t event)
232 const char* which[] = { "Continue", "Redisplay", 0 };
235 AliFMDGeometry* geom = AliFMDGeometry::Instance();
237 if ((det = geom->GetDetector(1))) {
239 fFMD1Pad = new TPad("FMD1", "FMD1", 0.0, 0.50, 0.5, 1.0, 0, 0);
242 fFMD1.Begin(-1, fInnerMax, fInners, fOuters);
244 if ((det = geom->GetDetector(2))) {
246 fFMD2Pad = new TPad("FMD2", "FMD2", 0.5, 0.50, 1.0, 1.0, 0, 0);
249 fFMD2.Begin(-1, fOuterMax, fInners, fOuters);
251 if ((det = geom->GetDetector(3))) {
253 fFMD3Pad = new TPad("FMD3", "FMD3", 0.0, 0.0, .5, .5, 0, 0);
256 fFMD3.Begin(-1, fOuterMax, fInners, fOuters);
259 fSummary = new TPad("display", "Display", 0.5, 0.0, 1.0, 0.5, 0, 0);
269 fEvent.SetTitle(Form("Event # %6d", event));
277 return AliFMDInput::Begin(event);
280 //____________________________________________________________________
282 AliFMDPattern::Redisplay()
287 AliFMDDisplay::Redisplay();
290 //____________________________________________________________________
292 AliFMDPattern::AtEnd()
299 fFMD1Pad->Modified();
300 fFMD1Sum.SetTitle(Form("# hits in FMD1: %5d", fFMD1.Total()));
301 total += fFMD1.Total();
304 fFMD2Pad->Modified();
305 fFMD2Sum.SetTitle(Form("# hits in FMD2: %5d", fFMD2.Total()));
306 total += fFMD2.Total();
309 fFMD3Pad->Modified();
310 fFMD3Sum.SetTitle(Form("# hits in FMD3: %5d", fFMD3.Total()));
311 total += fFMD3.Total();
313 fTotal.SetTitle(Form("Total: %5d/51200 (%3d%%)",
314 total, Int_t(100. / 51200 * total)));
315 fSummary->Modified();
321 //____________________________________________________________________
323 AliFMDPattern::ProcessHit(AliFMDHit* hit, TParticle*)
325 switch (hit->Detector()) {
326 case 1: fFMD1.AddMarker(hit->X(), hit->Y(), hit->Edep(), 1); break;
327 case 2: fFMD2.AddMarker(hit->X(), hit->Y(), hit->Edep(), 1); break;
328 case 3: fFMD3.AddMarker(hit->X(), hit->Y(), hit->Edep(), 1); break;
334 //____________________________________________________________________
336 AliFMDPattern::AddMarker(UShort_t det, Char_t rng, UShort_t sec, UShort_t str,
337 TObject*, Float_t s, Float_t max)
339 // Add a marker to the display
345 // o Object to refer to
347 // max Maximum of signal
351 case 1: d = &fFMD1; break;
352 case 2: d = &fFMD2; break;
353 case 3: d = &fFMD3; break;
356 AliFMDGeometry* geom = AliFMDGeometry::Instance();
358 geom->Detector2XYZ(det, rng, sec, str, x, y, z);
360 AliFMDRing* r = geom->GetRing(rng);
361 Double_t t = .9 * r->GetTheta() / 2;
362 Double_t a = gRandom->Uniform(-t,t) * TMath::Pi() / 180;
363 Double_t x1 = x * TMath::Cos(a) - y * TMath::Sin(a);
364 Double_t y1 = x * TMath::Sin(a) + y * TMath::Cos(a);
368 d->AddMarker(x, y, s, max);
371 //____________________________________________________________________