1 //_________________________________________________________________________
2 // Utility Class for transverse energy studies
3 // Base class for MC analysis
7 //*-- Authors: Oystein Djuvsland (Bergen), David Silvermyr (ORNL)
8 //_________________________________________________________________________
10 #include "AliAnalysisEtMonteCarlo.h"
11 #include "AliAnalysisEtCuts.h"
12 #include "AliESDtrack.h"
14 #include "AliMCEvent.h"
16 #include "TParticle.h"
17 #include "AliGenHijingEventHeader.h"
18 #include "AliGenPythiaEventHeader.h"
22 ClassImp(AliAnalysisEtMonteCarlo);
26 AliAnalysisEtMonteCarlo::AliAnalysisEtMonteCarlo() :
35 AliAnalysisEtMonteCarlo::~AliAnalysisEtMonteCarlo()
39 Int_t AliAnalysisEtMonteCarlo::AnalyseEvent(AliVEvent* ev)
44 AliMCEvent *event = dynamic_cast<AliMCEvent*>(ev);
46 Double_t protonMass =fgProtonMass;
49 AliGenEventHeader* genHeader = event->GenEventHeader();
50 AliGenHijingEventHeader* hijingGenHeader = dynamic_cast<AliGenHijingEventHeader*>(genHeader);
51 if (hijingGenHeader) {
52 fImpactParameter = hijingGenHeader->ImpactParameter();
53 fNcoll = hijingGenHeader->HardScatters(); // or should this be some combination of NN() NNw() NwN() NwNw() ?
54 fNpart = hijingGenHeader->ProjectileParticipants() + hijingGenHeader->TargetParticipants();
56 printf("Hijing: ImpactParameter %g ReactionPlaneAngle %g \n",
57 hijingGenHeader->ImpactParameter(), hijingGenHeader->ReactionPlaneAngle());
58 printf("HardScatters %d ProjecileParticipants %d TargetParticipants %d\n",
59 hijingGenHeader->HardScatters(), hijingGenHeader->ProjectileParticipants(), hijingGenHeader->TargetParticipants());
60 printf("ProjSpectatorsn %d ProjSpectatorsp %d TargSpectatorsn %d TargSpectatorsp %d\n",
61 hijingGenHeader->ProjSpectatorsn(), hijingGenHeader->ProjSpectatorsp(), hijingGenHeader->TargSpectatorsn(), hijingGenHeader->TargSpectatorsp());
62 printf("NN %d NNw %d NwN %d, NwNw %d\n",
63 hijingGenHeader->NN(), hijingGenHeader->NNw(), hijingGenHeader->NwN(), hijingGenHeader->NwNw());
67 /* // placeholder if we want to get some Pythia info later
68 AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(genHeader);
69 if (pythiaGenHeader) { // not Hijing; try with Pythia
70 printf("Pythia: ProcessType %d GetPtHard %g \n",
71 pythiaGenHeader->ProcessType(), pythiaGenHeader->GetPtHard());
75 // Let's play with the stack!
76 AliStack *stack = event->Stack();
78 Int_t nPrim = stack->GetNtrack();
80 for (Int_t iPart = 0; iPart < nPrim; iPart++)
83 TParticle *part = stack->Particle(iPart);
87 Printf("ERROR: Could not get particle %d", iPart);
91 TParticlePDG *pdg = part->GetPDG(0);
93 Double_t particleMassPart = 0; //The mass part in the Et calculation for this particle
95 // Check if it is a primary particle
96 if (!stack->IsPhysicalPrimary(iPart)) continue;
98 // printf("MC: iPart %03d eta %4.3f phi %4.3f code %d charge %g \n", iPart, part->Eta(), part->Phi(), pdg->PdgCode(), pdg->Charge()); // tmp/debug printout
100 // Check for reasonable (for now neutral and singly charged) charge on the particle
101 //TODO:Maybe not only singly charged?
102 if (TMath::Abs(TMath::Abs(pdg->Charge()) - fCuts->GetMonteCarloSingleChargedParticle())<1e-3 && TMath::Abs(TMath::Abs(pdg->Charge()) - fCuts->GetMonteCarloNeutralParticle())<1e-3) continue;
106 if (TMath::Abs(part->Eta()) < fCuts->GetCommonEtaCut())
110 TMath::Abs(pdg->PdgCode()) == fgProtonCode ||
111 TMath::Abs(pdg->PdgCode()) == fgNeutronCode ||
112 TMath::Abs(pdg->PdgCode()) == fgLambdaCode ||
113 TMath::Abs(pdg->PdgCode()) == fgXiCode ||
114 TMath::Abs(pdg->PdgCode()) == fgXi0Code ||
115 TMath::Abs(pdg->PdgCode()) == fgOmegaCode
118 if (pdg->PdgCode() > 0) { particleMassPart = - protonMass;}
119 if (pdg->PdgCode() < 0) { particleMassPart = protonMass;}
121 Double_t et = part->Energy() * TMath::Sin(part->Theta()) + particleMassPart;
123 if (pdg->PdgCode() == fgProtonCode || pdg->PdgCode() == fgAntiProtonCode)
127 if (pdg->PdgCode() == fgPiPlusCode || pdg->PdgCode() == fgPiMinusCode)
131 if (pdg->PdgCode() == fgKPlusCode || pdg->PdgCode() == fgKMinusCode)
133 fChargedKaonEt += et;
135 if (pdg->PdgCode() == fgMuPlusCode || pdg->PdgCode() == fgMuMinusCode)
139 if (pdg->PdgCode() == fgEPlusCode || pdg->PdgCode() == fgEMinusCode)
144 // some neutrals also
145 if(pdg->PdgCode() == fgNeutronCode)
149 if(pdg->PdgCode() == fgAntiNeutronCode)
151 fAntiNeutronEt += et;
153 if(pdg->PdgCode() == fgGammaCode)
158 if (TMath::Abs(pdg->Charge() - fCuts->GetMonteCarloNeutralParticle()) <1e-3 )
160 fNeutralMultiplicity++;
163 if (TMath::Abs(part->Eta()) < fEtaCutAcc && part->Phi() < fPhiCutAccMax && part->Phi() > fPhiCutAccMin)
165 fTotNeutralEtAcc += et;
169 else if (TMath::Abs( pdg->Charge() - fCuts->GetMonteCarloNeutralParticle())<1e-3 )
171 fChargedMultiplicity++;
173 if (TMath::Abs(part->Eta()) < fEtaCutAcc && part->Phi() < fPhiCutAccMax && part->Phi() > fPhiCutAccMin)
175 fTotChargedEtAcc += et;
179 if (pdg->PdgCode() == fgProtonCode || pdg->PdgCode() == fgAntiProtonCode)
183 if (pdg->PdgCode() == fgPiPlusCode || pdg->PdgCode() == fgPiMinusCode)
187 if (pdg->PdgCode() == fgKPlusCode || pdg->PdgCode() == fgKMinusCode)
189 fChargedKaonEtAcc += et;
191 if (pdg->PdgCode() == fgMuPlusCode || pdg->PdgCode() == fgMuMinusCode)
195 if (pdg->PdgCode() == fgEPlusCode || pdg->PdgCode() == fgEMinusCode)
197 fElectronEtAcc += et;
202 // if (TrackHitsCalorimeter(part, event->GetMagneticField()))
203 if (TrackHitsCalorimeter(part)) // magnetic field info not filled?
205 if (pdg->Charge() > 0) fHistPhivsPtPos->Fill(part->Phi(),part->Pt());
206 else fHistPhivsPtNeg->Fill(part->Phi(), part->Pt());
212 fTotEt = fTotChargedEt + fTotNeutralEt;
213 fTotEtAcc = fTotChargedEtAcc + fTotNeutralEtAcc;
220 void AliAnalysisEtMonteCarlo::Init()
222 AliAnalysisEt::Init();
225 void AliAnalysisEtMonteCarlo::ResetEventValues()
226 { // reset event values
227 AliAnalysisEt::ResetEventValues();
229 // collision geometry defaults for p+p:
230 fImpactParameter = 0;
235 void AliAnalysisEtMonteCarlo::CreateHistograms()
236 { // histogram related additions
237 AliAnalysisEt::CreateHistograms();
239 fTree->Branch("fImpactParameter",&fImpactParameter,"fImpactParameter/D");
240 fTree->Branch("fNcoll",&fNcoll,"fNcoll/I");
241 fTree->Branch("fNpart",&fNpart,"fNpart/I");
245 bool AliAnalysisEtMonteCarlo::TrackHitsCalorimeter(TParticle* part, Double_t magField)
247 // printf(" TrackHitsCalorimeter - magField %f\n", magField);
248 AliESDtrack *esdTrack = new AliESDtrack(part);
249 // Printf("MC Propagating track: eta: %f, phi: %f, pt: %f", esdTrack->Eta(), esdTrack->Phi(), esdTrack->Pt());
251 Bool_t prop = esdTrack->PropagateTo(fDetectorRadius, magField);
253 // if(prop) Printf("Track propagated, eta: %f, phi: %f, pt: %f", esdTrack->Eta(), esdTrack->Phi(), esdTrack->Pt());
255 bool status = prop &&
256 TMath::Abs(esdTrack->Eta()) < fEtaCutAcc &&
257 esdTrack->Phi() > fPhiCutAccMin*TMath::Pi()/180. &&
258 esdTrack->Phi() < fPhiCutAccMax*TMath::Pi()/180.;