3 #include "AliMultiplicityESDSelector.h"
16 #include "esdTrackCuts/AliESDtrackCuts.h"
17 #include "AliPWG0Helper.h"
19 ClassImp(AliMultiplicityESDSelector)
21 AliMultiplicityESDSelector::AliMultiplicityESDSelector() :
27 // Constructor. Initialization of pointers
31 AliMultiplicityESDSelector::~AliMultiplicityESDSelector()
37 // histograms are in the output list and deleted when the output
38 // list is deleted by the TSelector dtor
41 void AliMultiplicityESDSelector::Begin(TTree* tree)
45 AliSelector::Begin(tree);
47 ReadUserObjects(tree);
50 void AliMultiplicityESDSelector::ReadUserObjects(TTree* tree)
52 // read the user objects, called from slavebegin and begin
54 if (!fEsdTrackCuts && fInput)
55 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fInput->FindObject("AliESDtrackCuts"));
57 if (!fEsdTrackCuts && tree)
58 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (tree->GetUserInfo()->FindObject("AliESDtrackCuts"));
61 AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from input list.");
64 void AliMultiplicityESDSelector::SlaveBegin(TTree* tree)
66 // The SlaveBegin() function is called after the Begin() function.
67 // When running with PROOF SlaveBegin() is called on each slave server.
68 // The tree argument is deprecated (on PROOF 0 is passed).
70 AliSelector::SlaveBegin(tree);
72 ReadUserObjects(tree);
74 fMultiplicity = new TH1F("multiplicity", "multiplicity", 100, 0, 100);
77 Bool_t AliMultiplicityESDSelector::Process(Long64_t entry)
79 // The Process() function is called for each entry in the tree (or possibly
80 // keyed object in the case of PROOF) to be processed. The entry argument
81 // specifies which entry in the currently loaded tree is to be processed.
82 // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
83 // to read either all or the required parts of the data. When processing
84 // keyed objects with PROOF, the object is already loaded and is available
85 // via the fObject pointer.
87 // This function should contain the "body" of the analysis. It can contain
88 // simple or elaborate selection criteria, run algorithms on the data
89 // of the event and typically fill histograms.
91 // WARNING when a selector is used with a TChain, you must use
92 // the pointer to the current TTree to call GetEntry(entry).
93 // The entry is always the local entry number in the current tree.
94 // Assuming that fTree is the pointer to the TChain being processed,
95 // use fTree->GetTree()->GetEntry(entry).
97 if (AliSelector::Process(entry) == kFALSE)
100 // Check prerequisites
103 AliDebug(AliLog::kError, "ESD branch not available");
109 AliDebug(AliLog::kError, "fESDTrackCuts not available");
113 if (AliPWG0Helper::IsEventTriggered(fESD) == kFALSE)
116 if (AliPWG0Helper::IsVertexReconstructed(fESD) == kFALSE)
119 // get number of "good" tracks
120 Int_t nGoodTracks = fEsdTrackCuts->CountAcceptedTracks(fESD);
122 fMultiplicity->Fill(nGoodTracks);
127 void AliMultiplicityESDSelector::SlaveTerminate()
129 // The SlaveTerminate() function is called after all entries or objects
130 // have been processed. When running with PROOF SlaveTerminate() is called
131 // on each slave server.
133 AliSelector::SlaveTerminate();
135 // Add the histograms to the output on each slave server
138 AliDebug(AliLog::kError, Form("ERROR: Output list not initialized."));
142 fOutput->Add(fMultiplicity);
145 void AliMultiplicityESDSelector::Terminate()
147 // The Terminate() function is the last function to be called during
148 // a query. It always runs on the client, it can be used to present
149 // the results graphically or save the results to file.
151 AliSelector::Terminate();
153 fMultiplicity = dynamic_cast<TH1F*> (fOutput->FindObject("multiplicity"));
157 AliDebug(AliLog::kError, Form("ERROR: Histograms not available %p", (void*) fMultiplicity));
162 fMultiplicity->Draw();