311 if (
m_SUSYTools->resetSystematics() != StatusCode::SUCCESS) {
319 return StatusCode::SUCCESS;
339 if (!
evtStore()->event()->retrieveMetaInput(completeCBC,
"CutBookkeepers").isSuccess()) {
340 ATH_MSG_ERROR(
"Failed to retrieve CutBookkeepers from MetaData! Exiting.");
343 for (
const auto *cbk : *completeCBC ) {
344 cbkname = cbk->name();
345 stream = cbk->inputStream();
346 ATH_MSG_INFO(
"cbkname: " << cbkname <<
", stream: " << stream);
347 if (cbkname.find(
"PHYSVAL")!=std::string::npos)
m_kernel=
"PHYSVAL";
348 else if (cbkname.find(
"PHYSLITE")!=std::string::npos)
m_kernel=
"PHYSLITE";
349 else if (cbkname.find(
"PHYS")!=std::string::npos)
m_kernel=
"PHYS";
350 else if (stream.find(
"StreamDAOD")!=std::string::npos)
m_kernel=stream.replace(stream.find(
"Stream"),6,
"");
358 if (stream.find(
"PHYSVAL")!=std::string::npos)
m_kernel=
"PHYSVAL";
359 else if (stream.find(
"PHYSLITE")!=std::string::npos)
m_kernel=
"PHYSLITE";
360 else if (stream.find(
"PHYS")!=std::string::npos)
m_kernel=
"PHYS";
361 else if (stream.find(
"StreamDAOD")!=std::string::npos)
m_kernel=stream.replace(stream.find(
"Stream"),6,
"");
373 TH1* info_runNo =
hist(
"EventInfo/info_runNo");
374 TH1* info_evtNo =
hist(
"EventInfo/info_evtNo");
375 TH1* info_lumiBlock =
hist(
"EventInfo/info_lumiBlock");
378 info_lumiBlock->Fill(evtInfo->
lumiBlock());
412 static std::atomic<bool> doFatJets =
true;
420 return StatusCode::FAILURE;
425 }
else if(
m_slices[
"jet"] && doFatJets) {
430 static std::atomic<bool> doTrkJets =
true;
438 return StatusCode::FAILURE;
443 }
else if(
m_slices[
"jet"] && doTrkJets) {
483 for(
const auto tau : *taus_gettruth) {
500 double metsig_cst(0.);
501 double metsig_tst(0.);
530 hist(
"MET/met_significance")->Fill( metsig_tst );
534 ATH_CHECK(
m_SUSYTools->OverlapRemoval(electrons_nominal, muons_nominal, jets_nominal, photons_nominal, taus_nominal) );
537 bool isRun3Trig =
false;
538 if (
m_mcCampaign.find(
"mc21") != std::string::npos ||
m_mcCampaign.find(
"mc23") != std::string::npos) isRun3Trig =
true;
540 hist(
"Trigger/isMETTrigPassed")->Fill(
double(
m_SUSYTools->IsMETTrigPassed()) );
547 TH1* el_n_flow_nominal =
hist(
"Cutflow/el_n_flow_nominal");
548 TH1* el_trigmatch_eff_nominal =
hist(
"Trigger/el_trigmatch_eff_nominal");
553 for(
auto el : *electrons_nominal) {
571 bool passit = ((isRun3Trig||t.find(
"_L1")==std::string::npos) ?
m_SUSYTools->IsTrigMatched(el, t) :
false);
573 if(passit) el_trigmatch_eff_nominal->SetBinContent(idx, el_trigmatch_eff_nominal->GetBinContent(idx)+1);
574 #ifdef XAOD_STANDALONE
575 m_heffs[
"Trigger/el_pt_"+t]->Fill(passit,el->pt()/1000.);
576 m_heffs[
"Trigger/el_eta_"+t]->Fill(passit,el->eta());
577 m_heffs[
"Trigger/el_phi_"+t]->Fill(passit,el->phi());
594 TH1* ph_n_flow_nominal =
hist(
"Cutflow/ph_n_flow_nominal");
595 TH1* ph_trigmatch_eff_nominal =
hist(
"Trigger/ph_trigmatch_eff_nominal");
600 for(
auto ph : *photons_nominal) {
616 bool passit = ((isRun3Trig||t.find(
"_L1")==std::string::npos) ?
m_SUSYTools->IsTrigMatched(ph, t) :
false);
618 if(passit) ph_trigmatch_eff_nominal->SetBinContent(idx, ph_trigmatch_eff_nominal->GetBinContent(idx)+1);
619 #ifdef XAOD_STANDALONE
620 m_heffs[
"Trigger/ph_pt_"+t]->Fill(passit,ph->pt()/1000.);
621 m_heffs[
"Trigger/ph_eta_"+t]->Fill(passit,ph->eta());
622 m_heffs[
"Trigger/ph_phi_"+t]->Fill(passit,ph->phi());
639 TH1* mu_n_flow_nominal =
hist(
"Cutflow/mu_n_flow_nominal");
640 TH1* mu_trigmatch_eff_nominal =
hist(
"Trigger/mu_trigmatch_eff_nominal");
645 for(
auto mu : *muons_nominal) {
661 bool passit = ((isRun3Trig||t.find(
"_L1")==std::string::npos) ?
m_SUSYTools->IsTrigMatched(mu, t) :
false);
663 if(passit) mu_trigmatch_eff_nominal->SetBinContent(idx, mu_trigmatch_eff_nominal->GetBinContent(idx)+1);
664 #ifdef XAOD_STANDALONE
665 m_heffs[
"Trigger/mu_pt_"+t]->Fill(passit,mu->pt()/1000.);
666 m_heffs[
"Trigger/mu_eta_"+t]->Fill(passit,mu->eta());
667 m_heffs[
"Trigger/mu_phi_"+t]->Fill(passit,mu->phi());
684 TH1* jet_n_flow_nominal =
hist(
"Cutflow/jet_n_flow_nominal");
685 TH1* bjet_n_flow_nominal =
hist(
"Cutflow/bjet_n_flow_nominal");
690 for(
auto jet : *jets_nominal) {
695 if (bjet) bjet_n_flow_nominal->Fill(
Cut::all);
736 TH1* fatjet_n_flow_nominal =
hist(
"Cutflow/fatjet_n_flow_nominal");
738 if(
m_slices[
"fjet"] && doFatJets ) {
742 std::string taggerKey;
743 taggerKey =
findInReg(reg, (*fatjets_nominal)[0],
"(SmoothW.*?)_.*");
744 if (!taggerKey.empty()) {
m_configDict[
"WtaggerKey"] = taggerKey; }
748 std::string taggerKey;
749 taggerKey =
findInReg(reg, (*fatjets_nominal)[0],
"(SmoothZ.*?)_.*");
750 if (!taggerKey.empty()) {
m_configDict[
"ZtaggerKey"] = taggerKey; }
754 std::string taggerKey;
755 taggerKey =
findInReg(reg, (*fatjets_nominal)[0],
"(.*Tag.*Top.*?)_.*");
756 if (!taggerKey.empty()) {
m_configDict[
"ToptaggerKey"] = taggerKey; }
764 for(
auto fatjet : *fatjets_nominal) {
765 fatjet_n_flow_nominal->Fill(
Cut::all);
789 TH1* trkjet_n_flow_nominal =
hist(
"Cutflow/trkjet_n_flow_nominal");
791 if(
m_slices[
"tjet"] && doTrkJets ) {
793 for(
auto trkjet : *trkjets_nominal) {
794 trkjet_n_flow_nominal->Fill(
Cut::all);
818 TH1* tau_n_flow_nominal =
hist(
"Cutflow/tau_n_flow_nominal");
822 for(
auto tau : *taus_nominal) {
848 double base_event_weight(1.);
856 ATH_MSG_DEBUG(
"Truth MET etx=" << (*met_truth)[
"NonInt"]->mpx()
857 <<
", ety=" << (*met_truth)[
"NonInt"]->mpy()
858 <<
", et=" << (*met_truth)[
"NonInt"]->
met()
859 <<
", sumet=" << (*met_truth)[
"NonInt"]->sumet());
861 <<
", dety=" << (*
m_metcst_nominal)[
"Final"]->mpy() - (*met_truth)[
"NonInt"]->mpy());
863 <<
", dety=" << (*
m_mettst_nominal)[
"Final"]->mpy() - (*met_truth)[
"NonInt"]->mpy());
869 double electrons_weight_nominal(1.);
870 double photons_weight_nominal(1.);
871 double muons_weight_nominal(1.);
872 double jets_weight_nominal(1.);
875 double btag_weight_nominal(1.);
876 double taus_weight_nominal(1.);
877 double event_weight_nominal(1.);
878 double prw_weight_nominal(1.);
881 TH1* weight_event =
hist(
"Syst/weight_event");
882 TH1* weight_electrons =
hist(
"Syst/weight_electrons");
883 TH1* weight_muons =
hist(
"Syst/weight_muons");
884 TH1* weight_photons =
hist(
"Syst/weight_photons");
885 TH1* weight_taus =
hist(
"Syst/weight_taus");
886 TH1* weight_jets =
hist(
"Syst/weight_jets");
887 TH1* weight_btags =
hist(
"Syst/weight_btags");
889 bool isNominal(
true);
892 if (
m_SUSYTools->applySystematicVariation(sys) != StatusCode::SUCCESS) {
893 ATH_MSG_ERROR(
"Cannot configure SUSYTools for systematic var. %s" << sys.name() );
897 if (isNominal && (sysInfo.affectsKinematics || sysInfo.affectsWeights)) {
899 return StatusCode::FAILURE;
901 if (sysInfo.affectsKinematics || sysInfo.affectsWeights) isNominal =
false;
903 double event_weight = base_event_weight;
908 double prw_weight=1.;
910 if(!isData) prw_weight_nominal =
m_SUSYTools->GetPileupWeight();
911 event_weight *= prw_weight_nominal;
912 weight_event->SetBinContent(1, weight_event->GetBinContent(1)+event_weight);
914 else if (!syst_affectsEventWeight) {
915 event_weight *= prw_weight_nominal;
922 event_weight *= prw_weight;
924 if(iwbin <
m_syst_weights[
"EventWeight"].size()) { weight_event->SetBinContent(iwbin+1, weight_event->GetBinContent(iwbin+1)+event_weight); }
956 if (sysInfo.affectsKinematics) {
957 if (
m_slices[
"el"] && syst_affectsElectrons) {
962 electrons = electrons_syst;
965 if (
m_slices[
"pho"] && syst_affectsPhotons) {
970 photons = photons_syst;
973 if (
m_slices[
"mu"] && syst_affectsMuons) {
981 if (syst_affectsJets) {
989 if (
m_slices[
"fjet"] and doFatJets) {
994 fatjets = fatjets_syst;
1001 trkjets = trkjets_syst;
1005 if (
m_slices[
"tau"] && syst_affectsTaus) {
1040 float electrons_weight(1.);
1041 for (
const auto el : *electrons ) {
1043 if (isNominal || syst_affectsElectrons) {
1044 if ((
ST::acc_signal(*el) == 1) && (isNominal || sysInfo.affectsWeights)) {
1046 electrons_weight *=
m_SUSYTools->GetSignalElecSF(*el,
true,
true,
false,
true);
1057 electrons_weight_nominal = electrons_weight;
1058 weight_electrons->SetBinContent(1, weight_electrons->GetBinContent(1)+electrons_weight);
1060 else if (!syst_affectsElectrons) {
1061 electrons_weight = electrons_weight_nominal;
1063 else if ( sysInfo.affectsWeights ){
1065 if(iwbin <
m_syst_weights[
"Electron"].size()) { weight_electrons->SetBinContent(iwbin+1, weight_electrons->GetBinContent(iwbin+1)+electrons_weight); }
1068 event_weight *= electrons_weight;
1069 ATH_MSG_DEBUG(
"Combined electron scale factor: " << electrons_weight);
1075 float photons_weight(1.);
1076 for (
const auto ph : *photons ) {
1078 if (isNominal || syst_affectsPhotons) {
1079 if ((
ST::acc_signal(*ph) == 1) && (isNominal || sysInfo.affectsWeights)) {
1080 photons_weight *=
m_SUSYTools->GetSignalPhotonSF( *ph );
1090 photons_weight_nominal = photons_weight;
1091 weight_photons->SetBinContent(1, weight_photons->GetBinContent(1)+photons_weight);
1093 else if (!syst_affectsPhotons) {
1094 photons_weight = photons_weight_nominal;
1096 else if ( sysInfo.affectsWeights ){
1098 if(iwbin <
m_syst_weights[
"Photon"].size()) { weight_photons->SetBinContent(iwbin+1, weight_photons->GetBinContent(iwbin+1)+photons_weight); }
1101 event_weight *= photons_weight;
1102 ATH_MSG_DEBUG(
"Combined photon scale factor: " << photons_weight);
1108 float muons_weight(1.);
1109 for (
const auto mu : *muons ) {
1111 if (isNominal || syst_affectsMuons) {
1112 if ((
ST::acc_signal(*mu) == 1) && (isNominal || sysInfo.affectsWeights)) {
1113 muons_weight *=
m_SUSYTools->GetSignalMuonSF(*mu);;
1124 muons_weight_nominal = muons_weight;
1125 weight_muons->SetBinContent(1, weight_muons->GetBinContent(1)+muons_weight);
1127 else if (!syst_affectsMuons) {
1128 muons_weight = muons_weight_nominal;
1130 else if ( sysInfo.affectsWeights ){
1132 if(iwbin <
m_syst_weights[
"Muon"].size()) { weight_muons->SetBinContent(iwbin+1, weight_muons->GetBinContent(iwbin+1)+muons_weight); }
1135 event_weight *= muons_weight;
1136 ATH_MSG_DEBUG(
"Combined muon scale factor: " << muons_weight);
1142 for (
const auto jet : *jets ) {
1147 if (
m_slices[
"bjet"] && (isNominal || syst_affectsJets || syst_affectsBTag)) {
1154 float jet_weight(1.);
1155 float btag_weight(1.);
1158 btag_weight_nominal = btag_weight =
m_SUSYTools->BtagSF(jets);
1159 weight_btags->SetBinContent(1, weight_btags->GetBinContent(1)+btag_weight);
1161 else if (!syst_affectsBTag){
1162 btag_weight = btag_weight_nominal;
1167 if(iwbin <
m_syst_weights[
"BTag"].size()) { weight_btags->SetBinContent(iwbin+1, weight_btags->GetBinContent(iwbin+1)+btag_weight); }
1173 jets_weight_nominal = jet_weight;
1174 jets_weight_nominal *=
m_SUSYTools->FJVT_SF(jets);
1175 weight_jets->SetBinContent(1, weight_jets->GetBinContent(1)+jet_weight);
1177 else if (!syst_affectsJets || (syst_affectsJets && !sysInfo.affectsWeights)){
1178 jet_weight = jets_weight_nominal;
1180 else if ( syst_affectsJets && sysInfo.affectsWeights ){
1184 if(iwbin <
m_syst_weights[
"Jet"].size()) { weight_jets->SetBinContent(iwbin+1, weight_jets->GetBinContent(iwbin+1)+jet_weight); }
1188 weight_jets->SetBinContent(1, 1.);
1189 weight_btags->SetBinContent(1, 1.);
1191 event_weight *= jet_weight;
1192 event_weight *= btag_weight;
1193 ATH_MSG_DEBUG(
"Combined b-tagging scale factor: " << btag_weight);
1199 if(
m_slices[
"fjet"] && doFatJets ) {
1201 for (
const auto fatjet : *fatjets ) {
1207 float fatjet_weight(1.);
1223 ATH_MSG_DEBUG(
"Combined large radius jet scale factor: " << fatjet_weight);
1228 if(
m_slices[
"tjet"] && doTrkJets ) {
1230 for (
const auto trkjet : *trkjets ) {
1236 float trkjet_weight(1.);
1252 ATH_MSG_DEBUG(
"Combined track jet scale factor: " << trkjet_weight);
1258 float taus_weight(1.);
1259 for (
const auto ta : *
taus ) {
1261 if (isNominal || syst_affectsTaus) {
1262 if ((
ST::acc_signal(*ta) == 1) && (isNominal || sysInfo.affectsWeights)) {
1263 taus_weight *=
m_SUSYTools->GetSignalTauSF(*ta,
true,
false);
1274 taus_weight_nominal = taus_weight;
1275 weight_taus->SetBinContent(1, weight_taus->GetBinContent(1)+taus_weight);
1277 else if (!syst_affectsTaus) {
1278 taus_weight = taus_weight_nominal;
1280 else if ( sysInfo.affectsWeights ){
1282 if(iwbin <
m_syst_weights[
"Tau"].size()) { weight_taus->SetBinContent(iwbin+1, weight_taus->GetBinContent(iwbin+1)+taus_weight); }
1285 event_weight *= taus_weight;
1290 if (isNominal) {event_weight_nominal = event_weight;}
1291 else if (sysInfo.affectsWeights)
ATH_MSG_DEBUG(
"Difference with nominal weight: " << event_weight - event_weight_nominal);
1294 if (sysInfo.affectsKinematics) {
1316 return StatusCode::SUCCESS;