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 **************************************************************************/
18 //--------------------------------------------------
19 // Filling of CalTrkTrack objects in the MC reader task
21 // Author: magali.estienne@subatech.in2p3.fr
22 // alexandre.shabetai@cern.ch
23 //-------------------------------------------------
25 // --- ROOT system ---
26 #include <TDatabasePDG.h>
30 // --- AliRoot system ---
31 #include "AliJetFillCalTrkTrackMC.h"
32 #include "AliAODMCParticle.h"
33 #include "AliJetKineReaderHeader.h"
34 #include "AliVEvent.h"
35 #include "AliMCEvent.h"
37 ClassImp(AliJetFillCalTrkTrackMC)
39 /////////////////////////////////////////////////////////////////////////
41 AliJetFillCalTrkTrackMC::AliJetFillCalTrkTrackMC():
42 AliJetFillCalTrkEvent(),
44 fApplyMIPCorrection(kTRUE),
51 //-----------------------------------------------------------------------
52 AliJetFillCalTrkTrackMC::AliJetFillCalTrkTrackMC(AliVEvent* evt):
53 AliJetFillCalTrkEvent(),
55 fApplyMIPCorrection(kTRUE),
62 //-----------------------------------------------------------------------
63 AliJetFillCalTrkTrackMC::AliJetFillCalTrkTrackMC(const AliJetFillCalTrkTrackMC &det):
64 AliJetFillCalTrkEvent(det),
65 fHadCorr(det.fHadCorr),
66 fApplyMIPCorrection(det.fApplyMIPCorrection),
68 fMCEvent(det.fMCEvent)
73 //-----------------------------------------------------------------------
74 AliJetFillCalTrkTrackMC& AliJetFillCalTrkTrackMC::operator=(const AliJetFillCalTrkTrackMC& other)
78 fHadCorr = other.fHadCorr;
79 fApplyMIPCorrection = other.fApplyMIPCorrection;
81 fMCEvent = other.fMCEvent;
88 //-----------------------------------------------------------------------
89 AliJetFillCalTrkTrackMC::~AliJetFillCalTrkTrackMC()
94 //-----------------------------------------------------------------------
95 void AliJetFillCalTrkTrackMC::Exec(Option_t* const /*option*/)
98 // Fill AliJetFillCalTrkTrackMC the with the charged particle information
100 fDebug = fReaderHeader->GetDebug();
101 fOpt = fReaderHeader->GetDetector();
102 TString datatype = fReaderHeader->GetDataType();
107 if (datatype.Contains("AODMC2B")) { type=kTrackAODMCChargedAcceptance; }
108 else if (datatype.Contains("AODMC2")) { type=kTrackAODMCCharged; }
109 else if (datatype.Contains("AODMC")) { type=kTrackAODMCAll; }
111 else if (!datatype.Contains("AOD") && datatype.Contains("MC2")) {type=kTrackKineCharged;}
112 else if (!datatype.Contains("AOD") && datatype.Contains("MC")) {type=kTrackKineAll;}
114 else { cout<< "Unknown Data type !" << endl; }
116 // temporary storage of signal and pt cut flag
120 // get cuts set by user
121 Float_t ptMin = fReaderHeader->GetPtCut();
122 Float_t etaMin = fReaderHeader->GetFiducialEtaMin();
123 Float_t etaMax = fReaderHeader->GetFiducialEtaMax();
124 Float_t phiMin = fReaderHeader->GetFiducialPhiMin();
125 Float_t phiMax = fReaderHeader->GetFiducialPhiMax();
127 if(fDebug>2) Printf("%s:%d Selecting tracks with %d",(char*)__FILE__,__LINE__,type);
129 Int_t goodTrackStd = 0;
130 Int_t goodTrackNonStd = 0;
132 if (type == kTrackKineAll || type == kTrackKineCharged){
137 else if (type == kTrackAODMCCharged || type == kTrackAODMCAll || type == kTrackAODMCChargedAcceptance) {
139 TClonesArray *mcArray = dynamic_cast<TClonesArray*>(fVEvt->FindListObject(AliAODMCParticle::StdBranchName()));
141 Printf("%s:%d No MC particle branch found",(char*)__FILE__,__LINE__);
144 for(int it = 0;it < mcArray->GetEntriesFast();++it){
146 AliAODMCParticle *part = (AliAODMCParticle*)(mcArray->At(it));
147 if(!part->IsPhysicalPrimary())continue;
148 Int_t pdg = TMath::Abs(part->GetPdgCode());
149 // exclude neutrinos anyway
150 if((pdg == 12 || pdg == 14 || pdg == 16)) continue;
151 cflag = ( part->Pt()>ptMin ) ? 1 : 0;
152 sflag = ( TMath::Abs(part->GetLabel()) < 10000 ) ? 1 : 0;
153 if(type == kTrackAODMCAll){
154 fCalTrkEvent->AddCalTrkTrack(part,cflag,sflag);
157 else if (type == kTrackAODMCCharged || type == kTrackAODMCChargedAcceptance ){
158 if(part->Charge()==0)continue;
159 if(kTrackAODMCCharged){
160 fCalTrkEvent->AddCalTrkTrack(part,cflag,sflag);
164 if((part->Eta()>etaMax) || (part->Eta()<etaMin)) continue;
165 Float_t phi = ( (part->Phi()) < 0) ? (part->Phi()) + 2. * TMath::Pi() : (part->Phi());
166 if((phi>phiMax) || (phi<phiMin)) continue;
167 fCalTrkEvent->AddCalTrkTrack(part,cflag,sflag);
172 if(fDebug>0) printf("Number of good tracks selected: %5d \n", goodTrackStd+goodTrackNonStd);
177 //-----------------------------------------------------------------------
178 Bool_t AliJetFillCalTrkTrackMC::FillKine()
184 if(!fMCEvent) {cout<<"could not get MCEvent!"<<endl; return kFALSE;}
186 Int_t nt = fMCEvent->GetNumberOfTracks();
188 // Get cuts set by user and header
189 Double_t ptMin = ((AliJetKineReaderHeader*) fReaderHeader)->GetPtCut();
190 Float_t etaMin = fReaderHeader->GetFiducialEtaMin();
191 Float_t etaMax = fReaderHeader->GetFiducialEtaMax();
194 // Loop over particles
195 for (Int_t it = 0; it < nt; it++) {
196 if(!fMCEvent->IsPhysicalPrimary(it)) continue;
197 AliVParticle* part = fMCEvent->GetTrack(it);
198 Int_t pdg = TMath::Abs(part->PdgCode());
199 Float_t pt = part->Pt();
201 if( (pdg == 12 || pdg == 14 || pdg == 16)) continue;
203 Float_t p = part->P();
205 Float_t eta = part->Eta();
206 Float_t phi = part->Phi();
207 Float_t charge = part->Charge();
209 if (((AliJetKineReaderHeader*)fReaderHeader)->ChargedOnly()) {
210 if (charge == 0) continue;
211 } // End charged only
213 // Fast simulation of EMCAL if requested
214 if (((AliJetKineReaderHeader*)fReaderHeader)->FastSimEMCAL()) {
215 // Charged particles only
217 // Simulate efficiency
218 if (!Efficiency(p0, eta, phi)) continue;
219 // Simulate resolution
220 p = SmearMomentum(4, p0);
221 } // end "if" charged particles
222 // Neutral particles (exclude K0L, n, nbar)
223 if (pdg == kNeutron || pdg == kK0Long) continue;
226 // Fast simulation of TPC if requested
227 if (((AliJetKineReaderHeader*)fReaderHeader)->FastSimTPC()) {
228 // Charged particles only
229 if (charge == 0) continue;
230 // Simulate efficiency
231 if (!Efficiency(p0, eta, phi)) continue;
232 // Simulate resolution
233 p = SmearMomentum(4, p0);
236 // Fill momentum array
238 Float_t px = r * part->Px();
239 Float_t py = r * part->Py();
240 Float_t pz = r * part->Pz();
241 Float_t m = part->M();
243 Float_t e = TMath::Sqrt(px * px + py * py + pz * pz + m * m);
244 p4 = TLorentzVector(px, py, pz, e);
245 if ((p4.Eta()>etaMax) || (p4.Eta()<etaMin)) continue;
247 // Flag used to store the r factor
249 Bool_t cflag = kFALSE, sflag = kTRUE;
250 if (pt > ptMin) cflag = kTRUE; // track surviving pt cut
252 fCalTrkEvent->AddCalTrkTrackKine(part,cflag,sflag,ptReso);
258 if(fDebug>0) printf(" Number of good tracks %d \n", goodTrack);
264 //-----------------------------------------------------------------------
265 Float_t AliJetFillCalTrkTrackMC::SmearMomentum(Int_t ind, Float_t p)
267 // The relative momentum error, i.e.
268 // (delta p)/p = sqrt (a**2 + (b*p)**2) * 10**-2,
269 // where typically a = 0.75 and b = 0.16 - 0.24 depending on multiplicity
270 // (the lower value is for dn/d(eta) about 2000, and the higher one for 8000)
272 // If we include information from TRD, b will be a factor 2/3 smaller.
274 // ind = 1: high multiplicity
275 // ind = 2: low multiplicity
276 // ind = 3: high multiplicity + TRD
277 // ind = 4: low multiplicity + TRD
283 if (ind == 1) b = 0.12;
284 if (ind == 2) b = 0.08;
285 if (ind == 3) b = 0.12;
286 if (ind == 4) b = 0.08;
288 Float_t sigma = p * TMath::Sqrt(a * a + b * b * p * p)*0.01;
289 pSmeared = p + gRandom->Gaus(0., sigma);
294 //-----------------------------------------------------------------------
295 Bool_t AliJetFillCalTrkTrackMC::Efficiency(Float_t p, Float_t /*eta*/, Float_t phi)
297 // Fast simulation of geometrical acceptance and tracking efficiency
301 if (p < 0.5) eff -= (0.5-p)*0.2/0.3;
304 phi *= 180. / TMath::Pi();
305 // Sector number 0 - 17
306 Int_t isec = Int_t(phi / 20.);
308 Float_t phi0 = isec * 20. + 10.;
309 Float_t phir = TMath::Abs(phi-phi0);
310 // 2 deg of dead space
311 if (phir > 9.) eff = 0.;
314 if (gRandom->Rndm() > eff) {