//____________________________________________________________________
AliMCTruthdNdetaTask::AliMCTruthdNdetaTask()
- : AliBasedNdetaTask()
+ : AliBasedNdetaTask(),
+ fHasData(true)
{
//
// Constructor
//____________________________________________________________________
AliMCTruthdNdetaTask::AliMCTruthdNdetaTask(const char* /* name */)
- : AliBasedNdetaTask("MCTruth")
+ : AliBasedNdetaTask("MCTruth"),
+ fHasData(true)
{
//
// Constructor
// name Name of task
}
-//____________________________________________________________________
-AliMCTruthdNdetaTask::AliMCTruthdNdetaTask(const AliMCTruthdNdetaTask& o)
- : AliBasedNdetaTask(o)
-{
- //
- // Copy constructor
- //
-}
//____________________________________________________________________
AliBasedNdetaTask::CentralityBin*
//____________________________________________________________________
TH2D*
-AliMCTruthdNdetaTask::GetHistogram(const AliAODEvent* aod, Bool_t mc)
+AliMCTruthdNdetaTask::GetHistogram(const AliAODEvent& aod, Bool_t mc)
{
//
// Retrieve the histogram
// Return:
// Retrieved histogram or null
//
+ if (!fHasData) return 0;
if (mc) return 0;
- TObject* obj = aod->FindListObject("primary");
- // We should have a forward object at least
- if (!obj) return 0;
- TH2D* ret = static_cast<TH2D*>(obj);
- // Need to fill underflow bin with 1's
- for (Int_t i = 1; i <= ret->GetNbinsX(); i++)
- ret->SetBinContent(i, 0, 1);
+
+ TH2D* ret = GetPrimary(aod);
+ if (!ret) {
+ fHasData = false;
+ return 0;
+ }
+ Int_t nY = ret->GetNbinsY();
+ // Need to fill under-/overflow bin with 1's
+ for (Int_t i = 1; i <= ret->GetNbinsX(); i++) {
+ ret->SetBinContent(i, 0, 1);
+ ret->SetBinContent(i, nY+1, 1);
+ }
return ret;
}
//________________________________________________________________________
-void
-AliMCTruthdNdetaTask::Terminate(Option_t *option)
+Bool_t
+AliMCTruthdNdetaTask::Finalize()
{
//
// Called at end of event processing..
//
// Parameters:
// option Not used
- AliBasedNdetaTask::Terminate(option);
+ if (!fHasData) {
+ AliInfo("The MC truth dN/deta task didn't get any data");
+ return false;
+ }
+ AliBasedNdetaTask::Finalize();
THStack* truth = new THStack("dndetaTruth", "dN/d#eta MC Truth");
THStack* truthRebin = new THStack(Form("dndetaTruth_rebin%02d", fRebin),
TIter next(fListOfCentralities);
CentralityBin* bin = 0;
while ((bin = static_cast<CentralityBin*>(next()))) {
- if (fCentAxis && bin->IsAllBin()) continue;
+ if (HasCentrality() && bin->IsAllBin()) continue;
TList* results = bin->GetResults();
if (!results) continue;
delete truth;
truth = 0;
}
- if (truth) fOutput->Add(truth);
+ if (truth) fResults->Add(truth);
// If available output rebinned stack
if (!truthRebin->GetHists() ||
delete truthRebin;
truthRebin = 0;
}
- if (truthRebin) fOutput->Add(truthRebin);
+ if (truthRebin) fResults->Add(truthRebin);
+ return true;
}
//========================================================================
-void
+Bool_t
AliMCTruthdNdetaTask::CentralityBin::ProcessEvent(const AliAODForwardMult*
forward,
Int_t triggerMask,
const TH2D*)
{
// Check the centrality class unless this is the 'all' bin
- if (!primary) return;
+ if (!primary) return false;
if (!IsAllBin()) {
Double_t centrality = forward->GetCentrality();
- if (centrality < fLow || centrality >= fHigh) return;
+ if (centrality < fLow || centrality >= fHigh) return false;
}
if (!fSum) CreateSums(primary, 0);
// Now use our normal check with the full trigger mask and vertex
if (CheckEvent(forward, triggerMask, vzMin, vzMax))
fSum->Add(primary, isZero);
+ return true;
}
//________________________________________________________________________
AliMCTruthdNdetaTask::CentralityBin::End(TList* sums,
TList* results,
UShort_t scheme,
- const TH1* shapeCorr,
+ const TH2F* shapeCorr,
Double_t trigEff,
+ Double_t trigEff0,
Bool_t symmetrice,
Int_t rebin,
Bool_t rootProj,
"shapeCorr=%p, trigEff=%f, symmetrice=%d, rebin=%d, "
"rootProj=%d, corrEmpty=%d, cutEdges=%d, triggerMask=0x%08x, "
"marker=%d (%d)",
- sums, results, scheme, shapeCorr, trigEff, symmetrice,
+ sums, results, scheme, shapeCorr, trigEff, trigEff0, symmetrice,
rebin, rootProj, corrEmpty, cutEdges, triggerMask, marker,
GetMarkerStyle(kStar)));
#endif
AliBasedNdetaTask::CentralityBin::End(sums, results, scheme,
- shapeCorr, trigEff,
+ shapeCorr, trigEff, trigEff0,
symmetrice, rebin,
rootProj, corrEmpty, cutEdges,
triggerMask, marker, color, mclist,
Int_t n = (triggerMask == AliAODForwardMult::kNSD ?
Int_t(fTriggers->GetBinContent(AliAODForwardMult::kBinMCNSD)) :
Int_t(fTriggers->GetBinContent(AliAODForwardMult::kBinAll)));
- AliInfo(Form("Normalising MC truth to %d (%d additions)", n, n0));
+ DMSG(fDebug,0,"Normalising MC truth to %d (%d additions)", n, n0);
TH1D* dndetaTruth = fSumTruth->ProjectionX("dndetaTruth",1,
fSumTruth->GetNbinsY(),"e");
fOutput->Add(dndetaTruth);
fOutput->Add(Rebin(dndetaTruth, rebin, cutEdges));
}
- TH1* dndeta = GetResult(0, false, "");
- TH1* dndetaSym = GetResult(0, true, "");
- TH1* dndeta_rebin = GetResult(rebin, false, "");
- TH1* dndetaSym_rebin = GetResult(rebin, true, "");
+ TH1* dndeta = GetResult(0, false, "");
+ TH1* dndetaSym = symmetrice ? GetResult(0, true, "") : 0;
+ TH1* dndeta_rebin = rebin ? GetResult(rebin, false, "") : 0;
+ TH1* dndetaSym_rebin = symmetrice && rebin ? GetResult(rebin, true, "") : 0;
if (dndeta)
dndeta->SetTitle("Monte-Carlo truth (selected)");
if (dndetaSym)