]>
Commit | Line | Data |
---|---|---|
99e5fe42 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | ||
83a444b1 | 16 | //------------------------------------------------------------------------- |
99e5fe42 | 17 | // Jet kinematics reader |
18 | // MC reader for jet analysis | |
83a444b1 | 19 | // Author: Andreas Morsch (andreas.morsch@cern.ch) |
20 | //------------------------------------------------------------------------- | |
99e5fe42 | 21 | |
22 | // From root ... | |
23 | #include <TClonesArray.h> | |
24 | #include <TPDGCode.h> | |
25 | #include <TParticle.h> | |
26 | #include <TParticlePDG.h> | |
99e5fe42 | 27 | #include <TLorentzVector.h> |
28 | #include <TSystem.h> | |
29 | #include <TDatabasePDG.h> | |
30 | #include <TRandom.h> | |
31 | // From AliRoot ... | |
85575952 | 32 | #include "AliAODJet.h" |
99e5fe42 | 33 | #include "AliJetKineReaderHeader.h" |
34 | #include "AliJetKineReader.h" | |
85575952 | 35 | #include "AliMCEventHandler.h" |
99e5fe42 | 36 | #include "AliStack.h" |
0ffa8579 | 37 | #include "AliHeader.h" |
38 | #include "AliGenPythiaEventHeader.h" | |
85575952 | 39 | #include "AliLog.h" |
99e5fe42 | 40 | |
41 | ClassImp(AliJetKineReader) | |
42 | ||
1b7d5d7e | 43 | AliJetKineReader::AliJetKineReader(): |
b45b0c92 | 44 | AliJetReader(), |
85575952 | 45 | fAliHeader(0), |
46 | fMCEventHandler(0), | |
47 | fGenJets(0) | |
99e5fe42 | 48 | { |
1b7d5d7e | 49 | // Default constructor |
99e5fe42 | 50 | } |
51 | ||
52 | //____________________________________________________________________________ | |
53 | ||
54 | AliJetKineReader::~AliJetKineReader() | |
55 | { | |
56 | // Destructor | |
0ffa8579 | 57 | delete fAliHeader; |
99e5fe42 | 58 | } |
59 | ||
60 | //____________________________________________________________________________ | |
61 | ||
62 | void AliJetKineReader::OpenInputFiles() | |
63 | { | |
83a444b1 | 64 | // Opens the input file using the run loader |
85575952 | 65 | // Not used anymore |
99e5fe42 | 66 | } |
67 | ||
68 | //____________________________________________________________________________ | |
69 | ||
0ffa8579 | 70 | Bool_t AliJetKineReader::FillMomentumArray(Int_t event) |
99e5fe42 | 71 | { |
83a444b1 | 72 | // Fill momentum array for event |
85575952 | 73 | Int_t goodTrack = 0; |
74 | // Clear array | |
75 | // temporary storage of signal and cut flags | |
76 | Int_t* sflag = new Int_t[50000]; | |
77 | Int_t* cflag = new Int_t[50000]; | |
83a444b1 | 78 | |
85575952 | 79 | ClearArray(); |
80 | // Get the stack | |
81 | AliStack* stack = fMCEventHandler->Stack(); | |
82 | // Number of primaries | |
83 | Int_t nt = stack->GetNprimary(); | |
4faf4c3d | 84 | |
85575952 | 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(); | |
4faf4c3d | 90 | |
85575952 | 91 | |
92 | TLorentzVector p4; | |
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(); | |
4faf4c3d | 99 | |
85575952 | 100 | // Skip non-final state particles, neutrinos |
101 | // and particles with pt < pt_min | |
102 | if ((status != 1) | |
103 | || (pdg == 12 || pdg == 14 || pdg == 16)) continue; | |
104 | ||
105 | Float_t p = part->P(); | |
106 | Float_t p0 = p; | |
107 | Float_t eta = part->Eta(); | |
108 | Float_t phi = part->Phi(); | |
109 | ||
110 | // Fast simulation of TPC if requested | |
111 | if (((AliJetKineReaderHeader*)fReaderHeader)->FastSimTPC()) { | |
112 | // Charged particles only | |
113 | Float_t charge = | |
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); | |
120 | } // End fast TPC | |
4faf4c3d | 121 | |
122 | // Fast simulation of EMCAL if requested | |
85575952 | 123 | if (((AliJetKineReaderHeader*)fReaderHeader)->FastSimEMCAL()) { |
124 | Float_t charge = | |
125 | TDatabasePDG::Instance()->GetParticle(pdg)->Charge(); | |
126 | // Charged particles only | |
127 | if (charge != 0){ | |
128 | // Simulate efficiency | |
129 | if (!Efficiency(p0, eta, phi)) continue; | |
130 | // Simulate resolution | |
131 | p = SmearMomentum(4, p0); | |
132 | } // end "if" charged particles | |
4faf4c3d | 133 | // Neutral particles (exclude K0L, n, nbar) |
85575952 | 134 | if (pdg == kNeutron || pdg == kK0Long) continue; |
135 | } // End fast EMCAL | |
136 | ||
4faf4c3d | 137 | // Fill momentum array |
85575952 | 138 | Float_t r = p/p0; |
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); | |
147 | ||
148 | // all tracks are signal ... ? | |
149 | sflag[goodTrack]=1; | |
150 | cflag[goodTrack]=0; | |
151 | if (pt > ptMin) cflag[goodTrack] = 1; // track surviving pt cut | |
152 | goodTrack++; | |
153 | } // track loop | |
154 | ||
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)); | |
159 | ||
160 | delete[] sflag; | |
161 | delete[] cflag; | |
162 | ||
163 | return kTRUE; | |
99e5fe42 | 164 | } |
165 | ||
166 | ||
48bb52d8 | 167 | Float_t AliJetKineReader::SmearMomentum(Int_t ind, Float_t p) |
168 | { | |
83a444b1 | 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) | |
173 | // | |
174 | // If we include information from TRD, b will be a factor 2/3 smaller. | |
175 | // | |
176 | // ind = 1: high multiplicity | |
177 | // ind = 2: low multiplicity | |
178 | // ind = 3: high multiplicity + TRD | |
179 | // ind = 4: low multiplicity + TRD | |
180 | ||
181 | Float_t pSmeared; | |
182 | Float_t a = 0.75; | |
183 | Float_t b = 0.12; | |
184 | ||
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; | |
189 | ||
190 | Float_t sigma = p * TMath::Sqrt(a * a + b * b * p * p)*0.01; | |
191 | pSmeared = p + gRandom->Gaus(0., sigma); | |
192 | return pSmeared; | |
48bb52d8 | 193 | } |
83a444b1 | 194 | |
195 | ||
48bb52d8 | 196 | Bool_t AliJetKineReader::Efficiency(Float_t p, Float_t /*eta*/, Float_t phi) |
197 | { | |
83a444b1 | 198 | // Fast simulation of geometrical acceptance and tracking efficiency |
199 | ||
200 | // Tracking | |
201 | Float_t eff = 0.99; | |
202 | if (p < 0.5) eff -= (0.5-p)*0.2/0.3; | |
203 | // Geometry | |
204 | if (p > 0.5) { | |
205 | phi *= 180. / TMath::Pi(); | |
206 | // Sector number 0 - 17 | |
207 | Int_t isec = Int_t(phi / 20.); | |
208 | // Sector centre | |
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.; | |
213 | } | |
214 | ||
215 | if (gRandom->Rndm() > eff) { | |
216 | return kFALSE; | |
217 | } else { | |
218 | return kTRUE; | |
219 | } | |
220 | ||
48bb52d8 | 221 | } |
222 | ||
85575952 | 223 | TClonesArray* AliJetKineReader::GetGeneratedJets() |
0ffa8579 | 224 | { |
85575952 | 225 | // |
0ffa8579 | 226 | // Get generated jets from mc header |
85575952 | 227 | // |
228 | if (!fGenJets) { | |
229 | fGenJets = new TClonesArray("AliAODJets", 100); | |
230 | } else { | |
231 | fGenJets->Clear(); | |
232 | } | |
233 | ||
234 | ||
0ffa8579 | 235 | AliHeader* alih = GetAliHeader(); |
85575952 | 236 | if (alih == 0) return 0; |
0ffa8579 | 237 | AliGenEventHeader * genh = alih->GenEventHeader(); |
85575952 | 238 | if (genh == 0) return 0; |
239 | ||
0ffa8579 | 240 | Int_t nj =((AliGenPythiaEventHeader*)genh)->NTriggerJets(); |
85575952 | 241 | for (Int_t i = 0; i < nj; i++) { |
0ffa8579 | 242 | Float_t p[4]; |
243 | ((AliGenPythiaEventHeader*)genh)->TriggerJet(i,p); | |
85575952 | 244 | new ((*fGenJets)[i]) AliAODJet(p[0], p[1], p[2], p[3]); |
0ffa8579 | 245 | } |
85575952 | 246 | |
247 | return fGenJets; | |
248 | } | |
249 | ||
250 | void AliJetKineReader::SetInputEvent(TObject* /*esd*/, TObject* /*aod*/, TObject* mc) | |
251 | { | |
252 | // Connect the input event | |
253 | fMCEventHandler = (AliMCEventHandler*) mc; | |
0ffa8579 | 254 | } |