]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/AliFMDEnergyFitterTask.cxx
Configuration script
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliFMDEnergyFitterTask.cxx
CommitLineData
7984e5f7 1//
2// Histogram and fit the energy loss distributions for the FMD
3//
4// Inputs:
5// - AliESDEvent
6//
7// Outputs:
8// - None
9//
10// Histograms:
11//
12// Corrections used:
13// - None
14//
15//
16//
0bd4b00f 17#include "AliFMDEnergyFitterTask.h"
18#include "AliLog.h"
0bd4b00f 19#include "AliESDEvent.h"
c8b1a7db 20#include "AliESDFMD.h"
21#include "AliMCEvent.h"
0bd4b00f 22#include "AliAODForwardMult.h"
0bd4b00f 23#include "AliAnalysisManager.h"
c8b1a7db 24#include "AliForwardCorrectionManager.h"
0bd4b00f 25#include <TH1.h>
26#include <TDirectory.h>
27#include <TTree.h>
72cc12cd 28#include <TFile.h>
e65b8b56 29#include <TROOT.h>
e58000b7 30#include <iostream>
0bd4b00f 31
32//====================================================================
33AliFMDEnergyFitterTask::AliFMDEnergyFitterTask()
c8b1a7db 34 : AliBaseESDTask(),
0ccdab7b 35 fEventInspector(),
36 fESDFixer(),
0bd4b00f 37 fEnergyFitter(),
a03f01f7 38 fOnlyMB(false)
0bd4b00f 39{
7984e5f7 40 //
41 // Constructor
42 //
5ca83fee 43 DGUARD(fDebug, 3,"Default CTOR of AliFMDEnergyFitterTask");
c8b1a7db 44 fCloneList = true;
0bd4b00f 45}
46
47//____________________________________________________________________
48AliFMDEnergyFitterTask::AliFMDEnergyFitterTask(const char* name)
b22c1c9a 49 : AliBaseESDTask(name, "AliFMDEnergyFitterTask",
50 &(AliForwardCorrectionManager::Instance())),
0bd4b00f 51 fEventInspector("event"),
0ccdab7b 52 fESDFixer("esdFizer"),
0bd4b00f 53 fEnergyFitter("energy"),
a03f01f7 54 fOnlyMB(false)
0bd4b00f 55{
7984e5f7 56 //
57 // Constructor
58 //
59 // Parameters:
60 // name Name of task
61 //
5ca83fee 62 DGUARD(fDebug, 3,"Named CTOR of AliFMDEnergyFitterTask: %s", name);
c8b1a7db 63 fCloneList = true;
0bd4b00f 64}
65
0bd4b00f 66
67//____________________________________________________________________
68void
69AliFMDEnergyFitterTask::SetDebug(Int_t dbg)
70{
7984e5f7 71 //
72 // Set the debug level
73 //
74 // Parameters:
75 // dbg Debug level
76 //
c8b1a7db 77 AliBaseESDTask::SetDebug(dbg);
0bd4b00f 78 fEnergyFitter.SetDebug(dbg);
79}
0bd4b00f 80//____________________________________________________________________
c8b1a7db 81TAxis*
82AliFMDEnergyFitterTask::DefaultEtaAxis() const
0bd4b00f 83{
c8b1a7db 84 static TAxis* a = new TAxis(0, 0, 0);
85 return a;
0bd4b00f 86}
0bd4b00f 87//____________________________________________________________________
c8b1a7db 88TAxis*
89AliFMDEnergyFitterTask::DefaultVertexAxis() const
0bd4b00f 90{
c8b1a7db 91 static TAxis* a = new TAxis(10, -10, 10);
92 return a;
0bd4b00f 93}
94
0b7de667 95//____________________________________________________________________
96Bool_t
97AliFMDEnergyFitterTask::Setup()
98{
99 fEnergyFitter.Init();
100 return true;
101}
102
0bd4b00f 103//____________________________________________________________________
c8b1a7db 104Bool_t
105AliFMDEnergyFitterTask::Book()
0bd4b00f 106{
7984e5f7 107 //
108 // Create output objects
109 //
110 //
6ab100ec 111 DGUARD(fDebug,1,"Create output objects of AliFMDEnergyFitterTask");
0bd4b00f 112
c8b1a7db 113 // We don't need any corrections for this task
0ccdab7b 114 fNeededCorrections = 0;
c8b1a7db 115 fExtraCorrections = 0;
0ccdab7b 116 if (fESDFixer.IsUseNoiseCorrection())
117 fNeededCorrections = AliForwardCorrectionManager::kNoiseGain;
c8b1a7db 118
0ccdab7b 119 fESDFixer .CreateOutputObjects(fList);
5934a3e3 120 fEnergyFitter.CreateOutputObjects(fList);
0bd4b00f 121
a03f01f7 122 fList->Add(AliForwardUtil::MakeParameter("onlyMB", fOnlyMB));
c8b1a7db 123 return true;
0bd4b00f 124}
0ccdab7b 125//____________________________________________________________________
126void
127AliFMDEnergyFitterTask::PreCorrections(const AliESDEvent* esd)
128{
129 if (!esd) return;
130
131 AliESDFMD* esdFMD = esd->GetFMDData();
132 if (!esdFMD) return;
133
134 // TODO: We should always disable this on MC!
135 Int_t tgt = fESDFixer.FindTargetNoiseFactor(*esdFMD, false);
136 if (tgt <= 0) {
137 // If the target noise factor is 0 or less, disable the noise/gain
138 // correction.
139 fESDFixer.SetRecoNoiseFactor(4);
140 fNeededCorrections ^= AliForwardCorrectionManager::kNoiseGain;
141 }
142 else
143 AliWarning("The noise corrector has been enabled!");
144}
145
0bd4b00f 146//____________________________________________________________________
c8b1a7db 147Bool_t
148AliFMDEnergyFitterTask::PreData(const TAxis& /*vertex*/, const TAxis& eta)
149{
150 //
151 // Initialise the sub objects and stuff. Called on first event
152 //
153 //
154 DGUARD(fDebug,1,"Initialize subs of AliFMDEnergyFitterTask");
155
156 fEnergyFitter.SetupForData(eta);
157
0ccdab7b 158 Print();
c8b1a7db 159 return true;
160}
161
162//____________________________________________________________________
163Bool_t
164AliFMDEnergyFitterTask::Event(AliESDEvent& esd)
0bd4b00f 165{
7984e5f7 166 //
167 // Process each event
168 //
169 // Parameters:
170 // option Not used
171 //
172
0bd4b00f 173 // static Int_t cnt = 0;
174 // cnt++;
175 // Get the input data
db298fc6 176 DGUARD(fDebug,3,"Analyse event of AliFMDEnergyFitterTask");
5934a3e3 177 // --- Read in the data --------------------------------------------
178 LoadBranches();
179
5bb5d1f6 180 Bool_t lowFlux = kFALSE;
181 UInt_t triggers = 0;
182 UShort_t ivz = 0;
5ca83fee 183 TVector3 ip;
5bb5d1f6 184 Double_t cent = 0;
185 UShort_t nClusters = 0;
c8b1a7db 186 UInt_t found = fEventInspector.Process(&esd, triggers, lowFlux,
5ca83fee 187 ivz, ip, cent, nClusters);
c8b1a7db 188 if (found & AliFMDEventInspector::kNoEvent) return false;
189 if (found & AliFMDEventInspector::kNoTriggers) return false;
190 if (found & AliFMDEventInspector::kNoSPD) return false;
191 if (found & AliFMDEventInspector::kNoFMD) return false;
192 if (found & AliFMDEventInspector::kNoVertex) return false;
193 if (found & AliFMDEventInspector::kBadVertex) return false;
81775aba 194
195 // do not process pile-up, A, C, and E events
c8b1a7db 196 if (triggers & AliAODForwardMult::kPileUp) return false;
197 if (triggers & AliAODForwardMult::kA) return false;
198 if (triggers & AliAODForwardMult::kC) return false;
199 if (triggers & AliAODForwardMult::kE) return false;
12fffad7 200
81775aba 201 // We want only the events found by off-line
c8b1a7db 202 if (!(triggers & AliAODForwardMult::kOffline)) return false;
81775aba 203
a03f01f7 204 // Perhaps we should also insist on MB only
205 if (fOnlyMB && (!(triggers & AliAODForwardMult::kInel))) return false;
206
12fffad7 207 // if(cent > 0) {
208 // if( cent < 40 || cent >50 ) return;
209 // else std::cout<<"selecting event with cent "<<cent<<std::endl;
210 // }
211
0bd4b00f 212 // Get FMD data
c8b1a7db 213 AliESDFMD* esdFMD = esd.GetFMDData();
0ccdab7b 214
215 // Fix up ESD
216 fESDFixer.Fix(*esdFMD, ip.Z());
217
0bd4b00f 218 // Do the energy stuff
5e4d905e 219 if (!fEnergyFitter.Accumulate(*esdFMD, cent,
220 triggers & AliAODForwardMult::kEmpty)){
0bd4b00f 221 AliWarning("Energy fitter failed");
c8b1a7db 222 return false;
0bd4b00f 223 }
0bd4b00f 224
c8b1a7db 225 return true;
db298fc6 226}
227
0bd4b00f 228//____________________________________________________________________
c8b1a7db 229Bool_t
230AliFMDEnergyFitterTask::Finalize()
0bd4b00f 231{
7984e5f7 232 //
233 // End of job
234 //
235 // Parameters:
236 // option Not used
237 //
6ab100ec 238 DGUARD(fDebug,1,"Processing merged output of AliFMDEnergyFitterTask");
239
1c762251 240 AliInfo("Fitting energy loss spectra");
c8b1a7db 241 fEnergyFitter.Fit(fResults);
72cc12cd 242
c8b1a7db 243 return true;
0bd4b00f 244}
245
a03f01f7 246#define PFB(N,FLAG) \
247 do { \
248 AliForwardUtil::PrintName(N); \
249 std::cout << std::boolalpha << (FLAG) << std::noboolalpha << std::endl; \
250 } while(false)
0bd4b00f 251//____________________________________________________________________
252void
e65b8b56 253AliFMDEnergyFitterTask::Print(Option_t* option) const
0bd4b00f 254{
7984e5f7 255 //
256 // Print information
257 //
258 // Parameters:
259 // option Not used
260 //
c8b1a7db 261 AliBaseESDTask::Print(option);
e65b8b56 262 gROOT->IncreaseDirLevel();
a03f01f7 263 PFB("Only MB", fOnlyMB);
0ccdab7b 264 fESDFixer .Print(option);
e65b8b56 265 fEnergyFitter.Print(option);
e65b8b56 266 gROOT->DecreaseDirLevel();
0bd4b00f 267}
268
269//
270// EOF
271//