1 #include "AliFMDEnergyFitterTask.h"
3 // #include "AliFMDAnaParameters.h"
4 #include "AliESDEvent.h"
5 #include "AliAODForwardMult.h"
6 #include "AliForwardCorrectionManager.h"
7 #include "AliAnalysisManager.h"
9 #include <TDirectory.h>
12 //====================================================================
13 AliFMDEnergyFitterTask::AliFMDEnergyFitterTask()
14 : AliAnalysisTaskSE(),
22 //____________________________________________________________________
23 AliFMDEnergyFitterTask::AliFMDEnergyFitterTask(const char* name)
24 : AliAnalysisTaskSE(name),
26 fEventInspector("event"),
27 fEnergyFitter("energy"),
30 DefineOutput(1, TList::Class());
33 //____________________________________________________________________
34 AliFMDEnergyFitterTask::AliFMDEnergyFitterTask(const AliFMDEnergyFitterTask& o)
35 : AliAnalysisTaskSE(o),
36 fFirstEvent(o.fFirstEvent),
37 fEventInspector(o.fEventInspector),
38 fEnergyFitter(o.fEnergyFitter),
41 DefineOutput(1, TList::Class());
44 //____________________________________________________________________
45 AliFMDEnergyFitterTask&
46 AliFMDEnergyFitterTask::operator=(const AliFMDEnergyFitterTask& o)
48 AliAnalysisTaskSE::operator=(o);
50 fFirstEvent = o.fFirstEvent;
51 fEventInspector = o.fEventInspector;
52 fEnergyFitter = o.fEnergyFitter;
58 //____________________________________________________________________
60 AliFMDEnergyFitterTask::SetDebug(Int_t dbg)
62 fEventInspector.SetDebug(dbg);
63 fEnergyFitter.SetDebug(dbg);
66 //____________________________________________________________________
68 AliFMDEnergyFitterTask::Init()
73 //____________________________________________________________________
75 AliFMDEnergyFitterTask::InitializeSubs()
78 // AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
81 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
82 fcm.Init(fEventInspector.GetCollisionSystem(),
83 fEventInspector.GetEnergy(),
84 fEventInspector.GetField(), 0);
86 TAxis vAxis(10,-10,10);
87 fEnergyFitter.Init(eAxis);
88 fEventInspector.Init(vAxis);
91 //____________________________________________________________________
93 AliFMDEnergyFitterTask::UserCreateOutputObjects()
97 fEventInspector.DefineOutput(fList);
98 fEnergyFitter.DefineOutput(fList);
102 //____________________________________________________________________
104 AliFMDEnergyFitterTask::UserExec(Option_t*)
106 // static Int_t cnt = 0;
108 // Get the input data
109 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
110 // AliInfo(Form("Event # %6d (esd=%p)", cnt, esd));
112 AliWarning("No ESD event found for input event");
116 // On the first event, initialize the parameters
117 if (fFirstEvent && esd->GetESDRun()) {
118 fEventInspector.ReadRunDetails(esd);
120 AliInfo(Form("Initializing with parameters from the ESD:\n"
121 " AliESDEvent::GetBeamEnergy() ->%f\n"
122 " AliESDEvent::GetBeamType() ->%s\n"
123 " AliESDEvent::GetCurrentL3() ->%f\n"
124 " AliESDEvent::GetMagneticField()->%f\n"
125 " AliESDEvent::GetRunNumber() ->%d\n",
126 esd->GetBeamEnergy(),
129 esd->GetMagneticField(),
130 esd->GetRunNumber()));
134 // AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
135 // pars->SetParametersFromESD(esd);
136 // pars->PrintStatus();
141 Bool_t lowFlux = kFALSE;
145 UInt_t found = fEventInspector.Process(esd, triggers, lowFlux, ivz, vz);
146 if (found & AliFMDEventInspector::kNoEvent) return;
147 if (found & AliFMDEventInspector::kNoTriggers) return;
148 if (found & AliFMDEventInspector::kNoSPD) return;
149 if (found & AliFMDEventInspector::kNoFMD) return;
150 if (found & AliFMDEventInspector::kNoVertex) return;
151 if (found & AliFMDEventInspector::kBadVertex) return;
154 AliESDFMD* esdFMD = esd->GetFMDData();
155 // Do the energy stuff
156 if (!fEnergyFitter.Accumulate(*esdFMD, triggers & AliAODForwardMult::kEmpty)){
157 AliWarning("Energy fitter failed");
163 //____________________________________________________________________
165 AliFMDEnergyFitterTask::Terminate(Option_t*)
167 TList* list = dynamic_cast<TList*>(GetOutputData(1));
169 AliError(Form("No output list defined (%p)", GetOutputData(1)));
170 if (GetOutputData(1)) GetOutputData(1)->Print();
174 // Get our histograms from the container
175 TH1I* hEventsTr = 0;//static_cast<TH1I*>(list->FindObject("nEventsTr"));
176 TH1I* hEventsTrVtx = 0;//static_cast<TH1I*>(list->FindObject("nEventsTrVtx"));
178 if (!fEventInspector.FetchHistograms(list, hEventsTr,
179 hEventsTrVtx, hTriggers)) {
180 AliError(Form("Didn't get histograms from event selector "
181 "(hEventsTr=%p,hEventsTrVtx=%p)",
182 hEventsTr, hEventsTrVtx));
186 fEnergyFitter.Fit(list);
189 //____________________________________________________________________
191 AliFMDEnergyFitterTask::Print(Option_t*) const