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 "AliFMDEventPlaneFinder.h"
28 #include "AliESDEvent.h"
36 //====================================================================
37 AliForwardMultiplicityBase::AliForwardMultiplicityBase(const char* name)
38 : AliAnalysisTaskSE(name),
39 fEnableLowFlux(false),
43 DGUARD(0,0,"Named Construction of AliForwardMultiplicityBase %s",name);
44 // Set our persistent pointer
45 fCorrManager = &AliForwardCorrectionManager::Instance();
47 "ESD:AliESDRun.,AliESDHeader.,AliMultiplicity.,"
48 "AliESDFMD.,SPDVertex.,PrimaryVertex.";
51 //____________________________________________________________________
52 AliForwardMultiplicityBase&
53 AliForwardMultiplicityBase::operator=(const AliForwardMultiplicityBase& o)
55 DGUARD(fDebug,2,"Assignment to AliForwardMultiplicityBase");
56 if (&o == this) return *this;
57 fEnableLowFlux = o.fEnableLowFlux;
58 fFirstEvent = o.fFirstEvent;
59 fCorrManager = o.fCorrManager;
62 //____________________________________________________________________
64 AliForwardMultiplicityBase::Configure(const char* macro)
66 // --- Configure the task ------------------------------------------
67 TString macroPath(gROOT->GetMacroPath());
68 if (!macroPath.Contains("$(ALICE_ROOT)/PWGLF/FORWARD/analysis2")) {
69 macroPath.Append(":$(ALICE_ROOT)/PWGLF/FORWARD/analysis2");
70 gROOT->SetMacroPath(macroPath);
72 const char* config = gSystem->Which(gROOT->GetMacroPath(), macro);
74 AliWarningF("%s not found in %s", macro, gROOT->GetMacroPath());
78 AliInfoF("Loading configuration of '%s' from %s", ClassName(), config);
79 gROOT->Macro(Form("%s((AliForwardMultiplicityBase*)%p)", config, this));
85 //____________________________________________________________________
87 AliForwardMultiplicityBase::CheckCorrections(UInt_t what) const
90 // Check if all needed corrections are there and accounted for. If not,
94 // what Which corrections is needed
97 // true if all present, false otherwise
99 DGUARD(fDebug,1,"Checking corrections 0x%x", what);
101 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
102 // Check that we have the energy loss fits, needed by
103 // AliFMDSharingFilter
104 // AliFMDDensityCalculator
105 if (what & AliForwardCorrectionManager::kELossFits && !fcm.GetELossFit()) {
106 AliFatal(Form("No energy loss fits"));
109 // Check that we have the double hit correction - (optionally) used by
110 // AliFMDDensityCalculator
111 if (what & AliForwardCorrectionManager::kDoubleHit && !fcm.GetDoubleHit()) {
112 AliFatal("No double hit corrections");
115 // Check that we have the secondary maps, needed by
117 // AliFMDHistCollector
118 if (what & AliForwardCorrectionManager::kSecondaryMap &&
119 !fcm.GetSecondaryMap()) {
120 AliFatal("No secondary corrections");
123 // Check that we have the vertex bias correction, needed by
125 if (what & AliForwardCorrectionManager::kVertexBias &&
126 !fcm.GetVertexBias()) {
127 AliFatal("No event vertex bias corrections");
130 // Check that we have the merging efficiencies, optionally used by
132 if (what & AliForwardCorrectionManager::kMergingEfficiency &&
133 !fcm.GetMergingEfficiency()) {
134 AliFatal("No merging efficiencies");
137 // Check that we have the acceptance correction, needed by
139 if (what & AliForwardCorrectionManager::kAcceptance &&
140 !fcm.GetAcceptance()) {
141 AliFatal("No acceptance corrections");
146 //____________________________________________________________________
148 AliForwardMultiplicityBase::ReadCorrections(const TAxis*& pe,
157 UInt_t what = AliForwardCorrectionManager::kAll;
159 what ^= AliForwardCorrectionManager::kDoubleHit;
160 if (!GetCorrections().IsUseVertexBias())
161 what ^= AliForwardCorrectionManager::kVertexBias;
162 if (!GetCorrections().IsUseAcceptance())
163 what ^= AliForwardCorrectionManager::kAcceptance;
164 if (!GetCorrections().IsUseMergingEfficiency())
165 what ^= AliForwardCorrectionManager::kMergingEfficiency;
166 DGUARD(fDebug,1,"Read corrections 0x%x", what);
168 AliForwardCorrectionManager& fcm = AliForwardCorrectionManager::Instance();
169 if (!fcm.Init(GetEventInspector().GetCollisionSystem(),
170 GetEventInspector().GetEnergy(),
171 GetEventInspector().GetField(),
174 AliWarning("Failed to read in some corrections, making task zombie");
177 if (!CheckCorrections(what)) return false;
179 // Sett our persistency pointer
180 // fCorrManager = &fcm;
182 // Get the eta axis from the secondary maps - if read in
184 pe = fcm.GetEtaAxis();
185 if (!pe) AliFatal("No eta axis defined");
187 // Get the vertex axis from the secondary maps - if read in
189 pv = fcm.GetVertexAxis();
190 if (!pv) AliFatal("No vertex axis defined");
195 //____________________________________________________________________
197 AliForwardMultiplicityBase::GetESDEvent()
200 // Get the ESD event. IF this is the first event, initialise
202 DGUARD(fDebug,1,"Get the ESD event");
203 if (IsZombie()) return 0;
204 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
206 AliWarning("No ESD event found for input event");
210 // On the first event, initialize the parameters
211 if (fFirstEvent && esd->GetESDRun()) {
212 GetEventInspector().ReadRunDetails(esd);
214 AliInfo(Form("Initializing with parameters from the ESD:\n"
215 " AliESDEvent::GetBeamEnergy() ->%f\n"
216 " AliESDEvent::GetBeamType() ->%s\n"
217 " AliESDEvent::GetCurrentL3() ->%f\n"
218 " AliESDEvent::GetMagneticField()->%f\n"
219 " AliESDEvent::GetRunNumber() ->%d",
220 esd->GetBeamEnergy(),
223 esd->GetMagneticField(),
224 esd->GetRunNumber()));
228 GetEventPlaneFinder().SetRunNumber(esd->GetRunNumber());
229 if (!InitializeSubs()) {
230 AliError("Failed to initialize sub-algorithms, making this a zombie");
231 esd = 0; // Make sure we do nothing on this event
232 Info("GetESDEvent", "ESD event pointer %p", esd);
239 //____________________________________________________________________
241 AliForwardMultiplicityBase::MarkEventForStore() const
243 // Make sure the AOD tree is filled
244 DGUARD(fDebug,3,"Mark AOD event for storage");
245 AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
247 dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler());
249 AliFatal("No AOD output handler set in analysis manager");
251 ah->SetFillAOD(kTRUE);
254 //____________________________________________________________________
256 AliForwardMultiplicityBase::MakeRingdNdeta(const TList* input,
262 // Make dN/deta for each ring found in the input list.
264 // A stack of all the dN/deta is also made for easy drawing.
266 // Note, that the distributions are normalised to the number of
267 // observed events only - they should be corrected for
268 DGUARD(fDebug,3,"Make first-shot ring dN/deta");
271 TList* list = static_cast<TList*>(input->FindObject(inName));
273 AliWarning(Form("No list %s found in %s", inName, input->GetName()));
277 TList* out = new TList;
278 out->SetName(outName);
282 THStack* dndetaRings = new THStack("all", "dN/d#eta per ring");
283 const char* names[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3I", "FMD3O", 0 };
284 const char** ptr = names;
287 TList* thisList = new TList;
288 thisList->SetOwner();
289 thisList->SetName(*ptr);
292 TH2D* h = static_cast<TH2D*>(list->FindObject(Form("%s_cache", *ptr)));
294 AliWarning(Form("Didn't find %s_cache in %s", *ptr, list->GetName()));
298 TH2D* copy = static_cast<TH2D*>(h->Clone("sum"));
299 copy->SetDirectory(0);
302 TH1D* norm =static_cast<TH1D*>(h->ProjectionX("norm", 0, 0, ""));
303 for (Int_t i = 1; i <= copy->GetNbinsX(); i++) {
304 for (Int_t j = 1; j <= copy->GetNbinsY(); j++) {
305 Double_t c = copy->GetBinContent(i, j);
306 Double_t e = copy->GetBinError(i, j);
307 Double_t a = norm->GetBinContent(i);
308 copy->SetBinContent(i, j, a <= 0 ? 0 : c / a);
309 copy->SetBinError(i, j, a <= 0 ? 0 : e / a);
313 TH1D* res =static_cast<TH1D*>(copy->ProjectionX("dndeta",1,
314 h->GetNbinsY(),"e"));
315 TH1D* proj =static_cast<TH1D*>(h->ProjectionX("proj",1,h->GetNbinsY(),"e"));
317 res->Scale(1., "width");
318 copy->Scale(1., "width");
320 if(norm->GetMaximum() > 0) {
321 proj->Scale(1. / norm->GetMaximum(), "width");
322 norm->Scale(1. / norm->GetMaximum());
325 res->SetMarkerStyle(style);
326 norm->SetDirectory(0);
327 res->SetDirectory(0);
328 proj->SetDirectory(0);
332 dndetaRings->Add(res);
335 out->Add(dndetaRings);
338 //____________________________________________________________________
340 AliForwardMultiplicityBase::Print(Option_t* option) const
349 std::cout << ClassName() << ": " << GetName() << "\n"
350 << " Enable low flux code: " << (fEnableLowFlux ? "yes" : "no")
352 << " Off-line trigger mask: 0x"
353 << std::hex << std::setfill('0')
354 << std::setw (8) << fOfflineTriggerMask
355 << std::dec << std::setfill (' ') << std::endl;
356 gROOT->IncreaseDirLevel();
357 if (fCorrManager) fCorrManager->Print();
359 std::cout << " Correction manager not set yet" << std::endl;
360 GetEventInspector() .Print(option);
361 GetSharingFilter() .Print(option);
362 GetDensityCalculator().Print(option);
363 GetCorrections() .Print(option);
364 GetHistCollector() .Print(option);
365 GetEventPlaneFinder() .Print(option);
366 gROOT->DecreaseDirLevel();