Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 67 additions & 25 deletions PWGLF/Tasks/Nuspex/antinucleiInJets.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ struct JetMatching {

struct AntinucleiInJets {

// Random engine (Mersenne Twister)
// Random Engine (Mersenne Twister)
std::mt19937 rng;
std::uniform_int_distribution<int> generateRandomNr{0, 1};

Expand Down Expand Up @@ -205,14 +205,16 @@ struct AntinucleiInJets {
// Configuration parameters for CCDB access and reweighting input files
Configurable<bool> applyReweighting{"applyReweighting", true, "enable reweighting for efficiency"};
Configurable<std::string> urlToCcdb{"urlToCcdb", "http://alice-ccdb.cern.ch/", "url of the personal ccdb"};
Configurable<std::string> pathToFile{"pathToFile", "Users/a/alcaliva/reweightingHistogramsAnalysis/", "path to file"};
Configurable<std::string> pathToFile{"pathToFile", "Users/a/alcaliva/reweightingHistogramsAntinucleiInJets/", "path to file"};
Configurable<std::string> weightsProton{"weightsProton", "weightsProton", "weightsProton"};
Configurable<std::string> weightsLambda{"weightsLambda", "weightsLambda", "weightsLambda"};
Configurable<std::string> weightsSigma{"weightsSigma", "weightsSigma", "weightsSigma"};
Configurable<std::string> weightsXi{"weightsXi", "weightsXi", "weightsXi"};
Configurable<std::string> weightsOmega{"weightsOmega", "weightsOmega", "weightsOmega"};
Configurable<std::string> weightsJet{"weightsJet", "weightsJet", "weightsJet"};
Configurable<std::string> weightsUe{"weightsUe", "weightsUe", "weightsUe"};
Configurable<std::string> weightsAntidJet{"weightsAntidJet", "weightsAntidJet", "weightsAntidJet"};
Configurable<std::string> weightsAntidUe{"weightsAntidUe", "weightsAntidUe", "weightsAntidUe"};

// Number of events
Configurable<int> shrinkInterval{"shrinkInterval", 1000, "variable that controls how often shrinking happens"};
Expand All @@ -225,13 +227,15 @@ struct AntinucleiInJets {
Configurable<double> 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<o2::ccdb::BasicCCDBManager> ccdb;
Expand Down Expand Up @@ -284,7 +288,7 @@ struct AntinucleiInJets {
ccdb->setLocalObjectValidityChecking();
ccdb->setCreatedNotAfter(std::chrono::duration_cast<std::chrono::milliseconds>(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
Expand Down Expand Up @@ -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})"}});
Expand Down Expand Up @@ -686,7 +692,7 @@ struct AntinucleiInJets {
}
}

void getReweightingHistograms(o2::framework::Service<o2::ccdb::BasicCCDBManager> const& ccdbObj, TString filepath, TString antip, TString antilambda, TString antisigma, TString antixi, TString antiomega, TString jet, TString ue)
void getReweightingHistograms(o2::framework::Service<o2::ccdb::BasicCCDBManager> 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<TList>(filepath.Data());
if (!list) {
Expand All @@ -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<TH1F*>(list->FindObject(jet));
antiprotonsPerpCone = static_cast<TH1F*>(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<TH1F*>(list->FindObject(antidJet));
antideuteronsPerpCone = static_cast<TH1F*>(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");
Expand Down Expand Up @@ -770,7 +783,7 @@ struct AntinucleiInJets {

// Evaluate proton–neutron coalescence for deuteron formation
template <typename ReducedPart>
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;
Expand Down Expand Up @@ -810,7 +823,7 @@ struct AntinucleiInJets {
}

// Spin-statistical acceptance
if (mRand.Uniform() > SpinFactor) {
if (random.Uniform() > SpinFactor) {
return false;
}
return true;
Expand Down Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
Loading