]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FORWARD/analysis2/AliForwardMultiplicityBase.cxx
Code clean-up in dN/deta calculation.
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliForwardMultiplicityBase.cxx
CommitLineData
1a26066e 1//====================================================================
7984e5f7 2//
3// Base class for classes that calculate the multiplicity in the
4// forward regions event-by-event
5//
6// Inputs:
7// - AliESDEvent
8//
9// Outputs:
10// - AliAODForwardMult
11//
12// Histograms
13//
14// Corrections used
1a26066e 15#include "AliForwardMultiplicityBase.h"
1174780f 16#include "AliForwardCorrectionManager.h"
fb3430ac 17#include "AliForwardUtil.h"
1a26066e 18#include "AliLog.h"
19#include "AliAODHandler.h"
20#include "AliInputEventHandler.h"
21#include "AliAnalysisManager.h"
1174780f 22#include "AliFMDEventInspector.h"
1174780f 23#include "AliFMDSharingFilter.h"
24#include "AliFMDDensityCalculator.h"
72cc12cd 25#include "AliFMDCorrector.h"
1174780f 26#include "AliFMDHistCollector.h"
7ec4d843 27#include "AliESDEvent.h"
1a26066e 28#include <TROOT.h>
fb3430ac 29#include <TAxis.h>
3c5497d0 30#include <iostream>
31#include <iomanip>
1a26066e 32
33//====================================================================
19abe41d 34AliForwardMultiplicityBase::AliForwardMultiplicityBase(const char* name)
35 : AliAnalysisTaskSE(name),
9d05ffeb 36 fEnableLowFlux(false),
19abe41d 37 fFirstEvent(true),
38 fCorrManager(0)
39{
40 // Set our persistent pointer
41 fCorrManager = &AliForwardCorrectionManager::Instance();
331c3502 42 fBranchNames =
43 "ESD:AliESDRun.,AliESDHeader.,AliMultiplicity.,"
44 "AliESDFMD.,SPDVertex.,PrimaryVertex.";
19abe41d 45}
46
fb3430ac 47//____________________________________________________________________
48AliForwardMultiplicityBase&
49AliForwardMultiplicityBase::operator=(const AliForwardMultiplicityBase& o)
50{
51 fEnableLowFlux = o.fEnableLowFlux;
52 fFirstEvent = o.fFirstEvent;
53 fCorrManager = o.fCorrManager;
54 return *this;
55}
56
19abe41d 57//____________________________________________________________________
1174780f 58Bool_t
59AliForwardMultiplicityBase::CheckCorrections(UInt_t what) const
60{
61 //
62 // Check if all needed corrections are there and accounted for. If not,
63 // do a Fatal exit
64 //
65 // Parameters:
66 // what Which corrections is needed
67 //
68 // Return:
69 // true if all present, false otherwise
70 //
71
72 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
73 // Check that we have the energy loss fits, needed by
74 // AliFMDSharingFilter
75 // AliFMDDensityCalculator
76 if (what & AliForwardCorrectionManager::kELossFits && !fcm.GetELossFit()) {
77 AliFatal(Form("No energy loss fits"));
78 return false;
79 }
80 // Check that we have the double hit correction - (optionally) used by
81 // AliFMDDensityCalculator
82 if (what & AliForwardCorrectionManager::kDoubleHit && !fcm.GetDoubleHit()) {
83 AliFatal("No double hit corrections");
84 return false;
85 }
86 // Check that we have the secondary maps, needed by
72cc12cd 87 // AliFMDCorrector
1174780f 88 // AliFMDHistCollector
89 if (what & AliForwardCorrectionManager::kSecondaryMap &&
90 !fcm.GetSecondaryMap()) {
91 AliFatal("No secondary corrections");
92 return false;
93 }
94 // Check that we have the vertex bias correction, needed by
72cc12cd 95 // AliFMDCorrector
1174780f 96 if (what & AliForwardCorrectionManager::kVertexBias &&
97 !fcm.GetVertexBias()) {
98 AliFatal("No event vertex bias corrections");
99 return false;
100 }
101 // Check that we have the merging efficiencies, optionally used by
72cc12cd 102 // AliFMDCorrector
1174780f 103 if (what & AliForwardCorrectionManager::kMergingEfficiency &&
104 !fcm.GetMergingEfficiency()) {
105 AliFatal("No merging efficiencies");
106 return false;
107 }
cc83fca2 108 // Check that we have the acceptance correction, needed by
109 // AliFMDCorrector
110 if (what & AliForwardCorrectionManager::kAcceptance &&
111 !fcm.GetAcceptance()) {
112 AliFatal("No acceptance corrections");
113 return false;
114 }
1174780f 115 return true;
116}
7ec4d843 117//____________________________________________________________________
118Bool_t
19abe41d 119AliForwardMultiplicityBase::ReadCorrections(const TAxis*& pe,
120 const TAxis*& pv,
121 Bool_t mc)
7ec4d843 122{
fb3430ac 123 //
124 // Read corrections
125 //
126 //
7ec4d843 127 UInt_t what = AliForwardCorrectionManager::kAll;
128 if (!fEnableLowFlux)
129 what ^= AliForwardCorrectionManager::kDoubleHit;
7ec4d843 130 if (!GetCorrections().IsUseVertexBias())
131 what ^= AliForwardCorrectionManager::kVertexBias;
132 if (!GetCorrections().IsUseAcceptance())
133 what ^= AliForwardCorrectionManager::kAcceptance;
134 if (!GetCorrections().IsUseMergingEfficiency())
135 what ^= AliForwardCorrectionManager::kMergingEfficiency;
136
137 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
138 if (!fcm.Init(GetEventInspector().GetCollisionSystem(),
19abe41d 139 GetEventInspector().GetEnergy(),
140 GetEventInspector().GetField(),
141 mc,
142 what)) return false;
7ec4d843 143 if (!CheckCorrections(what)) return false;
144
19abe41d 145 // Sett our persistency pointer
146 // fCorrManager = &fcm;
147
7ec4d843 148 // Get the eta axis from the secondary maps - if read in
149 if (!pe) {
150 pe = fcm.GetEtaAxis();
151 if (!pe) AliFatal("No eta axis defined");
152 }
153 // Get the vertex axis from the secondary maps - if read in
154 if (!pv) {
155 pv = fcm.GetVertexAxis();
156 if (!pv) AliFatal("No vertex axis defined");
157 }
158
159 return true;
160}
161//____________________________________________________________________
162AliESDEvent*
163AliForwardMultiplicityBase::GetESDEvent()
164{
fb3430ac 165 //
166 // Get the ESD event. IF this is the first event, initialise
167 //
7ec4d843 168 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
169 if (!esd) {
170 AliWarning("No ESD event found for input event");
171 return 0;
172 }
1174780f 173
7ec4d843 174 // On the first event, initialize the parameters
175 if (fFirstEvent && esd->GetESDRun()) {
176 GetEventInspector().ReadRunDetails(esd);
177
178 AliInfo(Form("Initializing with parameters from the ESD:\n"
179 " AliESDEvent::GetBeamEnergy() ->%f\n"
180 " AliESDEvent::GetBeamType() ->%s\n"
181 " AliESDEvent::GetCurrentL3() ->%f\n"
182 " AliESDEvent::GetMagneticField()->%f\n"
183 " AliESDEvent::GetRunNumber() ->%d\n",
184 esd->GetBeamEnergy(),
185 esd->GetBeamType(),
186 esd->GetCurrentL3(),
187 esd->GetMagneticField(),
188 esd->GetRunNumber()));
189
190 fFirstEvent = false;
191
192 InitializeSubs();
193 }
194 return esd;
195}
1174780f 196//____________________________________________________________________
1a26066e 197void
198AliForwardMultiplicityBase::MarkEventForStore() const
199{
200 // Make sure the AOD tree is filled
201 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
202 AliAODHandler* ah =
203 dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
204 if (!ah)
205 AliFatal("No AOD output handler set in analysis manager");
206
207 ah->SetFillAOD(kTRUE);
208}
209
210//____________________________________________________________________
211void
212AliForwardMultiplicityBase::Print(Option_t* option) const
213{
7984e5f7 214 //
215 // Print information
216 //
217 // Parameters:
218 // option Not used
219 //
3c5497d0 220
1a26066e 221 std::cout << "AliForwardMultiplicityBase: " << GetName() << "\n"
9bff843b 222 << " Enable low flux code: " << (fEnableLowFlux ? "yes" : "no")
223 << "\n"
3c5497d0 224 << " Off-line trigger mask: 0x"
225 << std::hex << std::setfill('0')
226 << std::setw (8) << fOfflineTriggerMask
227 << std::dec << std::setfill (' ') << std::endl;
1174780f 228 gROOT->IncreaseDirLevel();
3c5497d0 229 if (fCorrManager) fCorrManager->Print();
9bff843b 230 else
231 std::cout << " Correction manager not set yet" << std::endl;
1174780f 232 GetEventInspector() .Print(option);
1174780f 233 GetSharingFilter() .Print(option);
234 GetDensityCalculator().Print(option);
235 GetCorrections() .Print(option);
236 GetHistCollector() .Print(option);
237 gROOT->DecreaseDirLevel();
1a26066e 238}
239
1174780f 240
1a26066e 241//
242// EOF
243//