@@ -132,7 +132,7 @@ struct JetMatching {
132132
133133struct AntinucleiInJets {
134134
135- // Random engine (Mersenne Twister)
135+ // Random Engine (Mersenne Twister)
136136 std::mt19937 rng;
137137 std::uniform_int_distribution<int > generateRandomNr{0 , 1 };
138138
@@ -205,14 +205,7 @@ struct AntinucleiInJets {
205205 // Configuration parameters for CCDB access and reweighting input files
206206 Configurable<bool > applyReweighting{" applyReweighting" , true , " enable reweighting for efficiency" };
207207 Configurable<std::string> urlToCcdb{" urlToCcdb" , " http://alice-ccdb.cern.ch/" , " url of the personal ccdb" };
208- Configurable<std::string> pathToFile{" pathToFile" , " Users/a/alcaliva/reweightingHistogramsAnalysis/" , " path to file" };
209- Configurable<std::string> weightsProton{" weightsProton" , " weightsProton" , " weightsProton" };
210- Configurable<std::string> weightsLambda{" weightsLambda" , " weightsLambda" , " weightsLambda" };
211- Configurable<std::string> weightsSigma{" weightsSigma" , " weightsSigma" , " weightsSigma" };
212- Configurable<std::string> weightsXi{" weightsXi" , " weightsXi" , " weightsXi" };
213- Configurable<std::string> weightsOmega{" weightsOmega" , " weightsOmega" , " weightsOmega" };
214- Configurable<std::string> weightsJet{" weightsJet" , " weightsJet" , " weightsJet" };
215- Configurable<std::string> weightsUe{" weightsUe" , " weightsUe" , " weightsUe" };
208+ Configurable<std::string> pathToFile{" pathToFile" , " Users/a/alcaliva/reweightingHistogramsAntinucleiInJets/" , " path to file" };
216209
217210 // Number of events
218211 Configurable<int > shrinkInterval{" shrinkInterval" , 1000 , " variable that controls how often shrinking happens" };
@@ -225,16 +218,18 @@ struct AntinucleiInJets {
225218 Configurable<double > coalescenceMomentum{" coalescenceMomentum" , 0.15 , " p0 (GeV/c)" };
226219
227220 // Reweighting histograms
228- TH1F * primaryAntiprotons;
229- TH1F * primaryAntiLambda;
230- TH1F * primaryAntiSigma;
231- TH1F * primaryAntiXi;
232- TH1F * primaryAntiOmega;
233- TH1F * antiprotonsInsideJets;
234- TH1F * antiprotonsPerpCone;
221+ TH1F * primaryAntiprotons = nullptr ;
222+ TH1F * primaryAntiLambda = nullptr ;
223+ TH1F * primaryAntiSigma = nullptr ;
224+ TH1F * primaryAntiXi = nullptr ;
225+ TH1F * primaryAntiOmega = nullptr ;
226+ TH1F * antiprotonsInsideJets = nullptr ;
227+ TH1F * antiprotonsPerpCone = nullptr ;
228+ TH1F * antideuteronsInsideJets = nullptr ;
229+ TH1F * antideuteronsPerpCone = nullptr ;
235230
236231 // CCDB manager service for accessing condition data
237- Service<o2::ccdb::BasicCCDBManager> ccdb;
232+ Service<o2::ccdb::BasicCCDBManager> ccdb{} ;
238233
239234 // Direct interface to the CCDB API for manual data access
240235 o2::ccdb::CcdbApi ccdbApi;
@@ -284,7 +279,7 @@ struct AntinucleiInJets {
284279 ccdb->setLocalObjectValidityChecking ();
285280 ccdb->setCreatedNotAfter (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now ().time_since_epoch ()).count ());
286281 ccdb->setFatalWhenNull (false );
287- getReweightingHistograms (ccdb, TString (pathToFile), TString (weightsProton), TString (weightsLambda), TString (weightsSigma), TString (weightsXi), TString (weightsOmega), TString (weightsJet), TString (weightsUe) );
282+ getReweightingHistograms (ccdb, TString (pathToFile));
288283 }
289284
290285 // Binning
@@ -395,6 +390,8 @@ struct AntinucleiInJets {
395390 // Generated spectra of antideuterons
396391 registryMC.add (" antideuteron_gen_jet" , " antideuteron_gen_jet" , HistType::kTH1F , {{nbins, min, max, " #it{p}_{T} (GeV/#it{c})" }});
397392 registryMC.add (" antideuteron_gen_ue" , " antideuteron_gen_ue" , HistType::kTH1F , {{nbins, min, max, " #it{p}_{T} (GeV/#it{c})" }});
393+ registryMC.add (" antideuteron_gen_jet_noweight" , " antideuteron_gen_jet_noweight" , HistType::kTH1F , {{nbins, min, max, " #it{p}_{T} (GeV/#it{c})" }});
394+ registryMC.add (" antideuteron_gen_ue_noweight" , " antideuteron_gen_ue_noweight" , HistType::kTH1F , {{nbins, min, max, " #it{p}_{T} (GeV/#it{c})" }});
398395
399396 // Generated spectra of antiprotons for closure test
400397 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 {
686683 }
687684 }
688685
689- 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 )
686+ void getReweightingHistograms (o2::framework::Service<o2::ccdb::BasicCCDBManager> const & ccdbObj, TString const & filepath )
690687 {
691688 TList* list = ccdbObj->get <TList>(filepath.Data ());
692689 if (!list) {
@@ -695,21 +692,28 @@ struct AntinucleiInJets {
695692 }
696693
697694 // Get reweighting histograms for primary fraction
698- primaryAntiprotons = static_cast <TH1F *>(list->FindObject (antip ));
699- primaryAntiLambda = static_cast <TH1F *>(list->FindObject (antilambda ));
700- primaryAntiSigma = static_cast <TH1F *>(list->FindObject (antisigma ));
701- primaryAntiXi = static_cast <TH1F *>(list->FindObject (antixi ));
702- primaryAntiOmega = static_cast <TH1F *>(list->FindObject (antiomega ));
695+ primaryAntiprotons = dynamic_cast <TH1F *>(list->FindObject (" weightsProton " ));
696+ primaryAntiLambda = dynamic_cast <TH1F *>(list->FindObject (" weightsLambda " ));
697+ primaryAntiSigma = dynamic_cast <TH1F *>(list->FindObject (" weightsSigma " ));
698+ primaryAntiXi = dynamic_cast <TH1F *>(list->FindObject (" weightsXi " ));
699+ primaryAntiOmega = dynamic_cast <TH1F *>(list->FindObject (" weightsOmega " ));
703700
704701 if (!primaryAntiprotons || !primaryAntiSigma || !primaryAntiLambda || !primaryAntiXi || !primaryAntiOmega) {
705702 LOGP (error, " Missing one or more reweighting histograms for primary fraction in CCDB list" );
706703 }
707704
708- // Get reweighting histograms for efficiency
709- antiprotonsInsideJets = static_cast <TH1F *>(list->FindObject (jet ));
710- antiprotonsPerpCone = static_cast <TH1F *>(list->FindObject (ue ));
705+ // Get reweighting histograms for antiproton efficiency
706+ antiprotonsInsideJets = dynamic_cast <TH1F *>(list->FindObject (" weightsJet " ));
707+ antiprotonsPerpCone = dynamic_cast <TH1F *>(list->FindObject (" weightsUe " ));
711708 if (!antiprotonsInsideJets || !antiprotonsPerpCone) {
712- LOGP (error, " Missing one or more reweighting histograms for efficiency in CCDB list" );
709+ LOGP (error, " Missing one or more reweighting histograms for antiproton efficiency in CCDB list" );
710+ }
711+
712+ // Get reweighting histograms for antideuteron efficiency
713+ antideuteronsInsideJets = dynamic_cast <TH1F *>(list->FindObject (" weightsAntidJet" ));
714+ antideuteronsPerpCone = dynamic_cast <TH1F *>(list->FindObject (" weightsAntidUe" ));
715+ if (!antideuteronsInsideJets || !antideuteronsPerpCone) {
716+ LOGP (error, " Missing one or more reweighting histograms for antideuteron efficiency in CCDB list" );
713717 }
714718
715719 LOGP (info, " Successfully loaded reweighting histograms from CCDB path" );
@@ -770,7 +774,7 @@ struct AntinucleiInJets {
770774
771775 // Evaluate proton–neutron coalescence for deuteron formation
772776 template <typename ReducedPart>
773- bool passDeuteronCoalescence (const ReducedPart& p, const ReducedPart& n, double p0, TRandom3& mRand )
777+ bool passDeuteronCoalescence (const ReducedPart& p, const ReducedPart& n, double p0, TRandom3& random )
774778 {
775779 // Nucleon masses
776780 const double mp = o2::constants::physics::MassProton;
@@ -810,7 +814,7 @@ struct AntinucleiInJets {
810814 }
811815
812816 // Spin-statistical acceptance
813- if (mRand .Uniform () > SpinFactor) {
817+ if (random .Uniform () > SpinFactor) {
814818 return false ;
815819 }
816820 return true ;
@@ -1784,6 +1788,8 @@ struct AntinucleiInJets {
17841788 case PDG_t::kSigmaBarMinus :
17851789 registryMC.fill (HIST (" sigmaBar" ), particle.pt ());
17861790 break ;
1791+ default :
1792+ break ;
17871793 }
17881794 }
17891795 }
@@ -2188,7 +2194,14 @@ struct AntinucleiInJets {
21882194
21892195 // Fill antideuteron spectra
21902196 if (isAntid) {
2191- registryMC.fill (HIST (" antideuteron_gen_jet" ), particle.pt ());
2197+ double weightJetAntid (1.0 );
2198+ if (applyReweighting && particle.pt () < antideuteronsInsideJets->GetXaxis ()->GetXmax ()) {
2199+ int ipt = antideuteronsInsideJets->FindBin (particle.pt ());
2200+ weightJetAntid = antideuteronsInsideJets->GetBinContent (ipt);
2201+ }
2202+
2203+ registryMC.fill (HIST (" antideuteron_gen_jet" ), particle.pt (), weightJetAntid);
2204+ registryMC.fill (HIST (" antideuteron_gen_jet_noweight" ), particle.pt ());
21922205 }
21932206 }
21942207
@@ -2255,8 +2268,16 @@ struct AntinucleiInJets {
22552268 if (deltaRUe1 > rJet && deltaRUe2 > rJet)
22562269 continue ;
22572270
2271+ // Calculate weight
2272+ double weightUeAntid (1.0 );
2273+ if (applyReweighting && deuteronVec.Pt () < antideuteronsPerpCone->GetXaxis ()->GetXmax ()) {
2274+ int ipt = antideuteronsPerpCone->FindBin (deuteronVec.Pt ());
2275+ weightUeAntid = antideuteronsPerpCone->GetBinContent (ipt);
2276+ }
2277+
22582278 // Fill histogram for antideuterons in the UE
2259- registryMC.fill (HIST (" antideuteron_gen_ue" ), deuteronVec.Pt ());
2279+ registryMC.fill (HIST (" antideuteron_gen_ue" ), deuteronVec.Pt (), weightUeAntid);
2280+ registryMC.fill (HIST (" antideuteron_gen_ue_noweight" ), deuteronVec.Pt ());
22602281 }
22612282 }
22622283 if (isAtLeastOneJetSelected) {
@@ -2512,7 +2533,7 @@ struct AntinucleiInJets {
25122533 // Fill antiproton spectrum for physical primaries
25132534 registryMC.fill (HIST (" antiproton_prim_jet" ), pt);
25142535
2515- // Calculate weight
2536+ // Calculate weights
25162537 double weightJet (1.0 );
25172538 if (applyReweighting && mcparticle.pt () < antiprotonsInsideJets->GetXaxis ()->GetXmax ()) {
25182539 int ipt = antiprotonsInsideJets->FindBin (mcparticle.pt ());
@@ -2549,16 +2570,23 @@ struct AntinucleiInJets {
25492570 if (std::fabs (dcaxy) > maxDcaxy || std::fabs (dcaz) > maxDcaz)
25502571 continue ;
25512572
2552- // Select physical primary antiprotons
2573+ // Select physical primary antideuterons
25532574 if (!mcparticle.isPhysicalPrimary ())
25542575 continue ;
25552576
2577+ // Calculate weight
2578+ double weightJetAntid (1.0 );
2579+ if (applyReweighting && mcparticle.pt () < antideuteronsInsideJets->GetXaxis ()->GetXmax ()) {
2580+ int ipt = antideuteronsInsideJets->FindBin (mcparticle.pt ());
2581+ weightJetAntid = antideuteronsInsideJets->GetBinContent (ipt);
2582+ }
2583+
25562584 // Fill histograms (TPC and TOF) only for selected candidates
25572585 if (nsigmaTPCDe > minNsigmaTpc && nsigmaTPCDe < maxNsigmaTpc) {
2558- registryMC.fill (HIST (" antideuteron_rec_tpc_jet" ), pt);
2586+ registryMC.fill (HIST (" antideuteron_rec_tpc_jet" ), pt, weightJetAntid );
25592587
25602588 if (track.hasTOF () && nsigmaTOFDe > minNsigmaTof && nsigmaTOFDe < maxNsigmaTof) {
2561- registryMC.fill (HIST (" antideuteron_rec_tof_jet" ), pt);
2589+ registryMC.fill (HIST (" antideuteron_rec_tof_jet" ), pt, weightJetAntid );
25622590 }
25632591 }
25642592 } // end of isAntid
@@ -2624,7 +2652,7 @@ struct AntinucleiInJets {
26242652 // Fill antiproton spectrum for physical primaries
26252653 registryMC.fill (HIST (" antiproton_prim_ue" ), pt);
26262654
2627- // Calculate weight
2655+ // Calculate weights
26282656 double weightUe (1.0 );
26292657 if (applyReweighting && mcparticle.pt () < antiprotonsPerpCone->GetXaxis ()->GetXmax ()) {
26302658 int ipt = antiprotonsPerpCone->FindBin (mcparticle.pt ());
@@ -2689,16 +2717,23 @@ struct AntinucleiInJets {
26892717 if (deltaRUe1 > rJet && deltaRUe2 > rJet)
26902718 continue ;
26912719
2692- // Select physical primary antiprotons
2720+ // Select physical primary antideuterons
26932721 if (!mcparticle.isPhysicalPrimary ())
26942722 continue ;
26952723
2724+ // Calculate weight
2725+ double weightUeAntid (1.0 );
2726+ if (applyReweighting && mcparticle.pt () < antideuteronsPerpCone->GetXaxis ()->GetXmax ()) {
2727+ int ipt = antideuteronsPerpCone->FindBin (mcparticle.pt ());
2728+ weightUeAntid = antideuteronsPerpCone->GetBinContent (ipt);
2729+ }
2730+
26962731 // Fill histograms (TPC and TOF) only for selected candidates
26972732 if (nsigmaTPCDe > minNsigmaTpc && nsigmaTPCDe < maxNsigmaTpc) {
2698- registryMC.fill (HIST (" antideuteron_rec_tpc_ue" ), pt);
2733+ registryMC.fill (HIST (" antideuteron_rec_tpc_ue" ), pt, weightUeAntid );
26992734
27002735 if (track.hasTOF () && nsigmaTOFDe > minNsigmaTof && nsigmaTOFDe < maxNsigmaTof) {
2701- registryMC.fill (HIST (" antideuteron_rec_tof_ue" ), pt);
2736+ registryMC.fill (HIST (" antideuteron_rec_tof_ue" ), pt, weightUeAntid );
27022737 }
27032738 }
27042739 }
@@ -2962,6 +2997,8 @@ struct AntinucleiInJets {
29622997 case -o2::constants::physics::Pdg::kHelium3 :
29632998 registryMC.fill (HIST (" antihelium3_gen_syst" ), particle.pt ());
29642999 break ;
3000+ default :
3001+ break ;
29653002 }
29663003 }
29673004 }
0 commit comments