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 <TLorentzVector.h>
29 #include <TDatabasePDG.h>
32 #include "AliAODJet.h"
33 #include "AliJetKineReaderHeader.h"
34 #include "AliJetKineReader.h"
35 #include "AliMCEventHandler.h"
37 #include "AliHeader.h"
38 #include "AliGenPythiaEventHeader.h"
41 ClassImp(AliJetKineReader)
43 AliJetKineReader::AliJetKineReader():
49 // Default constructor
52 //____________________________________________________________________________
54 AliJetKineReader::~AliJetKineReader()
60 //____________________________________________________________________________
62 void AliJetKineReader::OpenInputFiles()
64 // Opens the input file using the run loader
68 //____________________________________________________________________________
70 Bool_t AliJetKineReader::FillMomentumArray(Int_t event)
72 // Fill momentum array for event
75 // temporary storage of signal and cut flags
76 Int_t* sflag = new Int_t[50000];
77 Int_t* cflag = new Int_t[50000];
81 AliStack* stack = fMCEventHandler->Stack();
82 // Number of primaries
83 Int_t nt = stack->GetNprimary();
85 // Get cuts set by user and header
86 Double_t ptMin = ((AliJetKineReaderHeader*) fReaderHeader)->GetPtCut();
87 Float_t etaMin = fReaderHeader->GetFiducialEtaMin();
88 Float_t etaMax = fReaderHeader->GetFiducialEtaMax();
89 fAliHeader = fMCEventHandler->Header();
93 // Loop over particles
94 for (Int_t it = 0; it < nt; it++) {
95 TParticle *part = stack->Particle(it);
96 Int_t status = part->GetStatusCode();
97 Int_t pdg = TMath::Abs(part->GetPdgCode());
98 Float_t pt = part->Pt();
100 // Skip non-final state particles, neutrinos
101 // and particles with pt < pt_min
103 || (pdg == 12 || pdg == 14 || pdg == 16)) continue;
105 Float_t p = part->P();
107 Float_t eta = part->Eta();
108 Float_t phi = part->Phi();
110 // Fast simulation of TPC if requested
111 if (((AliJetKineReaderHeader*)fReaderHeader)->FastSimTPC()) {
112 // Charged particles only
114 TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
115 if (charge == 0) continue;
116 // Simulate efficiency
117 if (!Efficiency(p0, eta, phi)) continue;
118 // Simulate resolution
119 p = SmearMomentum(4, p0);
122 // Fast simulation of EMCAL if requested
123 if (((AliJetKineReaderHeader*)fReaderHeader)->FastSimEMCAL()) {
125 TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
126 // Charged particles only
128 // Simulate efficiency
129 if (!Efficiency(p0, eta, phi)) continue;
130 // Simulate resolution
131 p = SmearMomentum(4, p0);
132 } // end "if" charged particles
133 // Neutral particles (exclude K0L, n, nbar)
134 if (pdg == kNeutron || pdg == kK0Long) continue;
137 // Fill momentum array
139 Float_t px = r * part->Px();
140 Float_t py = r * part->Py();
141 Float_t pz = r * part->Pz();
142 Float_t m = part->GetMass();
143 Float_t e = TMath::Sqrt(px * px + py * py + pz * pz + m * m);
144 p4 = TLorentzVector(px, py, pz, e);
145 if ( (p4.Eta()>etaMax) || (p4.Eta()<etaMin)) continue;
146 new ((*fMomentumArray)[goodTrack]) TLorentzVector(p4);
148 // all tracks are signal ... ?
151 if (pt > ptMin) cflag[goodTrack] = 1; // track surviving pt cut
155 // set the signal flags
156 fSignalFlag.Set(goodTrack, sflag);
157 fCutFlag.Set(goodTrack, cflag);
158 AliInfo(Form("\n In event %d, number of good tracks %d \n", event, goodTrack));
167 Float_t AliJetKineReader::SmearMomentum(Int_t ind, Float_t p)
169 // The relative momentum error, i.e.
170 // (delta p)/p = sqrt (a**2 + (b*p)**2) * 10**-2,
171 // where typically a = 0.75 and b = 0.16 - 0.24 depending on multiplicity
172 // (the lower value is for dn/d(eta) about 2000, and the higher one for 8000)
174 // If we include information from TRD, b will be a factor 2/3 smaller.
176 // ind = 1: high multiplicity
177 // ind = 2: low multiplicity
178 // ind = 3: high multiplicity + TRD
179 // ind = 4: low multiplicity + TRD
185 if (ind == 1) b = 0.12;
186 if (ind == 2) b = 0.08;
187 if (ind == 3) b = 0.12;
188 if (ind == 4) b = 0.08;
190 Float_t sigma = p * TMath::Sqrt(a * a + b * b * p * p)*0.01;
191 pSmeared = p + gRandom->Gaus(0., sigma);
196 Bool_t AliJetKineReader::Efficiency(Float_t p, Float_t /*eta*/, Float_t phi)
198 // Fast simulation of geometrical acceptance and tracking efficiency
202 if (p < 0.5) eff -= (0.5-p)*0.2/0.3;
205 phi *= 180. / TMath::Pi();
206 // Sector number 0 - 17
207 Int_t isec = Int_t(phi / 20.);
209 Float_t phi0 = isec * 20. + 10.;
210 Float_t phir = TMath::Abs(phi-phi0);
211 // 2 deg of dead space
212 if (phir > 9.) eff = 0.;
215 if (gRandom->Rndm() > eff) {
223 TClonesArray* AliJetKineReader::GetGeneratedJets()
226 // Get generated jets from mc header
229 fGenJets = new TClonesArray("AliAODJets", 100);
235 AliHeader* alih = GetAliHeader();
236 if (alih == 0) return 0;
237 AliGenEventHeader * genh = alih->GenEventHeader();
238 if (genh == 0) return 0;
240 Int_t nj =((AliGenPythiaEventHeader*)genh)->NTriggerJets();
241 for (Int_t i = 0; i < nj; i++) {
243 ((AliGenPythiaEventHeader*)genh)->TriggerJet(i,p);
244 new ((*fGenJets)[i]) AliAODJet(p[0], p[1], p[2], p[3]);
250 void AliJetKineReader::SetInputEvent(TObject* /*esd*/, TObject* /*aod*/, TObject* mc)
252 // Connect the input event
253 fMCEventHandler = (AliMCEventHandler*) mc;