23 #include <TStopwatch.h> 
   25 #include "TObjArray.h" 
   26 #include "TObjString.h" 
   84   "==1 baseline lepton",
 
   87   "trig. matched lepton",
 
  106 std::vector<std::string> 
getTokens(TString 
line, 
const TString& delim);
 
  112   using namespace asg::msgSTT;
 
  124     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]" );
 
  131   int autoconfigPRW = 1;
 
  132   int commonPRWFile = 1;
 
  137   bool isPHYSLite = 
false;
 
  144   std::unique_ptr< TFile > 
ifile( TFile::Open( 
fileName, 
"READ" ) );
 
  156   std::string prw_file = 
"DUMMY";
 
  157   std::string ilumicalc_file = 
"DUMMY";
 
  159   for (
int i = 1 ; 
i < 
argc ; 
i++) {
 
  160     const char* 
key = strtok(
argv[
i], 
"=") ;
 
  161     const char* 
val = strtok(0, 
" ") ;
 
  163     ANA_MSG_INFO( 
"===== Processing key " << TString(
key) << 
" with value " << TString(
val) );
 
  164     if (strcmp(
key, 
"autoconfigPRW") == 0) autoconfigPRW = 
atoi(
val);
 
  165     if (strcmp(
key, 
"commonPRWFile") == 0) commonPRWFile = 
atoi(
val);
 
  166     if (strcmp(
key, 
"isData") == 0) isData = 
atoi(
val);
 
  167     if (strcmp(
key, 
"isAtlfast") == 0) isAtlfast = 
atoi(
val);
 
  168     if (strcmp(
key, 
"NoSyst") == 0) NoSyst = 
atoi(
val);
 
  171     if (strcmp(
key, 
"PRWFile") == 0) prw_file = std::string(
val);
 
  172     if (strcmp(
key, 
"ilumicalcFile") == 0) ilumicalc_file = std::string(
val);
 
  179   if (isData < 0 || isAtlfast < 0) {
 
  180     ANA_MSG_ERROR( 
"One of the flags isData or isAtlfast was not set! Must provide isData or isAtlfast." );
 
  181     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]");
 
  189   bool hasTrkJets(
false), hasFatJets(
false);
 
  191     if (
x.first.find(
"AntiKtVR30Rmax4Rmin02TrackJets")!=std::string::npos)           hasTrkJets = 
true;
 
  192     if (
x.first.find(
"AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets")!=std::string::npos) hasFatJets = 
true;
 
  193     if (
x.first.find(
"AnalysisElectrons")!=std::string::npos)                        isPHYSLite = 
true;
 
  194     if (isPHYSLite && 
x.first.find(
"AnalysisLargeRJets")!=std::string::npos)         hasFatJets = 
false;
 
  195     if (
x.first.find(
"InDetLargeD0TrackParticles") != std::string::npos)             hasLRT     = 
true;
 
  200     ANA_MSG_INFO(
"hasTrkJets: " << (hasTrkJets?
"true":
"false"));
 
  201     ANA_MSG_INFO(
"hasFatJets: " << (hasFatJets?
"true":
"false"));
 
  202     ANA_MSG_INFO(
"isPHYSLite: " << (isPHYSLite?
"true":
"false"));
 
  228     std::vector<std::string> myGRLs;
 
  234     myGRLs.push_back(
PathResolverFindCalibFile(
"GoodRunsLists/data22_13p6TeV/20250321/data22_13p6TeV.periodAllYear_DetStatus-v134-pro28-09_MERGED_PHYS_StandardGRL_All_Good_25ns.xml"));
 
  235     myGRLs.push_back(
PathResolverFindCalibFile(
"GoodRunsLists/data23_13p6TeV/20250321/data23_13p6TeV.periodAllYear_DetStatus-v133-pro31-11_MERGED_PHYS_StandardGRL_All_Good_25ns.xml"));
 
  262   ANA_CHECK( objTool.setProperty(
"DataSource", datasource) ) ;
 
  263   if(!config_file.empty())
 
  264     ANA_CHECK( objTool.setProperty(
"ConfigFile", config_file) );
 
  273   std::vector<std::string> prw_conf;
 
  275     if ( autoconfigPRW == 1 ) {
 
  277       if ( commonPRWFile == 1 )
 
  280       if (prw_file == 
"DUMMY") {
 
  281         prw_conf.push_back(
"dev/SUSYTools/merged_prw_mc16a_latest.root");
 
  285       ANA_CHECK( objTool.setProperty(
"PRWConfigFiles", prw_conf) );
 
  291   std::string ilumi = 
"GoodRunsLists/data18_13TeV/20190318/ilumicalc_histograms_None_348885-364292_OflLumi-13TeV-010.root";
 
  294     ilumi = 
"GoodRunsLists/data22_13p6TeV/20250321/ilumicalc_histograms_None_431810-440613_OflLumi-Run3-004.root"; 
 
  297     ilumi = 
"GoodRunsLists/data23_13p6TeV/20250321/ilumicalc_histograms_None_451587-456749_OflLumi-Run3-004.root";
 
  300     ilumi = 
"GoodRunsLists/data24_13p6TeV/20241118/ilumicalc_histograms_None_473235-486706_OflLumi-Run3-005.root";
 
  304     ilumi = 
"GoodRunsLists/data16_13TeV/20180129/PHYS_StandardGRL_All_Good_25ns_297730-311481_OflLumi-13TeV-009.root";
 
  307     ilumi = 
"GoodRunsLists/data17_13TeV/20180619/physics_25ns_Triggerno17e33prim.lumicalc.OflLumi-13TeV-010.root";
 
  310     ilumi = 
"GoodRunsLists/data18_13TeV/20190318/ilumicalc_histograms_None_348885-364292_OflLumi-13TeV-010.root";
 
  331   std::vector<std::string> prw_lumicalc;
 
  332   if (ilumicalc_file == 
"DUMMY") {
 
  335     prw_lumicalc = 
getTokens(ilumicalc_file,
",");
 
  337   ANA_CHECK( objTool.setProperty(
"PRWLumiCalcFiles", prw_lumicalc) );
 
  343     ANA_CHECK( objTool.setProperty(
"ShowerType", (
int)ishower) );
 
  354   if ( objTool.
initialize() != StatusCode::SUCCESS) {
 
  355     ANA_MSG_ERROR( 
"Cannot initialize SUSYObjDef_xAOD, exiting." );
 
  366   if ( rEnv.ReadFile(config_file.c_str(), kEnvAll) != 0 ) {
 
  372   std::map<std::string,std::string> configDict = {};
 
  373   configDict[
"Jet.LargeRcollection"] = rEnv.GetValue(
"Jet.LargeRcollection", 
"AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets" );
 
  374   configDict[
"TrackJet.Collection"]  = rEnv.GetValue(
"TrackJet.Collection", 
"AntiKtVR30Rmax4Rmin02TrackJets" );
 
  375   configDict[
"Jet.WtaggerConfig"]    = rEnv.GetValue(
"Jet.WtaggerConfig", 
"None");
 
  376   configDict[
"Jet.ZtaggerConfig"]    = rEnv.GetValue(
"Jet.ZtaggerConfig", 
"None");
 
  377   configDict[
"Jet.ToptaggerConfig"]  = rEnv.GetValue(
"Jet.ToptaggerConfig", 
"None");
 
  381   for (
auto& keyval : configDict) {
 
  382      configDict[keyval.first] = regex_replace(configDict[keyval.first], 
comment, 
"");
 
  383      configDict[keyval.first] = regex_replace(configDict[keyval.first], trimspaces, 
"$1");
 
  384      ANA_MSG_DEBUG(
"config " << keyval.first << 
" : " << configDict[keyval.first]);
 
  386   std::string FatJetCollection = configDict[
"Jet.LargeRcollection"];
 
  387   std::string TrkJetCollection = configDict[
"TrackJet.Collection"];
 
  388   if (configDict[
"TrackJet.Collection"].
find(
"None")!=std::string::npos) TrkJetCollection = 
"";
 
  390   std::map<std::string,bool> 
slices = {};
 
  391   slices[
"ele"]  = 
bool(rEnv.GetValue(
"Slices.Ele", 
true));
 
  392   slices[
"pho"]  = 
bool(rEnv.GetValue(
"Slices.Pho", 
true));
 
  393   slices[
"mu"]   = 
bool(rEnv.GetValue(
"Slices.Mu", 
true));
 
  394   slices[
"tau"]  = 
bool(rEnv.GetValue(
"Slices.Tau", 
true));
 
  395   slices[
"jet"]  = 
bool(rEnv.GetValue(
"Slices.Jet", 
true));
 
  396   slices[
"bjet"] = 
bool(rEnv.GetValue(
"Slices.BJet", 
true));
 
  397   slices[
"fjet"] = 
bool(rEnv.GetValue(
"Slices.FJet", 
true));
 
  398   slices[
"tjet"] = 
bool(rEnv.GetValue(
"Slices.TJet", 
true));
 
  399   slices[
"met"]  = 
bool(rEnv.GetValue(
"Slices.MET", 
true));
 
  403   ToolHandle<TauAnalysisTools::ITauTruthMatchingTool> T2MT = 0;
 
  404   if (
slices[
"tau"] && !isData) {
 
  406     T2MT = asg::ToolStore::get<TauAnalysisTools::ITauTruthMatchingTool>(
"ToolSvc.TauTruthMatch");
 
  412   std::vector<std::string> el_triggers,mu_triggers,ph_triggers,tau_triggers,emu_triggers;
 
  414     el_triggers = {
"HLT_e26_lhtight_ivarloose_L1EM22VHI",
"HLT_e26_lhtight_ivarloose_L1eEM26M",
"HLT_e60_lhmedium_L1EM22VHI", 
"HLT_e140_lhloose_L1EM22VHI"};
 
  415     mu_triggers = {
"HLT_mu24_ivarmedium_L1MU14FCH",
"HLT_mu50_L1MU14FCH",
"HLT_mu60_0eta105_msonly_L1MU14FCH",
"HLT_mu60_L1MU14FCH",
"HLT_mu80_msonly_3layersEC_L1MU14FCH"};
 
  416     ph_triggers = {
"HLT_g140_loose_L1EM22VHI",
"HLT_g300_etcut_L1EM22VHI"};
 
  417     tau_triggers = {
"HLT_tau160_mediumRNN_tracktwoMVA_L1TAU100", 
"HLT_tau40_mediumRNN_tracktwoMVA_tau35_mediumRNN_tracktwoMVA_03dRAB_L1TAU25IM_2TAU20IM_2J25_3J20"};
 
  418     emu_triggers = {
"HLT_2e12_lhloose_mu10_L12EM8VH_MU8F", 
"HLT_e12_lhloose_2mu10_L12MU8F", 
"HLT_e17_lhloose_mu14_L1EM15VH_MU8F", 
"HLT_e7_lhmedium_mu24_L1MU14FCH"};
 
  422     el_triggers = {
"HLT_e24_lhmedium_L1EM20VH",
"HLT_e26_lhtight_nod0_ivarloose", 
"HLT_e60_lhmedium_nod0", 
"HLT_e160_lhloose_nod0"};
 
  423     mu_triggers = {
"HLT_mu26_ivarmedium",
"HLT_mu50",
"HLT_mu20_mu8noL1"};
 
  424     ph_triggers = {
"HLT_g120_loose"};
 
  425     tau_triggers = {
"HLT_tau125_medium1_tracktwo", 
"HLT_tau40_mediumRNN_tracktwoMVA_tau35_mediumRNN_tracktwoMVA"};
 
  426     emu_triggers = {
"HLT_2e12_lhloose_nod0_mu10", 
"HLT_e12_lhloose_nod0_2mu10", 
"HLT_e17_lhloose_nod0_mu14", 
"HLT_e7_lhmedium_nod0_mu24"};
 
  430   std::vector<ST::SystInfo> systInfoList;
 
  436     systInfoList.push_back(infodef);
 
  442   const size_t Nsyst = systInfoList.size();
 
  443   std::vector<std::vector<int> > elcuts;
 
  444   std::vector<std::vector<int> > mucuts;
 
  445   for (isys = 0; isys < Nsyst; ++isys) {
 
  446     std::vector<int> elcutsCurrentSyst;
 
  447     std::vector<int> mucutsCurrentSyst;
 
  448     for (
size_t icut = 0; icut < 
Ncuts; ++icut) {
 
  449       elcutsCurrentSyst.push_back(0);
 
  450       mucutsCurrentSyst.push_back(0);
 
  452     elcuts.push_back(elcutsCurrentSyst);
 
  453     mucuts.push_back(elcutsCurrentSyst);
 
  457     Error(
APP_NAME, 
"Cannot reset SUSYTools systematics" );
 
  470   std::string cbkname, 
stream, ostream, kernel;
 
  484     event.getEntry( 
entry );
 
  490         ANA_MSG_ERROR(
"Failed to retrieve CutBookkeepers from MetaData, exiting.");
 
  497       for ( 
const auto *cbk : *completeCBC ) {
 
  498         cbkname = cbk->
name();
 
  499         stream = cbk->inputStream();
 
  500         ostream = (cbk->outputStreams().size() ? cbk->outputStreams()[0] : 
"");
 
  501         ANA_MSG_INFO(
"== cbkname: " << cbkname << 
", description: " << cbk->description() << 
", stream: " << 
stream);
 
  502         ANA_MSG_INFO(
"   inputStream: " << cbk->inputStream()  << 
", outputStreams: " << ostream);
 
  503         ANA_MSG_INFO(
"   cycle: " << cbk->cycle() << 
",  allEvents = " << cbk->nAcceptedEvents());
 
  504         if (cbkname.find(
"PHYSVAL")!=std::string::npos) kernel=
"PHYSVAL";
 
  505         else if (cbkname.find(
"PHYSLITE")!=std::string::npos) kernel=
"PHYSLITE";
 
  506         else if (cbkname.find(
"PHYS")!=std::string::npos) kernel=
"PHYS";
 
  507         else if (
stream.find(
"StreamAOD")!=std::string::npos) kernel=
stream.replace(
stream.find(
"Stream"),6,
"");
 
  509         if (cbkname.find(
"AllExecutedEvents")!=std::string::npos && ostream.find(
"StreamAOD")!=std::string::npos && cbk->cycle() > maxcycle) {
 
  510            maxcycle = cbk->cycle();
 
  519         ANA_MSG_INFO( 
"CutBookkeepers Accepted " << nEventsProcessed << 
" SumWei " << sumOfWeights << 
" sumWei2 " << sumOfWeightsSquared);
 
  520       } 
else { 
ANA_MSG_INFO( 
"No relevent CutBookKeepers found" ); }
 
  549                     "run #" << 
static_cast< int >( ei->
runNumber() ) << 
" " << 
static_cast< int >( 
entry ) << 
" events processed so far  <<<===");
 
  554       ANA_MSG_INFO( 
"===>>>  process cross section " << xsectTimesEff );
 
  557     bool eventPassesGRL(
true);
 
  558     bool eventPassesCleaning(
true);
 
  559     bool eventPassesTileTrip(
true); 
 
  560     bool eventPassesTrigger(
true);  
 
  564       float PRW_weight = isPHYSLite? pileupWeightAcc(*ei): objTool.
GetPileupWeight();
 
  582         if( objTool.
FindSusyHP(pdgid1, pdgid2) != StatusCode::SUCCESS ){
 
  583           ANA_MSG_WARNING( 
"SUSY Proc finding failed. Normal for non-SUSY samples." );
 
  586         if( pdgid1!=0 && pdgid2!=0){ 
 
  601       Warning(
APP_NAME , 
"No PV found for this event! Skipping...");
 
  633       ANA_CHECK( objTool.
GetElectrons(electrons_nominal, electrons_nominal_aux, 
true, isPHYSLite?
"AnalysisElectrons":
"Electrons") );
 
  636       for (
const auto& 
electron : *electrons_nominal){
 
  639           bool idok = 
electron->passSelection(accepted, 
"passBaseID");
 
  640           if(idok) 
ANA_MSG_DEBUG(
"Electron Baseline ID Decision : " << accepted );
 
  641           else     ANA_MSG_DEBUG(
"Electron Baseline ID Decision not available " );
 
  647     if( 
slices[
"pho"] && 
stream.find(
"SUSY12")==std::string::npos) {
 
  649       ANA_CHECK( objTool.
GetPhotons(photons_nominal,photons_nominal_aux, 
true, isPHYSLite?
"AnalysisPhotons":
"Photons") );
 
  656       ANA_CHECK( objTool.
GetMuons(muons_nominal, muons_nominal_aux, 
true, isPHYSLite?
"AnalysisMuons":
"Muons") );
 
  660       for (
const auto& 
muon : *muons_nominal){
 
  664             << 
"baseline = " << (
int)ST::acc_baseline(*
muon) << 
" ," 
  665             << 
"bad = " << (
int)ST::acc_bad(*
muon) << 
" ," 
  666             << 
"IsHighPt(deco) = " << (
int)ST::acc_passedHighPtCuts(*
muon) << 
" , " 
  675       ANA_CHECK( objTool.
GetJets(jets_nominal, jets_nominal_aux, 
true, isPHYSLite?
"AnalysisJets":
"") ); 
 
  681     if (
slices[
"tjet"] && hasTrkJets) {
 
  687         ANA_MSG_ERROR(
"TrackJet collection " << TrkJetCollection.c_str() << 
" not available in input file. Please check!");
 
  694     if(
slices[
"fjet"] && hasFatJets) { 
 
  695       ANA_MSG_DEBUG( 
"Nominal fat jet step, collection: " <<  FatJetCollection );
 
  700           for (
const auto& 
fatjet : *fatjets_nominal) {
 
  705         ANA_MSG_ERROR(
"LargeR jet collection " << FatJetCollection.c_str() << 
" not available in input file. Please check!");
 
  713       ANA_CHECK( objTool.
GetTaus(taus_nominal,taus_nominal_aux, 
true, isPHYSLite?
"AnalysisTauJets":
"TauJets") );
 
  722     metcst_nominal->setStore(metcst_nominal_aux);
 
  724     double metsig_cst (0.);
 
  725     mettst_nominal->setStore(mettst_nominal_aux);
 
  727     double metsig_tst (0.);
 
  733     double base_event_weight(1.);
 
  739         Info(
APP_NAME , 
"--- SHERPA2.2 REWEIGHTING : %f", RW_sh22);
 
  746     double elecSF_nominal(1.);
 
  747     double muonSF_nominal(1.);
 
  749     double btagSF_nominal(1.);
 
  750     double btagSF_trkJet_nominal(1.);
 
  753     bool isNominal(
true);
 
  756     for (
const auto& sysInfo : systInfoList) {
 
  758       ANA_MSG_DEBUG(
">>>> Working on variation: \"" <<(
sys.name()).c_str() << 
"\" <<<<<<" );
 
  762       elcuts[isys][icut] += 1;
 
  763       mucuts[isys][icut] += 1;
 
  767       if (!(eventPassesGRL && eventPassesCleaning)) {++isys; 
continue;}
 
  768       elcuts[isys][icut] += 1;
 
  769       mucuts[isys][icut] += 1;
 
  773       if (!eventPassesTileTrip) {++isys; 
continue;}
 
  774       elcuts[isys][icut] += 1;
 
  775       mucuts[isys][icut] += 1;
 
  780         std::vector<std::string> trigItem = {
"HLT_e26_lhtight_nod0_ivarloose",
"HLT_mu26_ivarmedium",
"HLT_mu50",
"HLT_xe100",
"HLT_noalg_.*"}; 
 
  781         if (isRun3) trigItem = {
"HLT_e26_lhtight_ivarloose_L1EM22VHI",
"HLT_e26_lhtight_ivarloose_L1eEM26M",
"HLT_mu24_ivarmedium_L1MU14FCH",
"HLT_mu50_L1MU14FCH",
"HLT_xe100",
"HLT_noalg_.*"}; 
 
  782         for (
int it = 0; 
it < (
int) trigItem.size(); 
it++) {
 
  785           ANA_MSG_DEBUG( 
"Pass " << trigItem[
it].c_str() << 
" trigger? " << (
int)
passed << 
", prescale " << prescale );
 
  791           ANA_MSG_DEBUG( 
"ChainGroup " << trigItem[
it].c_str() << 
": passing trigger? " << (
int)cg_passed << 
", prescale " << cg_prescale );
 
  799       if (!eventPassesTrigger)  {++isys; 
continue;}
 
  800       elcuts[isys][icut] += 1;
 
  801       mucuts[isys][icut] += 1;
 
  824         ANA_MSG_INFO( 
"Cannot configure SUSYTools for systematic var. " << (
sys.name()).c_str() );
 
  828       if (sysInfo.affectsKinematics || sysInfo.affectsWeights) isNominal = 
false;
 
  831       double event_weight = base_event_weight;
 
  835       bool syst_affectsMuons = ST::testAffectsObject(
xAOD::Type::Muon, sysInfo.affectsType);
 
  836       bool syst_affectsTaus = ST::testAffectsObject(
xAOD::Type::Tau, sysInfo.affectsType);
 
  837       bool syst_affectsPhotons = ST::testAffectsObject(
xAOD::Type::Photon, sysInfo.affectsType);
 
  838       bool syst_affectsJets = ST::testAffectsObject(
xAOD::Type::Jet, sysInfo.affectsType);
 
  839       bool syst_affectsBTag = ST::testAffectsObject(
xAOD::Type::BTag, sysInfo.affectsType);
 
  843       if (sysInfo.affectsKinematics) {
 
  844         if (
slices[
"ele"] && syst_affectsElectrons) {
 
  847           ANA_CHECK( objTool.
GetElectrons(electrons_syst, electrons_syst_aux, 
true, isPHYSLite?
"AnalysisElectrons":
"Electrons") );
 
  851         if (
slices[
"mu"] && syst_affectsMuons) {
 
  854           ANA_CHECK( objTool.
GetMuons(muons_syst, muons_syst_aux, 
true, isPHYSLite?
"AnalysisMuons":
"Muons") );
 
  858         if(
slices[
"tau"] && syst_affectsTaus) {
 
  861           ANA_CHECK( objTool.
GetTaus(taus_syst,taus_syst_aux, 
true, isPHYSLite?
"AnalysisTauJets":
"TauJets") );
 
  865         if(
slices[
"pho"] && syst_affectsPhotons) {
 
  868           ANA_CHECK( objTool.
GetPhotons(photons_syst,photons_syst_aux, 
true, isPHYSLite?
"AnalysisPhotons":
"Photons") );
 
  869           photons = photons_syst;
 
  872         if (
slices[
"jet"] && syst_affectsJets) {
 
  875           ANA_CHECK( objTool.
GetJetsSyst(*jets_nominal, jets_syst, jets_syst_aux, 
true, isPHYSLite?
"AnalysisJets":
"") );
 
  879         if (
slices[
"btag"] && syst_affectsBTag) {
 
  883           trkjets = trkjets_syst;
 
  891           metcst_syst->setStore(metcst_syst_aux);
 
  892           mettst_syst->setStore(mettst_syst_aux);
 
  896           metcst = metcst_syst;
 
  897           mettst = mettst_syst;
 
  898           metcst_aux = metcst_syst_aux;
 
  899           mettst_aux = mettst_syst_aux;
 
  909       if (
slices[
"ele"] && (isNominal || (sysInfo.affectsKinematics && syst_affectsElectrons))) {
 
  916               ANA_MSG_DEBUG( 
" Truth Electron pt " << truthEle->
pt() << 
" eta " << truthEle->
eta() );
 
  924       if (
slices[
"mu"] && (isNominal || (sysInfo.affectsKinematics && syst_affectsMuons))) {
 
  925         for (
const auto& 
mu : *muons) {
 
  932             int muonTruthType = 0;
 
  933             int muonTruthOrigin = 0;
 
  936               if (ST::acc_truthType.
isAvailable(*trackParticle)) muonTruthType = ST::acc_truthType(*trackParticle);
 
  937               if (ST::acc_truthOrigin.
isAvailable(*trackParticle)) muonTruthOrigin = ST::acc_truthOrigin(*trackParticle);
 
  941                 ANA_MSG_DEBUG( 
"            type " << muonTruthType << 
" origin " <<  muonTruthOrigin );
 
  949       if (
slices[
"jet"] && (isNominal || (sysInfo.affectsKinematics && syst_affectsJets))) {
 
  950         for (
const auto& 
jet : *
jets) {
 
  956       if (
slices[
"tau"] && (isNominal || (sysInfo.affectsKinematics && syst_affectsTaus))) {
 
  957         for(
const auto& tau : *taus){
 
  961               ANA_MSG_DEBUG(
"Tau was matched to a truth particle, which has a charge of " 
  962                              << 
static_cast<int>(truthTau->
charge()));  
 
  970       if (isNominal || (sysInfo.affectsKinematics && (syst_affectsElectrons || syst_affectsMuons || syst_affectsJets))) {
 
  979         for (
const auto& 
jet : *
jets) {
 
  980           if (ST::acc_baseline(*
jet) == 1  &&
 
  981               ST::acc_passOR(*
jet) == 1  &&
 
  982               ST::acc_signal(*
jet) == 1  &&
 
  983               jet->pt() > 20000.  && ( std::abs(
jet->eta()) < 2.5) ) {
 
  989       if (
slices[
"met"] && (isNominal || sysInfo.affectsKinematics)) {
 
  991         if(
stream.find(
"SUSY3")!=std::string::npos){
 
 1019       int el_idx[
nSel] = {0};
 
 1023           if ( ST::acc_passOR(*
el) == 0  ) {
 
 1027           if ( ST::acc_baseline(*
el) == 1  ) {
 
 1030           if ( ST::acc_signal(*
el) == 1  ) {
 
 1032             if ( 
el->pt() > 20000. ) {
 
 1036               for(
const auto& 
t : el_triggers){
 
 1049         if (isNominal || syst_affectsElectrons) {
 
 1053         if (isNominal) {elecSF_nominal = elecSF;}
 
 1054         else if (!syst_affectsElectrons) {elecSF = elecSF_nominal;}
 
 1055         event_weight *= elecSF;
 
 1061       int mu_idx[
nSel] = {0};
 
 1062       bool passTMtest = 
false;
 
 1064       TString muTrig2015 = 
"HLT_mu20_iloose_L1MU15_OR_HLT_mu50"; 
 
 1065       TString muTrig2016 = 
"HLT_mu26_ivarmedium_OR_HLT_mu50";
 
 1066       TString muTrig2017 = 
"HLT_mu26_ivarmedium_OR_HLT_mu50";
 
 1067       TString muTrig2022 = 
"HLT_mu24_ivarmedium_L1MU14FCH_OR_HLT_mu50_L1MU14FCH";
 
 1069       std::vector<std::string> muTrigs2015 = {
"HLT_mu20_iloose_L1MU15",
"HLT_mu50"}; 
 
 1070       std::vector<std::string> muTrigs2016 = {
"HLT_mu26_ivarmedium",
"HLT_mu50"};
 
 1071       std::vector<std::string> muTrigs2017 = {
"HLT_mu26_ivarmedium",
"HLT_mu50"};
 
 1072       std::vector<std::string> muTrigs2022 = {
"HLT_mu24_ivarmedium_L1MU14FCH",
"HLT_mu50_L1MU14FCH"};
 
 1076         for (
const auto& 
mu : *muons) {
 
 1077           if ( ST::acc_passOR(*
mu) == 0  ) {
 
 1081           if ( ST::acc_baseline(*
mu) == 1  ) {
 
 1083             if ( ST::acc_cosmic(*
mu) == 1  ) {
 
 1087           if ( ST::acc_signal(*
mu) == 1  ) {
 
 1089             if ( 
mu->pt() > 20000. )  {
 
 1093               for(
const auto& 
t : mu_triggers){
 
 1103             std::vector<std::string> my_mu_trigs;
 
 1106                 my_mu_trigs=muTrigs2015;
 
 1108                 my_mu_trigs=muTrigs2016;
 
 1110                 my_mu_trigs=muTrigs2017;
 
 1112                 my_mu_trigs=muTrigs2022;
 
 1115               my_mu_trigs=muTrigs2016;
 
 1127         int n_SignalPhotons = 0;
 
 1128         for (
const auto& 
y : *photons) {
 
 1129           if ( ST::acc_passOR(*
y) && ST::acc_signal(*
y)) {
 
 1143       bool comb_trig_check = 
false;
 
 1145       if (
slices[
"ele"] && 
slices[
"mu"] && comb_trig_check) {
 
 1147         if (objTool.
IsTrigPassed(
"HLT_2e12_lhloose_L12EM10VH"))
 
 1153         if (objTool.
IsTrigPassed(
"HLT_2e17_lhvloose_nod0_L12EM15VHI"))
 
 1171         if (objTool.
IsTrigPassed(
"HLT_2e12_lhloose_nod0_mu10"))
 
 1175         if (objTool.
IsTrigPassed(
"HLT_e12_lhloose_nod0_2mu10"))
 
 1181       if (
slices[
"mu"] && ((!isData && isNominal) || syst_affectsMuons)) {
 
 1183         if(passTMtest || 1){ 
 
 1195         if (isNominal) { muonSF_nominal = muonSF; }
 
 1196         else if (!syst_affectsMuons) { muonSF = muonSF_nominal; }
 
 1197         event_weight *= muonSF;
 
 1202       if (
slices[
"tau"] && isNominal && !isData && 
stream.find(
"SUSY3")!=std::string::npos) {
 
 1214           for (
const auto& tau : *taus) {
 
 1216                           << 
", idSF = "   << objTool.
GetSignalTauSF(*tau,
true,
false,
"tau125_medium1_tracktwo")
 
 1217                           << 
", trigSF = " << objTool.
GetSignalTauSF(*tau,
false,
true,
"tau125_medium1_tracktwo")
 
 1218                           << 
", totSF = "  << objTool.
GetSignalTauSF(*tau,
true,
true,
"tau125_medium1_tracktwo")
 
 1229       int jet_idx[
nSel] = {0};
 
 1232         for (
const auto& 
jet : *goodJets) {
 
 1233           if ( ST::acc_bad(*
jet) == 1 )
 
 1235           if ( ST::acc_passOR(*
jet) == 0 ) {
 
 1239           if ( ST::acc_baseline(*
jet) == 1 ) {
 
 1241             if ( 
jet->pt() > 50000. )
 
 1244           if ( ST::acc_bjet(*
jet) == 1 )
 
 1254           if (isNominal) {btagSF = btagSF_nominal = objTool.
BtagSF(
jets);}
 
 1255           else if (syst_affectsBTag || (sysInfo.affectsKinematics && syst_affectsJets)) {btagSF = objTool.
BtagSF(
jets);}
 
 1256           else {btagSF = btagSF_nominal;}
 
 1258         event_weight *= btagSF;
 
 1261         if ( 
stream.find(
"SUSY1")!=std::string::npos ) { 
 
 1262           float btagSF_trkJet(1.);
 
 1264             if (isNominal) {btagSF_trkJet = btagSF_trkJet_nominal = objTool.
BtagSF_trkJet(trkjets);}
 
 1265             else if (syst_affectsBTag || (sysInfo.affectsKinematics && syst_affectsJets)) {btagSF_trkJet = objTool.
BtagSF_trkJet(trkjets);}
 
 1266             else {btagSF_trkJet = btagSF_trkJet_nominal;}
 
 1268           event_weight *= btagSF_trkJet;
 
 1277         elcuts[isys][icut] += 1;
 
 1278         mucuts[isys][icut] += 1;
 
 1283           bool passel = el_idx[
baseline] == 1;
 
 1284           bool passmu = mu_idx[
baseline] == 1;
 
 1285           if (passel) elcuts[isys][icut] += 1;
 
 1286           if (passmu) mucuts[isys][icut] += 1;
 
 1291           if (passel) elcuts[isys][icut] += 1;
 
 1292           if (passmu) mucuts[isys][icut] += 1;
 
 1295           passel = el_idx[
goodpt] == 1;
 
 1296           passmu = mu_idx[
goodpt] == 1;
 
 1297           if (passel) elcuts[isys][icut] += 1;
 
 1298           if (passmu) mucuts[isys][icut] += 1;
 
 1303           if (passel) elcuts[isys][icut] += 1;
 
 1304           if (passmu) mucuts[isys][icut] += 1;
 
 1307           if (jet_idx[
goodpt] >= 2) {
 
 1308             if (passel) elcuts[isys][icut] += 1;
 
 1309             if (passmu) mucuts[isys][icut] += 1;
 
 1319       if (sysInfo.affectsKinematics) {
 
 1327       ANA_MSG_DEBUG(
">>>> Finished with variation: \"" <<(
sys.name()).c_str() << 
"\" <<<<<<" );
 
 1347             "===>>>  done processing event #%i, " 
 1348             "run #%i %i events processed so far  <<<===",
 
 1351             static_cast< int >( 
entry + 1 ) );
 
 1365         "Time per event:          (CPU / WALL)\n" 
 1366         "  Entire loop           - %f / %f ms\n" 
 1367         "  First event           - %f / %f ms\n" 
 1368         "  Excluding first event - %f / %f ms",
 
 1370         m_clock1.CpuTime() * 1
e3, m_clock1.RealTime() * 1
e3,
 
 1371         m_clock2.CpuTime() * 1
e3 / (
entries - 1), m_clock2.RealTime() * 1
e3 / (
entries - 1));
 
 1376   for (
const auto& sysInfo : systInfoList) {
 
 1378     ANA_MSG_INFO( 
"-- Dummy Cutflow -- >>>> Variation " << 
sys.name().c_str() << 
" <<<<" );
 
 1379     for (
size_t icut = 0; icut < 
Ncuts; ++icut) {
 
 1381                     << 
"-> el: " << elcuts[isys][icut] << 
", mu: " << mucuts[isys][icut] );
 
 1393   std::vector<std::string> vtokens;
 
 1394   TObjArray* 
tokens = TString(std::move(
line)).Tokenize(delim); 
 
 1395   if(
tokens->GetEntriesFast()) {
 
 1397     TObjString* 
os = 
nullptr;
 
 1398     while ((
os=(TObjString*)iString())) {
 
 1399       vtokens.push_back( 
os->GetString().Data() );
 
 1410   std::map< std::string, std::string > 
containers;
 
 1411   std::unique_ptr< TTree > ctree( 
dynamic_cast<TTree*
>( 
f->Get(
"CollectionTree") ) );
 
 1412   TObjArray *blist = 
dynamic_cast<TObjArray*
>( ctree->GetListOfBranches() );
 
 1414   std::string 
result, bname;
 
 1415   for (
int ib=0; 
ib<blist->GetEntries(); ++
ib) {
 
 1416      TBranch *
b = 
dynamic_cast<TBranch*
>( blist->At(
ib) );
 
 1417      bname = 
b->GetName();
 
 1418      if (bname.find(
"Aux")==std::string::npos) 
continue;