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 ) {
281 ANA_CHECK( objTool.setBoolProperty(
"AutoconfigurePRWTool",
true) );
282 if ( commonPRWFile == 1 )
283 ANA_CHECK( objTool.setBoolProperty(
"PRWUseCommonMCFiles",
true) );
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) );
324 int ishower = objTool.getMCShowerType(
"PhPy8EG",
"GN2v01");
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;
386 if (
slices[
"tau"] && !isData) {
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);
420 systInfoList = objTool.getSystInfoList();
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);
438 if (objTool.resetSystematics() != StatusCode::SUCCESS) {
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" ); }
521 ANA_CHECK( objTool.ApplyLRTUncertainty());
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){
582 if (objTool.GetPrimVtx() ==
nullptr) {
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) <<
" , "
649 <<
"IsHighPt(only) = " << (
int)objTool.IsHighPtMuon(*
muon) );
657 ANA_CHECK( objTool.GetJets(jets_nominal, jets_nominal_aux,
true, isPHYSLite?
"AnalysisJets":
"") );
663 if (
slices[
"tjet"] && hasTrkJets) {
666 ANA_CHECK(objTool.GetTrackJets(trkjets_nominal, trkjets_nominal_aux));
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 );
679 ANA_CHECK( objTool.GetFatJets(fatjets_nominal, fatjets_nominal_aux,
true,
"",
true) );
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") );
700 bool passMETtrig = objTool.IsMETTrigPassed();
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.);
720 float RW_sh22 = objTool.getSherpaVjetsNjetsWeight(
"AntiKt4TruthWZDressedJets");
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++) {
765 bool passed = objTool.IsTrigPassed(trigItem[
it]);
766 float prescale = objTool.GetTrigPrescale(trigItem[
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;
805 if (objTool.applySystematicVariation(
sys) != StatusCode::SUCCESS) {
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) {
864 ANA_CHECK( objTool.GetTrackJets(trkjets_syst, trkjets_syst_aux) );
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) {
933 objTool.IsBJet( *
jet) ;
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))) {
956 else if(
stream.find(
"SUSY10")!=std::string::npos) {
ANA_CHECK( objTool.OverlapRemoval(
electrons, muons,
jets, 0, 0, fatjets_nominal) ); }
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) {
975 std::string
jetcoll = jets_nominal_aux->name();
984 if (objTool.treatAsYear()<2017 && !objTool.IsPFlowCrackVetoCleaning(
electrons, photons)) {
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){
998 ANA_CHECK( objTool.GetMETSig(*metcst, metsig_cst,
false,
false) );
1003 ANA_CHECK( objTool.GetMETSig(*mettst, metsig_tst,
true,
true) );
1009 ANA_CHECK( objTool.GetMETSig(*metcst, metsig_cst,
false,
false) );
1014 ANA_CHECK( objTool.GetMETSig(*mettst, metsig_tst,
true,
true) );
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){
1040 passTM |= (objTool.IsTrigPassed(
t) && objTool.IsTrigMatched(
el,
t));
1052 if (isNominal || syst_affectsElectrons) {
1053 if(!isData) elecSF = objTool.GetTotalElectronSF(*
electrons);
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){
1097 if (objTool.IsTrigPassed(
t))
ANA_MSG_DEBUG(
"Pass " <<
t <<
" : " << (
int)objTool.IsTrigMatched(
mu,
t));
1099 passTM |= (objTool.IsTrigPassed(
t) && objTool.IsTrigMatched(
mu,
t));
1106 std::vector<std::string> my_mu_trigs;
1108 if(objTool.treatAsYear()==2015)
1109 my_mu_trigs=muTrigs2015;
1110 else if(objTool.treatAsYear()==2016)
1111 my_mu_trigs=muTrigs2016;
1112 else if(objTool.treatAsYear()==2017 || objTool.treatAsYear()==2018)
1113 my_mu_trigs=muTrigs2017;
1115 my_mu_trigs=muTrigs2022;
1118 my_mu_trigs=muTrigs2016;
1120 for (
auto&
t : my_mu_trigs) passTMtest |= (objTool.IsTrigPassed(
t) && objTool.IsTrigMatched(
mu,
t));
1130 int n_SignalPhotons = 0;
1131 for (
const auto&
y : *photons) {
1132 if ( ST::acc_passOR(*
y) && ST::acc_signal(*
y)) {
1135 <<
", idSF = " << objTool.GetSignalPhotonSF(*
y,
true,
false,
false)
1136 <<
", isoSF = " << objTool.GetSignalPhotonSF(*
y,
false,
true,
false)
1137 <<
", trigSF = " << objTool.GetSignalPhotonSF(*
y,
false,
false,
true)
1141 if(n_SignalPhotons>0)
ANA_MSG_DEBUG(
"Total Event photon SF = " << objTool.GetTotalPhotonSF(*photons,
true,
true,
true));
1146 bool comb_trig_check =
false;
1148 if (
slices[
"ele"] &&
slices[
"mu"] && comb_trig_check) {
1150 if (objTool.IsTrigPassed(
"HLT_2e12_lhloose_L12EM10VH"))
1151 ANA_MSG_DEBUG(
" 2e12_lhloose_L12EM10VH SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal,
"diLepton"));
1152 if (objTool.IsTrigPassed(
"HLT_e17_lhloose_mu14"))
1153 ANA_MSG_DEBUG(
"e17_lhloose_mu14 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal,
"diLepton") );
1154 if (objTool.IsTrigPassed(
"HLT_2e17_lhvloose_nod0"))
1155 ANA_MSG_DEBUG(
" 2e17_lhvloose_nod0 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal,
"diLepton") );
1156 if (objTool.IsTrigPassed(
"HLT_2e17_lhvloose_nod0_L12EM15VHI"))
1157 ANA_MSG_DEBUG(
" 2e17_lhvloose_nod0_L12EM15VHI SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal,
"diLepton") );
1158 if (objTool.IsTrigPassed(
"HLT_e17_lhloose_nod0_mu14"))
1159 ANA_MSG_DEBUG(
" e17_lhloose_nod0_mu14 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal,
"diLepton") );
1160 if (objTool.IsTrigPassed(
"HLT_e7_lhmedium_mu24"))
1161 ANA_MSG_DEBUG(
" e7_lhmedium_mu24 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal,
"diLepton") );
1162 if (objTool.IsTrigPassed(
"HLT_e7_lhmedium_nod0_mu24"))
1163 ANA_MSG_DEBUG(
" e7_lhmedium_nod0_mu24 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal,
"diLepton") );
1164 if (objTool.IsTrigPassed(
"HLT_mu18_mu8noL1"))
1165 ANA_MSG_DEBUG(
" mu18_mu8noL1 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal,
"diLepton") );
1166 if (objTool.IsTrigPassed(
"HLT_mu20_mu8noL1"))
1167 ANA_MSG_DEBUG(
" mu20_mu8noL1 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal,
"diLepton") );
1168 if (objTool.IsTrigPassed(
"HLT_2mu10"))
1169 ANA_MSG_DEBUG(
" 2mu10 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal,
"diLepton") );
1170 if (objTool.IsTrigPassed(
"HLT_2mu14"))
1171 ANA_MSG_DEBUG(
" 2mu14 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal,
"diLepton") );
1172 if (objTool.IsTrigPassed(
"HLT_2e12_lhloose_mu10"))
1173 ANA_MSG_DEBUG(
" 2e12_lhloose_mu10 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal,
"multiLepton") );
1174 if (objTool.IsTrigPassed(
"HLT_2e12_lhloose_nod0_mu10"))
1175 ANA_MSG_DEBUG(
" 2e12_lhloose_nod0_mu10 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal,
"multiLepton") );
1176 if (objTool.IsTrigPassed(
"HLT_e12_lhloose_2mu10"))
1177 ANA_MSG_DEBUG(
" e12_lhloose_2mu10 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal,
"multiLepton") );
1178 if (objTool.IsTrigPassed(
"HLT_e12_lhloose_nod0_2mu10"))
1179 ANA_MSG_DEBUG(
" e12_lhloose_nod0_2mu10 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal,
"multiLepton") );
1180 if (objTool.IsTrigPassed(
"HLT_3mu6"))
1181 ANA_MSG_DEBUG(
" 3mu6 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal,
"multiLepton") );
1184 if (
slices[
"mu"] && ((!isData && isNominal) || syst_affectsMuons)) {
1186 if(passTMtest || 1){
1187 ANA_MSG_DEBUG(
"MUON BEFORE SF = " << muonSF <<
" " << objTool.treatAsYear() <<
" " << objTool.GetRandomRunNumber() <<
" " << objTool.GetPileupWeight() );
1188 if(objTool.treatAsYear()==2015) muonSF = objTool.GetTotalMuonSF(*muons,
true,
true, muTrig2015.Data());
1189 else if(objTool.treatAsYear()==2016) muonSF = objTool.GetTotalMuonSF(*muons,
true,
true, muTrig2016.Data());
1190 else if(objTool.treatAsYear()==2017) muonSF = objTool.GetTotalMuonSF(*muons,
true,
true, muTrig2017.Data());
1191 else if(objTool.treatAsYear()==2018) muonSF = objTool.GetTotalMuonSF(*muons,
true,
true, muTrig2017.Data());
1192 else if(objTool.treatAsYear()==2022) muonSF = objTool.GetTotalMuonSF(*muons,
true,
true, muTrig2022.Data());
1193 ANA_MSG_DEBUG(
"MUON AFTER SF = " << muonSF <<
" " << objTool.treatAsYear() <<
" " << objTool.GetRandomRunNumber() <<
" " << objTool.GetPileupWeight() );
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")
1224 ANA_MSG_INFO(
"Total Event Tau SF = " << objTool.GetTotalTauSF(*taus,
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] );