]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/AliForwardMultiplicityBase.cxx
First half of changes for displaced vertices - second half to follow
[u/mrichter/AliRoot.git] / PWGLF / 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"
2b556440 27#include "AliFMDEventPlaneFinder.h"
7ec4d843 28#include "AliESDEvent.h"
1a26066e 29#include <TROOT.h>
fb3430ac 30#include <TAxis.h>
5bb5d1f6 31#include <THStack.h>
3c5497d0 32#include <iostream>
33#include <iomanip>
1a26066e 34
35//====================================================================
19abe41d 36AliForwardMultiplicityBase::AliForwardMultiplicityBase(const char* name)
37 : AliAnalysisTaskSE(name),
9d05ffeb 38 fEnableLowFlux(false),
19abe41d 39 fFirstEvent(true),
40 fCorrManager(0)
41{
42 // Set our persistent pointer
43 fCorrManager = &AliForwardCorrectionManager::Instance();
331c3502 44 fBranchNames =
45 "ESD:AliESDRun.,AliESDHeader.,AliMultiplicity.,"
46 "AliESDFMD.,SPDVertex.,PrimaryVertex.";
19abe41d 47}
48
fb3430ac 49//____________________________________________________________________
50AliForwardMultiplicityBase&
51AliForwardMultiplicityBase::operator=(const AliForwardMultiplicityBase& o)
52{
d015ecfe 53 if (&o == this) return *this;
fb3430ac 54 fEnableLowFlux = o.fEnableLowFlux;
55 fFirstEvent = o.fFirstEvent;
56 fCorrManager = o.fCorrManager;
57 return *this;
58}
59
19abe41d 60//____________________________________________________________________
1174780f 61Bool_t
62AliForwardMultiplicityBase::CheckCorrections(UInt_t what) const
63{
64 //
65 // Check if all needed corrections are there and accounted for. If not,
66 // do a Fatal exit
67 //
68 // Parameters:
69 // what Which corrections is needed
70 //
71 // Return:
72 // true if all present, false otherwise
73 //
74
75 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
76 // Check that we have the energy loss fits, needed by
77 // AliFMDSharingFilter
78 // AliFMDDensityCalculator
79 if (what & AliForwardCorrectionManager::kELossFits && !fcm.GetELossFit()) {
80 AliFatal(Form("No energy loss fits"));
81 return false;
82 }
83 // Check that we have the double hit correction - (optionally) used by
84 // AliFMDDensityCalculator
85 if (what & AliForwardCorrectionManager::kDoubleHit && !fcm.GetDoubleHit()) {
86 AliFatal("No double hit corrections");
87 return false;
88 }
89 // Check that we have the secondary maps, needed by
72cc12cd 90 // AliFMDCorrector
1174780f 91 // AliFMDHistCollector
92 if (what & AliForwardCorrectionManager::kSecondaryMap &&
93 !fcm.GetSecondaryMap()) {
94 AliFatal("No secondary corrections");
95 return false;
96 }
97 // Check that we have the vertex bias correction, needed by
72cc12cd 98 // AliFMDCorrector
1174780f 99 if (what & AliForwardCorrectionManager::kVertexBias &&
100 !fcm.GetVertexBias()) {
101 AliFatal("No event vertex bias corrections");
102 return false;
103 }
104 // Check that we have the merging efficiencies, optionally used by
72cc12cd 105 // AliFMDCorrector
1174780f 106 if (what & AliForwardCorrectionManager::kMergingEfficiency &&
107 !fcm.GetMergingEfficiency()) {
108 AliFatal("No merging efficiencies");
109 return false;
110 }
cc83fca2 111 // Check that we have the acceptance correction, needed by
112 // AliFMDCorrector
113 if (what & AliForwardCorrectionManager::kAcceptance &&
114 !fcm.GetAcceptance()) {
115 AliFatal("No acceptance corrections");
116 return false;
117 }
1174780f 118 return true;
119}
7ec4d843 120//____________________________________________________________________
121Bool_t
19abe41d 122AliForwardMultiplicityBase::ReadCorrections(const TAxis*& pe,
123 const TAxis*& pv,
124 Bool_t mc)
7ec4d843 125{
fb3430ac 126 //
127 // Read corrections
128 //
129 //
7ec4d843 130 UInt_t what = AliForwardCorrectionManager::kAll;
131 if (!fEnableLowFlux)
132 what ^= AliForwardCorrectionManager::kDoubleHit;
7ec4d843 133 if (!GetCorrections().IsUseVertexBias())
134 what ^= AliForwardCorrectionManager::kVertexBias;
135 if (!GetCorrections().IsUseAcceptance())
136 what ^= AliForwardCorrectionManager::kAcceptance;
137 if (!GetCorrections().IsUseMergingEfficiency())
138 what ^= AliForwardCorrectionManager::kMergingEfficiency;
139
140 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
141 if (!fcm.Init(GetEventInspector().GetCollisionSystem(),
19abe41d 142 GetEventInspector().GetEnergy(),
143 GetEventInspector().GetField(),
144 mc,
145 what)) return false;
7ec4d843 146 if (!CheckCorrections(what)) return false;
147
19abe41d 148 // Sett our persistency pointer
149 // fCorrManager = &fcm;
150
7ec4d843 151 // Get the eta axis from the secondary maps - if read in
152 if (!pe) {
153 pe = fcm.GetEtaAxis();
154 if (!pe) AliFatal("No eta axis defined");
155 }
156 // Get the vertex axis from the secondary maps - if read in
157 if (!pv) {
158 pv = fcm.GetVertexAxis();
159 if (!pv) AliFatal("No vertex axis defined");
160 }
161
162 return true;
163}
164//____________________________________________________________________
165AliESDEvent*
166AliForwardMultiplicityBase::GetESDEvent()
167{
fb3430ac 168 //
169 // Get the ESD event. IF this is the first event, initialise
170 //
7ec4d843 171 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
172 if (!esd) {
173 AliWarning("No ESD event found for input event");
174 return 0;
175 }
1174780f 176
7ec4d843 177 // On the first event, initialize the parameters
178 if (fFirstEvent && esd->GetESDRun()) {
179 GetEventInspector().ReadRunDetails(esd);
180
181 AliInfo(Form("Initializing with parameters from the ESD:\n"
182 " AliESDEvent::GetBeamEnergy() ->%f\n"
183 " AliESDEvent::GetBeamType() ->%s\n"
184 " AliESDEvent::GetCurrentL3() ->%f\n"
185 " AliESDEvent::GetMagneticField()->%f\n"
186 " AliESDEvent::GetRunNumber() ->%d\n",
187 esd->GetBeamEnergy(),
188 esd->GetBeamType(),
189 esd->GetCurrentL3(),
190 esd->GetMagneticField(),
191 esd->GetRunNumber()));
192
193 fFirstEvent = false;
194
2b556440 195 GetEventPlaneFinder().SetRunNumber(esd->GetRunNumber());
7ec4d843 196 InitializeSubs();
197 }
198 return esd;
199}
1174780f 200//____________________________________________________________________
1a26066e 201void
202AliForwardMultiplicityBase::MarkEventForStore() const
203{
204 // Make sure the AOD tree is filled
205 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
206 AliAODHandler* ah =
207 dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
208 if (!ah)
209 AliFatal("No AOD output handler set in analysis manager");
210
211 ah->SetFillAOD(kTRUE);
212}
213
5bb5d1f6 214//____________________________________________________________________
215void
216AliForwardMultiplicityBase::MakeRingdNdeta(const TList* input,
217 const char* inName,
218 TList* output,
219 const char* outName,
220 Int_t style) const
221{
222 // Make dN/deta for each ring found in the input list.
223 //
224 // A stack of all the dN/deta is also made for easy drawing.
225 //
226 // Note, that the distributions are normalised to the number of
227 // observed events only - they should be corrected for
228 if (!input) return;
229 TList* list = static_cast<TList*>(input->FindObject(inName));
230 if (!list) {
231 AliWarning(Form("No list %s found in %s", inName, input->GetName()));
232 return;
233 }
234
235 TList* out = new TList;
236 out->SetName(outName);
237 out->SetOwner();
238 output->Add(out);
239
240 THStack* dndetaRings = new THStack("all", "dN/d#eta per ring");
241 const char* names[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3I", "FMD3O", 0 };
242 const char** ptr = names;
243
244 while (*ptr) {
245 TList* thisList = new TList;
246 thisList->SetOwner();
247 thisList->SetName(*ptr);
248 out->Add(thisList);
249
250 TH2D* h = static_cast<TH2D*>(list->FindObject(Form("%s_cache", *ptr)));
251 if (!h) {
252 AliWarning(Form("Didn't find %s_cache in %s", *ptr, list->GetName()));
253 ptr++;
254 continue;
255 }
256 TH2D* copy = static_cast<TH2D*>(h->Clone("sum"));
257 copy->SetDirectory(0);
258 thisList->Add(copy);
259
260 TH1D* norm =static_cast<TH1D*>(h->ProjectionX("norm", 0, 0, ""));
261 for (Int_t i = 1; i <= copy->GetNbinsX(); i++) {
262 for (Int_t j = 1; j <= copy->GetNbinsY(); j++) {
263 Double_t c = copy->GetBinContent(i, j);
264 Double_t e = copy->GetBinError(i, j);
265 Double_t a = norm->GetBinContent(i);
266 copy->SetBinContent(i, j, a <= 0 ? 0 : c / a);
267 copy->SetBinError(i, j, a <= 0 ? 0 : e / a);
268 }
269 }
270
271 TH1D* res =static_cast<TH1D*>(copy->ProjectionX("dndeta",1,
272 h->GetNbinsY(),"e"));
273 TH1D* proj =static_cast<TH1D*>(h->ProjectionX("proj",1,h->GetNbinsY(),"e"));
274 res->SetTitle(*ptr);
275 res->Scale(1., "width");
276 copy->Scale(1., "width");
277 proj->Scale(1. / norm->GetMaximum(), "width");
278 norm->Scale(1. / norm->GetMaximum());
279
280 res->SetMarkerStyle(style);
281 norm->SetDirectory(0);
282 res->SetDirectory(0);
283 proj->SetDirectory(0);
284 thisList->Add(norm);
285 thisList->Add(res);
286 thisList->Add(proj);
287 dndetaRings->Add(res);
288 ptr++;
289 }
290 out->Add(dndetaRings);
291}
292
1a26066e 293//____________________________________________________________________
294void
295AliForwardMultiplicityBase::Print(Option_t* option) const
296{
7984e5f7 297 //
298 // Print information
299 //
300 // Parameters:
301 // option Not used
302 //
3c5497d0 303
1f480471 304 std::cout << ClassName() << ": " << GetName() << "\n"
9bff843b 305 << " Enable low flux code: " << (fEnableLowFlux ? "yes" : "no")
306 << "\n"
3c5497d0 307 << " Off-line trigger mask: 0x"
308 << std::hex << std::setfill('0')
309 << std::setw (8) << fOfflineTriggerMask
310 << std::dec << std::setfill (' ') << std::endl;
1174780f 311 gROOT->IncreaseDirLevel();
3c5497d0 312 if (fCorrManager) fCorrManager->Print();
9bff843b 313 else
314 std::cout << " Correction manager not set yet" << std::endl;
1174780f 315 GetEventInspector() .Print(option);
1174780f 316 GetSharingFilter() .Print(option);
317 GetDensityCalculator().Print(option);
318 GetCorrections() .Print(option);
319 GetHistCollector() .Print(option);
2b556440 320 GetEventPlaneFinder() .Print(option);
1174780f 321 gROOT->DecreaseDirLevel();
1a26066e 322}
323
1174780f 324
1a26066e 325//
326// EOF
327//