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);
739 TH1* fatjet_n_flow_nominal =
hist(
"Cutflow/fatjet_n_flow_nominal");
741 if(
m_slices[
"fjet"] && doFatJets ) {
745 std::string taggerKey;
746 taggerKey =
findInReg(reg, (*fatjets_nominal)[0],
"(SmoothW.*?)_.*");
747 if (!taggerKey.empty()) {
m_configDict[
"WtaggerKey"] = taggerKey; }
751 std::string taggerKey;
752 taggerKey =
findInReg(reg, (*fatjets_nominal)[0],
"(SmoothZ.*?)_.*");
753 if (!taggerKey.empty()) {
m_configDict[
"ZtaggerKey"] = taggerKey; }
757 std::string taggerKey;
758 taggerKey =
findInReg(reg, (*fatjets_nominal)[0],
"(.*Tag.*Top.*?)_.*");
759 if (!taggerKey.empty()) {
m_configDict[
"ToptaggerKey"] = taggerKey; }
767 for(
auto fatjet : *fatjets_nominal) {
768 fatjet_n_flow_nominal->Fill(
Cut::all);
792 TH1* trkjet_n_flow_nominal =
hist(
"Cutflow/trkjet_n_flow_nominal");
794 if(
m_slices[
"tjet"] && doTrkJets ) {
796 for(
auto trkjet : *trkjets_nominal) {
797 trkjet_n_flow_nominal->Fill(
Cut::all);
821 TH1* tau_n_flow_nominal =
hist(
"Cutflow/tau_n_flow_nominal");
825 for(
auto tau : *taus_nominal) {
851 double base_event_weight(1.);
859 ATH_MSG_DEBUG(
"Truth MET etx=" << (*met_truth)[
"NonInt"]->mpx()
860 <<
", ety=" << (*met_truth)[
"NonInt"]->mpy()
861 <<
", et=" << (*met_truth)[
"NonInt"]->
met()
862 <<
", sumet=" << (*met_truth)[
"NonInt"]->sumet());
864 <<
", dety=" << (*
m_metcst_nominal)[
"Final"]->mpy() - (*met_truth)[
"NonInt"]->mpy());
866 <<
", dety=" << (*
m_mettst_nominal)[
"Final"]->mpy() - (*met_truth)[
"NonInt"]->mpy());
872 double electrons_weight_nominal(1.);
873 double photons_weight_nominal(1.);
874 double muons_weight_nominal(1.);
875 double jets_weight_nominal(1.);
878 double btag_weight_nominal(1.);
879 double taus_weight_nominal(1.);
880 double event_weight_nominal(1.);
881 double prw_weight_nominal(1.);
884 TH1* weight_event =
hist(
"Syst/weight_event");
885 TH1* weight_electrons =
hist(
"Syst/weight_electrons");
886 TH1* weight_muons =
hist(
"Syst/weight_muons");
887 TH1* weight_photons =
hist(
"Syst/weight_photons");
888 TH1* weight_taus =
hist(
"Syst/weight_taus");
889 TH1* weight_jets =
hist(
"Syst/weight_jets");
890 TH1* weight_btags =
hist(
"Syst/weight_btags");
892 bool isNominal(
true);
895 if (
m_SUSYTools->applySystematicVariation(sys) != StatusCode::SUCCESS) {
896 ATH_MSG_ERROR(
"Cannot configure SUSYTools for systematic var. %s" << sys.name() );
900 if (isNominal && (sysInfo.affectsKinematics || sysInfo.affectsWeights)) {
902 return StatusCode::FAILURE;
904 if (sysInfo.affectsKinematics || sysInfo.affectsWeights) isNominal =
false;
906 double event_weight = base_event_weight;
911 double prw_weight=1.;
913 if(!isData) prw_weight_nominal =
m_SUSYTools->GetPileupWeight();
914 event_weight *= prw_weight_nominal;
915 weight_event->SetBinContent(1, weight_event->GetBinContent(1)+event_weight);
917 else if (!syst_affectsEventWeight) {
918 event_weight *= prw_weight_nominal;
925 event_weight *= prw_weight;
927 if(iwbin <
m_syst_weights[
"EventWeight"].
size()) { weight_event->SetBinContent(iwbin+1, weight_event->GetBinContent(iwbin+1)+event_weight); }
959 if (sysInfo.affectsKinematics) {
960 if (
m_slices[
"el"] && syst_affectsElectrons) {
965 electrons = electrons_syst;
968 if (
m_slices[
"pho"] && syst_affectsPhotons) {
973 photons = photons_syst;
976 if (
m_slices[
"mu"] && syst_affectsMuons) {
984 if (syst_affectsJets) {
992 if (
m_slices[
"fjet"] and doFatJets) {
997 fatjets = fatjets_syst;
1004 trkjets = trkjets_syst;
1008 if (
m_slices[
"tau"] && syst_affectsTaus) {
1043 float electrons_weight(1.);
1044 for (
const auto el : *electrons ) {
1046 if (isNominal || syst_affectsElectrons) {
1047 if ((
ST::acc_signal(*el) == 1) && (isNominal || sysInfo.affectsWeights)) {
1049 electrons_weight *=
m_SUSYTools->GetSignalElecSF(*el,
true,
true,
false,
true);
1060 electrons_weight_nominal = electrons_weight;
1061 weight_electrons->SetBinContent(1, weight_electrons->GetBinContent(1)+electrons_weight);
1063 else if (!syst_affectsElectrons) {
1064 electrons_weight = electrons_weight_nominal;
1066 else if ( sysInfo.affectsWeights ){
1068 if(iwbin <
m_syst_weights[
"Electron"].
size()) { weight_electrons->SetBinContent(iwbin+1, weight_electrons->GetBinContent(iwbin+1)+electrons_weight); }
1071 event_weight *= electrons_weight;
1072 ATH_MSG_DEBUG(
"Combined electron scale factor: " << electrons_weight);
1078 float photons_weight(1.);
1079 for (
const auto ph : *photons ) {
1081 if (isNominal || syst_affectsPhotons) {
1082 if ((
ST::acc_signal(*ph) == 1) && (isNominal || sysInfo.affectsWeights)) {
1083 photons_weight *=
m_SUSYTools->GetSignalPhotonSF( *ph );
1093 photons_weight_nominal = photons_weight;
1094 weight_photons->SetBinContent(1, weight_photons->GetBinContent(1)+photons_weight);
1096 else if (!syst_affectsPhotons) {
1097 photons_weight = photons_weight_nominal;
1099 else if ( sysInfo.affectsWeights ){
1101 if(iwbin <
m_syst_weights[
"Photon"].
size()) { weight_photons->SetBinContent(iwbin+1, weight_photons->GetBinContent(iwbin+1)+photons_weight); }
1104 event_weight *= photons_weight;
1105 ATH_MSG_DEBUG(
"Combined photon scale factor: " << photons_weight);
1111 float muons_weight(1.);
1112 for (
const auto mu : *muons ) {
1114 if (isNominal || syst_affectsMuons) {
1115 if ((
ST::acc_signal(*mu) == 1) && (isNominal || sysInfo.affectsWeights)) {
1116 muons_weight *=
m_SUSYTools->GetSignalMuonSF(*mu);;
1127 muons_weight_nominal = muons_weight;
1128 weight_muons->SetBinContent(1, weight_muons->GetBinContent(1)+muons_weight);
1130 else if (!syst_affectsMuons) {
1131 muons_weight = muons_weight_nominal;
1133 else if ( sysInfo.affectsWeights ){
1135 if(iwbin <
m_syst_weights[
"Muon"].
size()) { weight_muons->SetBinContent(iwbin+1, weight_muons->GetBinContent(iwbin+1)+muons_weight); }
1138 event_weight *= muons_weight;
1139 ATH_MSG_DEBUG(
"Combined muon scale factor: " << muons_weight);
1145 for (
const auto jet : *jets ) {
1150 if (
m_slices[
"bjet"] && (isNominal || syst_affectsJets || syst_affectsBTag)) {
1157 float jet_weight(1.);
1158 float btag_weight(1.);
1161 btag_weight_nominal = btag_weight =
m_SUSYTools->BtagSF(jets);
1162 weight_btags->SetBinContent(1, weight_btags->GetBinContent(1)+btag_weight);
1164 else if (!syst_affectsBTag){
1165 btag_weight = btag_weight_nominal;
1170 if(iwbin <
m_syst_weights[
"BTag"].
size()) { weight_btags->SetBinContent(iwbin+1, weight_btags->GetBinContent(iwbin+1)+btag_weight); }
1176 jets_weight_nominal = jet_weight;
1177 jets_weight_nominal *=
m_SUSYTools->FJVT_SF(jets);
1178 weight_jets->SetBinContent(1, weight_jets->GetBinContent(1)+jet_weight);
1180 else if (!syst_affectsJets || (syst_affectsJets && !sysInfo.affectsWeights)){
1181 jet_weight = jets_weight_nominal;
1183 else if ( syst_affectsJets && sysInfo.affectsWeights ){
1187 if(iwbin <
m_syst_weights[
"Jet"].
size()) { weight_jets->SetBinContent(iwbin+1, weight_jets->GetBinContent(iwbin+1)+jet_weight); }
1191 weight_jets->SetBinContent(1, 1.);
1192 weight_btags->SetBinContent(1, 1.);
1194 event_weight *= jet_weight;
1195 event_weight *= btag_weight;
1196 ATH_MSG_DEBUG(
"Combined b-tagging scale factor: " << btag_weight);
1202 if(
m_slices[
"fjet"] && doFatJets ) {
1204 for (
const auto fatjet : *fatjets ) {
1210 float fatjet_weight(1.);
1226 ATH_MSG_DEBUG(
"Combined large radius jet scale factor: " << fatjet_weight);
1231 if(
m_slices[
"tjet"] && doTrkJets ) {
1233 for (
const auto trkjet : *trkjets ) {
1239 float trkjet_weight(1.);
1255 ATH_MSG_DEBUG(
"Combined track jet scale factor: " << trkjet_weight);
1261 float taus_weight(1.);
1262 for (
const auto ta : *
taus ) {
1264 if (isNominal || syst_affectsTaus) {
1265 if ((
ST::acc_signal(*ta) == 1) && (isNominal || sysInfo.affectsWeights)) {
1266 taus_weight *=
m_SUSYTools->GetSignalTauSF(*ta,
true,
false);
1277 taus_weight_nominal = taus_weight;
1278 weight_taus->SetBinContent(1, weight_taus->GetBinContent(1)+taus_weight);
1280 else if (!syst_affectsTaus) {
1281 taus_weight = taus_weight_nominal;
1283 else if ( sysInfo.affectsWeights ){
1285 if(iwbin <
m_syst_weights[
"Tau"].
size()) { weight_taus->SetBinContent(iwbin+1, weight_taus->GetBinContent(iwbin+1)+taus_weight); }
1288 event_weight *= taus_weight;
1293 if (isNominal) {event_weight_nominal = event_weight;}
1294 else if (sysInfo.affectsWeights)
ATH_MSG_DEBUG(
"Difference with nominal weight: " << event_weight - event_weight_nominal);
1297 if (sysInfo.affectsKinematics) {
1319 return StatusCode::SUCCESS;