]>
Commit | Line | Data |
---|---|---|
2a445445 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | //---------------------------------------------------------------------------------- | |
17 | // Class AliRsnSimpleAnalysisTaskSE | |
18 | // ------------------------ | |
19 | // Reader for conversion of ESD output into the internal format | |
20 | // used for resonance study. | |
21 | // --- | |
22 | // original author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) | |
23 | // --- | |
24 | // adapted for Analysis Framework | |
25 | // by : R. Vernet (email: renaud.vernet@cern.ch) | |
26 | //---------------------------------------------------------------------------------- | |
27 | ||
28 | #include <TH1.h> | |
29 | #include <TH2.h> | |
30 | #include <TChain.h> | |
31 | #include <TROOT.h> | |
32 | #include <TObjArray.h> | |
33 | ||
34 | #include "AliLog.h" | |
35 | #include "AliVEvent.h" | |
36 | #include "AliMCEventHandler.h" | |
37 | #include "AliInputEventHandler.h" | |
38 | #include "AliAnalysisManager.h" | |
39 | ||
40 | #include "AliMCEvent.h" | |
41 | ||
42 | #include "AliRsnPairDef.h" | |
43 | #include "AliRsnEvent.h" | |
44 | #include "AliRsnReader.h" | |
45 | #include "AliRsnPID.h" | |
46 | #include "AliRsnSimpleFunction.h" | |
47 | #include "AliRsnSimpleAnalyzer.h" | |
48 | #include "AliRsnSimpleAnalysisTaskSE.h" | |
49 | ||
50 | ClassImp(AliRsnSimpleAnalysisTaskSE) | |
51 | ||
52 | //_____________________________________________________________________________ | |
53 | AliRsnSimpleAnalysisTaskSE::AliRsnSimpleAnalysisTaskSE() : | |
aec0ec32 | 54 | AliAnalysisTaskSE(), |
55 | fReader(0x0), | |
56 | fPID(0x0), | |
57 | fAnalyzer(0x0), | |
58 | fRsnEvent(0x0), | |
59 | fHistograms(0x0) | |
2a445445 | 60 | { |
61 | // | |
62 | // Default constructor (not recommended) | |
63 | // | |
64 | } | |
65 | ||
66 | //_____________________________________________________________________________ | |
67 | AliRsnSimpleAnalysisTaskSE::AliRsnSimpleAnalysisTaskSE(const char *name) : | |
aec0ec32 | 68 | AliAnalysisTaskSE(name), |
69 | fReader(0x0), | |
70 | fPID(0x0), | |
71 | fAnalyzer(0x0), | |
72 | fRsnEvent(0x0), | |
73 | fHistograms(0x0) | |
2a445445 | 74 | { |
75 | // | |
76 | // Working constructor (recommended) | |
77 | // | |
78 | ||
aec0ec32 | 79 | DefineOutput(1, TList::Class()); |
2a445445 | 80 | } |
81 | ||
82 | //_____________________________________________________________________________ | |
83 | void AliRsnSimpleAnalysisTaskSE::UserCreateOutputObjects() | |
84 | { | |
85 | // | |
86 | // Create the output container | |
87 | // | |
88 | ||
aec0ec32 | 89 | // check for presence of NECESSARY data-members |
90 | if (!fReader) | |
91 | { | |
92 | AliFatal("Event reader not initialized. Impossible to continue. Aborting with fatal error."); | |
93 | return; | |
94 | } | |
95 | if (!fPID) | |
96 | { | |
97 | AliFatal("PID manager not initialized. Impossible to continue. Aborting with fatal error."); | |
98 | return; | |
99 | } | |
100 | if (!fAnalyzer) | |
101 | { | |
102 | AliFatal("Analysis manager not initialized. Impossible to continue. Aborting with fatal error."); | |
103 | return; | |
104 | } | |
105 | ||
106 | // output histogram list | |
107 | fHistograms = new TList; | |
108 | ||
109 | // initialize analyzer | |
110 | fAnalyzer->Init(); | |
111 | ||
112 | // store all histograms in the functions into the list | |
113 | TObjArray *array = fAnalyzer->GetSingle(); | |
114 | AliRsnSimpleFunction *fcn; | |
115 | TH1D *h1D; | |
116 | TH2D *h2D; | |
117 | if (array) | |
118 | { | |
119 | TObjArrayIter iter(array); | |
120 | while ((fcn = (AliRsnSimpleFunction*)iter.Next())) | |
121 | { | |
122 | h1D = fcn->GetHistogram1D(); | |
123 | h2D = fcn->GetHistogram2D(); | |
124 | if (h1D) fHistograms->AddLast(h1D); | |
125 | if (h2D) fHistograms->AddLast(h2D); | |
2a445445 | 126 | |
2a445445 | 127 | } |
aec0ec32 | 128 | } |
129 | else | |
130 | { | |
131 | AliWarning("No single-event functions in analyzer"); | |
132 | } | |
133 | array = fAnalyzer->GetMix(); | |
134 | if (array) | |
135 | { | |
136 | TObjArrayIter iter(array); | |
137 | while ((fcn = (AliRsnSimpleFunction*)iter.Next())) | |
138 | { | |
139 | h1D = fcn->GetHistogram1D(); | |
140 | h2D = fcn->GetHistogram2D(); | |
141 | if (h1D) fHistograms->AddLast(h1D); | |
142 | if (h2D) fHistograms->AddLast(h2D); | |
2a445445 | 143 | } |
aec0ec32 | 144 | } |
145 | else | |
146 | { | |
147 | AliWarning("No mixing functions in analyzer"); | |
148 | } | |
2a445445 | 149 | } |
150 | ||
151 | //_____________________________________________________________________________ | |
152 | void AliRsnSimpleAnalysisTaskSE::UserExec(Option_t */*option*/) | |
153 | { | |
154 | // | |
155 | // Loops on input container to store data of all tracks. | |
156 | // Uses the AliRsnReader methods to save them in the output. | |
157 | // | |
158 | ||
aec0ec32 | 159 | // clear previous event |
160 | if (!fRsnEvent) | |
161 | { | |
162 | fRsnEvent = new AliRsnEvent; | |
163 | fRsnEvent->Init(); | |
164 | } | |
165 | else fRsnEvent->Clear(); | |
166 | ||
167 | // read event | |
168 | if (!fReader->Fill(fRsnEvent, fInputEvent, fMCEvent)) AliWarning("Failed reading"); | |
169 | AliInfo(Form("Collected %d tracks", fRsnEvent->GetMultiplicity())); | |
170 | ||
171 | // identify event if the class is available | |
172 | if (fPID) fPID->Process(fRsnEvent); | |
173 | ||
174 | // process event with analyzer | |
175 | fAnalyzer->Process(fRsnEvent); | |
176 | ||
177 | // post histograms in slot #1 | |
178 | PostData(1, fHistograms); | |
2a445445 | 179 | } |
180 | ||
181 | //_____________________________________________________________________________ | |
182 | Bool_t AliRsnSimpleAnalysisTaskSE::Configure(const char *configFile) | |
183 | { | |
184 | // | |
185 | // Configure this object using an external macro which creates | |
186 | // all required objects and stores them in the appropriate data members | |
187 | // Returns kFALSE if not all the required objects were created. | |
188 | // | |
189 | ||
aec0ec32 | 190 | gROOT->LoadMacro(configFile); |
191 | gROOT->ProcessLine("RsnConfig()"); | |
192 | ||
193 | fReader = (AliRsnReader*)gDirectory->Get("RsnReader"); | |
194 | fPID = (AliRsnPID*)gDirectory->Get("RsnPID"); | |
195 | fAnalyzer = (AliRsnSimpleAnalyzer*)gDirectory->Get("RsnSimpleAnalyzer"); | |
196 | ||
197 | // check for presence of NECESSARY data-members | |
198 | if (!fReader) | |
199 | { | |
200 | AliError("Event reader not initialized. Impossible to continue. Aborting with fatal error."); | |
201 | return kFALSE; | |
202 | } | |
203 | if (!fPID) | |
204 | { | |
205 | AliError("PID manager not initialized. Impossible to continue. Aborting with fatal error."); | |
206 | return kFALSE; | |
207 | } | |
208 | if (!fAnalyzer) | |
209 | { | |
210 | AliError("Analysis manager not initialized. Impossible to continue. Aborting with fatal error."); | |
211 | return kFALSE; | |
212 | } | |
213 | ||
214 | return kTRUE; | |
2a445445 | 215 | } |
216 | ||
217 | //_____________________________________________________________________________ | |
218 | void AliRsnSimpleAnalysisTaskSE::PrintSettings() | |
219 | { | |
220 | // | |
221 | // Print analysis settings | |
222 | // | |
223 | ||
aec0ec32 | 224 | AliInfo("==== ANALYSIS TASK INFO ======================================================="); |
225 | ||
226 | // reader | |
227 | AliInfo(Form("Reader address, name: %x %s", fReader, fReader->GetName())); | |
228 | switch (fReader->GetSource()) | |
229 | { | |
230 | case AliRsnReader::kESD: | |
231 | AliInfo("Reader source: kESD"); | |
232 | break; | |
233 | case AliRsnReader::kESDTPC: | |
234 | AliInfo("Reader source: kESDTPC"); | |
235 | break; | |
236 | case AliRsnReader::kAOD: | |
237 | AliInfo("Reader source: kAOD"); | |
238 | break; | |
239 | case AliRsnReader::kMC: | |
240 | AliInfo("Reader source: kMC"); | |
241 | break; | |
242 | default: | |
243 | AliInfo("Reader source not properly set"); | |
244 | } | |
245 | AliInfo(Form("Reader->CheckSplit = %s", (fReader->CheckSplit() ? "true" : "false"))); | |
246 | AliInfo(Form("Reader->RejectFakes = %s", (fReader->RejectFakes() ? "true" : "false"))); | |
247 | ||
248 | // PID | |
249 | Int_t i; | |
250 | AliRsnPID::EType type; | |
251 | AliInfo(Form("PID address, name: %x", fPID, fPID->GetName())); | |
252 | for (i = 0; i < AliRsnPID::kSpecies; i++) | |
253 | { | |
254 | type = (AliRsnPID::EType)i; | |
255 | AliInfo(Form("Prior probability [%d] = %f (%s)", i, fPID->GetPriorProbability(type), AliRsnPID::ParticleName(type))); | |
256 | } | |
257 | AliInfo(Form("PID momentum threshold = %f", fPID->GetMaxPt())); | |
258 | AliInfo(Form("PID probability threshold = %f", fPID->GetMinProb())); | |
259 | ||
260 | // analyzer | |
261 | AliRsnSimpleFunction *fcn; | |
262 | AliInfo(Form("Analyzer address, name: %x", fAnalyzer, fAnalyzer->GetName())); | |
263 | TObjArrayIter iter1(fAnalyzer->GetSingle()); | |
264 | while ((fcn = (AliRsnSimpleFunction*)iter1.Next())) | |
265 | { | |
266 | AliInfo(Form("Single-event function: %s [%s]", fcn->GetName(), fcn->ClassName())); | |
267 | } | |
268 | if (fAnalyzer->GetMix()) | |
269 | { | |
270 | TObjArrayIter iter2(fAnalyzer->GetMix()); | |
271 | while ((fcn = (AliRsnSimpleFunction*)iter2.Next())) | |
272 | { | |
273 | AliInfo(Form("Mix function: %s [%s]", fcn->GetName(), fcn->ClassName())); | |
2a445445 | 274 | } |
aec0ec32 | 275 | } |
2a445445 | 276 | |
aec0ec32 | 277 | AliInfo("==============================================================================="); |
2a445445 | 278 | } |