23 #include <TStopwatch.h>
25 #include "TObjArray.h"
26 #include "TObjString.h"
89 "==1 baseline lepton",
92 "trig. matched lepton",
111 std::vector<std::string>
getTokens(TString
line,
const TString& delim);
117 using namespace asg::msgSTT;
119 setMsgLevel(MSG::INFO);
129 ANA_MSG_ERROR(
" Usage: " <<
APP_NAME <<
" [xAOD file name] [maxEvents] [isData=0/1 isAtlfast=0/1] [NoSyst=0/1] [Debug=0/1/2] [ConfigFile=<cfile.conf>] [PRWFile=<prwfile.root>] [autoconfigPRW=0/1] [commonPRWFile=0/1]" );
136 int autoconfigPRW = 1;
137 int commonPRWFile = 1;
142 bool isPHYSLite =
false;
149 std::unique_ptr< TFile >
ifile( TFile::Open(
fileName,
"READ" ) );
161 std::string prw_file =
"DUMMY";
162 std::string ilumicalc_file =
"DUMMY";
164 for (
int i = 1 ;
i <
argc ;
i++) {
165 const char*
key = strtok(
argv[
i],
"=") ;
166 const char*
val = strtok(0,
" ") ;
168 ANA_MSG_INFO(
"===== Processing key " << TString(
key) <<
" with value " << TString(
val) );
169 if (strcmp(
key,
"autoconfigPRW") == 0) autoconfigPRW =
atoi(
val);
170 if (strcmp(
key,
"commonPRWFile") == 0) commonPRWFile =
atoi(
val);
171 if (strcmp(
key,
"isData") == 0) isData =
atoi(
val);
172 if (strcmp(
key,
"isAtlfast") == 0) isAtlfast =
atoi(
val);
173 if (strcmp(
key,
"NoSyst") == 0) NoSyst =
atoi(
val);
176 if (strcmp(
key,
"PRWFile") == 0) prw_file = std::string(
val);
177 if (strcmp(
key,
"ilumicalcFile") == 0) ilumicalc_file = std::string(
val);
184 if (isData < 0 || isAtlfast < 0) {
185 ANA_MSG_ERROR(
"One of the flags isData or isAtlfast was not set! Must provide isData or isAtlfast." );
186 ANA_MSG_ERROR(
" Usage: " <<
APP_NAME <<
" [xAOD file name] [maxEvents] [isData=0/1 isAtlfast=0/1] [NoSyst=0/1] [Debug=0/1/2] [ConfigFile=<cfile.conf>] [PRWFile=<prwfile.root>] [autoconfigPRW=0/1] [commonPRWFile=0/1]");
194 bool hasTrkJets(
false), hasFatJets(
false);
196 if (
x.first.find(
"AntiKtVR30Rmax4Rmin02TrackJets")!=std::string::npos) hasTrkJets =
true;
197 if (
x.first.find(
"AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets")!=std::string::npos) hasFatJets =
true;
198 if (
x.first.find(
"AnalysisElectrons")!=std::string::npos) isPHYSLite =
true;
199 if (isPHYSLite &&
x.first.find(
"AnalysisLargeRJets")!=std::string::npos) hasFatJets =
false;
200 if (
x.first.find(
"InDetLargeD0TrackParticles") != std::string::npos) hasLRT =
true;
205 ANA_MSG_INFO(
"hasTrkJets: " << (hasTrkJets?
"true":
"false"));
206 ANA_MSG_INFO(
"hasFatJets: " << (hasFatJets?
"true":
"false"));
207 ANA_MSG_INFO(
"isPHYSLite: " << (isPHYSLite?
"true":
"false"));
233 std::vector<std::string> myGRLs;
239 myGRLs.push_back(
PathResolverFindCalibFile(
"GoodRunsLists/data22_13p6TeV/20230116/data22_13p6TeV.periodAllYear_DetStatus-v109-pro28-04_MERGED_PHYS_StandardGRL_All_Good_25ns.xml"));
240 myGRLs.push_back(
PathResolverFindCalibFile(
"GoodRunsLists/data23_13p6TeV/20230828/data23_13p6TeV.periodAllYear_DetStatus-v110-pro31-06_MERGED_PHYS_StandardGRL_All_Good_25ns.xml"));
267 ANA_CHECK( objTool.setProperty(
"DataSource", datasource) ) ;
268 if(!config_file.empty())
269 ANA_CHECK( objTool.setProperty(
"ConfigFile", config_file) );
278 std::vector<std::string> prw_conf;
280 if ( autoconfigPRW == 1 ) {
282 if ( commonPRWFile == 1 )
285 if (prw_file ==
"DUMMY") {
286 prw_conf.push_back(
"dev/SUSYTools/merged_prw_mc16a_latest.root");
290 ANA_CHECK( objTool.setProperty(
"PRWConfigFiles", prw_conf) );
312 std::vector<std::string> prw_lumicalc;
313 if (ilumicalc_file ==
"DUMMY") {
314 ANA_CHECK( objTool.setProperty(
"mcCampaign",
"mc16e" ) );
315 prw_lumicalc.push_back(
PathResolverFindCalibFile(
"GoodRunsLists/data18_13TeV/20190318/ilumicalc_histograms_None_348885-364292_OflLumi-13TeV-010.root"));
317 prw_lumicalc =
getTokens(ilumicalc_file,
",");
319 ANA_CHECK( objTool.setProperty(
"PRWLumiCalcFiles", prw_lumicalc) );
325 ANA_CHECK( objTool.setProperty(
"ShowerType", (
int)ishower) );
336 if ( objTool.
initialize() != StatusCode::SUCCESS) {
337 ANA_MSG_ERROR(
"Cannot initialize SUSYObjDef_xAOD, exiting." );
348 if ( rEnv.ReadFile(config_file.c_str(), kEnvAll) != 0 ) {
354 std::map<std::string,std::string> configDict = {};
355 configDict[
"Jet.LargeRcollection"] = rEnv.GetValue(
"Jet.LargeRcollection",
"AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets" );
356 configDict[
"TrackJet.Collection"] = rEnv.GetValue(
"TrackJet.Collection",
"AntiKtVR30Rmax4Rmin02TrackJets" );
357 configDict[
"Jet.WtaggerConfig"] = rEnv.GetValue(
"Jet.WtaggerConfig",
"None");
358 configDict[
"Jet.ZtaggerConfig"] = rEnv.GetValue(
"Jet.ZtaggerConfig",
"None");
359 configDict[
"Jet.ToptaggerConfig"] = rEnv.GetValue(
"Jet.ToptaggerConfig",
"None");
363 for (
auto& keyval : configDict) {
364 configDict[keyval.first] = regex_replace(configDict[keyval.first],
comment,
"");
365 configDict[keyval.first] = regex_replace(configDict[keyval.first], trimspaces,
"$1");
366 ANA_MSG_DEBUG(
"config " << keyval.first <<
" : " << configDict[keyval.first]);
368 std::string FatJetCollection = configDict[
"Jet.LargeRcollection"];
369 std::string TrkJetCollection = configDict[
"TrackJet.Collection"];
370 if (configDict[
"TrackJet.Collection"].
find(
"None")!=std::string::npos) TrkJetCollection =
"";
372 std::map<std::string,bool>
slices = {};
373 slices[
"ele"] =
bool(rEnv.GetValue(
"Slices.Ele",
true));
374 slices[
"pho"] =
bool(rEnv.GetValue(
"Slices.Pho",
true));
375 slices[
"mu"] =
bool(rEnv.GetValue(
"Slices.Mu",
true));
376 slices[
"tau"] =
bool(rEnv.GetValue(
"Slices.Tau",
true));
377 slices[
"jet"] =
bool(rEnv.GetValue(
"Slices.Jet",
true));
378 slices[
"bjet"] =
bool(rEnv.GetValue(
"Slices.BJet",
true));
379 slices[
"fjet"] =
bool(rEnv.GetValue(
"Slices.FJet",
true));
380 slices[
"tjet"] =
bool(rEnv.GetValue(
"Slices.TJet",
true));
381 slices[
"met"] =
bool(rEnv.GetValue(
"Slices.MET",
true));
385 ToolHandle<TauAnalysisTools::ITauTruthMatchingTool> T2MT = 0;
388 T2MT = asg::ToolStore::get<TauAnalysisTools::ITauTruthMatchingTool>(
"ToolSvc.TauTruthMatch");
394 std::vector<std::string> el_triggers,mu_triggers,ph_triggers,tau_triggers,emu_triggers;
396 el_triggers = {
"HLT_e26_lhtight_ivarloose_L1EM22VHI",
"HLT_e26_lhtight_ivarloose_L1eEM26M",
"HLT_e60_lhmedium_L1EM22VHI",
"HLT_e140_lhloose_L1EM22VHI"};
397 mu_triggers = {
"HLT_mu24_ivarmedium_L1MU14FCH",
"HLT_mu50_L1MU14FCH",
"HLT_mu60_0eta105_msonly_L1MU14FCH",
"HLT_mu60_L1MU14FCH",
"HLT_mu80_msonly_3layersEC_L1MU14FCH"};
398 ph_triggers = {
"HLT_g140_loose_L1EM22VHI",
"HLT_g300_etcut_L1EM22VHI"};
399 tau_triggers = {
"HLT_tau160_mediumRNN_tracktwoMVA_L1TAU100",
"HLT_tau40_mediumRNN_tracktwoMVA_tau35_mediumRNN_tracktwoMVA_03dRAB_L1TAU25IM_2TAU20IM_2J25_3J20"};
400 emu_triggers = {
"HLT_2e12_lhloose_mu10_L12EM8VH_MU8F",
"HLT_e12_lhloose_2mu10_L12MU8F",
"HLT_e17_lhloose_mu14_L1EM15VH_MU8F",
"HLT_e7_lhmedium_mu24_L1MU14FCH"};
404 el_triggers = {
"HLT_e24_lhmedium_L1EM20VH",
"HLT_e26_lhtight_nod0_ivarloose",
"HLT_e60_lhmedium_nod0",
"HLT_e160_lhloose_nod0"};
405 mu_triggers = {
"HLT_mu26_ivarmedium",
"HLT_mu50",
"HLT_mu20_mu8noL1"};
406 ph_triggers = {
"HLT_g120_loose"};
407 tau_triggers = {
"HLT_tau125_medium1_tracktwo",
"HLT_tau40_mediumRNN_tracktwoMVA_tau35_mediumRNN_tracktwoMVA"};
408 emu_triggers = {
"HLT_2e12_lhloose_nod0_mu10",
"HLT_e12_lhloose_nod0_2mu10",
"HLT_e17_lhloose_nod0_mu14",
"HLT_e7_lhmedium_nod0_mu24"};
412 std::vector<ST::SystInfo> systInfoList;
418 systInfoList.push_back(infodef);
424 const size_t Nsyst = systInfoList.size();
425 std::vector<std::vector<int> > elcuts;
426 std::vector<std::vector<int> > mucuts;
427 for (isys = 0; isys < Nsyst; ++isys) {
428 std::vector<int> elcutsCurrentSyst;
429 std::vector<int> mucutsCurrentSyst;
430 for (
size_t icut = 0; icut <
Ncuts; ++icut) {
431 elcutsCurrentSyst.push_back(0);
432 mucutsCurrentSyst.push_back(0);
434 elcuts.push_back(elcutsCurrentSyst);
435 mucuts.push_back(elcutsCurrentSyst);
439 Error(
APP_NAME,
"Cannot reset SUSYTools systematics" );
452 std::string cbkname,
stream, ostream, kernel;
466 event.getEntry(
entry );
472 ANA_MSG_ERROR(
"Failed to retrieve CutBookkeepers from MetaData, exiting.");
479 for (
const auto *cbk : *completeCBC ) {
480 cbkname = cbk->
name();
481 stream = cbk->inputStream();
482 ostream = (cbk->outputStreams().size() ? cbk->outputStreams()[0] :
"");
483 ANA_MSG_INFO(
"== cbkname: " << cbkname <<
", description: " << cbk->description() <<
", stream: " <<
stream);
484 ANA_MSG_INFO(
" inputStream: " << cbk->inputStream() <<
", outputStreams: " << ostream);
485 ANA_MSG_INFO(
" cycle: " << cbk->cycle() <<
", allEvents = " << cbk->nAcceptedEvents());
486 if (cbkname.find(
"PHYSVAL")!=std::string::npos) kernel=
"PHYSVAL";
487 else if (cbkname.find(
"PHYSLITE")!=std::string::npos) kernel=
"PHYSLITE";
488 else if (cbkname.find(
"PHYS")!=std::string::npos) kernel=
"PHYS";
489 else if (
stream.find(
"StreamAOD")!=std::string::npos) kernel=
stream.replace(
stream.find(
"Stream"),6,
"");
491 if (cbkname.find(
"AllExecutedEvents")!=std::string::npos && ostream.find(
"StreamAOD")!=std::string::npos && cbk->cycle() > maxcycle) {
492 maxcycle = cbk->cycle();
501 ANA_MSG_INFO(
"CutBookkeepers Accepted " << nEventsProcessed <<
" SumWei " << sumOfWeights <<
" sumWei2 " << sumOfWeightsSquared);
502 }
else {
ANA_MSG_INFO(
"No relevent CutBookKeepers found" ); }
531 "run #" <<
static_cast< int >( ei->
runNumber() ) <<
" " <<
static_cast< int >(
entry ) <<
" events processed so far <<<===");
536 ANA_MSG_INFO(
"===>>> process cross section " << xsectTimesEff );
539 bool eventPassesGRL(
true);
540 bool eventPassesCleaning(
true);
541 bool eventPassesTileTrip(
true);
542 bool eventPassesTrigger(
true);
546 float PRW_weight = isPHYSLite? pileupWeightAcc(*ei): objTool.
GetPileupWeight();
564 if( objTool.
FindSusyHP(pdgid1, pdgid2) != StatusCode::SUCCESS ){
565 ANA_MSG_WARNING(
"SUSY Proc finding failed. Normal for non-SUSY samples." );
568 if( pdgid1!=0 && pdgid2!=0){
583 Warning(
APP_NAME ,
"No PV found for this event! Skipping...");
615 ANA_CHECK( objTool.
GetElectrons(electrons_nominal, electrons_nominal_aux,
true, isPHYSLite?
"AnalysisElectrons":
"Electrons") );
618 for (
const auto&
electron : *electrons_nominal){
621 bool idok =
electron->passSelection(accepted,
"passBaseID");
622 if(idok)
ANA_MSG_DEBUG(
"Electron Baseline ID Decision : " << accepted );
623 else ANA_MSG_DEBUG(
"Electron Baseline ID Decision not available " );
629 if(
slices[
"pho"] &&
stream.find(
"SUSY12")==std::string::npos) {
631 ANA_CHECK( objTool.
GetPhotons(photons_nominal,photons_nominal_aux,
true, isPHYSLite?
"AnalysisPhotons":
"Photons") );
638 ANA_CHECK( objTool.
GetMuons(muons_nominal, muons_nominal_aux,
true, isPHYSLite?
"AnalysisMuons":
"Muons") );
642 for (
const auto&
muon : *muons_nominal){
646 <<
"baseline = " << (
int)ST::acc_baseline(*
muon) <<
" ,"
647 <<
"bad = " << (
int)ST::acc_bad(*
muon) <<
" ,"
648 <<
"IsHighPt(deco) = " << (
int)ST::acc_passedHighPtCuts(*
muon) <<
" , "
657 ANA_CHECK( objTool.
GetJets(jets_nominal, jets_nominal_aux,
true, isPHYSLite?
"AnalysisJets":
"") );
663 if (
slices[
"tjet"] && hasTrkJets) {
669 ANA_MSG_ERROR(
"TrackJet collection " << TrkJetCollection.c_str() <<
" not available in input file. Please check!");
676 if(
slices[
"fjet"] && hasFatJets) {
677 ANA_MSG_DEBUG(
"Nominal fat jet step, collection: " << FatJetCollection );
682 for (
const auto&
fatjet : *fatjets_nominal) {
687 ANA_MSG_ERROR(
"LargeR jet collection " << FatJetCollection.c_str() <<
" not available in input file. Please check!");
695 ANA_CHECK( objTool.
GetTaus(taus_nominal,taus_nominal_aux,
true, isPHYSLite?
"AnalysisTauJets":
"TauJets") );
704 metcst_nominal->setStore(metcst_nominal_aux);
706 double metsig_cst (0.);
707 mettst_nominal->setStore(mettst_nominal_aux);
709 double metsig_tst (0.);
715 double base_event_weight(1.);
721 Info(
APP_NAME ,
"--- SHERPA2.2 REWEIGHTING : %f", RW_sh22);
728 double elecSF_nominal(1.);
729 double muonSF_nominal(1.);
731 double btagSF_nominal(1.);
732 double btagSF_trkJet_nominal(1.);
735 bool isNominal(
true);
738 for (
const auto& sysInfo : systInfoList) {
740 ANA_MSG_DEBUG(
">>>> Working on variation: \"" <<(
sys.name()).c_str() <<
"\" <<<<<<" );
744 elcuts[isys][icut] += 1;
745 mucuts[isys][icut] += 1;
749 if (!(eventPassesGRL && eventPassesCleaning)) {++isys;
continue;}
750 elcuts[isys][icut] += 1;
751 mucuts[isys][icut] += 1;
755 if (!eventPassesTileTrip) {++isys;
continue;}
756 elcuts[isys][icut] += 1;
757 mucuts[isys][icut] += 1;
762 std::vector<std::string> trigItem = {
"HLT_e26_lhtight_nod0_ivarloose",
"HLT_mu26_ivarmedium",
"HLT_mu50",
"HLT_xe100",
"HLT_noalg_.*"};
763 if (isRun3) trigItem = {
"HLT_e26_lhtight_ivarloose_L1EM22VHI",
"HLT_e26_lhtight_ivarloose_L1eEM26M",
"HLT_mu24_ivarmedium_L1MU14FCH",
"HLT_mu50_L1MU14FCH",
"HLT_xe100",
"HLT_noalg_.*"};
764 for (
int it = 0;
it < (
int) trigItem.size();
it++) {
767 ANA_MSG_DEBUG(
"Pass " << trigItem[
it].c_str() <<
" trigger? " << (
int)
passed <<
", prescale " << prescale );
773 ANA_MSG_DEBUG(
"ChainGroup " << trigItem[
it].c_str() <<
": passing trigger? " << (
int)cg_passed <<
", prescale " << cg_prescale );
781 if (!eventPassesTrigger) {++isys;
continue;}
782 elcuts[isys][icut] += 1;
783 mucuts[isys][icut] += 1;
806 ANA_MSG_INFO(
"Cannot configure SUSYTools for systematic var. " << (
sys.name()).c_str() );
810 if (sysInfo.affectsKinematics || sysInfo.affectsWeights) isNominal =
false;
813 double event_weight = base_event_weight;
817 bool syst_affectsMuons = ST::testAffectsObject(
xAOD::Type::Muon, sysInfo.affectsType);
818 bool syst_affectsTaus = ST::testAffectsObject(
xAOD::Type::Tau, sysInfo.affectsType);
819 bool syst_affectsPhotons = ST::testAffectsObject(
xAOD::Type::Photon, sysInfo.affectsType);
820 bool syst_affectsJets = ST::testAffectsObject(
xAOD::Type::Jet, sysInfo.affectsType);
821 bool syst_affectsBTag = ST::testAffectsObject(
xAOD::Type::BTag, sysInfo.affectsType);
825 if (sysInfo.affectsKinematics) {
826 if (
slices[
"ele"] && syst_affectsElectrons) {
829 ANA_CHECK( objTool.
GetElectrons(electrons_syst, electrons_syst_aux,
true, isPHYSLite?
"AnalysisElectrons":
"Electrons") );
833 if (
slices[
"mu"] && syst_affectsMuons) {
836 ANA_CHECK( objTool.
GetMuons(muons_syst, muons_syst_aux,
true, isPHYSLite?
"AnalysisMuons":
"Muons") );
840 if(
slices[
"tau"] && syst_affectsTaus) {
843 ANA_CHECK( objTool.
GetTaus(taus_syst,taus_syst_aux,
true, isPHYSLite?
"AnalysisTauJets":
"TauJets") );
847 if(
slices[
"pho"] && syst_affectsPhotons) {
850 ANA_CHECK( objTool.
GetPhotons(photons_syst,photons_syst_aux,
true, isPHYSLite?
"AnalysisPhotons":
"Photons") );
851 photons = photons_syst;
854 if (
slices[
"jet"] && syst_affectsJets) {
857 ANA_CHECK( objTool.
GetJetsSyst(*jets_nominal, jets_syst, jets_syst_aux,
true, isPHYSLite?
"AnalysisJets":
"") );
861 if (
slices[
"btag"] && syst_affectsBTag) {
865 trkjets = trkjets_syst;
873 metcst_syst->setStore(metcst_syst_aux);
874 mettst_syst->setStore(mettst_syst_aux);
878 metcst = metcst_syst;
879 mettst = mettst_syst;
880 metcst_aux = metcst_syst_aux;
881 mettst_aux = mettst_syst_aux;
891 if (
slices[
"ele"] && (isNominal || (sysInfo.affectsKinematics && syst_affectsElectrons))) {
898 ANA_MSG_DEBUG(
" Truth Electron pt " << truthEle->
pt() <<
" eta " << truthEle->
eta() );
906 if (
slices[
"mu"] && (isNominal || (sysInfo.affectsKinematics && syst_affectsMuons))) {
907 for (
const auto&
mu : *muons) {
914 int muonTruthType = 0;
915 int muonTruthOrigin = 0;
918 if (ST::acc_truthType.
isAvailable(*trackParticle)) muonTruthType = ST::acc_truthType(*trackParticle);
919 if (ST::acc_truthOrigin.
isAvailable(*trackParticle)) muonTruthOrigin = ST::acc_truthOrigin(*trackParticle);
923 ANA_MSG_DEBUG(
" type " << muonTruthType <<
" origin " << muonTruthOrigin );
931 if (
slices[
"jet"] && (isNominal || (sysInfo.affectsKinematics && syst_affectsJets))) {
932 for (
const auto&
jet : *
jets) {
938 if (
slices[
"tau"] && (isNominal || (sysInfo.affectsKinematics && syst_affectsTaus))) {
939 for(
const auto& tau : *taus){
942 if (acc_IsTruthMatched(*tau) || !truthTau){
944 <<
int(acc_TruthProng(*tau))
945 <<
" prongs and a charge of "
946 << acc_TruthCharge(*tau));
954 if (isNominal || (sysInfo.affectsKinematics && (syst_affectsElectrons || syst_affectsMuons || syst_affectsJets))) {
964 for (
const auto&
jet : *
jets) {
965 if (ST::acc_baseline(*
jet) == 1 &&
966 ST::acc_passOR(*
jet) == 1 &&
967 ST::acc_signal(*
jet) == 1 &&
968 jet->pt() > 20000. && ( std::abs(
jet->eta()) < 2.5) ) {
972 if (
stream.compare(
"PHYSVAL")==0) jetInputType =
jet->getInputType();
974 else if (
stream.find(
"SUSY")!=std::string::npos) {
985 ANA_MSG_WARNING(
"Event failed 2015+2016 IsPFlowCrackVetoCleaning(electrons, photons), skipping..." );
992 if (
slices[
"met"] && (isNominal || sysInfo.affectsKinematics)) {
994 if(
stream.find(
"SUSY3")!=std::string::npos){
1022 int el_idx[
nSel] = {0};
1026 if ( ST::acc_passOR(*
el) == 0 ) {
1030 if ( ST::acc_baseline(*
el) == 1 ) {
1033 if ( ST::acc_signal(*
el) == 1 ) {
1035 if (
el->pt() > 20000. ) {
1039 for(
const auto&
t : el_triggers){
1052 if (isNominal || syst_affectsElectrons) {
1056 if (isNominal) {elecSF_nominal = elecSF;}
1057 else if (!syst_affectsElectrons) {elecSF = elecSF_nominal;}
1058 event_weight *= elecSF;
1064 int mu_idx[
nSel] = {0};
1065 bool passTMtest =
false;
1067 TString muTrig2015 =
"HLT_mu20_iloose_L1MU15_OR_HLT_mu50";
1068 TString muTrig2016 =
"HLT_mu26_ivarmedium_OR_HLT_mu50";
1069 TString muTrig2017 =
"HLT_mu26_ivarmedium_OR_HLT_mu50";
1070 TString muTrig2022 =
"HLT_mu24_ivarmedium_L1MU14FCH_OR_HLT_mu50_L1MU14FCH";
1072 std::vector<std::string> muTrigs2015 = {
"HLT_mu20_iloose_L1MU15",
"HLT_mu50"};
1073 std::vector<std::string> muTrigs2016 = {
"HLT_mu26_ivarmedium",
"HLT_mu50"};
1074 std::vector<std::string> muTrigs2017 = {
"HLT_mu26_ivarmedium",
"HLT_mu50"};
1075 std::vector<std::string> muTrigs2022 = {
"HLT_mu24_ivarmedium_L1MU14FCH",
"HLT_mu50_L1MU14FCH"};
1079 for (
const auto&
mu : *muons) {
1080 if ( ST::acc_passOR(*
mu) == 0 ) {
1084 if ( ST::acc_baseline(*
mu) == 1 ) {
1086 if ( ST::acc_cosmic(*
mu) == 1 ) {
1090 if ( ST::acc_signal(*
mu) == 1 ) {
1092 if (
mu->pt() > 20000. ) {
1096 for(
const auto&
t : mu_triggers){
1106 std::vector<std::string> my_mu_trigs;
1109 my_mu_trigs=muTrigs2015;
1111 my_mu_trigs=muTrigs2016;
1113 my_mu_trigs=muTrigs2017;
1115 my_mu_trigs=muTrigs2022;
1118 my_mu_trigs=muTrigs2016;
1130 int n_SignalPhotons = 0;
1131 for (
const auto&
y : *photons) {
1132 if ( ST::acc_passOR(*
y) && ST::acc_signal(*
y)) {
1146 bool comb_trig_check =
false;
1148 if (
slices[
"ele"] &&
slices[
"mu"] && comb_trig_check) {
1150 if (objTool.
IsTrigPassed(
"HLT_2e12_lhloose_L12EM10VH"))
1156 if (objTool.
IsTrigPassed(
"HLT_2e17_lhvloose_nod0_L12EM15VHI"))
1174 if (objTool.
IsTrigPassed(
"HLT_2e12_lhloose_nod0_mu10"))
1178 if (objTool.
IsTrigPassed(
"HLT_e12_lhloose_nod0_2mu10"))
1184 if (
slices[
"mu"] && ((!isData && isNominal) || syst_affectsMuons)) {
1186 if(passTMtest || 1){
1198 if (isNominal) { muonSF_nominal = muonSF; }
1199 else if (!syst_affectsMuons) { muonSF = muonSF_nominal; }
1200 event_weight *= muonSF;
1205 if (
slices[
"tau"] && isNominal && !isData &&
stream.find(
"SUSY3")!=std::string::npos) {
1217 for (
const auto& tau : *taus) {
1219 <<
", idSF = " << objTool.
GetSignalTauSF(*tau,
true,
false,
"tau125_medium1_tracktwo")
1220 <<
", trigSF = " << objTool.
GetSignalTauSF(*tau,
false,
true,
"tau125_medium1_tracktwo")
1221 <<
", totSF = " << objTool.
GetSignalTauSF(*tau,
true,
true,
"tau125_medium1_tracktwo")
1232 int jet_idx[
nSel] = {0};
1235 for (
const auto&
jet : *goodJets) {
1236 if ( ST::acc_bad(*
jet) == 1 )
1238 if ( ST::acc_passOR(*
jet) == 0 ) {
1242 if ( ST::acc_baseline(*
jet) == 1 ) {
1244 if (
jet->pt() > 50000. )
1247 if ( ST::acc_bjet(*
jet) == 1 )
1257 if (isNominal) {btagSF = btagSF_nominal = objTool.
BtagSF(
jets);}
1258 else if (syst_affectsBTag || (sysInfo.affectsKinematics && syst_affectsJets)) {btagSF = objTool.
BtagSF(
jets);}
1259 else {btagSF = btagSF_nominal;}
1261 event_weight *= btagSF;
1264 if (
stream.find(
"SUSY1")!=std::string::npos ) {
1265 float btagSF_trkJet(1.);
1267 if (isNominal) {btagSF_trkJet = btagSF_trkJet_nominal = objTool.
BtagSF_trkJet(trkjets);}
1268 else if (syst_affectsBTag || (sysInfo.affectsKinematics && syst_affectsJets)) {btagSF_trkJet = objTool.
BtagSF_trkJet(trkjets);}
1269 else {btagSF_trkJet = btagSF_trkJet_nominal;}
1271 event_weight *= btagSF_trkJet;
1280 elcuts[isys][icut] += 1;
1281 mucuts[isys][icut] += 1;
1286 bool passel = el_idx[
baseline] == 1;
1287 bool passmu = mu_idx[
baseline] == 1;
1288 if (passel) elcuts[isys][icut] += 1;
1289 if (passmu) mucuts[isys][icut] += 1;
1294 if (passel) elcuts[isys][icut] += 1;
1295 if (passmu) mucuts[isys][icut] += 1;
1298 passel = el_idx[
goodpt] == 1;
1299 passmu = mu_idx[
goodpt] == 1;
1300 if (passel) elcuts[isys][icut] += 1;
1301 if (passmu) mucuts[isys][icut] += 1;
1306 if (passel) elcuts[isys][icut] += 1;
1307 if (passmu) mucuts[isys][icut] += 1;
1310 if (jet_idx[
goodpt] >= 2) {
1311 if (passel) elcuts[isys][icut] += 1;
1312 if (passmu) mucuts[isys][icut] += 1;
1322 if (sysInfo.affectsKinematics) {
1330 ANA_MSG_DEBUG(
">>>> Finished with variation: \"" <<(
sys.name()).c_str() <<
"\" <<<<<<" );
1350 "===>>> done processing event #%i, "
1351 "run #%i %i events processed so far <<<===",
1354 static_cast< int >(
entry + 1 ) );
1368 "Time per event: (CPU / WALL)\n"
1369 " Entire loop - %f / %f ms\n"
1370 " First event - %f / %f ms\n"
1371 " Excluding first event - %f / %f ms",
1373 m_clock1.CpuTime() * 1
e3, m_clock1.RealTime() * 1
e3,
1374 m_clock2.CpuTime() * 1
e3 / (
entries - 1), m_clock2.RealTime() * 1
e3 / (
entries - 1));
1379 for (
const auto& sysInfo : systInfoList) {
1381 ANA_MSG_INFO(
"-- Dummy Cutflow -- >>>> Variation " <<
sys.name().c_str() <<
" <<<<" );
1382 for (
size_t icut = 0; icut <
Ncuts; ++icut) {
1384 <<
"-> el: " << elcuts[isys][icut] <<
", mu: " << mucuts[isys][icut] );
1396 std::vector<std::string> vtokens;
1397 TObjArray*
tokens = TString(std::move(
line)).Tokenize(delim);
1398 if(
tokens->GetEntriesFast()) {
1400 TObjString*
os =
nullptr;
1401 while ((
os=(TObjString*)iString())) {
1402 vtokens.push_back(
os->GetString().Data() );
1413 std::map< std::string, std::string >
containers;
1414 std::unique_ptr< TTree > ctree(
dynamic_cast<TTree*
>(
f->Get(
"CollectionTree") ) );
1415 TObjArray *blist =
dynamic_cast<TObjArray*
>( ctree->GetListOfBranches() );
1417 std::string
result, bname;
1418 for (
int ib=0;
ib<blist->GetEntries(); ++
ib) {
1419 TBranch *
b =
dynamic_cast<TBranch*
>( blist->At(
ib) );
1420 bname =
b->GetName();
1421 if (bname.find(
"Aux")==std::string::npos)
continue;