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
32 // #include <iostream>
34 // #include <TApplication.h>
35 // #include <TButton.h>
41 // #include <TSlider.h>
43 // #include <TSystem.h>
47 #include "AliFMDPattern.h" // ALIFMDDISPLAY_H
48 #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
49 //#include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
50 #include "AliFMDRing.h"
51 // #include "AliFMDDetector.h"
52 #include "AliFMDHit.h"
53 // #include <AliLog.h>
54 #include "AliFMDDebug.h" // Better debug macros
57 //____________________________________________________________________
58 ClassImp(AliFMDPattern)
60 ; // This is here to keep Emacs for indenting the next line
63 //____________________________________________________________________
64 AliFMDPattern::AliFMDPatternDetector::AliFMDPatternDetector(UShort_t id)
77 //____________________________________________________________________
78 AliFMDPattern::AliFMDPatternDetector::~AliFMDPatternDetector()
82 // deletes mother frame
83 if (fFrame) delete fFrame;
86 //____________________________________________________________________
88 AliFMDPattern::AliFMDPatternDetector::DrawShape(TObjArray& a)
98 while ((g = static_cast<TGraph*>(next()))) {
99 g->DrawClone("f same");
100 g->DrawClone("l same");
104 //____________________________________________________________________
106 AliFMDPattern::AliFMDPatternDetector::Begin(Int_t nlevel, Double_t r,
107 TObjArray& inners, TObjArray& outers)
113 // nlevel Number of levels
115 // inners Array of inner shapes
116 // outers Array of outer shapes
119 // To make code-checker shut up
120 TStyle* style = gStyle;
121 if (nlevel < 1) nlevel = style->GetNumberOfColors();
124 // The code-checker thinks this is not using the declaration of
125 // TH2F - what a morron!
126 fFrame = new TH2F(Form("fmd%dFrame", fId), Form("FMD%d", fId),
127 10, -r, r, 10, -r, r);
128 fFrame->SetStats(kFALSE);
132 if (fId != 1) DrawShape(outers);
133 for (Int_t i = 0; i < nlevel; i++) {
134 TGraph* g = new TGraph;
135 Int_t idx = Int_t(Float_t(i) / nlevel * style->GetNumberOfColors());
136 Int_t col = style->GetColorPalette(idx);
137 g->SetName(Form("FMD%d_L%02d", fId, i));
138 g->SetMarkerColor(col);
139 g->SetLineColor(col);
140 g->SetFillColor(col);
141 g->SetMarkerSize(i * .2 + .2);
142 g->SetMarkerStyle(2);
144 fGraphs.AddAtAndExpand(g, i);
146 TIter next(&fGraphs);
149 //____________________________________________________________________
151 AliFMDPattern::AliFMDPatternDetector::Clear()
153 // Clear this display.
154 // Simply reset counters to zero.
155 // Avoid deleting memory.
159 //____________________________________________________________________
161 AliFMDPattern::AliFMDPatternDetector::End()
163 // Called when displaying the data.
164 // Simply resets number of points at each level to
165 // the seen number of hits at that level.
166 // Avoid deleting memory.
167 TIter next(&fGraphs);
170 while ((g = static_cast<TGraph*>(next()))) g->Set(fCounts[i++]);
172 //____________________________________________________________________
174 AliFMDPattern::AliFMDPatternDetector::AddMarker(Double_t x, Double_t y, Float_t s,
177 // Add a marker at (X,Y,Z). The marker color and size is chosen
178 // relative to the MAX argument.
183 // MAX Maximum value.
185 /** Sigh, for some odd reason, the code-checker does not recognise
186 this a usage of the TMath namespace declaration! Idiot */
187 Int_t i = TMath::Min(Int_t(fCounts.fN * s / max),
188 Int_t(fGraphs.GetEntries()-1));
189 TGraph* g = static_cast<TGraph*>(fGraphs.At(i));
191 g->SetPoint(fCounts[i]++, x, y);
195 //____________________________________________________________________
196 AliFMDPattern::AliFMDPattern(const char* gAliceFile)
197 : AliFMDDisplay(kTRUE, gAliceFile),
206 fEvent(.1, .8, "Event #"),
207 fFMD1Sum(.2, .7, "# in FMD1: "),
208 fFMD2Sum(.2, .6, "# in FMD2: "),
209 fFMD3Sum(.2, .5, "# in FMD3: "),
210 fLine(.15, .47, .85, .47),
211 fTotal(.2, .35, "Total: ")
217 // gAliceFile The galice.root file to use - if any.
220 // RemoveLoad(kGeometry);
221 fEvent.SetBit(TLatex::kTextNDC);
222 fFMD1Sum.SetBit(TLatex::kTextNDC);
223 fFMD2Sum.SetBit(TLatex::kTextNDC);
224 fFMD3Sum.SetBit(TLatex::kTextNDC);
225 fLine.SetBit(TLine::kLineNDC);
226 fTotal.SetBit(TLatex::kTextNDC);
229 //____________________________________________________________________
230 AliFMDPattern::~AliFMDPattern()
233 // Free all allocated shapes.
234 // note, that most members are real objects, so we do not need to
235 // deal with them here.
241 //____________________________________________________________________
243 AliFMDPattern::Init()
245 // Initialize. Get transforms and such,
246 if (!AliFMDInput::Init()) return kFALSE;
247 AliFMDGeometry* geom = AliFMDGeometry::Instance();
249 geom->InitTransformations();
251 Char_t rs[] = { 'I' , 'O', '\0' };
254 AliFMDRing* ring = geom->GetRing(*r);
256 const TObjArray& vs = ring->GetVerticies();
257 TObjArray& gs = (*r == 'I' ? fInners : fOuters);
258 Float_t& mr = (*r == 'I' ? fInnerMax : fOuterMax);
259 Int_t nm = ring->GetNModules();
260 AliInfo(Form("Making %d modules for %c", nm, *r));
261 for (Int_t m = 0; m < nm; m++) {
262 Int_t nv = vs.GetEntries();
263 Double_t a = TMath::Pi() / 180 * (m * 2 + 1) * ring->GetTheta();
264 TGraph* g = new TGraph(nv+1);
265 Double_t x0 = 0, y0 = 0;
266 gs.AddAtAndExpand(g, m);
267 for (Int_t c = 0; c < nv; c++) {
268 TVector2* v = static_cast<TVector2*>(vs.At(c));
269 mr = TMath::Max(mr, Float_t(v->Mod()));
270 TVector2 w(v->Rotate(a));
271 if (c == 0) { x0 = w.X(); y0 = w.Y(); }
272 g->SetPoint(c, w.X(), w.Y());
274 g->SetName(Form("FMDX%c_%02d", *r, m));
275 g->SetPoint(nv, x0, y0);
276 g->SetFillColor((*rs == 'I' ?
277 (m % 2 == 0 ? 18 : 17) :
278 (m % 2 == 0 ? 20 : 23)));
279 g->SetFillStyle(3001);
289 //____________________________________________________________________
291 AliFMDPattern::Begin(Int_t event)
293 // Called at the begining of an event.
297 // EVENT The event number
301 const char* which[] = { "Continue", "Redisplay", 0 };
304 AliFMDGeometry* geom = AliFMDGeometry::Instance();
305 // AliFMDDetector* det;
306 if ((/* det = */ geom->GetDetector(1))) {
308 fFMD1Pad = new TPad("FMD1", "FMD1", 0.0, 0.50, 0.5, 1.0, 0, 0);
311 fFMD1.Begin(-1, fInnerMax, fInners, fOuters);
313 if ((/* det = */ geom->GetDetector(2))) {
315 fFMD2Pad = new TPad("FMD2", "FMD2", 0.5, 0.50, 1.0, 1.0, 0, 0);
318 fFMD2.Begin(-1, fOuterMax, fInners, fOuters);
320 if ((/* det = */ geom->GetDetector(3))) {
322 fFMD3Pad = new TPad("FMD3", "FMD3", 0.0, 0.0, .5, .5, 0, 0);
325 fFMD3.Begin(-1, fOuterMax, fInners, fOuters);
328 fSummary = new TPad("display", "Display", 0.5, 0.0, 1.0, 0.5, 0, 0);
338 fEvent.SetTitle(Form("Event # %6d", event));
346 return AliFMDInput::Begin(event);
349 //____________________________________________________________________
351 AliFMDPattern::Redisplay()
353 // Redraw the displayu
357 AliFMDDisplay::Redisplay();
360 //____________________________________________________________________
362 AliFMDPattern::AtEnd()
364 // Called at the end of an event.
370 fFMD1Pad->Modified();
371 fFMD1Sum.SetTitle(Form("# hits in FMD1: %5d", fFMD1.Total()));
372 total += fFMD1.Total();
375 fFMD2Pad->Modified();
376 fFMD2Sum.SetTitle(Form("# hits in FMD2: %5d", fFMD2.Total()));
377 total += fFMD2.Total();
380 fFMD3Pad->Modified();
381 fFMD3Sum.SetTitle(Form("# hits in FMD3: %5d", fFMD3.Total()));
382 total += fFMD3.Total();
384 fTotal.SetTitle(Form("Total: %5d/51200 (%3d%%)",
385 total, Int_t(100. / 51200 * total)));
386 fSummary->Modified();
392 //____________________________________________________________________
394 AliFMDPattern::ProcessHit(AliFMDHit* hit, TParticle*)
400 // HIT The hit to process.
402 // The TParticle argument is never used.
403 switch (hit->Detector()) {
404 case 1: fFMD1.AddMarker(hit->X(), hit->Y(), hit->Edep(), 1); break;
405 case 2: fFMD2.AddMarker(hit->X(), hit->Y(), hit->Edep(), 1); break;
406 case 3: fFMD3.AddMarker(hit->X(), hit->Y(), hit->Edep(), 1); break;
412 //____________________________________________________________________
414 AliFMDPattern::AddMarker(UShort_t det, Char_t rng,
415 UShort_t sec, UShort_t str,
416 TObject*, Float_t s, Float_t max)
418 // Add a marker to the display
424 // o Object to refer to
426 // max Maximum of signal
428 AliFMDPatternDetector* d = 0;
430 case 1: d = &fFMD1; break;
431 case 2: d = &fFMD2; break;
432 case 3: d = &fFMD3; break;
435 AliFMDGeometry* geom = AliFMDGeometry::Instance();
437 geom->Detector2XYZ(det, rng, sec, str, x, y, z);
438 // Make code-checker shut the f**k up
439 TRandom* rand = gRandom;
441 AliFMDRing* r = geom->GetRing(rng);
442 Double_t t = .9 * r->GetTheta() / 2;
443 Double_t a = rand->Uniform(-t,t) * TMath::Pi() / 180;
444 Double_t x1 = x * TMath::Cos(a) - y * TMath::Sin(a);
445 Double_t y1 = x * TMath::Sin(a) + y * TMath::Cos(a);
449 d->AddMarker(x, y, s, max);
452 //____________________________________________________________________