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 "AliForwardCorrectionManager.h"
22 #include "AliAnalysisManager.h"
23 #include "AliAnalysisDataSlot.h"
24 #include "AliAnalysisDataContainer.h"
26 #include <TDirectory.h>
29 #include "AliMCEvent.h"
30 #include "AliGenHijingEventHeader.h"
31 #include "AliHeader.h"
34 //====================================================================
35 AliFMDEnergyFitterTask::AliFMDEnergyFitterTask()
36 : AliAnalysisTaskSE(),
47 DGUARD(fDebug, 3,"Default CTOR of AliFMDEnergyFitterTask");
50 //____________________________________________________________________
51 AliFMDEnergyFitterTask::AliFMDEnergyFitterTask(const char* name)
52 : AliAnalysisTaskSE(name),
54 fEventInspector("event"),
55 fEnergyFitter("energy"),
66 DGUARD(fDebug, 3,"Named CTOR of AliFMDEnergyFitterTask: %s", name);
67 DefineOutput(1, TList::Class());
68 DefineOutput(2, TList::Class());
70 "ESD:AliESDRun.,AliESDHeader.,AliMultiplicity.,"
71 "AliESDFMD.,SPDVertex.,PrimaryVertex.";
74 //____________________________________________________________________
75 AliFMDEnergyFitterTask::AliFMDEnergyFitterTask(const AliFMDEnergyFitterTask& o)
76 : AliAnalysisTaskSE(o),
77 fFirstEvent(o.fFirstEvent),
78 fEventInspector(o.fEventInspector),
79 fEnergyFitter(o.fEnergyFitter),
88 // o Object to copy from
90 DGUARD(fDebug, 3,"COPY CTOR of AliFMDEnergyFitterTask");
91 DefineOutput(1, TList::Class());
92 DefineOutput(2, TList::Class());
95 //____________________________________________________________________
96 AliFMDEnergyFitterTask&
97 AliFMDEnergyFitterTask::operator=(const AliFMDEnergyFitterTask& o)
100 // Assignment operator
103 // o Object to assign from
106 // Reference to this object
109 DGUARD(fDebug,3,"Assignment of AliFMDEnergyFitterTask");
110 if (&o == this) return *this;
111 AliAnalysisTaskSE::operator=(o);
113 fFirstEvent = o.fFirstEvent;
114 fEventInspector = o.fEventInspector;
115 fEnergyFitter = o.fEnergyFitter;
123 //____________________________________________________________________
125 AliFMDEnergyFitterTask::SetDebug(Int_t dbg)
128 // Set the debug level
134 fEventInspector.SetDebug(dbg);
135 fEnergyFitter.SetDebug(dbg);
138 //____________________________________________________________________
140 AliFMDEnergyFitterTask::Init()
143 // Initialize the task
146 DGUARD(fDebug,1,"Initialize of AliFMDEnergyFitterTask");
150 //____________________________________________________________________
152 AliFMDEnergyFitterTask::SetupForData()
155 // Initialise the sub objects and stuff. Called on first event
158 DGUARD(fDebug,1,"Initialize subs of AliFMDEnergyFitterTask");
159 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
160 UShort_t sys = fEventInspector.GetCollisionSystem();
161 UShort_t sNN = fEventInspector.GetEnergy();
162 Short_t fld = fEventInspector.GetField();
163 fcm.Init(sys, sNN, fld, 0);
165 TAxis vAxis(10,-10,10);
166 fEnergyFitter.SetupForData(eAxis);
167 fEventInspector.SetupForData(vAxis);
171 //____________________________________________________________________
173 AliFMDEnergyFitterTask::UserCreateOutputObjects()
176 // Create output objects
179 DGUARD(fDebug,1,"Create output objects of AliFMDEnergyFitterTask");
183 fEventInspector.CreateOutputObjects(fList);
184 fEnergyFitter.CreateOutputObjects(fList);
188 //____________________________________________________________________
190 AliFMDEnergyFitterTask::UserExec(Option_t*)
193 // Process each event
199 // static Int_t cnt = 0;
201 // Get the input data
202 DGUARD(fDebug,3,"Analyse event of AliFMDEnergyFitterTask");
204 AliMCEvent* mcevent = MCEvent();
206 AliHeader* header = mcevent->Header();
207 AliGenHijingEventHeader* hijingHeader =
208 dynamic_cast<AliGenHijingEventHeader*>(header->GenEventHeader());
210 Float_t b = hijingHeader->ImpactParameter();
211 if(b<fbLow || b>fbHigh) return;
213 std::cout<<"Selecting event with impact parameter "<<b<<std::endl;
218 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
219 // AliInfo(Form("Event # %6d (esd=%p)", cnt, esd));
221 AliWarning("No ESD event found for input event");
225 // --- Read in the data --------------------------------------------
228 // On the first event, initialize the parameters
229 if (fFirstEvent && esd->GetESDRun()) {
230 fEventInspector.ReadRunDetails(esd);
232 AliInfo(Form("Initializing with parameters from the ESD:\n"
233 " AliESDEvent::GetBeamEnergy() ->%f\n"
234 " AliESDEvent::GetBeamType() ->%s\n"
235 " AliESDEvent::GetCurrentL3() ->%f\n"
236 " AliESDEvent::GetMagneticField()->%f\n"
237 " AliESDEvent::GetRunNumber() ->%d\n",
238 esd->GetBeamEnergy(),
241 esd->GetMagneticField(),
242 esd->GetRunNumber()));
246 // AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
247 // pars->SetParametersFromESD(esd);
248 // pars->PrintStatus();
253 Bool_t lowFlux = kFALSE;
258 UShort_t nClusters = 0;
259 UInt_t found = fEventInspector.Process(esd, triggers, lowFlux,
260 ivz, ip, cent, nClusters);
261 if (found & AliFMDEventInspector::kNoEvent) return;
262 if (found & AliFMDEventInspector::kNoTriggers) return;
263 if (found & AliFMDEventInspector::kNoSPD) return;
264 if (found & AliFMDEventInspector::kNoFMD) return;
265 if (found & AliFMDEventInspector::kNoVertex) return;
266 if (found & AliFMDEventInspector::kBadVertex) return;
269 // if( cent < 40 || cent >50 ) return;
270 // else std::cout<<"selecting event with cent "<<cent<<std::endl;
274 AliESDFMD* esdFMD = esd->GetFMDData();
275 // Do the energy stuff
276 if (!fEnergyFitter.Accumulate(*esdFMD, cent,
277 triggers & AliAODForwardMult::kEmpty)){
278 AliWarning("Energy fitter failed");
284 //____________________________________________________________________
286 AliFMDEnergyFitterTask::FinishTaskOutput()
289 Warning("FinishTaskOutput", "No list defined");
296 AliAnalysisTaskSE::FinishTaskOutput();
299 //____________________________________________________________________
301 AliFMDEnergyFitterTask::Terminate(Option_t*)
309 DGUARD(fDebug,1,"Processing merged output of AliFMDEnergyFitterTask");
311 TList* list = dynamic_cast<TList*>(GetOutputData(1));
313 AliError(Form("No output list defined (%p)", GetOutputData(1)));
314 if (GetOutputData(1)) GetOutputData(1)->Print();
318 AliInfo("Fitting energy loss spectra");
319 fEnergyFitter.Fit(list);
321 // Make a deep copy and post that as output 2
322 TList* list2 = static_cast<TList*>(list->Clone(Form("%sResults",
328 //____________________________________________________________________
330 AliFMDEnergyFitterTask::Print(Option_t*) const