diff --git a/PWGLF/Tasks/Nuspex/antinucleiInJets.cxx b/PWGLF/Tasks/Nuspex/antinucleiInJets.cxx index f2b28bd38bb..624b5bebb22 100644 --- a/PWGLF/Tasks/Nuspex/antinucleiInJets.cxx +++ b/PWGLF/Tasks/Nuspex/antinucleiInJets.cxx @@ -132,7 +132,7 @@ struct JetMatching { struct AntinucleiInJets { - // Random engine (Mersenne Twister) + // Random Engine (Mersenne Twister) std::mt19937 rng; std::uniform_int_distribution generateRandomNr{0, 1}; @@ -205,14 +205,7 @@ struct AntinucleiInJets { // Configuration parameters for CCDB access and reweighting input files Configurable applyReweighting{"applyReweighting", true, "enable reweighting for efficiency"}; Configurable urlToCcdb{"urlToCcdb", "http://alice-ccdb.cern.ch/", "url of the personal ccdb"}; - Configurable pathToFile{"pathToFile", "Users/a/alcaliva/reweightingHistogramsAnalysis/", "path to file"}; - Configurable weightsProton{"weightsProton", "weightsProton", "weightsProton"}; - Configurable weightsLambda{"weightsLambda", "weightsLambda", "weightsLambda"}; - Configurable weightsSigma{"weightsSigma", "weightsSigma", "weightsSigma"}; - Configurable weightsXi{"weightsXi", "weightsXi", "weightsXi"}; - Configurable weightsOmega{"weightsOmega", "weightsOmega", "weightsOmega"}; - Configurable weightsJet{"weightsJet", "weightsJet", "weightsJet"}; - Configurable weightsUe{"weightsUe", "weightsUe", "weightsUe"}; + Configurable pathToFile{"pathToFile", "Users/a/alcaliva/reweightingHistogramsAntinucleiInJets/", "path to file"}; // Number of events Configurable shrinkInterval{"shrinkInterval", 1000, "variable that controls how often shrinking happens"}; @@ -225,16 +218,18 @@ struct AntinucleiInJets { Configurable coalescenceMomentum{"coalescenceMomentum", 0.15, "p0 (GeV/c)"}; // Reweighting histograms - TH1F* primaryAntiprotons; - TH1F* primaryAntiLambda; - TH1F* primaryAntiSigma; - TH1F* primaryAntiXi; - TH1F* primaryAntiOmega; - TH1F* antiprotonsInsideJets; - TH1F* antiprotonsPerpCone; + TH1F* primaryAntiprotons = nullptr; + TH1F* primaryAntiLambda = nullptr; + TH1F* primaryAntiSigma = nullptr; + TH1F* primaryAntiXi = nullptr; + TH1F* primaryAntiOmega = nullptr; + TH1F* antiprotonsInsideJets = nullptr; + TH1F* antiprotonsPerpCone = nullptr; + TH1F* antideuteronsInsideJets = nullptr; + TH1F* antideuteronsPerpCone = nullptr; // CCDB manager service for accessing condition data - Service ccdb; + Service ccdb{}; // Direct interface to the CCDB API for manual data access o2::ccdb::CcdbApi ccdbApi; @@ -284,7 +279,7 @@ struct AntinucleiInJets { ccdb->setLocalObjectValidityChecking(); ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); ccdb->setFatalWhenNull(false); - getReweightingHistograms(ccdb, TString(pathToFile), TString(weightsProton), TString(weightsLambda), TString(weightsSigma), TString(weightsXi), TString(weightsOmega), TString(weightsJet), TString(weightsUe)); + getReweightingHistograms(ccdb, TString(pathToFile)); } // Binning @@ -395,6 +390,8 @@ struct AntinucleiInJets { // Generated spectra of antideuterons registryMC.add("antideuteron_gen_jet", "antideuteron_gen_jet", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); registryMC.add("antideuteron_gen_ue", "antideuteron_gen_ue", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antideuteron_gen_jet_noweight", "antideuteron_gen_jet_noweight", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antideuteron_gen_ue_noweight", "antideuteron_gen_ue_noweight", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); // Generated spectra of antiprotons for closure test registryMC.add("antiproton_gen_jet_data", "antiproton_gen_jet_data", HistType::kTH1F, {{nbins, min, max, "#it{p}_{T} (GeV/#it{c})"}}); @@ -686,7 +683,7 @@ struct AntinucleiInJets { } } - void getReweightingHistograms(o2::framework::Service const& ccdbObj, TString filepath, TString antip, TString antilambda, TString antisigma, TString antixi, TString antiomega, TString jet, TString ue) + void getReweightingHistograms(o2::framework::Service const& ccdbObj, TString const& filepath) { TList* list = ccdbObj->get(filepath.Data()); if (!list) { @@ -695,21 +692,28 @@ struct AntinucleiInJets { } // Get reweighting histograms for primary fraction - primaryAntiprotons = static_cast(list->FindObject(antip)); - primaryAntiLambda = static_cast(list->FindObject(antilambda)); - primaryAntiSigma = static_cast(list->FindObject(antisigma)); - primaryAntiXi = static_cast(list->FindObject(antixi)); - primaryAntiOmega = static_cast(list->FindObject(antiomega)); + primaryAntiprotons = dynamic_cast(list->FindObject("weightsProton")); + primaryAntiLambda = dynamic_cast(list->FindObject("weightsLambda")); + primaryAntiSigma = dynamic_cast(list->FindObject("weightsSigma")); + primaryAntiXi = dynamic_cast(list->FindObject("weightsXi")); + primaryAntiOmega = dynamic_cast(list->FindObject("weightsOmega")); if (!primaryAntiprotons || !primaryAntiSigma || !primaryAntiLambda || !primaryAntiXi || !primaryAntiOmega) { LOGP(error, "Missing one or more reweighting histograms for primary fraction in CCDB list"); } - // Get reweighting histograms for efficiency - antiprotonsInsideJets = static_cast(list->FindObject(jet)); - antiprotonsPerpCone = static_cast(list->FindObject(ue)); + // Get reweighting histograms for antiproton efficiency + antiprotonsInsideJets = dynamic_cast(list->FindObject("weightsJet")); + antiprotonsPerpCone = dynamic_cast(list->FindObject("weightsUe")); if (!antiprotonsInsideJets || !antiprotonsPerpCone) { - LOGP(error, "Missing one or more reweighting histograms for efficiency in CCDB list"); + LOGP(error, "Missing one or more reweighting histograms for antiproton efficiency in CCDB list"); + } + + // Get reweighting histograms for antideuteron efficiency + antideuteronsInsideJets = dynamic_cast(list->FindObject("weightsAntidJet")); + antideuteronsPerpCone = dynamic_cast(list->FindObject("weightsAntidUe")); + if (!antideuteronsInsideJets || !antideuteronsPerpCone) { + LOGP(error, "Missing one or more reweighting histograms for antideuteron efficiency in CCDB list"); } LOGP(info, "Successfully loaded reweighting histograms from CCDB path"); @@ -770,7 +774,7 @@ struct AntinucleiInJets { // Evaluate proton–neutron coalescence for deuteron formation template - bool passDeuteronCoalescence(const ReducedPart& p, const ReducedPart& n, double p0, TRandom3& mRand) + bool passDeuteronCoalescence(const ReducedPart& p, const ReducedPart& n, double p0, TRandom3& random) { // Nucleon masses const double mp = o2::constants::physics::MassProton; @@ -810,7 +814,7 @@ struct AntinucleiInJets { } // Spin-statistical acceptance - if (mRand.Uniform() > SpinFactor) { + if (random.Uniform() > SpinFactor) { return false; } return true; @@ -1784,6 +1788,8 @@ struct AntinucleiInJets { case PDG_t::kSigmaBarMinus: registryMC.fill(HIST("sigmaBar"), particle.pt()); break; + default: + break; } } } @@ -2188,7 +2194,14 @@ struct AntinucleiInJets { // Fill antideuteron spectra if (isAntid) { - registryMC.fill(HIST("antideuteron_gen_jet"), particle.pt()); + double weightJetAntid(1.0); + if (applyReweighting && particle.pt() < antideuteronsInsideJets->GetXaxis()->GetXmax()) { + int ipt = antideuteronsInsideJets->FindBin(particle.pt()); + weightJetAntid = antideuteronsInsideJets->GetBinContent(ipt); + } + + registryMC.fill(HIST("antideuteron_gen_jet"), particle.pt(), weightJetAntid); + registryMC.fill(HIST("antideuteron_gen_jet_noweight"), particle.pt()); } } @@ -2255,8 +2268,16 @@ struct AntinucleiInJets { if (deltaRUe1 > rJet && deltaRUe2 > rJet) continue; + // Calculate weight + double weightUeAntid(1.0); + if (applyReweighting && deuteronVec.Pt() < antideuteronsPerpCone->GetXaxis()->GetXmax()) { + int ipt = antideuteronsPerpCone->FindBin(deuteronVec.Pt()); + weightUeAntid = antideuteronsPerpCone->GetBinContent(ipt); + } + // Fill histogram for antideuterons in the UE - registryMC.fill(HIST("antideuteron_gen_ue"), deuteronVec.Pt()); + registryMC.fill(HIST("antideuteron_gen_ue"), deuteronVec.Pt(), weightUeAntid); + registryMC.fill(HIST("antideuteron_gen_ue_noweight"), deuteronVec.Pt()); } } if (isAtLeastOneJetSelected) { @@ -2512,7 +2533,7 @@ struct AntinucleiInJets { // Fill antiproton spectrum for physical primaries registryMC.fill(HIST("antiproton_prim_jet"), pt); - // Calculate weight + // Calculate weights double weightJet(1.0); if (applyReweighting && mcparticle.pt() < antiprotonsInsideJets->GetXaxis()->GetXmax()) { int ipt = antiprotonsInsideJets->FindBin(mcparticle.pt()); @@ -2549,16 +2570,23 @@ struct AntinucleiInJets { if (std::fabs(dcaxy) > maxDcaxy || std::fabs(dcaz) > maxDcaz) continue; - // Select physical primary antiprotons + // Select physical primary antideuterons if (!mcparticle.isPhysicalPrimary()) continue; + // Calculate weight + double weightJetAntid(1.0); + if (applyReweighting && mcparticle.pt() < antideuteronsInsideJets->GetXaxis()->GetXmax()) { + int ipt = antideuteronsInsideJets->FindBin(mcparticle.pt()); + weightJetAntid = antideuteronsInsideJets->GetBinContent(ipt); + } + // Fill histograms (TPC and TOF) only for selected candidates if (nsigmaTPCDe > minNsigmaTpc && nsigmaTPCDe < maxNsigmaTpc) { - registryMC.fill(HIST("antideuteron_rec_tpc_jet"), pt); + registryMC.fill(HIST("antideuteron_rec_tpc_jet"), pt, weightJetAntid); if (track.hasTOF() && nsigmaTOFDe > minNsigmaTof && nsigmaTOFDe < maxNsigmaTof) { - registryMC.fill(HIST("antideuteron_rec_tof_jet"), pt); + registryMC.fill(HIST("antideuteron_rec_tof_jet"), pt, weightJetAntid); } } } // end of isAntid @@ -2624,7 +2652,7 @@ struct AntinucleiInJets { // Fill antiproton spectrum for physical primaries registryMC.fill(HIST("antiproton_prim_ue"), pt); - // Calculate weight + // Calculate weights double weightUe(1.0); if (applyReweighting && mcparticle.pt() < antiprotonsPerpCone->GetXaxis()->GetXmax()) { int ipt = antiprotonsPerpCone->FindBin(mcparticle.pt()); @@ -2689,16 +2717,23 @@ struct AntinucleiInJets { if (deltaRUe1 > rJet && deltaRUe2 > rJet) continue; - // Select physical primary antiprotons + // Select physical primary antideuterons if (!mcparticle.isPhysicalPrimary()) continue; + // Calculate weight + double weightUeAntid(1.0); + if (applyReweighting && mcparticle.pt() < antideuteronsPerpCone->GetXaxis()->GetXmax()) { + int ipt = antideuteronsPerpCone->FindBin(mcparticle.pt()); + weightUeAntid = antideuteronsPerpCone->GetBinContent(ipt); + } + // Fill histograms (TPC and TOF) only for selected candidates if (nsigmaTPCDe > minNsigmaTpc && nsigmaTPCDe < maxNsigmaTpc) { - registryMC.fill(HIST("antideuteron_rec_tpc_ue"), pt); + registryMC.fill(HIST("antideuteron_rec_tpc_ue"), pt, weightUeAntid); if (track.hasTOF() && nsigmaTOFDe > minNsigmaTof && nsigmaTOFDe < maxNsigmaTof) { - registryMC.fill(HIST("antideuteron_rec_tof_ue"), pt); + registryMC.fill(HIST("antideuteron_rec_tof_ue"), pt, weightUeAntid); } } } @@ -2962,6 +2997,8 @@ struct AntinucleiInJets { case -o2::constants::physics::Pdg::kHelium3: registryMC.fill(HIST("antihelium3_gen_syst"), particle.pt()); break; + default: + break; } } }