39 #ifndef XAOD_STANDALONE // For now metadata is Athena-only
51 #include "TEfficiency.h"
57 #include "THashList.h"
68 static const TString SCut[] = {
"All",
"Baseline",
"passOR",
"Signal",
"TrigM"};
73 int getSize(std::map<std::string,std::vector<std::string>> &collection,
const std::string&
object);
78 ISvcLocator* pSvcLocator )
79 :
EL::AnaAlgorithm (
name, pSvcLocator)
80 , m_SUSYTools(
"ST::SUSYObjDef_xAOD/SUSYTools",this)
81 , m_tauTruthMatchingTool(
"TauAnalysisTools::TauTruthMatchingTool/TauTruthMatchingTool")
83 , m_kernel(
"StreamDAOD")
84 , m_configFile(
"SUSYTools/SUSYTools_Default.conf")
128 std::vector<std::string> myGRLs;
158 m_triggers[
"el"].push_back(
"HLT_e24_lhtight_nod0_ivarloose");
159 m_triggers[
"el"].push_back(
"HLT_e60_lhmedium_nod0");
160 m_triggers[
"el"].push_back(
"HLT_e26_lhtight_nod0_ivarloose");
161 m_triggers[
"el"].push_back(
"HLT_e140_lhloose_nod0");
162 m_triggers[
"el"].push_back(
"HLT_e24_lhtight_ivarloose_L1EM22VHI");
163 m_triggers[
"el"].push_back(
"HLT_e24_lhtight_ivarloose_L1eEM26M");
164 m_triggers[
"el"].push_back(
"HLT_e26_lhtight_ivarloose_L1EM22VHI");
165 m_triggers[
"el"].push_back(
"HLT_e26_lhtight_ivarloose_L1eEM26M");
166 m_triggers[
"el"].push_back(
"HLT_e60_lhvloose_L1eEM26M");
167 m_triggers[
"el"].push_back(
"HLT_e60_lhvloose_L1EM22VHI");
172 m_triggers[
"ph"].push_back(
"HLT_g120_loose_L1eEM26M");
173 m_triggers[
"ph"].push_back(
"HLT_g120_loose_L1EM22VHI");
174 m_triggers[
"ph"].push_back(
"HLT_g140_loose_L1eEM26M");
175 m_triggers[
"ph"].push_back(
"HLT_g140_loose_L1EM22VHI");
178 m_triggers[
"mu"].push_back(
"HLT_mu24_ivarmedium");
179 m_triggers[
"mu"].push_back(
"HLT_mu26_ivarmedium");
181 m_triggers[
"mu"].push_back(
"HLT_mu24_ivarmedium_L1MU14FCH");
182 m_triggers[
"mu"].push_back(
"HLT_mu24_ivarmedium_L1MU18VFCH");
183 m_triggers[
"mu"].push_back(
"HLT_mu26_ivarmedium_L1MU14FCH");
184 m_triggers[
"mu"].push_back(
"HLT_mu26_ivarmedium_L1MU18VFCH");
189 m_triggers[
"el"].push_back(
"HLT_e26_lhtight_ivarloose_L1EM22VHI");
190 m_triggers[
"el"].push_back(
"HLT_e60_lhmedium_L1EM22VHI");
191 m_triggers[
"el"].push_back(
"HLT_e140_lhloose_L1EM22VHI");
194 m_triggers[
"ph"].push_back(
"HLT_g140_loose_L1EM22VHI");
195 m_triggers[
"ph"].push_back(
"HLT_g300_L1EM22VHI");
198 m_triggers[
"mu"].push_back(
"HLT_mu24_ivarmedium_L1MU14FCH");
199 m_triggers[
"mu"].push_back(
"HLT_mu50_L1MU14FCH");
200 m_triggers[
"mu"].push_back(
"HLT_mu60_0eta105_msonly_L1MU14FCH");
201 m_triggers[
"mu"].push_back(
"HLT_mu60_L1MU14FCH");
202 m_triggers[
"mu"].push_back(
"HLT_mu80_msonly_3layersEC_L1MU14FCH");
217 return StatusCode::FAILURE;
222 m_configDict[
"Jet.LargeRcollection"] = rEnv.GetValue(
"Jet.LargeRcollection",
"AntiKt10LCTopoTrimmedPtFrac5SmallR20Jets" );
223 m_configDict[
"TrackJet.Collection"] = rEnv.GetValue(
"TrackJet.Collection",
"AntiKtVR30Rmax4Rmin02TrackJets" );
224 m_configDict[
"Jet.WtaggerConfig"] = rEnv.GetValue(
"Jet.WtaggerConfig",
"None");
225 m_configDict[
"Jet.ZtaggerConfig"] = rEnv.GetValue(
"Jet.ZtaggerConfig",
"None");
226 m_configDict[
"Jet.ToptaggerConfig"] = rEnv.GetValue(
"Jet.ToptaggerConfig",
"None");
241 m_slices[
"ele"] =
bool(rEnv.GetValue(
"Slices.Ele",
true));
242 m_slices[
"pho"] =
bool(rEnv.GetValue(
"Slices.Pho",
true));
243 m_slices[
"mu"] =
bool(rEnv.GetValue(
"Slices.Mu",
true));
244 m_slices[
"tau"] =
bool(rEnv.GetValue(
"Slices.Tau",
true));
245 m_slices[
"jet"] =
bool(rEnv.GetValue(
"Slices.Jet",
true));
246 m_slices[
"bjet"] =
bool(rEnv.GetValue(
"Slices.BJet",
true));
247 m_slices[
"fjet"] =
bool(rEnv.GetValue(
"Slices.FJet",
true));
248 m_slices[
"tjet"] =
bool(rEnv.GetValue(
"Slices.TJet",
true));
249 m_slices[
"met"] =
bool(rEnv.GetValue(
"Slices.MET",
true));
252 return StatusCode::SUCCESS;
267 for (std::string
hname : {
"el_n_flow_nominal",
"ph_n_flow_nominal",
"mu_n_flow_nominal",
"jet_n_flow_nominal",
"bjet_n_flow_nominal",
"fatjet_n_flow_nominal",
"trkjet_n_flow_nominal",
"tau_n_flow_nominal"} ) {
269 for (
unsigned int i=1;
i <
Cut::NSel+1;
i++){
h->GetXaxis()->SetBinLabel(
i, Cut::SCut[
i-1].
Data()); }
270 h->GetXaxis()->SetLabelSize(0.05);
274 for (std::string
hname : {
"el_trigmatch_eff_nominal",
"ph_trigmatch_eff_nominal",
"mu_trigmatch_eff_nominal"}) {
275 std::string
obj =
hname.substr(0,2);
278 h->GetXaxis()->SetLabelSize(0.05);
283 std::map<std::string,std::string> mapweights = {{
"event",
"EventWeight"},{
"electrons",
"Electron"},{
"photons",
"Photon"},{
"muons",
"Muon"},{
"taus",
"Tau"},{
"jets",
"Jet"},{
"btags",
"BTag"}};
284 for (
const auto&
weight : mapweights) {
287 for (
unsigned int i=1;
i < syslist.size()+1;
i++) {
h->GetXaxis()->SetBinLabel(
i, syslist.at(
i-1).c_str()); }
288 h->GetXaxis()->SetLabelSize(0.05);
290 h->Scale(1./
static_cast<float>(
h->GetBinContent(1)));
294 for (
unsigned int i=1;
i < syslist.size()+1;
i++) { h2->GetYaxis()->SetBinLabel(syslist.size()-
i+1, syslist.at(
i-1).c_str()); h2->Fill(0.5,syslist.size()-
i,1.); }
295 h2->GetYaxis()->SetLabelSize(0.05);
298 return StatusCode::SUCCESS;
320 return StatusCode::SUCCESS;
340 if (!
evtStore()->
event()->retrieveMetaInput(completeCBC,
"CutBookkeepers").isSuccess()) {
341 ATH_MSG_ERROR(
"Failed to retrieve CutBookkeepers from MetaData! Exiting.");
344 for (
const auto *cbk : *completeCBC ) {
345 cbkname = cbk->name();
346 stream = cbk->inputStream();
348 if (cbkname.find(
"PHYSVAL")!=std::string::npos)
m_kernel=
"PHYSVAL";
349 else if (cbkname.find(
"PHYSLITE")!=std::string::npos)
m_kernel=
"PHYSLITE";
350 else if (cbkname.find(
"PHYS")!=std::string::npos)
m_kernel=
"PHYS";
359 if (
stream.find(
"PHYSVAL")!=std::string::npos)
m_kernel=
"PHYSVAL";
360 else if (
stream.find(
"PHYSLITE")!=std::string::npos)
m_kernel=
"PHYSLITE";
374 TH1* info_runNo =
hist(
"EventInfo/info_runNo");
375 TH1* info_evtNo =
hist(
"EventInfo/info_evtNo");
376 TH1* info_lumiBlock =
hist(
"EventInfo/info_lumiBlock");
379 info_lumiBlock->Fill(evtInfo->
lumiBlock());
413 static std::atomic<bool> doFatJets =
true;
421 return StatusCode::FAILURE;
426 }
else if(
m_slices[
"jet"] && doFatJets) {
431 static std::atomic<bool> doTrkJets =
true;
439 return StatusCode::FAILURE;
444 }
else if(
m_slices[
"jet"] && doTrkJets) {
484 for(
const auto& tau : *taus_gettruth) {
501 double metsig_cst(0.);
502 double metsig_tst(0.);
531 hist(
"MET/met_significance")->Fill( metsig_tst );
538 bool isRun3Trig =
false;
539 if (
m_mcCampaign.find(
"mc21") != std::string::npos ||
m_mcCampaign.find(
"mc23") != std::string::npos) isRun3Trig =
true;
546 TH1* el_n_flow_nominal =
hist(
"Cutflow/el_n_flow_nominal");
547 TH1* el_trigmatch_eff_nominal =
hist(
"Trigger/el_trigmatch_eff_nominal");
552 for(
auto el : *electrons_nominal) {
554 if ( ST::acc_baseline(*
el) == 1 ){
559 if ( ST::acc_passOR(*
el) == 1 ){
561 if ( ST::acc_signal(*
el) == 1 ){
572 if(passit) el_trigmatch_eff_nominal->SetBinContent(
idx, el_trigmatch_eff_nominal->GetBinContent(
idx)+1);
573 #ifdef XAOD_STANDALONE
574 m_heffs[
"Trigger/el_pt_"+
t]->Fill(passit,
el->pt()/1000.);
575 m_heffs[
"Trigger/el_eta_"+
t]->Fill(passit,
el->eta());
576 m_heffs[
"Trigger/el_phi_"+
t]->Fill(passit,
el->phi());
593 TH1* ph_n_flow_nominal =
hist(
"Cutflow/ph_n_flow_nominal");
594 TH1* ph_trigmatch_eff_nominal =
hist(
"Trigger/ph_trigmatch_eff_nominal");
599 for(
auto ph : *photons_nominal) {
601 if ( ST::acc_baseline(*ph) == 1 ){
605 if ( ST::acc_passOR(*ph) == 1 ){
607 if ( ST::acc_signal(*ph) == 1 ){
617 if(passit) ph_trigmatch_eff_nominal->SetBinContent(
idx, ph_trigmatch_eff_nominal->GetBinContent(
idx)+1);
618 #ifdef XAOD_STANDALONE
619 m_heffs[
"Trigger/ph_pt_"+
t]->Fill(passit,ph->pt()/1000.);
620 m_heffs[
"Trigger/ph_eta_"+
t]->Fill(passit,ph->eta());
621 m_heffs[
"Trigger/ph_phi_"+
t]->Fill(passit,ph->phi());
638 TH1* mu_n_flow_nominal =
hist(
"Cutflow/mu_n_flow_nominal");
639 TH1* mu_trigmatch_eff_nominal =
hist(
"Trigger/mu_trigmatch_eff_nominal");
644 for(
auto mu : *muons_nominal) {
646 if ( ST::acc_baseline(*
mu) == 1 ){
650 if ( ST::acc_passOR(*
mu) == 1 ){
652 if ( ST::acc_signal(*
mu) == 1 ){
662 if(passit) mu_trigmatch_eff_nominal->SetBinContent(
idx, mu_trigmatch_eff_nominal->GetBinContent(
idx)+1);
663 #ifdef XAOD_STANDALONE
664 m_heffs[
"Trigger/mu_pt_"+
t]->Fill(passit,
mu->pt()/1000.);
665 m_heffs[
"Trigger/mu_eta_"+
t]->Fill(passit,
mu->eta());
666 m_heffs[
"Trigger/mu_phi_"+
t]->Fill(passit,
mu->phi());
683 TH1* jet_n_flow_nominal =
hist(
"Cutflow/jet_n_flow_nominal");
684 TH1* bjet_n_flow_nominal =
hist(
"Cutflow/bjet_n_flow_nominal");
689 for(
auto jet : *jets_nominal) {
693 if ( ST::acc_bjet(*
jet) == 1 )
bjet =
true;
696 if ( ST::acc_baseline(*
jet) == 1 ){
706 if ( ST::acc_passOR(*
jet) == 1 ){
709 if ( ST::acc_signal(*
jet) == 1 ){
735 TH1* fatjet_n_flow_nominal =
hist(
"Cutflow/fatjet_n_flow_nominal");
737 if(
m_slices[
"fjet"] && doFatJets ) {
741 std::string taggerKey;
742 taggerKey =
findInReg(reg, (*fatjets_nominal)[0],
"(SmoothW.*?)_.*");
743 if (!taggerKey.empty()) {
m_configDict[
"WtaggerKey"] = taggerKey; }
747 std::string taggerKey;
748 taggerKey =
findInReg(reg, (*fatjets_nominal)[0],
"(SmoothZ.*?)_.*");
749 if (!taggerKey.empty()) {
m_configDict[
"ZtaggerKey"] = taggerKey; }
753 std::string taggerKey;
754 taggerKey =
findInReg(reg, (*fatjets_nominal)[0],
"(.*Tag.*Top.*?)_.*");
755 if (!taggerKey.empty()) {
m_configDict[
"ToptaggerKey"] = taggerKey; }
763 for(
auto fatjet : *fatjets_nominal) {
764 fatjet_n_flow_nominal->Fill(
Cut::all);
765 if ( ST::acc_baseline(*
fatjet) == 1 ){
769 if ( ST::acc_passOR(*
fatjet) == 1 ){
771 if ( ST::acc_signal(*
fatjet) == 1 ){
788 TH1* trkjet_n_flow_nominal =
hist(
"Cutflow/trkjet_n_flow_nominal");
790 if(
m_slices[
"tjet"] && doTrkJets ) {
792 for(
auto trkjet : *trkjets_nominal) {
793 trkjet_n_flow_nominal->Fill(
Cut::all);
794 if ( ST::acc_baseline(*trkjet) == 1 ){
798 if ( ST::acc_passOR(*trkjet) == 1 ){
800 if ( ST::acc_signal(*trkjet) == 1 ){
817 TH1* tau_n_flow_nominal =
hist(
"Cutflow/tau_n_flow_nominal");
821 for(
auto tau : *taus_nominal) {
823 if ( ST::acc_baseline(*tau) == 1 ){
827 if ( ST::acc_passOR(*tau) == 1 ){
830 if ( ST::acc_signal(*tau) == 1 ){
847 double base_event_weight(1.);
855 ATH_MSG_DEBUG(
"Truth MET etx=" << (*met_truth)[
"NonInt"]->mpx()
856 <<
", ety=" << (*met_truth)[
"NonInt"]->mpy()
857 <<
", et=" << (*met_truth)[
"NonInt"]->
met()
858 <<
", sumet=" << (*met_truth)[
"NonInt"]->sumet());
860 <<
", dety=" << (*
m_metcst_nominal)[
"Final"]->mpy() - (*met_truth)[
"NonInt"]->mpy());
862 <<
", dety=" << (*
m_mettst_nominal)[
"Final"]->mpy() - (*met_truth)[
"NonInt"]->mpy());
868 double electrons_weight_nominal(1.);
869 double photons_weight_nominal(1.);
870 double muons_weight_nominal(1.);
871 double jets_weight_nominal(1.);
874 double btag_weight_nominal(1.);
875 double taus_weight_nominal(1.);
876 double event_weight_nominal(1.);
877 double prw_weight_nominal(1.);
880 TH1* weight_event =
hist(
"Syst/weight_event");
881 TH1* weight_electrons =
hist(
"Syst/weight_electrons");
882 TH1* weight_muons =
hist(
"Syst/weight_muons");
883 TH1* weight_photons =
hist(
"Syst/weight_photons");
884 TH1* weight_taus =
hist(
"Syst/weight_taus");
885 TH1* weight_jets =
hist(
"Syst/weight_jets");
886 TH1* weight_btags =
hist(
"Syst/weight_btags");
888 bool isNominal(
true);
892 ATH_MSG_ERROR(
"Cannot configure SUSYTools for systematic var. %s" <<
sys.name() );
896 if (isNominal && (sysInfo.affectsKinematics || sysInfo.affectsWeights)) {
898 return StatusCode::FAILURE;
900 if (sysInfo.affectsKinematics || sysInfo.affectsWeights) isNominal =
false;
902 double event_weight = base_event_weight;
907 double prw_weight=1.;
910 event_weight *= prw_weight_nominal;
911 weight_event->SetBinContent(1, weight_event->GetBinContent(1)+event_weight);
913 else if (!syst_affectsEventWeight) {
914 event_weight *= prw_weight_nominal;
921 event_weight *= prw_weight;
923 if(iwbin <
m_syst_weights[
"EventWeight"].
size()) { weight_event->SetBinContent(iwbin+1, weight_event->GetBinContent(iwbin+1)+event_weight); }
939 bool syst_affectsMuons = ST::testAffectsObject(
xAOD::Type::Muon, sysInfo.affectsType);
940 bool syst_affectsPhotons = ST::testAffectsObject(
xAOD::Type::Photon, sysInfo.affectsType);
941 bool syst_affectsTaus = ST::testAffectsObject(
xAOD::Type::Tau, sysInfo.affectsType);
942 bool syst_affectsJets = ST::testAffectsObject(
xAOD::Type::Jet, sysInfo.affectsType);
943 bool syst_affectsBTag = ST::testAffectsObject(
xAOD::Type::BTag, sysInfo.affectsType);
944 bool syst_affectsLRT = ST::testAffectsObject(sysInfo.affectsType) ==
"LRT_Objects";
955 if (sysInfo.affectsKinematics) {
956 if (
m_slices[
"el"] && syst_affectsElectrons) {
964 if (
m_slices[
"pho"] && syst_affectsPhotons) {
969 photons = photons_syst;
972 if (
m_slices[
"mu"] && syst_affectsMuons) {
980 if (syst_affectsJets) {
993 fatjets = fatjets_syst;
1000 trkjets = trkjets_syst;
1004 if (
m_slices[
"tau"] && syst_affectsTaus) {
1039 float electrons_weight(1.);
1042 if (isNominal || syst_affectsElectrons) {
1043 if ((ST::acc_signal(*
el) == 1) && (isNominal || sysInfo.affectsWeights)) {
1049 ATH_MSG_VERBOSE(
" Electron passing baseline selection? " <<
static_cast<int>( ST::acc_baseline(*
el)));
1050 ATH_MSG_VERBOSE(
" Electron passing signal selection? " <<
static_cast<int>( ST::acc_signal(*
el)));
1051 if (ST::acc_signal(*
el) == 1)
1056 electrons_weight_nominal = electrons_weight;
1057 weight_electrons->SetBinContent(1, weight_electrons->GetBinContent(1)+electrons_weight);
1059 else if (!syst_affectsElectrons) {
1060 electrons_weight = electrons_weight_nominal;
1062 else if ( sysInfo.affectsWeights ){
1064 if(iwbin <
m_syst_weights[
"Electron"].
size()) { weight_electrons->SetBinContent(iwbin+1, weight_electrons->GetBinContent(iwbin+1)+electrons_weight); }
1067 event_weight *= electrons_weight;
1068 ATH_MSG_DEBUG(
"Combined electron scale factor: " << electrons_weight);
1074 float photons_weight(1.);
1075 for (
const auto& ph : *photons ) {
1077 if (isNominal || syst_affectsPhotons) {
1078 if ((ST::acc_signal(*ph) == 1) && (isNominal || sysInfo.affectsWeights)) {
1083 ATH_MSG_VERBOSE(
" Photon passing baseline selection? " <<
static_cast<int>(ST::acc_baseline(*ph)));
1084 ATH_MSG_VERBOSE(
" Photon passing signal selection? " <<
static_cast<int>(ST::acc_signal(*ph)));
1085 if (ST::acc_signal(*ph) == 1)
1089 photons_weight_nominal = photons_weight;
1090 weight_photons->SetBinContent(1, weight_photons->GetBinContent(1)+photons_weight);
1092 else if (!syst_affectsPhotons) {
1093 photons_weight = photons_weight_nominal;
1095 else if ( sysInfo.affectsWeights ){
1097 if(iwbin <
m_syst_weights[
"Photon"].
size()) { weight_photons->SetBinContent(iwbin+1, weight_photons->GetBinContent(iwbin+1)+photons_weight); }
1100 event_weight *= photons_weight;
1101 ATH_MSG_DEBUG(
"Combined photon scale factor: " << photons_weight);
1107 float muons_weight(1.);
1108 for (
const auto&
mu : *muons ) {
1110 if (isNominal || syst_affectsMuons) {
1111 if ((ST::acc_signal(*
mu) == 1) && (isNominal || sysInfo.affectsWeights)) {
1116 ATH_MSG_VERBOSE(
" Muon passing baseline selection? " <<
static_cast<int>(ST::acc_baseline(*
mu)));
1117 ATH_MSG_VERBOSE(
" Muon passing signal selection? " <<
static_cast<int>(ST::acc_signal(*
mu)));
1118 ATH_MSG_VERBOSE(
" Muon is a cosmic ray? " <<
static_cast<int>(ST::acc_cosmic(*
mu)));
1119 if (ST::acc_signal(*
mu) == 1)
1123 muons_weight_nominal = muons_weight;
1124 weight_muons->SetBinContent(1, weight_muons->GetBinContent(1)+muons_weight);
1126 else if (!syst_affectsMuons) {
1127 muons_weight = muons_weight_nominal;
1129 else if ( sysInfo.affectsWeights ){
1131 if(iwbin <
m_syst_weights[
"Muon"].
size()) { weight_muons->SetBinContent(iwbin+1, weight_muons->GetBinContent(iwbin+1)+muons_weight); }
1134 event_weight *= muons_weight;
1135 ATH_MSG_DEBUG(
"Combined muon scale factor: " << muons_weight);
1141 for (
const auto&
jet : *
jets ) {
1145 if (ST::acc_passOR(*
jet)) {
1146 if (
m_slices[
"bjet"] && (isNominal || syst_affectsJets || syst_affectsBTag)) {
1153 float jet_weight(1.);
1154 float btag_weight(1.);
1158 weight_btags->SetBinContent(1, weight_btags->GetBinContent(1)+btag_weight);
1160 else if (!syst_affectsBTag){
1161 btag_weight = btag_weight_nominal;
1166 if(iwbin <
m_syst_weights[
"BTag"].
size()) { weight_btags->SetBinContent(iwbin+1, weight_btags->GetBinContent(iwbin+1)+btag_weight); }
1172 jets_weight_nominal = jet_weight;
1174 weight_jets->SetBinContent(1, weight_jets->GetBinContent(1)+jet_weight);
1176 else if (!syst_affectsJets || (syst_affectsJets && !sysInfo.affectsWeights)){
1177 jet_weight = jets_weight_nominal;
1179 else if ( syst_affectsJets && sysInfo.affectsWeights ){
1183 if(iwbin <
m_syst_weights[
"Jet"].
size()) { weight_jets->SetBinContent(iwbin+1, weight_jets->GetBinContent(iwbin+1)+jet_weight); }
1187 weight_jets->SetBinContent(1, 1.);
1188 weight_btags->SetBinContent(1, 1.);
1190 event_weight *= jet_weight;
1191 event_weight *= btag_weight;
1192 ATH_MSG_DEBUG(
"Combined b-tagging scale factor: " << btag_weight);
1198 if(
m_slices[
"fjet"] && doFatJets ) {
1200 for (
const auto&
fatjet : *fatjets ) {
1206 float fatjet_weight(1.);
1222 ATH_MSG_DEBUG(
"Combined large radius jet scale factor: " << fatjet_weight);
1227 if(
m_slices[
"tjet"] && doTrkJets ) {
1229 for (
const auto& trkjet : *trkjets ) {
1230 ATH_MSG_VERBOSE(
" Jet is bad? " <<
static_cast<int>(ST::acc_bad(*trkjet)));
1231 ATH_MSG_VERBOSE(
" Jet is baseline ? " <<
static_cast<int>(ST::acc_baseline(*trkjet)));
1232 ATH_MSG_VERBOSE(
" Jet passes OR ? " <<
static_cast<int>(ST::acc_passOR(*trkjet)));
1235 float trkjet_weight(1.);
1251 ATH_MSG_DEBUG(
"Combined track jet scale factor: " << trkjet_weight);
1257 float taus_weight(1.);
1258 for (
const auto& ta : *taus ) {
1260 if (isNominal || syst_affectsTaus) {
1261 if ((ST::acc_signal(*ta) == 1) && (isNominal || sysInfo.affectsWeights)) {
1266 ATH_MSG_VERBOSE(
" Tau passing baseline selection? " <<
static_cast<int>(ST::acc_baseline(*ta)));
1267 ATH_MSG_VERBOSE(
" Tau passing signal selection? " <<
static_cast<int>(ST::acc_signal(*ta)));
1268 if (ST::acc_signal(*ta) == 1)
1273 taus_weight_nominal = taus_weight;
1274 weight_taus->SetBinContent(1, weight_taus->GetBinContent(1)+taus_weight);
1276 else if (!syst_affectsTaus) {
1277 taus_weight = taus_weight_nominal;
1279 else if ( sysInfo.affectsWeights ){
1281 if(iwbin <
m_syst_weights[
"Tau"].
size()) { weight_taus->SetBinContent(iwbin+1, weight_taus->GetBinContent(iwbin+1)+taus_weight); }
1284 event_weight *= taus_weight;
1289 if (isNominal) {event_weight_nominal = event_weight;}
1290 else if (sysInfo.affectsWeights)
ATH_MSG_DEBUG(
"Difference with nominal weight: " << event_weight - event_weight_nominal);
1293 if (sysInfo.affectsKinematics) {
1315 return StatusCode::SUCCESS;
1322 ATH_CHECK(
book(TH1D(
"EventInfo/info_runNo",
";RunNumber;N", 1500, 250000, 400000)) );
1323 ATH_CHECK(
book(TH1D(
"EventInfo/info_evtNo",
";EventNumber;N", 600, 100000000, 400000000)) );
1324 ATH_CHECK(
book(TH1D(
"EventInfo/info_lumiBlock",
";LumiBlock;N", 1000, 0, 1000)) );
1327 m_objects = {
"el",
"ph",
"mu",
"tau",
"jet",
"bjet",
"fatjet",
"trkjet"};
1329 m_vars = {
"pt",
"eta",
"phi",
"e",
"mass",
"d0",
"z0",
"isolCalo",
"isolTrack",
"truthType",
"truthOrigin",
"N",
"bweight",
"bweightpb",
"bweightpc",
"bweightpu",
"pid",
"parentpid",
"wtagged",
"ztagged",
"toptagged",
"toptaggedscore",
"nTracks",
"nTracksCharged",
"nTracksIsolation",
"RNNJetScoreSigTrans"};
1330 std::map<std::string,std::vector<std::string>> cfg_hist_labels = {
1331 {
"pt",{
"p_{T} [GeV]",
"N"}}, {
"eta",{
"#eta",
"N"}}, {
"phi",{
"#phi",
"N"}}, {
"e",{
"energy",
"N"}}, {
"mass",{
"mass",
"N"}},
1332 {
"d0",{
"d0 significance",
"N"}}, {
"z0",{
"z0 * sin(#theta)",
"N"}}, {
"isolCalo",{
"isolation (calo) / pT",
"N"}}, {
"isolTrack",{
"isolation (track) / pT",
"N"}},
1333 {
"truthType",{
"truth type",
"N"}}, {
"truthOrigin",{
"truth origin",
"N"}}, {
"N",{
"count",
"N"}},
1334 {
"bweight",{
"b-weight",
"N"}}, {
"bweightpb",{
"b-weight (pb)",
"N"}}, {
"bweightpc",{
"b-weight (pc)",
"N"}}, {
"bweightpu",{
"b-weight (pu)",
"N"}},
1335 {
"pid", {
"pdg ID",
"N"}}, {
"parentpid", {
"parent pdg ID",
"N"}},
1336 {
"wtagged", {
"W tagged",
"N"}}, {
"ztagged", {
"Z tagged",
"N"}}, {
"toptagged", {
"Top tagged",
"N"}}, {
"toptaggedscore", {
"Top tagger score",
"N"}},
1337 {
"nTracks", {
"N tracks",
"N"}}, {
"nTracksCharged", {
"N tracks charged",
"N"}}, {
"nTracksIsolation", {
"N tracks isolation",
"N"}}, {
"RNNJetScoreSigTrans", {
"RNNJetScoreSigTrans",
"N"}} };
1338 std::map<std::string,int> cfg_hist_nbins = {
1339 {
"pt",100}, {
"eta",40}, {
"phi",64}, {
"e",100}, {
"mass",100},
1340 {
"d0",50}, {
"z0",60}, {
"isolCalo",70}, {
"isolTrack",70},
1341 {
"truthType",50}, {
"truthOrigin",50}, {
"N",16},
1342 {
"bweight",200}, {
"bweightpb",200}, {
"bweightpc",200}, {
"bweightpu",200},
1343 {
"pid",61}, {
"parentpid",61},
1344 {
"wtagged",3}, {
"ztagged",3}, {
"toptagged",3}, {
"toptaggedscore",50},
1345 {
"nTracks",20}, {
"nTracksCharged",20}, {
"nTracksIsolation",5}, {
"RNNJetScoreSigTrans",50} };
1346 std::map<std::string,std::vector<float>> cfg_hist_minmax = {
1347 {
"pt",{0,200}}, {
"eta",{-4,4}}, {
"phi",{-3.2,3.2}}, {
"e",{0,200}}, {
"mass",{0,200}},
1348 {
"d0",{-10,10}}, {
"z0",{-1.5,1.5}}, {
"isolCalo",{-0.2,0.5}}, {
"isolTrack",{-0.2,0.5}},
1349 {
"truthType",{0,50}}, {
"truthOrigin",{0,50}}, {
"N",{0,16}},
1350 {
"bweight",{-10,10}}, {
"bweightpb",{-0.5,1.5}}, {
"bweightpc",{-0.5,1.5}}, {
"bweightpu",{-0.5,1.5}},
1351 {
"pid",{-30.5,30.5}}, {
"parentpid",{-30.5,30.5}},
1352 {
"wtagged", {-1,2}}, {
"ztagged", {-1,2}}, {
"toptagged", {-1,2}}, {
"toptaggedscore", {0,1}},
1353 {
"nTracks", {0,20}}, {
"nTracksCharged", {0,20}}, {
"nTracksIsolation", {0,5}}, {
"RNNJetScoreSigTrans", {0,1}} };
1354 std::map<std::string,std::string> labels_objects = { {
"el",
"Electron"}, {
"ph",
"Photon"}, {
"mu",
"Muon"}, {
"jet",
"Jet"}, {
"bjet",
"b-Jet"}, {
"tau",
"Tau"}, {
"fatjet",
"Large-R jet"}, {
"trkjet",
"Track jet"} };
1355 std::map<std::string,std::string> labels_levels = { {
"nom",
"Nominal"}, {
"bsl",
"Baseline"}, {
"sig",
"Signal"} };
1356 std::map<std::string,std::string> labels_dir = { {
"el",
"Electron"}, {
"ph",
"Photon"}, {
"mu",
"Muon"}, {
"jet",
"Jet"}, {
"bjet",
"bJet"}, {
"tau",
"Tau"}, {
"fatjet",
"LargeRJet"}, {
"trkjet",
"TrackJet"} };
1368 if (
var.find(
"bweight")!=std::string::npos &&
obj.compare(
"bjet")!=0)
continue;
1369 if (
var.find(
"tagged")!=std::string::npos &&
obj.compare(
"fatjet")!=0)
continue;
1370 if ((
var.find(
"nTracks")!=std::string::npos||
var.find(
"RNNJetScore")!=std::string::npos) &&
obj.compare(
"tau")!=0)
continue;
1371 if (
var.find(
"isol")!=std::string::npos && !(
obj.compare(
"el")==0||
obj.compare(
"mu")==0||
obj.compare(
"ph")==0))
continue;
1372 std::string
key = labels_dir[
obj] +
"/" +
obj +
"_" + lev +
"_" +
var;
1373 std::string
labels =
";"+labels_levels[lev]+
" "+labels_objects[
obj]+
" "+cfg_hist_labels[
var][0]+
";"+cfg_hist_labels[
var][1];
1381 #ifdef XAOD_STANDALONE
1382 for (std::string
obj : {
"el",
"mu",
"ph"}) {
1385 for (std::string
var : {
"pt",
"eta",
"phi"} ) {
1386 std::string
key =
"Trigger/"+
obj+
"_"+
var+
"_"+trg;
1387 std::string
labels =
";"+labels_objects[
obj]+
" "+cfg_hist_labels[
var][0]+
";Efficiency "+trg;
1406 ATH_CHECK(
book(TH1D(
"Cutflow/fatjet_n_flow_nominal",
"Large R. Jet Cutflow (Nominal);Large R. Jet Cutflow (Nominal);N",
Cut::NSel, 0,
Cut::NSel) ) );
1410 ATH_CHECK(
book(TH1D(
"MET/met_et",
"MET (Nominal);MET (Nominal) [GeV];N / [10 GeV]", 50, 0, 500) ) );
1411 ATH_CHECK(
book(TH1D(
"MET/met_phi",
"MET_phi (Nominal);MET_phi (Nominal);N", 50, -5, 5) ) );
1412 ATH_CHECK(
book(TH1D(
"MET/met_sumet",
"MET_sumet (Nominal);MET_sumet (Nominal) [GeV];N / [10 GeV]", 50, 0, 500) ) );
1413 ATH_CHECK(
book(TH1D(
"MET/met_et_tst",
"MET [PVSoftTrk] (Nominal);MET [PVSoftTrk] (Nominal) [GeV];N / [10 GeV]", 50, 0, 500) ) );
1414 ATH_CHECK(
book(TH1D(
"MET/met_et_el",
"MET [RefEle] (Nominal);MET [RefEle] (Nominal) [GeV];N / [10 GeV]", 50, 0, 500) ) );
1415 ATH_CHECK(
book(TH1D(
"MET/met_et_ph",
"MET [RefGamma] (Nominal);MET [RefGamma] (Nominal) [GeV];N / [10 GeV]", 50, 0, 500) ) );
1416 ATH_CHECK(
book(TH1D(
"MET/met_et_mu",
"MET [Muons] (Nominal);MET [Muons] (Nominal) [GeV];N / [10 GeV]", 50, 0, 500) ) );
1417 ATH_CHECK(
book(TH1D(
"MET/met_et_jet",
"MET [RefJet] (Nominal);MET [RefJet] (Nominal) [GeV];N / [10 GeV]", 50, 0, 500) ) );
1419 ATH_CHECK(
book(TH1D(
"MET/met_significance",
"MET Significance;MET Significance;N / [0.5]", 60, 0, 30) ) );
1439 return StatusCode::SUCCESS;
1447 const std::vector<std::string>
Nominal{
"Nominal"};
1449 std::string sys_name = sysInfo.systset.name();
1450 std::string sys_affects = ST::testAffectsObject(sysInfo.affectsType);
1451 ATH_MSG_DEBUG(
"Syst " << sys_name <<
" affects " << sys_affects);
1453 bool sys_affects_weights = sysInfo.affectsWeights;
1457 const auto & [pairPtr, inserted] =
m_syst_all.try_emplace(sys_affects,
Nominal);
1458 pairPtr->second.push_back(sys_name);
1461 if (sys_affects_weights) {
1463 pairPtr_w->second.push_back(sys_name);
1471 std::map<std::string,std::string> labels_dir = { {
"el",
"Electron"}, {
"ph",
"Photon"}, {
"mu",
"Muon"}, {
"jet",
"Jet"}, {
"bjet",
"bJet"}, {
"tau",
"Tau"}, {
"fatjet",
"LargeRJet"}, {
"trkjet",
"TrackJet"} };
1472 std::string
dir = labels_dir[objtype]+
"/";
1475 hist(
dir+objtype+
"_"+objlevel+
"_pt")->Fill(
obj->pt()/1000. );
1476 hist(
dir+objtype+
"_"+objlevel+
"_eta")->Fill(
obj->eta() );
1477 hist(
dir+objtype+
"_"+objlevel+
"_phi")->Fill(
obj->phi() );
1478 hist(
dir+objtype+
"_"+objlevel+
"_e")->Fill(
obj->e()/1000. );
1479 hist(
dir+objtype+
"_"+objlevel+
"_mass")->Fill(
obj->m()/1000. );
1481 if (objtype==
"el" || objtype==
"mu" || objtype==
"ph") {
1482 if (objtype==
"el") {
1484 hist(
dir+objtype+
"_"+objlevel+
"_z0")->Fill( ST::acc_z0sinTheta(*
obj) );
1486 hist(
dir+objtype+
"_"+objlevel+
"_d0")->Fill( ST::acc_d0sig(*
obj) );
1487 hist(
dir+objtype+
"_"+objlevel+
"_isolCalo")->Fill( STAlg::acc_topoetcone20(*
obj)/
obj->pt() );
1488 hist(
dir+objtype+
"_"+objlevel+
"_isolTrack")->Fill( STAlg::acc_ptvarcone30_TTVA_LooseCone(*
obj)/
obj->pt() );
1489 }
else if (objtype==
"mu") {
1491 hist(
dir+objtype+
"_"+objlevel+
"_z0")->Fill( ST::acc_z0sinTheta(*
obj) );
1493 hist(
dir+objtype+
"_"+objlevel+
"_d0")->Fill( ST::acc_d0sig(*
obj) );
1494 hist(
dir+objtype+
"_"+objlevel+
"_isolCalo")->Fill( STAlg::acc_topoetcone20(*
obj)/
obj->pt() );
1495 hist(
dir+objtype+
"_"+objlevel+
"_isolTrack")->Fill( STAlg::acc_ptvarcone30_TTVA(*
obj)/
obj->pt() );
1496 }
else if (objtype==
"ph") {
1497 hist(
dir+objtype+
"_"+objlevel+
"_isolCalo")->Fill( (STAlg::acc_topoetcone40(*
obj)-2450)/
obj->pt() );
1498 hist(
dir+objtype+
"_"+objlevel+
"_isolTrack")->Fill( STAlg::acc_ptcone20(*
obj)/
obj->pt() );
1502 if (objtype==
"el" || objtype==
"mu" || objtype==
"ph" || objtype==
"tau") {
1503 if ( objtype!=
"tau" ) {
1505 ATH_MSG_DEBUG(objtype <<
", " << objlevel <<
": " << ST::acc_truthType(*
obj) <<
", " << ST::acc_truthOrigin(*
obj));
1506 hist(
dir+objtype+
"_"+objlevel+
"_truthType")->Fill( ST::acc_truthType(*
obj) );
1507 hist(
dir+objtype+
"_"+objlevel+
"_truthOrigin")->Fill( ST::acc_truthOrigin(*
obj) );
1511 bool istruthmatched = STAlg::acc_IsTruthMatched.isAvailable(*
obj) ? (
bool)STAlg::acc_IsTruthMatched(*
obj) :
false;
1513 if (istruthmatched && STAlg::acc_truthParticleLink.
isAvailable(*
obj)) {
1514 const auto *
tp = *(STAlg::acc_truthParticleLink(*
obj));
1517 ppid = (
tp->nParents()>0)?
tp->parent(0)->pdgId():0;
1520 hist(
dir+objtype+
"_"+objlevel+
"_pid")->Fill(
pid );
1521 hist(
dir+objtype+
"_"+objlevel+
"_parentpid")->Fill( ppid );
1526 if (objtype==
"tau") {
1528 hist(
dir+objtype+
"_"+objlevel+
"_nTracksCharged")->Fill(
dynamic_cast<xAOD::TauJet*
>(
obj)->nTracksCharged() );
1529 hist(
dir+objtype+
"_"+objlevel+
"_nTracksIsolation")->Fill(
dynamic_cast<xAOD::TauJet*
>(
obj)->nTracksIsolation() );
1530 hist(
dir+objtype+
"_"+objlevel+
"_RNNJetScoreSigTrans")->Fill( STAlg::acc_RNNJetScoreSigTrans(*
obj) );
1534 if (objtype==
"bjet") {
1535 hist(
dir+objtype+
"_"+objlevel+
"_bweight")->Fill( ST::acc_btag_weight(*
obj) );
1536 hist(
dir+objtype+
"_"+objlevel+
"_bweightpb")->Fill( ST::acc_btag_dl1pb(*
obj) );
1537 hist(
dir+objtype+
"_"+objlevel+
"_bweightpc")->Fill( ST::acc_btag_dl1pc(*
obj) );
1538 hist(
dir+objtype+
"_"+objlevel+
"_bweightpu")->Fill( ST::acc_btag_dl1pu(*
obj) );
1551 bool kin = acc_topValidPtRangeLow(*
obj) && acc_topValidPtRangeHigh(*
obj) && acc_topValidEtaRange(*
obj);
1563 std::smatch matches;
1564 for (
auto x :
obj->getAuxIDs()) {
1565 std::string xname = reg.
getName(
x);
1566 std::regex_search(xname, matches, re_tag);
1567 if (matches.size()>1 and !matches[1].str().empty()) {
1568 return matches[1].str();
1575 int getSize(std::map<std::string,std::vector<std::string>> &collection,
const std::string&
object) {
1576 if (collection.find(
object) == collection.end())
return 1;
1577 return static_cast<int>(collection[
object].size());