]>
Commit | Line | Data |
---|---|---|
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 | ||
16 | //------------------------------------------------------------------------- | |
17 | // Jet kinematics reader | |
18 | // MC reader for jet analysis | |
19 | // Author: Andreas Morsch (andreas.morsch@cern.ch) | |
20 | //------------------------------------------------------------------------- | |
21 | ||
22 | // From root ... | |
23 | #include <TClonesArray.h> | |
24 | #include <TPDGCode.h> | |
25 | #include <TParticle.h> | |
26 | #include <TParticlePDG.h> | |
27 | #include <TLorentzVector.h> | |
28 | #include <TSystem.h> | |
29 | #include <TDatabasePDG.h> | |
30 | #include <TRandom.h> | |
31 | // From AliRoot ... | |
32 | #include "AliAODJet.h" | |
33 | #include "AliJetKineReaderHeader.h" | |
34 | #include "AliJetKineReader.h" | |
35 | #include "AliMCEventHandler.h" | |
36 | #include "AliStack.h" | |
37 | #include "AliHeader.h" | |
38 | #include "AliGenPythiaEventHeader.h" | |
39 | #include "AliLog.h" | |
40 | ||
41 | ClassImp(AliJetKineReader) | |
42 | ||
43 | AliJetKineReader::AliJetKineReader(): | |
44 | AliJetReader(), | |
45 | fAliHeader(0), | |
46 | fMCEventHandler(0), | |
47 | fGenJets(0) | |
48 | { | |
49 | // Default constructor | |
50 | } | |
51 | ||
52 | //____________________________________________________________________________ | |
53 | ||
54 | AliJetKineReader::~AliJetKineReader() | |
55 | { | |
56 | // Destructor | |
57 | delete fAliHeader; | |
58 | } | |
59 | ||
60 | //____________________________________________________________________________ | |
61 | ||
62 | void AliJetKineReader::OpenInputFiles() | |
63 | { | |
64 | // Opens the input file using the run loader | |
65 | // Not used anymore | |
66 | } | |
67 | ||
68 | //____________________________________________________________________________ | |
69 | ||
70 | Bool_t AliJetKineReader::FillMomentumArray(Int_t event) | |
71 | { | |
72 | // Fill momentum array for event | |
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]; | |
78 | ||
79 | ClearArray(); | |
80 | // Get the stack | |
81 | AliStack* stack = fMCEventHandler->Stack(); | |
82 | // Number of primaries | |
83 | Int_t nt = stack->GetNprimary(); | |
84 | ||
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(); | |
90 | ||
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(); | |
99 | ||
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 | |
121 | ||
122 | // Fast simulation of EMCAL if requested | |
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 | |
133 | // Neutral particles (exclude K0L, n, nbar) | |
134 | if (pdg == kNeutron || pdg == kK0Long) continue; | |
135 | } // End fast EMCAL | |
136 | ||
137 | // Fill momentum array | |
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; | |
164 | } | |
165 | ||
166 | ||
167 | Float_t AliJetKineReader::SmearMomentum(Int_t ind, Float_t p) | |
168 | { | |
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; | |
193 | } | |
194 | ||
195 | ||
196 | Bool_t AliJetKineReader::Efficiency(Float_t p, Float_t /*eta*/, Float_t phi) | |
197 | { | |
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 | ||
221 | } | |
222 | ||
223 | TClonesArray* AliJetKineReader::GetGeneratedJets() | |
224 | { | |
225 | // | |
226 | // Get generated jets from mc header | |
227 | // | |
228 | if (!fGenJets) { | |
229 | fGenJets = new TClonesArray("AliAODJets", 100); | |
230 | } else { | |
231 | fGenJets->Clear(); | |
232 | } | |
233 | ||
234 | ||
235 | AliHeader* alih = GetAliHeader(); | |
236 | if (alih == 0) return 0; | |
237 | AliGenEventHeader * genh = alih->GenEventHeader(); | |
238 | if (genh == 0) return 0; | |
239 | ||
240 | Int_t nj =((AliGenPythiaEventHeader*)genh)->NTriggerJets(); | |
241 | for (Int_t i = 0; i < nj; i++) { | |
242 | Float_t p[4]; | |
243 | ((AliGenPythiaEventHeader*)genh)->TriggerJet(i,p); | |
244 | new ((*fGenJets)[i]) AliAODJet(p[0], p[1], p[2], p[3]); | |
245 | } | |
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; | |
254 | } |