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"
24 #include <TDirectory.h>
27 //====================================================================
28 AliFMDEnergyFitterTask::AliFMDEnergyFitterTask()
29 : AliAnalysisTaskSE(),
40 //____________________________________________________________________
41 AliFMDEnergyFitterTask::AliFMDEnergyFitterTask(const char* name)
42 : AliAnalysisTaskSE(name),
44 fEventInspector("event"),
45 fEnergyFitter("energy"),
54 DefineOutput(1, TList::Class());
57 //____________________________________________________________________
58 AliFMDEnergyFitterTask::AliFMDEnergyFitterTask(const AliFMDEnergyFitterTask& o)
59 : AliAnalysisTaskSE(o),
60 fFirstEvent(o.fFirstEvent),
61 fEventInspector(o.fEventInspector),
62 fEnergyFitter(o.fEnergyFitter),
69 // o Object to copy from
71 DefineOutput(1, TList::Class());
74 //____________________________________________________________________
75 AliFMDEnergyFitterTask&
76 AliFMDEnergyFitterTask::operator=(const AliFMDEnergyFitterTask& o)
79 // Assignment operator
82 // o Object to assign from
85 // Reference to this object
87 AliAnalysisTaskSE::operator=(o);
89 fFirstEvent = o.fFirstEvent;
90 fEventInspector = o.fEventInspector;
91 fEnergyFitter = o.fEnergyFitter;
97 //____________________________________________________________________
99 AliFMDEnergyFitterTask::SetDebug(Int_t dbg)
102 // Set the debug level
107 fEventInspector.SetDebug(dbg);
108 fEnergyFitter.SetDebug(dbg);
111 //____________________________________________________________________
113 AliFMDEnergyFitterTask::Init()
116 // Initialize the task
122 //____________________________________________________________________
124 AliFMDEnergyFitterTask::InitializeSubs()
127 // Initialise the sub objects and stuff. Called on first event
130 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
131 fcm.Init(fEventInspector.GetCollisionSystem(),
132 fEventInspector.GetEnergy(),
133 fEventInspector.GetField(), 0);
135 TAxis vAxis(10,-10,10);
136 fEnergyFitter.Init(eAxis);
137 fEventInspector.Init(vAxis);
140 //____________________________________________________________________
142 AliFMDEnergyFitterTask::UserCreateOutputObjects()
145 // Create output objects
150 fEventInspector.DefineOutput(fList);
151 fEnergyFitter.DefineOutput(fList);
155 //____________________________________________________________________
157 AliFMDEnergyFitterTask::UserExec(Option_t*)
160 // Process each event
166 // static Int_t cnt = 0;
168 // Get the input data
169 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
170 // AliInfo(Form("Event # %6d (esd=%p)", cnt, esd));
172 AliWarning("No ESD event found for input event");
176 // On the first event, initialize the parameters
177 if (fFirstEvent && esd->GetESDRun()) {
178 fEventInspector.ReadRunDetails(esd);
180 AliInfo(Form("Initializing with parameters from the ESD:\n"
181 " AliESDEvent::GetBeamEnergy() ->%f\n"
182 " AliESDEvent::GetBeamType() ->%s\n"
183 " AliESDEvent::GetCurrentL3() ->%f\n"
184 " AliESDEvent::GetMagneticField()->%f\n"
185 " AliESDEvent::GetRunNumber() ->%d\n",
186 esd->GetBeamEnergy(),
189 esd->GetMagneticField(),
190 esd->GetRunNumber()));
194 // AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
195 // pars->SetParametersFromESD(esd);
196 // pars->PrintStatus();
201 Bool_t lowFlux = kFALSE;
205 UInt_t found = fEventInspector.Process(esd, triggers, lowFlux, ivz, vz);
206 if (found & AliFMDEventInspector::kNoEvent) return;
207 if (found & AliFMDEventInspector::kNoTriggers) return;
208 if (found & AliFMDEventInspector::kNoSPD) return;
209 if (found & AliFMDEventInspector::kNoFMD) return;
210 if (found & AliFMDEventInspector::kNoVertex) return;
211 if (found & AliFMDEventInspector::kBadVertex) return;
214 AliESDFMD* esdFMD = esd->GetFMDData();
215 // Do the energy stuff
216 if (!fEnergyFitter.Accumulate(*esdFMD, triggers & AliAODForwardMult::kEmpty)){
217 AliWarning("Energy fitter failed");
223 //____________________________________________________________________
225 AliFMDEnergyFitterTask::Terminate(Option_t*)
233 AliInfo(Form("Running terminate of %s", GetName()));
234 TList* list = dynamic_cast<TList*>(GetOutputData(1));
236 AliError(Form("No output list defined (%p)", GetOutputData(1)));
237 if (GetOutputData(1)) GetOutputData(1)->Print();
241 // Get our histograms from the container
242 TH1I* hEventsTr = 0;//static_cast<TH1I*>(list->FindObject("nEventsTr"));
243 TH1I* hEventsTrVtx = 0;//static_cast<TH1I*>(list->FindObject("nEventsTrVtx"));
245 if (!fEventInspector.FetchHistograms(list, hEventsTr,
246 hEventsTrVtx, hTriggers)) {
247 AliError(Form("Didn't get histograms from event selector "
248 "(hEventsTr=%p,hEventsTrVtx=%p)",
249 hEventsTr, hEventsTrVtx));
253 AliInfo("Fitting energy loss spectra");
254 fEnergyFitter.Fit(list);
257 //____________________________________________________________________
259 AliFMDEnergyFitterTask::Print(Option_t*) const