]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDReconstructor.cxx
Adding call to PreRun for each multiplicity algorithm
[u/mrichter/AliRoot.git] / FMD / AliFMDReconstructor.cxx
CommitLineData
37c55dc0 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
0d0e6995 16/* $Id$ */
17
4347b38f 18//____________________________________________________________________
42403906 19//
7684b53c 20// This is a class that constructs AliFMDMult (reconstructed
21// multiplicity) from of Digits
4347b38f 22//
23// This class reads either digits from a TClonesArray or raw data from
24// a DDL file (or similar), and stores the read ADC counts in an
25// internal cache (fAdcs).
26//
27// From the cached values it then calculates the number of particles
28// that hit a region of the FMDs, as specified by the user.
29//
30// The reconstruction can be done in two ways: Either via counting the
31// number of empty strips (Poisson method), or by converting the ADC
32// signal to an energy deposition, and then dividing by the typical
33// energy loss of a particle.
34//
7684b53c 35// +---------------------+ +---------------------+
36// | AliFMDReconstructor |<>-----| AliFMDMultAlgorithm |
37// +---------------------+ +---------------------+
38// ^
39// |
40// +-----------+---------+
41// | |
42// +-------------------+ +------------------+
43// | AliFMDMultPoisson | | AliFMDMultNaiive |
44// +-------------------+ +------------------+
45//
46// AliFMDReconstructor acts as a manager class. It contains a list of
47// AliFMDMultAlgorithm objects. The call graph looks something like
48//
49//
50// +----------------------+ +----------------------+
51// | :AliFMDReconstructor | | :AliFMDMultAlgorithm |
52// +----------------------+ +----------------------+
53// | |
54// Reconstruct +-+ |
55// ------------>| | PreRun +-+
56// | |------------------------------->| |
57// | | +-+
58// | |-----+ (for each event) |
59// | | | *ProcessEvent |
60// |+-+ | |
61// || |<---+ PreEvent +-+
62// || |------------------------------>| |
63// || | +-+
64// || |-----+ |
65// || | | ProcessDigits |
66// ||+-+ | |
67// ||| |<---+ |
68// ||| | *ProcessDigit(digit) +-+
69// ||| |----------------------------->| |
70// ||| | +-+
71// ||+-+ |
72// || | PostEvent +-+
73// || |------------------------------>| |
74// || | +-+
75// |+-+ |
76// | | PostRun +-+
77// | |------------------------------->| |
78// | | +-+
79// +-+ |
80// | |
81//
4347b38f 82//
37c55dc0 83//
84//-- Authors: Evgeny Karpechev(INR) and Alla Maevsksia
4347b38f 85// Latest changes by Christian Holm Christensen <cholm@nbi.dk>
86//
87//
88//____________________________________________________________________
37c55dc0 89
56b1929b 90#include <AliLog.h> // ALILOG_H
91#include <AliRun.h> // ALIRUN_H
92#include <AliRunLoader.h> // ALIRUNLOADER_H
93#include <AliLoader.h> // ALILOADER_H
94#include <AliHeader.h> // ALIHEADER_H
95#include <AliRawReader.h> // ALIRAWREADER_H
96#include <AliGenEventHeader.h> // ALIGENEVENTHEADER_H
1a1fdef7 97#include "AliFMD.h" // ALIFMD_H
98#include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
99#include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
100#include "AliFMDDetector.h" // ALIFMDDETECTOR_H
101#include "AliFMDRing.h" // ALIFMDRING_H
56b1929b 102#include "AliFMDDigit.h" // ALIFMDDIGIT_H
103#include "AliFMDReconstructor.h" // ALIFMDRECONSTRUCTOR_H
104#include "AliFMDRawStream.h" // ALIFMDRAWSTREAM_H
105#include "AliFMDRawReader.h" // ALIFMDRAWREADER_H
106#include "AliFMDMultAlgorithm.h" // ALIFMDMULTALGORITHM_H
107#include "AliFMDMultPoisson.h" // ALIFMDMULTPOISSON_H
108#include "AliFMDMultNaiive.h" // ALIFMDMULTNAIIVE_H
4347b38f 109
110//____________________________________________________________________
925e6570 111ClassImp(AliFMDReconstructor)
1a1fdef7 112#if 0
113 ; // This is here to keep Emacs for indenting the next line
114#endif
37c55dc0 115
4347b38f 116//____________________________________________________________________
117AliFMDReconstructor::AliFMDReconstructor()
118 : AliReconstructor(),
4347b38f 119 fPedestal(0),
e802be3e 120 fPedestalWidth(0),
121 fPedestalFactor(0)
4347b38f 122{
42403906 123 // Make a new FMD reconstructor object - default CTOR.
1a1fdef7 124 AliFMDParameters* pars = AliFMDParameters::Instance();
125 fPedestal = pars->GetPedestal();
126 fPedestalWidth = pars->GetPedestalWidth();
127 fPedestalFactor = pars->GetPedestalFactor();
128
56b1929b 129 fAlgorithms.Add(new AliFMDMultNaiive);
130 fAlgorithms.Add(new AliFMDMultPoisson);
c3907f00 131
132 TIter next(&fAlgorithms);
133 AliFMDMultAlgorithm* algorithm = 0;
134 while ((algorithm = static_cast<AliFMDMultAlgorithm*>(next())))
135 algorithm->PreRun(0);
4347b38f 136}
137
42403906 138
139//____________________________________________________________________
140AliFMDReconstructor::AliFMDReconstructor(const AliFMDReconstructor& other)
141 : AliReconstructor(),
42403906 142 fPedestal(0),
e802be3e 143 fPedestalWidth(0),
144 fPedestalFactor(0)
42403906 145{
56b1929b 146 // Copy constructor
1a1fdef7 147 fPedestal = other.fPedestal;
148 fPedestalWidth = other.fPedestalWidth;
149 fPedestalFactor = other.fPedestalFactor;
42403906 150
56b1929b 151
152 fAlgorithms.Delete();
153 TIter next(&(other.fAlgorithms));
154 AliFMDMultAlgorithm* algorithm = 0;
155 while ((algorithm = static_cast<AliFMDMultAlgorithm*>(next())))
156 fAlgorithms.Add(algorithm);
157 fAlgorithms.SetOwner(kFALSE);
42403906 158}
159
160
161//____________________________________________________________________
162AliFMDReconstructor&
163AliFMDReconstructor::operator=(const AliFMDReconstructor& other)
164{
56b1929b 165 // Assignment operator
1a1fdef7 166 fPedestal = other.fPedestal;
167 fPedestalWidth = other.fPedestalWidth;
168 fPedestalFactor = other.fPedestalFactor;
42403906 169
56b1929b 170 fAlgorithms.Delete();
171 TIter next(&(other.fAlgorithms));
172 AliFMDMultAlgorithm* algorithm = 0;
173 while ((algorithm = static_cast<AliFMDMultAlgorithm*>(next())))
174 fAlgorithms.Add(algorithm);
175 fAlgorithms.SetOwner(kFALSE);
176
42403906 177 return *this;
178}
56b1929b 179
180//____________________________________________________________________
181AliFMDReconstructor::~AliFMDReconstructor()
182{
183 // Destructor
184 fAlgorithms.Delete();
185}
4347b38f 186
187//____________________________________________________________________
188void
1a1fdef7 189AliFMDReconstructor::Init(AliRunLoader* runLoader)
190{
191 // Initialize the reconstructor
192 AliDebug(1, Form("Init called with runloader 0x%x", runLoader));
193 fCurrentVertex = 0;
194 if (!runLoader) {
195 Warning("Init", "No run loader");
4347b38f 196 return;
197 }
1a1fdef7 198 AliHeader* header = runLoader->GetHeader();
199 if (!header) {
200 Warning("Init", "No header");
4347b38f 201 return;
202 }
1a1fdef7 203 AliGenEventHeader* eventHeader = header->GenEventHeader();
204 if (!eventHeader) {
205 Warning("Init", "no event header");
206 return;
4347b38f 207 }
1a1fdef7 208 TArrayF vtx;
209 eventHeader->PrimaryVertex(vtx);
210 fCurrentVertex = vtx[2];
211 AliDebug(1, Form("Primary vertex Z coordinate for event # %d/%d is %f",
212 header->GetRun(), header->GetEvent(), fCurrentVertex));
4347b38f 213}
dc8af42e 214
4347b38f 215//____________________________________________________________________
216void
1a1fdef7 217AliFMDReconstructor::ConvertDigits(AliRawReader* reader,
218 TTree* digitsTree) const
219{
220 // Convert Raw digits to AliFMDDigit's in a tree
221 AliFMDRawReader rawRead(reader, digitsTree);
222 // rawRead.SetSampleRate(fFMD->GetSampleRate());
223 rawRead.Exec();
4347b38f 224}
225
4347b38f 226//____________________________________________________________________
227void
1a1fdef7 228AliFMDReconstructor::Reconstruct(TTree* digitsTree,
229 TTree* clusterTree) const
4347b38f 230{
1a1fdef7 231 // Reconstruct event from digits in tree
4347b38f 232 // Get the FMD branch holding the digits.
1a1fdef7 233 AliDebug(1, "Reconstructing from digits in a tree");
234
235 TBranch *digitBranch = digitsTree->GetBranch("FMD");
236 TClonesArray* digits = new TClonesArray("AliFMDDigit");
4347b38f 237 if (!digitBranch) {
1a1fdef7 238 Error("Exec", "No digit branch for the FMD found");
239 return;
4347b38f 240 }
1a1fdef7 241 digitBranch->SetAddress(&digits);
4347b38f 242
e802be3e 243 TIter next(&fAlgorithms);
56b1929b 244 AliFMDMultAlgorithm* algorithm = 0;
245 while ((algorithm = static_cast<AliFMDMultAlgorithm*>(next())))
1a1fdef7 246 algorithm->PreEvent(clusterTree, fCurrentVertex);
247 digitBranch->GetEntry(0);
248
e802be3e 249 ProcessDigits(digits);
250
251 next.Reset();
252 algorithm = 0;
56b1929b 253 while ((algorithm = static_cast<AliFMDMultAlgorithm*>(next())))
e802be3e 254 algorithm->PostEvent();
1a1fdef7 255 clusterTree->Fill();
4347b38f 256}
1a1fdef7 257
4347b38f 258//____________________________________________________________________
e802be3e 259void
260AliFMDReconstructor::ProcessDigits(TClonesArray* digits) const
4347b38f 261{
e802be3e 262 Int_t nDigits = digits->GetEntries();
1a1fdef7 263 AliDebug(1, Form("Got %d digits", nDigits));
e802be3e 264 for (Int_t i = 0; i < nDigits; i++) {
265 AliFMDDigit* digit = static_cast<AliFMDDigit*>(digits->At(i));
1a1fdef7 266 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
267 AliFMDDetector* subDetector = fmd->GetDetector(digit->Detector());
e802be3e 268 if (!subDetector) {
269 Warning("ProcessDigits", "Unknown detector: FMD%d" , digit->Detector());
270 continue;
271 }
4347b38f 272
1a1fdef7 273 AliFMDRing* ring = subDetector->GetRing(digit->Ring());
274 Float_t ringZ = subDetector->GetRingZ(digit->Ring());
e802be3e 275 if (!ring) {
276 Warning("ProcessDigits", "Unknown ring: FMD%d%c", digit->Detector(),
277 digit->Ring());
278 break;
4347b38f 279 }
280
e802be3e 281 Float_t realZ = fCurrentVertex + ringZ;
56b1929b 282 Float_t stripR = ((ring->GetHighR() - ring->GetLowR())
283 / ring->GetNStrips() * (digit->Strip() + .5)
284 + ring->GetLowR());
e802be3e 285 Float_t theta = TMath::ATan2(stripR, realZ);
286 Float_t phi = (2 * TMath::Pi() / ring->GetNSectors()
287 * (digit->Sector() + .5));
288 Float_t eta = -TMath::Log(TMath::Tan(theta / 2));
289 UShort_t counts = SubtractPedestal(digit);
4347b38f 290
e802be3e 291 TIter next(&fAlgorithms);
56b1929b 292 AliFMDMultAlgorithm* algorithm = 0;
293 while ((algorithm = static_cast<AliFMDMultAlgorithm*>(next())))
e802be3e 294 algorithm->ProcessDigit(digit, eta, phi, counts);
4347b38f 295 }
4347b38f 296}
4347b38f 297
1a1fdef7 298//____________________________________________________________________
299UShort_t
300AliFMDReconstructor::SubtractPedestal(AliFMDDigit* digit) const
301{
302 // Member function to subtract the pedestal from a digit
303 // This implementation does nothing, but a derived class could over
304 // load this to subtract a pedestal that was given in a database or
305 // something like that.
306
307 Int_t counts = 0;
308 Float_t ped = fPedestal + fPedestalFactor * fPedestalWidth;
309 if (digit->Count3() > 0) counts = digit->Count3();
310 else if (digit->Count2() > 0) counts = digit->Count2();
311 else counts = digit->Count1();
312 counts = TMath::Max(Int_t(counts - ped), 0);
313 return UShort_t(counts);
314}
315
4347b38f 316//____________________________________________________________________
317void
1a1fdef7 318AliFMDReconstructor::FillESD(TTree* /* digitsTree */,
319 TTree* /* clusterTree */,
320 AliESD* /* esd*/) const
121a60bd 321{
42403906 322 // nothing to be done
121a60bd 323
324}
325
42403906 326//____________________________________________________________________
327//
328// EOF
329//