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 if (&o == this) return *this;
103 AliAnalysisTaskSE::operator=(o);
105 fFirstEvent = o.fFirstEvent;
106 fEventInspector = o.fEventInspector;
107 fEnergyFitter = o.fEnergyFitter;
115 //____________________________________________________________________
117 AliFMDEnergyFitterTask::SetDebug(Int_t dbg)
120 // Set the debug level
125 fEventInspector.SetDebug(dbg);
126 fEnergyFitter.SetDebug(dbg);
129 //____________________________________________________________________
131 AliFMDEnergyFitterTask::Init()
134 // Initialize the task
140 //____________________________________________________________________
142 AliFMDEnergyFitterTask::InitializeSubs()
145 // Initialise the sub objects and stuff. Called on first event
148 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
149 UShort_t sys = fEventInspector.GetCollisionSystem();
150 UShort_t sNN = fEventInspector.GetEnergy();
151 Short_t fld = fEventInspector.GetField();
152 fcm.Init(sys, sNN, fld, 0);
154 TAxis vAxis(10,-10,10);
155 fEnergyFitter.Init(eAxis);
156 fEventInspector.Init(vAxis);
160 //____________________________________________________________________
162 AliFMDEnergyFitterTask::UserCreateOutputObjects()
165 // Create output objects
171 fEventInspector.DefineOutput(fList);
172 fEnergyFitter.DefineOutput(fList);
176 //____________________________________________________________________
178 AliFMDEnergyFitterTask::UserExec(Option_t*)
181 // Process each event
187 // static Int_t cnt = 0;
189 // Get the input data
191 AliMCEvent* mcevent = MCEvent();
193 AliHeader* header = mcevent->Header();
194 AliGenHijingEventHeader* hijingHeader =
195 dynamic_cast<AliGenHijingEventHeader*>(header->GenEventHeader());
197 Float_t b = hijingHeader->ImpactParameter();
198 if(b<fbLow || b>fbHigh) return;
200 std::cout<<"Selecting event with impact parameter "<<b<<std::endl;
205 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
206 // AliInfo(Form("Event # %6d (esd=%p)", cnt, esd));
208 AliWarning("No ESD event found for input event");
212 // On the first event, initialize the parameters
213 if (fFirstEvent && esd->GetESDRun()) {
214 fEventInspector.ReadRunDetails(esd);
216 AliInfo(Form("Initializing with parameters from the ESD:\n"
217 " AliESDEvent::GetBeamEnergy() ->%f\n"
218 " AliESDEvent::GetBeamType() ->%s\n"
219 " AliESDEvent::GetCurrentL3() ->%f\n"
220 " AliESDEvent::GetMagneticField()->%f\n"
221 " AliESDEvent::GetRunNumber() ->%d\n",
222 esd->GetBeamEnergy(),
225 esd->GetMagneticField(),
226 esd->GetRunNumber()));
230 // AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
231 // pars->SetParametersFromESD(esd);
232 // pars->PrintStatus();
237 Bool_t lowFlux = kFALSE;
242 UShort_t nClusters = 0;
243 UInt_t found = fEventInspector.Process(esd, triggers, lowFlux,
244 ivz, vz, cent, nClusters);
245 if (found & AliFMDEventInspector::kNoEvent) return;
246 if (found & AliFMDEventInspector::kNoTriggers) return;
247 if (found & AliFMDEventInspector::kNoSPD) return;
248 if (found & AliFMDEventInspector::kNoFMD) return;
249 if (found & AliFMDEventInspector::kNoVertex) return;
250 if (found & AliFMDEventInspector::kBadVertex) return;
253 // if( cent < 40 || cent >50 ) return;
254 // else std::cout<<"selecting event with cent "<<cent<<std::endl;
258 AliESDFMD* esdFMD = esd->GetFMDData();
259 // Do the energy stuff
260 if (!fEnergyFitter.Accumulate(*esdFMD, cent,
261 triggers & AliAODForwardMult::kEmpty)){
262 AliWarning("Energy fitter failed");
268 //____________________________________________________________________
270 AliFMDEnergyFitterTask::Terminate(Option_t*)
278 AliInfo(Form("Running terminate of %s", GetName()));
279 TList* list = dynamic_cast<TList*>(GetOutputData(1));
281 AliError(Form("No output list defined (%p)", GetOutputData(1)));
282 if (GetOutputData(1)) GetOutputData(1)->Print();
286 AliInfo("Fitting energy loss spectra");
287 fEnergyFitter.Fit(list);
289 // Make a deep copy and post that as output 2
290 TList* list2 = static_cast<TList*>(list->Clone(Form("%sResults",
296 //____________________________________________________________________
298 AliFMDEnergyFitterTask::Print(Option_t*) const