From b5af2238f88f3f3c5847cdc713393937917a5187 Mon Sep 17 00:00:00 2001 From: Emil Gorm Nielsen Date: Thu, 30 Jan 2025 13:43:00 +0100 Subject: [PATCH 1/6] Task uses GFWWeightsList, fixed merging in GFWWeightsList --- PWGCF/GenericFramework/Core/GFWWeights.cxx | 9 + PWGCF/GenericFramework/Core/GFWWeights.h | 1 + .../GenericFramework/Core/GFWWeightsList.cxx | 119 +++++++++- PWGCF/GenericFramework/Core/GFWWeightsList.h | 16 +- .../Tasks/flowGenericFramework.cxx | 206 ++++++------------ 5 files changed, 208 insertions(+), 143 deletions(-) diff --git a/PWGCF/GenericFramework/Core/GFWWeights.cxx b/PWGCF/GenericFramework/Core/GFWWeights.cxx index 8ff60183f99..e0f5610bd36 100644 --- a/PWGCF/GenericFramework/Core/GFWWeights.cxx +++ b/PWGCF/GenericFramework/Core/GFWWeights.cxx @@ -470,3 +470,12 @@ TH1D* GFWWeights::GetEfficiency(double etamin, double etamax, double vzmin, doub delete den1d; return num1d; } +void GFWWeights::MergeWeights(GFWWeights* other){ + if (!fW_data) { + fW_data = new TObjArray(); + fW_data->SetName("Weights_Data"); + fW_data->SetOwner(kTRUE); + } + AddArray(fW_data, other->GetDataArray()); + return; +} \ No newline at end of file diff --git a/PWGCF/GenericFramework/Core/GFWWeights.h b/PWGCF/GenericFramework/Core/GFWWeights.h index e88904f14e8..deedbf20192 100644 --- a/PWGCF/GenericFramework/Core/GFWWeights.h +++ b/PWGCF/GenericFramework/Core/GFWWeights.h @@ -52,6 +52,7 @@ class GFWWeights : public TNamed void OverwriteNUA(); TH1D* GetdNdPhi(); TH1D* GetEfficiency(double etamin, double etamax, double vzmin, double vzmax); + void MergeWeights(GFWWeights* other); private: bool fDataFilled; diff --git a/PWGCF/GenericFramework/Core/GFWWeightsList.cxx b/PWGCF/GenericFramework/Core/GFWWeightsList.cxx index 4853ccd0507..801fbe68115 100644 --- a/PWGCF/GenericFramework/Core/GFWWeightsList.cxx +++ b/PWGCF/GenericFramework/Core/GFWWeightsList.cxx @@ -20,18 +20,21 @@ GFWWeightsList::GFWWeightsList() : TNamed("", ""), list(0) { - runNumerMap.clear(); + runNumberMap.clear(); + runNumberPIDMap.clear(); } GFWWeightsList::GFWWeightsList(const char* name) : TNamed(name, name), list(0) { - runNumerMap.clear(); + runNumberMap.clear(); + runNumberPIDMap.clear(); } GFWWeightsList::~GFWWeightsList() { delete list; - runNumerMap.clear(); + runNumberMap.clear(); + runNumberPIDMap.clear(); } void GFWWeightsList::init(const char* listName) @@ -69,14 +72,14 @@ void GFWWeightsList::addGFWWeightsByRun(int runNumber, int nPtBins, double* ptBi if (!list) { init("weightList"); } - if (runNumerMap.contains(runNumber)) { + if (runNumberMap.contains(runNumber)) { return; } GFWWeights* weight = new GFWWeights(Form("weight_%d", runNumber)); weight->SetPtBins(nPtBins, ptBins); weight->Init(addData, addMC); list->Add(weight); - runNumerMap.insert(std::make_pair(runNumber, weight)); + runNumberMap.insert(std::make_pair(runNumber, weight)); } GFWWeights* GFWWeightsList::getGFWWeightsByRun(int runNumber) @@ -85,9 +88,111 @@ GFWWeights* GFWWeightsList::getGFWWeightsByRun(int runNumber) printf("Error: weight list is not initialized\n"); return nullptr; } - if (!runNumerMap.contains(runNumber)) { + if (!runNumberMap.contains(runNumber)) { printf("Error: weight for run %d is not found\n", runNumber); return nullptr; } - return runNumerMap.at(runNumber); + return runNumberMap.at(runNumber); } + +void GFWWeightsList::addPIDGFWWeightsByName(const char* weightName, int nPtBins, double* ptBins, double ptrefup, bool addData, bool addMC) +{ + if (!list) { + init("weightList"); + } + + std::vector ptbins(ptBins, ptBins + nPtBins + 1); + auto it = std::find(ptbins.begin(), ptbins.end(), ptrefup); + std::vector refpt(ptbins.begin(), it + 1); + + for(auto & type : species){ + if (reinterpret_cast(list->FindObject((static_cast(weightName)+type).c_str()))) { + continue; + } + GFWWeights* weight = new GFWWeights(Form("%s",(static_cast(weightName)+type).c_str())); + if(!type.compare("_ref")) weight->SetPtBins(refpt.size() - 1, &(refpt[0])); + else weight->SetPtBins(nPtBins, ptBins); + weight->Init(addData, addMC); + list->Add(weight); + } +} +GFWWeights* GFWWeightsList::getPIDGFWWeightsByName(const char* weightName, int pidIndex) +{ + if(static_cast(pidIndex) >= species.size()) + return nullptr; + if (!list) { + printf("Error: weight list is not initialized\n"); + return nullptr; + } + return reinterpret_cast(list->FindObject((static_cast(weightName)+species[pidIndex]).c_str())); +} +void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, double ptrefup, bool addData, bool addMC) +{ + if (!list) { + init("weightList"); + } + + if (runNumberPIDMap.contains(runNumber)) return; + std::vector ptbins(ptBins, ptBins + nPtBins + 1); + auto it = std::find(ptbins.begin(), ptbins.end(), ptrefup); + std::vector refpt(ptbins.begin(), it + 1); + + std::vector weights; + for(auto & type : species){ + GFWWeights* weight = new GFWWeights(Form("weight_%d%s", runNumber, type.c_str())); + if(!type.compare("_ref")) weight->SetPtBins(refpt.size() - 1, &(refpt[0])); + else weight->SetPtBins(nPtBins, ptBins); + weight->Init(addData, addMC); + list->Add(weight); + weights.push_back(weight); + } + printf("Adding weights for run %d\n",runNumber); + runNumberPIDMap.insert(std::make_pair(runNumber, weights)); + return; +} + +GFWWeights* GFWWeightsList::getPIDGFWWeightsByRun(int runNumber, int pidIndex) +{ + if (!list) { + printf("Error: weight list is not initialized\n"); + return nullptr; + } + if (!runNumberPIDMap.contains(runNumber)) { + printf("Error: PID weights for run %d is not found\n", runNumber); + return nullptr; + } + return runNumberPIDMap.at(runNumber)[pidIndex]; +} +Long64_t GFWWeightsList::Merge(TCollection* collist) +{ + printf("Merging weight lists!\n"); + Long64_t nmerged = 0; + if (!list) { + list = new TObjArray(); + list->SetName("weightList"); + list->SetOwner(kTRUE); + } + TIter allWeights(collist); + GFWWeightsList* lWeight = 0; + while ((lWeight = (reinterpret_cast(allWeights())))) { + AddArray(list, lWeight->getList()); + nmerged++; + } + return nmerged; +} +void GFWWeightsList::AddArray(TObjArray* target, TObjArray* source) +{ + if (!source) { + return; + } + for (int i = 0; i < source->GetEntries(); i++) { + GFWWeights* sourw = reinterpret_cast(source->At(i)); + GFWWeights* targw = reinterpret_cast(target->FindObject(sourw->GetName())); + if (!targw) { + targw = reinterpret_cast(sourw->Clone(sourw->GetName())); + target->Add(targw); + } else { + targw->MergeWeights(sourw); + } + } +}; diff --git a/PWGCF/GenericFramework/Core/GFWWeightsList.h b/PWGCF/GenericFramework/Core/GFWWeightsList.h index 278a6e4edc6..f9cc4de0aa9 100644 --- a/PWGCF/GenericFramework/Core/GFWWeightsList.h +++ b/PWGCF/GenericFramework/Core/GFWWeightsList.h @@ -17,6 +17,9 @@ #ifndef PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTSLIST_H_ #define PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTSLIST_H_ #include + +#include "Framework/Logger.h" + #include "TObjArray.h" #include "GFWWeights.h" @@ -31,11 +34,20 @@ class GFWWeightsList : public TNamed GFWWeights* getGFWWeightsByName(const char* weightName); void addGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, bool addData = kTRUE, bool addMC = kTRUE); GFWWeights* getGFWWeightsByRun(int runNumber); - TObjArray* getList() const { return list; } + void addPIDGFWWeightsByName(const char* weightName, int nPtBins, double* ptBins, double ptrefup, bool addData = kTRUE, bool addMC = kTRUE); + GFWWeights* getPIDGFWWeightsByName(const char* weightName, int pidIndex); + void addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, double ptrefup, bool addData = kTRUE, bool addMC = kTRUE); + GFWWeights* getPIDGFWWeightsByRun(int runNumber, int pidIndex); + void PrintRuns() { for(auto &el : runNumberPIDMap) printf("%i\n",el.first); } + TObjArray* getList() const { return list; } + Long64_t Merge(TCollection* collist); private: TObjArray* list; - std::map runNumerMap; + std::vector species = {"_ref", "_ch", "_pi", "_ka", "_pr"}; //! + std::map runNumberMap; + std::map> runNumberPIDMap; + void AddArray(TObjArray* target, TObjArray* source); ClassDef(GFWWeightsList, 1); }; diff --git a/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx b/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx index a566d03c7ad..cf0ac0cbd30 100644 --- a/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx +++ b/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx @@ -42,6 +42,7 @@ #include "FlowPtContainer.h" #include "GFWConfig.h" #include "GFWWeights.h" +#include "GFWWeightsList.h" #include #include #include @@ -124,7 +125,7 @@ struct GenericFramework { struct Config { TH1D* mEfficiency = nullptr; - std::vector mAcceptance; + GFWWeightsList* mAcceptance; bool correctionsLoaded = false; } cfg; @@ -132,7 +133,7 @@ struct GenericFramework { OutputObj fFC{FlowContainer("FlowContainer")}; OutputObj fFCpt{FlowPtContainer("FlowPtContainer")}; OutputObj fFCgen{FlowContainer("FlowContainer_gen")}; - OutputObj fWeightList{"WeightList", OutputObjHandlingPolicy::AnalysisObject}; + OutputObj fWeightList{GFWWeightsList("WeightList")}; HistogramRegistry registry{"registry"}; // define global variables @@ -211,31 +212,13 @@ struct GenericFramework { int ptbins = ptbinning.size() - 1; fPtAxis = new TAxis(ptbins, &ptbinning[0]); - TList* weightlist = new TList(); - weightlist->SetOwner(true); - fWeightList.setObject(weightlist); + fWeightList->init("weightList"); if (!cfgRunByRunWeights && cfgFillWeights) { if (cfgUsePID) { - std::vector weights; - std::vector species = {"ref", "ch", "pi", "ka", "pr"}; - for (size_t i = 0; i < species.size(); ++i) { - weights.push_back(new GFWWeights(Form("w_%s", species[i].c_str()))); - if (i == 0) { - auto it = std::find(ptbinning.begin(), ptbinning.end(), ptrefup); - std::vector refpt(ptbinning.begin(), it + 1); - weights[i]->SetPtBins(refpt.size() - 1, &refpt[0]); - } else { - weights[i]->SetPtBins(fPtAxis->GetNbins(), &ptbinning[0]); - } - weights[i]->Init(true, false); - fWeightList->Add(weights[i]); - } + fWeightList->addPIDGFWWeightsByName("weight", fPtAxis->GetNbins(), &ptbinning[0], ptrefup, true, false); } else { - GFWWeights* weight = new GFWWeights("w_ch"); - weight->SetPtBins(fPtAxis->GetNbins(), &ptbinning[0]); - weight->Init(true, false); - fWeightList->Add(weight); + fWeightList->addGFWWeightsByName("weight", fPtAxis->GetNbins(), &ptbinning[0], true, false); } } @@ -260,7 +243,7 @@ struct GenericFramework { registry.add("eventQA/before/multV0A_multT0A", "", {HistType::kTH2D, {t0aAxis, t0aAxis}}); registry.add("eventQA/before/multT0C_centT0C", "", {HistType::kTH2D, {centAxis, t0cAxis}}); registry.addClone("eventQA/before/", "eventQA/after/"); - registry.add("eventQA/eventSel", "Number of Events;; Counts", {HistType::kTH1D, {{10, 0, 10}}}); + registry.add("eventQA/eventSel", "Number of Events;; Counts", {HistType::kTH1D, {{11, 0, 11}}}); registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(1, "Filtered event"); registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(2, "sel8"); registry.get(HIST("eventQA/eventSel"))->GetXaxis()->SetBinLabel(3, "occupancy"); @@ -376,52 +359,17 @@ struct GenericFramework { void loadCorrections(aod::BCsWithTimestamps::iterator const& bc) { uint64_t timestamp = bc.timestamp(); - int run = bc.runNumber(); - if (cfg.correctionsLoaded) { - if (!cfgRunByRunWeights) - return; - if (run == lastRun) - return; - } - if (cfgUsePID) { - if (cfgAcceptance.value.empty() == false) { - if (cfgRunByRunWeights) { // run-by-run NUA weights from ccdb, stored in TList to hold PID weights - TList* weightlist = ccdb->getForTimeStamp(cfgAcceptance, timestamp); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject(Form("w%i_ref", run)))); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject(Form("w%i_ch", run)))); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject(Form("w%i_pi", run)))); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject(Form("w%i_ka", run)))); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject(Form("w%i_pr", run)))); - } else { // run-averaged weights, stored in TList to hold PID weights - TList* weightlist = ccdb->getForTimeStamp(cfgAcceptance, timestamp); - weightlist->ls(); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject("weights_ref"))); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject("weights_ch"))); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject("weights_pi"))); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject("weights_ka"))); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject("weights_pr"))); - } - if (!cfg.mAcceptance.empty()) - LOGF(info, "Loaded acceptance weights from %s", cfgAcceptance.value.c_str()); - else - LOGF(warning, "Could not load acceptance weights from %s", cfgAcceptance.value.c_str()); - } - } else { - if (cfgAcceptance.value.empty() == false) { - if (cfgRunByRunWeights) { // run-by-run NUA weights from ccdb, stored in TList - TList* weightlist = ccdb->getForTimeStamp(cfgAcceptance, timestamp); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject(Form("w%i_ch", run)))); - } else { // run-averaged weights, stored in TList - TList* weightlist = ccdb->getForTimeStamp(cfgAcceptance, timestamp); - cfg.mAcceptance.push_back(dynamic_cast(weightlist->FindObject("w_ch"))); - } - if (!cfg.mAcceptance.empty()) - LOGF(info, "Loaded acceptance weights from %s", cfgAcceptance.value.c_str()); - else - LOGF(warning, "Could not load acceptance weights from %s", cfgAcceptance.value.c_str()); - } + if (cfg.correctionsLoaded) + return; + if (!cfgAcceptance.value.empty()) { + cfg.mAcceptance = ccdb->getForTimeStamp(cfgAcceptance, timestamp); + if (cfg.mAcceptance) + LOGF(info, "Loaded acceptance weights from %s", cfgAcceptance.value.c_str()); + else + LOGF(warning, "Could not load acceptance weights from %s", cfgAcceptance.value.c_str()); } - if (cfgEfficiency.value.empty() == false) { + + if (!cfgEfficiency.value.empty()) { cfg.mEfficiency = ccdb->getForTimeStamp(cfgEfficiency, timestamp); if (cfg.mEfficiency == nullptr) { LOGF(fatal, "Could not load efficiency histogram from %s", cfgEfficiency.value.c_str()); @@ -433,14 +381,15 @@ struct GenericFramework { template double getAcceptance(TTrack track, const double& vtxz, int index) - { //-1 ref, 0 ch, 1 pi, 2 ka, 3 pr + { // 0 ref, 1 ch, 2 pi, 3 ka, 4 pr double wacc = 1; - index += 1; - if (!cfg.mAcceptance.empty()) { + if (cfg.mAcceptance) { if (cfgUsePID) { - wacc = cfg.mAcceptance[index]->GetNUA(track.phi(), track.eta(), vtxz); + if(cfgRunByRunWeights) wacc = cfg.mAcceptance->getPIDGFWWeightsByRun(lastRun,index)->GetNUA(track.phi(), track.eta(), vtxz); + else wacc = cfg.mAcceptance->getPIDGFWWeightsByName("weight",index)->GetNUA(track.phi(), track.eta(), vtxz); } else { - wacc = cfg.mAcceptance[0]->GetNUA(track.phi(), track.eta(), vtxz); + if(cfgRunByRunWeights) wacc = cfg.mAcceptance->getGFWWeightsByRun(lastRun)->GetNUA(track.phi(), track.eta(), vtxz); + else wacc = cfg.mAcceptance->getGFWWeightsByName("weight")->GetNUA(track.phi(), track.eta(), vtxz); } } return wacc; @@ -562,15 +511,19 @@ struct GenericFramework { if (vtxz > vtxZup || vtxz < vtxZlow) return 0; - if (multNTracksPV < fMultPVCutLow->Eval(centrality)) - return 0; - if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) - return 0; - if (multTrk < fMultCutLow->Eval(centrality)) - return 0; - if (multTrk > fMultCutHigh->Eval(centrality)) - return 0; - registry.fill(HIST("eventQA/eventSel"), 9.5); + + if(cfgMultCut){ + if (multNTracksPV < fMultPVCutLow->Eval(centrality)) + return 0; + if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) + return 0; + if (multTrk < fMultCutLow->Eval(centrality)) + return 0; + if (multTrk > fMultCutHigh->Eval(centrality)) + return 0; + registry.fill(HIST("eventQA/eventSel"), 9.5); + } + /* 22s if (multNTracksPV < fMultPVCutLow->Eval(centrality)) return 0; @@ -614,62 +567,40 @@ struct GenericFramework { }; template - void fillWeights(const TTrack track, const double vtxz, const double multcent, int pid_index) + void fillWeights(const TTrack track, const double vtxz, const double multcent, const int& pid_index, const int& run) { if (cfgUsePID) { - std::vector species = {"ref", "ch", "pi", "ka", "pr"}; double ptpidmins[] = {ptpoilow, ptpoilow, 0.3, 0.5}; // min pt for ch, pi, ka, pr double ptpidmaxs[] = {ptpoiup, ptpoiup, 6.0, 6.0}; // max pt for ch, pi, ka, pr bool withinPtPOI = (ptpidmins[pid_index] < track.pt()) && (track.pt() < ptpidmaxs[pid_index]); // within POI pT range bool withinPtRef = (ptreflow < track.pt()) && (track.pt() < ptrefup); // within RF pT range if (cfgRunByRunWeights) { if (withinPtRef && !pid_index) - dynamic_cast(fWeightList->FindObject(Form("w%i_%s", lastRun, species[pid_index].c_str())))->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow + fWeightList->getPIDGFWWeightsByRun(run,pid_index)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow if (withinPtPOI) - dynamic_cast(fWeightList->FindObject(Form("w%i_%s", lastRun, species[pid_index + 1].c_str())))->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights + fWeightList->getPIDGFWWeightsByRun(run,pid_index+1)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights } else { if (withinPtRef && !pid_index) - dynamic_cast(fWeightList->FindObject(Form("w_%s", species[pid_index].c_str())))->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow + fWeightList->getPIDGFWWeightsByName("weight",pid_index)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow if (withinPtPOI) - dynamic_cast(fWeightList->FindObject(Form("w_%s", species[pid_index + 1].c_str())))->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights + fWeightList->getPIDGFWWeightsByName("weight",pid_index+1)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights } } else { if (cfgRunByRunWeights) - dynamic_cast(fWeightList->FindObject(Form("w%i_ch", lastRun)))->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); + fWeightList->getGFWWeightsByRun(lastRun)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); else - dynamic_cast(fWeightList->FindObject("w_ch"))->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); + fWeightList->getGFWWeightsByName("weight")->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); } return; } - void createRunByRunWeights() + void createRunByRunWeights(int run) { if (cfgUsePID) { - std::vector weights; - std::vector species = {"ref", "ch", "pi", "ka", "pr"}; - for (size_t i = 0; i < species.size(); ++i) { - if (dynamic_cast(fWeightList->FindObject(Form("w%i_%s", lastRun, species[i].c_str())))) - continue; - weights.push_back(new GFWWeights(Form("w%i_%s", lastRun, species[i].c_str()))); - if (i == 0) { - auto it = std::find(ptbinning.begin(), ptbinning.end(), ptrefup); - std::vector refpt(ptbinning.begin(), it + 1); - weights[i]->SetPtBins(refpt.size() - 1, &refpt[0]); - } else { - weights[i]->SetPtBins(fPtAxis->GetNbins(), &ptbinning[0]); - } - weights[i]->Init(true, false); - fWeightList->Add(weights[i]); - } + fWeightList->addPIDGFWWeightsByRun(run,fPtAxis->GetNbins(),&ptbinning[0],ptrefup,true,false); } else { - if (dynamic_cast(fWeightList->FindObject(Form("w%i_ch", lastRun)))) - return; - GFWWeights* weight = new GFWWeights(Form("w%i_ch", lastRun)); - weight->SetPtBins(fPtAxis->GetNbins(), &ptbinning[0]); - weight->Init(true, false); - fWeightList->Add(weight); + fWeightList->addGFWWeightsByRun(run,fPtAxis->GetNbins(),&ptbinning[0],true,false); } - return; } @@ -707,7 +638,7 @@ struct GenericFramework { } template - void processCollision(TCollision collision, TTracks tracks, const float& centrality, const int& field) + void processCollision(TCollision collision, TTracks tracks, const float& centrality, const int& field, const int& run) { if (tracks.size() < 1) return; @@ -719,14 +650,14 @@ struct GenericFramework { fFCpt->clearVector(); float lRandom = fRndm->Rndm(); for (const auto& track : tracks) { - processTrack(track, centrality, vtxz, field); + processTrack(track, centrality, vtxz, field, run); } if (!cfgFillWeights) fillOutputContainers
((cfgUseNch) ? tracks.size() : centrality, lRandom); } template - inline void processTrack(TTrack const& track, const float& centrality, const float& vtxz, const int& field) + inline void processTrack(TTrack const& track, const float& centrality, const float& vtxz, const int& field, const int& run) { if constexpr (framework::has_type_v) { if (track.mcParticleId() < 0 || !(track.has_mcParticle())) @@ -755,7 +686,7 @@ struct GenericFramework { } if (cfgFillWeights) { - fillWeights(mcParticle, vtxz, centrality, 0); + fillWeights(mcParticle, vtxz, centrality, 0, run); } else { fillPtSums(track, vtxz); fillGFW(mcParticle, vtxz, pidIndex); @@ -803,7 +734,7 @@ struct GenericFramework { pidIndex = getNsigmaPID(track); } if (cfgFillWeights) { - fillWeights(track, vtxz, centrality, pidIndex); + fillWeights(track, vtxz, centrality, pidIndex, run); } else { fillPtSums(track, vtxz); fillGFW(track, vtxz, pidIndex); @@ -816,7 +747,7 @@ struct GenericFramework { template inline void fillPtSums(TTrack track, const double& vtxz) { - double wacc = (dt == kGen) ? 1. : getAcceptance(track, vtxz, -1); + double wacc = (dt == kGen) ? 1. : getAcceptance(track, vtxz, 0); double weff = (dt == kGen) ? 1. : getEfficiency(track); if (weff < 0) return; @@ -842,8 +773,8 @@ struct GenericFramework { bool withinPtNch = (track.pt() > ptmins[0] && track.pt() < ptmaxs[0]); if (!withinPtPOI && !withinPtRef) return; - double waccRef = (dt == kGen) ? 1. : getAcceptance(track, vtxz, -1); - double waccPOI = (dt == kGen) ? 1. : withinPtPOI ? getAcceptance(track, vtxz, pid_index) + double waccRef = (dt == kGen) ? 1. : getAcceptance(track, vtxz, 0); + double waccPOI = (dt == kGen) ? 1. : withinPtPOI ? getAcceptance(track, vtxz, pid_index+1) : getAcceptance(track, vtxz, 0); // if (withinPtRef && withinPtPOI && pid_index) waccRef = waccPOI; // if particle is both (then it's overlap), override ref with POI @@ -861,7 +792,7 @@ struct GenericFramework { double weff = (dt == kGen) ? 1. : getEfficiency(track); if (weff < 0) return; - double wacc = (dt == kGen) ? 1. : getAcceptance(track, vtxz, -1); + double wacc = (dt == kGen) ? 1. : getAcceptance(track, vtxz, 0); fGFW->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), weff * wacc, 1); } return; @@ -874,8 +805,8 @@ struct GenericFramework { registry.fill(HIST("MCGen/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ_gen"), track.phi(), track.eta(), vtxz); registry.fill(HIST("MCGen/") + HIST(FillTimeName[ft]) + HIST("pt_gen"), track.pt()); } else { - double wacc = getAcceptance(track, vtxz, -1); - registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ"), track.phi(), track.eta(), vtxz, wacc); + double wacc = getAcceptance(track, vtxz, 0); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ"), track.phi(), track.eta(), vtxz, (ft == kAfter)?wacc:1.0); registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_dcaXY_dcaZ"), track.pt(), track.dcaXY(), track.dcaZ()); if (ft == kAfter) { registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_ref"), track.pt()); @@ -908,7 +839,7 @@ struct GenericFramework { if (run != lastRun) { lastRun = run; if (cfgFillWeights && cfgRunByRunWeights) - createRunByRunWeights(); + createRunByRunWeights(run); } registry.fill(HIST("eventQA/eventSel"), 0.5); if (!collision.sel8()) @@ -932,7 +863,7 @@ struct GenericFramework { if (!cfgFillWeights) loadCorrections(bc); auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; - processCollision(collision, tracks, centrality, field); + processCollision(collision, tracks, centrality, field, run); } PROCESS_SWITCH(GenericFramework, processData, "Process analysis for non-derived data", true); @@ -943,7 +874,7 @@ struct GenericFramework { if (run != lastRun) { lastRun = run; if (cfgFillWeights && cfgRunByRunWeights) - createRunByRunWeights(); + createRunByRunWeights(run); } if (!collision.sel8()) return; @@ -958,7 +889,7 @@ struct GenericFramework { if (!cfgFillWeights) loadCorrections(bc); auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; - processCollision(collision, tracks, centrality, field); + processCollision(collision, tracks, centrality, field, run); } PROCESS_SWITCH(GenericFramework, processMCReco, "Process analysis for MC reconstructed events", false); @@ -971,19 +902,26 @@ struct GenericFramework { for (const auto& collision : collisions) { centrality = collision.centFT0C(); } - processCollision(mcCollision, particles, centrality, -999); + processCollision(mcCollision, particles, centrality, -999, 0); } PROCESS_SWITCH(GenericFramework, processMCGen, "Process analysis for MC generated events", false); void processRun2(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, GFWTracks const& tracks) { + auto bc = collision.bc_as(); + int run = bc.runNumber(); + if (run != lastRun) { + lastRun = run; + if (cfgFillWeights && cfgRunByRunWeights) + createRunByRunWeights(run); + } if (!collision.sel7()) return; const auto centrality = collision.centRun2V0M(); - auto bc = collision.bc_as(); - loadCorrections(bc); + if(!cfgFillWeights) + loadCorrections(bc); auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; - processCollision(collision, tracks, centrality, field); + processCollision(collision, tracks, centrality, field, run); } PROCESS_SWITCH(GenericFramework, processRun2, "Process analysis for Run 2 converted data", false); }; From 5fb73961c921a8efa1c36f1a677f04803df77f0d Mon Sep 17 00:00:00 2001 From: Emil Gorm Nielsen Date: Thu, 30 Jan 2025 14:49:29 +0100 Subject: [PATCH 2/6] O2 Linter --- PWGCF/Flow/Tasks/FlowGFWPbPb.cxx | 12 +- PWGCF/Flow/Tasks/flowAnalysisGF.cxx | 8 +- PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx | 32 +++--- PWGCF/Flow/Tasks/flowRunbyRun.cxx | 4 +- PWGCF/Flow/Tasks/flowTask.cxx | 20 ++-- PWGCF/GenericFramework/Core/GFWWeights.cxx | 105 +++++++++--------- PWGCF/GenericFramework/Core/GFWWeights.h | 66 ++++++----- .../GenericFramework/Core/GFWWeightsList.cxx | 60 +++++----- PWGCF/GenericFramework/Core/GFWWeightsList.h | 11 +- .../Tasks/flowGenericFramework.cxx | 50 +++++---- PWGDQ/Tasks/dqCorrelation.cxx | 2 +- PWGDQ/Tasks/dqFlow.cxx | 6 +- 12 files changed, 200 insertions(+), 176 deletions(-) diff --git a/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx b/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx index 39cddafbd2a..12fbf2f7538 100644 --- a/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx +++ b/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx @@ -249,8 +249,8 @@ struct FlowGFWPbPb { fPtAxis = new TAxis(nPtBins, PtBins); if (cfgOutputNUAWeights) { - fWeights->SetPtBins(nPtBins, PtBins); - fWeights->Init(true, false); + fWeights->setPtBins(nPtBins, PtBins); + fWeights->init(true, false); } // add in FlowContainer to Get boostrap sample automatically @@ -384,7 +384,7 @@ struct FlowGFWPbPb { return false; weight_nue = 1. / eff; if (mAcceptance) - weight_nua = mAcceptance->GetNUA(phi, eta, vtxz); + weight_nua = mAcceptance->getNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -510,8 +510,8 @@ struct FlowGFWPbPb { Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::dcaXY) < cfgCutDCAxy); - using Colls = soa::Filtered>; // collisions filter - using aodTracks = soa::Filtered>; // tracks filter + using Colls = soa::Filtered>; // collisions filter + using aodTracks = soa::Filtered>; // tracks filter void process(Colls::iterator const& collision, aod::BCsWithTimestamps const&, aodTracks const& tracks) { @@ -590,7 +590,7 @@ struct FlowGFWPbPb { if (cfgUseAdditionalTrackCut && !trackSelected(track, Magnetfield)) continue; if (cfgOutputNUAWeights) - fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), centrality, 0); + fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), centrality, 0); if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz)) continue; diff --git a/PWGCF/Flow/Tasks/flowAnalysisGF.cxx b/PWGCF/Flow/Tasks/flowAnalysisGF.cxx index e6e60d89b8c..08e223befb6 100644 --- a/PWGCF/Flow/Tasks/flowAnalysisGF.cxx +++ b/PWGCF/Flow/Tasks/flowAnalysisGF.cxx @@ -214,8 +214,8 @@ struct flowAnalysisGF { fPtAxis = new TAxis(ptbins, &ptbinning[0]); if (cfgFillWeights) { - fWeights->SetPtBins(ptbins, &ptbinning[0]); - fWeights->Init(true, false); + fWeights->setPtBins(ptbins, &ptbinning[0]); + fWeights->init(true, false); } if (doprocessMCGen) { @@ -388,7 +388,7 @@ struct flowAnalysisGF { return false; weight_nue = 1. / eff; if (cfg.mAcceptance) - weight_nua = cfg.mAcceptance->GetNUA(phi, eta, vtxz); + weight_nua = cfg.mAcceptance->getNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -582,7 +582,7 @@ struct flowAnalysisGF { return false; if (cfgFillWeights) - fWeights->Fill(particle.phi(), particle.eta(), vtxz, particle.pt(), centrality, 0); + fWeights->fill(particle.phi(), particle.eta(), vtxz, particle.pt(), centrality, 0); if (!setCurrentParticleWeights(weff, wacc, particle.phi(), particle.eta(), particle.pt(), vtxz)) return false; diff --git a/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx b/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx index 7d62084098a..a5f0bdc0fbb 100644 --- a/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx +++ b/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx @@ -376,16 +376,16 @@ struct FlowGFWOmegaXi { // fWeight output if (cfgOutputNUAWeights) { - fWeightsREF->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsREF->Init(true, false); - fWeightsK0s->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsK0s->Init(true, false); - fWeightsLambda->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsLambda->Init(true, false); - fWeightsXi->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsXi->Init(true, false); - fWeightsOmega->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsOmega->Init(true, false); + fWeightsREF->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsREF->init(true, false); + fWeightsK0s->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsK0s->init(true, false); + fWeightsLambda->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsLambda->init(true, false); + fWeightsXi->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsXi->init(true, false); + fWeightsOmega->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsOmega->init(true, false); } } @@ -565,7 +565,7 @@ struct FlowGFWOmegaXi { return false; weight_nue = 1. / eff; if (mAcceptance.size() == 5) - weight_nua = mAcceptance[ispecies]->GetNUA(track.phi(), track.eta(), vtxz); + weight_nua = mAcceptance[ispecies]->getNUA(track.phi(), track.eta(), vtxz); else weight_nua = 1; return true; @@ -681,7 +681,7 @@ struct FlowGFWOmegaXi { fGFW->Fill(track.eta(), ptbin, track.phi(), wacc * weff, 32); } if (cfgOutputNUAWeights) - fWeightsREF->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeightsREF->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } // fill GFW of V0 flow for (const auto& v0 : V0s) { @@ -767,7 +767,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("hEtaPhiVtxzPOIK0s"), v0.phi(), v0.eta(), vtxz, wacc); fGFW->Fill(v0.eta(), fV0PtAxis->FindBin(v0.pt()) - 1 + ((fK0sMass->FindBin(v0.mK0Short()) - 1) * nV0PtBins), v0.phi(), wacc * weff, 8); if (cfgOutputNUAWeights) - fWeightsK0s->Fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); + fWeightsK0s->fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); } if (isLambda) { candNum[1] = candNum[1] + 1; @@ -775,7 +775,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("hEtaPhiVtxzPOILambda"), v0.phi(), v0.eta(), vtxz, wacc); fGFW->Fill(v0.eta(), fV0PtAxis->FindBin(v0.pt()) - 1 + ((fLambdaMass->FindBin(v0.mLambda()) - 1) * nV0PtBins), v0.phi(), wacc * weff, 16); if (cfgOutputNUAWeights) - fWeightsLambda->Fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); + fWeightsLambda->fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); } } // fill GFW of casc flow @@ -861,7 +861,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("InvMassOmega"), casc.pt(), casc.mOmega(), casc.eta(), cent); fGFW->Fill(casc.eta(), fXiPtAxis->FindBin(casc.pt()) - 1 + ((fOmegaMass->FindBin(casc.mOmega()) - 1) * nXiPtBins), casc.phi(), wacc * weff, 4); if (cfgOutputNUAWeights) - fWeightsOmega->Fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); + fWeightsOmega->fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); } if (isXi) { candNum[2] = candNum[2] + 1; @@ -869,7 +869,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("InvMassXi"), casc.pt(), casc.mXi(), casc.eta(), cent); fGFW->Fill(casc.eta(), fXiPtAxis->FindBin(casc.pt()) - 1 + ((fXiMass->FindBin(casc.mXi()) - 1) * nXiPtBins), casc.phi(), wacc * weff, 2); if (cfgOutputNUAWeights) - fWeightsXi->Fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); + fWeightsXi->fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); } } for (int i = 0; i < 4; i++) { diff --git a/PWGCF/Flow/Tasks/flowRunbyRun.cxx b/PWGCF/Flow/Tasks/flowRunbyRun.cxx index 03c596c9d2a..7a92e90494e 100644 --- a/PWGCF/Flow/Tasks/flowRunbyRun.cxx +++ b/PWGCF/Flow/Tasks/flowRunbyRun.cxx @@ -278,7 +278,7 @@ struct FlowRunbyRun { LOGF(fatal, "Could not find the weight for run %d", runNumber); return; } - weight->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); + weight->fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); } } else { GFWWeights* weight = fGFWWeightsList->getGFWWeightsByRun(runNumber); @@ -286,7 +286,7 @@ struct FlowRunbyRun { LOGF(fatal, "Could not find the weight for run %d", runNumber); return; } - weight->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); + weight->fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); } } diff --git a/PWGCF/Flow/Tasks/flowTask.cxx b/PWGCF/Flow/Tasks/flowTask.cxx index 19c0b7418bd..d39f4b802a2 100644 --- a/PWGCF/Flow/Tasks/flowTask.cxx +++ b/PWGCF/Flow/Tasks/flowTask.cxx @@ -254,8 +254,8 @@ struct FlowTask { fPtAxis = new TAxis(nPtBins, ptBins); if (cfgOutputNUAWeights) { - fWeights->SetPtBins(nPtBins, ptBins); - fWeights->Init(true, false); + fWeights->setPtBins(nPtBins, ptBins); + fWeights->init(true, false); } TList* groupNUAWeightlist = new TList(); @@ -271,8 +271,8 @@ struct FlowTask { else groupweight = new GFWWeights(Form("groupweight_last")); - groupweight->SetPtBins(nPtBins, ptBins); - groupweight->Init(true, false); + groupweight->setPtBins(nPtBins, ptBins); + groupweight->init(true, false); groupNUAWeightlist->Add(groupweight); std::shared_ptr sharePtrGroupWeight(groupweight); groupNUAWeightPtr[i] = sharePtrGroupWeight; @@ -566,14 +566,14 @@ struct FlowTask { weight_nue = 1. / eff; if (cfgAcceptanceGroupUse) { if (mGroupAcceptanceList && mGroupAcceptanceList->At(groupNUAIndex)) { - weight_nua = reinterpret_cast(mGroupAcceptanceList->At(groupNUAIndex))->GetNUA(phi, eta, vtxz); + weight_nua = reinterpret_cast(mGroupAcceptanceList->At(groupNUAIndex))->getNUA(phi, eta, vtxz); } else { weight_nua = 1; } return true; } if (mAcceptance) - weight_nua = mAcceptance->GetNUA(phi, eta, vtxz); + weight_nua = mAcceptance->getNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -790,18 +790,18 @@ struct FlowTask { if (cfgOutputNUAWeights) { if (cfgOutputNUAWeightsRefPt) { if (withinPtRef) - fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } else { - fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } if (cfgOutputGroupNUAWeights) { if (cfgOutputNUAWeightsRefPt) { if (withinPtRef) { - groupNUAWeightPtr[groupNUAIndex]->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + groupNUAWeightPtr[groupNUAIndex]->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } else { - groupNUAWeightPtr[groupNUAIndex]->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + groupNUAWeightPtr[groupNUAIndex]->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz, groupNUAIndex)) diff --git a/PWGCF/GenericFramework/Core/GFWWeights.cxx b/PWGCF/GenericFramework/Core/GFWWeights.cxx index e0f5610bd36..cbc5acaa0bb 100644 --- a/PWGCF/GenericFramework/Core/GFWWeights.cxx +++ b/PWGCF/GenericFramework/Core/GFWWeights.cxx @@ -10,7 +10,7 @@ // or submit itself to any jurisdiction. #include "GFWWeights.h" -#include "TMath.h" + GFWWeights::GFWWeights() : TNamed("", ""), fDataFilled(kFALSE), fMCFilled(kFALSE), @@ -44,7 +44,7 @@ GFWWeights::~GFWWeights() if (fbinsPt) delete[] fbinsPt; }; -void GFWWeights::SetPtBins(int Nbins, double* bins) +void GFWWeights::setPtBins(int Nbins, double* bins) { if (fbinsPt) delete[] fbinsPt; @@ -53,7 +53,7 @@ void GFWWeights::SetPtBins(int Nbins, double* bins) for (int i = 0; i <= fNbinsPt; ++i) fbinsPt[i] = bins[i]; }; -void GFWWeights::Init(bool AddData, bool AddMC) +void GFWWeights::init(bool AddData, bool AddMC) { if (!fbinsPt) { // If pT bins not initialized, set to default (-1 to 1e6) to accept everything fNbinsPt = 1; @@ -65,8 +65,8 @@ void GFWWeights::Init(bool AddData, bool AddMC) fW_data = new TObjArray(); fW_data->SetName("GFWWeights_Data"); fW_data->SetOwner(kTRUE); - const char* tnd = GetBinName(0, 0, Form("data_%s", this->GetName())); - fW_data->Add(new TH3D(tnd, ";#varphi;#eta;v_{z}", 60, 0, TMath::TwoPi(), 64, -1.6, 1.6, 40, -10, 10)); + const char* tnd = getBinName(0, 0, Form("data_%s", this->GetName())); + fW_data->Add(new TH3D(tnd, ";#varphi;#eta;v_{z}", 60, 0, TwoPI, 64, -1.6, 1.6, 40, -10, 10)); fDataFilled = kTRUE; } if (AddMC) { @@ -76,8 +76,8 @@ void GFWWeights::Init(bool AddData, bool AddMC) fW_mcgen->SetName("GFWWeights_MCGen"); fW_mcrec->SetOwner(kTRUE); fW_mcgen->SetOwner(kTRUE); - const char* tnr = GetBinName(0, 0, "mcrec"); // all integrated over cent. anyway - const char* tng = GetBinName(0, 0, "mcgen"); // all integrated over cent. anyway + const char* tnr = getBinName(0, 0, "mcrec"); // all integrated over cent. anyway + const char* tng = getBinName(0, 0, "mcgen"); // all integrated over cent. anyway fW_mcrec->Add(new TH3D(tnr, ";#it{p}_{T};#eta;v_{z}", fNbinsPt, 0, 20, 64, -1.6, 1.6, 40, -10, 10)); fW_mcgen->Add(new TH3D(tng, ";#it{p}_{T};#eta;v_{z}", fNbinsPt, 0, 20, 64, -1.6, 1.6, 40, -10, 10)); reinterpret_cast(fW_mcrec->At(fW_mcrec->GetEntries() - 1))->GetXaxis()->Set(fNbinsPt, fbinsPt); @@ -86,7 +86,7 @@ void GFWWeights::Init(bool AddData, bool AddMC) } }; -void GFWWeights::Fill(double phi, double eta, double vz, double pt, double /*cent*/, int htype, double weight) +void GFWWeights::fill(double phi, double eta, double vz, double pt, double /*cent*/, int htype, double weight) { TObjArray* tar = 0; const char* pf = ""; @@ -104,15 +104,15 @@ void GFWWeights::Fill(double phi, double eta, double vz, double pt, double /*cen } if (!tar) return; - TH3D* th3 = reinterpret_cast(tar->FindObject(GetBinName(0, 0, pf))); // pT bin 0, V0M bin 0, since all integrated + TH3D* th3 = reinterpret_cast(tar->FindObject(getBinName(0, 0, pf))); // pT bin 0, V0M bin 0, since all integrated if (!th3) { if (!htype) - tar->Add(new TH3D(GetBinName(0, 0, pf), ";#varphi;#eta;v_{z}", 60, 0, TMath::TwoPi(), 64, -1.6, 1.6, 40, -10, 10)); // 0,0 since all integrated + tar->Add(new TH3D(getBinName(0, 0, pf), ";#varphi;#eta;v_{z}", 60, 0, TwoPI, 64, -1.6, 1.6, 40, -10, 10)); // 0,0 since all integrated th3 = reinterpret_cast(tar->At(tar->GetEntries() - 1)); } th3->Fill(htype ? pt : phi, eta, vz, weight); }; -double GFWWeights::GetWeight(double phi, double eta, double vz, double pt, double /*cent*/, int htype) +double GFWWeights::getWeight(double phi, double eta, double vz, double pt, double /*cent*/, int htype) { TObjArray* tar = 0; const char* pf = ""; @@ -130,7 +130,7 @@ double GFWWeights::GetWeight(double phi, double eta, double vz, double pt, doubl } if (!tar) return 1; - TH3D* th3 = reinterpret_cast(tar->FindObject(GetBinName(0, 0, pf))); + TH3D* th3 = reinterpret_cast(tar->FindObject(getBinName(0, 0, pf))); if (!th3) return 1; //-1; int xind = th3->GetXaxis()->FindBin(htype ? pt : phi); @@ -141,10 +141,10 @@ double GFWWeights::GetWeight(double phi, double eta, double vz, double pt, doubl return 1. / weight; return 1; }; -double GFWWeights::GetNUA(double phi, double eta, double vz) +double GFWWeights::getNUA(double phi, double eta, double vz) { if (!fAccInt) - CreateNUA(); + createNUA(); int xind = fAccInt->GetXaxis()->FindBin(phi); int etaind = fAccInt->GetYaxis()->FindBin(eta); int vzind = fAccInt->GetZaxis()->FindBin(vz); @@ -153,10 +153,10 @@ double GFWWeights::GetNUA(double phi, double eta, double vz) return 1. / weight; return 1; } -double GFWWeights::GetNUE(double pt, double eta, double vz) +double GFWWeights::getNUE(double pt, double eta, double vz) { if (!fEffInt) - CreateNUE(); + createNUE(); int xind = fEffInt->GetXaxis()->FindBin(pt); int etaind = fEffInt->GetYaxis()->FindBin(eta); int vzind = fEffInt->GetZaxis()->FindBin(vz); @@ -165,7 +165,7 @@ double GFWWeights::GetNUE(double pt, double eta, double vz) return 1. / weight; return 1; } -double GFWWeights::FindMax(TH3D* inh, int& ix, int& iy, int& iz) +double GFWWeights::findMax(TH3D* inh, int& ix, int& iy, int& iz) { double maxv = inh->GetBinContent(1, 1, 1); for (int i = 1; i <= inh->GetNbinsX(); i++) @@ -179,10 +179,10 @@ double GFWWeights::FindMax(TH3D* inh, int& ix, int& iy, int& iz) } return maxv; }; -void GFWWeights::MCToEfficiency() +void GFWWeights::mcToEfficiency() { if (fW_mcgen->GetEntries() < 1) { - printf("MC gen. array empty. This is probably because effs. have been calculated and the generated particle histograms have been cleared out!\n"); + LOGF(info, "MC gen. array empty. This is probably because effs. have been calculated and the generated particle histograms have been cleared out!\n"); return; } for (int i = 0; i < fW_mcrec->GetEntries(); i++) { @@ -194,7 +194,7 @@ void GFWWeights::MCToEfficiency() } fW_mcgen->Clear(); }; -void GFWWeights::RebinNUA(int nX, int nY, int nZ) +void GFWWeights::rebinNUA(int nX, int nY, int nZ) { if (fW_data->GetEntries() < 1) return; @@ -204,10 +204,10 @@ void GFWWeights::RebinNUA(int nX, int nY, int nZ) reinterpret_cast(fW_data->At(i))->RebinZ(nZ); } }; -void GFWWeights::CreateNUA(bool IntegrateOverCentAndPt) +void GFWWeights::createNUA(bool IntegrateOverCentAndPt) { if (!IntegrateOverCentAndPt) { - printf("Method is outdated! NUA is integrated over centrality and pT. Quit now, or the behaviour will be bad\n"); + LOGF(info, "Method is outdated! NUA is integrated over centrality and pT. Quit now, or the behaviour will be bad\n"); return; } TH1D* h1; @@ -240,7 +240,7 @@ void GFWWeights::CreateNUA(bool IntegrateOverCentAndPt) return; } }; -TH1D* GFWWeights::GetdNdPhi() +TH1D* GFWWeights::getdNdPhi() { TH3D* temph = reinterpret_cast(fW_data->At(0)->Clone("tempH3")); TH1D* reth = reinterpret_cast(temph->Project3D("x")); @@ -257,10 +257,10 @@ TH1D* GFWWeights::GetdNdPhi() } return reth; } -void GFWWeights::CreateNUE(bool IntegrateOverCentrality) +void GFWWeights::createNUE(bool IntegrateOverCentrality) { if (!IntegrateOverCentrality) { - printf("Method is outdated! NUE is integrated over centrality. Quit now, or the behaviour will be bad\n"); + LOGF(info, "Method is outdated! NUE is integrated over centrality. Quit now, or the behaviour will be bad\n"); return; } TH3D* num = 0; @@ -281,7 +281,7 @@ void GFWWeights::CreateNUE(bool IntegrateOverCentrality) return; } }; -void GFWWeights::ReadAndMerge(TString filelinks, TString listName, bool addData, bool addRec, bool addGen) +void GFWWeights::readAndMerge(TString filelinks, TString listName, bool addData, bool addRec, bool addGen) { FILE* flist = fopen(filelinks.Data(), "r"); char str[150]; @@ -290,7 +290,7 @@ void GFWWeights::ReadAndMerge(TString filelinks, TString listName, bool addData, nFiles++; rewind(flist); if (nFiles == 0) { - printf("No files to read!\n"); + LOGF(info, "No files to read!\n"); return; } if (!fW_data && addData) { @@ -314,31 +314,31 @@ void GFWWeights::ReadAndMerge(TString filelinks, TString listName, bool addData, (void)retVal; tf = new TFile(str, "READ"); if (tf->IsZombie()) { - printf("Could not open file %s!\n", str); + LOGF(warning, "Could not open file %s!\n", str); tf->Close(); continue; } TList* tl = reinterpret_cast(tf->Get(listName.Data())); GFWWeights* tw = reinterpret_cast(tl->FindObject(this->GetName())); if (!tw) { - printf("Could not fetch weights object from %s\n", str); + LOGF(warning, "Could not fetch weights object from %s\n", str); tf->Close(); continue; } if (addData) - AddArray(fW_data, tw->GetDataArray()); + addArray(fW_data, tw->getDataArray()); if (addRec) - AddArray(fW_mcrec, tw->GetRecArray()); + addArray(fW_mcrec, tw->getRecArray()); if (addGen) - AddArray(fW_mcgen, tw->GetGenArray()); + addArray(fW_mcgen, tw->getGenArray()); tf->Close(); delete tw; } }; -void GFWWeights::AddArray(TObjArray* targ, TObjArray* sour) +void GFWWeights::addArray(TObjArray* targ, TObjArray* sour) { if (!sour) { - printf("Source array does not exist!\n"); + LOGF(info, "Source array does not exist!\n"); return; } for (int i = 0; i < sour->GetEntries(); i++) { @@ -353,10 +353,10 @@ void GFWWeights::AddArray(TObjArray* targ, TObjArray* sour) } } }; -void GFWWeights::OverwriteNUA() +void GFWWeights::overwriteNUA() { if (!fAccInt) - CreateNUA(); + createNUA(); TString ts(fW_data->At(0)->GetName()); TH3D* trash = reinterpret_cast(fW_data->RemoveAt(0)); delete trash; @@ -384,29 +384,29 @@ Long64_t GFWWeights::Merge(TCollection* collist) GFWWeights* l_w = 0; TIter all_w(collist); while ((l_w = (reinterpret_cast(all_w())))) { - AddArray(fW_data, l_w->GetDataArray()); - AddArray(fW_mcrec, l_w->GetRecArray()); - AddArray(fW_mcgen, l_w->GetGenArray()); + addArray(fW_data, l_w->getDataArray()); + addArray(fW_mcrec, l_w->getRecArray()); + addArray(fW_mcgen, l_w->getGenArray()); nmerged++; } return nmerged; }; -TH1D* GFWWeights::GetIntegratedEfficiencyHist() +TH1D* GFWWeights::getIntegratedEfficiencyHist() { if (!fW_mcgen) { - printf("MCGen array does not exist!\n"); + LOGF(warning, "MCGen array does not exist!\n"); return 0; } if (!fW_mcrec) { - printf("MCRec array does not exist!\n"); + LOGF(warning, "MCRec array does not exist!\n"); return 0; } if (!fW_mcgen->GetEntries()) { - printf("MCGen array is empty!\n"); + LOGF(warning, "MCGen array is empty!\n"); return 0; } if (!fW_mcrec->GetEntries()) { - printf("MCRec array is empty!\n"); + LOGF(warning, "MCRec array is empty!\n"); return 0; } TH3D* num = reinterpret_cast(fW_mcrec->At(0)->Clone("Numerator")); @@ -426,25 +426,25 @@ TH1D* GFWWeights::GetIntegratedEfficiencyHist() delete den1d; return num1d; } -bool GFWWeights::CalculateIntegratedEff() +bool GFWWeights::calculateIntegratedEff() { if (fIntEff) delete fIntEff; - fIntEff = GetIntegratedEfficiencyHist(); + fIntEff = getIntegratedEfficiencyHist(); if (!fIntEff) { return kFALSE; } fIntEff->SetName("IntegratedEfficiency"); return kTRUE; } -double GFWWeights::GetIntegratedEfficiency(double pt) +double GFWWeights::getIntegratedEfficiency(double pt) { if (!fIntEff) - if (!CalculateIntegratedEff()) + if (!calculateIntegratedEff()) return 0; return fIntEff->GetBinContent(fIntEff->FindBin(pt)); } -TH1D* GFWWeights::GetEfficiency(double etamin, double etamax, double vzmin, double vzmax) +TH1D* GFWWeights::getEfficiency(double etamin, double etamax, double vzmin, double vzmax) { TH3D* num = reinterpret_cast(fW_mcrec->At(0)->Clone("Numerator")); for (int i = 1; i < fW_mcrec->GetEntries(); i++) @@ -470,12 +470,13 @@ TH1D* GFWWeights::GetEfficiency(double etamin, double etamax, double vzmin, doub delete den1d; return num1d; } -void GFWWeights::MergeWeights(GFWWeights* other){ +void GFWWeights::mergeWeights(GFWWeights* other) +{ if (!fW_data) { fW_data = new TObjArray(); fW_data->SetName("Weights_Data"); fW_data->SetOwner(kTRUE); } - AddArray(fW_data, other->GetDataArray()); + addArray(fW_data, other->getDataArray()); return; -} \ No newline at end of file +} diff --git a/PWGCF/GenericFramework/Core/GFWWeights.h b/PWGCF/GenericFramework/Core/GFWWeights.h index deedbf20192..8cb8bfc1bb8 100644 --- a/PWGCF/GenericFramework/Core/GFWWeights.h +++ b/PWGCF/GenericFramework/Core/GFWWeights.h @@ -9,8 +9,16 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file GFWWeights.h +/// \brief Class to store corrections for the Generic Framework +/// \author Emil Gorm Nielsen, NBI, emil.gorm.nielsen@cern.ch + #ifndef PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTS_H_ #define PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTS_H_ + +#include "Framework/Logger.h" +#include "Framework/AnalysisTask.h" + #include "TObjArray.h" #include "TNamed.h" #include "TH3D.h" @@ -20,39 +28,41 @@ #include "TCollection.h" #include "TString.h" +using namespace o2::constants::math; + class GFWWeights : public TNamed { public: GFWWeights(); explicit GFWWeights(const char* name); ~GFWWeights(); - void Init(bool AddData = kTRUE, bool AddM = kTRUE); - void Fill(double phi, double eta, double vz, double pt, double cent, int htype, double weight = 1); // htype: 0 for data, 1 for mc rec, 2 for mc gen - double GetWeight(double phi, double eta, double vz, double pt, double cent, int htype); // htype: 0 for data, 1 for mc rec, 2 for mc gen - double GetNUA(double phi, double eta, double vz); // This just fetches correction from integrated NUA, should speed up - double GetNUE(double pt, double eta, double vz); // fetches weight from fEffInt - bool IsDataFilled() { return fDataFilled; } - bool IsMCFilled() { return fMCFilled; } - double FindMax(TH3D* inh, int& ix, int& iy, int& iz); - void MCToEfficiency(); - TObjArray* GetRecArray() { return fW_mcrec; } - TObjArray* GetGenArray() { return fW_mcgen; } - TObjArray* GetDataArray() { return fW_data; } - void CreateNUA(bool IntegrateOverCentAndPt = kTRUE); - void CreateNUE(bool IntegrateOverCentrality = kTRUE); - TH1D* GetIntegratedEfficiencyHist(); - bool CalculateIntegratedEff(); - double GetIntegratedEfficiency(double pt); - void SetDataFilled(bool newval) { fDataFilled = newval; } - void SetMCFilled(bool newval) { fMCFilled = newval; } - void ReadAndMerge(TString filelinks, TString listName = "OutputList", bool addData = kTRUE, bool addRec = kTRUE, bool addGen = kTRUE); - void SetPtBins(int Nbins, double* bins); + void init(bool AddData = kTRUE, bool AddM = kTRUE); + void fill(double phi, double eta, double vz, double pt, double cent, int htype, double weight = 1); // htype: 0 for data, 1 for mc rec, 2 for mc gen + double getWeight(double phi, double eta, double vz, double pt, double cent, int htype); // htype: 0 for data, 1 for mc rec, 2 for mc gen + double getNUA(double phi, double eta, double vz); // This just fetches correction from integrated NUA, should speed up + double getNUE(double pt, double eta, double vz); // fetches weight from fEffInt + bool isDataFilled() { return fDataFilled; } + bool isMCFilled() { return fMCFilled; } + double findMax(TH3D* inh, int& ix, int& iy, int& iz); + void mcToEfficiency(); + TObjArray* getRecArray() { return fW_mcrec; } + TObjArray* getGenArray() { return fW_mcgen; } + TObjArray* getDataArray() { return fW_data; } + void createNUA(bool IntegrateOverCentAndPt = kTRUE); + void createNUE(bool IntegrateOverCentrality = kTRUE); + TH1D* getIntegratedEfficiencyHist(); + bool calculateIntegratedEff(); + double getIntegratedEfficiency(double pt); + void setDataFilled(bool newval) { fDataFilled = newval; } + void setMCFilled(bool newval) { fMCFilled = newval; } + void readAndMerge(TString filelinks, TString listName = "OutputList", bool addData = kTRUE, bool addRec = kTRUE, bool addGen = kTRUE); + void setPtBins(int Nbins, double* bins); Long64_t Merge(TCollection* collist); - void RebinNUA(int nX = 1, int nY = 2, int nZ = 5); - void OverwriteNUA(); - TH1D* GetdNdPhi(); - TH1D* GetEfficiency(double etamin, double etamax, double vzmin, double vzmax); - void MergeWeights(GFWWeights* other); + void rebinNUA(int nX = 1, int nY = 2, int nZ = 5); + void overwriteNUA(); + TH1D* getdNdPhi(); + TH1D* getEfficiency(double etamin, double etamax, double vzmin, double vzmax); + void mergeWeights(GFWWeights* other); private: bool fDataFilled; @@ -65,8 +75,8 @@ class GFWWeights : public TNamed TH3D* fAccInt; //! int fNbinsPt; //! do not store double* fbinsPt; //! do not store - void AddArray(TObjArray* targ, TObjArray* sour); - const char* GetBinName(double /*ptv*/, double /*v0mv*/, const char* pf = "") + void addArray(TObjArray* targ, TObjArray* sour); + const char* getBinName(double /*ptv*/, double /*v0mv*/, const char* pf = "") { int ptind = 0; // GetPtBin(ptv); int v0mind = 0; // GetV0MBin(v0mv); diff --git a/PWGCF/GenericFramework/Core/GFWWeightsList.cxx b/PWGCF/GenericFramework/Core/GFWWeightsList.cxx index 801fbe68115..d4b1d02fed4 100644 --- a/PWGCF/GenericFramework/Core/GFWWeightsList.cxx +++ b/PWGCF/GenericFramework/Core/GFWWeightsList.cxx @@ -53,15 +53,15 @@ void GFWWeightsList::addGFWWeightsByName(const char* weightName, int nPtBins, do return; } GFWWeights* weight = new GFWWeights(weightName); - weight->SetPtBins(nPtBins, ptBins); - weight->Init(addData, addMC); + weight->setPtBins(nPtBins, ptBins); + weight->init(addData, addMC); list->Add(weight); } GFWWeights* GFWWeightsList::getGFWWeightsByName(const char* weightName) { if (!list) { - printf("Error: weight list is not initialized\n"); + LOGF(error, "weight list is not initialized\n"); return nullptr; } return reinterpret_cast(list->FindObject(weightName)); @@ -76,8 +76,8 @@ void GFWWeightsList::addGFWWeightsByRun(int runNumber, int nPtBins, double* ptBi return; } GFWWeights* weight = new GFWWeights(Form("weight_%d", runNumber)); - weight->SetPtBins(nPtBins, ptBins); - weight->Init(addData, addMC); + weight->setPtBins(nPtBins, ptBins); + weight->init(addData, addMC); list->Add(weight); runNumberMap.insert(std::make_pair(runNumber, weight)); } @@ -85,11 +85,11 @@ void GFWWeightsList::addGFWWeightsByRun(int runNumber, int nPtBins, double* ptBi GFWWeights* GFWWeightsList::getGFWWeightsByRun(int runNumber) { if (!list) { - printf("Error: weight list is not initialized\n"); + LOGF(error, "weight list is not initialized\n"); return nullptr; } if (!runNumberMap.contains(runNumber)) { - printf("Error: weight for run %d is not found\n", runNumber); + LOGF(error, "weight for run %d is not found\n", runNumber); return nullptr; } return runNumberMap.at(runNumber); @@ -105,26 +105,28 @@ void GFWWeightsList::addPIDGFWWeightsByName(const char* weightName, int nPtBins, auto it = std::find(ptbins.begin(), ptbins.end(), ptrefup); std::vector refpt(ptbins.begin(), it + 1); - for(auto & type : species){ - if (reinterpret_cast(list->FindObject((static_cast(weightName)+type).c_str()))) { + for (auto& type : species) { + if (reinterpret_cast(list->FindObject((static_cast(weightName) + type).c_str()))) { continue; } - GFWWeights* weight = new GFWWeights(Form("%s",(static_cast(weightName)+type).c_str())); - if(!type.compare("_ref")) weight->SetPtBins(refpt.size() - 1, &(refpt[0])); - else weight->SetPtBins(nPtBins, ptBins); - weight->Init(addData, addMC); + GFWWeights* weight = new GFWWeights(Form("%s", (static_cast(weightName) + type).c_str())); + if (!type.compare("_ref")) + weight->setPtBins(refpt.size() - 1, &(refpt[0])); + else + weight->setPtBins(nPtBins, ptBins); + weight->init(addData, addMC); list->Add(weight); } } GFWWeights* GFWWeightsList::getPIDGFWWeightsByName(const char* weightName, int pidIndex) { - if(static_cast(pidIndex) >= species.size()) + if (static_cast(pidIndex) >= species.size()) return nullptr; if (!list) { - printf("Error: weight list is not initialized\n"); + LOGF(error, "weight list is not initialized\n"); return nullptr; } - return reinterpret_cast(list->FindObject((static_cast(weightName)+species[pidIndex]).c_str())); + return reinterpret_cast(list->FindObject((static_cast(weightName) + species[pidIndex]).c_str())); } void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, double ptrefup, bool addData, bool addMC) { @@ -132,21 +134,24 @@ void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* p init("weightList"); } - if (runNumberPIDMap.contains(runNumber)) return; + if (runNumberPIDMap.contains(runNumber)) + return; std::vector ptbins(ptBins, ptBins + nPtBins + 1); auto it = std::find(ptbins.begin(), ptbins.end(), ptrefup); std::vector refpt(ptbins.begin(), it + 1); std::vector weights; - for(auto & type : species){ + for (auto& type : species) { GFWWeights* weight = new GFWWeights(Form("weight_%d%s", runNumber, type.c_str())); - if(!type.compare("_ref")) weight->SetPtBins(refpt.size() - 1, &(refpt[0])); - else weight->SetPtBins(nPtBins, ptBins); - weight->Init(addData, addMC); + if (!type.compare("_ref")) + weight->setPtBins(refpt.size() - 1, &(refpt[0])); + else + weight->setPtBins(nPtBins, ptBins); + weight->init(addData, addMC); list->Add(weight); weights.push_back(weight); } - printf("Adding weights for run %d\n",runNumber); + LOGF(info, "Adding weights for run %d\n", runNumber); runNumberPIDMap.insert(std::make_pair(runNumber, weights)); return; } @@ -154,18 +159,17 @@ void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* p GFWWeights* GFWWeightsList::getPIDGFWWeightsByRun(int runNumber, int pidIndex) { if (!list) { - printf("Error: weight list is not initialized\n"); + LOGF(error, "weight list is not initialized\n"); return nullptr; } if (!runNumberPIDMap.contains(runNumber)) { - printf("Error: PID weights for run %d is not found\n", runNumber); + LOGF(error, "PID weights for run %d is not found\n", runNumber); return nullptr; } return runNumberPIDMap.at(runNumber)[pidIndex]; } Long64_t GFWWeightsList::Merge(TCollection* collist) { - printf("Merging weight lists!\n"); Long64_t nmerged = 0; if (!list) { list = new TObjArray(); @@ -175,12 +179,12 @@ Long64_t GFWWeightsList::Merge(TCollection* collist) TIter allWeights(collist); GFWWeightsList* lWeight = 0; while ((lWeight = (reinterpret_cast(allWeights())))) { - AddArray(list, lWeight->getList()); + addArray(list, lWeight->getList()); nmerged++; } return nmerged; } -void GFWWeightsList::AddArray(TObjArray* target, TObjArray* source) +void GFWWeightsList::addArray(TObjArray* target, TObjArray* source) { if (!source) { return; @@ -192,7 +196,7 @@ void GFWWeightsList::AddArray(TObjArray* target, TObjArray* source) targw = reinterpret_cast(sourw->Clone(sourw->GetName())); target->Add(targw); } else { - targw->MergeWeights(sourw); + targw->mergeWeights(sourw); } } }; diff --git a/PWGCF/GenericFramework/Core/GFWWeightsList.h b/PWGCF/GenericFramework/Core/GFWWeightsList.h index f9cc4de0aa9..8de876133d6 100644 --- a/PWGCF/GenericFramework/Core/GFWWeightsList.h +++ b/PWGCF/GenericFramework/Core/GFWWeightsList.h @@ -38,16 +38,21 @@ class GFWWeightsList : public TNamed GFWWeights* getPIDGFWWeightsByName(const char* weightName, int pidIndex); void addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, double ptrefup, bool addData = kTRUE, bool addMC = kTRUE); GFWWeights* getPIDGFWWeightsByRun(int runNumber, int pidIndex); - void PrintRuns() { for(auto &el : runNumberPIDMap) printf("%i\n",el.first); } + void printRuns() + { + for (auto& el : runNumberPIDMap) + printf("%i\n", el.first); + } TObjArray* getList() const { return list; } Long64_t Merge(TCollection* collist); + private: TObjArray* list; std::vector species = {"_ref", "_ch", "_pi", "_ka", "_pr"}; //! std::map runNumberMap; - std::map> runNumberPIDMap; - void AddArray(TObjArray* target, TObjArray* source); + std::map> runNumberPIDMap; + void addArray(TObjArray* target, TObjArray* source); ClassDef(GFWWeightsList, 1); }; diff --git a/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx b/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx index cf0ac0cbd30..632dff15c85 100644 --- a/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx +++ b/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx @@ -80,7 +80,7 @@ GFWCorrConfigs configs; using namespace o2::analysis::genericframework; -struct GenericFramework { +struct FlowGenericFramework { O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 10, "Number of subsamples") O2_DEFINE_CONFIGURABLE(cfgMpar, int, 8, "Highest order of pt-pt correlations") @@ -385,11 +385,15 @@ struct GenericFramework { double wacc = 1; if (cfg.mAcceptance) { if (cfgUsePID) { - if(cfgRunByRunWeights) wacc = cfg.mAcceptance->getPIDGFWWeightsByRun(lastRun,index)->GetNUA(track.phi(), track.eta(), vtxz); - else wacc = cfg.mAcceptance->getPIDGFWWeightsByName("weight",index)->GetNUA(track.phi(), track.eta(), vtxz); + if (cfgRunByRunWeights) + wacc = cfg.mAcceptance->getPIDGFWWeightsByRun(lastRun, index)->getNUA(track.phi(), track.eta(), vtxz); + else + wacc = cfg.mAcceptance->getPIDGFWWeightsByName("weight", index)->getNUA(track.phi(), track.eta(), vtxz); } else { - if(cfgRunByRunWeights) wacc = cfg.mAcceptance->getGFWWeightsByRun(lastRun)->GetNUA(track.phi(), track.eta(), vtxz); - else wacc = cfg.mAcceptance->getGFWWeightsByName("weight")->GetNUA(track.phi(), track.eta(), vtxz); + if (cfgRunByRunWeights) + wacc = cfg.mAcceptance->getGFWWeightsByRun(lastRun)->getNUA(track.phi(), track.eta(), vtxz); + else + wacc = cfg.mAcceptance->getGFWWeightsByName("weight")->getNUA(track.phi(), track.eta(), vtxz); } } return wacc; @@ -512,7 +516,7 @@ struct GenericFramework { if (vtxz > vtxZup || vtxz < vtxZlow) return 0; - if(cfgMultCut){ + if (cfgMultCut) { if (multNTracksPV < fMultPVCutLow->Eval(centrality)) return 0; if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) @@ -576,20 +580,20 @@ struct GenericFramework { bool withinPtRef = (ptreflow < track.pt()) && (track.pt() < ptrefup); // within RF pT range if (cfgRunByRunWeights) { if (withinPtRef && !pid_index) - fWeightList->getPIDGFWWeightsByRun(run,pid_index)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow + fWeightList->getPIDGFWWeightsByRun(run, pid_index)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow if (withinPtPOI) - fWeightList->getPIDGFWWeightsByRun(run,pid_index+1)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights + fWeightList->getPIDGFWWeightsByRun(run, pid_index + 1)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights } else { if (withinPtRef && !pid_index) - fWeightList->getPIDGFWWeightsByName("weight",pid_index)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow + fWeightList->getPIDGFWWeightsByName("weight", pid_index)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow if (withinPtPOI) - fWeightList->getPIDGFWWeightsByName("weight",pid_index+1)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights + fWeightList->getPIDGFWWeightsByName("weight", pid_index + 1)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights } } else { if (cfgRunByRunWeights) - fWeightList->getGFWWeightsByRun(lastRun)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); + fWeightList->getGFWWeightsByRun(lastRun)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); else - fWeightList->getGFWWeightsByName("weight")->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); + fWeightList->getGFWWeightsByName("weight")->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); } return; } @@ -597,9 +601,9 @@ struct GenericFramework { void createRunByRunWeights(int run) { if (cfgUsePID) { - fWeightList->addPIDGFWWeightsByRun(run,fPtAxis->GetNbins(),&ptbinning[0],ptrefup,true,false); + fWeightList->addPIDGFWWeightsByRun(run, fPtAxis->GetNbins(), &ptbinning[0], ptrefup, true, false); } else { - fWeightList->addGFWWeightsByRun(run,fPtAxis->GetNbins(),&ptbinning[0],true,false); + fWeightList->addGFWWeightsByRun(run, fPtAxis->GetNbins(), &ptbinning[0], true, false); } return; } @@ -774,7 +778,7 @@ struct GenericFramework { if (!withinPtPOI && !withinPtRef) return; double waccRef = (dt == kGen) ? 1. : getAcceptance(track, vtxz, 0); - double waccPOI = (dt == kGen) ? 1. : withinPtPOI ? getAcceptance(track, vtxz, pid_index+1) + double waccPOI = (dt == kGen) ? 1. : withinPtPOI ? getAcceptance(track, vtxz, pid_index + 1) : getAcceptance(track, vtxz, 0); // if (withinPtRef && withinPtPOI && pid_index) waccRef = waccPOI; // if particle is both (then it's overlap), override ref with POI @@ -806,7 +810,7 @@ struct GenericFramework { registry.fill(HIST("MCGen/") + HIST(FillTimeName[ft]) + HIST("pt_gen"), track.pt()); } else { double wacc = getAcceptance(track, vtxz, 0); - registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ"), track.phi(), track.eta(), vtxz, (ft == kAfter)?wacc:1.0); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ"), track.phi(), track.eta(), vtxz, (ft == kAfter) ? wacc : 1.0); registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_dcaXY_dcaZ"), track.pt(), track.dcaXY(), track.dcaZ()); if (ft == kAfter) { registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_ref"), track.pt()); @@ -865,7 +869,7 @@ struct GenericFramework { auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; processCollision(collision, tracks, centrality, field, run); } - PROCESS_SWITCH(GenericFramework, processData, "Process analysis for non-derived data", true); + PROCESS_SWITCH(FlowGenericFramework, processData, "Process analysis for non-derived data", true); void processMCReco(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, soa::Filtered> const& tracks, aod::McParticles const&) { @@ -891,7 +895,7 @@ struct GenericFramework { auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; processCollision(collision, tracks, centrality, field, run); } - PROCESS_SWITCH(GenericFramework, processMCReco, "Process analysis for MC reconstructed events", false); + PROCESS_SWITCH(FlowGenericFramework, processMCReco, "Process analysis for MC reconstructed events", false); Filter mcCollFilter = nabs(aod::mccollision::posZ) < cfgVtxZ; void processMCGen(soa::Filtered::iterator const& mcCollision, soa::SmallGroups> const& collisions, aod::McParticles const& particles) @@ -904,7 +908,7 @@ struct GenericFramework { } processCollision(mcCollision, particles, centrality, -999, 0); } - PROCESS_SWITCH(GenericFramework, processMCGen, "Process analysis for MC generated events", false); + PROCESS_SWITCH(FlowGenericFramework, processMCGen, "Process analysis for MC generated events", false); void processRun2(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, GFWTracks const& tracks) { @@ -918,17 +922,17 @@ struct GenericFramework { if (!collision.sel7()) return; const auto centrality = collision.centRun2V0M(); - if(!cfgFillWeights) - loadCorrections(bc); + if (!cfgFillWeights) + loadCorrections(bc); auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; processCollision(collision, tracks, centrality, field, run); } - PROCESS_SWITCH(GenericFramework, processRun2, "Process analysis for Run 2 converted data", false); + PROCESS_SWITCH(FlowGenericFramework, processRun2, "Process analysis for Run 2 converted data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), }; } diff --git a/PWGDQ/Tasks/dqCorrelation.cxx b/PWGDQ/Tasks/dqCorrelation.cxx index d2fa3a0dd4b..950e82364cb 100644 --- a/PWGDQ/Tasks/dqCorrelation.cxx +++ b/PWGDQ/Tasks/dqCorrelation.cxx @@ -303,7 +303,7 @@ struct DqCumulantFlow { } weff = 1. / weff; if (cfg.mAcceptance) { - wacc = cfg.mAcceptance->GetNUA(track.phi(), track.eta(), event.posZ()); + wacc = cfg.mAcceptance->getNUA(track.phi(), track.eta(), event.posZ()); } else { wacc = 1.0; } diff --git a/PWGDQ/Tasks/dqFlow.cxx b/PWGDQ/Tasks/dqFlow.cxx index b5e855d3d13..d9210685a2e 100644 --- a/PWGDQ/Tasks/dqFlow.cxx +++ b/PWGDQ/Tasks/dqFlow.cxx @@ -189,7 +189,7 @@ struct DQEventQvector { fPtAxis = new TAxis(ptbins, &ptbinning[0]); if (fConfigFillWeights) { // fWeights->SetPtBins(ptbins, &ptbinning[0]); // in the default case, it will accept everything - fWeights->Init(true, false); // true for data, false for MC + fWeights->init(true, false); // true for data, false for MC } // Reference flow @@ -383,7 +383,7 @@ struct DQEventQvector { // Fill weights for Q-vector correction: this should be enabled for a first run to get weights if (fConfigFillWeights) { - fWeights->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), centrality, 0); + fWeights->fill(track.phi(), track.eta(), collision.posZ(), track.pt(), centrality, 0); } if (cfg.mEfficiency) { @@ -396,7 +396,7 @@ struct DQEventQvector { } weff = 1. / weff; if (cfg.mAcceptance) { - wacc = cfg.mAcceptance->GetNUA(track.phi(), track.eta(), collision.posZ()); + wacc = cfg.mAcceptance->getNUA(track.phi(), track.eta(), collision.posZ()); } else { wacc = 1.0; } From 154eb1970920f466969cf1106331cbb4d3271a1d Mon Sep 17 00:00:00 2001 From: Emil Gorm Nielsen Date: Thu, 30 Jan 2025 14:54:20 +0100 Subject: [PATCH 3/6] Revert "O2 Linter" This reverts commit 5fb73961c921a8efa1c36f1a677f04803df77f0d. --- PWGCF/Flow/Tasks/FlowGFWPbPb.cxx | 12 +- PWGCF/Flow/Tasks/flowAnalysisGF.cxx | 8 +- PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx | 32 +++--- PWGCF/Flow/Tasks/flowRunbyRun.cxx | 4 +- PWGCF/Flow/Tasks/flowTask.cxx | 20 ++-- PWGCF/GenericFramework/Core/GFWWeights.cxx | 105 +++++++++--------- PWGCF/GenericFramework/Core/GFWWeights.h | 66 +++++------ .../GenericFramework/Core/GFWWeightsList.cxx | 60 +++++----- PWGCF/GenericFramework/Core/GFWWeightsList.h | 11 +- .../Tasks/flowGenericFramework.cxx | 50 ++++----- PWGDQ/Tasks/dqCorrelation.cxx | 2 +- PWGDQ/Tasks/dqFlow.cxx | 6 +- 12 files changed, 176 insertions(+), 200 deletions(-) diff --git a/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx b/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx index 12fbf2f7538..39cddafbd2a 100644 --- a/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx +++ b/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx @@ -249,8 +249,8 @@ struct FlowGFWPbPb { fPtAxis = new TAxis(nPtBins, PtBins); if (cfgOutputNUAWeights) { - fWeights->setPtBins(nPtBins, PtBins); - fWeights->init(true, false); + fWeights->SetPtBins(nPtBins, PtBins); + fWeights->Init(true, false); } // add in FlowContainer to Get boostrap sample automatically @@ -384,7 +384,7 @@ struct FlowGFWPbPb { return false; weight_nue = 1. / eff; if (mAcceptance) - weight_nua = mAcceptance->getNUA(phi, eta, vtxz); + weight_nua = mAcceptance->GetNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -510,8 +510,8 @@ struct FlowGFWPbPb { Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::dcaXY) < cfgCutDCAxy); - using Colls = soa::Filtered>; // collisions filter - using aodTracks = soa::Filtered>; // tracks filter + using Colls = soa::Filtered>; // collisions filter + using aodTracks = soa::Filtered>; // tracks filter void process(Colls::iterator const& collision, aod::BCsWithTimestamps const&, aodTracks const& tracks) { @@ -590,7 +590,7 @@ struct FlowGFWPbPb { if (cfgUseAdditionalTrackCut && !trackSelected(track, Magnetfield)) continue; if (cfgOutputNUAWeights) - fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), centrality, 0); + fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), centrality, 0); if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz)) continue; diff --git a/PWGCF/Flow/Tasks/flowAnalysisGF.cxx b/PWGCF/Flow/Tasks/flowAnalysisGF.cxx index 08e223befb6..e6e60d89b8c 100644 --- a/PWGCF/Flow/Tasks/flowAnalysisGF.cxx +++ b/PWGCF/Flow/Tasks/flowAnalysisGF.cxx @@ -214,8 +214,8 @@ struct flowAnalysisGF { fPtAxis = new TAxis(ptbins, &ptbinning[0]); if (cfgFillWeights) { - fWeights->setPtBins(ptbins, &ptbinning[0]); - fWeights->init(true, false); + fWeights->SetPtBins(ptbins, &ptbinning[0]); + fWeights->Init(true, false); } if (doprocessMCGen) { @@ -388,7 +388,7 @@ struct flowAnalysisGF { return false; weight_nue = 1. / eff; if (cfg.mAcceptance) - weight_nua = cfg.mAcceptance->getNUA(phi, eta, vtxz); + weight_nua = cfg.mAcceptance->GetNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -582,7 +582,7 @@ struct flowAnalysisGF { return false; if (cfgFillWeights) - fWeights->fill(particle.phi(), particle.eta(), vtxz, particle.pt(), centrality, 0); + fWeights->Fill(particle.phi(), particle.eta(), vtxz, particle.pt(), centrality, 0); if (!setCurrentParticleWeights(weff, wacc, particle.phi(), particle.eta(), particle.pt(), vtxz)) return false; diff --git a/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx b/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx index a5f0bdc0fbb..7d62084098a 100644 --- a/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx +++ b/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx @@ -376,16 +376,16 @@ struct FlowGFWOmegaXi { // fWeight output if (cfgOutputNUAWeights) { - fWeightsREF->setPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsREF->init(true, false); - fWeightsK0s->setPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsK0s->init(true, false); - fWeightsLambda->setPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsLambda->init(true, false); - fWeightsXi->setPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsXi->init(true, false); - fWeightsOmega->setPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsOmega->init(true, false); + fWeightsREF->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsREF->Init(true, false); + fWeightsK0s->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsK0s->Init(true, false); + fWeightsLambda->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsLambda->Init(true, false); + fWeightsXi->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsXi->Init(true, false); + fWeightsOmega->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsOmega->Init(true, false); } } @@ -565,7 +565,7 @@ struct FlowGFWOmegaXi { return false; weight_nue = 1. / eff; if (mAcceptance.size() == 5) - weight_nua = mAcceptance[ispecies]->getNUA(track.phi(), track.eta(), vtxz); + weight_nua = mAcceptance[ispecies]->GetNUA(track.phi(), track.eta(), vtxz); else weight_nua = 1; return true; @@ -681,7 +681,7 @@ struct FlowGFWOmegaXi { fGFW->Fill(track.eta(), ptbin, track.phi(), wacc * weff, 32); } if (cfgOutputNUAWeights) - fWeightsREF->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeightsREF->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } // fill GFW of V0 flow for (const auto& v0 : V0s) { @@ -767,7 +767,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("hEtaPhiVtxzPOIK0s"), v0.phi(), v0.eta(), vtxz, wacc); fGFW->Fill(v0.eta(), fV0PtAxis->FindBin(v0.pt()) - 1 + ((fK0sMass->FindBin(v0.mK0Short()) - 1) * nV0PtBins), v0.phi(), wacc * weff, 8); if (cfgOutputNUAWeights) - fWeightsK0s->fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); + fWeightsK0s->Fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); } if (isLambda) { candNum[1] = candNum[1] + 1; @@ -775,7 +775,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("hEtaPhiVtxzPOILambda"), v0.phi(), v0.eta(), vtxz, wacc); fGFW->Fill(v0.eta(), fV0PtAxis->FindBin(v0.pt()) - 1 + ((fLambdaMass->FindBin(v0.mLambda()) - 1) * nV0PtBins), v0.phi(), wacc * weff, 16); if (cfgOutputNUAWeights) - fWeightsLambda->fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); + fWeightsLambda->Fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); } } // fill GFW of casc flow @@ -861,7 +861,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("InvMassOmega"), casc.pt(), casc.mOmega(), casc.eta(), cent); fGFW->Fill(casc.eta(), fXiPtAxis->FindBin(casc.pt()) - 1 + ((fOmegaMass->FindBin(casc.mOmega()) - 1) * nXiPtBins), casc.phi(), wacc * weff, 4); if (cfgOutputNUAWeights) - fWeightsOmega->fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); + fWeightsOmega->Fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); } if (isXi) { candNum[2] = candNum[2] + 1; @@ -869,7 +869,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("InvMassXi"), casc.pt(), casc.mXi(), casc.eta(), cent); fGFW->Fill(casc.eta(), fXiPtAxis->FindBin(casc.pt()) - 1 + ((fXiMass->FindBin(casc.mXi()) - 1) * nXiPtBins), casc.phi(), wacc * weff, 2); if (cfgOutputNUAWeights) - fWeightsXi->fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); + fWeightsXi->Fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); } } for (int i = 0; i < 4; i++) { diff --git a/PWGCF/Flow/Tasks/flowRunbyRun.cxx b/PWGCF/Flow/Tasks/flowRunbyRun.cxx index 7a92e90494e..03c596c9d2a 100644 --- a/PWGCF/Flow/Tasks/flowRunbyRun.cxx +++ b/PWGCF/Flow/Tasks/flowRunbyRun.cxx @@ -278,7 +278,7 @@ struct FlowRunbyRun { LOGF(fatal, "Could not find the weight for run %d", runNumber); return; } - weight->fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); + weight->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); } } else { GFWWeights* weight = fGFWWeightsList->getGFWWeightsByRun(runNumber); @@ -286,7 +286,7 @@ struct FlowRunbyRun { LOGF(fatal, "Could not find the weight for run %d", runNumber); return; } - weight->fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); + weight->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); } } diff --git a/PWGCF/Flow/Tasks/flowTask.cxx b/PWGCF/Flow/Tasks/flowTask.cxx index d39f4b802a2..19c0b7418bd 100644 --- a/PWGCF/Flow/Tasks/flowTask.cxx +++ b/PWGCF/Flow/Tasks/flowTask.cxx @@ -254,8 +254,8 @@ struct FlowTask { fPtAxis = new TAxis(nPtBins, ptBins); if (cfgOutputNUAWeights) { - fWeights->setPtBins(nPtBins, ptBins); - fWeights->init(true, false); + fWeights->SetPtBins(nPtBins, ptBins); + fWeights->Init(true, false); } TList* groupNUAWeightlist = new TList(); @@ -271,8 +271,8 @@ struct FlowTask { else groupweight = new GFWWeights(Form("groupweight_last")); - groupweight->setPtBins(nPtBins, ptBins); - groupweight->init(true, false); + groupweight->SetPtBins(nPtBins, ptBins); + groupweight->Init(true, false); groupNUAWeightlist->Add(groupweight); std::shared_ptr sharePtrGroupWeight(groupweight); groupNUAWeightPtr[i] = sharePtrGroupWeight; @@ -566,14 +566,14 @@ struct FlowTask { weight_nue = 1. / eff; if (cfgAcceptanceGroupUse) { if (mGroupAcceptanceList && mGroupAcceptanceList->At(groupNUAIndex)) { - weight_nua = reinterpret_cast(mGroupAcceptanceList->At(groupNUAIndex))->getNUA(phi, eta, vtxz); + weight_nua = reinterpret_cast(mGroupAcceptanceList->At(groupNUAIndex))->GetNUA(phi, eta, vtxz); } else { weight_nua = 1; } return true; } if (mAcceptance) - weight_nua = mAcceptance->getNUA(phi, eta, vtxz); + weight_nua = mAcceptance->GetNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -790,18 +790,18 @@ struct FlowTask { if (cfgOutputNUAWeights) { if (cfgOutputNUAWeightsRefPt) { if (withinPtRef) - fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } else { - fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } if (cfgOutputGroupNUAWeights) { if (cfgOutputNUAWeightsRefPt) { if (withinPtRef) { - groupNUAWeightPtr[groupNUAIndex]->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + groupNUAWeightPtr[groupNUAIndex]->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } else { - groupNUAWeightPtr[groupNUAIndex]->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + groupNUAWeightPtr[groupNUAIndex]->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz, groupNUAIndex)) diff --git a/PWGCF/GenericFramework/Core/GFWWeights.cxx b/PWGCF/GenericFramework/Core/GFWWeights.cxx index cbc5acaa0bb..e0f5610bd36 100644 --- a/PWGCF/GenericFramework/Core/GFWWeights.cxx +++ b/PWGCF/GenericFramework/Core/GFWWeights.cxx @@ -10,7 +10,7 @@ // or submit itself to any jurisdiction. #include "GFWWeights.h" - +#include "TMath.h" GFWWeights::GFWWeights() : TNamed("", ""), fDataFilled(kFALSE), fMCFilled(kFALSE), @@ -44,7 +44,7 @@ GFWWeights::~GFWWeights() if (fbinsPt) delete[] fbinsPt; }; -void GFWWeights::setPtBins(int Nbins, double* bins) +void GFWWeights::SetPtBins(int Nbins, double* bins) { if (fbinsPt) delete[] fbinsPt; @@ -53,7 +53,7 @@ void GFWWeights::setPtBins(int Nbins, double* bins) for (int i = 0; i <= fNbinsPt; ++i) fbinsPt[i] = bins[i]; }; -void GFWWeights::init(bool AddData, bool AddMC) +void GFWWeights::Init(bool AddData, bool AddMC) { if (!fbinsPt) { // If pT bins not initialized, set to default (-1 to 1e6) to accept everything fNbinsPt = 1; @@ -65,8 +65,8 @@ void GFWWeights::init(bool AddData, bool AddMC) fW_data = new TObjArray(); fW_data->SetName("GFWWeights_Data"); fW_data->SetOwner(kTRUE); - const char* tnd = getBinName(0, 0, Form("data_%s", this->GetName())); - fW_data->Add(new TH3D(tnd, ";#varphi;#eta;v_{z}", 60, 0, TwoPI, 64, -1.6, 1.6, 40, -10, 10)); + const char* tnd = GetBinName(0, 0, Form("data_%s", this->GetName())); + fW_data->Add(new TH3D(tnd, ";#varphi;#eta;v_{z}", 60, 0, TMath::TwoPi(), 64, -1.6, 1.6, 40, -10, 10)); fDataFilled = kTRUE; } if (AddMC) { @@ -76,8 +76,8 @@ void GFWWeights::init(bool AddData, bool AddMC) fW_mcgen->SetName("GFWWeights_MCGen"); fW_mcrec->SetOwner(kTRUE); fW_mcgen->SetOwner(kTRUE); - const char* tnr = getBinName(0, 0, "mcrec"); // all integrated over cent. anyway - const char* tng = getBinName(0, 0, "mcgen"); // all integrated over cent. anyway + const char* tnr = GetBinName(0, 0, "mcrec"); // all integrated over cent. anyway + const char* tng = GetBinName(0, 0, "mcgen"); // all integrated over cent. anyway fW_mcrec->Add(new TH3D(tnr, ";#it{p}_{T};#eta;v_{z}", fNbinsPt, 0, 20, 64, -1.6, 1.6, 40, -10, 10)); fW_mcgen->Add(new TH3D(tng, ";#it{p}_{T};#eta;v_{z}", fNbinsPt, 0, 20, 64, -1.6, 1.6, 40, -10, 10)); reinterpret_cast(fW_mcrec->At(fW_mcrec->GetEntries() - 1))->GetXaxis()->Set(fNbinsPt, fbinsPt); @@ -86,7 +86,7 @@ void GFWWeights::init(bool AddData, bool AddMC) } }; -void GFWWeights::fill(double phi, double eta, double vz, double pt, double /*cent*/, int htype, double weight) +void GFWWeights::Fill(double phi, double eta, double vz, double pt, double /*cent*/, int htype, double weight) { TObjArray* tar = 0; const char* pf = ""; @@ -104,15 +104,15 @@ void GFWWeights::fill(double phi, double eta, double vz, double pt, double /*cen } if (!tar) return; - TH3D* th3 = reinterpret_cast(tar->FindObject(getBinName(0, 0, pf))); // pT bin 0, V0M bin 0, since all integrated + TH3D* th3 = reinterpret_cast(tar->FindObject(GetBinName(0, 0, pf))); // pT bin 0, V0M bin 0, since all integrated if (!th3) { if (!htype) - tar->Add(new TH3D(getBinName(0, 0, pf), ";#varphi;#eta;v_{z}", 60, 0, TwoPI, 64, -1.6, 1.6, 40, -10, 10)); // 0,0 since all integrated + tar->Add(new TH3D(GetBinName(0, 0, pf), ";#varphi;#eta;v_{z}", 60, 0, TMath::TwoPi(), 64, -1.6, 1.6, 40, -10, 10)); // 0,0 since all integrated th3 = reinterpret_cast(tar->At(tar->GetEntries() - 1)); } th3->Fill(htype ? pt : phi, eta, vz, weight); }; -double GFWWeights::getWeight(double phi, double eta, double vz, double pt, double /*cent*/, int htype) +double GFWWeights::GetWeight(double phi, double eta, double vz, double pt, double /*cent*/, int htype) { TObjArray* tar = 0; const char* pf = ""; @@ -130,7 +130,7 @@ double GFWWeights::getWeight(double phi, double eta, double vz, double pt, doubl } if (!tar) return 1; - TH3D* th3 = reinterpret_cast(tar->FindObject(getBinName(0, 0, pf))); + TH3D* th3 = reinterpret_cast(tar->FindObject(GetBinName(0, 0, pf))); if (!th3) return 1; //-1; int xind = th3->GetXaxis()->FindBin(htype ? pt : phi); @@ -141,10 +141,10 @@ double GFWWeights::getWeight(double phi, double eta, double vz, double pt, doubl return 1. / weight; return 1; }; -double GFWWeights::getNUA(double phi, double eta, double vz) +double GFWWeights::GetNUA(double phi, double eta, double vz) { if (!fAccInt) - createNUA(); + CreateNUA(); int xind = fAccInt->GetXaxis()->FindBin(phi); int etaind = fAccInt->GetYaxis()->FindBin(eta); int vzind = fAccInt->GetZaxis()->FindBin(vz); @@ -153,10 +153,10 @@ double GFWWeights::getNUA(double phi, double eta, double vz) return 1. / weight; return 1; } -double GFWWeights::getNUE(double pt, double eta, double vz) +double GFWWeights::GetNUE(double pt, double eta, double vz) { if (!fEffInt) - createNUE(); + CreateNUE(); int xind = fEffInt->GetXaxis()->FindBin(pt); int etaind = fEffInt->GetYaxis()->FindBin(eta); int vzind = fEffInt->GetZaxis()->FindBin(vz); @@ -165,7 +165,7 @@ double GFWWeights::getNUE(double pt, double eta, double vz) return 1. / weight; return 1; } -double GFWWeights::findMax(TH3D* inh, int& ix, int& iy, int& iz) +double GFWWeights::FindMax(TH3D* inh, int& ix, int& iy, int& iz) { double maxv = inh->GetBinContent(1, 1, 1); for (int i = 1; i <= inh->GetNbinsX(); i++) @@ -179,10 +179,10 @@ double GFWWeights::findMax(TH3D* inh, int& ix, int& iy, int& iz) } return maxv; }; -void GFWWeights::mcToEfficiency() +void GFWWeights::MCToEfficiency() { if (fW_mcgen->GetEntries() < 1) { - LOGF(info, "MC gen. array empty. This is probably because effs. have been calculated and the generated particle histograms have been cleared out!\n"); + printf("MC gen. array empty. This is probably because effs. have been calculated and the generated particle histograms have been cleared out!\n"); return; } for (int i = 0; i < fW_mcrec->GetEntries(); i++) { @@ -194,7 +194,7 @@ void GFWWeights::mcToEfficiency() } fW_mcgen->Clear(); }; -void GFWWeights::rebinNUA(int nX, int nY, int nZ) +void GFWWeights::RebinNUA(int nX, int nY, int nZ) { if (fW_data->GetEntries() < 1) return; @@ -204,10 +204,10 @@ void GFWWeights::rebinNUA(int nX, int nY, int nZ) reinterpret_cast(fW_data->At(i))->RebinZ(nZ); } }; -void GFWWeights::createNUA(bool IntegrateOverCentAndPt) +void GFWWeights::CreateNUA(bool IntegrateOverCentAndPt) { if (!IntegrateOverCentAndPt) { - LOGF(info, "Method is outdated! NUA is integrated over centrality and pT. Quit now, or the behaviour will be bad\n"); + printf("Method is outdated! NUA is integrated over centrality and pT. Quit now, or the behaviour will be bad\n"); return; } TH1D* h1; @@ -240,7 +240,7 @@ void GFWWeights::createNUA(bool IntegrateOverCentAndPt) return; } }; -TH1D* GFWWeights::getdNdPhi() +TH1D* GFWWeights::GetdNdPhi() { TH3D* temph = reinterpret_cast(fW_data->At(0)->Clone("tempH3")); TH1D* reth = reinterpret_cast(temph->Project3D("x")); @@ -257,10 +257,10 @@ TH1D* GFWWeights::getdNdPhi() } return reth; } -void GFWWeights::createNUE(bool IntegrateOverCentrality) +void GFWWeights::CreateNUE(bool IntegrateOverCentrality) { if (!IntegrateOverCentrality) { - LOGF(info, "Method is outdated! NUE is integrated over centrality. Quit now, or the behaviour will be bad\n"); + printf("Method is outdated! NUE is integrated over centrality. Quit now, or the behaviour will be bad\n"); return; } TH3D* num = 0; @@ -281,7 +281,7 @@ void GFWWeights::createNUE(bool IntegrateOverCentrality) return; } }; -void GFWWeights::readAndMerge(TString filelinks, TString listName, bool addData, bool addRec, bool addGen) +void GFWWeights::ReadAndMerge(TString filelinks, TString listName, bool addData, bool addRec, bool addGen) { FILE* flist = fopen(filelinks.Data(), "r"); char str[150]; @@ -290,7 +290,7 @@ void GFWWeights::readAndMerge(TString filelinks, TString listName, bool addData, nFiles++; rewind(flist); if (nFiles == 0) { - LOGF(info, "No files to read!\n"); + printf("No files to read!\n"); return; } if (!fW_data && addData) { @@ -314,31 +314,31 @@ void GFWWeights::readAndMerge(TString filelinks, TString listName, bool addData, (void)retVal; tf = new TFile(str, "READ"); if (tf->IsZombie()) { - LOGF(warning, "Could not open file %s!\n", str); + printf("Could not open file %s!\n", str); tf->Close(); continue; } TList* tl = reinterpret_cast(tf->Get(listName.Data())); GFWWeights* tw = reinterpret_cast(tl->FindObject(this->GetName())); if (!tw) { - LOGF(warning, "Could not fetch weights object from %s\n", str); + printf("Could not fetch weights object from %s\n", str); tf->Close(); continue; } if (addData) - addArray(fW_data, tw->getDataArray()); + AddArray(fW_data, tw->GetDataArray()); if (addRec) - addArray(fW_mcrec, tw->getRecArray()); + AddArray(fW_mcrec, tw->GetRecArray()); if (addGen) - addArray(fW_mcgen, tw->getGenArray()); + AddArray(fW_mcgen, tw->GetGenArray()); tf->Close(); delete tw; } }; -void GFWWeights::addArray(TObjArray* targ, TObjArray* sour) +void GFWWeights::AddArray(TObjArray* targ, TObjArray* sour) { if (!sour) { - LOGF(info, "Source array does not exist!\n"); + printf("Source array does not exist!\n"); return; } for (int i = 0; i < sour->GetEntries(); i++) { @@ -353,10 +353,10 @@ void GFWWeights::addArray(TObjArray* targ, TObjArray* sour) } } }; -void GFWWeights::overwriteNUA() +void GFWWeights::OverwriteNUA() { if (!fAccInt) - createNUA(); + CreateNUA(); TString ts(fW_data->At(0)->GetName()); TH3D* trash = reinterpret_cast(fW_data->RemoveAt(0)); delete trash; @@ -384,29 +384,29 @@ Long64_t GFWWeights::Merge(TCollection* collist) GFWWeights* l_w = 0; TIter all_w(collist); while ((l_w = (reinterpret_cast(all_w())))) { - addArray(fW_data, l_w->getDataArray()); - addArray(fW_mcrec, l_w->getRecArray()); - addArray(fW_mcgen, l_w->getGenArray()); + AddArray(fW_data, l_w->GetDataArray()); + AddArray(fW_mcrec, l_w->GetRecArray()); + AddArray(fW_mcgen, l_w->GetGenArray()); nmerged++; } return nmerged; }; -TH1D* GFWWeights::getIntegratedEfficiencyHist() +TH1D* GFWWeights::GetIntegratedEfficiencyHist() { if (!fW_mcgen) { - LOGF(warning, "MCGen array does not exist!\n"); + printf("MCGen array does not exist!\n"); return 0; } if (!fW_mcrec) { - LOGF(warning, "MCRec array does not exist!\n"); + printf("MCRec array does not exist!\n"); return 0; } if (!fW_mcgen->GetEntries()) { - LOGF(warning, "MCGen array is empty!\n"); + printf("MCGen array is empty!\n"); return 0; } if (!fW_mcrec->GetEntries()) { - LOGF(warning, "MCRec array is empty!\n"); + printf("MCRec array is empty!\n"); return 0; } TH3D* num = reinterpret_cast(fW_mcrec->At(0)->Clone("Numerator")); @@ -426,25 +426,25 @@ TH1D* GFWWeights::getIntegratedEfficiencyHist() delete den1d; return num1d; } -bool GFWWeights::calculateIntegratedEff() +bool GFWWeights::CalculateIntegratedEff() { if (fIntEff) delete fIntEff; - fIntEff = getIntegratedEfficiencyHist(); + fIntEff = GetIntegratedEfficiencyHist(); if (!fIntEff) { return kFALSE; } fIntEff->SetName("IntegratedEfficiency"); return kTRUE; } -double GFWWeights::getIntegratedEfficiency(double pt) +double GFWWeights::GetIntegratedEfficiency(double pt) { if (!fIntEff) - if (!calculateIntegratedEff()) + if (!CalculateIntegratedEff()) return 0; return fIntEff->GetBinContent(fIntEff->FindBin(pt)); } -TH1D* GFWWeights::getEfficiency(double etamin, double etamax, double vzmin, double vzmax) +TH1D* GFWWeights::GetEfficiency(double etamin, double etamax, double vzmin, double vzmax) { TH3D* num = reinterpret_cast(fW_mcrec->At(0)->Clone("Numerator")); for (int i = 1; i < fW_mcrec->GetEntries(); i++) @@ -470,13 +470,12 @@ TH1D* GFWWeights::getEfficiency(double etamin, double etamax, double vzmin, doub delete den1d; return num1d; } -void GFWWeights::mergeWeights(GFWWeights* other) -{ +void GFWWeights::MergeWeights(GFWWeights* other){ if (!fW_data) { fW_data = new TObjArray(); fW_data->SetName("Weights_Data"); fW_data->SetOwner(kTRUE); } - addArray(fW_data, other->getDataArray()); + AddArray(fW_data, other->GetDataArray()); return; -} +} \ No newline at end of file diff --git a/PWGCF/GenericFramework/Core/GFWWeights.h b/PWGCF/GenericFramework/Core/GFWWeights.h index 8cb8bfc1bb8..deedbf20192 100644 --- a/PWGCF/GenericFramework/Core/GFWWeights.h +++ b/PWGCF/GenericFramework/Core/GFWWeights.h @@ -9,16 +9,8 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file GFWWeights.h -/// \brief Class to store corrections for the Generic Framework -/// \author Emil Gorm Nielsen, NBI, emil.gorm.nielsen@cern.ch - #ifndef PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTS_H_ #define PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTS_H_ - -#include "Framework/Logger.h" -#include "Framework/AnalysisTask.h" - #include "TObjArray.h" #include "TNamed.h" #include "TH3D.h" @@ -28,41 +20,39 @@ #include "TCollection.h" #include "TString.h" -using namespace o2::constants::math; - class GFWWeights : public TNamed { public: GFWWeights(); explicit GFWWeights(const char* name); ~GFWWeights(); - void init(bool AddData = kTRUE, bool AddM = kTRUE); - void fill(double phi, double eta, double vz, double pt, double cent, int htype, double weight = 1); // htype: 0 for data, 1 for mc rec, 2 for mc gen - double getWeight(double phi, double eta, double vz, double pt, double cent, int htype); // htype: 0 for data, 1 for mc rec, 2 for mc gen - double getNUA(double phi, double eta, double vz); // This just fetches correction from integrated NUA, should speed up - double getNUE(double pt, double eta, double vz); // fetches weight from fEffInt - bool isDataFilled() { return fDataFilled; } - bool isMCFilled() { return fMCFilled; } - double findMax(TH3D* inh, int& ix, int& iy, int& iz); - void mcToEfficiency(); - TObjArray* getRecArray() { return fW_mcrec; } - TObjArray* getGenArray() { return fW_mcgen; } - TObjArray* getDataArray() { return fW_data; } - void createNUA(bool IntegrateOverCentAndPt = kTRUE); - void createNUE(bool IntegrateOverCentrality = kTRUE); - TH1D* getIntegratedEfficiencyHist(); - bool calculateIntegratedEff(); - double getIntegratedEfficiency(double pt); - void setDataFilled(bool newval) { fDataFilled = newval; } - void setMCFilled(bool newval) { fMCFilled = newval; } - void readAndMerge(TString filelinks, TString listName = "OutputList", bool addData = kTRUE, bool addRec = kTRUE, bool addGen = kTRUE); - void setPtBins(int Nbins, double* bins); + void Init(bool AddData = kTRUE, bool AddM = kTRUE); + void Fill(double phi, double eta, double vz, double pt, double cent, int htype, double weight = 1); // htype: 0 for data, 1 for mc rec, 2 for mc gen + double GetWeight(double phi, double eta, double vz, double pt, double cent, int htype); // htype: 0 for data, 1 for mc rec, 2 for mc gen + double GetNUA(double phi, double eta, double vz); // This just fetches correction from integrated NUA, should speed up + double GetNUE(double pt, double eta, double vz); // fetches weight from fEffInt + bool IsDataFilled() { return fDataFilled; } + bool IsMCFilled() { return fMCFilled; } + double FindMax(TH3D* inh, int& ix, int& iy, int& iz); + void MCToEfficiency(); + TObjArray* GetRecArray() { return fW_mcrec; } + TObjArray* GetGenArray() { return fW_mcgen; } + TObjArray* GetDataArray() { return fW_data; } + void CreateNUA(bool IntegrateOverCentAndPt = kTRUE); + void CreateNUE(bool IntegrateOverCentrality = kTRUE); + TH1D* GetIntegratedEfficiencyHist(); + bool CalculateIntegratedEff(); + double GetIntegratedEfficiency(double pt); + void SetDataFilled(bool newval) { fDataFilled = newval; } + void SetMCFilled(bool newval) { fMCFilled = newval; } + void ReadAndMerge(TString filelinks, TString listName = "OutputList", bool addData = kTRUE, bool addRec = kTRUE, bool addGen = kTRUE); + void SetPtBins(int Nbins, double* bins); Long64_t Merge(TCollection* collist); - void rebinNUA(int nX = 1, int nY = 2, int nZ = 5); - void overwriteNUA(); - TH1D* getdNdPhi(); - TH1D* getEfficiency(double etamin, double etamax, double vzmin, double vzmax); - void mergeWeights(GFWWeights* other); + void RebinNUA(int nX = 1, int nY = 2, int nZ = 5); + void OverwriteNUA(); + TH1D* GetdNdPhi(); + TH1D* GetEfficiency(double etamin, double etamax, double vzmin, double vzmax); + void MergeWeights(GFWWeights* other); private: bool fDataFilled; @@ -75,8 +65,8 @@ class GFWWeights : public TNamed TH3D* fAccInt; //! int fNbinsPt; //! do not store double* fbinsPt; //! do not store - void addArray(TObjArray* targ, TObjArray* sour); - const char* getBinName(double /*ptv*/, double /*v0mv*/, const char* pf = "") + void AddArray(TObjArray* targ, TObjArray* sour); + const char* GetBinName(double /*ptv*/, double /*v0mv*/, const char* pf = "") { int ptind = 0; // GetPtBin(ptv); int v0mind = 0; // GetV0MBin(v0mv); diff --git a/PWGCF/GenericFramework/Core/GFWWeightsList.cxx b/PWGCF/GenericFramework/Core/GFWWeightsList.cxx index d4b1d02fed4..801fbe68115 100644 --- a/PWGCF/GenericFramework/Core/GFWWeightsList.cxx +++ b/PWGCF/GenericFramework/Core/GFWWeightsList.cxx @@ -53,15 +53,15 @@ void GFWWeightsList::addGFWWeightsByName(const char* weightName, int nPtBins, do return; } GFWWeights* weight = new GFWWeights(weightName); - weight->setPtBins(nPtBins, ptBins); - weight->init(addData, addMC); + weight->SetPtBins(nPtBins, ptBins); + weight->Init(addData, addMC); list->Add(weight); } GFWWeights* GFWWeightsList::getGFWWeightsByName(const char* weightName) { if (!list) { - LOGF(error, "weight list is not initialized\n"); + printf("Error: weight list is not initialized\n"); return nullptr; } return reinterpret_cast(list->FindObject(weightName)); @@ -76,8 +76,8 @@ void GFWWeightsList::addGFWWeightsByRun(int runNumber, int nPtBins, double* ptBi return; } GFWWeights* weight = new GFWWeights(Form("weight_%d", runNumber)); - weight->setPtBins(nPtBins, ptBins); - weight->init(addData, addMC); + weight->SetPtBins(nPtBins, ptBins); + weight->Init(addData, addMC); list->Add(weight); runNumberMap.insert(std::make_pair(runNumber, weight)); } @@ -85,11 +85,11 @@ void GFWWeightsList::addGFWWeightsByRun(int runNumber, int nPtBins, double* ptBi GFWWeights* GFWWeightsList::getGFWWeightsByRun(int runNumber) { if (!list) { - LOGF(error, "weight list is not initialized\n"); + printf("Error: weight list is not initialized\n"); return nullptr; } if (!runNumberMap.contains(runNumber)) { - LOGF(error, "weight for run %d is not found\n", runNumber); + printf("Error: weight for run %d is not found\n", runNumber); return nullptr; } return runNumberMap.at(runNumber); @@ -105,28 +105,26 @@ void GFWWeightsList::addPIDGFWWeightsByName(const char* weightName, int nPtBins, auto it = std::find(ptbins.begin(), ptbins.end(), ptrefup); std::vector refpt(ptbins.begin(), it + 1); - for (auto& type : species) { - if (reinterpret_cast(list->FindObject((static_cast(weightName) + type).c_str()))) { + for(auto & type : species){ + if (reinterpret_cast(list->FindObject((static_cast(weightName)+type).c_str()))) { continue; } - GFWWeights* weight = new GFWWeights(Form("%s", (static_cast(weightName) + type).c_str())); - if (!type.compare("_ref")) - weight->setPtBins(refpt.size() - 1, &(refpt[0])); - else - weight->setPtBins(nPtBins, ptBins); - weight->init(addData, addMC); + GFWWeights* weight = new GFWWeights(Form("%s",(static_cast(weightName)+type).c_str())); + if(!type.compare("_ref")) weight->SetPtBins(refpt.size() - 1, &(refpt[0])); + else weight->SetPtBins(nPtBins, ptBins); + weight->Init(addData, addMC); list->Add(weight); } } GFWWeights* GFWWeightsList::getPIDGFWWeightsByName(const char* weightName, int pidIndex) { - if (static_cast(pidIndex) >= species.size()) + if(static_cast(pidIndex) >= species.size()) return nullptr; if (!list) { - LOGF(error, "weight list is not initialized\n"); + printf("Error: weight list is not initialized\n"); return nullptr; } - return reinterpret_cast(list->FindObject((static_cast(weightName) + species[pidIndex]).c_str())); + return reinterpret_cast(list->FindObject((static_cast(weightName)+species[pidIndex]).c_str())); } void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, double ptrefup, bool addData, bool addMC) { @@ -134,24 +132,21 @@ void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* p init("weightList"); } - if (runNumberPIDMap.contains(runNumber)) - return; + if (runNumberPIDMap.contains(runNumber)) return; std::vector ptbins(ptBins, ptBins + nPtBins + 1); auto it = std::find(ptbins.begin(), ptbins.end(), ptrefup); std::vector refpt(ptbins.begin(), it + 1); std::vector weights; - for (auto& type : species) { + for(auto & type : species){ GFWWeights* weight = new GFWWeights(Form("weight_%d%s", runNumber, type.c_str())); - if (!type.compare("_ref")) - weight->setPtBins(refpt.size() - 1, &(refpt[0])); - else - weight->setPtBins(nPtBins, ptBins); - weight->init(addData, addMC); + if(!type.compare("_ref")) weight->SetPtBins(refpt.size() - 1, &(refpt[0])); + else weight->SetPtBins(nPtBins, ptBins); + weight->Init(addData, addMC); list->Add(weight); weights.push_back(weight); } - LOGF(info, "Adding weights for run %d\n", runNumber); + printf("Adding weights for run %d\n",runNumber); runNumberPIDMap.insert(std::make_pair(runNumber, weights)); return; } @@ -159,17 +154,18 @@ void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* p GFWWeights* GFWWeightsList::getPIDGFWWeightsByRun(int runNumber, int pidIndex) { if (!list) { - LOGF(error, "weight list is not initialized\n"); + printf("Error: weight list is not initialized\n"); return nullptr; } if (!runNumberPIDMap.contains(runNumber)) { - LOGF(error, "PID weights for run %d is not found\n", runNumber); + printf("Error: PID weights for run %d is not found\n", runNumber); return nullptr; } return runNumberPIDMap.at(runNumber)[pidIndex]; } Long64_t GFWWeightsList::Merge(TCollection* collist) { + printf("Merging weight lists!\n"); Long64_t nmerged = 0; if (!list) { list = new TObjArray(); @@ -179,12 +175,12 @@ Long64_t GFWWeightsList::Merge(TCollection* collist) TIter allWeights(collist); GFWWeightsList* lWeight = 0; while ((lWeight = (reinterpret_cast(allWeights())))) { - addArray(list, lWeight->getList()); + AddArray(list, lWeight->getList()); nmerged++; } return nmerged; } -void GFWWeightsList::addArray(TObjArray* target, TObjArray* source) +void GFWWeightsList::AddArray(TObjArray* target, TObjArray* source) { if (!source) { return; @@ -196,7 +192,7 @@ void GFWWeightsList::addArray(TObjArray* target, TObjArray* source) targw = reinterpret_cast(sourw->Clone(sourw->GetName())); target->Add(targw); } else { - targw->mergeWeights(sourw); + targw->MergeWeights(sourw); } } }; diff --git a/PWGCF/GenericFramework/Core/GFWWeightsList.h b/PWGCF/GenericFramework/Core/GFWWeightsList.h index 8de876133d6..f9cc4de0aa9 100644 --- a/PWGCF/GenericFramework/Core/GFWWeightsList.h +++ b/PWGCF/GenericFramework/Core/GFWWeightsList.h @@ -38,21 +38,16 @@ class GFWWeightsList : public TNamed GFWWeights* getPIDGFWWeightsByName(const char* weightName, int pidIndex); void addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, double ptrefup, bool addData = kTRUE, bool addMC = kTRUE); GFWWeights* getPIDGFWWeightsByRun(int runNumber, int pidIndex); - void printRuns() - { - for (auto& el : runNumberPIDMap) - printf("%i\n", el.first); - } + void PrintRuns() { for(auto &el : runNumberPIDMap) printf("%i\n",el.first); } TObjArray* getList() const { return list; } Long64_t Merge(TCollection* collist); - private: TObjArray* list; std::vector species = {"_ref", "_ch", "_pi", "_ka", "_pr"}; //! std::map runNumberMap; - std::map> runNumberPIDMap; - void addArray(TObjArray* target, TObjArray* source); + std::map> runNumberPIDMap; + void AddArray(TObjArray* target, TObjArray* source); ClassDef(GFWWeightsList, 1); }; diff --git a/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx b/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx index 632dff15c85..cf0ac0cbd30 100644 --- a/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx +++ b/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx @@ -80,7 +80,7 @@ GFWCorrConfigs configs; using namespace o2::analysis::genericframework; -struct FlowGenericFramework { +struct GenericFramework { O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 10, "Number of subsamples") O2_DEFINE_CONFIGURABLE(cfgMpar, int, 8, "Highest order of pt-pt correlations") @@ -385,15 +385,11 @@ struct FlowGenericFramework { double wacc = 1; if (cfg.mAcceptance) { if (cfgUsePID) { - if (cfgRunByRunWeights) - wacc = cfg.mAcceptance->getPIDGFWWeightsByRun(lastRun, index)->getNUA(track.phi(), track.eta(), vtxz); - else - wacc = cfg.mAcceptance->getPIDGFWWeightsByName("weight", index)->getNUA(track.phi(), track.eta(), vtxz); + if(cfgRunByRunWeights) wacc = cfg.mAcceptance->getPIDGFWWeightsByRun(lastRun,index)->GetNUA(track.phi(), track.eta(), vtxz); + else wacc = cfg.mAcceptance->getPIDGFWWeightsByName("weight",index)->GetNUA(track.phi(), track.eta(), vtxz); } else { - if (cfgRunByRunWeights) - wacc = cfg.mAcceptance->getGFWWeightsByRun(lastRun)->getNUA(track.phi(), track.eta(), vtxz); - else - wacc = cfg.mAcceptance->getGFWWeightsByName("weight")->getNUA(track.phi(), track.eta(), vtxz); + if(cfgRunByRunWeights) wacc = cfg.mAcceptance->getGFWWeightsByRun(lastRun)->GetNUA(track.phi(), track.eta(), vtxz); + else wacc = cfg.mAcceptance->getGFWWeightsByName("weight")->GetNUA(track.phi(), track.eta(), vtxz); } } return wacc; @@ -516,7 +512,7 @@ struct FlowGenericFramework { if (vtxz > vtxZup || vtxz < vtxZlow) return 0; - if (cfgMultCut) { + if(cfgMultCut){ if (multNTracksPV < fMultPVCutLow->Eval(centrality)) return 0; if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) @@ -580,20 +576,20 @@ struct FlowGenericFramework { bool withinPtRef = (ptreflow < track.pt()) && (track.pt() < ptrefup); // within RF pT range if (cfgRunByRunWeights) { if (withinPtRef && !pid_index) - fWeightList->getPIDGFWWeightsByRun(run, pid_index)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow + fWeightList->getPIDGFWWeightsByRun(run,pid_index)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow if (withinPtPOI) - fWeightList->getPIDGFWWeightsByRun(run, pid_index + 1)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights + fWeightList->getPIDGFWWeightsByRun(run,pid_index+1)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights } else { if (withinPtRef && !pid_index) - fWeightList->getPIDGFWWeightsByName("weight", pid_index)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow + fWeightList->getPIDGFWWeightsByName("weight",pid_index)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow if (withinPtPOI) - fWeightList->getPIDGFWWeightsByName("weight", pid_index + 1)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights + fWeightList->getPIDGFWWeightsByName("weight",pid_index+1)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights } } else { if (cfgRunByRunWeights) - fWeightList->getGFWWeightsByRun(lastRun)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); + fWeightList->getGFWWeightsByRun(lastRun)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); else - fWeightList->getGFWWeightsByName("weight")->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); + fWeightList->getGFWWeightsByName("weight")->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); } return; } @@ -601,9 +597,9 @@ struct FlowGenericFramework { void createRunByRunWeights(int run) { if (cfgUsePID) { - fWeightList->addPIDGFWWeightsByRun(run, fPtAxis->GetNbins(), &ptbinning[0], ptrefup, true, false); + fWeightList->addPIDGFWWeightsByRun(run,fPtAxis->GetNbins(),&ptbinning[0],ptrefup,true,false); } else { - fWeightList->addGFWWeightsByRun(run, fPtAxis->GetNbins(), &ptbinning[0], true, false); + fWeightList->addGFWWeightsByRun(run,fPtAxis->GetNbins(),&ptbinning[0],true,false); } return; } @@ -778,7 +774,7 @@ struct FlowGenericFramework { if (!withinPtPOI && !withinPtRef) return; double waccRef = (dt == kGen) ? 1. : getAcceptance(track, vtxz, 0); - double waccPOI = (dt == kGen) ? 1. : withinPtPOI ? getAcceptance(track, vtxz, pid_index + 1) + double waccPOI = (dt == kGen) ? 1. : withinPtPOI ? getAcceptance(track, vtxz, pid_index+1) : getAcceptance(track, vtxz, 0); // if (withinPtRef && withinPtPOI && pid_index) waccRef = waccPOI; // if particle is both (then it's overlap), override ref with POI @@ -810,7 +806,7 @@ struct FlowGenericFramework { registry.fill(HIST("MCGen/") + HIST(FillTimeName[ft]) + HIST("pt_gen"), track.pt()); } else { double wacc = getAcceptance(track, vtxz, 0); - registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ"), track.phi(), track.eta(), vtxz, (ft == kAfter) ? wacc : 1.0); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ"), track.phi(), track.eta(), vtxz, (ft == kAfter)?wacc:1.0); registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_dcaXY_dcaZ"), track.pt(), track.dcaXY(), track.dcaZ()); if (ft == kAfter) { registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_ref"), track.pt()); @@ -869,7 +865,7 @@ struct FlowGenericFramework { auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; processCollision(collision, tracks, centrality, field, run); } - PROCESS_SWITCH(FlowGenericFramework, processData, "Process analysis for non-derived data", true); + PROCESS_SWITCH(GenericFramework, processData, "Process analysis for non-derived data", true); void processMCReco(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, soa::Filtered> const& tracks, aod::McParticles const&) { @@ -895,7 +891,7 @@ struct FlowGenericFramework { auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; processCollision(collision, tracks, centrality, field, run); } - PROCESS_SWITCH(FlowGenericFramework, processMCReco, "Process analysis for MC reconstructed events", false); + PROCESS_SWITCH(GenericFramework, processMCReco, "Process analysis for MC reconstructed events", false); Filter mcCollFilter = nabs(aod::mccollision::posZ) < cfgVtxZ; void processMCGen(soa::Filtered::iterator const& mcCollision, soa::SmallGroups> const& collisions, aod::McParticles const& particles) @@ -908,7 +904,7 @@ struct FlowGenericFramework { } processCollision(mcCollision, particles, centrality, -999, 0); } - PROCESS_SWITCH(FlowGenericFramework, processMCGen, "Process analysis for MC generated events", false); + PROCESS_SWITCH(GenericFramework, processMCGen, "Process analysis for MC generated events", false); void processRun2(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, GFWTracks const& tracks) { @@ -922,17 +918,17 @@ struct FlowGenericFramework { if (!collision.sel7()) return; const auto centrality = collision.centRun2V0M(); - if (!cfgFillWeights) - loadCorrections(bc); + if(!cfgFillWeights) + loadCorrections(bc); auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; processCollision(collision, tracks, centrality, field, run); } - PROCESS_SWITCH(FlowGenericFramework, processRun2, "Process analysis for Run 2 converted data", false); + PROCESS_SWITCH(GenericFramework, processRun2, "Process analysis for Run 2 converted data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), }; } diff --git a/PWGDQ/Tasks/dqCorrelation.cxx b/PWGDQ/Tasks/dqCorrelation.cxx index 950e82364cb..d2fa3a0dd4b 100644 --- a/PWGDQ/Tasks/dqCorrelation.cxx +++ b/PWGDQ/Tasks/dqCorrelation.cxx @@ -303,7 +303,7 @@ struct DqCumulantFlow { } weff = 1. / weff; if (cfg.mAcceptance) { - wacc = cfg.mAcceptance->getNUA(track.phi(), track.eta(), event.posZ()); + wacc = cfg.mAcceptance->GetNUA(track.phi(), track.eta(), event.posZ()); } else { wacc = 1.0; } diff --git a/PWGDQ/Tasks/dqFlow.cxx b/PWGDQ/Tasks/dqFlow.cxx index d9210685a2e..b5e855d3d13 100644 --- a/PWGDQ/Tasks/dqFlow.cxx +++ b/PWGDQ/Tasks/dqFlow.cxx @@ -189,7 +189,7 @@ struct DQEventQvector { fPtAxis = new TAxis(ptbins, &ptbinning[0]); if (fConfigFillWeights) { // fWeights->SetPtBins(ptbins, &ptbinning[0]); // in the default case, it will accept everything - fWeights->init(true, false); // true for data, false for MC + fWeights->Init(true, false); // true for data, false for MC } // Reference flow @@ -383,7 +383,7 @@ struct DQEventQvector { // Fill weights for Q-vector correction: this should be enabled for a first run to get weights if (fConfigFillWeights) { - fWeights->fill(track.phi(), track.eta(), collision.posZ(), track.pt(), centrality, 0); + fWeights->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), centrality, 0); } if (cfg.mEfficiency) { @@ -396,7 +396,7 @@ struct DQEventQvector { } weff = 1. / weff; if (cfg.mAcceptance) { - wacc = cfg.mAcceptance->getNUA(track.phi(), track.eta(), collision.posZ()); + wacc = cfg.mAcceptance->GetNUA(track.phi(), track.eta(), collision.posZ()); } else { wacc = 1.0; } From dd98835f72f4517f97eef6ca403027a27a07e788 Mon Sep 17 00:00:00 2001 From: Emil Gorm Nielsen Date: Thu, 30 Jan 2025 14:49:29 +0100 Subject: [PATCH 4/6] O2 Linter --- PWGCF/Flow/Tasks/FlowGFWPbPb.cxx | 12 +- PWGCF/Flow/Tasks/flowAnalysisGF.cxx | 8 +- PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx | 32 +++--- PWGCF/Flow/Tasks/flowRunbyRun.cxx | 4 +- PWGCF/Flow/Tasks/flowTask.cxx | 20 ++-- PWGCF/GenericFramework/Core/GFWWeights.cxx | 105 +++++++++--------- PWGCF/GenericFramework/Core/GFWWeights.h | 66 ++++++----- .../GenericFramework/Core/GFWWeightsList.cxx | 60 +++++----- PWGCF/GenericFramework/Core/GFWWeightsList.h | 11 +- .../Tasks/flowGenericFramework.cxx | 50 +++++---- PWGDQ/Tasks/dqCorrelation.cxx | 2 +- PWGDQ/Tasks/dqFlow.cxx | 6 +- 12 files changed, 200 insertions(+), 176 deletions(-) diff --git a/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx b/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx index 39cddafbd2a..12fbf2f7538 100644 --- a/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx +++ b/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx @@ -249,8 +249,8 @@ struct FlowGFWPbPb { fPtAxis = new TAxis(nPtBins, PtBins); if (cfgOutputNUAWeights) { - fWeights->SetPtBins(nPtBins, PtBins); - fWeights->Init(true, false); + fWeights->setPtBins(nPtBins, PtBins); + fWeights->init(true, false); } // add in FlowContainer to Get boostrap sample automatically @@ -384,7 +384,7 @@ struct FlowGFWPbPb { return false; weight_nue = 1. / eff; if (mAcceptance) - weight_nua = mAcceptance->GetNUA(phi, eta, vtxz); + weight_nua = mAcceptance->getNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -510,8 +510,8 @@ struct FlowGFWPbPb { Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::dcaXY) < cfgCutDCAxy); - using Colls = soa::Filtered>; // collisions filter - using aodTracks = soa::Filtered>; // tracks filter + using Colls = soa::Filtered>; // collisions filter + using aodTracks = soa::Filtered>; // tracks filter void process(Colls::iterator const& collision, aod::BCsWithTimestamps const&, aodTracks const& tracks) { @@ -590,7 +590,7 @@ struct FlowGFWPbPb { if (cfgUseAdditionalTrackCut && !trackSelected(track, Magnetfield)) continue; if (cfgOutputNUAWeights) - fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), centrality, 0); + fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), centrality, 0); if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz)) continue; diff --git a/PWGCF/Flow/Tasks/flowAnalysisGF.cxx b/PWGCF/Flow/Tasks/flowAnalysisGF.cxx index e6e60d89b8c..08e223befb6 100644 --- a/PWGCF/Flow/Tasks/flowAnalysisGF.cxx +++ b/PWGCF/Flow/Tasks/flowAnalysisGF.cxx @@ -214,8 +214,8 @@ struct flowAnalysisGF { fPtAxis = new TAxis(ptbins, &ptbinning[0]); if (cfgFillWeights) { - fWeights->SetPtBins(ptbins, &ptbinning[0]); - fWeights->Init(true, false); + fWeights->setPtBins(ptbins, &ptbinning[0]); + fWeights->init(true, false); } if (doprocessMCGen) { @@ -388,7 +388,7 @@ struct flowAnalysisGF { return false; weight_nue = 1. / eff; if (cfg.mAcceptance) - weight_nua = cfg.mAcceptance->GetNUA(phi, eta, vtxz); + weight_nua = cfg.mAcceptance->getNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -582,7 +582,7 @@ struct flowAnalysisGF { return false; if (cfgFillWeights) - fWeights->Fill(particle.phi(), particle.eta(), vtxz, particle.pt(), centrality, 0); + fWeights->fill(particle.phi(), particle.eta(), vtxz, particle.pt(), centrality, 0); if (!setCurrentParticleWeights(weff, wacc, particle.phi(), particle.eta(), particle.pt(), vtxz)) return false; diff --git a/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx b/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx index 7d62084098a..a5f0bdc0fbb 100644 --- a/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx +++ b/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx @@ -376,16 +376,16 @@ struct FlowGFWOmegaXi { // fWeight output if (cfgOutputNUAWeights) { - fWeightsREF->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsREF->Init(true, false); - fWeightsK0s->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsK0s->Init(true, false); - fWeightsLambda->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsLambda->Init(true, false); - fWeightsXi->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsXi->Init(true, false); - fWeightsOmega->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsOmega->Init(true, false); + fWeightsREF->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsREF->init(true, false); + fWeightsK0s->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsK0s->init(true, false); + fWeightsLambda->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsLambda->init(true, false); + fWeightsXi->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsXi->init(true, false); + fWeightsOmega->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsOmega->init(true, false); } } @@ -565,7 +565,7 @@ struct FlowGFWOmegaXi { return false; weight_nue = 1. / eff; if (mAcceptance.size() == 5) - weight_nua = mAcceptance[ispecies]->GetNUA(track.phi(), track.eta(), vtxz); + weight_nua = mAcceptance[ispecies]->getNUA(track.phi(), track.eta(), vtxz); else weight_nua = 1; return true; @@ -681,7 +681,7 @@ struct FlowGFWOmegaXi { fGFW->Fill(track.eta(), ptbin, track.phi(), wacc * weff, 32); } if (cfgOutputNUAWeights) - fWeightsREF->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeightsREF->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } // fill GFW of V0 flow for (const auto& v0 : V0s) { @@ -767,7 +767,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("hEtaPhiVtxzPOIK0s"), v0.phi(), v0.eta(), vtxz, wacc); fGFW->Fill(v0.eta(), fV0PtAxis->FindBin(v0.pt()) - 1 + ((fK0sMass->FindBin(v0.mK0Short()) - 1) * nV0PtBins), v0.phi(), wacc * weff, 8); if (cfgOutputNUAWeights) - fWeightsK0s->Fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); + fWeightsK0s->fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); } if (isLambda) { candNum[1] = candNum[1] + 1; @@ -775,7 +775,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("hEtaPhiVtxzPOILambda"), v0.phi(), v0.eta(), vtxz, wacc); fGFW->Fill(v0.eta(), fV0PtAxis->FindBin(v0.pt()) - 1 + ((fLambdaMass->FindBin(v0.mLambda()) - 1) * nV0PtBins), v0.phi(), wacc * weff, 16); if (cfgOutputNUAWeights) - fWeightsLambda->Fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); + fWeightsLambda->fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); } } // fill GFW of casc flow @@ -861,7 +861,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("InvMassOmega"), casc.pt(), casc.mOmega(), casc.eta(), cent); fGFW->Fill(casc.eta(), fXiPtAxis->FindBin(casc.pt()) - 1 + ((fOmegaMass->FindBin(casc.mOmega()) - 1) * nXiPtBins), casc.phi(), wacc * weff, 4); if (cfgOutputNUAWeights) - fWeightsOmega->Fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); + fWeightsOmega->fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); } if (isXi) { candNum[2] = candNum[2] + 1; @@ -869,7 +869,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("InvMassXi"), casc.pt(), casc.mXi(), casc.eta(), cent); fGFW->Fill(casc.eta(), fXiPtAxis->FindBin(casc.pt()) - 1 + ((fXiMass->FindBin(casc.mXi()) - 1) * nXiPtBins), casc.phi(), wacc * weff, 2); if (cfgOutputNUAWeights) - fWeightsXi->Fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); + fWeightsXi->fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); } } for (int i = 0; i < 4; i++) { diff --git a/PWGCF/Flow/Tasks/flowRunbyRun.cxx b/PWGCF/Flow/Tasks/flowRunbyRun.cxx index 03c596c9d2a..7a92e90494e 100644 --- a/PWGCF/Flow/Tasks/flowRunbyRun.cxx +++ b/PWGCF/Flow/Tasks/flowRunbyRun.cxx @@ -278,7 +278,7 @@ struct FlowRunbyRun { LOGF(fatal, "Could not find the weight for run %d", runNumber); return; } - weight->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); + weight->fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); } } else { GFWWeights* weight = fGFWWeightsList->getGFWWeightsByRun(runNumber); @@ -286,7 +286,7 @@ struct FlowRunbyRun { LOGF(fatal, "Could not find the weight for run %d", runNumber); return; } - weight->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); + weight->fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); } } diff --git a/PWGCF/Flow/Tasks/flowTask.cxx b/PWGCF/Flow/Tasks/flowTask.cxx index 19c0b7418bd..d39f4b802a2 100644 --- a/PWGCF/Flow/Tasks/flowTask.cxx +++ b/PWGCF/Flow/Tasks/flowTask.cxx @@ -254,8 +254,8 @@ struct FlowTask { fPtAxis = new TAxis(nPtBins, ptBins); if (cfgOutputNUAWeights) { - fWeights->SetPtBins(nPtBins, ptBins); - fWeights->Init(true, false); + fWeights->setPtBins(nPtBins, ptBins); + fWeights->init(true, false); } TList* groupNUAWeightlist = new TList(); @@ -271,8 +271,8 @@ struct FlowTask { else groupweight = new GFWWeights(Form("groupweight_last")); - groupweight->SetPtBins(nPtBins, ptBins); - groupweight->Init(true, false); + groupweight->setPtBins(nPtBins, ptBins); + groupweight->init(true, false); groupNUAWeightlist->Add(groupweight); std::shared_ptr sharePtrGroupWeight(groupweight); groupNUAWeightPtr[i] = sharePtrGroupWeight; @@ -566,14 +566,14 @@ struct FlowTask { weight_nue = 1. / eff; if (cfgAcceptanceGroupUse) { if (mGroupAcceptanceList && mGroupAcceptanceList->At(groupNUAIndex)) { - weight_nua = reinterpret_cast(mGroupAcceptanceList->At(groupNUAIndex))->GetNUA(phi, eta, vtxz); + weight_nua = reinterpret_cast(mGroupAcceptanceList->At(groupNUAIndex))->getNUA(phi, eta, vtxz); } else { weight_nua = 1; } return true; } if (mAcceptance) - weight_nua = mAcceptance->GetNUA(phi, eta, vtxz); + weight_nua = mAcceptance->getNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -790,18 +790,18 @@ struct FlowTask { if (cfgOutputNUAWeights) { if (cfgOutputNUAWeightsRefPt) { if (withinPtRef) - fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } else { - fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } if (cfgOutputGroupNUAWeights) { if (cfgOutputNUAWeightsRefPt) { if (withinPtRef) { - groupNUAWeightPtr[groupNUAIndex]->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + groupNUAWeightPtr[groupNUAIndex]->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } else { - groupNUAWeightPtr[groupNUAIndex]->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + groupNUAWeightPtr[groupNUAIndex]->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz, groupNUAIndex)) diff --git a/PWGCF/GenericFramework/Core/GFWWeights.cxx b/PWGCF/GenericFramework/Core/GFWWeights.cxx index e0f5610bd36..cbc5acaa0bb 100644 --- a/PWGCF/GenericFramework/Core/GFWWeights.cxx +++ b/PWGCF/GenericFramework/Core/GFWWeights.cxx @@ -10,7 +10,7 @@ // or submit itself to any jurisdiction. #include "GFWWeights.h" -#include "TMath.h" + GFWWeights::GFWWeights() : TNamed("", ""), fDataFilled(kFALSE), fMCFilled(kFALSE), @@ -44,7 +44,7 @@ GFWWeights::~GFWWeights() if (fbinsPt) delete[] fbinsPt; }; -void GFWWeights::SetPtBins(int Nbins, double* bins) +void GFWWeights::setPtBins(int Nbins, double* bins) { if (fbinsPt) delete[] fbinsPt; @@ -53,7 +53,7 @@ void GFWWeights::SetPtBins(int Nbins, double* bins) for (int i = 0; i <= fNbinsPt; ++i) fbinsPt[i] = bins[i]; }; -void GFWWeights::Init(bool AddData, bool AddMC) +void GFWWeights::init(bool AddData, bool AddMC) { if (!fbinsPt) { // If pT bins not initialized, set to default (-1 to 1e6) to accept everything fNbinsPt = 1; @@ -65,8 +65,8 @@ void GFWWeights::Init(bool AddData, bool AddMC) fW_data = new TObjArray(); fW_data->SetName("GFWWeights_Data"); fW_data->SetOwner(kTRUE); - const char* tnd = GetBinName(0, 0, Form("data_%s", this->GetName())); - fW_data->Add(new TH3D(tnd, ";#varphi;#eta;v_{z}", 60, 0, TMath::TwoPi(), 64, -1.6, 1.6, 40, -10, 10)); + const char* tnd = getBinName(0, 0, Form("data_%s", this->GetName())); + fW_data->Add(new TH3D(tnd, ";#varphi;#eta;v_{z}", 60, 0, TwoPI, 64, -1.6, 1.6, 40, -10, 10)); fDataFilled = kTRUE; } if (AddMC) { @@ -76,8 +76,8 @@ void GFWWeights::Init(bool AddData, bool AddMC) fW_mcgen->SetName("GFWWeights_MCGen"); fW_mcrec->SetOwner(kTRUE); fW_mcgen->SetOwner(kTRUE); - const char* tnr = GetBinName(0, 0, "mcrec"); // all integrated over cent. anyway - const char* tng = GetBinName(0, 0, "mcgen"); // all integrated over cent. anyway + const char* tnr = getBinName(0, 0, "mcrec"); // all integrated over cent. anyway + const char* tng = getBinName(0, 0, "mcgen"); // all integrated over cent. anyway fW_mcrec->Add(new TH3D(tnr, ";#it{p}_{T};#eta;v_{z}", fNbinsPt, 0, 20, 64, -1.6, 1.6, 40, -10, 10)); fW_mcgen->Add(new TH3D(tng, ";#it{p}_{T};#eta;v_{z}", fNbinsPt, 0, 20, 64, -1.6, 1.6, 40, -10, 10)); reinterpret_cast(fW_mcrec->At(fW_mcrec->GetEntries() - 1))->GetXaxis()->Set(fNbinsPt, fbinsPt); @@ -86,7 +86,7 @@ void GFWWeights::Init(bool AddData, bool AddMC) } }; -void GFWWeights::Fill(double phi, double eta, double vz, double pt, double /*cent*/, int htype, double weight) +void GFWWeights::fill(double phi, double eta, double vz, double pt, double /*cent*/, int htype, double weight) { TObjArray* tar = 0; const char* pf = ""; @@ -104,15 +104,15 @@ void GFWWeights::Fill(double phi, double eta, double vz, double pt, double /*cen } if (!tar) return; - TH3D* th3 = reinterpret_cast(tar->FindObject(GetBinName(0, 0, pf))); // pT bin 0, V0M bin 0, since all integrated + TH3D* th3 = reinterpret_cast(tar->FindObject(getBinName(0, 0, pf))); // pT bin 0, V0M bin 0, since all integrated if (!th3) { if (!htype) - tar->Add(new TH3D(GetBinName(0, 0, pf), ";#varphi;#eta;v_{z}", 60, 0, TMath::TwoPi(), 64, -1.6, 1.6, 40, -10, 10)); // 0,0 since all integrated + tar->Add(new TH3D(getBinName(0, 0, pf), ";#varphi;#eta;v_{z}", 60, 0, TwoPI, 64, -1.6, 1.6, 40, -10, 10)); // 0,0 since all integrated th3 = reinterpret_cast(tar->At(tar->GetEntries() - 1)); } th3->Fill(htype ? pt : phi, eta, vz, weight); }; -double GFWWeights::GetWeight(double phi, double eta, double vz, double pt, double /*cent*/, int htype) +double GFWWeights::getWeight(double phi, double eta, double vz, double pt, double /*cent*/, int htype) { TObjArray* tar = 0; const char* pf = ""; @@ -130,7 +130,7 @@ double GFWWeights::GetWeight(double phi, double eta, double vz, double pt, doubl } if (!tar) return 1; - TH3D* th3 = reinterpret_cast(tar->FindObject(GetBinName(0, 0, pf))); + TH3D* th3 = reinterpret_cast(tar->FindObject(getBinName(0, 0, pf))); if (!th3) return 1; //-1; int xind = th3->GetXaxis()->FindBin(htype ? pt : phi); @@ -141,10 +141,10 @@ double GFWWeights::GetWeight(double phi, double eta, double vz, double pt, doubl return 1. / weight; return 1; }; -double GFWWeights::GetNUA(double phi, double eta, double vz) +double GFWWeights::getNUA(double phi, double eta, double vz) { if (!fAccInt) - CreateNUA(); + createNUA(); int xind = fAccInt->GetXaxis()->FindBin(phi); int etaind = fAccInt->GetYaxis()->FindBin(eta); int vzind = fAccInt->GetZaxis()->FindBin(vz); @@ -153,10 +153,10 @@ double GFWWeights::GetNUA(double phi, double eta, double vz) return 1. / weight; return 1; } -double GFWWeights::GetNUE(double pt, double eta, double vz) +double GFWWeights::getNUE(double pt, double eta, double vz) { if (!fEffInt) - CreateNUE(); + createNUE(); int xind = fEffInt->GetXaxis()->FindBin(pt); int etaind = fEffInt->GetYaxis()->FindBin(eta); int vzind = fEffInt->GetZaxis()->FindBin(vz); @@ -165,7 +165,7 @@ double GFWWeights::GetNUE(double pt, double eta, double vz) return 1. / weight; return 1; } -double GFWWeights::FindMax(TH3D* inh, int& ix, int& iy, int& iz) +double GFWWeights::findMax(TH3D* inh, int& ix, int& iy, int& iz) { double maxv = inh->GetBinContent(1, 1, 1); for (int i = 1; i <= inh->GetNbinsX(); i++) @@ -179,10 +179,10 @@ double GFWWeights::FindMax(TH3D* inh, int& ix, int& iy, int& iz) } return maxv; }; -void GFWWeights::MCToEfficiency() +void GFWWeights::mcToEfficiency() { if (fW_mcgen->GetEntries() < 1) { - printf("MC gen. array empty. This is probably because effs. have been calculated and the generated particle histograms have been cleared out!\n"); + LOGF(info, "MC gen. array empty. This is probably because effs. have been calculated and the generated particle histograms have been cleared out!\n"); return; } for (int i = 0; i < fW_mcrec->GetEntries(); i++) { @@ -194,7 +194,7 @@ void GFWWeights::MCToEfficiency() } fW_mcgen->Clear(); }; -void GFWWeights::RebinNUA(int nX, int nY, int nZ) +void GFWWeights::rebinNUA(int nX, int nY, int nZ) { if (fW_data->GetEntries() < 1) return; @@ -204,10 +204,10 @@ void GFWWeights::RebinNUA(int nX, int nY, int nZ) reinterpret_cast(fW_data->At(i))->RebinZ(nZ); } }; -void GFWWeights::CreateNUA(bool IntegrateOverCentAndPt) +void GFWWeights::createNUA(bool IntegrateOverCentAndPt) { if (!IntegrateOverCentAndPt) { - printf("Method is outdated! NUA is integrated over centrality and pT. Quit now, or the behaviour will be bad\n"); + LOGF(info, "Method is outdated! NUA is integrated over centrality and pT. Quit now, or the behaviour will be bad\n"); return; } TH1D* h1; @@ -240,7 +240,7 @@ void GFWWeights::CreateNUA(bool IntegrateOverCentAndPt) return; } }; -TH1D* GFWWeights::GetdNdPhi() +TH1D* GFWWeights::getdNdPhi() { TH3D* temph = reinterpret_cast(fW_data->At(0)->Clone("tempH3")); TH1D* reth = reinterpret_cast(temph->Project3D("x")); @@ -257,10 +257,10 @@ TH1D* GFWWeights::GetdNdPhi() } return reth; } -void GFWWeights::CreateNUE(bool IntegrateOverCentrality) +void GFWWeights::createNUE(bool IntegrateOverCentrality) { if (!IntegrateOverCentrality) { - printf("Method is outdated! NUE is integrated over centrality. Quit now, or the behaviour will be bad\n"); + LOGF(info, "Method is outdated! NUE is integrated over centrality. Quit now, or the behaviour will be bad\n"); return; } TH3D* num = 0; @@ -281,7 +281,7 @@ void GFWWeights::CreateNUE(bool IntegrateOverCentrality) return; } }; -void GFWWeights::ReadAndMerge(TString filelinks, TString listName, bool addData, bool addRec, bool addGen) +void GFWWeights::readAndMerge(TString filelinks, TString listName, bool addData, bool addRec, bool addGen) { FILE* flist = fopen(filelinks.Data(), "r"); char str[150]; @@ -290,7 +290,7 @@ void GFWWeights::ReadAndMerge(TString filelinks, TString listName, bool addData, nFiles++; rewind(flist); if (nFiles == 0) { - printf("No files to read!\n"); + LOGF(info, "No files to read!\n"); return; } if (!fW_data && addData) { @@ -314,31 +314,31 @@ void GFWWeights::ReadAndMerge(TString filelinks, TString listName, bool addData, (void)retVal; tf = new TFile(str, "READ"); if (tf->IsZombie()) { - printf("Could not open file %s!\n", str); + LOGF(warning, "Could not open file %s!\n", str); tf->Close(); continue; } TList* tl = reinterpret_cast(tf->Get(listName.Data())); GFWWeights* tw = reinterpret_cast(tl->FindObject(this->GetName())); if (!tw) { - printf("Could not fetch weights object from %s\n", str); + LOGF(warning, "Could not fetch weights object from %s\n", str); tf->Close(); continue; } if (addData) - AddArray(fW_data, tw->GetDataArray()); + addArray(fW_data, tw->getDataArray()); if (addRec) - AddArray(fW_mcrec, tw->GetRecArray()); + addArray(fW_mcrec, tw->getRecArray()); if (addGen) - AddArray(fW_mcgen, tw->GetGenArray()); + addArray(fW_mcgen, tw->getGenArray()); tf->Close(); delete tw; } }; -void GFWWeights::AddArray(TObjArray* targ, TObjArray* sour) +void GFWWeights::addArray(TObjArray* targ, TObjArray* sour) { if (!sour) { - printf("Source array does not exist!\n"); + LOGF(info, "Source array does not exist!\n"); return; } for (int i = 0; i < sour->GetEntries(); i++) { @@ -353,10 +353,10 @@ void GFWWeights::AddArray(TObjArray* targ, TObjArray* sour) } } }; -void GFWWeights::OverwriteNUA() +void GFWWeights::overwriteNUA() { if (!fAccInt) - CreateNUA(); + createNUA(); TString ts(fW_data->At(0)->GetName()); TH3D* trash = reinterpret_cast(fW_data->RemoveAt(0)); delete trash; @@ -384,29 +384,29 @@ Long64_t GFWWeights::Merge(TCollection* collist) GFWWeights* l_w = 0; TIter all_w(collist); while ((l_w = (reinterpret_cast(all_w())))) { - AddArray(fW_data, l_w->GetDataArray()); - AddArray(fW_mcrec, l_w->GetRecArray()); - AddArray(fW_mcgen, l_w->GetGenArray()); + addArray(fW_data, l_w->getDataArray()); + addArray(fW_mcrec, l_w->getRecArray()); + addArray(fW_mcgen, l_w->getGenArray()); nmerged++; } return nmerged; }; -TH1D* GFWWeights::GetIntegratedEfficiencyHist() +TH1D* GFWWeights::getIntegratedEfficiencyHist() { if (!fW_mcgen) { - printf("MCGen array does not exist!\n"); + LOGF(warning, "MCGen array does not exist!\n"); return 0; } if (!fW_mcrec) { - printf("MCRec array does not exist!\n"); + LOGF(warning, "MCRec array does not exist!\n"); return 0; } if (!fW_mcgen->GetEntries()) { - printf("MCGen array is empty!\n"); + LOGF(warning, "MCGen array is empty!\n"); return 0; } if (!fW_mcrec->GetEntries()) { - printf("MCRec array is empty!\n"); + LOGF(warning, "MCRec array is empty!\n"); return 0; } TH3D* num = reinterpret_cast(fW_mcrec->At(0)->Clone("Numerator")); @@ -426,25 +426,25 @@ TH1D* GFWWeights::GetIntegratedEfficiencyHist() delete den1d; return num1d; } -bool GFWWeights::CalculateIntegratedEff() +bool GFWWeights::calculateIntegratedEff() { if (fIntEff) delete fIntEff; - fIntEff = GetIntegratedEfficiencyHist(); + fIntEff = getIntegratedEfficiencyHist(); if (!fIntEff) { return kFALSE; } fIntEff->SetName("IntegratedEfficiency"); return kTRUE; } -double GFWWeights::GetIntegratedEfficiency(double pt) +double GFWWeights::getIntegratedEfficiency(double pt) { if (!fIntEff) - if (!CalculateIntegratedEff()) + if (!calculateIntegratedEff()) return 0; return fIntEff->GetBinContent(fIntEff->FindBin(pt)); } -TH1D* GFWWeights::GetEfficiency(double etamin, double etamax, double vzmin, double vzmax) +TH1D* GFWWeights::getEfficiency(double etamin, double etamax, double vzmin, double vzmax) { TH3D* num = reinterpret_cast(fW_mcrec->At(0)->Clone("Numerator")); for (int i = 1; i < fW_mcrec->GetEntries(); i++) @@ -470,12 +470,13 @@ TH1D* GFWWeights::GetEfficiency(double etamin, double etamax, double vzmin, doub delete den1d; return num1d; } -void GFWWeights::MergeWeights(GFWWeights* other){ +void GFWWeights::mergeWeights(GFWWeights* other) +{ if (!fW_data) { fW_data = new TObjArray(); fW_data->SetName("Weights_Data"); fW_data->SetOwner(kTRUE); } - AddArray(fW_data, other->GetDataArray()); + addArray(fW_data, other->getDataArray()); return; -} \ No newline at end of file +} diff --git a/PWGCF/GenericFramework/Core/GFWWeights.h b/PWGCF/GenericFramework/Core/GFWWeights.h index deedbf20192..8cb8bfc1bb8 100644 --- a/PWGCF/GenericFramework/Core/GFWWeights.h +++ b/PWGCF/GenericFramework/Core/GFWWeights.h @@ -9,8 +9,16 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file GFWWeights.h +/// \brief Class to store corrections for the Generic Framework +/// \author Emil Gorm Nielsen, NBI, emil.gorm.nielsen@cern.ch + #ifndef PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTS_H_ #define PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTS_H_ + +#include "Framework/Logger.h" +#include "Framework/AnalysisTask.h" + #include "TObjArray.h" #include "TNamed.h" #include "TH3D.h" @@ -20,39 +28,41 @@ #include "TCollection.h" #include "TString.h" +using namespace o2::constants::math; + class GFWWeights : public TNamed { public: GFWWeights(); explicit GFWWeights(const char* name); ~GFWWeights(); - void Init(bool AddData = kTRUE, bool AddM = kTRUE); - void Fill(double phi, double eta, double vz, double pt, double cent, int htype, double weight = 1); // htype: 0 for data, 1 for mc rec, 2 for mc gen - double GetWeight(double phi, double eta, double vz, double pt, double cent, int htype); // htype: 0 for data, 1 for mc rec, 2 for mc gen - double GetNUA(double phi, double eta, double vz); // This just fetches correction from integrated NUA, should speed up - double GetNUE(double pt, double eta, double vz); // fetches weight from fEffInt - bool IsDataFilled() { return fDataFilled; } - bool IsMCFilled() { return fMCFilled; } - double FindMax(TH3D* inh, int& ix, int& iy, int& iz); - void MCToEfficiency(); - TObjArray* GetRecArray() { return fW_mcrec; } - TObjArray* GetGenArray() { return fW_mcgen; } - TObjArray* GetDataArray() { return fW_data; } - void CreateNUA(bool IntegrateOverCentAndPt = kTRUE); - void CreateNUE(bool IntegrateOverCentrality = kTRUE); - TH1D* GetIntegratedEfficiencyHist(); - bool CalculateIntegratedEff(); - double GetIntegratedEfficiency(double pt); - void SetDataFilled(bool newval) { fDataFilled = newval; } - void SetMCFilled(bool newval) { fMCFilled = newval; } - void ReadAndMerge(TString filelinks, TString listName = "OutputList", bool addData = kTRUE, bool addRec = kTRUE, bool addGen = kTRUE); - void SetPtBins(int Nbins, double* bins); + void init(bool AddData = kTRUE, bool AddM = kTRUE); + void fill(double phi, double eta, double vz, double pt, double cent, int htype, double weight = 1); // htype: 0 for data, 1 for mc rec, 2 for mc gen + double getWeight(double phi, double eta, double vz, double pt, double cent, int htype); // htype: 0 for data, 1 for mc rec, 2 for mc gen + double getNUA(double phi, double eta, double vz); // This just fetches correction from integrated NUA, should speed up + double getNUE(double pt, double eta, double vz); // fetches weight from fEffInt + bool isDataFilled() { return fDataFilled; } + bool isMCFilled() { return fMCFilled; } + double findMax(TH3D* inh, int& ix, int& iy, int& iz); + void mcToEfficiency(); + TObjArray* getRecArray() { return fW_mcrec; } + TObjArray* getGenArray() { return fW_mcgen; } + TObjArray* getDataArray() { return fW_data; } + void createNUA(bool IntegrateOverCentAndPt = kTRUE); + void createNUE(bool IntegrateOverCentrality = kTRUE); + TH1D* getIntegratedEfficiencyHist(); + bool calculateIntegratedEff(); + double getIntegratedEfficiency(double pt); + void setDataFilled(bool newval) { fDataFilled = newval; } + void setMCFilled(bool newval) { fMCFilled = newval; } + void readAndMerge(TString filelinks, TString listName = "OutputList", bool addData = kTRUE, bool addRec = kTRUE, bool addGen = kTRUE); + void setPtBins(int Nbins, double* bins); Long64_t Merge(TCollection* collist); - void RebinNUA(int nX = 1, int nY = 2, int nZ = 5); - void OverwriteNUA(); - TH1D* GetdNdPhi(); - TH1D* GetEfficiency(double etamin, double etamax, double vzmin, double vzmax); - void MergeWeights(GFWWeights* other); + void rebinNUA(int nX = 1, int nY = 2, int nZ = 5); + void overwriteNUA(); + TH1D* getdNdPhi(); + TH1D* getEfficiency(double etamin, double etamax, double vzmin, double vzmax); + void mergeWeights(GFWWeights* other); private: bool fDataFilled; @@ -65,8 +75,8 @@ class GFWWeights : public TNamed TH3D* fAccInt; //! int fNbinsPt; //! do not store double* fbinsPt; //! do not store - void AddArray(TObjArray* targ, TObjArray* sour); - const char* GetBinName(double /*ptv*/, double /*v0mv*/, const char* pf = "") + void addArray(TObjArray* targ, TObjArray* sour); + const char* getBinName(double /*ptv*/, double /*v0mv*/, const char* pf = "") { int ptind = 0; // GetPtBin(ptv); int v0mind = 0; // GetV0MBin(v0mv); diff --git a/PWGCF/GenericFramework/Core/GFWWeightsList.cxx b/PWGCF/GenericFramework/Core/GFWWeightsList.cxx index 801fbe68115..d4b1d02fed4 100644 --- a/PWGCF/GenericFramework/Core/GFWWeightsList.cxx +++ b/PWGCF/GenericFramework/Core/GFWWeightsList.cxx @@ -53,15 +53,15 @@ void GFWWeightsList::addGFWWeightsByName(const char* weightName, int nPtBins, do return; } GFWWeights* weight = new GFWWeights(weightName); - weight->SetPtBins(nPtBins, ptBins); - weight->Init(addData, addMC); + weight->setPtBins(nPtBins, ptBins); + weight->init(addData, addMC); list->Add(weight); } GFWWeights* GFWWeightsList::getGFWWeightsByName(const char* weightName) { if (!list) { - printf("Error: weight list is not initialized\n"); + LOGF(error, "weight list is not initialized\n"); return nullptr; } return reinterpret_cast(list->FindObject(weightName)); @@ -76,8 +76,8 @@ void GFWWeightsList::addGFWWeightsByRun(int runNumber, int nPtBins, double* ptBi return; } GFWWeights* weight = new GFWWeights(Form("weight_%d", runNumber)); - weight->SetPtBins(nPtBins, ptBins); - weight->Init(addData, addMC); + weight->setPtBins(nPtBins, ptBins); + weight->init(addData, addMC); list->Add(weight); runNumberMap.insert(std::make_pair(runNumber, weight)); } @@ -85,11 +85,11 @@ void GFWWeightsList::addGFWWeightsByRun(int runNumber, int nPtBins, double* ptBi GFWWeights* GFWWeightsList::getGFWWeightsByRun(int runNumber) { if (!list) { - printf("Error: weight list is not initialized\n"); + LOGF(error, "weight list is not initialized\n"); return nullptr; } if (!runNumberMap.contains(runNumber)) { - printf("Error: weight for run %d is not found\n", runNumber); + LOGF(error, "weight for run %d is not found\n", runNumber); return nullptr; } return runNumberMap.at(runNumber); @@ -105,26 +105,28 @@ void GFWWeightsList::addPIDGFWWeightsByName(const char* weightName, int nPtBins, auto it = std::find(ptbins.begin(), ptbins.end(), ptrefup); std::vector refpt(ptbins.begin(), it + 1); - for(auto & type : species){ - if (reinterpret_cast(list->FindObject((static_cast(weightName)+type).c_str()))) { + for (auto& type : species) { + if (reinterpret_cast(list->FindObject((static_cast(weightName) + type).c_str()))) { continue; } - GFWWeights* weight = new GFWWeights(Form("%s",(static_cast(weightName)+type).c_str())); - if(!type.compare("_ref")) weight->SetPtBins(refpt.size() - 1, &(refpt[0])); - else weight->SetPtBins(nPtBins, ptBins); - weight->Init(addData, addMC); + GFWWeights* weight = new GFWWeights(Form("%s", (static_cast(weightName) + type).c_str())); + if (!type.compare("_ref")) + weight->setPtBins(refpt.size() - 1, &(refpt[0])); + else + weight->setPtBins(nPtBins, ptBins); + weight->init(addData, addMC); list->Add(weight); } } GFWWeights* GFWWeightsList::getPIDGFWWeightsByName(const char* weightName, int pidIndex) { - if(static_cast(pidIndex) >= species.size()) + if (static_cast(pidIndex) >= species.size()) return nullptr; if (!list) { - printf("Error: weight list is not initialized\n"); + LOGF(error, "weight list is not initialized\n"); return nullptr; } - return reinterpret_cast(list->FindObject((static_cast(weightName)+species[pidIndex]).c_str())); + return reinterpret_cast(list->FindObject((static_cast(weightName) + species[pidIndex]).c_str())); } void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, double ptrefup, bool addData, bool addMC) { @@ -132,21 +134,24 @@ void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* p init("weightList"); } - if (runNumberPIDMap.contains(runNumber)) return; + if (runNumberPIDMap.contains(runNumber)) + return; std::vector ptbins(ptBins, ptBins + nPtBins + 1); auto it = std::find(ptbins.begin(), ptbins.end(), ptrefup); std::vector refpt(ptbins.begin(), it + 1); std::vector weights; - for(auto & type : species){ + for (auto& type : species) { GFWWeights* weight = new GFWWeights(Form("weight_%d%s", runNumber, type.c_str())); - if(!type.compare("_ref")) weight->SetPtBins(refpt.size() - 1, &(refpt[0])); - else weight->SetPtBins(nPtBins, ptBins); - weight->Init(addData, addMC); + if (!type.compare("_ref")) + weight->setPtBins(refpt.size() - 1, &(refpt[0])); + else + weight->setPtBins(nPtBins, ptBins); + weight->init(addData, addMC); list->Add(weight); weights.push_back(weight); } - printf("Adding weights for run %d\n",runNumber); + LOGF(info, "Adding weights for run %d\n", runNumber); runNumberPIDMap.insert(std::make_pair(runNumber, weights)); return; } @@ -154,18 +159,17 @@ void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* p GFWWeights* GFWWeightsList::getPIDGFWWeightsByRun(int runNumber, int pidIndex) { if (!list) { - printf("Error: weight list is not initialized\n"); + LOGF(error, "weight list is not initialized\n"); return nullptr; } if (!runNumberPIDMap.contains(runNumber)) { - printf("Error: PID weights for run %d is not found\n", runNumber); + LOGF(error, "PID weights for run %d is not found\n", runNumber); return nullptr; } return runNumberPIDMap.at(runNumber)[pidIndex]; } Long64_t GFWWeightsList::Merge(TCollection* collist) { - printf("Merging weight lists!\n"); Long64_t nmerged = 0; if (!list) { list = new TObjArray(); @@ -175,12 +179,12 @@ Long64_t GFWWeightsList::Merge(TCollection* collist) TIter allWeights(collist); GFWWeightsList* lWeight = 0; while ((lWeight = (reinterpret_cast(allWeights())))) { - AddArray(list, lWeight->getList()); + addArray(list, lWeight->getList()); nmerged++; } return nmerged; } -void GFWWeightsList::AddArray(TObjArray* target, TObjArray* source) +void GFWWeightsList::addArray(TObjArray* target, TObjArray* source) { if (!source) { return; @@ -192,7 +196,7 @@ void GFWWeightsList::AddArray(TObjArray* target, TObjArray* source) targw = reinterpret_cast(sourw->Clone(sourw->GetName())); target->Add(targw); } else { - targw->MergeWeights(sourw); + targw->mergeWeights(sourw); } } }; diff --git a/PWGCF/GenericFramework/Core/GFWWeightsList.h b/PWGCF/GenericFramework/Core/GFWWeightsList.h index f9cc4de0aa9..8de876133d6 100644 --- a/PWGCF/GenericFramework/Core/GFWWeightsList.h +++ b/PWGCF/GenericFramework/Core/GFWWeightsList.h @@ -38,16 +38,21 @@ class GFWWeightsList : public TNamed GFWWeights* getPIDGFWWeightsByName(const char* weightName, int pidIndex); void addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, double ptrefup, bool addData = kTRUE, bool addMC = kTRUE); GFWWeights* getPIDGFWWeightsByRun(int runNumber, int pidIndex); - void PrintRuns() { for(auto &el : runNumberPIDMap) printf("%i\n",el.first); } + void printRuns() + { + for (auto& el : runNumberPIDMap) + printf("%i\n", el.first); + } TObjArray* getList() const { return list; } Long64_t Merge(TCollection* collist); + private: TObjArray* list; std::vector species = {"_ref", "_ch", "_pi", "_ka", "_pr"}; //! std::map runNumberMap; - std::map> runNumberPIDMap; - void AddArray(TObjArray* target, TObjArray* source); + std::map> runNumberPIDMap; + void addArray(TObjArray* target, TObjArray* source); ClassDef(GFWWeightsList, 1); }; diff --git a/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx b/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx index cf0ac0cbd30..632dff15c85 100644 --- a/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx +++ b/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx @@ -80,7 +80,7 @@ GFWCorrConfigs configs; using namespace o2::analysis::genericframework; -struct GenericFramework { +struct FlowGenericFramework { O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 10, "Number of subsamples") O2_DEFINE_CONFIGURABLE(cfgMpar, int, 8, "Highest order of pt-pt correlations") @@ -385,11 +385,15 @@ struct GenericFramework { double wacc = 1; if (cfg.mAcceptance) { if (cfgUsePID) { - if(cfgRunByRunWeights) wacc = cfg.mAcceptance->getPIDGFWWeightsByRun(lastRun,index)->GetNUA(track.phi(), track.eta(), vtxz); - else wacc = cfg.mAcceptance->getPIDGFWWeightsByName("weight",index)->GetNUA(track.phi(), track.eta(), vtxz); + if (cfgRunByRunWeights) + wacc = cfg.mAcceptance->getPIDGFWWeightsByRun(lastRun, index)->getNUA(track.phi(), track.eta(), vtxz); + else + wacc = cfg.mAcceptance->getPIDGFWWeightsByName("weight", index)->getNUA(track.phi(), track.eta(), vtxz); } else { - if(cfgRunByRunWeights) wacc = cfg.mAcceptance->getGFWWeightsByRun(lastRun)->GetNUA(track.phi(), track.eta(), vtxz); - else wacc = cfg.mAcceptance->getGFWWeightsByName("weight")->GetNUA(track.phi(), track.eta(), vtxz); + if (cfgRunByRunWeights) + wacc = cfg.mAcceptance->getGFWWeightsByRun(lastRun)->getNUA(track.phi(), track.eta(), vtxz); + else + wacc = cfg.mAcceptance->getGFWWeightsByName("weight")->getNUA(track.phi(), track.eta(), vtxz); } } return wacc; @@ -512,7 +516,7 @@ struct GenericFramework { if (vtxz > vtxZup || vtxz < vtxZlow) return 0; - if(cfgMultCut){ + if (cfgMultCut) { if (multNTracksPV < fMultPVCutLow->Eval(centrality)) return 0; if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) @@ -576,20 +580,20 @@ struct GenericFramework { bool withinPtRef = (ptreflow < track.pt()) && (track.pt() < ptrefup); // within RF pT range if (cfgRunByRunWeights) { if (withinPtRef && !pid_index) - fWeightList->getPIDGFWWeightsByRun(run,pid_index)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow + fWeightList->getPIDGFWWeightsByRun(run, pid_index)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow if (withinPtPOI) - fWeightList->getPIDGFWWeightsByRun(run,pid_index+1)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights + fWeightList->getPIDGFWWeightsByRun(run, pid_index + 1)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights } else { if (withinPtRef && !pid_index) - fWeightList->getPIDGFWWeightsByName("weight",pid_index)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow + fWeightList->getPIDGFWWeightsByName("weight", pid_index)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow if (withinPtPOI) - fWeightList->getPIDGFWWeightsByName("weight",pid_index+1)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights + fWeightList->getPIDGFWWeightsByName("weight", pid_index + 1)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights } } else { if (cfgRunByRunWeights) - fWeightList->getGFWWeightsByRun(lastRun)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); + fWeightList->getGFWWeightsByRun(lastRun)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); else - fWeightList->getGFWWeightsByName("weight")->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); + fWeightList->getGFWWeightsByName("weight")->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); } return; } @@ -597,9 +601,9 @@ struct GenericFramework { void createRunByRunWeights(int run) { if (cfgUsePID) { - fWeightList->addPIDGFWWeightsByRun(run,fPtAxis->GetNbins(),&ptbinning[0],ptrefup,true,false); + fWeightList->addPIDGFWWeightsByRun(run, fPtAxis->GetNbins(), &ptbinning[0], ptrefup, true, false); } else { - fWeightList->addGFWWeightsByRun(run,fPtAxis->GetNbins(),&ptbinning[0],true,false); + fWeightList->addGFWWeightsByRun(run, fPtAxis->GetNbins(), &ptbinning[0], true, false); } return; } @@ -774,7 +778,7 @@ struct GenericFramework { if (!withinPtPOI && !withinPtRef) return; double waccRef = (dt == kGen) ? 1. : getAcceptance(track, vtxz, 0); - double waccPOI = (dt == kGen) ? 1. : withinPtPOI ? getAcceptance(track, vtxz, pid_index+1) + double waccPOI = (dt == kGen) ? 1. : withinPtPOI ? getAcceptance(track, vtxz, pid_index + 1) : getAcceptance(track, vtxz, 0); // if (withinPtRef && withinPtPOI && pid_index) waccRef = waccPOI; // if particle is both (then it's overlap), override ref with POI @@ -806,7 +810,7 @@ struct GenericFramework { registry.fill(HIST("MCGen/") + HIST(FillTimeName[ft]) + HIST("pt_gen"), track.pt()); } else { double wacc = getAcceptance(track, vtxz, 0); - registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ"), track.phi(), track.eta(), vtxz, (ft == kAfter)?wacc:1.0); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ"), track.phi(), track.eta(), vtxz, (ft == kAfter) ? wacc : 1.0); registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_dcaXY_dcaZ"), track.pt(), track.dcaXY(), track.dcaZ()); if (ft == kAfter) { registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_ref"), track.pt()); @@ -865,7 +869,7 @@ struct GenericFramework { auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; processCollision(collision, tracks, centrality, field, run); } - PROCESS_SWITCH(GenericFramework, processData, "Process analysis for non-derived data", true); + PROCESS_SWITCH(FlowGenericFramework, processData, "Process analysis for non-derived data", true); void processMCReco(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, soa::Filtered> const& tracks, aod::McParticles const&) { @@ -891,7 +895,7 @@ struct GenericFramework { auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; processCollision(collision, tracks, centrality, field, run); } - PROCESS_SWITCH(GenericFramework, processMCReco, "Process analysis for MC reconstructed events", false); + PROCESS_SWITCH(FlowGenericFramework, processMCReco, "Process analysis for MC reconstructed events", false); Filter mcCollFilter = nabs(aod::mccollision::posZ) < cfgVtxZ; void processMCGen(soa::Filtered::iterator const& mcCollision, soa::SmallGroups> const& collisions, aod::McParticles const& particles) @@ -904,7 +908,7 @@ struct GenericFramework { } processCollision(mcCollision, particles, centrality, -999, 0); } - PROCESS_SWITCH(GenericFramework, processMCGen, "Process analysis for MC generated events", false); + PROCESS_SWITCH(FlowGenericFramework, processMCGen, "Process analysis for MC generated events", false); void processRun2(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, GFWTracks const& tracks) { @@ -918,17 +922,17 @@ struct GenericFramework { if (!collision.sel7()) return; const auto centrality = collision.centRun2V0M(); - if(!cfgFillWeights) - loadCorrections(bc); + if (!cfgFillWeights) + loadCorrections(bc); auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; processCollision(collision, tracks, centrality, field, run); } - PROCESS_SWITCH(GenericFramework, processRun2, "Process analysis for Run 2 converted data", false); + PROCESS_SWITCH(FlowGenericFramework, processRun2, "Process analysis for Run 2 converted data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), }; } diff --git a/PWGDQ/Tasks/dqCorrelation.cxx b/PWGDQ/Tasks/dqCorrelation.cxx index d2fa3a0dd4b..950e82364cb 100644 --- a/PWGDQ/Tasks/dqCorrelation.cxx +++ b/PWGDQ/Tasks/dqCorrelation.cxx @@ -303,7 +303,7 @@ struct DqCumulantFlow { } weff = 1. / weff; if (cfg.mAcceptance) { - wacc = cfg.mAcceptance->GetNUA(track.phi(), track.eta(), event.posZ()); + wacc = cfg.mAcceptance->getNUA(track.phi(), track.eta(), event.posZ()); } else { wacc = 1.0; } diff --git a/PWGDQ/Tasks/dqFlow.cxx b/PWGDQ/Tasks/dqFlow.cxx index b5e855d3d13..d9210685a2e 100644 --- a/PWGDQ/Tasks/dqFlow.cxx +++ b/PWGDQ/Tasks/dqFlow.cxx @@ -189,7 +189,7 @@ struct DQEventQvector { fPtAxis = new TAxis(ptbins, &ptbinning[0]); if (fConfigFillWeights) { // fWeights->SetPtBins(ptbins, &ptbinning[0]); // in the default case, it will accept everything - fWeights->Init(true, false); // true for data, false for MC + fWeights->init(true, false); // true for data, false for MC } // Reference flow @@ -383,7 +383,7 @@ struct DQEventQvector { // Fill weights for Q-vector correction: this should be enabled for a first run to get weights if (fConfigFillWeights) { - fWeights->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), centrality, 0); + fWeights->fill(track.phi(), track.eta(), collision.posZ(), track.pt(), centrality, 0); } if (cfg.mEfficiency) { @@ -396,7 +396,7 @@ struct DQEventQvector { } weff = 1. / weff; if (cfg.mAcceptance) { - wacc = cfg.mAcceptance->GetNUA(track.phi(), track.eta(), collision.posZ()); + wacc = cfg.mAcceptance->getNUA(track.phi(), track.eta(), collision.posZ()); } else { wacc = 1.0; } From 46e49ec08c7a6e2b808038fa0646ead74d0821da Mon Sep 17 00:00:00 2001 From: Emil Gorm Nielsen Date: Thu, 30 Jan 2025 15:08:00 +0100 Subject: [PATCH 5/6] Revert "O2 Linter" This reverts commit dd98835f72f4517f97eef6ca403027a27a07e788. --- PWGCF/Flow/Tasks/FlowGFWPbPb.cxx | 12 +- PWGCF/Flow/Tasks/flowAnalysisGF.cxx | 8 +- PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx | 32 +++--- PWGCF/Flow/Tasks/flowRunbyRun.cxx | 4 +- PWGCF/Flow/Tasks/flowTask.cxx | 20 ++-- PWGCF/GenericFramework/Core/GFWWeights.cxx | 105 +++++++++--------- PWGCF/GenericFramework/Core/GFWWeights.h | 66 +++++------ .../GenericFramework/Core/GFWWeightsList.cxx | 60 +++++----- PWGCF/GenericFramework/Core/GFWWeightsList.h | 11 +- .../Tasks/flowGenericFramework.cxx | 50 ++++----- PWGDQ/Tasks/dqCorrelation.cxx | 2 +- PWGDQ/Tasks/dqFlow.cxx | 6 +- 12 files changed, 176 insertions(+), 200 deletions(-) diff --git a/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx b/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx index 12fbf2f7538..39cddafbd2a 100644 --- a/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx +++ b/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx @@ -249,8 +249,8 @@ struct FlowGFWPbPb { fPtAxis = new TAxis(nPtBins, PtBins); if (cfgOutputNUAWeights) { - fWeights->setPtBins(nPtBins, PtBins); - fWeights->init(true, false); + fWeights->SetPtBins(nPtBins, PtBins); + fWeights->Init(true, false); } // add in FlowContainer to Get boostrap sample automatically @@ -384,7 +384,7 @@ struct FlowGFWPbPb { return false; weight_nue = 1. / eff; if (mAcceptance) - weight_nua = mAcceptance->getNUA(phi, eta, vtxz); + weight_nua = mAcceptance->GetNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -510,8 +510,8 @@ struct FlowGFWPbPb { Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::dcaXY) < cfgCutDCAxy); - using Colls = soa::Filtered>; // collisions filter - using aodTracks = soa::Filtered>; // tracks filter + using Colls = soa::Filtered>; // collisions filter + using aodTracks = soa::Filtered>; // tracks filter void process(Colls::iterator const& collision, aod::BCsWithTimestamps const&, aodTracks const& tracks) { @@ -590,7 +590,7 @@ struct FlowGFWPbPb { if (cfgUseAdditionalTrackCut && !trackSelected(track, Magnetfield)) continue; if (cfgOutputNUAWeights) - fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), centrality, 0); + fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), centrality, 0); if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz)) continue; diff --git a/PWGCF/Flow/Tasks/flowAnalysisGF.cxx b/PWGCF/Flow/Tasks/flowAnalysisGF.cxx index 08e223befb6..e6e60d89b8c 100644 --- a/PWGCF/Flow/Tasks/flowAnalysisGF.cxx +++ b/PWGCF/Flow/Tasks/flowAnalysisGF.cxx @@ -214,8 +214,8 @@ struct flowAnalysisGF { fPtAxis = new TAxis(ptbins, &ptbinning[0]); if (cfgFillWeights) { - fWeights->setPtBins(ptbins, &ptbinning[0]); - fWeights->init(true, false); + fWeights->SetPtBins(ptbins, &ptbinning[0]); + fWeights->Init(true, false); } if (doprocessMCGen) { @@ -388,7 +388,7 @@ struct flowAnalysisGF { return false; weight_nue = 1. / eff; if (cfg.mAcceptance) - weight_nua = cfg.mAcceptance->getNUA(phi, eta, vtxz); + weight_nua = cfg.mAcceptance->GetNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -582,7 +582,7 @@ struct flowAnalysisGF { return false; if (cfgFillWeights) - fWeights->fill(particle.phi(), particle.eta(), vtxz, particle.pt(), centrality, 0); + fWeights->Fill(particle.phi(), particle.eta(), vtxz, particle.pt(), centrality, 0); if (!setCurrentParticleWeights(weff, wacc, particle.phi(), particle.eta(), particle.pt(), vtxz)) return false; diff --git a/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx b/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx index a5f0bdc0fbb..7d62084098a 100644 --- a/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx +++ b/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx @@ -376,16 +376,16 @@ struct FlowGFWOmegaXi { // fWeight output if (cfgOutputNUAWeights) { - fWeightsREF->setPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsREF->init(true, false); - fWeightsK0s->setPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsK0s->init(true, false); - fWeightsLambda->setPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsLambda->init(true, false); - fWeightsXi->setPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsXi->init(true, false); - fWeightsOmega->setPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsOmega->init(true, false); + fWeightsREF->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsREF->Init(true, false); + fWeightsK0s->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsK0s->Init(true, false); + fWeightsLambda->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsLambda->Init(true, false); + fWeightsXi->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsXi->Init(true, false); + fWeightsOmega->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsOmega->Init(true, false); } } @@ -565,7 +565,7 @@ struct FlowGFWOmegaXi { return false; weight_nue = 1. / eff; if (mAcceptance.size() == 5) - weight_nua = mAcceptance[ispecies]->getNUA(track.phi(), track.eta(), vtxz); + weight_nua = mAcceptance[ispecies]->GetNUA(track.phi(), track.eta(), vtxz); else weight_nua = 1; return true; @@ -681,7 +681,7 @@ struct FlowGFWOmegaXi { fGFW->Fill(track.eta(), ptbin, track.phi(), wacc * weff, 32); } if (cfgOutputNUAWeights) - fWeightsREF->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeightsREF->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } // fill GFW of V0 flow for (const auto& v0 : V0s) { @@ -767,7 +767,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("hEtaPhiVtxzPOIK0s"), v0.phi(), v0.eta(), vtxz, wacc); fGFW->Fill(v0.eta(), fV0PtAxis->FindBin(v0.pt()) - 1 + ((fK0sMass->FindBin(v0.mK0Short()) - 1) * nV0PtBins), v0.phi(), wacc * weff, 8); if (cfgOutputNUAWeights) - fWeightsK0s->fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); + fWeightsK0s->Fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); } if (isLambda) { candNum[1] = candNum[1] + 1; @@ -775,7 +775,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("hEtaPhiVtxzPOILambda"), v0.phi(), v0.eta(), vtxz, wacc); fGFW->Fill(v0.eta(), fV0PtAxis->FindBin(v0.pt()) - 1 + ((fLambdaMass->FindBin(v0.mLambda()) - 1) * nV0PtBins), v0.phi(), wacc * weff, 16); if (cfgOutputNUAWeights) - fWeightsLambda->fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); + fWeightsLambda->Fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); } } // fill GFW of casc flow @@ -861,7 +861,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("InvMassOmega"), casc.pt(), casc.mOmega(), casc.eta(), cent); fGFW->Fill(casc.eta(), fXiPtAxis->FindBin(casc.pt()) - 1 + ((fOmegaMass->FindBin(casc.mOmega()) - 1) * nXiPtBins), casc.phi(), wacc * weff, 4); if (cfgOutputNUAWeights) - fWeightsOmega->fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); + fWeightsOmega->Fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); } if (isXi) { candNum[2] = candNum[2] + 1; @@ -869,7 +869,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("InvMassXi"), casc.pt(), casc.mXi(), casc.eta(), cent); fGFW->Fill(casc.eta(), fXiPtAxis->FindBin(casc.pt()) - 1 + ((fXiMass->FindBin(casc.mXi()) - 1) * nXiPtBins), casc.phi(), wacc * weff, 2); if (cfgOutputNUAWeights) - fWeightsXi->fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); + fWeightsXi->Fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); } } for (int i = 0; i < 4; i++) { diff --git a/PWGCF/Flow/Tasks/flowRunbyRun.cxx b/PWGCF/Flow/Tasks/flowRunbyRun.cxx index 7a92e90494e..03c596c9d2a 100644 --- a/PWGCF/Flow/Tasks/flowRunbyRun.cxx +++ b/PWGCF/Flow/Tasks/flowRunbyRun.cxx @@ -278,7 +278,7 @@ struct FlowRunbyRun { LOGF(fatal, "Could not find the weight for run %d", runNumber); return; } - weight->fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); + weight->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); } } else { GFWWeights* weight = fGFWWeightsList->getGFWWeightsByRun(runNumber); @@ -286,7 +286,7 @@ struct FlowRunbyRun { LOGF(fatal, "Could not find the weight for run %d", runNumber); return; } - weight->fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); + weight->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); } } diff --git a/PWGCF/Flow/Tasks/flowTask.cxx b/PWGCF/Flow/Tasks/flowTask.cxx index d39f4b802a2..19c0b7418bd 100644 --- a/PWGCF/Flow/Tasks/flowTask.cxx +++ b/PWGCF/Flow/Tasks/flowTask.cxx @@ -254,8 +254,8 @@ struct FlowTask { fPtAxis = new TAxis(nPtBins, ptBins); if (cfgOutputNUAWeights) { - fWeights->setPtBins(nPtBins, ptBins); - fWeights->init(true, false); + fWeights->SetPtBins(nPtBins, ptBins); + fWeights->Init(true, false); } TList* groupNUAWeightlist = new TList(); @@ -271,8 +271,8 @@ struct FlowTask { else groupweight = new GFWWeights(Form("groupweight_last")); - groupweight->setPtBins(nPtBins, ptBins); - groupweight->init(true, false); + groupweight->SetPtBins(nPtBins, ptBins); + groupweight->Init(true, false); groupNUAWeightlist->Add(groupweight); std::shared_ptr sharePtrGroupWeight(groupweight); groupNUAWeightPtr[i] = sharePtrGroupWeight; @@ -566,14 +566,14 @@ struct FlowTask { weight_nue = 1. / eff; if (cfgAcceptanceGroupUse) { if (mGroupAcceptanceList && mGroupAcceptanceList->At(groupNUAIndex)) { - weight_nua = reinterpret_cast(mGroupAcceptanceList->At(groupNUAIndex))->getNUA(phi, eta, vtxz); + weight_nua = reinterpret_cast(mGroupAcceptanceList->At(groupNUAIndex))->GetNUA(phi, eta, vtxz); } else { weight_nua = 1; } return true; } if (mAcceptance) - weight_nua = mAcceptance->getNUA(phi, eta, vtxz); + weight_nua = mAcceptance->GetNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -790,18 +790,18 @@ struct FlowTask { if (cfgOutputNUAWeights) { if (cfgOutputNUAWeightsRefPt) { if (withinPtRef) - fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } else { - fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } if (cfgOutputGroupNUAWeights) { if (cfgOutputNUAWeightsRefPt) { if (withinPtRef) { - groupNUAWeightPtr[groupNUAIndex]->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + groupNUAWeightPtr[groupNUAIndex]->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } else { - groupNUAWeightPtr[groupNUAIndex]->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + groupNUAWeightPtr[groupNUAIndex]->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz, groupNUAIndex)) diff --git a/PWGCF/GenericFramework/Core/GFWWeights.cxx b/PWGCF/GenericFramework/Core/GFWWeights.cxx index cbc5acaa0bb..e0f5610bd36 100644 --- a/PWGCF/GenericFramework/Core/GFWWeights.cxx +++ b/PWGCF/GenericFramework/Core/GFWWeights.cxx @@ -10,7 +10,7 @@ // or submit itself to any jurisdiction. #include "GFWWeights.h" - +#include "TMath.h" GFWWeights::GFWWeights() : TNamed("", ""), fDataFilled(kFALSE), fMCFilled(kFALSE), @@ -44,7 +44,7 @@ GFWWeights::~GFWWeights() if (fbinsPt) delete[] fbinsPt; }; -void GFWWeights::setPtBins(int Nbins, double* bins) +void GFWWeights::SetPtBins(int Nbins, double* bins) { if (fbinsPt) delete[] fbinsPt; @@ -53,7 +53,7 @@ void GFWWeights::setPtBins(int Nbins, double* bins) for (int i = 0; i <= fNbinsPt; ++i) fbinsPt[i] = bins[i]; }; -void GFWWeights::init(bool AddData, bool AddMC) +void GFWWeights::Init(bool AddData, bool AddMC) { if (!fbinsPt) { // If pT bins not initialized, set to default (-1 to 1e6) to accept everything fNbinsPt = 1; @@ -65,8 +65,8 @@ void GFWWeights::init(bool AddData, bool AddMC) fW_data = new TObjArray(); fW_data->SetName("GFWWeights_Data"); fW_data->SetOwner(kTRUE); - const char* tnd = getBinName(0, 0, Form("data_%s", this->GetName())); - fW_data->Add(new TH3D(tnd, ";#varphi;#eta;v_{z}", 60, 0, TwoPI, 64, -1.6, 1.6, 40, -10, 10)); + const char* tnd = GetBinName(0, 0, Form("data_%s", this->GetName())); + fW_data->Add(new TH3D(tnd, ";#varphi;#eta;v_{z}", 60, 0, TMath::TwoPi(), 64, -1.6, 1.6, 40, -10, 10)); fDataFilled = kTRUE; } if (AddMC) { @@ -76,8 +76,8 @@ void GFWWeights::init(bool AddData, bool AddMC) fW_mcgen->SetName("GFWWeights_MCGen"); fW_mcrec->SetOwner(kTRUE); fW_mcgen->SetOwner(kTRUE); - const char* tnr = getBinName(0, 0, "mcrec"); // all integrated over cent. anyway - const char* tng = getBinName(0, 0, "mcgen"); // all integrated over cent. anyway + const char* tnr = GetBinName(0, 0, "mcrec"); // all integrated over cent. anyway + const char* tng = GetBinName(0, 0, "mcgen"); // all integrated over cent. anyway fW_mcrec->Add(new TH3D(tnr, ";#it{p}_{T};#eta;v_{z}", fNbinsPt, 0, 20, 64, -1.6, 1.6, 40, -10, 10)); fW_mcgen->Add(new TH3D(tng, ";#it{p}_{T};#eta;v_{z}", fNbinsPt, 0, 20, 64, -1.6, 1.6, 40, -10, 10)); reinterpret_cast(fW_mcrec->At(fW_mcrec->GetEntries() - 1))->GetXaxis()->Set(fNbinsPt, fbinsPt); @@ -86,7 +86,7 @@ void GFWWeights::init(bool AddData, bool AddMC) } }; -void GFWWeights::fill(double phi, double eta, double vz, double pt, double /*cent*/, int htype, double weight) +void GFWWeights::Fill(double phi, double eta, double vz, double pt, double /*cent*/, int htype, double weight) { TObjArray* tar = 0; const char* pf = ""; @@ -104,15 +104,15 @@ void GFWWeights::fill(double phi, double eta, double vz, double pt, double /*cen } if (!tar) return; - TH3D* th3 = reinterpret_cast(tar->FindObject(getBinName(0, 0, pf))); // pT bin 0, V0M bin 0, since all integrated + TH3D* th3 = reinterpret_cast(tar->FindObject(GetBinName(0, 0, pf))); // pT bin 0, V0M bin 0, since all integrated if (!th3) { if (!htype) - tar->Add(new TH3D(getBinName(0, 0, pf), ";#varphi;#eta;v_{z}", 60, 0, TwoPI, 64, -1.6, 1.6, 40, -10, 10)); // 0,0 since all integrated + tar->Add(new TH3D(GetBinName(0, 0, pf), ";#varphi;#eta;v_{z}", 60, 0, TMath::TwoPi(), 64, -1.6, 1.6, 40, -10, 10)); // 0,0 since all integrated th3 = reinterpret_cast(tar->At(tar->GetEntries() - 1)); } th3->Fill(htype ? pt : phi, eta, vz, weight); }; -double GFWWeights::getWeight(double phi, double eta, double vz, double pt, double /*cent*/, int htype) +double GFWWeights::GetWeight(double phi, double eta, double vz, double pt, double /*cent*/, int htype) { TObjArray* tar = 0; const char* pf = ""; @@ -130,7 +130,7 @@ double GFWWeights::getWeight(double phi, double eta, double vz, double pt, doubl } if (!tar) return 1; - TH3D* th3 = reinterpret_cast(tar->FindObject(getBinName(0, 0, pf))); + TH3D* th3 = reinterpret_cast(tar->FindObject(GetBinName(0, 0, pf))); if (!th3) return 1; //-1; int xind = th3->GetXaxis()->FindBin(htype ? pt : phi); @@ -141,10 +141,10 @@ double GFWWeights::getWeight(double phi, double eta, double vz, double pt, doubl return 1. / weight; return 1; }; -double GFWWeights::getNUA(double phi, double eta, double vz) +double GFWWeights::GetNUA(double phi, double eta, double vz) { if (!fAccInt) - createNUA(); + CreateNUA(); int xind = fAccInt->GetXaxis()->FindBin(phi); int etaind = fAccInt->GetYaxis()->FindBin(eta); int vzind = fAccInt->GetZaxis()->FindBin(vz); @@ -153,10 +153,10 @@ double GFWWeights::getNUA(double phi, double eta, double vz) return 1. / weight; return 1; } -double GFWWeights::getNUE(double pt, double eta, double vz) +double GFWWeights::GetNUE(double pt, double eta, double vz) { if (!fEffInt) - createNUE(); + CreateNUE(); int xind = fEffInt->GetXaxis()->FindBin(pt); int etaind = fEffInt->GetYaxis()->FindBin(eta); int vzind = fEffInt->GetZaxis()->FindBin(vz); @@ -165,7 +165,7 @@ double GFWWeights::getNUE(double pt, double eta, double vz) return 1. / weight; return 1; } -double GFWWeights::findMax(TH3D* inh, int& ix, int& iy, int& iz) +double GFWWeights::FindMax(TH3D* inh, int& ix, int& iy, int& iz) { double maxv = inh->GetBinContent(1, 1, 1); for (int i = 1; i <= inh->GetNbinsX(); i++) @@ -179,10 +179,10 @@ double GFWWeights::findMax(TH3D* inh, int& ix, int& iy, int& iz) } return maxv; }; -void GFWWeights::mcToEfficiency() +void GFWWeights::MCToEfficiency() { if (fW_mcgen->GetEntries() < 1) { - LOGF(info, "MC gen. array empty. This is probably because effs. have been calculated and the generated particle histograms have been cleared out!\n"); + printf("MC gen. array empty. This is probably because effs. have been calculated and the generated particle histograms have been cleared out!\n"); return; } for (int i = 0; i < fW_mcrec->GetEntries(); i++) { @@ -194,7 +194,7 @@ void GFWWeights::mcToEfficiency() } fW_mcgen->Clear(); }; -void GFWWeights::rebinNUA(int nX, int nY, int nZ) +void GFWWeights::RebinNUA(int nX, int nY, int nZ) { if (fW_data->GetEntries() < 1) return; @@ -204,10 +204,10 @@ void GFWWeights::rebinNUA(int nX, int nY, int nZ) reinterpret_cast(fW_data->At(i))->RebinZ(nZ); } }; -void GFWWeights::createNUA(bool IntegrateOverCentAndPt) +void GFWWeights::CreateNUA(bool IntegrateOverCentAndPt) { if (!IntegrateOverCentAndPt) { - LOGF(info, "Method is outdated! NUA is integrated over centrality and pT. Quit now, or the behaviour will be bad\n"); + printf("Method is outdated! NUA is integrated over centrality and pT. Quit now, or the behaviour will be bad\n"); return; } TH1D* h1; @@ -240,7 +240,7 @@ void GFWWeights::createNUA(bool IntegrateOverCentAndPt) return; } }; -TH1D* GFWWeights::getdNdPhi() +TH1D* GFWWeights::GetdNdPhi() { TH3D* temph = reinterpret_cast(fW_data->At(0)->Clone("tempH3")); TH1D* reth = reinterpret_cast(temph->Project3D("x")); @@ -257,10 +257,10 @@ TH1D* GFWWeights::getdNdPhi() } return reth; } -void GFWWeights::createNUE(bool IntegrateOverCentrality) +void GFWWeights::CreateNUE(bool IntegrateOverCentrality) { if (!IntegrateOverCentrality) { - LOGF(info, "Method is outdated! NUE is integrated over centrality. Quit now, or the behaviour will be bad\n"); + printf("Method is outdated! NUE is integrated over centrality. Quit now, or the behaviour will be bad\n"); return; } TH3D* num = 0; @@ -281,7 +281,7 @@ void GFWWeights::createNUE(bool IntegrateOverCentrality) return; } }; -void GFWWeights::readAndMerge(TString filelinks, TString listName, bool addData, bool addRec, bool addGen) +void GFWWeights::ReadAndMerge(TString filelinks, TString listName, bool addData, bool addRec, bool addGen) { FILE* flist = fopen(filelinks.Data(), "r"); char str[150]; @@ -290,7 +290,7 @@ void GFWWeights::readAndMerge(TString filelinks, TString listName, bool addData, nFiles++; rewind(flist); if (nFiles == 0) { - LOGF(info, "No files to read!\n"); + printf("No files to read!\n"); return; } if (!fW_data && addData) { @@ -314,31 +314,31 @@ void GFWWeights::readAndMerge(TString filelinks, TString listName, bool addData, (void)retVal; tf = new TFile(str, "READ"); if (tf->IsZombie()) { - LOGF(warning, "Could not open file %s!\n", str); + printf("Could not open file %s!\n", str); tf->Close(); continue; } TList* tl = reinterpret_cast(tf->Get(listName.Data())); GFWWeights* tw = reinterpret_cast(tl->FindObject(this->GetName())); if (!tw) { - LOGF(warning, "Could not fetch weights object from %s\n", str); + printf("Could not fetch weights object from %s\n", str); tf->Close(); continue; } if (addData) - addArray(fW_data, tw->getDataArray()); + AddArray(fW_data, tw->GetDataArray()); if (addRec) - addArray(fW_mcrec, tw->getRecArray()); + AddArray(fW_mcrec, tw->GetRecArray()); if (addGen) - addArray(fW_mcgen, tw->getGenArray()); + AddArray(fW_mcgen, tw->GetGenArray()); tf->Close(); delete tw; } }; -void GFWWeights::addArray(TObjArray* targ, TObjArray* sour) +void GFWWeights::AddArray(TObjArray* targ, TObjArray* sour) { if (!sour) { - LOGF(info, "Source array does not exist!\n"); + printf("Source array does not exist!\n"); return; } for (int i = 0; i < sour->GetEntries(); i++) { @@ -353,10 +353,10 @@ void GFWWeights::addArray(TObjArray* targ, TObjArray* sour) } } }; -void GFWWeights::overwriteNUA() +void GFWWeights::OverwriteNUA() { if (!fAccInt) - createNUA(); + CreateNUA(); TString ts(fW_data->At(0)->GetName()); TH3D* trash = reinterpret_cast(fW_data->RemoveAt(0)); delete trash; @@ -384,29 +384,29 @@ Long64_t GFWWeights::Merge(TCollection* collist) GFWWeights* l_w = 0; TIter all_w(collist); while ((l_w = (reinterpret_cast(all_w())))) { - addArray(fW_data, l_w->getDataArray()); - addArray(fW_mcrec, l_w->getRecArray()); - addArray(fW_mcgen, l_w->getGenArray()); + AddArray(fW_data, l_w->GetDataArray()); + AddArray(fW_mcrec, l_w->GetRecArray()); + AddArray(fW_mcgen, l_w->GetGenArray()); nmerged++; } return nmerged; }; -TH1D* GFWWeights::getIntegratedEfficiencyHist() +TH1D* GFWWeights::GetIntegratedEfficiencyHist() { if (!fW_mcgen) { - LOGF(warning, "MCGen array does not exist!\n"); + printf("MCGen array does not exist!\n"); return 0; } if (!fW_mcrec) { - LOGF(warning, "MCRec array does not exist!\n"); + printf("MCRec array does not exist!\n"); return 0; } if (!fW_mcgen->GetEntries()) { - LOGF(warning, "MCGen array is empty!\n"); + printf("MCGen array is empty!\n"); return 0; } if (!fW_mcrec->GetEntries()) { - LOGF(warning, "MCRec array is empty!\n"); + printf("MCRec array is empty!\n"); return 0; } TH3D* num = reinterpret_cast(fW_mcrec->At(0)->Clone("Numerator")); @@ -426,25 +426,25 @@ TH1D* GFWWeights::getIntegratedEfficiencyHist() delete den1d; return num1d; } -bool GFWWeights::calculateIntegratedEff() +bool GFWWeights::CalculateIntegratedEff() { if (fIntEff) delete fIntEff; - fIntEff = getIntegratedEfficiencyHist(); + fIntEff = GetIntegratedEfficiencyHist(); if (!fIntEff) { return kFALSE; } fIntEff->SetName("IntegratedEfficiency"); return kTRUE; } -double GFWWeights::getIntegratedEfficiency(double pt) +double GFWWeights::GetIntegratedEfficiency(double pt) { if (!fIntEff) - if (!calculateIntegratedEff()) + if (!CalculateIntegratedEff()) return 0; return fIntEff->GetBinContent(fIntEff->FindBin(pt)); } -TH1D* GFWWeights::getEfficiency(double etamin, double etamax, double vzmin, double vzmax) +TH1D* GFWWeights::GetEfficiency(double etamin, double etamax, double vzmin, double vzmax) { TH3D* num = reinterpret_cast(fW_mcrec->At(0)->Clone("Numerator")); for (int i = 1; i < fW_mcrec->GetEntries(); i++) @@ -470,13 +470,12 @@ TH1D* GFWWeights::getEfficiency(double etamin, double etamax, double vzmin, doub delete den1d; return num1d; } -void GFWWeights::mergeWeights(GFWWeights* other) -{ +void GFWWeights::MergeWeights(GFWWeights* other){ if (!fW_data) { fW_data = new TObjArray(); fW_data->SetName("Weights_Data"); fW_data->SetOwner(kTRUE); } - addArray(fW_data, other->getDataArray()); + AddArray(fW_data, other->GetDataArray()); return; -} +} \ No newline at end of file diff --git a/PWGCF/GenericFramework/Core/GFWWeights.h b/PWGCF/GenericFramework/Core/GFWWeights.h index 8cb8bfc1bb8..deedbf20192 100644 --- a/PWGCF/GenericFramework/Core/GFWWeights.h +++ b/PWGCF/GenericFramework/Core/GFWWeights.h @@ -9,16 +9,8 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file GFWWeights.h -/// \brief Class to store corrections for the Generic Framework -/// \author Emil Gorm Nielsen, NBI, emil.gorm.nielsen@cern.ch - #ifndef PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTS_H_ #define PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTS_H_ - -#include "Framework/Logger.h" -#include "Framework/AnalysisTask.h" - #include "TObjArray.h" #include "TNamed.h" #include "TH3D.h" @@ -28,41 +20,39 @@ #include "TCollection.h" #include "TString.h" -using namespace o2::constants::math; - class GFWWeights : public TNamed { public: GFWWeights(); explicit GFWWeights(const char* name); ~GFWWeights(); - void init(bool AddData = kTRUE, bool AddM = kTRUE); - void fill(double phi, double eta, double vz, double pt, double cent, int htype, double weight = 1); // htype: 0 for data, 1 for mc rec, 2 for mc gen - double getWeight(double phi, double eta, double vz, double pt, double cent, int htype); // htype: 0 for data, 1 for mc rec, 2 for mc gen - double getNUA(double phi, double eta, double vz); // This just fetches correction from integrated NUA, should speed up - double getNUE(double pt, double eta, double vz); // fetches weight from fEffInt - bool isDataFilled() { return fDataFilled; } - bool isMCFilled() { return fMCFilled; } - double findMax(TH3D* inh, int& ix, int& iy, int& iz); - void mcToEfficiency(); - TObjArray* getRecArray() { return fW_mcrec; } - TObjArray* getGenArray() { return fW_mcgen; } - TObjArray* getDataArray() { return fW_data; } - void createNUA(bool IntegrateOverCentAndPt = kTRUE); - void createNUE(bool IntegrateOverCentrality = kTRUE); - TH1D* getIntegratedEfficiencyHist(); - bool calculateIntegratedEff(); - double getIntegratedEfficiency(double pt); - void setDataFilled(bool newval) { fDataFilled = newval; } - void setMCFilled(bool newval) { fMCFilled = newval; } - void readAndMerge(TString filelinks, TString listName = "OutputList", bool addData = kTRUE, bool addRec = kTRUE, bool addGen = kTRUE); - void setPtBins(int Nbins, double* bins); + void Init(bool AddData = kTRUE, bool AddM = kTRUE); + void Fill(double phi, double eta, double vz, double pt, double cent, int htype, double weight = 1); // htype: 0 for data, 1 for mc rec, 2 for mc gen + double GetWeight(double phi, double eta, double vz, double pt, double cent, int htype); // htype: 0 for data, 1 for mc rec, 2 for mc gen + double GetNUA(double phi, double eta, double vz); // This just fetches correction from integrated NUA, should speed up + double GetNUE(double pt, double eta, double vz); // fetches weight from fEffInt + bool IsDataFilled() { return fDataFilled; } + bool IsMCFilled() { return fMCFilled; } + double FindMax(TH3D* inh, int& ix, int& iy, int& iz); + void MCToEfficiency(); + TObjArray* GetRecArray() { return fW_mcrec; } + TObjArray* GetGenArray() { return fW_mcgen; } + TObjArray* GetDataArray() { return fW_data; } + void CreateNUA(bool IntegrateOverCentAndPt = kTRUE); + void CreateNUE(bool IntegrateOverCentrality = kTRUE); + TH1D* GetIntegratedEfficiencyHist(); + bool CalculateIntegratedEff(); + double GetIntegratedEfficiency(double pt); + void SetDataFilled(bool newval) { fDataFilled = newval; } + void SetMCFilled(bool newval) { fMCFilled = newval; } + void ReadAndMerge(TString filelinks, TString listName = "OutputList", bool addData = kTRUE, bool addRec = kTRUE, bool addGen = kTRUE); + void SetPtBins(int Nbins, double* bins); Long64_t Merge(TCollection* collist); - void rebinNUA(int nX = 1, int nY = 2, int nZ = 5); - void overwriteNUA(); - TH1D* getdNdPhi(); - TH1D* getEfficiency(double etamin, double etamax, double vzmin, double vzmax); - void mergeWeights(GFWWeights* other); + void RebinNUA(int nX = 1, int nY = 2, int nZ = 5); + void OverwriteNUA(); + TH1D* GetdNdPhi(); + TH1D* GetEfficiency(double etamin, double etamax, double vzmin, double vzmax); + void MergeWeights(GFWWeights* other); private: bool fDataFilled; @@ -75,8 +65,8 @@ class GFWWeights : public TNamed TH3D* fAccInt; //! int fNbinsPt; //! do not store double* fbinsPt; //! do not store - void addArray(TObjArray* targ, TObjArray* sour); - const char* getBinName(double /*ptv*/, double /*v0mv*/, const char* pf = "") + void AddArray(TObjArray* targ, TObjArray* sour); + const char* GetBinName(double /*ptv*/, double /*v0mv*/, const char* pf = "") { int ptind = 0; // GetPtBin(ptv); int v0mind = 0; // GetV0MBin(v0mv); diff --git a/PWGCF/GenericFramework/Core/GFWWeightsList.cxx b/PWGCF/GenericFramework/Core/GFWWeightsList.cxx index d4b1d02fed4..801fbe68115 100644 --- a/PWGCF/GenericFramework/Core/GFWWeightsList.cxx +++ b/PWGCF/GenericFramework/Core/GFWWeightsList.cxx @@ -53,15 +53,15 @@ void GFWWeightsList::addGFWWeightsByName(const char* weightName, int nPtBins, do return; } GFWWeights* weight = new GFWWeights(weightName); - weight->setPtBins(nPtBins, ptBins); - weight->init(addData, addMC); + weight->SetPtBins(nPtBins, ptBins); + weight->Init(addData, addMC); list->Add(weight); } GFWWeights* GFWWeightsList::getGFWWeightsByName(const char* weightName) { if (!list) { - LOGF(error, "weight list is not initialized\n"); + printf("Error: weight list is not initialized\n"); return nullptr; } return reinterpret_cast(list->FindObject(weightName)); @@ -76,8 +76,8 @@ void GFWWeightsList::addGFWWeightsByRun(int runNumber, int nPtBins, double* ptBi return; } GFWWeights* weight = new GFWWeights(Form("weight_%d", runNumber)); - weight->setPtBins(nPtBins, ptBins); - weight->init(addData, addMC); + weight->SetPtBins(nPtBins, ptBins); + weight->Init(addData, addMC); list->Add(weight); runNumberMap.insert(std::make_pair(runNumber, weight)); } @@ -85,11 +85,11 @@ void GFWWeightsList::addGFWWeightsByRun(int runNumber, int nPtBins, double* ptBi GFWWeights* GFWWeightsList::getGFWWeightsByRun(int runNumber) { if (!list) { - LOGF(error, "weight list is not initialized\n"); + printf("Error: weight list is not initialized\n"); return nullptr; } if (!runNumberMap.contains(runNumber)) { - LOGF(error, "weight for run %d is not found\n", runNumber); + printf("Error: weight for run %d is not found\n", runNumber); return nullptr; } return runNumberMap.at(runNumber); @@ -105,28 +105,26 @@ void GFWWeightsList::addPIDGFWWeightsByName(const char* weightName, int nPtBins, auto it = std::find(ptbins.begin(), ptbins.end(), ptrefup); std::vector refpt(ptbins.begin(), it + 1); - for (auto& type : species) { - if (reinterpret_cast(list->FindObject((static_cast(weightName) + type).c_str()))) { + for(auto & type : species){ + if (reinterpret_cast(list->FindObject((static_cast(weightName)+type).c_str()))) { continue; } - GFWWeights* weight = new GFWWeights(Form("%s", (static_cast(weightName) + type).c_str())); - if (!type.compare("_ref")) - weight->setPtBins(refpt.size() - 1, &(refpt[0])); - else - weight->setPtBins(nPtBins, ptBins); - weight->init(addData, addMC); + GFWWeights* weight = new GFWWeights(Form("%s",(static_cast(weightName)+type).c_str())); + if(!type.compare("_ref")) weight->SetPtBins(refpt.size() - 1, &(refpt[0])); + else weight->SetPtBins(nPtBins, ptBins); + weight->Init(addData, addMC); list->Add(weight); } } GFWWeights* GFWWeightsList::getPIDGFWWeightsByName(const char* weightName, int pidIndex) { - if (static_cast(pidIndex) >= species.size()) + if(static_cast(pidIndex) >= species.size()) return nullptr; if (!list) { - LOGF(error, "weight list is not initialized\n"); + printf("Error: weight list is not initialized\n"); return nullptr; } - return reinterpret_cast(list->FindObject((static_cast(weightName) + species[pidIndex]).c_str())); + return reinterpret_cast(list->FindObject((static_cast(weightName)+species[pidIndex]).c_str())); } void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, double ptrefup, bool addData, bool addMC) { @@ -134,24 +132,21 @@ void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* p init("weightList"); } - if (runNumberPIDMap.contains(runNumber)) - return; + if (runNumberPIDMap.contains(runNumber)) return; std::vector ptbins(ptBins, ptBins + nPtBins + 1); auto it = std::find(ptbins.begin(), ptbins.end(), ptrefup); std::vector refpt(ptbins.begin(), it + 1); std::vector weights; - for (auto& type : species) { + for(auto & type : species){ GFWWeights* weight = new GFWWeights(Form("weight_%d%s", runNumber, type.c_str())); - if (!type.compare("_ref")) - weight->setPtBins(refpt.size() - 1, &(refpt[0])); - else - weight->setPtBins(nPtBins, ptBins); - weight->init(addData, addMC); + if(!type.compare("_ref")) weight->SetPtBins(refpt.size() - 1, &(refpt[0])); + else weight->SetPtBins(nPtBins, ptBins); + weight->Init(addData, addMC); list->Add(weight); weights.push_back(weight); } - LOGF(info, "Adding weights for run %d\n", runNumber); + printf("Adding weights for run %d\n",runNumber); runNumberPIDMap.insert(std::make_pair(runNumber, weights)); return; } @@ -159,17 +154,18 @@ void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* p GFWWeights* GFWWeightsList::getPIDGFWWeightsByRun(int runNumber, int pidIndex) { if (!list) { - LOGF(error, "weight list is not initialized\n"); + printf("Error: weight list is not initialized\n"); return nullptr; } if (!runNumberPIDMap.contains(runNumber)) { - LOGF(error, "PID weights for run %d is not found\n", runNumber); + printf("Error: PID weights for run %d is not found\n", runNumber); return nullptr; } return runNumberPIDMap.at(runNumber)[pidIndex]; } Long64_t GFWWeightsList::Merge(TCollection* collist) { + printf("Merging weight lists!\n"); Long64_t nmerged = 0; if (!list) { list = new TObjArray(); @@ -179,12 +175,12 @@ Long64_t GFWWeightsList::Merge(TCollection* collist) TIter allWeights(collist); GFWWeightsList* lWeight = 0; while ((lWeight = (reinterpret_cast(allWeights())))) { - addArray(list, lWeight->getList()); + AddArray(list, lWeight->getList()); nmerged++; } return nmerged; } -void GFWWeightsList::addArray(TObjArray* target, TObjArray* source) +void GFWWeightsList::AddArray(TObjArray* target, TObjArray* source) { if (!source) { return; @@ -196,7 +192,7 @@ void GFWWeightsList::addArray(TObjArray* target, TObjArray* source) targw = reinterpret_cast(sourw->Clone(sourw->GetName())); target->Add(targw); } else { - targw->mergeWeights(sourw); + targw->MergeWeights(sourw); } } }; diff --git a/PWGCF/GenericFramework/Core/GFWWeightsList.h b/PWGCF/GenericFramework/Core/GFWWeightsList.h index 8de876133d6..f9cc4de0aa9 100644 --- a/PWGCF/GenericFramework/Core/GFWWeightsList.h +++ b/PWGCF/GenericFramework/Core/GFWWeightsList.h @@ -38,21 +38,16 @@ class GFWWeightsList : public TNamed GFWWeights* getPIDGFWWeightsByName(const char* weightName, int pidIndex); void addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, double ptrefup, bool addData = kTRUE, bool addMC = kTRUE); GFWWeights* getPIDGFWWeightsByRun(int runNumber, int pidIndex); - void printRuns() - { - for (auto& el : runNumberPIDMap) - printf("%i\n", el.first); - } + void PrintRuns() { for(auto &el : runNumberPIDMap) printf("%i\n",el.first); } TObjArray* getList() const { return list; } Long64_t Merge(TCollection* collist); - private: TObjArray* list; std::vector species = {"_ref", "_ch", "_pi", "_ka", "_pr"}; //! std::map runNumberMap; - std::map> runNumberPIDMap; - void addArray(TObjArray* target, TObjArray* source); + std::map> runNumberPIDMap; + void AddArray(TObjArray* target, TObjArray* source); ClassDef(GFWWeightsList, 1); }; diff --git a/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx b/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx index 632dff15c85..cf0ac0cbd30 100644 --- a/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx +++ b/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx @@ -80,7 +80,7 @@ GFWCorrConfigs configs; using namespace o2::analysis::genericframework; -struct FlowGenericFramework { +struct GenericFramework { O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 10, "Number of subsamples") O2_DEFINE_CONFIGURABLE(cfgMpar, int, 8, "Highest order of pt-pt correlations") @@ -385,15 +385,11 @@ struct FlowGenericFramework { double wacc = 1; if (cfg.mAcceptance) { if (cfgUsePID) { - if (cfgRunByRunWeights) - wacc = cfg.mAcceptance->getPIDGFWWeightsByRun(lastRun, index)->getNUA(track.phi(), track.eta(), vtxz); - else - wacc = cfg.mAcceptance->getPIDGFWWeightsByName("weight", index)->getNUA(track.phi(), track.eta(), vtxz); + if(cfgRunByRunWeights) wacc = cfg.mAcceptance->getPIDGFWWeightsByRun(lastRun,index)->GetNUA(track.phi(), track.eta(), vtxz); + else wacc = cfg.mAcceptance->getPIDGFWWeightsByName("weight",index)->GetNUA(track.phi(), track.eta(), vtxz); } else { - if (cfgRunByRunWeights) - wacc = cfg.mAcceptance->getGFWWeightsByRun(lastRun)->getNUA(track.phi(), track.eta(), vtxz); - else - wacc = cfg.mAcceptance->getGFWWeightsByName("weight")->getNUA(track.phi(), track.eta(), vtxz); + if(cfgRunByRunWeights) wacc = cfg.mAcceptance->getGFWWeightsByRun(lastRun)->GetNUA(track.phi(), track.eta(), vtxz); + else wacc = cfg.mAcceptance->getGFWWeightsByName("weight")->GetNUA(track.phi(), track.eta(), vtxz); } } return wacc; @@ -516,7 +512,7 @@ struct FlowGenericFramework { if (vtxz > vtxZup || vtxz < vtxZlow) return 0; - if (cfgMultCut) { + if(cfgMultCut){ if (multNTracksPV < fMultPVCutLow->Eval(centrality)) return 0; if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) @@ -580,20 +576,20 @@ struct FlowGenericFramework { bool withinPtRef = (ptreflow < track.pt()) && (track.pt() < ptrefup); // within RF pT range if (cfgRunByRunWeights) { if (withinPtRef && !pid_index) - fWeightList->getPIDGFWWeightsByRun(run, pid_index)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow + fWeightList->getPIDGFWWeightsByRun(run,pid_index)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow if (withinPtPOI) - fWeightList->getPIDGFWWeightsByRun(run, pid_index + 1)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights + fWeightList->getPIDGFWWeightsByRun(run,pid_index+1)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights } else { if (withinPtRef && !pid_index) - fWeightList->getPIDGFWWeightsByName("weight", pid_index)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow + fWeightList->getPIDGFWWeightsByName("weight",pid_index)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow if (withinPtPOI) - fWeightList->getPIDGFWWeightsByName("weight", pid_index + 1)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights + fWeightList->getPIDGFWWeightsByName("weight",pid_index+1)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights } } else { if (cfgRunByRunWeights) - fWeightList->getGFWWeightsByRun(lastRun)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); + fWeightList->getGFWWeightsByRun(lastRun)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); else - fWeightList->getGFWWeightsByName("weight")->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); + fWeightList->getGFWWeightsByName("weight")->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); } return; } @@ -601,9 +597,9 @@ struct FlowGenericFramework { void createRunByRunWeights(int run) { if (cfgUsePID) { - fWeightList->addPIDGFWWeightsByRun(run, fPtAxis->GetNbins(), &ptbinning[0], ptrefup, true, false); + fWeightList->addPIDGFWWeightsByRun(run,fPtAxis->GetNbins(),&ptbinning[0],ptrefup,true,false); } else { - fWeightList->addGFWWeightsByRun(run, fPtAxis->GetNbins(), &ptbinning[0], true, false); + fWeightList->addGFWWeightsByRun(run,fPtAxis->GetNbins(),&ptbinning[0],true,false); } return; } @@ -778,7 +774,7 @@ struct FlowGenericFramework { if (!withinPtPOI && !withinPtRef) return; double waccRef = (dt == kGen) ? 1. : getAcceptance(track, vtxz, 0); - double waccPOI = (dt == kGen) ? 1. : withinPtPOI ? getAcceptance(track, vtxz, pid_index + 1) + double waccPOI = (dt == kGen) ? 1. : withinPtPOI ? getAcceptance(track, vtxz, pid_index+1) : getAcceptance(track, vtxz, 0); // if (withinPtRef && withinPtPOI && pid_index) waccRef = waccPOI; // if particle is both (then it's overlap), override ref with POI @@ -810,7 +806,7 @@ struct FlowGenericFramework { registry.fill(HIST("MCGen/") + HIST(FillTimeName[ft]) + HIST("pt_gen"), track.pt()); } else { double wacc = getAcceptance(track, vtxz, 0); - registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ"), track.phi(), track.eta(), vtxz, (ft == kAfter) ? wacc : 1.0); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ"), track.phi(), track.eta(), vtxz, (ft == kAfter)?wacc:1.0); registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_dcaXY_dcaZ"), track.pt(), track.dcaXY(), track.dcaZ()); if (ft == kAfter) { registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_ref"), track.pt()); @@ -869,7 +865,7 @@ struct FlowGenericFramework { auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; processCollision(collision, tracks, centrality, field, run); } - PROCESS_SWITCH(FlowGenericFramework, processData, "Process analysis for non-derived data", true); + PROCESS_SWITCH(GenericFramework, processData, "Process analysis for non-derived data", true); void processMCReco(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, soa::Filtered> const& tracks, aod::McParticles const&) { @@ -895,7 +891,7 @@ struct FlowGenericFramework { auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; processCollision(collision, tracks, centrality, field, run); } - PROCESS_SWITCH(FlowGenericFramework, processMCReco, "Process analysis for MC reconstructed events", false); + PROCESS_SWITCH(GenericFramework, processMCReco, "Process analysis for MC reconstructed events", false); Filter mcCollFilter = nabs(aod::mccollision::posZ) < cfgVtxZ; void processMCGen(soa::Filtered::iterator const& mcCollision, soa::SmallGroups> const& collisions, aod::McParticles const& particles) @@ -908,7 +904,7 @@ struct FlowGenericFramework { } processCollision(mcCollision, particles, centrality, -999, 0); } - PROCESS_SWITCH(FlowGenericFramework, processMCGen, "Process analysis for MC generated events", false); + PROCESS_SWITCH(GenericFramework, processMCGen, "Process analysis for MC generated events", false); void processRun2(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, GFWTracks const& tracks) { @@ -922,17 +918,17 @@ struct FlowGenericFramework { if (!collision.sel7()) return; const auto centrality = collision.centRun2V0M(); - if (!cfgFillWeights) - loadCorrections(bc); + if(!cfgFillWeights) + loadCorrections(bc); auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; processCollision(collision, tracks, centrality, field, run); } - PROCESS_SWITCH(FlowGenericFramework, processRun2, "Process analysis for Run 2 converted data", false); + PROCESS_SWITCH(GenericFramework, processRun2, "Process analysis for Run 2 converted data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), }; } diff --git a/PWGDQ/Tasks/dqCorrelation.cxx b/PWGDQ/Tasks/dqCorrelation.cxx index 950e82364cb..d2fa3a0dd4b 100644 --- a/PWGDQ/Tasks/dqCorrelation.cxx +++ b/PWGDQ/Tasks/dqCorrelation.cxx @@ -303,7 +303,7 @@ struct DqCumulantFlow { } weff = 1. / weff; if (cfg.mAcceptance) { - wacc = cfg.mAcceptance->getNUA(track.phi(), track.eta(), event.posZ()); + wacc = cfg.mAcceptance->GetNUA(track.phi(), track.eta(), event.posZ()); } else { wacc = 1.0; } diff --git a/PWGDQ/Tasks/dqFlow.cxx b/PWGDQ/Tasks/dqFlow.cxx index d9210685a2e..b5e855d3d13 100644 --- a/PWGDQ/Tasks/dqFlow.cxx +++ b/PWGDQ/Tasks/dqFlow.cxx @@ -189,7 +189,7 @@ struct DQEventQvector { fPtAxis = new TAxis(ptbins, &ptbinning[0]); if (fConfigFillWeights) { // fWeights->SetPtBins(ptbins, &ptbinning[0]); // in the default case, it will accept everything - fWeights->init(true, false); // true for data, false for MC + fWeights->Init(true, false); // true for data, false for MC } // Reference flow @@ -383,7 +383,7 @@ struct DQEventQvector { // Fill weights for Q-vector correction: this should be enabled for a first run to get weights if (fConfigFillWeights) { - fWeights->fill(track.phi(), track.eta(), collision.posZ(), track.pt(), centrality, 0); + fWeights->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), centrality, 0); } if (cfg.mEfficiency) { @@ -396,7 +396,7 @@ struct DQEventQvector { } weff = 1. / weff; if (cfg.mAcceptance) { - wacc = cfg.mAcceptance->getNUA(track.phi(), track.eta(), collision.posZ()); + wacc = cfg.mAcceptance->GetNUA(track.phi(), track.eta(), collision.posZ()); } else { wacc = 1.0; } From 32d4445f0c55e79268b6bcd1a721ac466d89237a Mon Sep 17 00:00:00 2001 From: Emil Gorm Nielsen Date: Thu, 30 Jan 2025 14:49:29 +0100 Subject: [PATCH 6/6] O2 Linter --- PWGCF/Flow/Tasks/FlowGFWPbPb.cxx | 12 +- PWGCF/Flow/Tasks/flowAnalysisGF.cxx | 8 +- PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx | 32 +++--- PWGCF/Flow/Tasks/flowRunbyRun.cxx | 4 +- PWGCF/Flow/Tasks/flowTask.cxx | 20 ++-- PWGCF/GenericFramework/Core/GFWWeights.cxx | 105 +++++++++--------- PWGCF/GenericFramework/Core/GFWWeights.h | 66 ++++++----- .../GenericFramework/Core/GFWWeightsList.cxx | 60 +++++----- PWGCF/GenericFramework/Core/GFWWeightsList.h | 11 +- .../Tasks/flowGenericFramework.cxx | 50 +++++---- PWGDQ/Tasks/dqCorrelation.cxx | 2 +- PWGDQ/Tasks/dqFlow.cxx | 6 +- 12 files changed, 200 insertions(+), 176 deletions(-) diff --git a/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx b/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx index 39cddafbd2a..12fbf2f7538 100644 --- a/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx +++ b/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx @@ -249,8 +249,8 @@ struct FlowGFWPbPb { fPtAxis = new TAxis(nPtBins, PtBins); if (cfgOutputNUAWeights) { - fWeights->SetPtBins(nPtBins, PtBins); - fWeights->Init(true, false); + fWeights->setPtBins(nPtBins, PtBins); + fWeights->init(true, false); } // add in FlowContainer to Get boostrap sample automatically @@ -384,7 +384,7 @@ struct FlowGFWPbPb { return false; weight_nue = 1. / eff; if (mAcceptance) - weight_nua = mAcceptance->GetNUA(phi, eta, vtxz); + weight_nua = mAcceptance->getNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -510,8 +510,8 @@ struct FlowGFWPbPb { Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::dcaXY) < cfgCutDCAxy); - using Colls = soa::Filtered>; // collisions filter - using aodTracks = soa::Filtered>; // tracks filter + using Colls = soa::Filtered>; // collisions filter + using aodTracks = soa::Filtered>; // tracks filter void process(Colls::iterator const& collision, aod::BCsWithTimestamps const&, aodTracks const& tracks) { @@ -590,7 +590,7 @@ struct FlowGFWPbPb { if (cfgUseAdditionalTrackCut && !trackSelected(track, Magnetfield)) continue; if (cfgOutputNUAWeights) - fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), centrality, 0); + fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), centrality, 0); if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz)) continue; diff --git a/PWGCF/Flow/Tasks/flowAnalysisGF.cxx b/PWGCF/Flow/Tasks/flowAnalysisGF.cxx index e6e60d89b8c..08e223befb6 100644 --- a/PWGCF/Flow/Tasks/flowAnalysisGF.cxx +++ b/PWGCF/Flow/Tasks/flowAnalysisGF.cxx @@ -214,8 +214,8 @@ struct flowAnalysisGF { fPtAxis = new TAxis(ptbins, &ptbinning[0]); if (cfgFillWeights) { - fWeights->SetPtBins(ptbins, &ptbinning[0]); - fWeights->Init(true, false); + fWeights->setPtBins(ptbins, &ptbinning[0]); + fWeights->init(true, false); } if (doprocessMCGen) { @@ -388,7 +388,7 @@ struct flowAnalysisGF { return false; weight_nue = 1. / eff; if (cfg.mAcceptance) - weight_nua = cfg.mAcceptance->GetNUA(phi, eta, vtxz); + weight_nua = cfg.mAcceptance->getNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -582,7 +582,7 @@ struct flowAnalysisGF { return false; if (cfgFillWeights) - fWeights->Fill(particle.phi(), particle.eta(), vtxz, particle.pt(), centrality, 0); + fWeights->fill(particle.phi(), particle.eta(), vtxz, particle.pt(), centrality, 0); if (!setCurrentParticleWeights(weff, wacc, particle.phi(), particle.eta(), particle.pt(), vtxz)) return false; diff --git a/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx b/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx index 7d62084098a..a5f0bdc0fbb 100644 --- a/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx +++ b/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx @@ -376,16 +376,16 @@ struct FlowGFWOmegaXi { // fWeight output if (cfgOutputNUAWeights) { - fWeightsREF->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsREF->Init(true, false); - fWeightsK0s->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsK0s->Init(true, false); - fWeightsLambda->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsLambda->Init(true, false); - fWeightsXi->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsXi->Init(true, false); - fWeightsOmega->SetPtBins(nPtBins, &(axisPt.binEdges)[0]); - fWeightsOmega->Init(true, false); + fWeightsREF->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsREF->init(true, false); + fWeightsK0s->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsK0s->init(true, false); + fWeightsLambda->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsLambda->init(true, false); + fWeightsXi->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsXi->init(true, false); + fWeightsOmega->setPtBins(nPtBins, &(axisPt.binEdges)[0]); + fWeightsOmega->init(true, false); } } @@ -565,7 +565,7 @@ struct FlowGFWOmegaXi { return false; weight_nue = 1. / eff; if (mAcceptance.size() == 5) - weight_nua = mAcceptance[ispecies]->GetNUA(track.phi(), track.eta(), vtxz); + weight_nua = mAcceptance[ispecies]->getNUA(track.phi(), track.eta(), vtxz); else weight_nua = 1; return true; @@ -681,7 +681,7 @@ struct FlowGFWOmegaXi { fGFW->Fill(track.eta(), ptbin, track.phi(), wacc * weff, 32); } if (cfgOutputNUAWeights) - fWeightsREF->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeightsREF->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } // fill GFW of V0 flow for (const auto& v0 : V0s) { @@ -767,7 +767,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("hEtaPhiVtxzPOIK0s"), v0.phi(), v0.eta(), vtxz, wacc); fGFW->Fill(v0.eta(), fV0PtAxis->FindBin(v0.pt()) - 1 + ((fK0sMass->FindBin(v0.mK0Short()) - 1) * nV0PtBins), v0.phi(), wacc * weff, 8); if (cfgOutputNUAWeights) - fWeightsK0s->Fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); + fWeightsK0s->fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); } if (isLambda) { candNum[1] = candNum[1] + 1; @@ -775,7 +775,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("hEtaPhiVtxzPOILambda"), v0.phi(), v0.eta(), vtxz, wacc); fGFW->Fill(v0.eta(), fV0PtAxis->FindBin(v0.pt()) - 1 + ((fLambdaMass->FindBin(v0.mLambda()) - 1) * nV0PtBins), v0.phi(), wacc * weff, 16); if (cfgOutputNUAWeights) - fWeightsLambda->Fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); + fWeightsLambda->fill(v0.phi(), v0.eta(), vtxz, v0.pt(), cent, 0); } } // fill GFW of casc flow @@ -861,7 +861,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("InvMassOmega"), casc.pt(), casc.mOmega(), casc.eta(), cent); fGFW->Fill(casc.eta(), fXiPtAxis->FindBin(casc.pt()) - 1 + ((fOmegaMass->FindBin(casc.mOmega()) - 1) * nXiPtBins), casc.phi(), wacc * weff, 4); if (cfgOutputNUAWeights) - fWeightsOmega->Fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); + fWeightsOmega->fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); } if (isXi) { candNum[2] = candNum[2] + 1; @@ -869,7 +869,7 @@ struct FlowGFWOmegaXi { registry.fill(HIST("InvMassXi"), casc.pt(), casc.mXi(), casc.eta(), cent); fGFW->Fill(casc.eta(), fXiPtAxis->FindBin(casc.pt()) - 1 + ((fXiMass->FindBin(casc.mXi()) - 1) * nXiPtBins), casc.phi(), wacc * weff, 2); if (cfgOutputNUAWeights) - fWeightsXi->Fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); + fWeightsXi->fill(casc.phi(), casc.eta(), vtxz, casc.pt(), cent, 0); } } for (int i = 0; i < 4; i++) { diff --git a/PWGCF/Flow/Tasks/flowRunbyRun.cxx b/PWGCF/Flow/Tasks/flowRunbyRun.cxx index 03c596c9d2a..7a92e90494e 100644 --- a/PWGCF/Flow/Tasks/flowRunbyRun.cxx +++ b/PWGCF/Flow/Tasks/flowRunbyRun.cxx @@ -278,7 +278,7 @@ struct FlowRunbyRun { LOGF(fatal, "Could not find the weight for run %d", runNumber); return; } - weight->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); + weight->fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); } } else { GFWWeights* weight = fGFWWeightsList->getGFWWeightsByRun(runNumber); @@ -286,7 +286,7 @@ struct FlowRunbyRun { LOGF(fatal, "Could not find the weight for run %d", runNumber); return; } - weight->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); + weight->fill(track.phi(), track.eta(), collision.posZ(), track.pt(), cent, 0); } } diff --git a/PWGCF/Flow/Tasks/flowTask.cxx b/PWGCF/Flow/Tasks/flowTask.cxx index 19c0b7418bd..d39f4b802a2 100644 --- a/PWGCF/Flow/Tasks/flowTask.cxx +++ b/PWGCF/Flow/Tasks/flowTask.cxx @@ -254,8 +254,8 @@ struct FlowTask { fPtAxis = new TAxis(nPtBins, ptBins); if (cfgOutputNUAWeights) { - fWeights->SetPtBins(nPtBins, ptBins); - fWeights->Init(true, false); + fWeights->setPtBins(nPtBins, ptBins); + fWeights->init(true, false); } TList* groupNUAWeightlist = new TList(); @@ -271,8 +271,8 @@ struct FlowTask { else groupweight = new GFWWeights(Form("groupweight_last")); - groupweight->SetPtBins(nPtBins, ptBins); - groupweight->Init(true, false); + groupweight->setPtBins(nPtBins, ptBins); + groupweight->init(true, false); groupNUAWeightlist->Add(groupweight); std::shared_ptr sharePtrGroupWeight(groupweight); groupNUAWeightPtr[i] = sharePtrGroupWeight; @@ -566,14 +566,14 @@ struct FlowTask { weight_nue = 1. / eff; if (cfgAcceptanceGroupUse) { if (mGroupAcceptanceList && mGroupAcceptanceList->At(groupNUAIndex)) { - weight_nua = reinterpret_cast(mGroupAcceptanceList->At(groupNUAIndex))->GetNUA(phi, eta, vtxz); + weight_nua = reinterpret_cast(mGroupAcceptanceList->At(groupNUAIndex))->getNUA(phi, eta, vtxz); } else { weight_nua = 1; } return true; } if (mAcceptance) - weight_nua = mAcceptance->GetNUA(phi, eta, vtxz); + weight_nua = mAcceptance->getNUA(phi, eta, vtxz); else weight_nua = 1; return true; @@ -790,18 +790,18 @@ struct FlowTask { if (cfgOutputNUAWeights) { if (cfgOutputNUAWeightsRefPt) { if (withinPtRef) - fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } else { - fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeights->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } if (cfgOutputGroupNUAWeights) { if (cfgOutputNUAWeightsRefPt) { if (withinPtRef) { - groupNUAWeightPtr[groupNUAIndex]->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + groupNUAWeightPtr[groupNUAIndex]->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } else { - groupNUAWeightPtr[groupNUAIndex]->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + groupNUAWeightPtr[groupNUAIndex]->fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); } } if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz, groupNUAIndex)) diff --git a/PWGCF/GenericFramework/Core/GFWWeights.cxx b/PWGCF/GenericFramework/Core/GFWWeights.cxx index e0f5610bd36..cbc5acaa0bb 100644 --- a/PWGCF/GenericFramework/Core/GFWWeights.cxx +++ b/PWGCF/GenericFramework/Core/GFWWeights.cxx @@ -10,7 +10,7 @@ // or submit itself to any jurisdiction. #include "GFWWeights.h" -#include "TMath.h" + GFWWeights::GFWWeights() : TNamed("", ""), fDataFilled(kFALSE), fMCFilled(kFALSE), @@ -44,7 +44,7 @@ GFWWeights::~GFWWeights() if (fbinsPt) delete[] fbinsPt; }; -void GFWWeights::SetPtBins(int Nbins, double* bins) +void GFWWeights::setPtBins(int Nbins, double* bins) { if (fbinsPt) delete[] fbinsPt; @@ -53,7 +53,7 @@ void GFWWeights::SetPtBins(int Nbins, double* bins) for (int i = 0; i <= fNbinsPt; ++i) fbinsPt[i] = bins[i]; }; -void GFWWeights::Init(bool AddData, bool AddMC) +void GFWWeights::init(bool AddData, bool AddMC) { if (!fbinsPt) { // If pT bins not initialized, set to default (-1 to 1e6) to accept everything fNbinsPt = 1; @@ -65,8 +65,8 @@ void GFWWeights::Init(bool AddData, bool AddMC) fW_data = new TObjArray(); fW_data->SetName("GFWWeights_Data"); fW_data->SetOwner(kTRUE); - const char* tnd = GetBinName(0, 0, Form("data_%s", this->GetName())); - fW_data->Add(new TH3D(tnd, ";#varphi;#eta;v_{z}", 60, 0, TMath::TwoPi(), 64, -1.6, 1.6, 40, -10, 10)); + const char* tnd = getBinName(0, 0, Form("data_%s", this->GetName())); + fW_data->Add(new TH3D(tnd, ";#varphi;#eta;v_{z}", 60, 0, TwoPI, 64, -1.6, 1.6, 40, -10, 10)); fDataFilled = kTRUE; } if (AddMC) { @@ -76,8 +76,8 @@ void GFWWeights::Init(bool AddData, bool AddMC) fW_mcgen->SetName("GFWWeights_MCGen"); fW_mcrec->SetOwner(kTRUE); fW_mcgen->SetOwner(kTRUE); - const char* tnr = GetBinName(0, 0, "mcrec"); // all integrated over cent. anyway - const char* tng = GetBinName(0, 0, "mcgen"); // all integrated over cent. anyway + const char* tnr = getBinName(0, 0, "mcrec"); // all integrated over cent. anyway + const char* tng = getBinName(0, 0, "mcgen"); // all integrated over cent. anyway fW_mcrec->Add(new TH3D(tnr, ";#it{p}_{T};#eta;v_{z}", fNbinsPt, 0, 20, 64, -1.6, 1.6, 40, -10, 10)); fW_mcgen->Add(new TH3D(tng, ";#it{p}_{T};#eta;v_{z}", fNbinsPt, 0, 20, 64, -1.6, 1.6, 40, -10, 10)); reinterpret_cast(fW_mcrec->At(fW_mcrec->GetEntries() - 1))->GetXaxis()->Set(fNbinsPt, fbinsPt); @@ -86,7 +86,7 @@ void GFWWeights::Init(bool AddData, bool AddMC) } }; -void GFWWeights::Fill(double phi, double eta, double vz, double pt, double /*cent*/, int htype, double weight) +void GFWWeights::fill(double phi, double eta, double vz, double pt, double /*cent*/, int htype, double weight) { TObjArray* tar = 0; const char* pf = ""; @@ -104,15 +104,15 @@ void GFWWeights::Fill(double phi, double eta, double vz, double pt, double /*cen } if (!tar) return; - TH3D* th3 = reinterpret_cast(tar->FindObject(GetBinName(0, 0, pf))); // pT bin 0, V0M bin 0, since all integrated + TH3D* th3 = reinterpret_cast(tar->FindObject(getBinName(0, 0, pf))); // pT bin 0, V0M bin 0, since all integrated if (!th3) { if (!htype) - tar->Add(new TH3D(GetBinName(0, 0, pf), ";#varphi;#eta;v_{z}", 60, 0, TMath::TwoPi(), 64, -1.6, 1.6, 40, -10, 10)); // 0,0 since all integrated + tar->Add(new TH3D(getBinName(0, 0, pf), ";#varphi;#eta;v_{z}", 60, 0, TwoPI, 64, -1.6, 1.6, 40, -10, 10)); // 0,0 since all integrated th3 = reinterpret_cast(tar->At(tar->GetEntries() - 1)); } th3->Fill(htype ? pt : phi, eta, vz, weight); }; -double GFWWeights::GetWeight(double phi, double eta, double vz, double pt, double /*cent*/, int htype) +double GFWWeights::getWeight(double phi, double eta, double vz, double pt, double /*cent*/, int htype) { TObjArray* tar = 0; const char* pf = ""; @@ -130,7 +130,7 @@ double GFWWeights::GetWeight(double phi, double eta, double vz, double pt, doubl } if (!tar) return 1; - TH3D* th3 = reinterpret_cast(tar->FindObject(GetBinName(0, 0, pf))); + TH3D* th3 = reinterpret_cast(tar->FindObject(getBinName(0, 0, pf))); if (!th3) return 1; //-1; int xind = th3->GetXaxis()->FindBin(htype ? pt : phi); @@ -141,10 +141,10 @@ double GFWWeights::GetWeight(double phi, double eta, double vz, double pt, doubl return 1. / weight; return 1; }; -double GFWWeights::GetNUA(double phi, double eta, double vz) +double GFWWeights::getNUA(double phi, double eta, double vz) { if (!fAccInt) - CreateNUA(); + createNUA(); int xind = fAccInt->GetXaxis()->FindBin(phi); int etaind = fAccInt->GetYaxis()->FindBin(eta); int vzind = fAccInt->GetZaxis()->FindBin(vz); @@ -153,10 +153,10 @@ double GFWWeights::GetNUA(double phi, double eta, double vz) return 1. / weight; return 1; } -double GFWWeights::GetNUE(double pt, double eta, double vz) +double GFWWeights::getNUE(double pt, double eta, double vz) { if (!fEffInt) - CreateNUE(); + createNUE(); int xind = fEffInt->GetXaxis()->FindBin(pt); int etaind = fEffInt->GetYaxis()->FindBin(eta); int vzind = fEffInt->GetZaxis()->FindBin(vz); @@ -165,7 +165,7 @@ double GFWWeights::GetNUE(double pt, double eta, double vz) return 1. / weight; return 1; } -double GFWWeights::FindMax(TH3D* inh, int& ix, int& iy, int& iz) +double GFWWeights::findMax(TH3D* inh, int& ix, int& iy, int& iz) { double maxv = inh->GetBinContent(1, 1, 1); for (int i = 1; i <= inh->GetNbinsX(); i++) @@ -179,10 +179,10 @@ double GFWWeights::FindMax(TH3D* inh, int& ix, int& iy, int& iz) } return maxv; }; -void GFWWeights::MCToEfficiency() +void GFWWeights::mcToEfficiency() { if (fW_mcgen->GetEntries() < 1) { - printf("MC gen. array empty. This is probably because effs. have been calculated and the generated particle histograms have been cleared out!\n"); + LOGF(info, "MC gen. array empty. This is probably because effs. have been calculated and the generated particle histograms have been cleared out!\n"); return; } for (int i = 0; i < fW_mcrec->GetEntries(); i++) { @@ -194,7 +194,7 @@ void GFWWeights::MCToEfficiency() } fW_mcgen->Clear(); }; -void GFWWeights::RebinNUA(int nX, int nY, int nZ) +void GFWWeights::rebinNUA(int nX, int nY, int nZ) { if (fW_data->GetEntries() < 1) return; @@ -204,10 +204,10 @@ void GFWWeights::RebinNUA(int nX, int nY, int nZ) reinterpret_cast(fW_data->At(i))->RebinZ(nZ); } }; -void GFWWeights::CreateNUA(bool IntegrateOverCentAndPt) +void GFWWeights::createNUA(bool IntegrateOverCentAndPt) { if (!IntegrateOverCentAndPt) { - printf("Method is outdated! NUA is integrated over centrality and pT. Quit now, or the behaviour will be bad\n"); + LOGF(info, "Method is outdated! NUA is integrated over centrality and pT. Quit now, or the behaviour will be bad\n"); return; } TH1D* h1; @@ -240,7 +240,7 @@ void GFWWeights::CreateNUA(bool IntegrateOverCentAndPt) return; } }; -TH1D* GFWWeights::GetdNdPhi() +TH1D* GFWWeights::getdNdPhi() { TH3D* temph = reinterpret_cast(fW_data->At(0)->Clone("tempH3")); TH1D* reth = reinterpret_cast(temph->Project3D("x")); @@ -257,10 +257,10 @@ TH1D* GFWWeights::GetdNdPhi() } return reth; } -void GFWWeights::CreateNUE(bool IntegrateOverCentrality) +void GFWWeights::createNUE(bool IntegrateOverCentrality) { if (!IntegrateOverCentrality) { - printf("Method is outdated! NUE is integrated over centrality. Quit now, or the behaviour will be bad\n"); + LOGF(info, "Method is outdated! NUE is integrated over centrality. Quit now, or the behaviour will be bad\n"); return; } TH3D* num = 0; @@ -281,7 +281,7 @@ void GFWWeights::CreateNUE(bool IntegrateOverCentrality) return; } }; -void GFWWeights::ReadAndMerge(TString filelinks, TString listName, bool addData, bool addRec, bool addGen) +void GFWWeights::readAndMerge(TString filelinks, TString listName, bool addData, bool addRec, bool addGen) { FILE* flist = fopen(filelinks.Data(), "r"); char str[150]; @@ -290,7 +290,7 @@ void GFWWeights::ReadAndMerge(TString filelinks, TString listName, bool addData, nFiles++; rewind(flist); if (nFiles == 0) { - printf("No files to read!\n"); + LOGF(info, "No files to read!\n"); return; } if (!fW_data && addData) { @@ -314,31 +314,31 @@ void GFWWeights::ReadAndMerge(TString filelinks, TString listName, bool addData, (void)retVal; tf = new TFile(str, "READ"); if (tf->IsZombie()) { - printf("Could not open file %s!\n", str); + LOGF(warning, "Could not open file %s!\n", str); tf->Close(); continue; } TList* tl = reinterpret_cast(tf->Get(listName.Data())); GFWWeights* tw = reinterpret_cast(tl->FindObject(this->GetName())); if (!tw) { - printf("Could not fetch weights object from %s\n", str); + LOGF(warning, "Could not fetch weights object from %s\n", str); tf->Close(); continue; } if (addData) - AddArray(fW_data, tw->GetDataArray()); + addArray(fW_data, tw->getDataArray()); if (addRec) - AddArray(fW_mcrec, tw->GetRecArray()); + addArray(fW_mcrec, tw->getRecArray()); if (addGen) - AddArray(fW_mcgen, tw->GetGenArray()); + addArray(fW_mcgen, tw->getGenArray()); tf->Close(); delete tw; } }; -void GFWWeights::AddArray(TObjArray* targ, TObjArray* sour) +void GFWWeights::addArray(TObjArray* targ, TObjArray* sour) { if (!sour) { - printf("Source array does not exist!\n"); + LOGF(info, "Source array does not exist!\n"); return; } for (int i = 0; i < sour->GetEntries(); i++) { @@ -353,10 +353,10 @@ void GFWWeights::AddArray(TObjArray* targ, TObjArray* sour) } } }; -void GFWWeights::OverwriteNUA() +void GFWWeights::overwriteNUA() { if (!fAccInt) - CreateNUA(); + createNUA(); TString ts(fW_data->At(0)->GetName()); TH3D* trash = reinterpret_cast(fW_data->RemoveAt(0)); delete trash; @@ -384,29 +384,29 @@ Long64_t GFWWeights::Merge(TCollection* collist) GFWWeights* l_w = 0; TIter all_w(collist); while ((l_w = (reinterpret_cast(all_w())))) { - AddArray(fW_data, l_w->GetDataArray()); - AddArray(fW_mcrec, l_w->GetRecArray()); - AddArray(fW_mcgen, l_w->GetGenArray()); + addArray(fW_data, l_w->getDataArray()); + addArray(fW_mcrec, l_w->getRecArray()); + addArray(fW_mcgen, l_w->getGenArray()); nmerged++; } return nmerged; }; -TH1D* GFWWeights::GetIntegratedEfficiencyHist() +TH1D* GFWWeights::getIntegratedEfficiencyHist() { if (!fW_mcgen) { - printf("MCGen array does not exist!\n"); + LOGF(warning, "MCGen array does not exist!\n"); return 0; } if (!fW_mcrec) { - printf("MCRec array does not exist!\n"); + LOGF(warning, "MCRec array does not exist!\n"); return 0; } if (!fW_mcgen->GetEntries()) { - printf("MCGen array is empty!\n"); + LOGF(warning, "MCGen array is empty!\n"); return 0; } if (!fW_mcrec->GetEntries()) { - printf("MCRec array is empty!\n"); + LOGF(warning, "MCRec array is empty!\n"); return 0; } TH3D* num = reinterpret_cast(fW_mcrec->At(0)->Clone("Numerator")); @@ -426,25 +426,25 @@ TH1D* GFWWeights::GetIntegratedEfficiencyHist() delete den1d; return num1d; } -bool GFWWeights::CalculateIntegratedEff() +bool GFWWeights::calculateIntegratedEff() { if (fIntEff) delete fIntEff; - fIntEff = GetIntegratedEfficiencyHist(); + fIntEff = getIntegratedEfficiencyHist(); if (!fIntEff) { return kFALSE; } fIntEff->SetName("IntegratedEfficiency"); return kTRUE; } -double GFWWeights::GetIntegratedEfficiency(double pt) +double GFWWeights::getIntegratedEfficiency(double pt) { if (!fIntEff) - if (!CalculateIntegratedEff()) + if (!calculateIntegratedEff()) return 0; return fIntEff->GetBinContent(fIntEff->FindBin(pt)); } -TH1D* GFWWeights::GetEfficiency(double etamin, double etamax, double vzmin, double vzmax) +TH1D* GFWWeights::getEfficiency(double etamin, double etamax, double vzmin, double vzmax) { TH3D* num = reinterpret_cast(fW_mcrec->At(0)->Clone("Numerator")); for (int i = 1; i < fW_mcrec->GetEntries(); i++) @@ -470,12 +470,13 @@ TH1D* GFWWeights::GetEfficiency(double etamin, double etamax, double vzmin, doub delete den1d; return num1d; } -void GFWWeights::MergeWeights(GFWWeights* other){ +void GFWWeights::mergeWeights(GFWWeights* other) +{ if (!fW_data) { fW_data = new TObjArray(); fW_data->SetName("Weights_Data"); fW_data->SetOwner(kTRUE); } - AddArray(fW_data, other->GetDataArray()); + addArray(fW_data, other->getDataArray()); return; -} \ No newline at end of file +} diff --git a/PWGCF/GenericFramework/Core/GFWWeights.h b/PWGCF/GenericFramework/Core/GFWWeights.h index deedbf20192..8cb8bfc1bb8 100644 --- a/PWGCF/GenericFramework/Core/GFWWeights.h +++ b/PWGCF/GenericFramework/Core/GFWWeights.h @@ -9,8 +9,16 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file GFWWeights.h +/// \brief Class to store corrections for the Generic Framework +/// \author Emil Gorm Nielsen, NBI, emil.gorm.nielsen@cern.ch + #ifndef PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTS_H_ #define PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTS_H_ + +#include "Framework/Logger.h" +#include "Framework/AnalysisTask.h" + #include "TObjArray.h" #include "TNamed.h" #include "TH3D.h" @@ -20,39 +28,41 @@ #include "TCollection.h" #include "TString.h" +using namespace o2::constants::math; + class GFWWeights : public TNamed { public: GFWWeights(); explicit GFWWeights(const char* name); ~GFWWeights(); - void Init(bool AddData = kTRUE, bool AddM = kTRUE); - void Fill(double phi, double eta, double vz, double pt, double cent, int htype, double weight = 1); // htype: 0 for data, 1 for mc rec, 2 for mc gen - double GetWeight(double phi, double eta, double vz, double pt, double cent, int htype); // htype: 0 for data, 1 for mc rec, 2 for mc gen - double GetNUA(double phi, double eta, double vz); // This just fetches correction from integrated NUA, should speed up - double GetNUE(double pt, double eta, double vz); // fetches weight from fEffInt - bool IsDataFilled() { return fDataFilled; } - bool IsMCFilled() { return fMCFilled; } - double FindMax(TH3D* inh, int& ix, int& iy, int& iz); - void MCToEfficiency(); - TObjArray* GetRecArray() { return fW_mcrec; } - TObjArray* GetGenArray() { return fW_mcgen; } - TObjArray* GetDataArray() { return fW_data; } - void CreateNUA(bool IntegrateOverCentAndPt = kTRUE); - void CreateNUE(bool IntegrateOverCentrality = kTRUE); - TH1D* GetIntegratedEfficiencyHist(); - bool CalculateIntegratedEff(); - double GetIntegratedEfficiency(double pt); - void SetDataFilled(bool newval) { fDataFilled = newval; } - void SetMCFilled(bool newval) { fMCFilled = newval; } - void ReadAndMerge(TString filelinks, TString listName = "OutputList", bool addData = kTRUE, bool addRec = kTRUE, bool addGen = kTRUE); - void SetPtBins(int Nbins, double* bins); + void init(bool AddData = kTRUE, bool AddM = kTRUE); + void fill(double phi, double eta, double vz, double pt, double cent, int htype, double weight = 1); // htype: 0 for data, 1 for mc rec, 2 for mc gen + double getWeight(double phi, double eta, double vz, double pt, double cent, int htype); // htype: 0 for data, 1 for mc rec, 2 for mc gen + double getNUA(double phi, double eta, double vz); // This just fetches correction from integrated NUA, should speed up + double getNUE(double pt, double eta, double vz); // fetches weight from fEffInt + bool isDataFilled() { return fDataFilled; } + bool isMCFilled() { return fMCFilled; } + double findMax(TH3D* inh, int& ix, int& iy, int& iz); + void mcToEfficiency(); + TObjArray* getRecArray() { return fW_mcrec; } + TObjArray* getGenArray() { return fW_mcgen; } + TObjArray* getDataArray() { return fW_data; } + void createNUA(bool IntegrateOverCentAndPt = kTRUE); + void createNUE(bool IntegrateOverCentrality = kTRUE); + TH1D* getIntegratedEfficiencyHist(); + bool calculateIntegratedEff(); + double getIntegratedEfficiency(double pt); + void setDataFilled(bool newval) { fDataFilled = newval; } + void setMCFilled(bool newval) { fMCFilled = newval; } + void readAndMerge(TString filelinks, TString listName = "OutputList", bool addData = kTRUE, bool addRec = kTRUE, bool addGen = kTRUE); + void setPtBins(int Nbins, double* bins); Long64_t Merge(TCollection* collist); - void RebinNUA(int nX = 1, int nY = 2, int nZ = 5); - void OverwriteNUA(); - TH1D* GetdNdPhi(); - TH1D* GetEfficiency(double etamin, double etamax, double vzmin, double vzmax); - void MergeWeights(GFWWeights* other); + void rebinNUA(int nX = 1, int nY = 2, int nZ = 5); + void overwriteNUA(); + TH1D* getdNdPhi(); + TH1D* getEfficiency(double etamin, double etamax, double vzmin, double vzmax); + void mergeWeights(GFWWeights* other); private: bool fDataFilled; @@ -65,8 +75,8 @@ class GFWWeights : public TNamed TH3D* fAccInt; //! int fNbinsPt; //! do not store double* fbinsPt; //! do not store - void AddArray(TObjArray* targ, TObjArray* sour); - const char* GetBinName(double /*ptv*/, double /*v0mv*/, const char* pf = "") + void addArray(TObjArray* targ, TObjArray* sour); + const char* getBinName(double /*ptv*/, double /*v0mv*/, const char* pf = "") { int ptind = 0; // GetPtBin(ptv); int v0mind = 0; // GetV0MBin(v0mv); diff --git a/PWGCF/GenericFramework/Core/GFWWeightsList.cxx b/PWGCF/GenericFramework/Core/GFWWeightsList.cxx index 801fbe68115..d4b1d02fed4 100644 --- a/PWGCF/GenericFramework/Core/GFWWeightsList.cxx +++ b/PWGCF/GenericFramework/Core/GFWWeightsList.cxx @@ -53,15 +53,15 @@ void GFWWeightsList::addGFWWeightsByName(const char* weightName, int nPtBins, do return; } GFWWeights* weight = new GFWWeights(weightName); - weight->SetPtBins(nPtBins, ptBins); - weight->Init(addData, addMC); + weight->setPtBins(nPtBins, ptBins); + weight->init(addData, addMC); list->Add(weight); } GFWWeights* GFWWeightsList::getGFWWeightsByName(const char* weightName) { if (!list) { - printf("Error: weight list is not initialized\n"); + LOGF(error, "weight list is not initialized\n"); return nullptr; } return reinterpret_cast(list->FindObject(weightName)); @@ -76,8 +76,8 @@ void GFWWeightsList::addGFWWeightsByRun(int runNumber, int nPtBins, double* ptBi return; } GFWWeights* weight = new GFWWeights(Form("weight_%d", runNumber)); - weight->SetPtBins(nPtBins, ptBins); - weight->Init(addData, addMC); + weight->setPtBins(nPtBins, ptBins); + weight->init(addData, addMC); list->Add(weight); runNumberMap.insert(std::make_pair(runNumber, weight)); } @@ -85,11 +85,11 @@ void GFWWeightsList::addGFWWeightsByRun(int runNumber, int nPtBins, double* ptBi GFWWeights* GFWWeightsList::getGFWWeightsByRun(int runNumber) { if (!list) { - printf("Error: weight list is not initialized\n"); + LOGF(error, "weight list is not initialized\n"); return nullptr; } if (!runNumberMap.contains(runNumber)) { - printf("Error: weight for run %d is not found\n", runNumber); + LOGF(error, "weight for run %d is not found\n", runNumber); return nullptr; } return runNumberMap.at(runNumber); @@ -105,26 +105,28 @@ void GFWWeightsList::addPIDGFWWeightsByName(const char* weightName, int nPtBins, auto it = std::find(ptbins.begin(), ptbins.end(), ptrefup); std::vector refpt(ptbins.begin(), it + 1); - for(auto & type : species){ - if (reinterpret_cast(list->FindObject((static_cast(weightName)+type).c_str()))) { + for (auto& type : species) { + if (reinterpret_cast(list->FindObject((static_cast(weightName) + type).c_str()))) { continue; } - GFWWeights* weight = new GFWWeights(Form("%s",(static_cast(weightName)+type).c_str())); - if(!type.compare("_ref")) weight->SetPtBins(refpt.size() - 1, &(refpt[0])); - else weight->SetPtBins(nPtBins, ptBins); - weight->Init(addData, addMC); + GFWWeights* weight = new GFWWeights(Form("%s", (static_cast(weightName) + type).c_str())); + if (!type.compare("_ref")) + weight->setPtBins(refpt.size() - 1, &(refpt[0])); + else + weight->setPtBins(nPtBins, ptBins); + weight->init(addData, addMC); list->Add(weight); } } GFWWeights* GFWWeightsList::getPIDGFWWeightsByName(const char* weightName, int pidIndex) { - if(static_cast(pidIndex) >= species.size()) + if (static_cast(pidIndex) >= species.size()) return nullptr; if (!list) { - printf("Error: weight list is not initialized\n"); + LOGF(error, "weight list is not initialized\n"); return nullptr; } - return reinterpret_cast(list->FindObject((static_cast(weightName)+species[pidIndex]).c_str())); + return reinterpret_cast(list->FindObject((static_cast(weightName) + species[pidIndex]).c_str())); } void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, double ptrefup, bool addData, bool addMC) { @@ -132,21 +134,24 @@ void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* p init("weightList"); } - if (runNumberPIDMap.contains(runNumber)) return; + if (runNumberPIDMap.contains(runNumber)) + return; std::vector ptbins(ptBins, ptBins + nPtBins + 1); auto it = std::find(ptbins.begin(), ptbins.end(), ptrefup); std::vector refpt(ptbins.begin(), it + 1); std::vector weights; - for(auto & type : species){ + for (auto& type : species) { GFWWeights* weight = new GFWWeights(Form("weight_%d%s", runNumber, type.c_str())); - if(!type.compare("_ref")) weight->SetPtBins(refpt.size() - 1, &(refpt[0])); - else weight->SetPtBins(nPtBins, ptBins); - weight->Init(addData, addMC); + if (!type.compare("_ref")) + weight->setPtBins(refpt.size() - 1, &(refpt[0])); + else + weight->setPtBins(nPtBins, ptBins); + weight->init(addData, addMC); list->Add(weight); weights.push_back(weight); } - printf("Adding weights for run %d\n",runNumber); + LOGF(info, "Adding weights for run %d\n", runNumber); runNumberPIDMap.insert(std::make_pair(runNumber, weights)); return; } @@ -154,18 +159,17 @@ void GFWWeightsList::addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* p GFWWeights* GFWWeightsList::getPIDGFWWeightsByRun(int runNumber, int pidIndex) { if (!list) { - printf("Error: weight list is not initialized\n"); + LOGF(error, "weight list is not initialized\n"); return nullptr; } if (!runNumberPIDMap.contains(runNumber)) { - printf("Error: PID weights for run %d is not found\n", runNumber); + LOGF(error, "PID weights for run %d is not found\n", runNumber); return nullptr; } return runNumberPIDMap.at(runNumber)[pidIndex]; } Long64_t GFWWeightsList::Merge(TCollection* collist) { - printf("Merging weight lists!\n"); Long64_t nmerged = 0; if (!list) { list = new TObjArray(); @@ -175,12 +179,12 @@ Long64_t GFWWeightsList::Merge(TCollection* collist) TIter allWeights(collist); GFWWeightsList* lWeight = 0; while ((lWeight = (reinterpret_cast(allWeights())))) { - AddArray(list, lWeight->getList()); + addArray(list, lWeight->getList()); nmerged++; } return nmerged; } -void GFWWeightsList::AddArray(TObjArray* target, TObjArray* source) +void GFWWeightsList::addArray(TObjArray* target, TObjArray* source) { if (!source) { return; @@ -192,7 +196,7 @@ void GFWWeightsList::AddArray(TObjArray* target, TObjArray* source) targw = reinterpret_cast(sourw->Clone(sourw->GetName())); target->Add(targw); } else { - targw->MergeWeights(sourw); + targw->mergeWeights(sourw); } } }; diff --git a/PWGCF/GenericFramework/Core/GFWWeightsList.h b/PWGCF/GenericFramework/Core/GFWWeightsList.h index f9cc4de0aa9..8de876133d6 100644 --- a/PWGCF/GenericFramework/Core/GFWWeightsList.h +++ b/PWGCF/GenericFramework/Core/GFWWeightsList.h @@ -38,16 +38,21 @@ class GFWWeightsList : public TNamed GFWWeights* getPIDGFWWeightsByName(const char* weightName, int pidIndex); void addPIDGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, double ptrefup, bool addData = kTRUE, bool addMC = kTRUE); GFWWeights* getPIDGFWWeightsByRun(int runNumber, int pidIndex); - void PrintRuns() { for(auto &el : runNumberPIDMap) printf("%i\n",el.first); } + void printRuns() + { + for (auto& el : runNumberPIDMap) + printf("%i\n", el.first); + } TObjArray* getList() const { return list; } Long64_t Merge(TCollection* collist); + private: TObjArray* list; std::vector species = {"_ref", "_ch", "_pi", "_ka", "_pr"}; //! std::map runNumberMap; - std::map> runNumberPIDMap; - void AddArray(TObjArray* target, TObjArray* source); + std::map> runNumberPIDMap; + void addArray(TObjArray* target, TObjArray* source); ClassDef(GFWWeightsList, 1); }; diff --git a/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx b/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx index cf0ac0cbd30..632dff15c85 100644 --- a/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx +++ b/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx @@ -80,7 +80,7 @@ GFWCorrConfigs configs; using namespace o2::analysis::genericframework; -struct GenericFramework { +struct FlowGenericFramework { O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 10, "Number of subsamples") O2_DEFINE_CONFIGURABLE(cfgMpar, int, 8, "Highest order of pt-pt correlations") @@ -385,11 +385,15 @@ struct GenericFramework { double wacc = 1; if (cfg.mAcceptance) { if (cfgUsePID) { - if(cfgRunByRunWeights) wacc = cfg.mAcceptance->getPIDGFWWeightsByRun(lastRun,index)->GetNUA(track.phi(), track.eta(), vtxz); - else wacc = cfg.mAcceptance->getPIDGFWWeightsByName("weight",index)->GetNUA(track.phi(), track.eta(), vtxz); + if (cfgRunByRunWeights) + wacc = cfg.mAcceptance->getPIDGFWWeightsByRun(lastRun, index)->getNUA(track.phi(), track.eta(), vtxz); + else + wacc = cfg.mAcceptance->getPIDGFWWeightsByName("weight", index)->getNUA(track.phi(), track.eta(), vtxz); } else { - if(cfgRunByRunWeights) wacc = cfg.mAcceptance->getGFWWeightsByRun(lastRun)->GetNUA(track.phi(), track.eta(), vtxz); - else wacc = cfg.mAcceptance->getGFWWeightsByName("weight")->GetNUA(track.phi(), track.eta(), vtxz); + if (cfgRunByRunWeights) + wacc = cfg.mAcceptance->getGFWWeightsByRun(lastRun)->getNUA(track.phi(), track.eta(), vtxz); + else + wacc = cfg.mAcceptance->getGFWWeightsByName("weight")->getNUA(track.phi(), track.eta(), vtxz); } } return wacc; @@ -512,7 +516,7 @@ struct GenericFramework { if (vtxz > vtxZup || vtxz < vtxZlow) return 0; - if(cfgMultCut){ + if (cfgMultCut) { if (multNTracksPV < fMultPVCutLow->Eval(centrality)) return 0; if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) @@ -576,20 +580,20 @@ struct GenericFramework { bool withinPtRef = (ptreflow < track.pt()) && (track.pt() < ptrefup); // within RF pT range if (cfgRunByRunWeights) { if (withinPtRef && !pid_index) - fWeightList->getPIDGFWWeightsByRun(run,pid_index)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow + fWeightList->getPIDGFWWeightsByRun(run, pid_index)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow if (withinPtPOI) - fWeightList->getPIDGFWWeightsByRun(run,pid_index+1)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights + fWeightList->getPIDGFWWeightsByRun(run, pid_index + 1)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights } else { if (withinPtRef && !pid_index) - fWeightList->getPIDGFWWeightsByName("weight",pid_index)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow + fWeightList->getPIDGFWWeightsByName("weight", pid_index)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // pt-subset of charged particles for ref flow if (withinPtPOI) - fWeightList->getPIDGFWWeightsByName("weight",pid_index+1)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights + fWeightList->getPIDGFWWeightsByName("weight", pid_index + 1)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); // charged and id'ed particle weights } } else { if (cfgRunByRunWeights) - fWeightList->getGFWWeightsByRun(lastRun)->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); + fWeightList->getGFWWeightsByRun(lastRun)->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); else - fWeightList->getGFWWeightsByName("weight")->Fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); + fWeightList->getGFWWeightsByName("weight")->fill(track.phi(), track.eta(), vtxz, track.pt(), multcent, 0); } return; } @@ -597,9 +601,9 @@ struct GenericFramework { void createRunByRunWeights(int run) { if (cfgUsePID) { - fWeightList->addPIDGFWWeightsByRun(run,fPtAxis->GetNbins(),&ptbinning[0],ptrefup,true,false); + fWeightList->addPIDGFWWeightsByRun(run, fPtAxis->GetNbins(), &ptbinning[0], ptrefup, true, false); } else { - fWeightList->addGFWWeightsByRun(run,fPtAxis->GetNbins(),&ptbinning[0],true,false); + fWeightList->addGFWWeightsByRun(run, fPtAxis->GetNbins(), &ptbinning[0], true, false); } return; } @@ -774,7 +778,7 @@ struct GenericFramework { if (!withinPtPOI && !withinPtRef) return; double waccRef = (dt == kGen) ? 1. : getAcceptance(track, vtxz, 0); - double waccPOI = (dt == kGen) ? 1. : withinPtPOI ? getAcceptance(track, vtxz, pid_index+1) + double waccPOI = (dt == kGen) ? 1. : withinPtPOI ? getAcceptance(track, vtxz, pid_index + 1) : getAcceptance(track, vtxz, 0); // if (withinPtRef && withinPtPOI && pid_index) waccRef = waccPOI; // if particle is both (then it's overlap), override ref with POI @@ -806,7 +810,7 @@ struct GenericFramework { registry.fill(HIST("MCGen/") + HIST(FillTimeName[ft]) + HIST("pt_gen"), track.pt()); } else { double wacc = getAcceptance(track, vtxz, 0); - registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ"), track.phi(), track.eta(), vtxz, (ft == kAfter)?wacc:1.0); + registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("phi_eta_vtxZ"), track.phi(), track.eta(), vtxz, (ft == kAfter) ? wacc : 1.0); registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_dcaXY_dcaZ"), track.pt(), track.dcaXY(), track.dcaZ()); if (ft == kAfter) { registry.fill(HIST("trackQA/") + HIST(FillTimeName[ft]) + HIST("pt_ref"), track.pt()); @@ -865,7 +869,7 @@ struct GenericFramework { auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; processCollision(collision, tracks, centrality, field, run); } - PROCESS_SWITCH(GenericFramework, processData, "Process analysis for non-derived data", true); + PROCESS_SWITCH(FlowGenericFramework, processData, "Process analysis for non-derived data", true); void processMCReco(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, soa::Filtered> const& tracks, aod::McParticles const&) { @@ -891,7 +895,7 @@ struct GenericFramework { auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; processCollision(collision, tracks, centrality, field, run); } - PROCESS_SWITCH(GenericFramework, processMCReco, "Process analysis for MC reconstructed events", false); + PROCESS_SWITCH(FlowGenericFramework, processMCReco, "Process analysis for MC reconstructed events", false); Filter mcCollFilter = nabs(aod::mccollision::posZ) < cfgVtxZ; void processMCGen(soa::Filtered::iterator const& mcCollision, soa::SmallGroups> const& collisions, aod::McParticles const& particles) @@ -904,7 +908,7 @@ struct GenericFramework { } processCollision(mcCollision, particles, centrality, -999, 0); } - PROCESS_SWITCH(GenericFramework, processMCGen, "Process analysis for MC generated events", false); + PROCESS_SWITCH(FlowGenericFramework, processMCGen, "Process analysis for MC generated events", false); void processRun2(soa::Filtered>::iterator const& collision, aod::BCsWithTimestamps const&, GFWTracks const& tracks) { @@ -918,17 +922,17 @@ struct GenericFramework { if (!collision.sel7()) return; const auto centrality = collision.centRun2V0M(); - if(!cfgFillWeights) - loadCorrections(bc); + if (!cfgFillWeights) + loadCorrections(bc); auto field = (cfgMagField == 99999) ? getMagneticField(bc.timestamp()) : cfgMagField; processCollision(collision, tracks, centrality, field, run); } - PROCESS_SWITCH(GenericFramework, processRun2, "Process analysis for Run 2 converted data", false); + PROCESS_SWITCH(FlowGenericFramework, processRun2, "Process analysis for Run 2 converted data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), }; } diff --git a/PWGDQ/Tasks/dqCorrelation.cxx b/PWGDQ/Tasks/dqCorrelation.cxx index d2fa3a0dd4b..950e82364cb 100644 --- a/PWGDQ/Tasks/dqCorrelation.cxx +++ b/PWGDQ/Tasks/dqCorrelation.cxx @@ -303,7 +303,7 @@ struct DqCumulantFlow { } weff = 1. / weff; if (cfg.mAcceptance) { - wacc = cfg.mAcceptance->GetNUA(track.phi(), track.eta(), event.posZ()); + wacc = cfg.mAcceptance->getNUA(track.phi(), track.eta(), event.posZ()); } else { wacc = 1.0; } diff --git a/PWGDQ/Tasks/dqFlow.cxx b/PWGDQ/Tasks/dqFlow.cxx index b5e855d3d13..d9210685a2e 100644 --- a/PWGDQ/Tasks/dqFlow.cxx +++ b/PWGDQ/Tasks/dqFlow.cxx @@ -189,7 +189,7 @@ struct DQEventQvector { fPtAxis = new TAxis(ptbins, &ptbinning[0]); if (fConfigFillWeights) { // fWeights->SetPtBins(ptbins, &ptbinning[0]); // in the default case, it will accept everything - fWeights->Init(true, false); // true for data, false for MC + fWeights->init(true, false); // true for data, false for MC } // Reference flow @@ -383,7 +383,7 @@ struct DQEventQvector { // Fill weights for Q-vector correction: this should be enabled for a first run to get weights if (fConfigFillWeights) { - fWeights->Fill(track.phi(), track.eta(), collision.posZ(), track.pt(), centrality, 0); + fWeights->fill(track.phi(), track.eta(), collision.posZ(), track.pt(), centrality, 0); } if (cfg.mEfficiency) { @@ -396,7 +396,7 @@ struct DQEventQvector { } weff = 1. / weff; if (cfg.mAcceptance) { - wacc = cfg.mAcceptance->GetNUA(track.phi(), track.eta(), collision.posZ()); + wacc = cfg.mAcceptance->getNUA(track.phi(), track.eta(), collision.posZ()); } else { wacc = 1.0; }