@@ -170,7 +170,7 @@ struct StrangenessInJets {
170170 ccdb->setFatalWhenNull (false );
171171
172172 if (applyReweighting) {
173- getReweightingHistograms (ccdb, TString (pathToFile), TString (histoNameWeightK0Jet), TString (histoNameWeightK0Ue), TString (histoNameWeightLambdaJet), TString (histoNameWeightLambdaUe), TString (histoNameWeightAntilambdaJet), TString (histoNameWeightAntilambdaUe), TString (histoNameWeightsXiInJet), TString (histoNameWeightsXiInUe), TString (histoNameWeightsAntiXiInJet), TString (histoNameWeightsAntiXiInUe) );
173+ getReweightingHistograms (ccdb);
174174 } else {
175175 twodWeightsK0Jet = nullptr ;
176176 twodWeightsK0Ue = nullptr ;
@@ -892,94 +892,63 @@ struct StrangenessInJets {
892892 return false ;
893893 }
894894
895- void getReweightingHistograms (o2::framework::Service<o2::ccdb::BasicCCDBManager> const & ccdbObj, TString filepath, TString histname_k0_jet, TString histname_k0_ue, TString histname_lambda_jet, TString histname_lambda_ue, TString histname_antilambda_jet, TString histname_antilambda_ue, TString histname_xi_jet, TString histname_xi_ue, TString histname_antixi_jet, TString histname_antixi_ue )
895+ void getReweightingHistograms (o2::framework::Service<o2::ccdb::BasicCCDBManager> const & ccdbObj)
896896 {
897- TList* l = ccdbObj->get <TList>(filepath.Data ());
898- if (!l) {
899- LOGP (error, " Could not open the file {}" , Form (" %s" , filepath.Data ()));
900- return ;
901- }
897+ auto getWeightHistoObj = [&](Configurable<std::string> name, TH2F*& histo) {
898+ if (name.value == " " ) {
899+ LOG (info) << " Getting weight histogram for " << name.name << " from " << name.value ;
900+ histo = ccdbObj->get <TH2F>(name);
901+ }
902+ };
902903
903- if (histoNameWeightPiplusJet.value != " " ) {
904- twodWeightsPiplusJet = ccdbObj->get <TH2F>(filepath.Data ());
905- LOG (info) << " Getting weight histogram for piplus in jet from " << histoNameWeightPiplusJet.value ;
906- }
907- if (histoNameWeightPiplusUe.value != " " ) {
908- twodWeightsPiplusUe = ccdbObj->get <TH2F>(filepath.Data ());
909- LOG (info) << " Getting weight histogram for piplus in ue from " << histoNameWeightPiplusUe.value ;
910- }
911- if (histoNameWeightPiminusJet.value != " " ) {
912- twodWeightsPiminusJet = ccdbObj->get <TH2F>(filepath.Data ());
913- LOG (info) << " Getting weight histogram for piminus in jet from " << histoNameWeightPiminusJet.value ;
914- }
915- if (histoNameWeightPiminusUe.value != " " ) {
916- twodWeightsPiminusUe = ccdbObj->get <TH2F>(filepath.Data ());
917- LOG (info) << " Getting weight histogram for piminus in ue from " << histoNameWeightPiminusUe.value ;
918- }
904+ getWeightHistoObj (histoNameWeightPiplusJet, twodWeightsPiplusJet);
905+ getWeightHistoObj (histoNameWeightPiplusUe, twodWeightsPiplusUe);
906+ getWeightHistoObj (histoNameWeightPiminusJet, twodWeightsPiminusJet);
907+ getWeightHistoObj (histoNameWeightPiminusUe, twodWeightsPiminusUe);
919908
920- twodWeightsK0Jet = static_cast <TH2F*>(l->FindObject (Form (" %s" , histname_k0_jet.Data ())));
921- if (!twodWeightsK0Jet) {
922- LOGP (error, " Could not open histogram {}" , Form (" %s" , histname_k0_jet.Data ()));
923- return ;
924- }
925- twodWeightsK0Ue = static_cast <TH2F*>(l->FindObject (Form (" %s" , histname_k0_ue.Data ())));
926- if (!twodWeightsK0Ue) {
927- LOGP (error, " Could not open histogram {}" , Form (" %s" , histname_k0_ue.Data ()));
928- return ;
929- }
930- twodWeightsLambdaJet = static_cast <TH2F*>(l->FindObject (Form (" %s" , histname_lambda_jet.Data ())));
931- if (!twodWeightsLambdaJet) {
932- LOGP (error, " Could not open histogram {}" , Form (" %s" , histname_lambda_jet.Data ()));
933- return ;
934- }
935- twodWeightsLambdaUe = static_cast <TH2F*>(l->FindObject (Form (" %s" , histname_lambda_ue.Data ())));
936- if (!twodWeightsLambdaUe) {
937- LOGP (error, " Could not open histogram {}" , Form (" %s" , histname_lambda_ue.Data ()));
938- return ;
939- }
940- twodWeightsAntilambdaJet = static_cast <TH2F*>(l->FindObject (Form (" %s" , histname_antilambda_jet.Data ())));
941- if (!twodWeightsAntilambdaJet) {
942- LOGP (error, " Could not open histogram {}" , Form (" %s" , histname_antilambda_jet.Data ()));
943- return ;
944- }
945- twodWeightsAntilambdaUe = static_cast <TH2F*>(l->FindObject (Form (" %s" , histname_antilambda_ue.Data ())));
946- if (!twodWeightsAntilambdaUe) {
947- LOGP (error, " Could not open histogram {}" , Form (" %s" , histname_antilambda_ue.Data ()));
909+ TList* l = ccdbObj->get <TList>(pathToFile.value .c_str ());
910+ if (!l) {
911+ LOG (error) << " Could not open the file " << pathToFile.value ;
948912 return ;
949913 }
914+ l->ls ();
950915
951- // Secondary Lambda
952- weightsXiInJet = static_cast <TH1F*>(l->FindObject (Form (" %s" , histname_xi_jet.Data ())));
953- if (!weightsXiInJet) {
954- LOGP (error, " Could not open histogram {}" , Form (" %s" , histname_xi_jet.Data ()));
955- return ;
956- }
957- weightsXiInUe = static_cast <TH1F*>(l->FindObject (Form (" %s" , histname_xi_ue.Data ())));
958- if (!weightsXiInUe) {
959- LOGP (error, " Could not open histogram {}" , Form (" %s" , histname_xi_ue.Data ()));
960- return ;
961- }
962- weightsAntiXiInJet = static_cast <TH1F*>(l->FindObject (Form (" %s" , histname_antixi_jet.Data ())));
963- if (!weightsAntiXiInJet) {
964- LOGP (error, " Could not open histogram {}" , Form (" %s" , histname_antixi_jet.Data ()));
965- return ;
966- }
967- weightsAntiXiInUe = static_cast <TH1F*>(l->FindObject (Form (" %s" , histname_antixi_ue.Data ())));
968- if (!weightsAntiXiInUe) {
969- LOGP (error, " Could not open histogram {}" , Form (" %s" , histname_antixi_ue.Data ()));
970- return ;
971- }
916+ auto get2DWeightHisto = [&](Configurable<std::string> name, TH2F*& histo) {
917+ LOG (info) << " Looking for 2D weight histogram '" << name.value << " ' for " << name.name ;
918+ if (name.value == " " ) {
919+ LOG (info) << " -> Skipping" ;
920+ }
921+ histo = static_cast <TH2F*>(l->FindObject (name.value .c_str ()));
922+ if (!histo) {
923+ LOG (error) << " Could not open histogram '" << name.value << " '" ;
924+ }
925+ LOG (info) << " Opened histogram " << histo->ClassName () << " " << histo->GetName ();
926+ };
927+
928+ get2DWeightHisto (histoNameWeightK0Jet, twodWeightsK0Jet);
929+ get2DWeightHisto (histoNameWeightK0Ue, twodWeightsK0Ue);
930+ get2DWeightHisto (histoNameWeightLambdaJet, twodWeightsLambdaJet);
931+ get2DWeightHisto (histoNameWeightLambdaUe, twodWeightsLambdaUe);
932+ get2DWeightHisto (histoNameWeightAntilambdaJet, twodWeightsAntilambdaJet);
933+ get2DWeightHisto (histoNameWeightAntilambdaUe, twodWeightsAntilambdaUe);
934+
935+ auto get1DWeightHisto = [&](Configurable<std::string> name, TH1F*& histo) {
936+ LOG (info) << " Looking for 1D weight histogram '" << name.value << " ' for " << name.name ;
937+ if (name.value == " " ) {
938+ LOG (info) << " -> Skipping" ;
939+ }
940+ histo = static_cast <TH1F*>(l->FindObject (name.value .c_str ()));
941+ if (!histo) {
942+ LOG (error) << " Could not open histogram '" << name.value << " '" ;
943+ }
944+ LOG (info) << " Opened histogram " << histo->ClassName () << " " << histo->GetName ();
945+ };
972946
973- LOGP (info, " Opened histogram {}" , Form (" %s" , histname_k0_jet.Data ()));
974- LOGP (info, " Opened histogram {}" , Form (" %s" , histname_k0_ue.Data ()));
975- LOGP (info, " Opened histogram {}" , Form (" %s" , histname_lambda_jet.Data ()));
976- LOGP (info, " Opened histogram {}" , Form (" %s" , histname_lambda_ue.Data ()));
977- LOGP (info, " Opened histogram {}" , Form (" %s" , histname_antilambda_jet.Data ()));
978- LOGP (info, " Opened histogram {}" , Form (" %s" , histname_antilambda_ue.Data ()));
979- LOGP (info, " Opened histogram {}" , Form (" %s" , histname_xi_jet.Data ()));
980- LOGP (info, " Opened histogram {}" , Form (" %s" , histname_xi_ue.Data ()));
981- LOGP (info, " Opened histogram {}" , Form (" %s" , histname_antixi_jet.Data ()));
982- LOGP (info, " Opened histogram {}" , Form (" %s" , histname_antixi_ue.Data ()));
947+ // Secondary Lambda
948+ get1DWeightHisto (histoNameWeightsXiInJet, weightsXiInJet);
949+ get1DWeightHisto (histoNameWeightsXiInUe, weightsXiInUe);
950+ get1DWeightHisto (histoNameWeightsAntiXiInJet, weightsAntiXiInJet);
951+ get1DWeightHisto (histoNameWeightsAntiXiInUe, weightsAntiXiInUe);
983952 }
984953
985954 void processData (SelCollisions::iterator const & collision, aod::V0Datas const & fullV0s, aod::CascDataExt const & Cascades, StrHadronDaughterTracks const & tracks)
@@ -1525,14 +1494,25 @@ struct StrangenessInJets {
15251494 double wSecLambdaInJet (1.0 );
15261495 double wSecLambdaInUe (1.0 );
15271496 int idMother = posParticle.mothersIds ()[0 ];
1528- auto mother = mcParticles.iteratorAt (idMother);
1497+ const auto & mother = mcParticles.iteratorAt (idMother);
15291498 int idGrandMother = mother.mothersIds ()[0 ];
1530- auto grandMother = mcParticles.iteratorAt (idGrandMother);
1531- int ibinXiInJet = weightsXiInJet->GetXaxis ()->FindBin (grandMother.pt ());
1532- int ibinXiInUe = weightsXiInUe->GetXaxis ()->FindBin (grandMother.pt ());
1533- if (std::fabs (grandMother.pdgCode ()) == 3312 || std::fabs (grandMother.pdgCode ()) == 3322 ) {
1534- wSecLambdaInJet = weightsXiInJet->GetBinContent (ibinXiInJet);
1535- wSecLambdaInUe = weightsXiInUe->GetBinContent (ibinXiInUe);
1499+ const auto & grandMother = mcParticles.iteratorAt (idGrandMother);
1500+ switch (grandMother.pdgCode ()) {
1501+ case 3312 :
1502+ case -3312 :
1503+ case 3322 :
1504+ case -3322 :
1505+ if (weightsXiInJet) {
1506+ int ibinXiInJet = weightsXiInJet->GetXaxis ()->FindBin (grandMother.pt ());
1507+ wSecLambdaInJet = weightsXiInJet->GetBinContent (ibinXiInJet);
1508+ }
1509+ if (weightsXiInUe) {
1510+ int ibinXiInUe = weightsXiInUe->GetXaxis ()->FindBin (grandMother.pt ());
1511+ wSecLambdaInUe = weightsXiInUe->GetBinContent (ibinXiInUe);
1512+ }
1513+ break ;
1514+ default :
1515+ break ;
15361516 }
15371517 registryMC.fill (HIST (" Secondary_Lambda_InJet" ), v0.pt (), wSecLambdaInJet);
15381518 registryMC.fill (HIST (" Secondary_Lambda_InUe" ), v0.pt (), wSecLambdaInUe);
@@ -1544,16 +1524,26 @@ struct StrangenessInJets {
15441524 if (!isPhysPrim) {
15451525 double wSecAntiLambdaInJet (1.0 );
15461526 double wSecAntiLambdaInUe (1.0 );
1547-
15481527 int idMother = posParticle.mothersIds ()[0 ];
1549- auto mother = mcParticles.iteratorAt (idMother);
1528+ const auto & mother = mcParticles.iteratorAt (idMother);
15501529 int idGrandMother = mother.mothersIds ()[0 ];
1551- auto grandMother = mcParticles.iteratorAt (idGrandMother);
1552- int ibinAntiXiInJet = weightsAntiXiInJet->GetXaxis ()->FindBin (grandMother.pt ());
1553- int ibinAntiXiInUe = weightsAntiXiInUe->GetXaxis ()->FindBin (grandMother.pt ());
1554- if (std::fabs (grandMother.pdgCode ()) == 3312 || std::fabs (grandMother.pdgCode ()) == 3322 ) {
1555- wSecAntiLambdaInJet = weightsAntiXiInJet->GetBinContent (ibinAntiXiInJet);
1556- wSecAntiLambdaInUe = weightsAntiXiInUe->GetBinContent (ibinAntiXiInUe);
1530+ const auto & grandMother = mcParticles.iteratorAt (idGrandMother);
1531+ switch (grandMother.pdgCode ()) {
1532+ case 3312 :
1533+ case -3312 :
1534+ case 3322 :
1535+ case -3322 :
1536+ if (weightsAntiXiInJet) {
1537+ int ibinAntiXiInJet = weightsAntiXiInJet->GetXaxis ()->FindBin (grandMother.pt ());
1538+ wSecAntiLambdaInJet = weightsAntiXiInJet->GetBinContent (ibinAntiXiInJet);
1539+ }
1540+ if (weightsAntiXiInUe) {
1541+ int ibinAntiXiInUe = weightsAntiXiInUe->GetXaxis ()->FindBin (grandMother.pt ());
1542+ wSecAntiLambdaInUe = weightsAntiXiInUe->GetBinContent (ibinAntiXiInUe);
1543+ }
1544+ break ;
1545+ default :
1546+ break ;
15571547 }
15581548 registryMC.fill (HIST (" Secondary_AntiLambda_InJet" ), v0.pt (), wSecAntiLambdaInJet);
15591549 registryMC.fill (HIST (" Secondary_AntiLambda_InUe" ), v0.pt (), wSecAntiLambdaInUe);
0 commit comments