From e304c4107c9f1182e2de613a4faa15116e5bfe6b Mon Sep 17 00:00:00 2001 From: loizides Date: Wed, 19 Jun 2013 15:11:51 +0000 Subject: [PATCH] From Marta - Allow user defined cent bins - Extra getters for AliEmcalContainer and a protection in case no clusters or tracks are added in the multi-jet framework. --- PWG/EMCAL/AliAnalysisTaskEmcal.cxx | 18 ++++++++++++------ PWG/EMCAL/AliAnalysisTaskEmcal.h | 3 ++- PWG/EMCAL/AliAnalysisTaskEmcalDev.cxx | 27 ++++++++++++++++++++------- PWG/EMCAL/AliAnalysisTaskEmcalDev.h | 3 ++- PWG/EMCAL/AliEmcalContainer.h | 2 +- 5 files changed, 37 insertions(+), 16 deletions(-) diff --git a/PWG/EMCAL/AliAnalysisTaskEmcal.cxx b/PWG/EMCAL/AliAnalysisTaskEmcal.cxx index e0183e75d29..51075bdd43f 100644 --- a/PWG/EMCAL/AliAnalysisTaskEmcal.cxx +++ b/PWG/EMCAL/AliAnalysisTaskEmcal.cxx @@ -607,13 +607,19 @@ Bool_t AliAnalysisTaskEmcal::RetrieveEventObjects() AliCentrality *aliCent = InputEvent()->GetCentrality(); if (aliCent) { fCent = aliCent->GetCentralityPercentile(fCentEst.Data()); - if (fCent >= 0 && fCent < 10) fCentBin = 0; - else if (fCent >= 10 && fCent < 30) fCentBin = 1; - else if (fCent >= 30 && fCent < 50) fCentBin = 2; - else if (fCent >= 50 && fCent <= 100) fCentBin = 3; + if(fNcentBins==4) { + if (fCent >= 0 && fCent < 10) fCentBin = 0; + else if (fCent >= 10 && fCent < 30) fCentBin = 1; + else if (fCent >= 30 && fCent < 50) fCentBin = 2; + else if (fCent >= 50 && fCent <= 100) fCentBin = 3; + else { + AliWarning(Form("%s: Negative centrality: %f. Assuming 99", GetName(), fCent)); + fCentBin = 3; + } + } else { - AliWarning(Form("%s: Negative centrality: %f. Assuming 99", GetName(), fCent)); - fCentBin = 3; + Double_t centWidth = (fMaxCent-fMinCent)/(Double_t)fNcentBins; + fCentBin = TMath::FloorNint(fCent/centWidth); } } else { AliWarning(Form("%s: Could not retrieve centrality information! Assuming 99", GetName())); diff --git a/PWG/EMCAL/AliAnalysisTaskEmcal.h b/PWG/EMCAL/AliAnalysisTaskEmcal.h index c00ca9aea25..d7c445f0042 100644 --- a/PWG/EMCAL/AliAnalysisTaskEmcal.h +++ b/PWG/EMCAL/AliAnalysisTaskEmcal.h @@ -40,7 +40,8 @@ class AliAnalysisTaskEmcal : public AliAnalysisTaskSE { void UserExec(Option_t *option); void UserCreateOutputObjects(); - void SetAnaType(EmcalAnaType type) { fAnaType = type ; ; } + void SetAnaType(EmcalAnaType type) { fAnaType = type ; } + void SetNCentBins(Int_t n) { fNcentBins = n ; } void SetCentRange(Double_t min, Double_t max) { fMinCent = min ; fMaxCent = max ; } void SetClusName(const char *n) { fCaloName = n ; } void SetCaloCellsName(const char *n) { fCaloCellsName = n ; } diff --git a/PWG/EMCAL/AliAnalysisTaskEmcalDev.cxx b/PWG/EMCAL/AliAnalysisTaskEmcalDev.cxx index b241bac23c1..b38384047f4 100644 --- a/PWG/EMCAL/AliAnalysisTaskEmcalDev.cxx +++ b/PWG/EMCAL/AliAnalysisTaskEmcalDev.cxx @@ -380,7 +380,8 @@ void AliAnalysisTaskEmcalDev::ExecOnce() AliClusterContainer *cont = static_cast(fClusterCollArray.At(i)); cont->SetClusterArray(InputEvent()); } - fCaloClusters = GetClusterArray(0); + if(fClusterCollArray.GetEntriesFast()>0) + fCaloClusters = GetClusterArray(0); if(!fCaloClusters && fClusterCollArray.GetEntriesFast()>0) { AliError(Form("%s: Could not retrieve first cluster branch!", GetName())); return; @@ -585,13 +586,19 @@ Bool_t AliAnalysisTaskEmcalDev::RetrieveEventObjects() AliCentrality *aliCent = InputEvent()->GetCentrality(); if (aliCent) { fCent = aliCent->GetCentralityPercentile(fCentEst.Data()); - if (fCent >= 0 && fCent < 10) fCentBin = 0; - else if (fCent >= 10 && fCent < 30) fCentBin = 1; - else if (fCent >= 30 && fCent < 50) fCentBin = 2; - else if (fCent >= 50 && fCent <= 100) fCentBin = 3; + if(fNcentBins==4) { + if (fCent >= 0 && fCent < 10) fCentBin = 0; + else if (fCent >= 10 && fCent < 30) fCentBin = 1; + else if (fCent >= 30 && fCent < 50) fCentBin = 2; + else if (fCent >= 50 && fCent <= 100) fCentBin = 3; + else { + AliWarning(Form("%s: Negative centrality: %f. Assuming 99", GetName(), fCent)); + fCentBin = 3; + } + } else { - AliWarning(Form("%s: Negative centrality: %f. Assuming 99", GetName(), fCent)); - fCentBin = 3; + Double_t centWidth = (fMaxCent-fMinCent)/(Double_t)fNcentBins; + fCentBin = TMath::Nint(fCent/centWidth); } } else { AliWarning(Form("%s: Could not retrieve centrality information! Assuming 99", GetName())); @@ -619,6 +626,9 @@ void AliAnalysisTaskEmcalDev::AddParticleContainer(const char *n) { // Add particle container // will be called in AddTask macro + TString tmp = TString(n); + if(tmp.IsNull()) return; + AliParticleContainer *cont = 0x0; cont = new AliParticleContainer(); cont->SetArrayName(n); @@ -634,6 +644,9 @@ void AliAnalysisTaskEmcalDev::AddClusterContainer(const char *n) { // Add cluster container // will be called in AddTask macro + TString tmp = TString(n); + if(tmp.IsNull()) return; + AliClusterContainer *cont = 0x0; cont = new AliClusterContainer(); cont->SetArrayName(n); diff --git a/PWG/EMCAL/AliAnalysisTaskEmcalDev.h b/PWG/EMCAL/AliAnalysisTaskEmcalDev.h index 4b8523aa695..3a025d90b46 100644 --- a/PWG/EMCAL/AliAnalysisTaskEmcalDev.h +++ b/PWG/EMCAL/AliAnalysisTaskEmcalDev.h @@ -44,7 +44,8 @@ class AliAnalysisTaskEmcalDev : public AliAnalysisTaskSE { void UserExec(Option_t *option); void UserCreateOutputObjects(); - void SetAnaType(EmcalAnaType type) { fAnaType = type ; ; } + void SetAnaType(EmcalAnaType type) { fAnaType = type ; } + void SetNCentBins(Int_t n) { fNcentBins = n ; } void SetCentRange(Double_t min, Double_t max) { fMinCent = min ; fMaxCent = max ; } void SetClusName(const char *n) { fCaloName = n ; AddClusterContainer(n); } void SetCaloCellsName(const char *n) { fCaloCellsName = n ; } diff --git a/PWG/EMCAL/AliEmcalContainer.h b/PWG/EMCAL/AliEmcalContainer.h index 11bb6c3288d..d24a3e32827 100644 --- a/PWG/EMCAL/AliEmcalContainer.h +++ b/PWG/EMCAL/AliEmcalContainer.h @@ -23,7 +23,7 @@ class AliEmcalContainer : public TNamed { void SetArrayName(const char *n) {fClArrayName = n;} TClonesArray *GetArray() {return fClArray;} Int_t GetNEntries() const {return fClArray->GetEntriesFast();} - TString GetArrayName() {return fClArrayName;} + const TString& GetArrayName() const {return fClArrayName;} protected: void SetArray(AliVEvent *event, const char *clname=0); -- 2.43.0