@@ -142,6 +142,22 @@ struct AntinucleiInJets {
142142 Configurable<bool > cfgCompensatePIDinTracking{" cfgCompensatePIDinTracking" , false , " If true, divide tpcInnerParam by the electric charge" };
143143 Configurable<std::array<double , 5 >> cfgBetheBlochParams{" cfgBetheBlochParams" , {0.6539 , 1.591 , 0.8225 , 2.363 , 0.09 }, " TPC Bethe-Bloch parameterisation for He3" };
144144
145+ // Configuration parameters for CCDB access and reweighting input files
146+ Configurable<std::string> urlToCcdb{" urlToCcdb" , " http://alice-ccdb.cern.ch" , " url of the personal ccdb" };
147+ Configurable<std::string> pathToFile{" pathToFile" , " Users/a/alcaliva/PrimaryFractionAntip" , " path to file with reweighting" };
148+ Configurable<std::string> weightsProton{" weightsProton" , " " , " weightsProton" };
149+ Configurable<std::string> weightsLambda{" weightsLambda" , " " , " weightsLambda" };
150+ Configurable<std::string> weightsSigma{" weightsSigma" , " " , " weightsSigma" };
151+ Configurable<std::string> weightsXi{" weightsXi" , " " , " weightsXi" };
152+ Configurable<std::string> weightsOmega{" weightsOmega" , " " , " weightsOmega" };
153+
154+ // Reweighting histograms
155+ TH1F* primaryAntiprotons;
156+ TH1F* primaryAntiLambda;
157+ TH1F* primaryAntiSigma;
158+ TH1F* primaryAntiXi;
159+ TH1F* primaryAntiOmega;
160+
145161 // CCDB manager service for accessing condition data
146162 Service<o2::ccdb::BasicCCDBManager> ccdb;
147163
@@ -179,6 +195,16 @@ struct AntinucleiInJets {
179195 itsResponse.setMCDefaultParameters ();
180196 }
181197
198+ // Load reweighting histograms from CCDB if antinuclei efficiency processing is enabled
199+ if (doprocessAntinucleiEfficiency) {
200+ ccdb->setURL (urlToCcdb.value );
201+ ccdb->setCaching (true );
202+ ccdb->setLocalObjectValidityChecking ();
203+ ccdb->setCreatedNotAfter (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now ().time_since_epoch ()).count ());
204+ ccdb->setFatalWhenNull (false );
205+ getReweightingHistograms (ccdb, TString (pathToFile), TString (weightsProton), TString (weightsLambda), TString (weightsSigma), TString (weightsXi), TString (weightsOmega));
206+ }
207+
182208 // Binning
183209 double min = 0.0 ;
184210 double max = 6.0 ;
@@ -361,6 +387,17 @@ struct AntinucleiInJets {
361387
362388 // nsigmaITS for antiproton candidates
363389 registryMC.add (" antiproton_nsigma_its_mc" , " antiproton_nsigma_its_mc" , HistType::kTH2F , {{nbins, min, max, " #it{p}_{T} (GeV/#it{c})" }, {400 , -20.0 , 20.0 , " n#sigma_{ITS}" }});
390+
391+ // Systematics on the fraction of primary antiprotons
392+ registryMC.add (" antip_prim_pythia" , " antip_prim_pythia" , HistType::kTH1F , {{nbins, min, max, " #it{p}_{T} (GeV/#it{c})" }});
393+ registryMC.add (" antip_prim_std" , " antip_prim_std" , HistType::kTH1F , {{nbins, min, max, " #it{p}_{T} (GeV/#it{c})" }});
394+ registryMC.add (" antip_prim_up" , " antip_prim_up" , HistType::kTH1F , {{nbins, min, max, " #it{p}_{T} (GeV/#it{c})" }});
395+ registryMC.add (" antip_prim_low" , " antip_prim_low" , HistType::kTH1F , {{nbins, min, max, " #it{p}_{T} (GeV/#it{c})" }});
396+
397+ registryMC.add (" antip_sec_pythia" , " antip_sec_pythia" , HistType::kTH1F , {{nbins, min, max, " #it{p}_{T} (GeV/#it{c})" }});
398+ registryMC.add (" antip_sec_std" , " antip_sec_std" , HistType::kTH1F , {{nbins, min, max, " #it{p}_{T} (GeV/#it{c})" }});
399+ registryMC.add (" antip_sec_up" , " antip_sec_up" , HistType::kTH1F , {{nbins, min, max, " #it{p}_{T} (GeV/#it{c})" }});
400+ registryMC.add (" antip_sec_low" , " antip_sec_low" , HistType::kTH1F , {{nbins, min, max, " #it{p}_{T} (GeV/#it{c})" }});
364401 }
365402
366403 // Systematic uncertainties (Data)
@@ -442,6 +479,27 @@ struct AntinucleiInJets {
442479 }
443480 }
444481
482+ void getReweightingHistograms (o2::framework::Service<o2::ccdb::BasicCCDBManager> const & ccdbObj, TString filepath, TString antip, TString antilambda, TString antisigma, TString antixi, TString antiomega)
483+ {
484+ TList* list = ccdbObj->get <TList>(filepath.Data ());
485+ if (!list) {
486+ LOGP (error, " Could not retrieve the list from CCDB" );
487+ return ;
488+ }
489+
490+ primaryAntiprotons = static_cast <TH1F*>(list->FindObject (antip));
491+ primaryAntiLambda = static_cast <TH1F*>(list->FindObject (antilambda));
492+ primaryAntiSigma = static_cast <TH1F*>(list->FindObject (antisigma));
493+ primaryAntiXi = static_cast <TH1F*>(list->FindObject (antixi));
494+ primaryAntiOmega = static_cast <TH1F*>(list->FindObject (antiomega));
495+
496+ if (!primaryAntiprotons || !primaryAntiSigma || !primaryAntiLambda || !primaryAntiXi || !primaryAntiOmega) {
497+ LOGP (error, " Missing one or more reweighting histograms in CCDB list" );
498+ }
499+
500+ LOGP (info, " Successfully loaded reweighting histograms from CCDB path" );
501+ }
502+
445503 // Compute two unit vectors perpendicular to p
446504 void getPerpendicularAxis (const TVector3& p, TVector3& u, double sign)
447505 {
@@ -1344,6 +1402,94 @@ struct AntinucleiInJets {
13441402 continue ;
13451403 const auto particle = track.mcParticle ();
13461404
1405+ // ****************************************************************************************************************
1406+
1407+ // Systematic uncertainty on primary fraction
1408+ if (track.sign () < 0 && particle.pdgCode () == PDG_t::kProtonBar ) {
1409+
1410+ // Primary antiprotons
1411+ if (particle.isPhysicalPrimary ()) {
1412+
1413+ // Initialize weights
1414+ double wPrimStd (1.0 ), wPrimUp (1.0 ), wPrimLow (1.0 );
1415+
1416+ // Weight assignment
1417+ if (particle.pt () < primaryAntiprotons->GetXaxis ()->GetXmax ()) {
1418+ int ipt = primaryAntiprotons->FindBin (particle.pt ());
1419+ wPrimStd = primaryAntiprotons->GetBinContent (ipt);
1420+ wPrimUp = wPrimStd + primaryAntiprotons->GetBinError (ipt);
1421+ wPrimLow = wPrimStd - primaryAntiprotons->GetBinError (ipt);
1422+ }
1423+
1424+ // Fill histograms
1425+ registryMC.fill (HIST (" antip_prim_pythia" ), track.pt ());
1426+ registryMC.fill (HIST (" antip_prim_std" ), track.pt (), wPrimStd);
1427+ registryMC.fill (HIST (" antip_prim_up" ), track.pt (), wPrimUp);
1428+ registryMC.fill (HIST (" antip_prim_low" ), track.pt (), wPrimLow);
1429+ }
1430+
1431+ // Secondary antiprotons from week decays
1432+ if (!particle.isPhysicalPrimary () && particle.has_mothers ()) {
1433+
1434+ // Initialize weights
1435+ double wSecStd (1.0 ), wSecUp (1.0 ), wSecLow (1.0 );
1436+ auto mother = mcParticles.iteratorAt (particle.mothersIds ()[0 ]);
1437+
1438+ // Antiprotons from sigma
1439+ if (std::abs (mother.pdgCode ()) == PDG_t::kSigmaBarMinus ) {
1440+ if (mother.pt () < primaryAntiSigma->GetXaxis ()->GetXmax ()) {
1441+ int ipt = primaryAntiSigma->FindBin (mother.pt ());
1442+ wSecStd = primaryAntiSigma->GetBinContent (ipt);
1443+ wSecUp = wSecStd + primaryAntiSigma->GetBinError (ipt);
1444+ wSecLow = wSecStd - primaryAntiSigma->GetBinError (ipt);
1445+ }
1446+ }
1447+
1448+ // Antiprotons from primary Lambda0
1449+ if (std::abs (mother.pdgCode ()) == kLambda0Bar ) {
1450+ if (mother.isPhysicalPrimary ()) {
1451+ if (mother.pt () < primaryAntiLambda->GetXaxis ()->GetXmax ()) {
1452+ int ipt = primaryAntiLambda->FindBin (mother.pt ());
1453+ wSecStd = primaryAntiLambda->GetBinContent (ipt);
1454+ wSecUp = wSecStd + primaryAntiLambda->GetBinError (ipt);
1455+ wSecLow = wSecStd - primaryAntiLambda->GetBinError (ipt);
1456+ }
1457+ }
1458+
1459+ // Antiprotons from secondary Lambda0 (Xi -> Lambda0)
1460+ if (!mother.isPhysicalPrimary ()) {
1461+ auto grandmother = mcParticles.iteratorAt (mother.mothersIds ()[0 ]);
1462+ if (std::abs (grandmother.pdgCode ()) == kXiMinus ) {
1463+ if (grandmother.pt () < primaryAntiXi->GetXaxis ()->GetXmax ()) {
1464+ int ipt = primaryAntiXi->FindBin (grandmother.pt ());
1465+ wSecStd = primaryAntiXi->GetBinContent (ipt);
1466+ wSecUp = wSecStd + primaryAntiXi->GetBinError (ipt);
1467+ wSecLow = wSecStd - primaryAntiXi->GetBinError (ipt);
1468+ }
1469+ }
1470+
1471+ // Antiprotons from secondary Lambda0 (Omega -> Lambda0)
1472+ if (std::abs (grandmother.pdgCode ()) == kOmegaMinus ) {
1473+ if (grandmother.pt () < primaryAntiOmega->GetXaxis ()->GetXmax ()) {
1474+ int ipt = primaryAntiOmega->FindBin (grandmother.pt ());
1475+ wSecStd = primaryAntiOmega->GetBinContent (ipt);
1476+ wSecUp = wSecStd + primaryAntiOmega->GetBinError (ipt);
1477+ wSecLow = wSecStd - primaryAntiOmega->GetBinError (ipt);
1478+ }
1479+ }
1480+ }
1481+ }
1482+
1483+ // Fill histograms
1484+ registryMC.fill (HIST (" antip_sec_pythia" ), track.pt ());
1485+ registryMC.fill (HIST (" antip_sec_std" ), track.pt (), wSecStd);
1486+ registryMC.fill (HIST (" antip_sec_up" ), track.pt (), wSecUp);
1487+ registryMC.fill (HIST (" antip_sec_low" ), track.pt (), wSecLow);
1488+ }
1489+ }
1490+
1491+ // ****************************************************************************************************************
1492+
13471493 // Select only physical primary particles
13481494 if (!particle.isPhysicalPrimary ())
13491495 continue ;
0 commit comments