1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 **************************************************************************/
18 //____________________________________________________________________
20 // This is a class that constructs AliFMDMult (reconstructed
21 // multiplicity) from of Digits
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).
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.
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.
35 // +---------------------+ +---------------------+
36 // | AliFMDReconstructor |<>-----| AliFMDMultAlgorithm |
37 // +---------------------+ +---------------------+
40 // +-----------+---------+
42 // +-------------------+ +------------------+
43 // | AliFMDMultPoisson | | AliFMDMultNaiive |
44 // +-------------------+ +------------------+
46 // AliFMDReconstructor acts as a manager class. It contains a list of
47 // AliFMDMultAlgorithm objects. The call graph looks something like
50 // +----------------------+ +----------------------+
51 // | :AliFMDReconstructor | | :AliFMDMultAlgorithm |
52 // +----------------------+ +----------------------+
55 // ------------>| | PreRun +-+
56 // | |------------------------------->| |
58 // | |-----+ (for each event) |
59 // | | | *ProcessEvent |
61 // || |<---+ PreEvent +-+
62 // || |------------------------------>| |
65 // || | | ProcessDigits |
68 // ||| | *ProcessDigit(digit) +-+
69 // ||| |----------------------------->| |
73 // || |------------------------------>| |
77 // | |------------------------------->| |
84 //-- Authors: Evgeny Karpechev(INR) and Alla Maevsksia
85 // Latest changes by Christian Holm Christensen <cholm@nbi.dk>
88 //____________________________________________________________________
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
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
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
109 #include "AliESD.h" // ALIESD_H
111 //____________________________________________________________________
112 ClassImp(AliFMDReconstructor)
114 ; // This is here to keep Emacs for indenting the next line
117 //____________________________________________________________________
118 AliFMDReconstructor::AliFMDReconstructor()
119 : AliReconstructor(),
124 // Make a new FMD reconstructor object - default CTOR.
125 AliFMDParameters* pars = AliFMDParameters::Instance();
126 fPedestal = pars->GetPedestal();
127 fPedestalWidth = pars->GetPedestalWidth();
128 fPedestalFactor = pars->GetPedestalFactor();
130 fAlgorithms.Add(new AliFMDMultNaiive);
131 fAlgorithms.Add(new AliFMDMultPoisson);
133 TIter next(&fAlgorithms);
134 AliFMDMultAlgorithm* algorithm = 0;
135 while ((algorithm = static_cast<AliFMDMultAlgorithm*>(next())))
136 algorithm->PreRun(0);
140 //____________________________________________________________________
141 AliFMDReconstructor::AliFMDReconstructor(const AliFMDReconstructor& other)
142 : AliReconstructor(),
148 fPedestal = other.fPedestal;
149 fPedestalWidth = other.fPedestalWidth;
150 fPedestalFactor = other.fPedestalFactor;
153 fAlgorithms.Delete();
154 TIter next(&(other.fAlgorithms));
155 AliFMDMultAlgorithm* algorithm = 0;
156 while ((algorithm = static_cast<AliFMDMultAlgorithm*>(next())))
157 fAlgorithms.Add(algorithm);
158 fAlgorithms.SetOwner(kFALSE);
162 //____________________________________________________________________
164 AliFMDReconstructor::operator=(const AliFMDReconstructor& other)
166 // Assignment operator
167 fPedestal = other.fPedestal;
168 fPedestalWidth = other.fPedestalWidth;
169 fPedestalFactor = other.fPedestalFactor;
171 fAlgorithms.Delete();
172 TIter next(&(other.fAlgorithms));
173 AliFMDMultAlgorithm* algorithm = 0;
174 while ((algorithm = static_cast<AliFMDMultAlgorithm*>(next())))
175 fAlgorithms.Add(algorithm);
176 fAlgorithms.SetOwner(kFALSE);
181 //____________________________________________________________________
182 AliFMDReconstructor::~AliFMDReconstructor()
185 fAlgorithms.Delete();
188 //____________________________________________________________________
190 AliFMDReconstructor::Init(AliRunLoader* runLoader)
192 // Initialize the reconstructor
193 AliDebug(1, Form("Init called with runloader 0x%x", runLoader));
196 Warning("Init", "No run loader");
199 AliHeader* header = runLoader->GetHeader();
201 Warning("Init", "No header");
204 AliGenEventHeader* eventHeader = header->GenEventHeader();
207 eventHeader->PrimaryVertex(vtx);
208 fCurrentVertex = vtx[2];
209 AliDebug(1, Form("Primary vertex Z coordinate for event # %d/%d is %f",
210 header->GetRun(), header->GetEvent(), fCurrentVertex));
211 Warning("Init", "no generator event header");
214 Warning("Init", "No generator event header - "
215 "perhaps we get the vertex from ESD?");
221 //____________________________________________________________________
223 AliFMDReconstructor::ConvertDigits(AliRawReader* reader,
224 TTree* digitsTree) const
226 // Convert Raw digits to AliFMDDigit's in a tree
227 AliFMDRawReader rawRead(reader, digitsTree);
228 // rawRead.SetSampleRate(fFMD->GetSampleRate());
232 //____________________________________________________________________
234 AliFMDReconstructor::Reconstruct(TTree* digitsTree,
235 TTree* clusterTree) const
237 // Reconstruct event from digits in tree
238 // Get the FMD branch holding the digits.
239 // FIXME: The vertex may not be known yet, so we may have to move
240 // some of this to FillESD.
241 AliDebug(1, "Reconstructing from digits in a tree");
244 // const AliESDVertex* vertex = fESD->GetVertex();
246 // AliDebug(1, Form("Got vertex from ESD: %f", vertex->GetZv()));
247 // fCurrentVertex = vertex->GetZv();
251 TBranch *digitBranch = digitsTree->GetBranch("FMD");
253 Error("Exec", "No digit branch for the FMD found");
256 TClonesArray* digits = new TClonesArray("AliFMDDigit");
257 digitBranch->SetAddress(&digits);
259 TIter next(&fAlgorithms);
260 AliFMDMultAlgorithm* algorithm = 0;
261 while ((algorithm = static_cast<AliFMDMultAlgorithm*>(next())))
262 algorithm->PreEvent(clusterTree, fCurrentVertex);
263 digitBranch->GetEntry(0);
265 ProcessDigits(digits);
269 while ((algorithm = static_cast<AliFMDMultAlgorithm*>(next())))
270 algorithm->PostEvent();
276 //____________________________________________________________________
278 AliFMDReconstructor::ProcessDigits(TClonesArray* digits) const
280 // For each digit, find the pseudo rapdity, azimuthal angle, and
281 // number of corrected ADC counts, and pass it on to the algorithms
283 Int_t nDigits = digits->GetEntries();
284 AliDebug(1, Form("Got %d digits", nDigits));
285 for (Int_t i = 0; i < nDigits; i++) {
286 AliFMDDigit* digit = static_cast<AliFMDDigit*>(digits->At(i));
287 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
288 AliFMDDetector* subDetector = fmd->GetDetector(digit->Detector());
290 Warning("ProcessDigits", "Unknown detector: FMD%d" , digit->Detector());
294 AliFMDRing* ring = subDetector->GetRing(digit->Ring());
295 Float_t ringZ = subDetector->GetRingZ(digit->Ring());
297 Warning("ProcessDigits", "Unknown ring: FMD%d%c", digit->Detector(),
302 Float_t realZ = fCurrentVertex + ringZ;
303 Float_t stripR = ((ring->GetHighR() - ring->GetLowR())
304 / ring->GetNStrips() * (digit->Strip() + .5)
306 Float_t theta = TMath::ATan2(stripR, realZ);
307 Float_t phi = (2 * TMath::Pi() / ring->GetNSectors()
308 * (digit->Sector() + .5));
309 Float_t eta = -TMath::Log(TMath::Tan(theta / 2));
310 UShort_t counts = SubtractPedestal(digit);
312 TIter next(&fAlgorithms);
313 AliFMDMultAlgorithm* algorithm = 0;
314 while ((algorithm = static_cast<AliFMDMultAlgorithm*>(next())))
315 algorithm->ProcessDigit(digit, eta, phi, counts);
319 //____________________________________________________________________
321 AliFMDReconstructor::SubtractPedestal(AliFMDDigit* digit) const
323 // Member function to subtract the pedestal from a digit
324 // This implementation does nothing, but a derived class could over
325 // load this to subtract a pedestal that was given in a database or
326 // something like that.
329 Float_t ped = fPedestal + fPedestalFactor * fPedestalWidth;
330 if (digit->Count3() > 0) counts = digit->Count3();
331 else if (digit->Count2() > 0) counts = digit->Count2();
332 else counts = digit->Count1();
333 counts = TMath::Max(Int_t(counts - ped), 0);
334 return UShort_t(counts);
337 //____________________________________________________________________
339 AliFMDReconstructor::FillESD(TTree* /* digitsTree */,
340 TTree* /* clusterTree */,
341 AliESD* /* esd*/) const
343 // nothing to be done
344 // FIXME: The vertex may not be known when Reconstruct is executed,
345 // so we may have to move some of that member function here.
347 TClonesArray* multStrips = 0;
348 TClonesArray* multRegions = 0;
349 TTree* treeR = fmdLoader->TreeR();
350 TBranch* branchRegions = treeR->GetBranch("FMDPoisson");
351 TBranch* branchStrips = treeR->GetBranch("FMDNaiive");
352 branchRegions->SetAddress(&multRegions);
353 branchStrips->SetAddress(&multStrips);
356 Int_t nEntries = clusterTree->GetEntries();
357 for (Int_t entry = 0; entry < nEntries; entry++) {
358 AliDebug(5, Form("Entry # %d in cluster tree", entry));
359 treeR->GetEntry(entry);
362 Int_t nMults = multRegions->GetLast();
363 for (Int_t i = 0; i <= nMults; i++) {
364 AliFMDMultRegion* multR =
365 static_cast<AliFMDMultRegion*>(multRegions->UncheckedAt(i));
366 Int_t nParticles=multR->Particles();
367 if (i>=0 && i<=13) hEtaPoissonI1->AddBinContent(i+1,nParticles);
368 if (i>=14 && i<=27 ) hEtaPoissonI2->AddBinContent(i-13,nParticles);
369 if (i>=28 && i<=33 );
370 if (i>=34 && i<=47 ) hEtaPoissonI3->AddBinContent(48-i,nParticles);
371 if (i>=48 && i<=53) hEtaPoissonO3->AddBinContent(54-i,nParticles);
378 //____________________________________________________________________
380 AliFMDReconstructor::Reconstruct(AliRawReader*,TTree*) const
382 // Cannot be used. See member function with same name but with 2
383 // TTree arguments. Make sure you do local reconstrucion
384 AliError("MayNotUse");
386 //____________________________________________________________________
388 AliFMDReconstructor::Reconstruct(AliRunLoader*) const
390 // Cannot be used. See member function with same name but with 2
391 // TTree arguments. Make sure you do local reconstrucion
392 AliError("MayNotUse");
394 //____________________________________________________________________
396 AliFMDReconstructor::Reconstruct(AliRunLoader*, AliRawReader*) const
398 // Cannot be used. See member function with same name but with 2
399 // TTree arguments. Make sure you do local reconstrucion
400 AliError("MayNotUse");
402 //____________________________________________________________________
404 AliFMDReconstructor::FillESD(AliRawReader*,TTree*,AliESD*) const
406 // Cannot be used. See member function with same name but with 2
407 // TTree arguments. Make sure you do local reconstrucion
408 AliError("MayNotUse");
410 //____________________________________________________________________
412 AliFMDReconstructor::FillESD(AliRunLoader*,AliESD*) const
414 // Cannot be used. See member function with same name but with 2
415 // TTree arguments. Make sure you do local reconstrucion
416 AliError("MayNotUse");
418 //____________________________________________________________________
420 AliFMDReconstructor::FillESD(AliRunLoader*,AliRawReader*,AliESD*) const
422 // Cannot be used. See member function with same name but with 2
423 // TTree arguments. Make sure you do local reconstrucion
424 AliError("MayNotUse");
427 //____________________________________________________________________