diff --git a/PWGLF/Tasks/Nuspex/antinucleiInJets.cxx b/PWGLF/Tasks/Nuspex/antinucleiInJets.cxx index f2b28bd38bb..b85d24eef64 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,7 +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 pathToFile{"pathToFile", "Users/a/alcaliva/reweightingHistogramsAntinucleiInJets/", "path to file"}; Configurable weightsProton{"weightsProton", "weightsProton", "weightsProton"}; Configurable weightsLambda{"weightsLambda", "weightsLambda", "weightsLambda"}; Configurable weightsSigma{"weightsSigma", "weightsSigma", "weightsSigma"}; @@ -213,6 +213,8 @@ struct AntinucleiInJets { Configurable weightsOmega{"weightsOmega", "weightsOmega", "weightsOmega"}; Configurable weightsJet{"weightsJet", "weightsJet", "weightsJet"}; Configurable weightsUe{"weightsUe", "weightsUe", "weightsUe"}; + Configurable weightsAntidJet{"weightsAntidJet", "weightsAntidJet", "weightsAntidJet"}; + Configurable weightsAntidUe{"weightsAntidUe", "weightsAntidUe", "weightsAntidUe"}; // Number of events Configurable shrinkInterval{"shrinkInterval", 1000, "variable that controls how often shrinking happens"}; @@ -225,13 +227,15 @@ 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; @@ -284,7 +288,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), TString(weightsProton), TString(weightsLambda), TString(weightsSigma), TString(weightsXi), TString(weightsOmega), TString(weightsJet), TString(weightsUe), TString(weightsAntidJet), TString(weightsAntidUe)); } // Binning @@ -395,6 +399,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 +692,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 filepath, TString antip, TString antilambda, TString antisigma, TString antixi, TString antiomega, TString jet, TString ue, TString antidJet, TString antidUe) { TList* list = ccdbObj->get(filepath.Data()); if (!list) { @@ -705,11 +711,18 @@ struct AntinucleiInJets { LOGP(error, "Missing one or more reweighting histograms for primary fraction in CCDB list"); } - // Get reweighting histograms for efficiency + // Get reweighting histograms for antiproton efficiency antiprotonsInsideJets = static_cast(list->FindObject(jet)); antiprotonsPerpCone = static_cast(list->FindObject(ue)); 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 = static_cast(list->FindObject(antidJet)); + antideuteronsPerpCone = static_cast(list->FindObject(antidUe)); + 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 +783,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 +823,7 @@ struct AntinucleiInJets { } // Spin-statistical acceptance - if (mRand.Uniform() > SpinFactor) { + if (random.Uniform() > SpinFactor) { return false; } return true; @@ -2188,7 +2201,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 +2275,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 +2540,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 +2577,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 +2659,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 +2724,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); } } }