2 // Histogram and fit the energy loss distributions for the FMD
17 #include "AliFMDEnergyFitterTask.h"
19 #include "AliESDEvent.h"
20 #include "AliAODForwardMult.h"
21 #include "AliAnalysisManager.h"
22 #include "AliAnalysisDataSlot.h"
23 #include "AliAnalysisDataContainer.h"
25 #include <TDirectory.h>
28 #include "AliMCEvent.h"
29 #include "AliGenHijingEventHeader.h"
30 #include "AliHeader.h"
33 //====================================================================
34 AliFMDEnergyFitterTask::AliFMDEnergyFitterTask()
35 : AliAnalysisTaskSE(),
46 DGUARD(fDebug, 3,"Default CTOR of AliFMDEnergyFitterTask");
49 //____________________________________________________________________
50 AliFMDEnergyFitterTask::AliFMDEnergyFitterTask(const char* name)
51 : AliAnalysisTaskSE(name),
53 fEventInspector("event"),
54 fEnergyFitter("energy"),
65 DGUARD(fDebug, 3,"Named CTOR of AliFMDEnergyFitterTask: %s", name);
66 DefineOutput(1, TList::Class());
67 DefineOutput(2, TList::Class());
69 "ESD:AliESDRun.,AliESDHeader.,AliMultiplicity.,"
70 "AliESDFMD.,SPDVertex.,PrimaryVertex.";
73 //____________________________________________________________________
74 AliFMDEnergyFitterTask::AliFMDEnergyFitterTask(const AliFMDEnergyFitterTask& o)
75 : AliAnalysisTaskSE(o),
76 fFirstEvent(o.fFirstEvent),
77 fEventInspector(o.fEventInspector),
78 fEnergyFitter(o.fEnergyFitter),
87 // o Object to copy from
89 DGUARD(fDebug, 3,"COPY CTOR of AliFMDEnergyFitterTask");
90 DefineOutput(1, TList::Class());
91 DefineOutput(2, TList::Class());
94 //____________________________________________________________________
95 AliFMDEnergyFitterTask&
96 AliFMDEnergyFitterTask::operator=(const AliFMDEnergyFitterTask& o)
99 // Assignment operator
102 // o Object to assign from
105 // Reference to this object
108 DGUARD(fDebug,3,"Assignment of AliFMDEnergyFitterTask");
109 if (&o == this) return *this;
110 AliAnalysisTaskSE::operator=(o);
112 fFirstEvent = o.fFirstEvent;
113 fEventInspector = o.fEventInspector;
114 fEnergyFitter = o.fEnergyFitter;
122 //____________________________________________________________________
124 AliFMDEnergyFitterTask::SetDebug(Int_t dbg)
127 // Set the debug level
133 fEventInspector.SetDebug(dbg);
134 fEnergyFitter.SetDebug(dbg);
137 //____________________________________________________________________
139 AliFMDEnergyFitterTask::Init()
142 // Initialize the task
145 DGUARD(fDebug,1,"Initialize of AliFMDEnergyFitterTask");
149 //____________________________________________________________________
151 AliFMDEnergyFitterTask::SetupForData()
154 // Initialise the sub objects and stuff. Called on first event
157 DGUARD(fDebug,1,"Initialize subs of AliFMDEnergyFitterTask");
158 TAxis eAxis(0,0,0); // Default only
159 TAxis vAxis(10,-10,10); // Default only
160 fEnergyFitter.SetupForData(eAxis);
161 fEventInspector.SetupForData(vAxis);
165 //____________________________________________________________________
167 AliFMDEnergyFitterTask::UserCreateOutputObjects()
170 // Create output objects
173 DGUARD(fDebug,1,"Create output objects of AliFMDEnergyFitterTask");
177 fEventInspector.CreateOutputObjects(fList);
178 fEnergyFitter.CreateOutputObjects(fList);
182 //____________________________________________________________________
184 AliFMDEnergyFitterTask::UserExec(Option_t*)
187 // Process each event
193 // static Int_t cnt = 0;
195 // Get the input data
196 DGUARD(fDebug,3,"Analyse event of AliFMDEnergyFitterTask");
198 AliMCEvent* mcevent = MCEvent();
200 AliHeader* header = mcevent->Header();
201 AliGenHijingEventHeader* hijingHeader =
202 dynamic_cast<AliGenHijingEventHeader*>(header->GenEventHeader());
204 Float_t b = hijingHeader->ImpactParameter();
205 if(b<fbLow || b>fbHigh) return;
207 std::cout<<"Selecting event with impact parameter "<<b<<std::endl;
212 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
213 // AliInfo(Form("Event # %6d (esd=%p)", cnt, esd));
215 AliWarning("No ESD event found for input event");
219 // --- Read in the data --------------------------------------------
222 // On the first event, initialize the parameters
223 if (fFirstEvent && esd->GetESDRun()) {
224 fEventInspector.ReadRunDetails(esd);
226 AliInfo(Form("Initializing with parameters from the ESD:\n"
227 " AliESDEvent::GetBeamEnergy() ->%f\n"
228 " AliESDEvent::GetBeamType() ->%s\n"
229 " AliESDEvent::GetCurrentL3() ->%f\n"
230 " AliESDEvent::GetMagneticField()->%f\n"
231 " AliESDEvent::GetRunNumber() ->%d\n",
232 esd->GetBeamEnergy(),
235 esd->GetMagneticField(),
236 esd->GetRunNumber()));
240 // AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
241 // pars->SetParametersFromESD(esd);
242 // pars->PrintStatus();
247 Bool_t lowFlux = kFALSE;
252 UShort_t nClusters = 0;
253 UInt_t found = fEventInspector.Process(esd, triggers, lowFlux,
254 ivz, ip, cent, nClusters);
255 if (found & AliFMDEventInspector::kNoEvent) return;
256 if (found & AliFMDEventInspector::kNoTriggers) return;
257 if (found & AliFMDEventInspector::kNoSPD) return;
258 if (found & AliFMDEventInspector::kNoFMD) return;
259 if (found & AliFMDEventInspector::kNoVertex) return;
260 if (found & AliFMDEventInspector::kBadVertex) return;
263 // if( cent < 40 || cent >50 ) return;
264 // else std::cout<<"selecting event with cent "<<cent<<std::endl;
268 AliESDFMD* esdFMD = esd->GetFMDData();
269 // Do the energy stuff
270 if (!fEnergyFitter.Accumulate(*esdFMD, cent,
271 triggers & AliAODForwardMult::kEmpty)){
272 AliWarning("Energy fitter failed");
278 //____________________________________________________________________
280 AliFMDEnergyFitterTask::FinishTaskOutput()
283 Warning("FinishTaskOutput", "No list defined");
290 AliAnalysisTaskSE::FinishTaskOutput();
293 //____________________________________________________________________
295 AliFMDEnergyFitterTask::Terminate(Option_t*)
303 DGUARD(fDebug,1,"Processing merged output of AliFMDEnergyFitterTask");
305 TList* list = dynamic_cast<TList*>(GetOutputData(1));
307 AliError(Form("No output list defined (%p)", GetOutputData(1)));
308 if (GetOutputData(1)) GetOutputData(1)->Print();
312 AliInfo("Fitting energy loss spectra");
313 fEnergyFitter.Fit(list);
315 // Make a deep copy and post that as output 2
316 TList* list2 = static_cast<TList*>(list->Clone(Form("%sResults",
322 //____________________________________________________________________
324 AliFMDEnergyFitterTask::Print(Option_t*) const