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 **************************************************************************/
16 //-------------------------------------------------------------------------
17 // Jet kinematics reader
18 // MC reader for jet analysis
19 // Author: Andreas Morsch (andreas.morsch@cern.ch)
20 //-------------------------------------------------------------------------
23 #include <TClonesArray.h>
25 #include <TParticle.h>
26 #include <TParticlePDG.h>
27 //#include <TVector3.h>
28 #include <TLorentzVector.h>
30 #include <TDatabasePDG.h>
33 #include "AliJetKineReaderHeader.h"
34 #include "AliJetKineReader.h"
35 #include "AliRunLoader.h"
38 ClassImp(AliJetKineReader)
40 AliJetKineReader::AliJetKineReader()
49 //____________________________________________________________________________
51 AliJetKineReader::~AliJetKineReader()
57 //____________________________________________________________________________
59 void AliJetKineReader::OpenInputFiles()
61 // Opens the input file using the run loader
62 const char* dirName = fReaderHeader->GetDirectory();
64 sprintf(path, "%s/galice.root",dirName);
65 fRunLoader = AliRunLoader::Open(path);
66 fRunLoader->LoadKinematics();
67 fRunLoader->LoadHeader();
69 // get number of events
70 Int_t nMax = fRunLoader->GetNumberOfEvents();
71 printf("\nTotal number of events = %d", nMax);
73 // set number of events in header
74 if (fReaderHeader->GetLastEvent() == -1)
75 fReaderHeader->SetLastEvent(nMax);
77 Int_t nUsr = fReaderHeader->GetLastEvent();
78 fReaderHeader->SetLastEvent(TMath::Min(nMax, nUsr));
82 //____________________________________________________________________________
84 void AliJetKineReader::FillMomentumArray(Int_t event)
86 // Fill momentum array for event
91 // Get event from runloader
92 fRunLoader->GetEvent(event);
94 AliStack* stack = fRunLoader->Stack();
95 // Number of primaries
96 Int_t nt = stack->GetNprimary();
98 // Get cuts set by user and header
99 Double_t ptMin = ((AliJetKineReaderHeader*) fReaderHeader)->GetPtCut();
100 Float_t etaMin = fReaderHeader->GetFiducialEtaMin();
101 Float_t etaMax = fReaderHeader->GetFiducialEtaMax();
102 fAliHeader = fRunLoader->GetHeader();
104 // temporary storage of signal and cut flags
105 Int_t* sflag = new Int_t[nt];
106 Int_t* cflag = new Int_t[nt];
109 // Loop over particles
110 for (Int_t it = 0; it < nt; it++) {
111 TParticle *part = stack->Particle(it);
112 Int_t status = part->GetStatusCode();
113 Int_t pdg = TMath::Abs(part->GetPdgCode());
114 Float_t pt = part->Pt();
116 // Skip non-final state particles, neutrinos
117 // and particles with pt < pt_min
119 || (pdg == 12 || pdg == 14 || pdg == 16)) continue;
121 Float_t p = part->P();
123 Float_t eta = part->Eta();
124 Float_t phi = part->Phi();
126 // Fast simulation of TPC if requested
127 if (((AliJetKineReaderHeader*)fReaderHeader)->FastSimTPC()) {
128 // Charged particles only
130 TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
131 if (charge == 0) continue;
132 // Simulate efficiency
133 if (!Efficiency(p0, eta, phi)) continue;
134 // Simulate resolution
135 p = SmearMomentum(4, p0);
138 // Fast simulation of EMCAL if requested
139 if (((AliJetKineReaderHeader*)fReaderHeader)->FastSimEMCAL()) {
141 TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
142 // Charged particles only
144 // Simulate efficiency
145 if (!Efficiency(p0, eta, phi)) continue;
146 // Simulate resolution
147 p = SmearMomentum(4, p0);
148 } // end "if" charged particles
149 // Neutral particles (exclude K0L, n, nbar)
150 if (pdg == kNeutron || pdg == kK0Long) continue;
153 fMass = part->GetCalcMass();
154 fPdgC = part->GetPdgCode();
156 // Fill momentum array
158 Float_t px = r * part->Px();
159 Float_t py = r * part->Py();
160 Float_t pz = r * part->Pz();
161 Float_t m = part->GetMass();
162 Float_t e = TMath::Sqrt(px * px + py * py + pz * pz + m * m);
163 p4 = TLorentzVector(px, py, pz, e);
164 if ( (p4.Eta()>etaMax) || (p4.Eta()<etaMin)) continue;
165 new ((*fMomentumArray)[goodTrack]) TLorentzVector(p4);
167 // all tracks are signal ... ?
170 if (pt > ptMin) cflag[goodTrack]=1; // track surviving pt cut
174 // set the signal flags
175 fSignalFlag.Set(goodTrack,sflag);
176 fCutFlag.Set(goodTrack,cflag);
177 printf("\nIn event %d, number of good tracks %d \n", event, goodTrack);
182 Float_t AliJetKineReader::SmearMomentum(Int_t ind, Float_t p)
184 // The relative momentum error, i.e.
185 // (delta p)/p = sqrt (a**2 + (b*p)**2) * 10**-2,
186 // where typically a = 0.75 and b = 0.16 - 0.24 depending on multiplicity
187 // (the lower value is for dn/d(eta) about 2000, and the higher one for 8000)
189 // If we include information from TRD, b will be a factor 2/3 smaller.
191 // ind = 1: high multiplicity
192 // ind = 2: low multiplicity
193 // ind = 3: high multiplicity + TRD
194 // ind = 4: low multiplicity + TRD
200 if (ind == 1) b = 0.12;
201 if (ind == 2) b = 0.08;
202 if (ind == 3) b = 0.12;
203 if (ind == 4) b = 0.08;
205 Float_t sigma = p * TMath::Sqrt(a * a + b * b * p * p)*0.01;
206 pSmeared = p + gRandom->Gaus(0., sigma);
211 Bool_t AliJetKineReader::Efficiency(Float_t p, Float_t /*eta*/, Float_t phi)
213 // Fast simulation of geometrical acceptance and tracking efficiency
217 if (p < 0.5) eff -= (0.5-p)*0.2/0.3;
220 phi *= 180. / TMath::Pi();
221 // Sector number 0 - 17
222 Int_t isec = Int_t(phi / 20.);
224 Float_t phi0 = isec * 20. + 10.;
225 Float_t phir = TMath::Abs(phi-phi0);
226 // 2 deg of dead space
227 if (phir > 9.) eff = 0.;
230 if (gRandom->Rndm() > eff) {