1 //====================================================================
2 #include "AliBasedNdetaTask.h"
8 #include <AliAnalysisManager.h>
9 #include <AliAODEvent.h>
10 #include <AliAODHandler.h>
11 #include <AliAODInputHandler.h>
12 #include "AliForwardUtil.h"
13 #include "AliAODForwardMult.h"
17 //____________________________________________________________________
18 AliBasedNdetaTask::AliBasedNdetaTask()
19 : AliAnalysisTaskSE(),
20 fSums(0), // Container of sums
21 fOutput(0), // Container of output
22 fVtxMin(0), // Minimum v_z
23 fVtxMax(0), // Maximum v_z
24 fTriggerMask(0), // Trigger mask
25 fRebin(0), // Rebinning factor
33 fListOfCentralities(0),
38 fNormalizationScheme(kFull),
46 DGUARD(0,0,"Default construction of AliBasedNdetaTask");
49 //____________________________________________________________________
50 AliBasedNdetaTask::AliBasedNdetaTask(const char* name)
51 : AliAnalysisTaskSE(name),
52 fSums(0), // Container of sums
53 fOutput(0), // Container of output
54 fVtxMin(-10), // Minimum v_z
55 fVtxMax(10), // Maximum v_z
56 fTriggerMask(AliAODForwardMult::kInel),
57 fRebin(5), // Rebinning factor
65 fListOfCentralities(0),
70 fNormalizationScheme(kFull),
78 DGUARD(0,0,"Named construction of AliBasedNdetaTask: %s", name);
79 fListOfCentralities = new TObjArray(1);
81 // Set the normalisation scheme
82 SetNormalizationScheme(kFull);
84 // Set the trigger mask
85 SetTriggerMask(AliAODForwardMult::kInel);
87 // Output slot #1 writes into a TH1 container
88 DefineOutput(1, TList::Class());
89 DefineOutput(2, TList::Class());
92 //____________________________________________________________________
93 AliBasedNdetaTask::AliBasedNdetaTask(const AliBasedNdetaTask& o)
94 : AliAnalysisTaskSE(o),
95 fSums(o.fSums), // TList* - Container of sums
96 fOutput(o.fOutput), // Container of output
97 fVtxMin(o.fVtxMin), // Double_t - Minimum v_z
98 fVtxMax(o.fVtxMax), // Double_t - Maximum v_z
99 fTriggerMask(o.fTriggerMask),// Int_t - Trigger mask
100 fRebin(o.fRebin), // Int_t - Rebinning factor
101 fCutEdges(o.fCutEdges), // Bool_t - Whether to cut edges when rebinning
102 fSymmetrice(o.fSymmetrice),
103 fCorrEmpty(o.fCorrEmpty),
104 fUseROOTProj(o.fUseROOTProj),
105 fTriggerEff(o.fTriggerEff),
106 fTriggerEff0(o.fTriggerEff0),
107 fShapeCorr(o.fShapeCorr),
108 fListOfCentralities(o.fListOfCentralities),
109 fSNNString(o.fSNNString),
110 fSysString(o.fSysString),
112 fCentAxis(o.fCentAxis),
113 fNormalizationScheme(o.fNormalizationScheme),
114 fSchemeString(o.fSchemeString),
115 fTriggerString(o.fTriggerString),
116 fFinalMCCorrFile(o.fFinalMCCorrFile)
118 DGUARD(0,0,"Copy construction of AliBasedNdetaTask");
121 //____________________________________________________________________
122 AliBasedNdetaTask::~AliBasedNdetaTask()
127 DGUARD(fDebug,3,"Destruction of AliBasedNdetaTask");
140 //________________________________________________________________________
142 AliBasedNdetaTask::SetDebugLevel(Int_t lvl)
144 AliAnalysisTaskSE::SetDebugLevel(lvl);
145 for (Int_t i = 0; i < fListOfCentralities->GetEntries(); i++) {
147 static_cast<CentralityBin*>(fListOfCentralities->At(i));
148 bin->SetDebugLevel(lvl);
152 //________________________________________________________________________
154 AliBasedNdetaTask::SetCentralityAxis(UShort_t n, Short_t* bins)
156 DGUARD(fDebug,3,"Set centrality axis, %d bins", n);
158 fCentAxis = new TAxis();
159 fCentAxis->SetName("centAxis");
160 fCentAxis->SetTitle("Centrality [%]");
163 for (UShort_t i = 0; i <= n; i++)
164 dbins[i] = (bins[i] == 100 ? 100.1 : bins[i]);
165 fCentAxis->Set(n, dbins.GetArray());
168 //________________________________________________________________________
170 AliBasedNdetaTask::AddCentralityBin(UShort_t at, Short_t low, Short_t high)
173 // Add a centrality bin
179 DGUARD(fDebug,3,"Add a centrality bin [%f,%f] @ %d", low, high, at);
180 CentralityBin* bin = MakeCentralityBin(GetName(), low, high);
181 bin->SetDebugLevel(fDebug);
182 fListOfCentralities->AddAtAndExpand(bin, at);
185 //________________________________________________________________________
186 AliBasedNdetaTask::CentralityBin*
187 AliBasedNdetaTask::MakeCentralityBin(const char* name,
188 Short_t low, Short_t high) const
191 // Make a centrality bin
194 // name Name used for histograms
195 // low Low cut in percent
196 // high High cut in percent
199 // A newly created centrality bin
201 DGUARD(fDebug,3,"Make a centrality bin [%f,%f]: %s", low, high, name);
202 return new CentralityBin(name, low, high);
205 #define TESTAPPEND(SCHEME,BIT,STRING) \
206 do { if (!(SCHEME & BIT)) break; \
207 if (!s.IsNull()) s.Append(","); s.Append(STRING); } while(false)
209 //________________________________________________________________________
211 AliBasedNdetaTask::NormalizationSchemeString(UShort_t scheme)
213 // Create a string from normalization scheme bits
219 if (scheme == kFull) {
223 TESTAPPEND(scheme, kEventLevel, "EVENT");
224 TESTAPPEND(scheme, kShape, "SHAPE");
225 TESTAPPEND(scheme, kBackground, "BACKGROUND");
226 TESTAPPEND(scheme, kTriggerEfficiency, "TRIGGER");
227 TESTAPPEND(scheme, kZeroBin, "ZEROBIN");
231 //________________________________________________________________________
233 AliBasedNdetaTask::ParseNormalizationScheme(const char* what)
239 TIter next(twhat.Tokenize(" ,|"));
240 while ((opt = static_cast<TObjString*>(next()))) {
241 TString s(opt->GetString());
242 if (s.IsNull()) continue;
245 case '-': add = false; // Fall through
246 case '+': s.Remove(0,1); // Remove character
249 if (s.CompareTo("EVENT") == 0) bit = kEventLevel;
250 else if (s.CompareTo("SHAPE") == 0) bit = kShape;
251 else if (s.CompareTo("BACKGROUND")== 0) bit = kBackground;
252 else if (s.CompareTo("TRIGGER") == 0) bit = kTriggerEfficiency;
253 else if (s.CompareTo("FULL") == 0) bit = kFull;
254 else if (s.CompareTo("NONE") == 0) bit = kNone;
255 else if (s.CompareTo("ZEROBIN") == 0) bit = kZeroBin;
257 ::Warning("SetNormalizationScheme", "Unknown option %s", s.Data());
258 if (add) scheme |= bit;
263 //________________________________________________________________________
265 AliBasedNdetaTask::SetNormalizationScheme(const char* what)
268 // Set normalisation scheme
270 DGUARD(fDebug,3,"Set the normalization scheme: %s", what);
271 SetNormalizationScheme(ParseNormalizationScheme(what));
273 //________________________________________________________________________
275 AliBasedNdetaTask::SetNormalizationScheme(UShort_t scheme)
277 DGUARD(fDebug,3,"Set the normalization scheme: 0x%x", scheme);
278 fNormalizationScheme = scheme;
279 if (fSchemeString) delete fSchemeString;
280 fSchemeString = AliForwardUtil::MakeParameter("scheme", scheme);
282 //________________________________________________________________________
284 AliBasedNdetaTask::SetTriggerMask(const char* mask)
287 // Set the trigger maskl
292 DGUARD(fDebug,3,"Set the trigger mask: %s", mask);
293 SetTriggerMask(AliAODForwardMult::MakeTriggerMask(mask));
295 //________________________________________________________________________
297 AliBasedNdetaTask::SetTriggerMask(UShort_t mask)
299 DGUARD(fDebug,3,"Set the trigger mask: 0x%0x", mask);
301 if (fTriggerString) delete fTriggerString;
302 fTriggerString = AliForwardUtil::MakeParameter("trigger", fTriggerMask);
305 //________________________________________________________________________
307 AliBasedNdetaTask::SetShapeCorrection(const TH2F* c)
310 // Set the shape correction (a.k.a., track correction) for selected
316 DGUARD(fDebug,3,"Set the shape correction: %p", c);
318 fShapeCorr = static_cast<TH2F*>(c->Clone());
319 fShapeCorr->SetDirectory(0);
322 //________________________________________________________________________
324 AliBasedNdetaTask::InitializeCentBins()
326 if (fListOfCentralities->GetEntries() > 0) return;
328 // Automatically add 'all' centrality bin if nothing has been defined.
329 AddCentralityBin(0, 0, 0);
330 if (fCentAxis && fCentAxis->GetNbins() > 0 && fCentAxis->GetXbins()) {
331 const TArrayD* bins = fCentAxis->GetXbins();
332 Int_t nbin = fCentAxis->GetNbins();
333 for (Int_t i = 0; i < nbin; i++)
334 AddCentralityBin(i+1, Short_t((*bins)[i]), Short_t((*bins)[i+1]));
338 //________________________________________________________________________
340 AliBasedNdetaTask::UserCreateOutputObjects()
343 // Create output objects.
345 // This is called once per slave process
347 DGUARD(fDebug,1,"Create user ouput object");
349 fSums->SetName(Form("%s_sums", GetName()));
352 InitializeCentBins();
353 if (fCentAxis) fSums->Add(fCentAxis);
356 // Centrality histogram
357 fCent = new TH1D("cent", "Centrality", 100, 0, 100);
358 fCent->SetDirectory(0);
362 // Loop over centrality bins
363 TIter next(fListOfCentralities);
364 CentralityBin* bin = 0;
365 while ((bin = static_cast<CentralityBin*>(next())))
366 bin->CreateOutputObjects(fSums);
369 // Post data for ALL output slots >0 here, to get at least an empty
374 //____________________________________________________________________
376 AliBasedNdetaTask::UserExec(Option_t *)
379 // Process a single event
385 DGUARD(fDebug,1,"Analyse the AOD event");
386 AliAODEvent* aod = AliForwardUtil::GetAODEvent(this);
390 TObject* obj = aod->FindListObject("Forward");
392 AliWarning("No forward object found");
395 AliAODForwardMult* forward = static_cast<AliAODForwardMult*>(obj);
397 // Fill centrality histogram
398 Float_t cent = forward->GetCentrality();
401 // Get the histogram(s)
402 TH2D* data = GetHistogram(aod, false);
403 TH2D* dataMC = GetHistogram(aod, true);
405 Bool_t isZero = ((fNormalizationScheme & kZeroBin) &&
406 !forward->IsTriggerBits(AliAODForwardMult::kNClusterGt0));
409 // Loop over centrality bins
410 CentralityBin* allBin =
411 static_cast<CentralityBin*>(fListOfCentralities->At(0));
412 allBin->ProcessEvent(forward, fTriggerMask, isZero,
413 fVtxMin, fVtxMax, data, dataMC);
415 // Find this centrality bin
416 if (fCentAxis && fCentAxis->GetNbins() > 0) {
417 Int_t icent = fCentAxis->FindBin(cent);
418 CentralityBin* thisBin = 0;
419 if (icent >= 1 && icent <= fCentAxis->GetNbins())
420 thisBin = static_cast<CentralityBin*>(fListOfCentralities->At(icent));
422 thisBin->ProcessEvent(forward, fTriggerMask, isZero, fVtxMin, fVtxMax,
426 // Here, we get the update
428 fSNNString = AliForwardUtil::MakeParameter("sNN", forward->GetSNN());
429 fSysString = AliForwardUtil::MakeParameter("sys", forward->GetSystem());
431 fSums->Add(fSNNString);
432 fSums->Add(fSysString);
433 fSums->Add(fSchemeString);
434 fSums->Add(fTriggerString);
441 //________________________________________________________________________
443 AliBasedNdetaTask::SetHistogramAttributes(TH1D* h, Int_t colour, Int_t marker,
444 const char* title, const char* ytitle)
447 // Set histogram graphical options, etc.
450 // h Histogram to modify
451 // colour Marker color
452 // marker Marker style
453 // title Title of histogram
454 // ytitle Title on y-axis.
457 h->SetMarkerColor(colour);
458 h->SetMarkerStyle(marker);
459 h->SetMarkerSize(marker == 29 || marker == 30 ? 1.2 : 1);
461 h->SetYTitle(ytitle);
462 h->GetXaxis()->SetTitleFont(132);
463 h->GetXaxis()->SetLabelFont(132);
464 h->GetXaxis()->SetNdivisions(10);
465 h->GetYaxis()->SetTitleFont(132);
466 h->GetYaxis()->SetLabelFont(132);
467 h->GetYaxis()->SetNdivisions(10);
468 h->GetYaxis()->SetDecimals();
472 //________________________________________________________________________
474 AliBasedNdetaTask::ScaleToCoverage(TH2D* copy, const TH1D* norm)
476 // Normalize to the acceptance -
477 // dndeta->Divide(accNorm);
478 for (Int_t i = 1; i <= copy->GetNbinsX(); i++) {
479 Double_t a = norm->GetBinContent(i);
480 for (Int_t j = 1; j <= copy->GetNbinsY(); j++) {
482 copy->SetBinContent(i,j,0);
483 copy->SetBinError(i,j,0);
486 Double_t c = copy->GetBinContent(i, j);
487 Double_t e = copy->GetBinError(i, j);
488 copy->SetBinContent(i, j, c / a);
489 copy->SetBinError(i, j, e / a);
494 //________________________________________________________________________
496 AliBasedNdetaTask::ProjectX(const TH2D* h,
505 // Project onto the X axis
510 // firstbin First bin to use
511 // lastbin Last bin to use
512 // error Whether to calculate errors
515 // Newly created histogram or null
519 return h->ProjectionX(name, firstbin, lastbin, (error ? "e" : ""));
521 TAxis* xaxis = h->GetXaxis();
522 TAxis* yaxis = h->GetYaxis();
523 TH1D* ret = new TH1D(name, h->GetTitle(), xaxis->GetNbins(),
524 xaxis->GetXmin(), xaxis->GetXmax());
525 static_cast<const TAttLine*>(h)->Copy(*ret);
526 static_cast<const TAttFill*>(h)->Copy(*ret);
527 static_cast<const TAttMarker*>(h)->Copy(*ret);
528 ret->GetXaxis()->ImportAttributes(xaxis);
530 Int_t first = firstbin;
531 Int_t last = lastbin;
532 if (first < 0) first = 0;
533 else if (first >= yaxis->GetNbins()+1) first = yaxis->GetNbins();
534 if (last < 0) last = yaxis->GetNbins();
535 else if (last > yaxis->GetNbins()+1) last = yaxis->GetNbins();
536 if (last-first < 0) {
537 AliWarningGeneral("AliBasedNdetaTask",
538 Form("Nothing to project [%d,%d]", first, last));
544 // AliInfo(Form("Projecting bins [%d,%d] of %s", first, last, h->GetName()));
545 Int_t ybins = (last-first+1);
546 for (Int_t xbin = 0; xbin <= xaxis->GetNbins()+1; xbin++) {
547 Double_t content = 0;
552 for (Int_t ybin = first; ybin <= last; ybin++) {
553 Double_t c1 = h->GetCellContent(xbin, ybin);
554 Double_t e1 = h->GetCellError(xbin, ybin);
557 if (c1 < 1e-12) continue;
567 if(content > 0 && nbins > 0) {
568 Double_t factor = (corr ? Double_t(ybins) / nbins : 1);
570 AliWarningGeneral(ret->GetName(),
571 Form("factor @ %d is %d/%d -> %f",
572 xbin, ybins, nbins, factor));
575 // Calculate weighted average
576 ret->SetBinContent(xbin, content * factor);
577 ret->SetBinError(xbin, factor * TMath::Sqrt(error2));
580 ret->SetBinContent(xbin, factor * content);
587 //________________________________________________________________________
589 AliBasedNdetaTask::Terminate(Option_t *)
592 // Called at end of event processing..
594 // This is called once in the master
599 // Draw result to screen, or perform fitting, normalizations Called
600 // once at the end of the query
601 DGUARD(fDebug,1,"Process final merged results");
603 fSums = dynamic_cast<TList*> (GetOutputData(1));
605 AliError("Could not retrieve TList fSums");
610 fOutput->SetName(Form("%s_result", GetName()));
613 fSNNString = fSums->FindObject("sNN");
614 fSysString = fSums->FindObject("sys");
615 fCentAxis = static_cast<TAxis*>(fSums->FindObject("centAxis"));
616 fSchemeString = fSums->FindObject("scheme");
617 fTriggerString = fSums->FindObject("trigger");
619 if(fSysString && fSNNString &&
620 fSysString->GetUniqueID() == AliForwardUtil::kPP)
621 LoadNormalizationData(fSysString->GetUniqueID(),
622 fSNNString->GetUniqueID());
624 InitializeCentBins();
626 // Print before we loop
629 // Loop over centrality bins
630 TIter next(fListOfCentralities);
631 CentralityBin* bin = 0;
632 gStyle->SetPalette(1);
633 THStack* dndetaStack = new THStack("dndeta", "dN/d#eta");
634 THStack* dndetaStackRebin = new THStack(Form("dndeta_rebin%02d", fRebin),
636 THStack* dndetaMCStack = new THStack("dndetaMC", "dN_{ch}/d#eta");
637 THStack* dndetaMCStackRebin = new THStack(Form("dndetaMC_rebin%02d", fRebin),
641 TList* truthlist = 0;
643 if (fFinalMCCorrFile.Contains(".root")) {
644 TFile* ftest = TFile::Open(fFinalMCCorrFile.Data());
646 mclist = dynamic_cast<TList*>(ftest->Get(Form("%sResults",GetName())));
647 truthlist = dynamic_cast<TList*>(ftest->Get("MCTruthResults"));
650 AliWarning("MC analysis file invalid - no final MC correction possible");
652 Int_t style = GetMarker();
653 Int_t color = GetColor();
655 AliInfo(Form("Marker style=%d, color=%d", style, color));
656 while ((bin = static_cast<CentralityBin*>(next()))) {
658 bin->End(fSums, fOutput, fNormalizationScheme, fShapeCorr,
659 fTriggerEff, fTriggerEff0,
660 fSymmetrice, fRebin, fUseROOTProj, fCorrEmpty, fCutEdges,
661 fTriggerMask, style, color, mclist, truthlist);
662 if (fCentAxis && bin->IsAllBin()) continue;
663 TH1* dndeta = bin->GetResult(0, false, "");
664 TH1* dndetaSym = bin->GetResult(0, true, "");
665 TH1* dndetaMC = bin->GetResult(0, false, "MC");
666 TH1* dndetaMCSym = bin->GetResult(0, true, "MC");
667 if (dndeta) dndetaStack->Add(dndeta);
668 if (dndetaSym) dndetaStack->Add(dndetaSym);
669 if (dndetaMC) dndetaMCStack->Add(dndetaMC);
670 if (dndetaMCSym) dndetaMCStack->Add(dndetaMCSym);
672 dndeta = bin->GetResult(fRebin, false, "");
673 dndetaSym = bin->GetResult(fRebin, true, "");
674 dndetaMC = bin->GetResult(fRebin, false, "MC");
675 dndetaMCSym = bin->GetResult(fRebin, true, "MC");
676 if (dndeta) dndetaStackRebin->Add(dndeta);
677 if (dndetaSym) dndetaStackRebin->Add(dndetaSym);
678 if (dndetaMC) dndetaMCStackRebin->Add(dndetaMC);
679 if (dndetaMCSym) dndetaMCStackRebin->Add(dndetaMCSym);
683 fOutput->Add(dndetaStack);
685 // If available output rebinned stack
686 if (!dndetaStackRebin->GetHists() ||
687 dndetaStackRebin->GetHists()->GetEntries() <= 0) {
688 AliWarning("No rebinned histograms found");
689 delete dndetaStackRebin;
690 dndetaStackRebin = 0;
692 if (dndetaStackRebin) fOutput->Add(dndetaStackRebin);
694 // If available, output track-ref stack
695 if (!dndetaMCStack->GetHists() ||
696 dndetaMCStack->GetHists()->GetEntries() <= 0) {
697 AliWarning("No MC histograms found");
698 delete dndetaMCStack;
701 if (dndetaMCStack) fOutput->Add(dndetaMCStack);
703 // If available, output rebinned track-ref stack
704 if (!dndetaMCStackRebin->GetHists() ||
705 dndetaMCStackRebin->GetHists()->GetEntries() <= 0) {
706 AliWarning("No rebinned MC histograms found");
707 delete dndetaMCStackRebin;
708 dndetaMCStackRebin = 0;
710 if (dndetaMCStackRebin) fOutput->Add(dndetaMCStackRebin);
712 // Output collision energy string
714 UShort_t sNN = fSNNString->GetUniqueID();
715 TNamed* sNNObj = new TNamed(fSNNString->GetName(),
716 AliForwardUtil::CenterOfMassEnergyString(sNN));
717 sNNObj->SetUniqueID(sNN);
718 fOutput->Add(sNNObj); // fSNNString->Clone());
721 // Output collision system string
723 UShort_t sys = fSysString->GetUniqueID();
724 TNamed* sysObj = new TNamed(fSysString->GetName(),
725 AliForwardUtil::CollisionSystemString(sys));
726 sysObj->SetUniqueID(sys);
727 fOutput->Add(sysObj); // fSysString->Clone());
730 // Output centrality axis
731 if (fCentAxis) fOutput->Add(fCentAxis);
733 // Output trigger string
734 if (fTriggerString) {
735 UShort_t mask = fTriggerString->GetUniqueID();
736 TNamed* maskObj = new TNamed(fTriggerString->GetName(),
737 AliAODForwardMult::GetTriggerString(mask));
738 maskObj->SetUniqueID(mask);
739 fOutput->Add(maskObj); // fTriggerString->Clone());
742 // Normalization string
744 UShort_t scheme = fSchemeString->GetUniqueID();
745 TNamed* schemeObj = new TNamed(fSchemeString->GetName(),
746 NormalizationSchemeString(scheme));
747 schemeObj->SetUniqueID(scheme);
748 fOutput->Add(schemeObj); // fSchemeString->Clone());
751 // Output vertex axis
752 TAxis* vtxAxis = new TAxis(1,fVtxMin,fVtxMax);
753 vtxAxis->SetName("vtxAxis");
754 vtxAxis->SetTitle(Form("v_{z}#in[%+5.1f,%+5.1f]cm", fVtxMin,fVtxMax));
755 fOutput->Add(vtxAxis);
757 // Output trigger efficiency and shape correction
758 fOutput->Add(AliForwardUtil::MakeParameter("triggerEff", fTriggerEff));
759 fOutput->Add(AliForwardUtil::MakeParameter("triggerEff0", fTriggerEff0));
760 if (fShapeCorr) fOutput->Add(fShapeCorr);
762 TNamed* options = new TNamed("options","");
764 str.Append(Form("Edges %scut, ", fCutEdges ? "" : "not "));
765 str.Append(Form("Empty bins %scorrected for, ", fCorrEmpty ? "" : "not "));
766 str.Append(Form("TH2::ProjectionX %sused", fUseROOTProj ? "" : "not "));
767 options->SetTitle(str);
768 fOutput->Add(options);
770 PostData(2, fOutput);
772 //________________________________________________________________________
774 AliBasedNdetaTask::LoadNormalizationData(UShort_t sys, UShort_t energy)
776 // Load the normalisation data for dN/deta for pp INEL, INEL>0, and NSD
777 DGUARD(fDebug,1,"Load the normalization data for sys=%d, energy=%d",
781 if(energy == 7000) snn.Form("7000");
782 if(energy == 2750) snn.Form("2750");
784 if(fShapeCorr && (fTriggerEff != 1)) {
785 AliInfo("Objects already set for normalization - no action taken");
789 TFile* fin = TFile::Open(Form("$ALICE_ROOT/PWGLF/FORWARD/corrections/"
790 "Normalization/normalizationHists_%s_%s.root",
791 type.Data(),snn.Data()));
793 AliWarning(Form("no file for normalization of %d/%d", sys, energy));
798 if ((fNormalizationScheme & kShape) && !fShapeCorr) {
799 TString trigName("All");
800 if (fTriggerMask == AliAODForwardMult::kInel ||
801 fTriggerMask == AliAODForwardMult::kNClusterGt0)
803 else if (fTriggerMask == AliAODForwardMult::kNSD)
805 else if (fTriggerMask == AliAODForwardMult::kInelGt0)
806 trigName = "InelGt0";
808 AliWarning(Form("Normalization for trigger %s not known, using all",
809 AliAODForwardMult::GetTriggerString(fTriggerMask)));
812 TString shapeCorName(Form("h%sNormalization", trigName.Data()));
813 TH2F* shapeCor = dynamic_cast<TH2F*>(fin->Get(shapeCorName));
814 if (shapeCor) SetShapeCorrection(shapeCor);
816 AliWarning(Form("No shape correction found for %s", trigName.Data()));
820 // Trigger efficiency
821 TString effName(Form("%sTriggerEff",
822 fTriggerMask == AliAODForwardMult::kInel ? "inel" :
823 fTriggerMask == AliAODForwardMult::kNSD ? "nsd" :
824 fTriggerMask == AliAODForwardMult::kInelGt0 ?
827 Double_t trigEff = 1;
828 if (fNormalizationScheme & kTriggerEfficiency) {
829 TObject* eff = fin->Get(effName);
830 if (eff) AliForwardUtil::GetParameter(eff, trigEff);
832 if (fTriggerEff != 1) SetTriggerEff(trigEff);
833 if (fTriggerEff < 0) fTriggerEff = 1;
835 // Trigger efficiency
836 TString eff0Name(Form("%sTriggerEff0",
837 fTriggerMask == AliAODForwardMult::kInel ? "inel" :
838 fTriggerMask == AliAODForwardMult::kNSD ? "nsd" :
839 fTriggerMask == AliAODForwardMult::kInelGt0 ?
842 Double_t trigEff0 = 1;
843 if (fNormalizationScheme & kTriggerEfficiency) {
844 TObject* eff = fin->Get(eff0Name);
845 if (eff) AliForwardUtil::GetParameter(eff, trigEff0);
847 if (fTriggerEff0 != 1) SetTriggerEff0(trigEff0);
848 if (fTriggerEff0 < 0) fTriggerEff0 = 1;
851 // Rescale the shape correction by the trigger efficiency
853 AliWarning(Form("Rescaling shape correction by trigger efficiency: "
854 "1/E_X=1/%f", trigEff));
855 fShapeCorr->Scale(1. / trigEff);
859 if (fShapeCorr && fTriggerEff) AliInfo("Loaded objects for normalization.");
863 //________________________________________________________________________
865 AliBasedNdetaTask::Print(Option_t*) const
870 std::cout << this->ClassName() << ": " << this->GetName() << "\n"
872 << " Trigger: " << (fTriggerString ?
873 fTriggerString->GetTitle() :
875 << " Vertex range: [" << fVtxMin << ":"
877 << " Rebin factor: " << fRebin << "\n"
878 << " Cut edges: " << fCutEdges << "\n"
879 << " Symmertrice: " << fSymmetrice << "\n"
880 << " Use TH2::ProjectionX: " << fUseROOTProj << "\n"
881 << " Correct for empty: " << fCorrEmpty << "\n"
882 << " Normalization scheme: " << (fSchemeString ?
883 fSchemeString->GetTitle() :
885 << " Trigger efficiency: " << fTriggerEff << "\n"
886 << " Bin-0 Trigger efficiency: " << fTriggerEff0 << "\n"
887 << " Shape correction: " << (fShapeCorr ?
888 fShapeCorr->GetName() :
890 << " sqrt(s_NN): " << (fSNNString ?
891 fSNNString->GetTitle() :
893 << " Collision system: " << (fSysString ?
894 fSysString->GetTitle() :
896 << " Centrality bins: " << (fCentAxis ? "" : "none");
898 Int_t nBins = fCentAxis->GetNbins();
899 const Double_t* bins = fCentAxis->GetXbins()->GetArray();
900 for (Int_t i = 0; i <= nBins; i++)
901 std::cout << (i==0 ? "" : "-") << bins[i];
903 std::cout << std::noboolalpha << std::endl;
907 //________________________________________________________________________
909 AliBasedNdetaTask::Rebin(const TH1D* h, Int_t rebin, Bool_t cutEdges)
912 // Make a copy of the input histogram and rebin that histogram
915 // h Histogram to rebin
918 // New (rebinned) histogram
920 if (rebin <= 1) return 0;
922 Int_t nBins = h->GetNbinsX();
923 if(nBins % rebin != 0) {
924 AliWarningGeneral("AliBasedNdetaTask",
925 Form("Rebin factor %d is not a devisor of current number "
926 "of bins %d in the histogram %s",
927 rebin, nBins, h->GetName()));
932 TH1D* tmp = static_cast<TH1D*>(h->Clone(Form("%s_rebin%02d",
933 h->GetName(), rebin)));
935 tmp->SetDirectory(0);
937 // The new number of bins
938 Int_t nBinsNew = nBins / rebin;
939 for(Int_t i = 1;i<= nBinsNew; i++) {
940 Double_t content = 0;
944 for(Int_t j = 1; j<=rebin;j++) {
945 Int_t bin = (i-1)*rebin + j;
946 Double_t c = h->GetBinContent(bin);
947 if (c <= 0) continue;
950 if (h->GetBinContent(bin+1)<=0 ||
951 h->GetBinContent(bin-1)<=0) {
953 AliWarningGeneral("AliBasedNdetaTask",
954 Form("removing bin %d=%f of %s (%d=%f,%d=%f)",
955 bin, c, h->GetName(),
956 bin+1, h->GetBinContent(bin+1),
957 bin-1, h->GetBinContent(bin-1)));
962 Double_t e = h->GetBinError(bin);
963 Double_t w = 1 / (e*e); // 1/c/c
970 if(content > 0 && nbins > 0) {
971 tmp->SetBinContent(i, wsum / sumw);
972 tmp->SetBinError(i,1./TMath::Sqrt(sumw));
979 //__________________________________________________________________
981 AliBasedNdetaTask::Symmetrice(const TH1* h)
984 // Make an extension of @a h to make it symmetric about 0
987 // h Histogram to symmertrice
990 // Symmetric extension of @a h
992 Int_t nBins = h->GetNbinsX();
993 TH1* s = static_cast<TH1*>(h->Clone(Form("%s_mirror", h->GetName())));
994 s->SetTitle(Form("%s (mirrored)", h->GetTitle()));
996 s->SetBins(nBins, -h->GetXaxis()->GetXmax(), -h->GetXaxis()->GetXmin());
997 s->SetMarkerColor(h->GetMarkerColor());
998 s->SetMarkerSize(h->GetMarkerSize());
999 s->SetMarkerStyle(FlipHollowStyle(h->GetMarkerStyle()));
1000 s->SetFillColor(h->GetFillColor());
1001 s->SetFillStyle(h->GetFillStyle());
1004 // Find the first and last bin with data
1005 Int_t first = nBins+1;
1007 for (Int_t i = 1; i <= nBins; i++) {
1008 if (h->GetBinContent(i) <= 0) continue;
1009 first = TMath::Min(first, i);
1010 last = TMath::Max(last, i);
1013 Double_t xfirst = h->GetBinCenter(first-1);
1014 Int_t f1 = h->GetXaxis()->FindBin(-xfirst);
1015 Int_t l2 = s->GetXaxis()->FindBin(xfirst);
1016 for (Int_t i = f1, j=l2; i <= last; i++,j--) {
1017 s->SetBinContent(j, h->GetBinContent(i));
1018 s->SetBinError(j, h->GetBinError(i));
1020 // Fill in overlap bin
1021 s->SetBinContent(l2+1, h->GetBinContent(first));
1022 s->SetBinError(l2+1, h->GetBinError(first));
1026 //__________________________________________________________________
1028 AliBasedNdetaTask::GetMarkerStyle(UShort_t bits)
1030 Int_t base = bits & (0xFE);
1031 Bool_t hollow = bits & kHollow;
1033 case kCircle: return (hollow ? 24 : 20);
1034 case kSquare: return (hollow ? 25 : 21);
1035 case kUpTriangle: return (hollow ? 26 : 22);
1036 case kDownTriangle: return (hollow ? 32 : 23);
1037 case kDiamond: return (hollow ? 27 : 33);
1038 case kCross: return (hollow ? 28 : 34);
1039 case kStar: return (hollow ? 30 : 29);
1043 //__________________________________________________________________
1045 AliBasedNdetaTask::GetMarkerBits(Int_t style)
1049 case 24: case 25: case 26: case 27: case 28: case 30: case 32:
1050 bits |= kHollow; break;
1053 case 20: case 24: bits |= kCircle; break;
1054 case 21: case 25: bits |= kSquare; break;
1055 case 22: case 26: bits |= kUpTriangle; break;
1056 case 23: case 32: bits |= kDownTriangle; break;
1057 case 27: case 33: bits |= kDiamond; break;
1058 case 28: case 34: bits |= kCross; break;
1059 case 29: case 30: bits |= kStar; break;
1063 //__________________________________________________________________
1065 AliBasedNdetaTask::FlipHollowStyle(Int_t style)
1067 UShort_t bits = GetMarkerBits(style);
1068 Int_t ret = GetMarkerStyle(bits ^ kHollow);
1072 //====================================================================
1074 AliBasedNdetaTask::Sum::Init(TList* list, const TH2D* data, Int_t col)
1076 DGUARD(fDebug,1,"Initializing sums with %s", data->GetName());
1077 TString n(GetHistName(0));
1078 TString n0(GetHistName(1));
1079 const char* postfix = GetTitle();
1081 fSum = static_cast<TH2D*>(data->Clone(n));
1082 if (postfix) fSum->SetTitle(Form("%s (%s)", data->GetTitle(), postfix));
1083 fSum->SetDirectory(0);
1084 fSum->SetMarkerColor(col);
1085 fSum->SetMarkerStyle(GetMarkerStyle(kCircle|kSolid));
1089 fSum0 = static_cast<TH2D*>(data->Clone(n0));
1091 fSum0->SetTitle(Form("%s 0-bin (%s)", data->GetTitle(), postfix));
1093 fSum0->SetTitle(Form("%s 0-bin", data->GetTitle()));
1094 fSum0->SetDirectory(0);
1095 fSum0->SetMarkerColor(col);
1096 fSum0->SetMarkerStyle(GetMarkerStyle(kCross|kHollow));
1100 fEvents = new TH1I(GetHistName(2), "Event types", 2, -.5, 1.5);
1101 fEvents->SetDirectory(0);
1102 fEvents->GetXaxis()->SetBinLabel(1, "Non-zero");
1103 fEvents->GetXaxis()->SetBinLabel(2, "Zero");
1107 //____________________________________________________________________
1109 AliBasedNdetaTask::Sum::GetHistName(const char* name, Int_t what, const char* post)
1112 if (what == 1) n.Append("0");
1113 else if (what == 2) n.Append("Events");
1114 if (post && post[0] != '\0') n.Append(post);
1118 //____________________________________________________________________
1120 AliBasedNdetaTask::Sum::GetHistName(Int_t what) const
1122 return GetHistName(GetName(), what, GetTitle());
1125 //____________________________________________________________________
1127 AliBasedNdetaTask::Sum::Add(const TH2D* data, Bool_t isZero)
1129 DGUARD(fDebug,2,"Adding %s to sums", data->GetName());
1130 if (isZero) fSum0->Add(data);
1131 else fSum->Add(data);
1132 fEvents->Fill(isZero ? 1 : 0);
1135 //____________________________________________________________________
1137 AliBasedNdetaTask::Sum::CalcSum(TList* output,
1143 Bool_t corrEmpty) const
1145 DGUARD(fDebug,2,"Calculating final summed histogram %s", fSum->GetName());
1147 TH2D* ret = static_cast<TH2D*>(fSum->Clone(fSum->GetName()));
1148 ret->SetDirectory(0);
1150 Int_t n = Int_t(fEvents->GetBinContent(1));
1151 Int_t n0 = Int_t(fEvents->GetBinContent(2));
1153 AliInfoF("Adding histograms %s and %s with weights %f and %f resp.",
1154 fSum0->GetName(), fSum->GetName(), 1./epsilon, 1./epsilon0);
1155 DMSG(fDebug,2, "Adding histograms %s and %s with weights %f and %f resp.",
1156 fSum0->GetName(), fSum->GetName(), 1./epsilon, 1./epsilon0);
1157 // Generate merged histogram
1158 ret->Add(fSum0, fSum, 1. / epsilon0, 1. / epsilon);
1159 ntotal = n / epsilon + n0 / epsilon0;
1161 TList* out = new TList;
1163 const char* postfix = GetTitle();
1164 if (!postfix) postfix = "";
1165 out->SetName(Form("partial%s", postfix));
1168 // Now make copies, normalize them, and store in output list
1169 TH2D* sumCopy = static_cast<TH2D*>(fSum->Clone("sum"));
1170 TH2D* sum0Copy = static_cast<TH2D*>(fSum0->Clone("sum0"));
1171 TH2D* retCopy = static_cast<TH2D*>(ret->Clone("sumAll"));
1172 sumCopy->SetMarkerStyle(FlipHollowStyle(marker));
1173 sumCopy->SetDirectory(0);
1174 sum0Copy->SetMarkerStyle(GetMarkerStyle(GetMarkerBits(marker)+4));
1175 sum0Copy->SetDirectory(0);
1176 retCopy->SetMarkerStyle(marker);
1177 retCopy->SetDirectory(0);
1179 TH1D* norm = ProjectX(fSum, "norm", 0, 0, rootProj, corrEmpty, false);
1180 TH1D* norm0 = ProjectX(fSum0, "norm0", 0, 0, rootProj, corrEmpty, false);
1181 TH1D* normAll = ProjectX(ret, "normAll", 0, 0, rootProj, corrEmpty, false);
1182 norm->SetDirectory(0);
1183 norm0->SetDirectory(0);
1184 normAll->SetDirectory(0);
1186 ScaleToCoverage(sumCopy, norm);
1187 ScaleToCoverage(sum0Copy, norm0);
1188 ScaleToCoverage(retCopy, normAll);
1190 Int_t nY = fSum->GetNbinsY();
1191 TH1D* sumCopyPx = ProjectX(sumCopy, "average", 1, nY,rootProj,corrEmpty);
1192 TH1D* sum0CopyPx = ProjectX(sum0Copy, "average0", 1, nY,rootProj,corrEmpty);
1193 TH1D* retCopyPx = ProjectX(retCopy, "averageAll", 1, nY,rootProj,corrEmpty);
1194 sumCopyPx->SetDirectory(0);
1195 sum0CopyPx->SetDirectory(0);
1196 retCopyPx->SetDirectory(0);
1198 // Scale our 1D histograms
1199 sumCopyPx->Scale(1., "width");
1200 sum0CopyPx->Scale(1., "width");
1201 retCopyPx->Scale(1., "width");
1203 AliInfo(Form("Maximum %f,%f changed to %f", sumCopyPx->GetMaximum(),
1204 sum0CopyPx->GetMaximum(), retCopyPx->GetMaximum()));
1206 // Scale the normalization - they should be 1 at the maximum
1207 norm->Scale(n > 0 ? 1. / n : 1);
1208 norm0->Scale(n0 > 0 ? 1. / n0 : 1);
1209 normAll->Scale(ntotal > 0 ? 1. / ntotal : 1);
1214 out->Add(sumCopyPx);
1215 out->Add(sum0CopyPx);
1216 out->Add(retCopyPx);
1221 AliInfoF("Returning (1/%f * %s + 1/%f * %s), "
1222 "1/%f * %d + 1/%f * %d = %d",
1223 epsilon0, fSum0->GetName(), epsilon, fSum->GetName(),
1224 epsilon0, n0, epsilon, n, int(ntotal));
1226 for (Int_t i = 1; i <= ret->GetNbinsX(); i++) {
1227 Double_t nc = sum->GetBinContent(i, 0);
1228 Double_t nc0 = sum0->GetBinContent(i, 0);
1229 ret->SetBinContent(i, 0, nc + nc0); // Just count events
1236 //====================================================================
1237 AliBasedNdetaTask::CentralityBin::CentralityBin()
1246 fDoFinalMCCorrection(false),
1252 DGUARD(0,0,"Centrality bin default construction");
1254 //____________________________________________________________________
1255 AliBasedNdetaTask::CentralityBin::CentralityBin(const char* name,
1256 Short_t low, Short_t high)
1265 fDoFinalMCCorrection(false),
1272 // name Name used for histograms (e.g., Forward)
1273 // low Lower centrality cut in percent
1274 // high Upper centrality cut in percent
1276 DGUARD(0,0,"Named Centrality bin construction: %s [%3d,%3d]",name,low,high);
1277 if (low <= 0 && high <= 0) {
1280 SetTitle("All centralities");
1285 SetTitle(Form("Centrality bin from %3d%% to %3d%%", low, high));
1288 //____________________________________________________________________
1289 AliBasedNdetaTask::CentralityBin::CentralityBin(const CentralityBin& o)
1295 fTriggers(o.fTriggers),
1298 fDoFinalMCCorrection(o.fDoFinalMCCorrection),
1305 // other Object to copy from
1307 DGUARD(0,0,"Copy Centrality bin construction");
1309 //____________________________________________________________________
1310 AliBasedNdetaTask::CentralityBin::~CentralityBin()
1315 DGUARD(fDebug,3,"Centrality bin desctruction");
1316 if (fSums) fSums->Delete();
1317 if (fOutput) fOutput->Delete();
1320 //____________________________________________________________________
1321 AliBasedNdetaTask::CentralityBin&
1322 AliBasedNdetaTask::CentralityBin::operator=(const CentralityBin& o)
1325 // Assignment operator
1328 // other Object to assign from
1331 // Reference to this
1333 DGUARD(fDebug,3,"Centrality bin assignment");
1334 if (&o == this) return *this;
1335 SetName(o.GetName());
1336 SetTitle(o.GetTitle());
1338 fOutput = o.fOutput;
1341 fTriggers = o.fTriggers;
1344 fDoFinalMCCorrection = o.fDoFinalMCCorrection;
1348 //____________________________________________________________________
1350 AliBasedNdetaTask::CentralityBin::GetColor(Int_t fallback) const
1352 if (IsAllBin()) return fallback;
1353 Float_t fc = (fLow+double(fHigh-fLow)/2) / 100;
1354 Int_t nCol = gStyle->GetNumberOfColors();
1355 Int_t icol = TMath::Min(nCol-1,int(fc * nCol + .5));
1356 Int_t col = gStyle->GetColorPalette(icol);
1359 //____________________________________________________________________
1361 AliBasedNdetaTask::CentralityBin::GetListName() const
1364 // Get the list name
1369 if (IsAllBin()) return "all";
1370 return Form("cent%03d_%03d", fLow, fHigh);
1372 //____________________________________________________________________
1374 AliBasedNdetaTask::CentralityBin::CreateOutputObjects(TList* dir)
1377 // Create output objects
1382 DGUARD(fDebug,1,"Create centrality bin output objects");
1384 fSums->SetName(GetListName());
1388 fTriggers = AliAODForwardMult::MakeTriggerHistogram("triggers");
1389 fTriggers->SetDirectory(0);
1390 fSums->Add(fTriggers);
1392 //____________________________________________________________________
1394 AliBasedNdetaTask::CentralityBin::SetDebugLevel(Int_t lvl)
1397 if (fSum) fSum->fDebug = lvl;
1398 if (fSumMC) fSumMC->fDebug = lvl;
1401 //____________________________________________________________________
1403 AliBasedNdetaTask::CentralityBin::ReadSum(TList* list, bool mc)
1405 const char* post = (mc ? "MC" : "");
1406 TString sn = Sum::GetHistName(GetName(),0,post);
1407 TString sn0 = Sum::GetHistName(GetName(),1,post);
1408 TString ev = Sum::GetHistName(GetName(),2,post);
1409 TH2D* sum = static_cast<TH2D*>(list->FindObject(sn));
1410 TH2D* sum0 = static_cast<TH2D*>(list->FindObject(sn0));
1411 TH1I* events = static_cast<TH1I*>(list->FindObject(ev));
1412 if (!sum || !sum0 || !events) {
1413 AliWarningF("Failed to find one or more histograms: "
1414 "%s (%p) %s (%p) %s (%p)",
1420 Sum* ret = new Sum(GetName(), post);
1423 ret->fEvents = events;
1424 ret->fDebug = fDebug;
1425 if (mc) fSumMC = ret;
1431 //____________________________________________________________________
1433 AliBasedNdetaTask::CentralityBin::CreateSums(const TH2D* data, const TH2D* mc)
1436 // Create sum histogram
1439 // data Data histogram to clone
1440 // mc (optional) MC histogram to clone
1442 DGUARD(fDebug,1,"Create centrality bin sums from %s",
1443 data ? data->GetName() : "(null)");
1445 fSum = new Sum(GetName(),"");
1446 fSum->Init(fSums, data, GetColor());
1447 fSum->fDebug = fDebug;
1450 // If no MC data is given, then do not create MC sum histogram
1453 fSumMC = new Sum(GetName(), "MC");
1454 fSumMC->Init(fSums, mc, GetColor());
1455 fSumMC->fDebug = fDebug;
1458 //____________________________________________________________________
1460 AliBasedNdetaTask::CentralityBin::CheckEvent(const AliAODForwardMult* forward,
1462 Double_t vzMin, Double_t vzMax)
1465 // Check the trigger, vertex, and centrality
1471 // true if the event is to be used
1473 if (!forward) return false;
1475 DGUARD(fDebug,2,"Check the event");
1476 // We do not check for centrality here - it's already done
1477 return forward->CheckEvent(triggerMask, vzMin, vzMax, 0, 0, fTriggers);
1481 //____________________________________________________________________
1483 AliBasedNdetaTask::CentralityBin::ProcessEvent(const AliAODForwardMult* forward,
1484 Int_t triggerMask, Bool_t isZero,
1485 Double_t vzMin, Double_t vzMax,
1486 const TH2D* data, const TH2D* mc)
1492 // forward Forward data (for trigger, vertex, & centrality)
1493 // triggerMask Trigger mask
1494 // vzMin Minimum IP z coordinate
1495 // vzMax Maximum IP z coordinate
1496 // data Data histogram
1499 DGUARD(fDebug,1,"Process one event for %s a given centrality bin",
1500 data ? data->GetName() : "(null)");
1501 if (!CheckEvent(forward, triggerMask, vzMin, vzMax)) return;
1503 if (!fSum) CreateSums(data, mc);
1505 fSum->Add(data, isZero);
1506 if (mc) fSumMC->Add(mc, isZero);
1509 //________________________________________________________________________
1511 AliBasedNdetaTask::CentralityBin::Normalization(const TH1I& t,
1514 Double_t& ntotal) const
1517 // Calculate normalization
1520 // t Trigger histogram
1521 // scheme Normaliztion scheme
1523 // ntotal On return, contains the number of events.
1525 DGUARD(fDebug,1,"Normalize centrality bin with %s", t.GetName());
1526 Double_t nAll = t.GetBinContent(AliAODForwardMult::kBinAll);
1527 Double_t nB = t.GetBinContent(AliAODForwardMult::kBinB);
1528 Double_t nA = t.GetBinContent(AliAODForwardMult::kBinA);
1529 Double_t nC = t.GetBinContent(AliAODForwardMult::kBinC);
1530 Double_t nE = t.GetBinContent(AliAODForwardMult::kBinE);
1531 Double_t nOffline = t.GetBinContent(AliAODForwardMult::kBinOffline);
1532 Double_t nTriggered = t.GetBinContent(AliAODForwardMult::kWithTrigger);
1533 Double_t nWithVertex = t.GetBinContent(AliAODForwardMult::kWithVertex);
1534 Double_t nAccepted = ntotal;
1537 if (nTriggered <= 0.1) {
1538 AliError("Number of triggered events <= 0");
1541 if (nWithVertex <= 0.1) {
1542 AliError("Number of events with vertex <= 0");
1546 Double_t vtxEff = nWithVertex / nTriggered;
1547 Double_t scaler = 1;
1548 Double_t beta = nA + nC - 2*nE;
1550 if (scheme & kEventLevel && !(scheme & kZeroBin)) {
1551 ntotal = nAccepted / vtxEff;
1553 AliInfo(Form("Calculating event normalisation as\n"
1554 " N = N_A * N_T / N_V = %d * %d / %d = %f (%f)",
1555 Int_t(nAccepted), Int_t(nTriggered), Int_t(nWithVertex),
1558 if (scheme & kBackground) {
1560 // s = --------- = ------------- = ------------
1561 // 1 - beta 1 - beta E_V 1 - beta N_V
1562 // --- ---- -------- ---- ---
1563 // E_V N_V N_V N_V N_T
1571 ntotal -= nAccepted * beta / nWithVertex;
1572 // This one is direct and correct.
1573 // scaler = 1. / (1. / vtxEff - beta / nWithVertex);
1574 // A simpler expresion
1575 scaler /= (1 - beta / nTriggered); // 0.831631 -> 0.780689
1576 AliInfo(Form("Calculating event normalisation as\n"
1577 " beta = N_a + N_c + 2 N_e = %d + %d - 2 * %d = %d\n"
1578 " N = N - N_A * beta / N_V = %f - %d * %d / %d = %f (%f)",
1579 Int_t(nA), Int_t(nC), Int_t(nE), Int_t(beta),
1580 nAccepted / vtxEff, Int_t(nAccepted), Int_t(beta),
1581 Int_t(nWithVertex), ntotal, scaler));
1584 if (scheme & kZeroBin) {
1587 // N = N_A + 1/E_X * N_A / N_V (N_T - N_V - beta)
1588 // = N_A (1 + 1/E_X (N_T/N_V - 1 - beta / N_V))
1590 // s = N_A/N = 1 / (1 + 1/E_X (N_T/N_V - 1 - beta / N_V))
1591 // = N_V / (N_V + 1/E_X (N_T - N_V - beta))
1593 if (!(scheme & kBackground)) beta = 0;
1594 ntotal = nAccepted * (1 + 1/trigEff * (nTriggered / nWithVertex - 1
1595 - beta / nWithVertex));
1596 scaler = nWithVertex / (nWithVertex +
1597 1/trigEff * (nTriggered-nWithVertex-beta));
1598 AliInfo(Form("Calculating event normalisation as\n"
1599 " beta = N_a + N_c + 2 N_e = %d + %d - 2 * %d = %d\n"
1600 " N = N_A (1 + 1/E_X (N_T/N_V - 1 - beta / N_V)) = "
1601 "%d (1 + 1 / %f (%d / %d - 1 - %d / %d)) = %f (%f)",
1602 Int_t(nA), Int_t(nC), Int_t(nE), Int_t(beta),
1603 Int_t(nAccepted), trigEff, Int_t(nTriggered),
1604 Int_t(nWithVertex), Int_t(beta), Int_t(nWithVertex),
1607 if (scheme & kTriggerEfficiency && !(scheme & kZeroBin)) {
1610 AliInfo(Form("Correcting for trigger efficiency:\n"
1611 " N = 1 / E_X * N = 1 / %f * %d = %f (%f)",
1612 trigEff, Int_t(ntotal), ntotal / trigEff, scaler));
1616 " Total of %9d events for %s\n"
1617 " of these %9d have an offline trigger\n"
1618 " of these N_T = %9d has the selected trigger\n"
1619 " of these N_V = %9d has a vertex\n"
1620 " of these N_A = %9d were in the selected range\n"
1621 " Triggers by hardware type:\n"
1623 " N_ac = %9d (%d+%d)\n"
1625 " Vertex efficiency: %f\n"
1626 " Trigger efficiency: %f\n"
1627 " Total number of events: N = %f\n"
1628 " Scaler (N_A/N): %f",
1629 Int_t(nAll), GetTitle(), Int_t(nOffline),
1630 Int_t(nTriggered), Int_t(nWithVertex), Int_t(nAccepted),
1631 Int_t(nB), Int_t(nA+nC), Int_t(nA), Int_t(nC), Int_t(nE),
1632 vtxEff, trigEff, ntotal, scaler));
1636 //________________________________________________________________________
1638 AliBasedNdetaTask::CentralityBin::GetResultName(Int_t rebin,
1640 const char* postfix) const
1643 n = Form("dndeta%s%s",GetName(), postfix);
1644 if (rebin > 1) n.Append(Form("_rebin%02d", rebin));
1645 if (sym) n.Append("_mirror");
1648 //________________________________________________________________________
1650 AliBasedNdetaTask::CentralityBin::GetResult(Int_t rebin,
1652 const char* postfix) const
1655 AliWarning(Form("No output list defined in %s [%3d,%3d]", GetName(),
1659 TString n = GetResultName(rebin, sym, postfix);
1660 TObject* o = fOutput->FindObject(n.Data());
1662 // AliWarning(Form("Object %s not found in output list", n.Data()));
1665 return static_cast<TH1*>(o);
1668 //________________________________________________________________________
1670 AliBasedNdetaTask::CentralityBin::MakeResult(const TH2D* sum,
1671 const char* postfix,
1674 const TH2F* shapeCorr,
1685 // Generate the dN/deta result from input
1688 // sum Sum of 2D hists
1689 // postfix Post fix on names
1690 // rootProj Whether to use ROOT TH2::ProjectionX
1691 // corrEmpty Correct for empty bins
1692 // shapeCorr Shape correction to use
1693 // scaler Event-level normalization scaler
1694 // symmetrice Whether to make symmetric extensions
1695 // rebin Whether to rebin
1696 // cutEdges Whether to cut edges when rebinning
1698 DGUARD(fDebug,1,"Make centrality bin result from %s", sum->GetName());
1699 TH2D* copy = static_cast<TH2D*>(sum->Clone(Form("d2Ndetadphi%s%s",
1700 GetName(), postfix)));
1701 TH1D* accNorm = ProjectX(sum, Form("norm%s%s",GetName(), postfix), 0, 0,
1702 rootProj, corrEmpty, false);
1703 accNorm->SetDirectory(0);
1705 // ---- Scale by shape correction ----------------------------------
1706 if (shapeCorr) copy->Divide(shapeCorr);
1707 else AliInfo("No shape correction specified, or disabled");
1709 // --- Normalize to the coverage -----------------------------------
1710 ScaleToCoverage(copy, accNorm);
1712 // --- Event-level normalization -----------------------------------
1713 copy->Scale(scaler);
1715 // --- Project on X axis -------------------------------------------
1716 TH1D* dndeta = ProjectX(copy, Form("dndeta%s%s",GetName(), postfix),
1717 1, sum->GetNbinsY(), rootProj, corrEmpty);
1718 dndeta->SetDirectory(0);
1719 // Event-level normalization
1720 dndeta->Scale(1., "width");
1721 copy->Scale(1., "width");
1723 TH1D* dndetaMCCorrection = 0;
1724 TList* centlist = 0;
1725 TH1D* dndetaMCtruth = 0;
1726 TList* truthcentlist = 0;
1728 // Possible final correction to <MC analysis> / <MC truth>
1730 centlist = static_cast<TList*> (mclist->FindObject(GetListName()));
1732 dndetaMCCorrection =
1733 static_cast<TH1D*>(centlist->FindObject(Form("dndeta%s%s",
1734 GetName(), postfix)));
1736 truthcentlist =static_cast<TList*>(truthlist->FindObject(GetListName()));
1738 dndetaMCtruth =static_cast<TH1D*>(truthcentlist->FindObject("dndetaTruth"));
1740 if(dndetaMCCorrection && dndetaMCtruth) {
1741 AliInfo("Correcting with final MC correction");
1742 dndetaMCCorrection->Divide(dndetaMCtruth);
1743 dndetaMCCorrection->SetTitle("Final MC correction");
1744 dndetaMCCorrection->SetName("finalMCCorr");
1745 dndeta->Divide(dndetaMCCorrection);
1748 AliInfo("No final MC correction applied");
1750 // --- Set some histogram attributes -------------------------------
1752 Int_t rColor = GetColor(color);
1753 if (postfix && postfix[0] != '\0') post = Form(" (%s)", postfix);
1754 SetHistogramAttributes(dndeta, rColor, marker,
1755 Form("ALICE %s%s", GetName(), post.Data()));
1756 SetHistogramAttributes(accNorm, rColor, marker,
1757 Form("ALICE %s normalisation%s",
1758 GetName(), post.Data()));
1760 // --- Make symmetric extensions and rebinnings --------------------
1761 if (symmetrice) fOutput->Add(Symmetrice(dndeta));
1762 fOutput->Add(dndeta);
1763 fOutput->Add(accNorm);
1765 fOutput->Add(Rebin(dndeta, rebin, cutEdges));
1766 if (symmetrice) fOutput->Add(Symmetrice(Rebin(dndeta, rebin, cutEdges)));
1767 if (dndetaMCCorrection) fOutput->Add(dndetaMCCorrection);
1770 //________________________________________________________________________
1772 AliBasedNdetaTask::CentralityBin::End(TList* sums,
1775 const TH2F* shapeCorr,
1790 // End of processing
1793 // sums List of sums
1794 // results Output list of results
1795 // shapeCorr Shape correction or nil
1796 // trigEff Trigger efficiency
1797 // symmetrice Whether to symmetrice the results
1798 // rebin Whether to rebin the results
1799 // corrEmpty Whether to correct for empty bins
1800 // cutEdges Whether to cut edges when rebinning
1801 // triggerMask Trigger mask
1803 DGUARD(fDebug,1,"End centrality bin procesing");
1805 fSums = dynamic_cast<TList*>(sums->FindObject(GetListName()));
1807 AliError("Could not retrieve TList fSums");
1811 fOutput = new TList;
1812 fOutput->SetName(GetListName());
1813 fOutput->SetOwner();
1814 results->Add(fOutput);
1817 if (!ReadSum(fSums, false)) {
1818 AliInfo("This task did not produce any output");
1822 if (!fSumMC) ReadSum(fSums, true);
1824 fTriggers = static_cast<TH1I*>(fSums->FindObject("triggers"));
1827 AliError("Couldn't find histogram 'triggers' in list");
1831 // --- Get normalization scaler ------------------------------------
1832 Double_t epsilonT = trigEff;
1833 Double_t epsilonT0 = trigEff0;
1834 AliInfoF("Using epsilonT=%f, epsilonT0=%f for %d",
1835 epsilonT, epsilonT0, triggerMask);
1838 if (triggerMask == AliAODForwardMult::kNSD) {
1839 // This is a local change
1841 AliWarning(Form("Using hard-coded NSD trigger efficiency of %f",epsilonT));
1843 else if (triggerMask == AliAODForwardMult::kInel) {
1844 // This is a local change
1846 AliWarning(Form("Using hard-coded Inel trigger efficiency of %f",epsilonT));
1848 if (scheme & kZeroBin) {
1849 if (triggerMask==AliAODForwardMult::kInel)
1850 epsilonT0 = 0.785021; // 0.100240;
1851 else if (triggerMask==AliAODForwardMult::kInelGt0)
1853 else if (triggerMask==AliAODForwardMult::kNSD)
1854 epsilonT0 = .706587;
1856 AliWarning(Form("Using hard-coded NCluster>0 trigger efficiency of %f",
1861 // Get our histograms
1863 TH2D* sum = fSum->CalcSum(fOutput, nSum, epsilonT0, epsilonT,
1864 marker, rootProj, corrEmpty);
1865 Double_t nSumMC = 0;
1867 if (fSumMC) sumMC = fSumMC->CalcSum(fOutput, nSumMC,
1868 epsilonT0, epsilonT, marker,
1869 rootProj, corrEmpty);
1871 AliError("Failed to get sum from summer - bailing out");
1875 Double_t ntotal = nSum;
1876 Double_t scaler = Normalization(*fTriggers, scheme, epsilonT, ntotal);
1878 AliError("Failed to calculate normalization - bailing out");
1881 fOutput->Add(fTriggers->Clone());
1883 // --- Make result and store ---------------------------------------
1884 MakeResult(sum, "", rootProj, corrEmpty, (scheme & kShape) ? shapeCorr : 0,
1885 scaler, symmetrice, rebin, cutEdges, marker, color,
1888 // --- Process result from TrackRefs -------------------------------
1890 MakeResult(sumMC, "MC", rootProj, corrEmpty,
1891 (scheme & kShape) ? shapeCorr : 0,
1892 scaler, symmetrice, rebin, cutEdges,
1893 GetMarkerStyle(GetMarkerBits(marker)+4), color,
1897 // if (!IsAllBin()) return;