]>
Commit | Line | Data |
---|---|---|
0ab29cfa | 1 | /* $Id$ */ |
2 | ||
3 | #include "AliMultiplicityESDSelector.h" | |
4 | ||
5 | #include <TStyle.h> | |
6 | #include <TSystem.h> | |
7 | #include <TCanvas.h> | |
8 | #include <TVector3.h> | |
9 | #include <TChain.h> | |
10 | #include <TFile.h> | |
11 | #include <TH1F.h> | |
12 | ||
13 | #include <AliLog.h> | |
14 | #include <AliESD.h> | |
15 | ||
16 | #include "esdTrackCuts/AliESDtrackCuts.h" | |
17 | #include "AliPWG0Helper.h" | |
18 | ||
7af955da | 19 | // uncomment this to enable mona lisa monitoring |
20 | //#define ALISELECTOR_USEMONALISA | |
21 | ||
22 | #ifdef ALISELECTOR_USEMONALISA | |
23 | #include <TMonaLisaWriter.h> | |
24 | #endif | |
25 | ||
0ab29cfa | 26 | ClassImp(AliMultiplicityESDSelector) |
27 | ||
28 | AliMultiplicityESDSelector::AliMultiplicityESDSelector() : | |
29 | AliSelector(), | |
30 | fMultiplicity(0), | |
7af955da | 31 | fEsdTrackCuts(0), |
32 | fMonaLisaWriter(0) | |
0ab29cfa | 33 | { |
34 | // | |
35 | // Constructor. Initialization of pointers | |
36 | // | |
0ab29cfa | 37 | } |
38 | ||
39 | AliMultiplicityESDSelector::~AliMultiplicityESDSelector() | |
40 | { | |
41 | // | |
42 | // Destructor | |
43 | // | |
44 | ||
45 | // histograms are in the output list and deleted when the output | |
46 | // list is deleted by the TSelector dtor | |
47 | } | |
48 | ||
49 | void AliMultiplicityESDSelector::Begin(TTree* tree) | |
50 | { | |
51 | // Begin function | |
52 | ||
10ebe68d | 53 | AliSelector::Begin(tree); |
54 | ||
0ab29cfa | 55 | ReadUserObjects(tree); |
56 | } | |
57 | ||
58 | void AliMultiplicityESDSelector::ReadUserObjects(TTree* tree) | |
59 | { | |
60 | // read the user objects, called from slavebegin and begin | |
61 | ||
62 | if (!fEsdTrackCuts && fInput) | |
63 | fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fInput->FindObject("AliESDtrackCuts")); | |
64 | ||
65 | if (!fEsdTrackCuts && tree) | |
66 | fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (tree->GetUserInfo()->FindObject("AliESDtrackCuts")); | |
67 | ||
68 | if (!fEsdTrackCuts) | |
69 | AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from input list."); | |
70 | } | |
71 | ||
72 | void AliMultiplicityESDSelector::SlaveBegin(TTree* tree) | |
73 | { | |
74 | // The SlaveBegin() function is called after the Begin() function. | |
75 | // When running with PROOF SlaveBegin() is called on each slave server. | |
76 | // The tree argument is deprecated (on PROOF 0 is passed). | |
77 | ||
78 | AliSelector::SlaveBegin(tree); | |
79 | ||
80 | ReadUserObjects(tree); | |
81 | ||
f31d5d49 | 82 | fMultiplicity = new TH1F("fMultiplicity", "multiplicity", 201, 0.5, 200.5); |
7af955da | 83 | |
84 | #ifdef ALISELECTOR_USEMONALISA | |
85 | TNamed *nm = 0; | |
86 | if (fInput) | |
87 | nm = dynamic_cast<TNamed*> (fInput->FindObject("PROOF_QueryTag")); | |
88 | if (!nm) | |
89 | { | |
90 | AliDebug(AliLog::kError, "Query tag not found. Cannot enable monitoring"); | |
91 | return; | |
92 | } | |
93 | ||
94 | TString option = GetOption(); | |
95 | option.ReplaceAll("#+", ""); | |
96 | ||
97 | TString id; | |
98 | id.Form("%s_%s%d", gSystem->HostName(), nm->GetTitle(), gSystem->GetPid()); | |
99 | fMonaLisaWriter = new TMonaLisaWriter(option, id, "CAF", "aliendb6.cern.ch"); | |
100 | #endif | |
0ab29cfa | 101 | } |
102 | ||
103 | Bool_t AliMultiplicityESDSelector::Process(Long64_t entry) | |
104 | { | |
105 | // The Process() function is called for each entry in the tree (or possibly | |
106 | // keyed object in the case of PROOF) to be processed. The entry argument | |
107 | // specifies which entry in the currently loaded tree is to be processed. | |
108 | // It can be passed to either TTree::GetEntry() or TBranch::GetEntry() | |
109 | // to read either all or the required parts of the data. When processing | |
110 | // keyed objects with PROOF, the object is already loaded and is available | |
111 | // via the fObject pointer. | |
112 | // | |
113 | // This function should contain the "body" of the analysis. It can contain | |
114 | // simple or elaborate selection criteria, run algorithms on the data | |
115 | // of the event and typically fill histograms. | |
116 | ||
117 | // WARNING when a selector is used with a TChain, you must use | |
118 | // the pointer to the current TTree to call GetEntry(entry). | |
119 | // The entry is always the local entry number in the current tree. | |
120 | // Assuming that fTree is the pointer to the TChain being processed, | |
121 | // use fTree->GetTree()->GetEntry(entry). | |
122 | ||
123 | if (AliSelector::Process(entry) == kFALSE) | |
124 | return kFALSE; | |
125 | ||
126 | // Check prerequisites | |
127 | if (!fESD) | |
128 | { | |
129 | AliDebug(AliLog::kError, "ESD branch not available"); | |
130 | return kFALSE; | |
131 | } | |
132 | ||
133 | if (!fEsdTrackCuts) | |
134 | { | |
135 | AliDebug(AliLog::kError, "fESDTrackCuts not available"); | |
136 | return kFALSE; | |
137 | } | |
138 | ||
139 | if (AliPWG0Helper::IsEventTriggered(fESD) == kFALSE) | |
140 | return kTRUE; | |
141 | ||
142 | if (AliPWG0Helper::IsVertexReconstructed(fESD) == kFALSE) | |
143 | return kTRUE; | |
144 | ||
145 | // get number of "good" tracks | |
38233af1 | 146 | Int_t nGoodTracks = fEsdTrackCuts->CountAcceptedTracks(fESD); |
0ab29cfa | 147 | |
148 | fMultiplicity->Fill(nGoodTracks); | |
149 | ||
0ab29cfa | 150 | return kTRUE; |
151 | } | |
152 | ||
153 | void AliMultiplicityESDSelector::SlaveTerminate() | |
154 | { | |
155 | // The SlaveTerminate() function is called after all entries or objects | |
156 | // have been processed. When running with PROOF SlaveTerminate() is called | |
157 | // on each slave server. | |
158 | ||
159 | AliSelector::SlaveTerminate(); | |
160 | ||
7af955da | 161 | #ifdef ALISELECTOR_USEMONALISA |
162 | if (fMonaLisaWriter) | |
163 | { | |
164 | delete fMonaLisaWriter; | |
165 | fMonaLisaWriter = 0; | |
166 | } | |
167 | #endif | |
168 | ||
0ab29cfa | 169 | // Add the histograms to the output on each slave server |
170 | if (!fOutput) | |
171 | { | |
172 | AliDebug(AliLog::kError, Form("ERROR: Output list not initialized.")); | |
173 | return; | |
174 | } | |
175 | ||
176 | fOutput->Add(fMultiplicity); | |
177 | } | |
178 | ||
179 | void AliMultiplicityESDSelector::Terminate() | |
180 | { | |
181 | // The Terminate() function is the last function to be called during | |
182 | // a query. It always runs on the client, it can be used to present | |
183 | // the results graphically or save the results to file. | |
184 | ||
185 | AliSelector::Terminate(); | |
186 | ||
f31d5d49 | 187 | fMultiplicity = dynamic_cast<TH1F*> (fOutput->FindObject("fMultiplicity")); |
0ab29cfa | 188 | |
189 | if (!fMultiplicity) | |
190 | { | |
6b7fa615 | 191 | AliDebug(AliLog::kError, Form("ERROR: Histogram not available %p", (void*) fMultiplicity)); |
0ab29cfa | 192 | return; |
193 | } | |
194 | ||
f31d5d49 | 195 | TFile* file = TFile::Open("multiplicityESD.root", "RECREATE"); |
196 | fMultiplicity->Write(); | |
197 | file->Close(); | |
0ab29cfa | 198 | } |