3 #include "AliMultiplicityESDSelector.h"
16 #include "esdTrackCuts/AliESDtrackCuts.h"
17 #include "AliPWG0Helper.h"
19 #ifdef ALISELECTOR_USEMONALISA
20 #include <TMonaLisaWriter.h>
23 ClassImp(AliMultiplicityESDSelector)
25 AliMultiplicityESDSelector::AliMultiplicityESDSelector() :
29 #ifdef ALISELECTOR_USEMONALISA
34 // Constructor. Initialization of pointers
38 AliMultiplicityESDSelector::~AliMultiplicityESDSelector()
44 // histograms are in the output list and deleted when the output
45 // list is deleted by the TSelector dtor
48 void AliMultiplicityESDSelector::Begin(TTree* tree)
52 AliSelector::Begin(tree);
54 ReadUserObjects(tree);
57 void AliMultiplicityESDSelector::ReadUserObjects(TTree* tree)
59 // read the user objects, called from slavebegin and begin
61 if (!fEsdTrackCuts && fInput)
62 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fInput->FindObject("AliESDtrackCuts"));
64 if (!fEsdTrackCuts && tree)
65 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (tree->GetUserInfo()->FindObject("AliESDtrackCuts"));
68 AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from input list.");
71 void AliMultiplicityESDSelector::SlaveBegin(TTree* tree)
73 // The SlaveBegin() function is called after the Begin() function.
74 // When running with PROOF SlaveBegin() is called on each slave server.
75 // The tree argument is deprecated (on PROOF 0 is passed).
77 AliSelector::SlaveBegin(tree);
79 ReadUserObjects(tree);
81 fMultiplicity = new TH1F("fMultiplicity", "multiplicity", 201, 0.5, 200.5);
83 #ifdef ALISELECTOR_USEMONALISA
86 nm = dynamic_cast<TNamed*> (fInput->FindObject("PROOF_QueryTag"));
89 AliDebug(AliLog::kError, "Query tag not found. Cannot enable monitoring");
93 TString option = GetOption();
94 option.ReplaceAll("#+", "");
97 id.Form("%s_%s%d", gSystem->HostName(), nm->GetTitle(), gSystem->GetPid());
98 fMonaLisaWriter = new TMonaLisaWriter(option, id, "CAF", "aliendb6.cern.ch");
102 Bool_t AliMultiplicityESDSelector::Process(Long64_t entry)
104 // The Process() function is called for each entry in the tree (or possibly
105 // keyed object in the case of PROOF) to be processed. The entry argument
106 // specifies which entry in the currently loaded tree is to be processed.
107 // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
108 // to read either all or the required parts of the data. When processing
109 // keyed objects with PROOF, the object is already loaded and is available
110 // via the fObject pointer.
112 // This function should contain the "body" of the analysis. It can contain
113 // simple or elaborate selection criteria, run algorithms on the data
114 // of the event and typically fill histograms.
116 // WARNING when a selector is used with a TChain, you must use
117 // the pointer to the current TTree to call GetEntry(entry).
118 // The entry is always the local entry number in the current tree.
119 // Assuming that fTree is the pointer to the TChain being processed,
120 // use fTree->GetTree()->GetEntry(entry).
122 if (AliSelector::Process(entry) == kFALSE)
125 // Check prerequisites
128 AliDebug(AliLog::kError, "ESD branch not available");
134 AliDebug(AliLog::kError, "fESDTrackCuts not available");
138 if (AliPWG0Helper::IsEventTriggered(fESD) == kFALSE)
141 if (AliPWG0Helper::IsVertexReconstructed(fESD) == kFALSE)
144 // get number of "good" tracks
145 Int_t nGoodTracks = fEsdTrackCuts->CountAcceptedTracks(fESD);
147 fMultiplicity->Fill(nGoodTracks);
152 void AliMultiplicityESDSelector::SlaveTerminate()
154 // The SlaveTerminate() function is called after all entries or objects
155 // have been processed. When running with PROOF SlaveTerminate() is called
156 // on each slave server.
158 AliSelector::SlaveTerminate();
160 #ifdef ALISELECTOR_USEMONALISA
163 delete fMonaLisaWriter;
168 // Add the histograms to the output on each slave server
171 AliDebug(AliLog::kError, Form("ERROR: Output list not initialized."));
175 fOutput->Add(fMultiplicity);
178 void AliMultiplicityESDSelector::Terminate()
180 // The Terminate() function is the last function to be called during
181 // a query. It always runs on the client, it can be used to present
182 // the results graphically or save the results to file.
184 AliSelector::Terminate();
186 fMultiplicity = dynamic_cast<TH1F*> (fOutput->FindObject("fMultiplicity"));
190 AliDebug(AliLog::kError, Form("ERROR: Histogram not available %p", (void*) fMultiplicity));
194 TFile* file = TFile::Open("multiplicityESD.root", "RECREATE");
195 fMultiplicity->Write();