]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSFastGlobalReconstruction.cxx
Rearranging the classes to use loadlibs.C
[u/mrichter/AliRoot.git] / PHOS / AliPHOSFastGlobalReconstruction.cxx
CommitLineData
8b2df7ae 1/**************************************************************************
2 * Copyright(c) 1998-2003, 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
16/* $Id$ */
17
18// --- AliRoot header files ---
19
20// Fast global reconstruction class.
21// It performes fast reconstruction for charged particles only,
22// assuming that they were detected by all central ALICE detectors but PHOS.
23// This class acts as a filter for primary particles, selects them
24// and deteriorates their 4-momenta.
25// The filter can recognize the primary particle list from different
26// event generators: Pythia, Hijing, HIJINGPara.
27//!
28// Usage:
29// rec = new AliPHOSGlobalReconstruction("galice.root");
30// rec->FastReconstruction(ievent);
31// TClonesArray *recList = rec->GetRecParticles();
32//!
33// See also $ALICE_ROOT/macros/TestGlobalReconstruction.C
34//!
35// Author: Yuri Kharlov. 17 April 2003
36
8b2df7ae 37#include "AliGenerator.h"
38#include "AliPHOSGetter.h"
39#include "AliPHOSFastGlobalReconstruction.h"
40
41ClassImp(AliPHOSFastGlobalReconstruction)
42
43//____________________________________________________________________________
43fbaae1 44AliPHOSFastGlobalReconstruction::AliPHOSFastGlobalReconstruction():
45 fgime(0),
46 fGenerator(0),
47 fParticles(0),
48 fNParticles(0)
49{
50 //Def ctor.
51}
52
53//____________________________________________________________________________
54AliPHOSFastGlobalReconstruction::AliPHOSFastGlobalReconstruction(const char* headerFile):
55 fgime(AliPHOSGetter::Instance(headerFile)),
56 fGenerator(gAlice->Generator()),
57 fParticles(new TClonesArray("TParticle",100)),
58 fNParticles(0)
8b2df7ae 59{
60 // Constructor of fast global reconstruction:
61 // create an instance of the PHOS getter,
62 // create an array or reconstructed particles.
43fbaae1 63}
8b2df7ae 64
43fbaae1 65//____________________________________________________________________________
66AliPHOSFastGlobalReconstruction::AliPHOSFastGlobalReconstruction(const AliPHOSFastGlobalReconstruction & rhs):
67 TObject(rhs),
68 fgime(0),
69 fGenerator(0),
70 fParticles(0),
71 fNParticles(0)
72{
73 //Required by effc++, but not clear for me how to do correct copy. To be fixed.
74 Fatal("AliPHOSFastGlobalReconstruction", "copy ctor not implemented");
75}
76
77//____________________________________________________________________________
78AliPHOSFastGlobalReconstruction & AliPHOSFastGlobalReconstruction::operator = (const AliPHOSFastGlobalReconstruction &)
79{
80 //Required by effc++, but not clear for me how to do correct copy. To be fixed.
81 Fatal("operator = ", "copy ctor not implemented");
82 return *this;
8b2df7ae 83}
84
85//____________________________________________________________________________
86AliPHOSFastGlobalReconstruction::~AliPHOSFastGlobalReconstruction()
87{
88 // Destructor of fast global reconstruction:
89 // delete the array of reconstructed particles
90 if (fParticles != 0) {
91 delete fParticles;
92 fParticles = 0;
93 fNParticles = 0;
94 }
95}
96
97//____________________________________________________________________________
98void AliPHOSFastGlobalReconstruction::FastReconstruction(Int_t event)
99{
100 // Perform a fast global reconstruction of event numbered "event".
101 // Reconstructed particles will be stored into array recParticles
102
103 TParticle *primary;
104 TLorentzVector p,v;
105 Int_t kf,ks,imom1,imom2,idaug1,idaug2;
106
e957fea8 107 fgime->Event(event,"X") ;
8b2df7ae 108 fParticles ->Clear();
109 fNParticles = 0;
e957fea8 110 Int_t nPrimaries = fgime->NPrimaries();
111 TClonesArray *primaries = fgime->Primaries();
8b2df7ae 112
113 for (Int_t iprim=0; iprim<nPrimaries; iprim++) {
114 primary = (TParticle*)primaries->At(iprim);
115 if ((strcmp(fGenerator->GetName(),"Pythia") ==0 && primary->GetStatusCode() == 1) ||
116 (strcmp(fGenerator->GetName(),"HIJINGpara")==0 && primary->GetFirstMother()==-1) ||
117 (strcmp(fGenerator->GetName(),"Hijing") ==0 && primary->GetStatusCode() == 3)) {
118 if (Detected(primary)) {
119 primary->Momentum(p);
120 primary->ProductionVertex(v);
121 kf = primary->GetPdgCode();
122 ks = primary->GetStatusCode();
123 imom1 = primary->GetFirstMother();
124 imom2 = primary->GetSecondMother();
125 idaug1 = primary->GetFirstDaughter();
126 idaug2 = primary->GetLastDaughter();
127 SmearMomentum(p);
128 new((*fParticles)[fNParticles]) TParticle(kf,ks,imom1,imom2,idaug1,idaug2,p,v);
129 fNParticles++;
130 }
131 }
132 }
133}
134
135//____________________________________________________________________________
136Bool_t AliPHOSFastGlobalReconstruction::Detected(TParticle *particle)
137{
138 // Returns kTRUE is a particle is reconstructed, kFALSE otherwise.
139 // A particle is reconstructed if it is charged and accepted with the
140 // probability Efficiency(pt,eta) depending on pt and eta.
141
142 Bool_t detected = kFALSE;
143 if (particle->GetPDG()->Charge() != 0) {
144 Float_t pt = particle->Pt();
145 Float_t eta = particle->Eta();
146 if (gRandom->Rndm() < Efficiency(pt,eta)) detected = kTRUE;
147 }
148 return detected;
149}
150
151//____________________________________________________________________________
152Float_t AliPHOSFastGlobalReconstruction::Efficiency(Float_t pt, Float_t eta)
153{
154 // Detection probability vs. pt and eta, i.e. a probability to detect
155 // a particle with transverse momentum pt and speudorapidity eta.
156 // For the moment assume that charged particles are detected with
157 // 80% efficiency within |eta|<0.9 and pt>0.15 GeV, and with 0% efficiency
158 // beyond that acceptance
159
160 const Float_t kEtaLimit = 0.9;
161 const Float_t kPtLimit = 0.15;
162 Float_t efficiency = 0.0;
163 if (TMath::Abs(eta) < kEtaLimit && pt > kPtLimit) efficiency = 0.80;
164 return efficiency;
165}
166
167//____________________________________________________________________________
168void AliPHOSFastGlobalReconstruction::SmearMomentum(TLorentzVector &p)
169{
170 // Smear 4-momentum according to known resolution (2% for the moment)
171
172 const Float_t kAngleResolution = 0.02;
173 const Float_t kMomentumResolution = 0.02;
174 Double_t mass = p.M();
175 for (Int_t i=0; i<3; i++) {
176 p[i] *= gRandom->Gaus(1.,kAngleResolution );
177 p[i] *= gRandom->Gaus(1.,kMomentumResolution);
178 }
179 p[3] = TMath::Sqrt(p.P()*p.P() + mass*mass);
180}