1 //====================================================================
3 // Base class for classes that calculate the multiplicity in the
4 // forward regions event-by-event
10 // - AliAODForwardMult
15 #include "AliForwardMultiplicityBase.h"
16 #include "AliForwardCorrectionManager.h"
17 #include "AliForwardUtil.h"
19 #include "AliAODHandler.h"
20 #include "AliInputEventHandler.h"
21 #include "AliAnalysisManager.h"
22 #include "AliFMDEventInspector.h"
23 #include "AliFMDSharingFilter.h"
24 #include "AliFMDDensityCalculator.h"
25 #include "AliFMDCorrector.h"
26 #include "AliFMDHistCollector.h"
27 #include "AliESDEvent.h"
34 //====================================================================
35 AliForwardMultiplicityBase::AliForwardMultiplicityBase(const char* name)
36 : AliAnalysisTaskSE(name),
37 fEnableLowFlux(false),
41 // Set our persistent pointer
42 fCorrManager = &AliForwardCorrectionManager::Instance();
44 "ESD:AliESDRun.,AliESDHeader.,AliMultiplicity.,"
45 "AliESDFMD.,SPDVertex.,PrimaryVertex.";
48 //____________________________________________________________________
49 AliForwardMultiplicityBase&
50 AliForwardMultiplicityBase::operator=(const AliForwardMultiplicityBase& o)
52 if (&o == this) return *this;
53 fEnableLowFlux = o.fEnableLowFlux;
54 fFirstEvent = o.fFirstEvent;
55 fCorrManager = o.fCorrManager;
59 //____________________________________________________________________
61 AliForwardMultiplicityBase::CheckCorrections(UInt_t what) const
64 // Check if all needed corrections are there and accounted for. If not,
68 // what Which corrections is needed
71 // true if all present, false otherwise
74 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
75 // Check that we have the energy loss fits, needed by
76 // AliFMDSharingFilter
77 // AliFMDDensityCalculator
78 if (what & AliForwardCorrectionManager::kELossFits && !fcm.GetELossFit()) {
79 AliFatal(Form("No energy loss fits"));
82 // Check that we have the double hit correction - (optionally) used by
83 // AliFMDDensityCalculator
84 if (what & AliForwardCorrectionManager::kDoubleHit && !fcm.GetDoubleHit()) {
85 AliFatal("No double hit corrections");
88 // Check that we have the secondary maps, needed by
90 // AliFMDHistCollector
91 if (what & AliForwardCorrectionManager::kSecondaryMap &&
92 !fcm.GetSecondaryMap()) {
93 AliFatal("No secondary corrections");
96 // Check that we have the vertex bias correction, needed by
98 if (what & AliForwardCorrectionManager::kVertexBias &&
99 !fcm.GetVertexBias()) {
100 AliFatal("No event vertex bias corrections");
103 // Check that we have the merging efficiencies, optionally used by
105 if (what & AliForwardCorrectionManager::kMergingEfficiency &&
106 !fcm.GetMergingEfficiency()) {
107 AliFatal("No merging efficiencies");
110 // Check that we have the acceptance correction, needed by
112 if (what & AliForwardCorrectionManager::kAcceptance &&
113 !fcm.GetAcceptance()) {
114 AliFatal("No acceptance corrections");
119 //____________________________________________________________________
121 AliForwardMultiplicityBase::ReadCorrections(const TAxis*& pe,
129 UInt_t what = AliForwardCorrectionManager::kAll;
131 what ^= AliForwardCorrectionManager::kDoubleHit;
132 if (!GetCorrections().IsUseVertexBias())
133 what ^= AliForwardCorrectionManager::kVertexBias;
134 if (!GetCorrections().IsUseAcceptance())
135 what ^= AliForwardCorrectionManager::kAcceptance;
136 if (!GetCorrections().IsUseMergingEfficiency())
137 what ^= AliForwardCorrectionManager::kMergingEfficiency;
139 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
140 if (!fcm.Init(GetEventInspector().GetCollisionSystem(),
141 GetEventInspector().GetEnergy(),
142 GetEventInspector().GetField(),
145 if (!CheckCorrections(what)) return false;
147 // Sett our persistency pointer
148 // fCorrManager = &fcm;
150 // Get the eta axis from the secondary maps - if read in
152 pe = fcm.GetEtaAxis();
153 if (!pe) AliFatal("No eta axis defined");
155 // Get the vertex axis from the secondary maps - if read in
157 pv = fcm.GetVertexAxis();
158 if (!pv) AliFatal("No vertex axis defined");
163 //____________________________________________________________________
165 AliForwardMultiplicityBase::GetESDEvent()
168 // Get the ESD event. IF this is the first event, initialise
170 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
172 AliWarning("No ESD event found for input event");
176 // On the first event, initialize the parameters
177 if (fFirstEvent && esd->GetESDRun()) {
178 GetEventInspector().ReadRunDetails(esd);
180 AliInfo(Form("Initializing with parameters from the ESD:\n"
181 " AliESDEvent::GetBeamEnergy() ->%f\n"
182 " AliESDEvent::GetBeamType() ->%s\n"
183 " AliESDEvent::GetCurrentL3() ->%f\n"
184 " AliESDEvent::GetMagneticField()->%f\n"
185 " AliESDEvent::GetRunNumber() ->%d\n",
186 esd->GetBeamEnergy(),
189 esd->GetMagneticField(),
190 esd->GetRunNumber()));
198 //____________________________________________________________________
200 AliForwardMultiplicityBase::MarkEventForStore() const
202 // Make sure the AOD tree is filled
203 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
205 dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
207 AliFatal("No AOD output handler set in analysis manager");
209 ah->SetFillAOD(kTRUE);
212 //____________________________________________________________________
214 AliForwardMultiplicityBase::MakeRingdNdeta(const TList* input,
220 // Make dN/deta for each ring found in the input list.
222 // A stack of all the dN/deta is also made for easy drawing.
224 // Note, that the distributions are normalised to the number of
225 // observed events only - they should be corrected for
227 TList* list = static_cast<TList*>(input->FindObject(inName));
229 AliWarning(Form("No list %s found in %s", inName, input->GetName()));
233 TList* out = new TList;
234 out->SetName(outName);
238 THStack* dndetaRings = new THStack("all", "dN/d#eta per ring");
239 const char* names[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3I", "FMD3O", 0 };
240 const char** ptr = names;
243 TList* thisList = new TList;
244 thisList->SetOwner();
245 thisList->SetName(*ptr);
248 TH2D* h = static_cast<TH2D*>(list->FindObject(Form("%s_cache", *ptr)));
250 AliWarning(Form("Didn't find %s_cache in %s", *ptr, list->GetName()));
254 TH2D* copy = static_cast<TH2D*>(h->Clone("sum"));
255 copy->SetDirectory(0);
258 TH1D* norm =static_cast<TH1D*>(h->ProjectionX("norm", 0, 0, ""));
259 for (Int_t i = 1; i <= copy->GetNbinsX(); i++) {
260 for (Int_t j = 1; j <= copy->GetNbinsY(); j++) {
261 Double_t c = copy->GetBinContent(i, j);
262 Double_t e = copy->GetBinError(i, j);
263 Double_t a = norm->GetBinContent(i);
264 copy->SetBinContent(i, j, a <= 0 ? 0 : c / a);
265 copy->SetBinError(i, j, a <= 0 ? 0 : e / a);
269 TH1D* res =static_cast<TH1D*>(copy->ProjectionX("dndeta",1,
270 h->GetNbinsY(),"e"));
271 TH1D* proj =static_cast<TH1D*>(h->ProjectionX("proj",1,h->GetNbinsY(),"e"));
273 res->Scale(1., "width");
274 copy->Scale(1., "width");
275 proj->Scale(1. / norm->GetMaximum(), "width");
276 norm->Scale(1. / norm->GetMaximum());
278 res->SetMarkerStyle(style);
279 norm->SetDirectory(0);
280 res->SetDirectory(0);
281 proj->SetDirectory(0);
285 dndetaRings->Add(res);
288 out->Add(dndetaRings);
291 //____________________________________________________________________
293 AliForwardMultiplicityBase::Print(Option_t* option) const
302 std::cout << ClassName() << ": " << GetName() << "\n"
303 << " Enable low flux code: " << (fEnableLowFlux ? "yes" : "no")
305 << " Off-line trigger mask: 0x"
306 << std::hex << std::setfill('0')
307 << std::setw (8) << fOfflineTriggerMask
308 << std::dec << std::setfill (' ') << std::endl;
309 gROOT->IncreaseDirLevel();
310 if (fCorrManager) fCorrManager->Print();
312 std::cout << " Correction manager not set yet" << std::endl;
313 GetEventInspector() .Print(option);
314 GetSharingFilter() .Print(option);
315 GetDensityCalculator().Print(option);
316 GetCorrections() .Print(option);
317 GetHistCollector() .Print(option);
318 gROOT->DecreaseDirLevel();