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(),
49 //____________________________________________________________________
50 AliFMDEnergyFitterTask::AliFMDEnergyFitterTask(const char* name)
51 : AliAnalysisTaskSE(name),
53 fEventInspector("event"),
54 fEnergyFitter("energy"),
65 DefineOutput(1, TList::Class());
66 DefineOutput(2, TList::Class());
69 //____________________________________________________________________
70 AliFMDEnergyFitterTask::AliFMDEnergyFitterTask(const AliFMDEnergyFitterTask& o)
71 : AliAnalysisTaskSE(o),
72 fFirstEvent(o.fFirstEvent),
73 fEventInspector(o.fEventInspector),
74 fEnergyFitter(o.fEnergyFitter),
83 // o Object to copy from
85 DefineOutput(1, TList::Class());
86 DefineOutput(2, TList::Class());
89 //____________________________________________________________________
90 AliFMDEnergyFitterTask&
91 AliFMDEnergyFitterTask::operator=(const AliFMDEnergyFitterTask& o)
94 // Assignment operator
97 // o Object to assign from
100 // Reference to this object
102 AliAnalysisTaskSE::operator=(o);
104 fFirstEvent = o.fFirstEvent;
105 fEventInspector = o.fEventInspector;
106 fEnergyFitter = o.fEnergyFitter;
114 //____________________________________________________________________
116 AliFMDEnergyFitterTask::SetDebug(Int_t dbg)
119 // Set the debug level
124 fEventInspector.SetDebug(dbg);
125 fEnergyFitter.SetDebug(dbg);
128 //____________________________________________________________________
130 AliFMDEnergyFitterTask::Init()
133 // Initialize the task
139 //____________________________________________________________________
141 AliFMDEnergyFitterTask::InitializeSubs()
144 // Initialise the sub objects and stuff. Called on first event
147 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
148 UShort_t sys = fEventInspector.GetCollisionSystem();
149 UShort_t sNN = fEventInspector.GetEnergy();
150 Short_t fld = fEventInspector.GetField();
151 fcm.Init(sys, sNN, fld, 0);
153 TAxis vAxis(10,-10,10);
154 fEnergyFitter.Init(eAxis);
155 fEventInspector.Init(vAxis);
159 //____________________________________________________________________
161 AliFMDEnergyFitterTask::UserCreateOutputObjects()
164 // Create output objects
170 fEventInspector.DefineOutput(fList);
171 fEnergyFitter.DefineOutput(fList);
175 //____________________________________________________________________
177 AliFMDEnergyFitterTask::UserExec(Option_t*)
180 // Process each event
186 // static Int_t cnt = 0;
188 // Get the input data
190 AliMCEvent* mcevent = MCEvent();
192 AliHeader* header = mcevent->Header();
193 AliGenHijingEventHeader* hijingHeader =
194 dynamic_cast<AliGenHijingEventHeader*>(header->GenEventHeader());
196 Float_t b = hijingHeader->ImpactParameter();
197 if(b<fbLow || b>fbHigh) return;
199 std::cout<<"Selecting event with impact parameter "<<b<<std::endl;
204 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
205 // AliInfo(Form("Event # %6d (esd=%p)", cnt, esd));
207 AliWarning("No ESD event found for input event");
211 // On the first event, initialize the parameters
212 if (fFirstEvent && esd->GetESDRun()) {
213 fEventInspector.ReadRunDetails(esd);
215 AliInfo(Form("Initializing with parameters from the ESD:\n"
216 " AliESDEvent::GetBeamEnergy() ->%f\n"
217 " AliESDEvent::GetBeamType() ->%s\n"
218 " AliESDEvent::GetCurrentL3() ->%f\n"
219 " AliESDEvent::GetMagneticField()->%f\n"
220 " AliESDEvent::GetRunNumber() ->%d\n",
221 esd->GetBeamEnergy(),
224 esd->GetMagneticField(),
225 esd->GetRunNumber()));
229 // AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
230 // pars->SetParametersFromESD(esd);
231 // pars->PrintStatus();
236 Bool_t lowFlux = kFALSE;
241 UShort_t nClusters = 0;
242 UInt_t found = fEventInspector.Process(esd, triggers, lowFlux,
243 ivz, vz, cent, nClusters);
244 if (found & AliFMDEventInspector::kNoEvent) return;
245 if (found & AliFMDEventInspector::kNoTriggers) return;
246 if (found & AliFMDEventInspector::kNoSPD) return;
247 if (found & AliFMDEventInspector::kNoFMD) return;
248 if (found & AliFMDEventInspector::kNoVertex) return;
249 if (found & AliFMDEventInspector::kBadVertex) return;
252 // if( cent < 40 || cent >50 ) return;
253 // else std::cout<<"selecting event with cent "<<cent<<std::endl;
257 AliESDFMD* esdFMD = esd->GetFMDData();
258 // Do the energy stuff
259 if (!fEnergyFitter.Accumulate(*esdFMD, cent,
260 triggers & AliAODForwardMult::kEmpty)){
261 AliWarning("Energy fitter failed");
267 //____________________________________________________________________
269 AliFMDEnergyFitterTask::Terminate(Option_t*)
277 AliInfo(Form("Running terminate of %s", GetName()));
278 TList* list = dynamic_cast<TList*>(GetOutputData(1));
280 AliError(Form("No output list defined (%p)", GetOutputData(1)));
281 if (GetOutputData(1)) GetOutputData(1)->Print();
285 AliInfo("Fitting energy loss spectra");
286 fEnergyFitter.Fit(list);
288 // Make a deep copy and post that as output 2
289 TList* list2 = static_cast<TList*>(list->Clone(Form("%sResults",
295 //____________________________________________________________________
297 AliFMDEnergyFitterTask::Print(Option_t*) const