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>
34 #include "AliJetKineReaderHeader.h"
35 #include "AliJetKineReader.h"
36 #include "AliRunLoader.h"
38 #include "AliHeader.h"
39 #include "AliGenPythiaEventHeader.h"
41 ClassImp(AliJetKineReader)
43 AliJetKineReader::AliJetKineReader():
48 // Default constructor
51 //____________________________________________________________________________
53 AliJetKineReader::~AliJetKineReader()
59 //____________________________________________________________________________
61 void AliJetKineReader::OpenInputFiles()
63 // Opens the input file using the run loader
64 const char* dirName = fReaderHeader->GetDirectory();
66 sprintf(path, "%s/galice.root",dirName);
67 fRunLoader = AliRunLoader::Open(path);
68 fRunLoader->LoadKinematics();
69 fRunLoader->LoadHeader();
71 // get number of events
72 Int_t nMax = fRunLoader->GetNumberOfEvents();
73 printf("\nTotal number of events = %d", nMax);
75 // set number of events in header
76 if (fReaderHeader->GetLastEvent() == -1)
77 fReaderHeader->SetLastEvent(nMax);
79 Int_t nUsr = fReaderHeader->GetLastEvent();
80 fReaderHeader->SetLastEvent(TMath::Min(nMax, nUsr));
84 //____________________________________________________________________________
86 Bool_t AliJetKineReader::FillMomentumArray(Int_t event)
88 // Fill momentum array for event
93 // Get event from runloader
94 fRunLoader->GetEvent(event);
96 AliStack* stack = fRunLoader->Stack();
97 // Number of primaries
98 Int_t nt = stack->GetNprimary();
100 // Get cuts set by user and header
101 Double_t ptMin = ((AliJetKineReaderHeader*) fReaderHeader)->GetPtCut();
102 Float_t etaMin = fReaderHeader->GetFiducialEtaMin();
103 Float_t etaMax = fReaderHeader->GetFiducialEtaMax();
104 fAliHeader = fRunLoader->GetHeader();
106 // temporary storage of signal and cut flags
107 Int_t* sflag = new Int_t[nt];
108 Int_t* cflag = new Int_t[nt];
111 // Loop over particles
112 for (Int_t it = 0; it < nt; it++) {
113 TParticle *part = stack->Particle(it);
114 Int_t status = part->GetStatusCode();
115 Int_t pdg = TMath::Abs(part->GetPdgCode());
116 Float_t pt = part->Pt();
118 // Skip non-final state particles, neutrinos
119 // and particles with pt < pt_min
121 || (pdg == 12 || pdg == 14 || pdg == 16)) continue;
123 Float_t p = part->P();
125 Float_t eta = part->Eta();
126 Float_t phi = part->Phi();
128 // Fast simulation of TPC if requested
129 if (((AliJetKineReaderHeader*)fReaderHeader)->FastSimTPC()) {
130 // Charged particles only
132 TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
133 if (charge == 0) continue;
134 // Simulate efficiency
135 if (!Efficiency(p0, eta, phi)) continue;
136 // Simulate resolution
137 p = SmearMomentum(4, p0);
140 // Fast simulation of EMCAL if requested
141 if (((AliJetKineReaderHeader*)fReaderHeader)->FastSimEMCAL()) {
143 TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
144 // Charged particles only
146 // Simulate efficiency
147 if (!Efficiency(p0, eta, phi)) continue;
148 // Simulate resolution
149 p = SmearMomentum(4, p0);
150 } // end "if" charged particles
151 // Neutral particles (exclude K0L, n, nbar)
152 if (pdg == kNeutron || pdg == kK0Long) continue;
155 // Fill momentum array
157 Float_t px = r * part->Px();
158 Float_t py = r * part->Py();
159 Float_t pz = r * part->Pz();
160 Float_t m = part->GetMass();
161 Float_t e = TMath::Sqrt(px * px + py * py + pz * pz + m * m);
162 p4 = TLorentzVector(px, py, pz, e);
163 if ( (p4.Eta()>etaMax) || (p4.Eta()<etaMin)) continue;
164 new ((*fMomentumArray)[goodTrack]) TLorentzVector(p4);
166 // all tracks are signal ... ?
169 if (pt > ptMin) cflag[goodTrack]=1; // track surviving pt cut
173 // set the signal flags
174 fSignalFlag.Set(goodTrack,sflag);
175 fCutFlag.Set(goodTrack,cflag);
176 printf("\nIn event %d, number of good tracks %d \n", event, goodTrack);
181 Float_t AliJetKineReader::SmearMomentum(Int_t ind, Float_t p)
183 // The relative momentum error, i.e.
184 // (delta p)/p = sqrt (a**2 + (b*p)**2) * 10**-2,
185 // where typically a = 0.75 and b = 0.16 - 0.24 depending on multiplicity
186 // (the lower value is for dn/d(eta) about 2000, and the higher one for 8000)
188 // If we include information from TRD, b will be a factor 2/3 smaller.
190 // ind = 1: high multiplicity
191 // ind = 2: low multiplicity
192 // ind = 3: high multiplicity + TRD
193 // ind = 4: low multiplicity + TRD
199 if (ind == 1) b = 0.12;
200 if (ind == 2) b = 0.08;
201 if (ind == 3) b = 0.12;
202 if (ind == 4) b = 0.08;
204 Float_t sigma = p * TMath::Sqrt(a * a + b * b * p * p)*0.01;
205 pSmeared = p + gRandom->Gaus(0., sigma);
210 Bool_t AliJetKineReader::Efficiency(Float_t p, Float_t /*eta*/, Float_t phi)
212 // Fast simulation of geometrical acceptance and tracking efficiency
216 if (p < 0.5) eff -= (0.5-p)*0.2/0.3;
219 phi *= 180. / TMath::Pi();
220 // Sector number 0 - 17
221 Int_t isec = Int_t(phi / 20.);
223 Float_t phi0 = isec * 20. + 10.;
224 Float_t phir = TMath::Abs(phi-phi0);
225 // 2 deg of dead space
226 if (phir > 9.) eff = 0.;
229 if (gRandom->Rndm() > eff) {
237 Bool_t AliJetKineReader::GetGenJets(AliJet* genJets)
239 // Get generated jets from mc header
240 AliHeader* alih = GetAliHeader();
241 if (alih == 0) return kFALSE;
242 AliGenEventHeader * genh = alih->GenEventHeader();
243 if (genh == 0) return kFALSE;
244 Int_t nj =((AliGenPythiaEventHeader*)genh)->NTriggerJets();
245 Int_t* m = new Int_t[nj];
246 Int_t* k = new Int_t[nj];
247 for (Int_t i=0; i< nj; i++) {
249 ((AliGenPythiaEventHeader*)genh)->TriggerJet(i,p);
250 genJets->AddJet(p[0],p[1],p[2],p[3]);
254 genJets->SetNinput(nj);
255 genJets->SetMultiplicities(m);
256 genJets->SetInJet(k);