3 #include "AliMultiplicityMCSelector.h"
13 #include <TParticle.h>
19 #include "esdTrackCuts/AliESDtrackCuts.h"
20 #include "AliPWG0Helper.h"
22 ClassImp(AliMultiplicityMCSelector)
24 AliMultiplicityMCSelector::AliMultiplicityMCSelector() :
32 // Constructor. Initialization of pointers
36 AliMultiplicityMCSelector::~AliMultiplicityMCSelector()
42 // histograms are in the output list and deleted when the output
43 // list is deleted by the TSelector dtor
46 void AliMultiplicityMCSelector::Begin(TTree* tree)
50 AliSelectorRL::Begin(tree);
52 ReadUserObjects(tree);
55 void AliMultiplicityMCSelector::ReadUserObjects(TTree* tree)
57 // read the user objects, called from slavebegin and begin
59 if (!fEsdTrackCuts && fInput)
60 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fInput->FindObject("AliESDtrackCuts"));
62 if (!fEsdTrackCuts && tree)
63 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (tree->GetUserInfo()->FindObject("AliESDtrackCuts"));
66 AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from input list.");
69 void AliMultiplicityMCSelector::SlaveBegin(TTree* tree)
71 // The SlaveBegin() function is called after the Begin() function.
72 // When running with PROOF SlaveBegin() is called on each slave server.
73 // The tree argument is deprecated (on PROOF 0 is passed).
75 AliSelector::SlaveBegin(tree);
77 ReadUserObjects(tree);
79 fMultiplicityESD = new TH1F("fMultiplicityESD", "fMultiplicityESD;Ntracks;Count", 201, -0.5, 200.5);
80 fMultiplicityMC = new TH1F("fMultiplicityMC", "fMultiplicityMC;Npart;Count", 201, -0.5, 200.5);
82 fCorrelation = new TH2F("fCorrelation", "fCorrelation;Npart;Ntracks", 201, -0.5, 200.5, 201, -0.5, 200.5);
85 Bool_t AliMultiplicityMCSelector::Process(Long64_t entry)
87 // The Process() function is called for each entry in the tree (or possibly
88 // keyed object in the case of PROOF) to be processed. The entry argument
89 // specifies which entry in the currently loaded tree is to be processed.
90 // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
91 // to read either all or the required parts of the data. When processing
92 // keyed objects with PROOF, the object is already loaded and is available
93 // via the fObject pointer.
95 // This function should contain the "body" of the analysis. It can contain
96 // simple or elaborate selection criteria, run algorithms on the data
97 // of the event and typically fill histograms.
99 // WARNING when a selector is used with a TChain, you must use
100 // the pointer to the current TTree to call GetEntry(entry).
101 // The entry is always the local entry number in the current tree.
102 // Assuming that fTree is the pointer to the TChain being processed,
103 // use fTree->GetTree()->GetEntry(entry).
105 if (AliSelectorRL::Process(entry) == kFALSE)
108 // Check prerequisites
111 AliDebug(AliLog::kError, "ESD branch not available");
117 AliDebug(AliLog::kError, "fESDTrackCuts not available");
121 AliStack* stack = GetStack();
124 AliDebug(AliLog::kError, "Stack not available");
128 if (AliPWG0Helper::IsEventTriggered(fESD) == kFALSE)
131 if (AliPWG0Helper::IsVertexReconstructed(fESD) == kFALSE)
136 // get number of "good" tracks from ESD
137 Int_t nESDTracks = fEsdTrackCuts->CountAcceptedTracks(fESD);
138 fMultiplicityESD->Fill(nESDTracks);
140 // get number of tracks from MC
141 // loop over mc particles
142 Int_t nPrim = stack->GetNprimary();
144 for (Int_t iMc = 0; iMc < nPrim; ++iMc)
146 AliDebug(AliLog::kDebug+1, Form("MC Loop: Processing particle %d.", iMc));
148 TParticle* particle = stack->Particle(iMc);
152 AliDebug(AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack (mc loop).", iMc));
156 if (AliPWG0Helper::IsPrimaryCharged(particle, nPrim) == kFALSE)
159 Float_t eta = particle->Eta();
161 if (TMath::Abs(eta) > 0.9)
165 }// end of mc particle
167 fMultiplicityMC->Fill(nMCTracks);
169 fCorrelation->Fill(nMCTracks, nESDTracks);
174 void AliMultiplicityMCSelector::SlaveTerminate()
176 // The SlaveTerminate() function is called after all entries or objects
177 // have been processed. When running with PROOF SlaveTerminate() is called
178 // on each slave server.
180 AliSelector::SlaveTerminate();
182 // Add the histograms to the output on each slave server
185 AliDebug(AliLog::kError, Form("ERROR: Output list not initialized."));
189 fOutput->Add(fMultiplicityESD);
190 fOutput->Add(fMultiplicityMC);
191 fOutput->Add(fCorrelation);
194 void AliMultiplicityMCSelector::Terminate()
196 // The Terminate() function is the last function to be called during
197 // a query. It always runs on the client, it can be used to present
198 // the results graphically or save the results to file.
200 AliSelector::Terminate();
204 fMultiplicityESD = dynamic_cast<TH1F*> (fOutput->FindObject("fMultiplicityESD"));
205 fMultiplicityMC = dynamic_cast<TH1F*> (fOutput->FindObject("fMultiplicityMC"));
206 fCorrelation = dynamic_cast<TH2F*> (fOutput->FindObject("fCorrelation"));
208 if (!fMultiplicityESD || !fMultiplicityMC || !fCorrelation)
210 AliDebug(AliLog::kError, Form("ERROR: Histograms not available %p %p %p", (void*) fMultiplicityESD, (void*) fMultiplicityMC, (void*) fCorrelation));
214 TFile* file = TFile::Open("multiplicityMC.root", "RECREATE");
216 fMultiplicityMC->Write();
217 fMultiplicityESD->Write();
218 fCorrelation->Write();