]>
Commit | Line | Data |
---|---|---|
7984e5f7 | 1 | // |
2 | // Histogram and fit the energy loss distributions for the FMD | |
3 | // | |
4 | // Inputs: | |
5 | // - AliESDEvent | |
6 | // | |
7 | // Outputs: | |
8 | // - None | |
9 | // | |
10 | // Histograms: | |
11 | // | |
12 | // Corrections used: | |
13 | // - None | |
14 | // | |
15 | // | |
16 | // | |
0bd4b00f | 17 | #include "AliFMDEnergyFitterTask.h" |
18 | #include "AliLog.h" | |
0bd4b00f | 19 | #include "AliESDEvent.h" |
20 | #include "AliAODForwardMult.h" | |
21 | #include "AliForwardCorrectionManager.h" | |
22 | #include "AliAnalysisManager.h" | |
72cc12cd | 23 | #include "AliAnalysisDataSlot.h" |
24 | #include "AliAnalysisDataContainer.h" | |
0bd4b00f | 25 | #include <TH1.h> |
26 | #include <TDirectory.h> | |
27 | #include <TTree.h> | |
72cc12cd | 28 | #include <TFile.h> |
e58000b7 | 29 | #include "AliMCEvent.h" |
30 | #include "AliGenHijingEventHeader.h" | |
31 | #include "AliHeader.h" | |
32 | #include <iostream> | |
0bd4b00f | 33 | |
34 | //==================================================================== | |
35 | AliFMDEnergyFitterTask::AliFMDEnergyFitterTask() | |
36 | : AliAnalysisTaskSE(), | |
37 | fFirstEvent(true), | |
38 | fEventInspector(), | |
39 | fEnergyFitter(), | |
6f4c294b | 40 | fList(0), |
41 | fbLow(0), | |
42 | fbHigh(100) | |
0bd4b00f | 43 | { |
7984e5f7 | 44 | // |
45 | // Constructor | |
46 | // | |
6ab100ec | 47 | DGUARD(fDebug,0,"Default CTOR of AliFMDEnergyFitterTask"); |
0bd4b00f | 48 | } |
49 | ||
50 | //____________________________________________________________________ | |
51 | AliFMDEnergyFitterTask::AliFMDEnergyFitterTask(const char* name) | |
52 | : AliAnalysisTaskSE(name), | |
53 | fFirstEvent(true), | |
54 | fEventInspector("event"), | |
55 | fEnergyFitter("energy"), | |
e58000b7 | 56 | fList(0), |
57 | fbLow(0), | |
58 | fbHigh(100) | |
0bd4b00f | 59 | { |
7984e5f7 | 60 | // |
61 | // Constructor | |
62 | // | |
63 | // Parameters: | |
64 | // name Name of task | |
65 | // | |
6ab100ec | 66 | DGUARD(fDebug,0,"Named CTOR of AliFMDEnergyFitterTask: %s", name); |
0bd4b00f | 67 | DefineOutput(1, TList::Class()); |
8e2bb72a | 68 | DefineOutput(2, TList::Class()); |
0bd4b00f | 69 | } |
70 | ||
71 | //____________________________________________________________________ | |
72 | AliFMDEnergyFitterTask::AliFMDEnergyFitterTask(const AliFMDEnergyFitterTask& o) | |
73 | : AliAnalysisTaskSE(o), | |
74 | fFirstEvent(o.fFirstEvent), | |
75 | fEventInspector(o.fEventInspector), | |
76 | fEnergyFitter(o.fEnergyFitter), | |
6f4c294b | 77 | fList(o.fList), |
78 | fbLow(o.fbLow), | |
79 | fbHigh(o.fbHigh) | |
0bd4b00f | 80 | { |
7984e5f7 | 81 | // |
82 | // Copy constructor | |
83 | // | |
84 | // Parameters: | |
85 | // o Object to copy from | |
86 | // | |
6ab100ec | 87 | DGUARD(fDebug,0,"COPY CTOR of AliFMDEnergyFitterTask"); |
0bd4b00f | 88 | DefineOutput(1, TList::Class()); |
8e2bb72a | 89 | DefineOutput(2, TList::Class()); |
0bd4b00f | 90 | } |
91 | ||
92 | //____________________________________________________________________ | |
93 | AliFMDEnergyFitterTask& | |
94 | AliFMDEnergyFitterTask::operator=(const AliFMDEnergyFitterTask& o) | |
95 | { | |
7984e5f7 | 96 | // |
97 | // Assignment operator | |
98 | // | |
99 | // Parameters: | |
100 | // o Object to assign from | |
101 | // | |
102 | // Return: | |
103 | // Reference to this object | |
104 | // | |
6ab100ec | 105 | DGUARD(fDebug,3,"Assignment of AliFMDEnergyFitterTask"); |
d015ecfe | 106 | if (&o == this) return *this; |
0bd4b00f | 107 | AliAnalysisTaskSE::operator=(o); |
108 | ||
109 | fFirstEvent = o.fFirstEvent; | |
110 | fEventInspector = o.fEventInspector; | |
111 | fEnergyFitter = o.fEnergyFitter; | |
112 | fList = o.fList; | |
6f4c294b | 113 | fbLow = o.fbLow; |
114 | fbHigh = o.fbHigh; | |
0bd4b00f | 115 | |
116 | return *this; | |
117 | } | |
118 | ||
119 | //____________________________________________________________________ | |
120 | void | |
121 | AliFMDEnergyFitterTask::SetDebug(Int_t dbg) | |
122 | { | |
7984e5f7 | 123 | // |
124 | // Set the debug level | |
125 | // | |
126 | // Parameters: | |
127 | // dbg Debug level | |
128 | // | |
0bd4b00f | 129 | fEventInspector.SetDebug(dbg); |
130 | fEnergyFitter.SetDebug(dbg); | |
131 | } | |
132 | ||
133 | //____________________________________________________________________ | |
134 | void | |
135 | AliFMDEnergyFitterTask::Init() | |
136 | { | |
7984e5f7 | 137 | // |
138 | // Initialize the task | |
139 | // | |
140 | // | |
6ab100ec | 141 | DGUARD(fDebug,1,"Initialize of AliFMDEnergyFitterTask"); |
0bd4b00f | 142 | fFirstEvent = true; |
143 | } | |
144 | ||
145 | //____________________________________________________________________ | |
146 | void | |
147 | AliFMDEnergyFitterTask::InitializeSubs() | |
148 | { | |
7984e5f7 | 149 | // |
150 | // Initialise the sub objects and stuff. Called on first event | |
151 | // | |
152 | // | |
6ab100ec | 153 | DGUARD(fDebug,1,"Initialize subs of AliFMDEnergyFitterTask"); |
0bd4b00f | 154 | AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance(); |
f7cfc454 | 155 | UShort_t sys = fEventInspector.GetCollisionSystem(); |
156 | UShort_t sNN = fEventInspector.GetEnergy(); | |
157 | Short_t fld = fEventInspector.GetField(); | |
158 | fcm.Init(sys, sNN, fld, 0); | |
0bd4b00f | 159 | TAxis eAxis(0,0,0); |
160 | TAxis vAxis(10,-10,10); | |
161 | fEnergyFitter.Init(eAxis); | |
162 | fEventInspector.Init(vAxis); | |
f7cfc454 | 163 | |
0bd4b00f | 164 | } |
165 | ||
166 | //____________________________________________________________________ | |
167 | void | |
168 | AliFMDEnergyFitterTask::UserCreateOutputObjects() | |
169 | { | |
7984e5f7 | 170 | // |
171 | // Create output objects | |
172 | // | |
173 | // | |
6ab100ec | 174 | DGUARD(fDebug,1,"Create output objects of AliFMDEnergyFitterTask"); |
0bd4b00f | 175 | fList = new TList; |
9b07e44d | 176 | fList->SetOwner(); |
0bd4b00f | 177 | |
178 | fEventInspector.DefineOutput(fList); | |
179 | fEnergyFitter.DefineOutput(fList); | |
180 | ||
181 | PostData(1, fList); | |
182 | } | |
183 | //____________________________________________________________________ | |
184 | void | |
185 | AliFMDEnergyFitterTask::UserExec(Option_t*) | |
186 | { | |
7984e5f7 | 187 | // |
188 | // Process each event | |
189 | // | |
190 | // Parameters: | |
191 | // option Not used | |
192 | // | |
193 | ||
0bd4b00f | 194 | // static Int_t cnt = 0; |
195 | // cnt++; | |
196 | // Get the input data | |
6ab100ec | 197 | DGUARD(fDebug,1,"Analyse event of AliFMDEnergyFitterTask"); |
e58000b7 | 198 | |
199 | AliMCEvent* mcevent = MCEvent(); | |
200 | if(mcevent) { | |
201 | AliHeader* header = mcevent->Header(); | |
5bb5d1f6 | 202 | AliGenHijingEventHeader* hijingHeader = |
203 | dynamic_cast<AliGenHijingEventHeader*>(header->GenEventHeader()); | |
e58000b7 | 204 | if(hijingHeader) { |
205 | Float_t b = hijingHeader->ImpactParameter(); | |
206 | if(b<fbLow || b>fbHigh) return; | |
207 | else | |
208 | std::cout<<"Selecting event with impact parameter "<<b<<std::endl; | |
209 | } | |
210 | ||
211 | } | |
212 | ||
0bd4b00f | 213 | AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent()); |
214 | // AliInfo(Form("Event # %6d (esd=%p)", cnt, esd)); | |
215 | if (!esd) { | |
216 | AliWarning("No ESD event found for input event"); | |
217 | return; | |
218 | } | |
219 | ||
220 | // On the first event, initialize the parameters | |
221 | if (fFirstEvent && esd->GetESDRun()) { | |
222 | fEventInspector.ReadRunDetails(esd); | |
223 | ||
224 | AliInfo(Form("Initializing with parameters from the ESD:\n" | |
225 | " AliESDEvent::GetBeamEnergy() ->%f\n" | |
226 | " AliESDEvent::GetBeamType() ->%s\n" | |
227 | " AliESDEvent::GetCurrentL3() ->%f\n" | |
228 | " AliESDEvent::GetMagneticField()->%f\n" | |
229 | " AliESDEvent::GetRunNumber() ->%d\n", | |
230 | esd->GetBeamEnergy(), | |
231 | esd->GetBeamType(), | |
232 | esd->GetCurrentL3(), | |
233 | esd->GetMagneticField(), | |
234 | esd->GetRunNumber())); | |
235 | ||
236 | ||
237 | ||
238 | // AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance(); | |
239 | // pars->SetParametersFromESD(esd); | |
240 | // pars->PrintStatus(); | |
241 | fFirstEvent = false; | |
242 | ||
243 | InitializeSubs(); | |
244 | } | |
5bb5d1f6 | 245 | Bool_t lowFlux = kFALSE; |
246 | UInt_t triggers = 0; | |
247 | UShort_t ivz = 0; | |
248 | Double_t vz = 0; | |
249 | Double_t cent = 0; | |
250 | UShort_t nClusters = 0; | |
251 | UInt_t found = fEventInspector.Process(esd, triggers, lowFlux, | |
252 | ivz, vz, cent, nClusters); | |
0bd4b00f | 253 | if (found & AliFMDEventInspector::kNoEvent) return; |
254 | if (found & AliFMDEventInspector::kNoTriggers) return; | |
255 | if (found & AliFMDEventInspector::kNoSPD) return; | |
256 | if (found & AliFMDEventInspector::kNoFMD) return; | |
257 | if (found & AliFMDEventInspector::kNoVertex) return; | |
258 | if (found & AliFMDEventInspector::kBadVertex) return; | |
12fffad7 | 259 | |
260 | // if(cent > 0) { | |
261 | // if( cent < 40 || cent >50 ) return; | |
262 | // else std::cout<<"selecting event with cent "<<cent<<std::endl; | |
263 | // } | |
264 | ||
0bd4b00f | 265 | // Get FMD data |
266 | AliESDFMD* esdFMD = esd->GetFMDData(); | |
267 | // Do the energy stuff | |
5e4d905e | 268 | if (!fEnergyFitter.Accumulate(*esdFMD, cent, |
269 | triggers & AliAODForwardMult::kEmpty)){ | |
0bd4b00f | 270 | AliWarning("Energy fitter failed"); |
271 | return; | |
272 | } | |
273 | PostData(1, fList); | |
274 | } | |
275 | ||
276 | //____________________________________________________________________ | |
277 | void | |
278 | AliFMDEnergyFitterTask::Terminate(Option_t*) | |
279 | { | |
7984e5f7 | 280 | // |
281 | // End of job | |
282 | // | |
283 | // Parameters: | |
284 | // option Not used | |
285 | // | |
6ab100ec | 286 | DGUARD(fDebug,1,"Processing merged output of AliFMDEnergyFitterTask"); |
287 | ||
0bd4b00f | 288 | TList* list = dynamic_cast<TList*>(GetOutputData(1)); |
289 | if (!list) { | |
290 | AliError(Form("No output list defined (%p)", GetOutputData(1))); | |
291 | if (GetOutputData(1)) GetOutputData(1)->Print(); | |
292 | return; | |
293 | } | |
294 | ||
1c762251 | 295 | AliInfo("Fitting energy loss spectra"); |
0bd4b00f | 296 | fEnergyFitter.Fit(list); |
72cc12cd | 297 | |
8e2bb72a | 298 | // Make a deep copy and post that as output 2 |
299 | TList* list2 = static_cast<TList*>(list->Clone(Form("%sResults", | |
300 | list->GetName()))); | |
9b07e44d | 301 | list2->SetOwner(); |
8e2bb72a | 302 | PostData(2, list2); |
0bd4b00f | 303 | } |
304 | ||
305 | //____________________________________________________________________ | |
306 | void | |
307 | AliFMDEnergyFitterTask::Print(Option_t*) const | |
308 | { | |
7984e5f7 | 309 | // |
310 | // Print information | |
311 | // | |
312 | // Parameters: | |
313 | // option Not used | |
314 | // | |
0bd4b00f | 315 | } |
316 | ||
317 | // | |
318 | // EOF | |
319 | // |