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,0,"Default CTOR of AliFMDEnergyFitterTask");
50 //____________________________________________________________________
51 AliFMDEnergyFitterTask::AliFMDEnergyFitterTask(const char* name)
52 : AliAnalysisTaskSE(name),
54 fEventInspector("event"),
55 fEnergyFitter("energy"),
66 DGUARD(fDebug,0,"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,0,"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
108 DGUARD(fDebug,3,"Assignment of AliFMDEnergyFitterTask");
109 if (&o == this) return *this;
110 AliAnalysisTaskSE::operator=(o);
112 fFirstEvent = o.fFirstEvent;
113 fEventInspector = o.fEventInspector;
114 fEnergyFitter = o.fEnergyFitter;
122 //____________________________________________________________________
124 AliFMDEnergyFitterTask::SetDebug(Int_t dbg)
127 // Set the debug level
132 fEventInspector.SetDebug(dbg);
133 fEnergyFitter.SetDebug(dbg);
136 //____________________________________________________________________
138 AliFMDEnergyFitterTask::Init()
141 // Initialize the task
144 DGUARD(fDebug,1,"Initialize of AliFMDEnergyFitterTask");
148 //____________________________________________________________________
150 AliFMDEnergyFitterTask::InitializeSubs()
153 // Initialise the sub objects and stuff. Called on first event
156 DGUARD(fDebug,1,"Initialize subs of AliFMDEnergyFitterTask");
157 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
158 UShort_t sys = fEventInspector.GetCollisionSystem();
159 UShort_t sNN = fEventInspector.GetEnergy();
160 Short_t fld = fEventInspector.GetField();
161 fcm.Init(sys, sNN, fld, 0);
163 TAxis vAxis(10,-10,10);
164 fEnergyFitter.Init(eAxis);
165 fEventInspector.Init(vAxis);
169 //____________________________________________________________________
171 AliFMDEnergyFitterTask::UserCreateOutputObjects()
174 // Create output objects
177 DGUARD(fDebug,1,"Create output objects of AliFMDEnergyFitterTask");
181 fEventInspector.DefineOutput(fList);
182 fEnergyFitter.DefineOutput(fList);
186 //____________________________________________________________________
188 AliFMDEnergyFitterTask::UserExec(Option_t*)
191 // Process each event
197 // static Int_t cnt = 0;
199 // Get the input data
200 DGUARD(fDebug,1,"Analyse event of AliFMDEnergyFitterTask");
202 AliMCEvent* mcevent = MCEvent();
204 AliHeader* header = mcevent->Header();
205 AliGenHijingEventHeader* hijingHeader =
206 dynamic_cast<AliGenHijingEventHeader*>(header->GenEventHeader());
208 Float_t b = hijingHeader->ImpactParameter();
209 if(b<fbLow || b>fbHigh) return;
211 std::cout<<"Selecting event with impact parameter "<<b<<std::endl;
216 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
217 // AliInfo(Form("Event # %6d (esd=%p)", cnt, esd));
219 AliWarning("No ESD event found for input event");
223 // On the first event, initialize the parameters
224 if (fFirstEvent && esd->GetESDRun()) {
225 fEventInspector.ReadRunDetails(esd);
227 AliInfo(Form("Initializing with parameters from the ESD:\n"
228 " AliESDEvent::GetBeamEnergy() ->%f\n"
229 " AliESDEvent::GetBeamType() ->%s\n"
230 " AliESDEvent::GetCurrentL3() ->%f\n"
231 " AliESDEvent::GetMagneticField()->%f\n"
232 " AliESDEvent::GetRunNumber() ->%d\n",
233 esd->GetBeamEnergy(),
236 esd->GetMagneticField(),
237 esd->GetRunNumber()));
241 // AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
242 // pars->SetParametersFromESD(esd);
243 // pars->PrintStatus();
248 Bool_t lowFlux = kFALSE;
253 UShort_t nClusters = 0;
254 UInt_t found = fEventInspector.Process(esd, triggers, lowFlux,
255 ivz, vz, cent, nClusters);
256 if (found & AliFMDEventInspector::kNoEvent) return;
257 if (found & AliFMDEventInspector::kNoTriggers) return;
258 if (found & AliFMDEventInspector::kNoSPD) return;
259 if (found & AliFMDEventInspector::kNoFMD) return;
260 if (found & AliFMDEventInspector::kNoVertex) return;
261 if (found & AliFMDEventInspector::kBadVertex) return;
264 // if( cent < 40 || cent >50 ) return;
265 // else std::cout<<"selecting event with cent "<<cent<<std::endl;
269 AliESDFMD* esdFMD = esd->GetFMDData();
270 // Do the energy stuff
271 if (!fEnergyFitter.Accumulate(*esdFMD, cent,
272 triggers & AliAODForwardMult::kEmpty)){
273 AliWarning("Energy fitter failed");
279 //____________________________________________________________________
281 AliFMDEnergyFitterTask::Terminate(Option_t*)
289 DGUARD(fDebug,1,"Processing merged output of AliFMDEnergyFitterTask");
291 TList* list = dynamic_cast<TList*>(GetOutputData(1));
293 AliError(Form("No output list defined (%p)", GetOutputData(1)));
294 if (GetOutputData(1)) GetOutputData(1)->Print();
298 AliInfo("Fitting energy loss spectra");
299 fEnergyFitter.Fit(list);
301 // Make a deep copy and post that as output 2
302 TList* list2 = static_cast<TList*>(list->Clone(Form("%sResults",
308 //____________________________________________________________________
310 AliFMDEnergyFitterTask::Print(Option_t*) const