Skip to content

Commit 423391c

Browse files
EloviyoShirajum Monira
andauthored
[PWGCF] FemtoUniverse V0 Task -- implemented efficiency CCDB loader for V0s (#14944)
Co-authored-by: Shirajum Monira <shirajum.monira@cern.ch>
1 parent dff34a3 commit 423391c

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackV0Extended.cxx

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h"
2323
#include "PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h"
2424

25+
#include "CCDB/BasicCCDBManager.h"
2526
#include "Framework/ASoAHelpers.h"
2627
#include "Framework/AnalysisTask.h"
2728
#include "Framework/HistogramRegistry.h"
@@ -190,8 +191,9 @@ struct FemtoUniversePairTaskTrackV0Extended {
190191
std::set<int> v0Duplicates;
191192

192193
std::unique_ptr<TFile> plocalEffFile;
193-
std::unique_ptr<TH1> plocalEffp1;
194-
std::unique_ptr<TH1> plocalEffp2;
194+
std::unique_ptr<TH1> pEffHistp1;
195+
std::unique_ptr<TH1> pEffHistp2;
196+
Service<o2::ccdb::BasicCCDBManager> ccdb;
195197

196198
bool isNSigmaCombined(float mom, float nsigmaTPCParticle, float nsigmaTOFParticle)
197199
{
@@ -351,15 +353,31 @@ struct FemtoUniversePairTaskTrackV0Extended {
351353
plocalEffFile = std::unique_ptr<TFile>(TFile::Open(confLocalEfficiency.value.c_str(), "read"));
352354
if (!plocalEffFile || plocalEffFile.get()->IsZombie())
353355
LOGF(fatal, "Could not load efficiency histogram from %s", confLocalEfficiency.value.c_str());
354-
if (doprocessSameEvent || doprocessMixedEvent) {
355-
plocalEffp1 = (ConfTrkSelection.confChargePart1 > 0) ? std::unique_ptr<TH1>(plocalEffFile.get()->Get<TH1>("PrPlus")) : std::unique_ptr<TH1>(plocalEffFile.get()->Get<TH1>("PrMinus")); // note: works only for protons for now
356-
plocalEffp2 = (ConfV0Selection.confV0Type1 == 0) ? std::unique_ptr<TH1>(plocalEffFile.get()->Get<TH1>("Lambda")) : std::unique_ptr<TH1>(plocalEffFile.get()->Get<TH1>("AntiLambda"));
356+
if (doprocessSameEvent || doprocessSameEventBitmask || doprocessMixedEvent || doprocessMixedEventBitmask) {
357+
pEffHistp1 = (ConfTrkSelection.confChargePart1 > 0) ? std::unique_ptr<TH1>(plocalEffFile.get()->Get<TH1>("PrPlus")) : std::unique_ptr<TH1>(plocalEffFile.get()->Get<TH1>("PrMinus")); // note: works only for protons for now
358+
pEffHistp2 = (ConfV0Selection.confV0Type1 == 0) ? std::unique_ptr<TH1>(plocalEffFile.get()->Get<TH1>("Lambda")) : std::unique_ptr<TH1>(plocalEffFile.get()->Get<TH1>("AntiLambda"));
357359
LOGF(info, "Loaded efficiency histograms for track-V0.");
358-
} else if (doprocessSameEventV0 || doprocessMixedEventV0) {
359-
plocalEffp1 = (ConfV0Selection.confV0Type1 == 0) ? std::unique_ptr<TH1>(plocalEffFile.get()->Get<TH1>("Lambda")) : std::unique_ptr<TH1>(plocalEffFile.get()->Get<TH1>("AntiLambda"));
360-
plocalEffp2 = (ConfV0Selection.confV0Type2 == 0) ? std::unique_ptr<TH1>(plocalEffFile.get()->Get<TH1>("Lambda")) : std::unique_ptr<TH1>(plocalEffFile.get()->Get<TH1>("AntiLambda"));
360+
} else if (doprocessSameEventV0 || doprocessSameEventV0Bitmask || doprocessMixedEventV0 || doprocessMixedEventV0Bitmask) {
361+
pEffHistp1 = (ConfV0Selection.confV0Type1 == 0) ? std::unique_ptr<TH1>(plocalEffFile.get()->Get<TH1>("Lambda")) : std::unique_ptr<TH1>(plocalEffFile.get()->Get<TH1>("AntiLambda"));
362+
pEffHistp2 = (ConfV0Selection.confV0Type2 == 0) ? std::unique_ptr<TH1>(plocalEffFile.get()->Get<TH1>("Lambda")) : std::unique_ptr<TH1>(plocalEffFile.get()->Get<TH1>("AntiLambda"));
361363
LOGF(info, "Loaded efficiency histograms for V0-V0.");
362364
}
365+
} else if (!effCorConfGroup.confEffCorCCDBPath.value.empty()) {
366+
ccdb->setURL("http://alice-ccdb.cern.ch");
367+
ccdb->setCaching(true);
368+
ccdb->setLocalObjectValidityChecking();
369+
370+
auto now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
371+
ccdb->setCreatedNotAfter(now);
372+
if (doprocessSameEvent || doprocessSameEventBitmask || doprocessMixedEvent || doprocessMixedEventBitmask) {
373+
pEffHistp1 = (ConfTrkSelection.confChargePart1 > 0) ? std::unique_ptr<TH1>(ccdb->getForTimeStamp<TH1>(effCorConfGroup.confEffCorCCDBPath.value + "/PrPlus", now)) : std::unique_ptr<TH1>(ccdb->getForTimeStamp<TH1>(effCorConfGroup.confEffCorCCDBPath.value + "/PrMinus", now)); // note: works only for protons for now
374+
pEffHistp2 = (ConfV0Selection.confV0Type1 == 0) ? std::unique_ptr<TH1>(ccdb->getForTimeStamp<TH1>(effCorConfGroup.confEffCorCCDBPath.value + "/Lambda", now)) : std::unique_ptr<TH1>(ccdb->getForTimeStamp<TH1>(effCorConfGroup.confEffCorCCDBPath.value + "/AntiLambda", now));
375+
LOGF(info, "Loaded efficiency histograms for track-V0 from CCDB.");
376+
} else if (doprocessSameEventV0 || doprocessSameEventV0Bitmask || doprocessMixedEventV0 || doprocessMixedEventV0Bitmask) {
377+
pEffHistp1 = (ConfV0Selection.confV0Type1 == 0) ? std::unique_ptr<TH1>(ccdb->getForTimeStamp<TH1>(effCorConfGroup.confEffCorCCDBPath.value + "/Lambda", now)) : std::unique_ptr<TH1>(ccdb->getForTimeStamp<TH1>(effCorConfGroup.confEffCorCCDBPath.value + "/AntiLambda", now));
378+
pEffHistp2 = (ConfV0Selection.confV0Type2 == 0) ? std::unique_ptr<TH1>(ccdb->getForTimeStamp<TH1>(effCorConfGroup.confEffCorCCDBPath.value + "/Lambda", now)) : std::unique_ptr<TH1>(ccdb->getForTimeStamp<TH1>(effCorConfGroup.confEffCorCCDBPath.value + "/AntiLambda", now));
379+
LOGF(info, "Loaded efficiency histograms for V0-V0 from CCDB.");
380+
}
363381
}
364382

365383
effCorrection.init(&qaRegistry, {static_cast<framework::AxisSpec>(ConfV0Selection.confV0TempFitVarpTBins), {confEtaBins, -2, 2}, confMultBins});
@@ -517,8 +535,8 @@ struct FemtoUniversePairTaskTrackV0Extended {
517535
}
518536

519537
float weight = 1.0f;
520-
if (plocalEffp1)
521-
weight = plocalEffp1.get()->GetBinContent(plocalEffp1->FindBin(p1.pt(), p1.eta())) * plocalEffp2.get()->GetBinContent(plocalEffp2->FindBin(p2.pt(), p2.eta()));
538+
if (pEffHistp1)
539+
weight = pEffHistp1.get()->GetBinContent(pEffHistp1->FindBin(p1.pt(), p1.eta())) * pEffHistp2.get()->GetBinContent(pEffHistp2->FindBin(p2.pt(), p2.eta()));
522540
if constexpr (std::is_same<PartType, FemtoRecoParticles>::value)
523541
sameEventCont.setPair<true>(p1, p2, multCol, confUse3D, weight);
524542
else
@@ -987,8 +1005,8 @@ struct FemtoUniversePairTaskTrackV0Extended {
9871005
}
9881006
}
9891007
float weight = 1.0f;
990-
if (plocalEffp1)
991-
weight = plocalEffp1.get()->GetBinContent(plocalEffp1->FindBin(p1.pt(), p1.eta())) * plocalEffp2.get()->GetBinContent(plocalEffp2->FindBin(p2.pt(), p2.eta()));
1008+
if (pEffHistp1)
1009+
weight = pEffHistp1.get()->GetBinContent(pEffHistp1->FindBin(p1.pt(), p1.eta())) * pEffHistp2.get()->GetBinContent(pEffHistp2->FindBin(p2.pt(), p2.eta()));
9921010

9931011
if constexpr (std::is_same<PartType, FemtoRecoParticles>::value)
9941012
mixedEventCont.setPair<true>(p1, p2, multCol, confUse3D, weight);

0 commit comments

Comments
 (0)