ATLAS Offline Software
Namespaces | Enumerations | Functions | Variables
SUSYToolsTester.cxx File Reference
#include <cstdlib>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <regex>
#include <string>
#include <utility>
#include <vector>
#include <TEnv.h>
#include <TFile.h>
#include <TTree.h>
#include <TBranch.h>
#include <TError.h>
#include <TString.h>
#include <TStopwatch.h>
#include <TSystem.h>
#include "TObjArray.h"
#include "TObjString.h"
#include "xAODRootAccess/Init.h"
#include "xAODRootAccess/TStore.h"
#include "POOLRootAccess/TEvent.h"
#include "xAODEventInfo/EventInfo.h"
#include "xAODMuon/MuonContainer.h"
#include "xAODEgamma/ElectronContainer.h"
#include "xAODEgamma/PhotonContainer.h"
#include "xAODTau/TauJetContainer.h"
#include "xAODTruth/TruthParticleAuxContainer.h"
#include "xAODJet/JetContainer.h"
#include "xAODJet/JetAuxContainer.h"
#include "xAODCaloEvent/CaloCluster.h"
#include "xAODTruth/TruthParticleContainer.h"
#include "xAODTruth/TruthEventContainer.h"
#include "xAODTruth/TruthEvent.h"
#include "xAODCore/ShallowCopy.h"
#include "xAODMissingET/MissingETContainer.h"
#include "xAODMissingET/MissingETAuxContainer.h"
#include "xAODBase/IParticleHelpers.h"
#include "xAODTruth/xAODTruthHelpers.h"
#include "AsgAnalysisInterfaces/IGoodRunsListSelectionTool.h"
#include "TauAnalysisTools/ITauTruthMatchingTool.h"
#include "SUSYTools/SUSYObjDef_xAOD.h"
#include "SUSYTools/SUSYCrossSection.h"
#include "PATInterfaces/SystematicSet.h"
#include "AsgMessaging/StatusCode.h"
#include "AsgMessaging/MessageCheck.h"
#include "PATInterfaces/CorrectionCode.h"
#include "PathResolver/PathResolver.h"
#include "AsgTools/ToolStore.h"
#include "AsgTools/ToolHandle.h"
#include "AsgTools/StandaloneToolHandle.h"
#include "AsgTools/IAsgTool.h"
#include "xAODCutFlow/CutBookkeeper.h"
#include "xAODCutFlow/CutBookkeeperContainer.h"
#include "TrigDecisionTool/ChainGroup.h"

Go to the source code of this file.

Namespaces

 asg
 

Enumerations

enum  sel {
  signallep, baseline, bad, cosmic,
  goodpt, btagged, trgmatch, passOR
}
 

Functions

 asg::ANA_MSG_HEADER (msgSTT) ANA_MSG_SOURCE(msgSTT
 
std::vector< std::string > getTokens (TString line, const TString &delim)
 
std::map< std::string, std::string > getFileContainers (std::unique_ptr< TFile > &)
 
int main (int argc, char *argv[])
 

Variables

const size_t Ncuts = 10
 
const char * cut_name []
 
const unsigned int nSel =8
 

Enumeration Type Documentation

◆ sel

enum sel
Enumerator
signallep 
baseline 
bad 
cosmic 
goodpt 
btagged 
trgmatch 
passOR 

Definition at line 97 of file SUSYToolsTester.cxx.

97  {
98  signallep,
99  baseline,
100  bad,
101  cosmic,
102  goodpt,
103  btagged,
104  trgmatch,
105  passOR
106 };

Function Documentation

◆ getFileContainers()

std::map< std::string, std::string > getFileContainers ( std::unique_ptr< TFile > &  f)

Definition at line 1412 of file SUSYToolsTester.cxx.

1412  {
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() );
1416  std::smatch match;
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;
1422  //
1423  if (std::regex_search(bname, match, std::regex("(.*)Aux\\..*")) && match.size() > 1) { result = match.str(1); } // static
1424  else if (std::regex_search(bname, match, std::regex("(.*)AuxDyn\\..*")) && match.size() > 1) { result = match.str(1); } // dynamic
1425  //
1426  if ((!result.empty()) && (containers.find(result)==containers.end()) && (ctree->GetBranch(result.c_str()))) {
1427  containers[result] = ctree->GetBranch(result.c_str())->GetClassName();
1428  }
1429  result = "";
1430  }
1431  return containers;
1432 }

◆ getTokens()

std::vector< std::string > getTokens ( TString  line,
const TString &  delim 
)

Definition at line 1395 of file SUSYToolsTester.cxx.

1395  {
1396  std::vector<std::string> vtokens;
1397  TObjArray* tokens = TString(std::move(line)).Tokenize(delim); //delimiters
1398  if(tokens->GetEntriesFast()) {
1399  TIter iString(tokens);
1400  TObjString* os = nullptr;
1401  while ((os=(TObjString*)iString())) {
1402  vtokens.push_back( os->GetString().Data() );
1403  }
1404  }
1405  delete tokens;
1406 
1407  return vtokens;
1408 }

◆ main()

int main ( int  argc,
char *  argv[] 
)

READ CONFIG ---------—

Definition at line 115 of file SUSYToolsTester.cxx.

115  {
116 
117  using namespace asg::msgSTT;
118  ANA_CHECK_SET_TYPE (int);
119  setMsgLevel(MSG::INFO);
120 
122 
123  // The application's name:
124  const char* APP_NAME = argv[ 0 ];
125 
126  // Check if we received a file name:
127  if ( argc < 2 ) {
128  ANA_MSG_ERROR( "No file name received!" );
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]" );
130  return 1;
131  }
132 
133 
135 
136  int autoconfigPRW = 1;
137  int commonPRWFile = 1;
138  int isData = -1;
139  int isAtlfast = -1;
140  int NoSyst = 1;
141  int debug = 1;
142  bool isPHYSLite = false;
143  bool hasLRT = false;
144  Long64_t entries=-1;
145 
146  // Open the input file:
147  TString fileName = argv[1];
148  ANA_MSG_INFO( "Opening file: " << fileName );
149  std::unique_ptr< TFile > ifile( TFile::Open( fileName, "READ" ) );
150  ANA_CHECK( ifile.get() );
151 
152  bool isRun3 = false;
153  if ((fileName.Contains("mc23") || fileName.Contains("mc21") || fileName.Contains("data2")) && fileName.Contains("13p6TeV")) isRun3 = true;
154  std::string config_file = (PathResolverFindCalibFile("SUSYTools/SUSYTools_Default.conf")).c_str();
155  if (fileName.Contains("LITE")) config_file = (PathResolverFindCalibFile("SUSYTools/SUSYTools_Default_LITE.conf")).c_str();
156  if (isRun3) {
157  config_file = (PathResolverFindCalibFile("SUSYTools/SUSYTools_Default_Run3.conf")).c_str();
158  if (fileName.Contains("LITE")) config_file = (PathResolverFindCalibFile("SUSYTools/SUSYTools_Default_Run3_LITE.conf")).c_str();
159  ANA_MSG_INFO("Configuring for Run 3");
160  }
161  std::string prw_file = "DUMMY";
162  std::string ilumicalc_file = "DUMMY";
163 
164  for (int i = 1 ; i < argc ; i++) {
165  const char* key = strtok(argv[i], "=") ;
166  const char* val = strtok(0, " ") ;
167 
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);
174  if (strcmp(key, "Debug") == 0) debug = atoi(val);
175  if (strcmp(key, "ConfigFile") == 0) config_file = (PathResolverFindCalibFile(val)).c_str();
176  if (strcmp(key, "PRWFile") == 0) prw_file = std::string(val);
177  if (strcmp(key, "ilumicalcFile") == 0) ilumicalc_file = std::string(val);
178  if (strcmp(key, "maxEvents") == 0) entries = atoi(val);
179 
180  }
181 
182  if (debug>0) setMsgLevel((MSG::Level)(3-debug)); // NIL=0, VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL, ALWAYS
183 
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]");
187  return 10;
188  }
190 
191 
192  // Open file and check available containers
193  std::map<std::string, std::string> containers = getFileContainers(ifile);
194  bool hasTrkJets(false), hasFatJets(false);
195  for (auto& x : containers) {
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;
201  }
202  if (debug>0) {
203  ANA_MSG_INFO("Checking file contents (containers):");
204  for (auto& x : containers) ANA_MSG_INFO(" - found " << x.first.c_str() << " (" << x.second.c_str() << ")");
205  ANA_MSG_INFO("hasTrkJets: " << (hasTrkJets?"true":"false"));
206  ANA_MSG_INFO("hasFatJets: " << (hasFatJets?"true":"false"));
207  ANA_MSG_INFO("isPHYSLite: " << (isPHYSLite?"true":"false"));
208  ANA_MSG_INFO("hasLRT : " << (hasLRT?"true":"false"));
209  }
210 
211  // Create a TEvent object:
212 
214  ANA_CHECK( event.readFrom( ifile.get() ) );
215  ANA_MSG_INFO( "Number of events in the file: " << static_cast< int >( event.getEntries() ) );
216 
218 
219  // Open up an output file. Not needed for this example. If you wish to enable
220  // this, please don't forget to add the call to fill towards the end of the code!
221  //std::unique_ptr< TFile > ofile( TFile::Open( "out.root", "RECREATE" ) );
222  //ANA_CHECK( event.writeTo( ofile.get() ) );
223 
224  // If we haven't set the number of events, then run over the whole tree
225  if (entries<0){
226  entries = event.getEntries();
227  }
228 
229  // GRL tool
231  if (isData) {
232  m_grl.setTypeAndName("GoodRunsListSelectionTool/grl");
233  std::vector<std::string> myGRLs;
234 
235  myGRLs.push_back(PathResolverFindCalibFile("GoodRunsLists/data15_13TeV/20170619/physics_25ns_21.0.19.xml"));
236  myGRLs.push_back(PathResolverFindCalibFile("GoodRunsLists/data16_13TeV/20180129/physics_25ns_21.0.19.xml"));
237  myGRLs.push_back(PathResolverFindCalibFile("GoodRunsLists/data17_13TeV/20180619/physics_25ns_Triggerno17e33prim.xml"));
238  myGRLs.push_back(PathResolverFindCalibFile("GoodRunsLists/data18_13TeV/20190219/physics_25ns_Triggerno17e33prim.xml"));
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"));
241  //myGRLs.push_back(PathResolverFindCalibFile("GoodRunsLists/data22_13p6TeV/20230116/data22_13p6TeV.periodAllYear_DetStatus-v109-pro28-04_MERGED_PHYS_StandardGRL_All_Good_25ns_ignore_TRIGMUO_TRIGLAR.xml"));
242  ANA_CHECK( m_grl.setProperty("GoodRunsListVec", myGRLs) );
243  ANA_CHECK( m_grl.setProperty("PassThrough", false) );
244  ANA_CHECK( m_grl.retrieve() );
245 
246  ANA_MSG_INFO( "GRL tool retrieve & initialized... " );
247  }
248 
249  //xsec DB
250  SUSY::CrossSectionDB *my_XsecDB = nullptr;
251  if (!isData){
253  if (isRun3 && fileName.Contains("mc21")) { my_XsecDB = new SUSY::CrossSectionDB(PathResolverFindCalibFile("dev/PMGTools/PMGxsecDB_mc21.txt"));}
254  else if (isRun3 && fileName.Contains("mc23")) { my_XsecDB = new SUSY::CrossSectionDB(PathResolverFindCalibFile("dev/PMGTools/PMGxsecDB_mc23.txt"));}
255  else { my_XsecDB = new SUSY::CrossSectionDB(PathResolverFindCalibFile("dev/PMGTools/PMGxsecDB_mc16.txt"));}
256  ANA_MSG_INFO( "xsec DB initialized" );
257  }
258 
259  // Create the tool(s) to test:
260  ST::SUSYObjDef_xAOD objTool("SUSYObjDef_xAOD");
261 
262  ANA_MSG_INFO(" ABOUT TO INITIALIZE SUSYTOOLS " );
263 
265  // Configure the SUSYObjDef instance
266 
267  ANA_CHECK( objTool.setProperty("DataSource", datasource) ) ;
268  if(!config_file.empty())
269  ANA_CHECK( objTool.setProperty("ConfigFile", config_file) );
270 
277 
278  std::vector<std::string> prw_conf;
279  if (!isData) {
280  if ( autoconfigPRW == 1 ) {
281  ANA_CHECK( objTool.setBoolProperty("AutoconfigurePRWTool", true) );
282  if ( commonPRWFile == 1 )
283  ANA_CHECK( objTool.setBoolProperty("PRWUseCommonMCFiles", true) );
284  } else {
285  if (prw_file == "DUMMY") {
286  prw_conf.push_back("dev/SUSYTools/merged_prw_mc16a_latest.root");
287  } else {
288  prw_conf = getTokens(prw_file,",");
289  }
290  ANA_CHECK( objTool.setProperty("PRWConfigFiles", prw_conf) );
291  }
292  }
293 
310 
311 
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"));
316  } else {
317  prw_lumicalc = getTokens(ilumicalc_file,",");
318  }
319  ANA_CHECK( objTool.setProperty("PRWLumiCalcFiles", prw_lumicalc) );
320 
321  // ============================================================================================
322  // Guess shower type for btagging MC/MC SFs
323  if(!isData){
324  int ishower = objTool.getMCShowerType("PhPy8EG","GN2v01"); //get your sample name here!
325  ANA_CHECK( objTool.setProperty("ShowerType", (int)ishower) );
326  }
327 
329  // ANA_CHECK( objTool.setBoolProperty("EleForceNoId", false) );
330  // ANA_CHECK( objTool.setBoolProperty("MuForceNoId", false) );
332 
333  ANA_CHECK(objTool.setProperty("OutputLevel", msg().level() ));
334  ANA_CHECK(objTool.setBoolProperty("DebugMode", (debug>1))); // debug=0:INFO,1:DEBUG->0, debug=2:VERBOSE->1
335 
336  if ( objTool.initialize() != StatusCode::SUCCESS) {
337  ANA_MSG_ERROR( "Cannot initialize SUSYObjDef_xAOD, exiting." );
338  return 1;
339  } else {
340  ANA_MSG_INFO( "SUSYObjDef_xAOD initialized..." );
341  }
342 
343  ANA_MSG_INFO( "Initialized SUSYTools" );
344 
345  // ============================================================================================
346  // Configuration
347  TEnv rEnv;
348  if ( rEnv.ReadFile(config_file.c_str(), kEnvAll) != 0 ) {
349  ANA_MSG_ERROR( "Cannot open config file, exiting.");
350  return 1;
351  }
352  ANA_MSG_INFO( "Config file opened" );
353 
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");
360  // Trim comments and extra spaces from config entries
361  std::regex comment("#.*$");
362  std::regex trimspaces("^ +| +$|( ) +");
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]);
367  }
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 = "";
371 
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));
382  for (auto& x : slices) { ANA_MSG_DEBUG( "Slice " << x.first << ": " << ((x.second)?"true":"false")); }
383 
384  // ============================================================================================
385  ToolHandle<TauAnalysisTools::ITauTruthMatchingTool> T2MT = 0;
386  if (slices["tau"] && !isData) {
387  // borrow the T2MT from SUSYTools
388  T2MT = asg::ToolStore::get<TauAnalysisTools::ITauTruthMatchingTool>("ToolSvc.TauTruthMatch");
389  ANA_CHECK(T2MT.retrieve());
390  }
391 
392  // ============================================================================================
393  // Triggers from https://twiki.cern.ch/twiki/bin/view/Atlas/LowestUnprescaled
394  std::vector<std::string> el_triggers,mu_triggers,ph_triggers,tau_triggers,emu_triggers;
395  if (isRun3){
396  el_triggers = {"HLT_e26_lhtight_ivarloose_L1EM22VHI","HLT_e26_lhtight_ivarloose_L1eEM26M","HLT_e60_lhmedium_L1EM22VHI", "HLT_e140_lhloose_L1EM22VHI"};//,"HLT_e300_etcut_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"};
401  }
402  else
403  {
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"};
409  }
410  // ============================================================================================
411  // Systematics and counts
412  std::vector<ST::SystInfo> systInfoList;
413  if (NoSyst) {
414  ST::SystInfo infodef;
415  infodef.affectsKinematics = false;
416  infodef.affectsWeights = false;
417  infodef.affectsType = ST::Unknown;
418  systInfoList.push_back(infodef);
419  } else {
420  systInfoList = objTool.getSystInfoList();
421  }
422 
423  size_t isys = 0;
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);
433  }
434  elcuts.push_back(elcutsCurrentSyst);
435  mucuts.push_back(elcutsCurrentSyst);
436  }
437 
438  if (objTool.resetSystematics() != StatusCode::SUCCESS) {
439  Error(APP_NAME, "Cannot reset SUSYTools systematics" );
440  exit(-2);
441  }
442 
443  // ===============================================================================================
444  // Event Loop
445  TStopwatch m_clock0;
446  m_clock0.Start();
447  TStopwatch m_clock1;
448  m_clock1.Start();
449  TStopwatch m_clock2;
450 
451  int period = (debug>0) ? 1 : 100;
452  std::string cbkname, stream, ostream, kernel;
453 
454  // Loop over the events:
455  for ( Long64_t entry = 0; entry < entries; ++entry ) {
456 
457  if (entry == 1) {
458  m_clock1.Stop();
459  m_clock2.Start();
460  // CALLGRIND_TOGGLE_COLLECT;
461  // ProfilerStart("gperftools.profile.out");
462  }
463 
464 
465  // Tell the object which entry to look at:
466  event.getEntry( entry );
467 
468  if(entry == 0){
469  // Read the CutBookkeeper container
470  const xAOD::CutBookkeeperContainer* completeCBC = nullptr;
471  if (!event.retrieveMetaInput(completeCBC, "CutBookkeepers").isSuccess()) {
472  ANA_MSG_ERROR("Failed to retrieve CutBookkeepers from MetaData, exiting.");
473  return 1;
474  }
475 
476  // Let's find the right CBK (latest with StreamAOD input before derivations)
477  const xAOD::CutBookkeeper* allEventsCBK = nullptr;
478  int maxcycle=-1;
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,"");
490  else kernel="other";
491  if (cbkname.find("AllExecutedEvents")!=std::string::npos && ostream.find("StreamAOD")!=std::string::npos && cbk->cycle() > maxcycle) {
492  maxcycle = cbk->cycle();
493  allEventsCBK = cbk;
494  }
495  }
496 
497  if (allEventsCBK) {
498  uint64_t nEventsProcessed = allEventsCBK->nAcceptedEvents();
499  double sumOfWeights = allEventsCBK->sumOfEventWeights();
500  double sumOfWeightsSquared = allEventsCBK->sumOfEventWeightsSquared();
501  ANA_MSG_INFO( "CutBookkeepers Accepted " << nEventsProcessed << " SumWei " << sumOfWeights << " sumWei2 " << sumOfWeightsSquared);
502  } else { ANA_MSG_INFO( "No relevent CutBookKeepers found" ); }
503 
504  ANA_MSG_INFO("Found kernel: " << kernel);
505  ANA_MSG_INFO("Found stream: " << stream);
506 
507  // No special jets when running on PHYSLITE
508  if (isPHYSLite) {
509  hasTrkJets = false;
510  }
511  }
512 
513  // Only need to PRW if we aren't running on PHYSLITE
514  if (!isPHYSLite) {
515  ANA_CHECK( objTool.ApplyPRWTool());
516  }
517 
518  // Only need LRT uncertainty tool if there are LRT tracks!
519  if (hasLRT) {
520  ANA_MSG_DEBUG( "Applying LRT uncertainty decorations" );
521  ANA_CHECK( objTool.ApplyLRTUncertainty());
522  }
523 
524  // ============================================================================================
525  // Print some event information for fun:
526  const xAOD::EventInfo* ei = nullptr;
527  ANA_CHECK( event.retrieve( ei, "EventInfo" ) );
528 
529  if (entry==0 || entry % period == 999) {
530  ANA_MSG_INFO( "===>>> start processing event #, " << static_cast< int >( ei->eventNumber() ) <<
531  "run #" << static_cast< int >( ei->runNumber() ) << " " << static_cast< int >( entry ) << " events processed so far <<<===");
532  }
533 
534  if (!isData && entry % period == 0) {
535  float xsectTimesEff = my_XsecDB->xsectTimesEff(ei->mcChannelNumber());
536  ANA_MSG_INFO( "===>>> process cross section " << xsectTimesEff );
537  }
538 
539  bool eventPassesGRL(true);
540  bool eventPassesCleaning(true);
541  bool eventPassesTileTrip(true); // move to xAOD tool!
542  bool eventPassesTrigger(true); // coming soon!
543 
544  if (!isData){
545  static const SG::ConstAccessor<float> pileupWeightAcc("PileupWeight_NOSYS");
546  float PRW_weight = isPHYSLite? pileupWeightAcc(*ei): objTool.GetPileupWeight();
547  ANA_MSG_DEBUG( "PRW Weight = " << PRW_weight);
548  }
549 
550  if (isData) {
551  eventPassesGRL = m_grl->passRunLB(ei->runNumber(), ei->lumiBlock());
552 
553  eventPassesCleaning = !((ei->errorState(xAOD::EventInfo::LAr) == xAOD::EventInfo::Error ) ||
557  }
558  else {
559  // Check SUSY Proc. ID for signal MC (only for first event for now!)
560  if(entry<5){
561  int pdgid1 = 0;
562  int pdgid2 = 0;
563 
564  if( objTool.FindSusyHP(pdgid1, pdgid2) != StatusCode::SUCCESS ){
565  ANA_MSG_WARNING( "SUSY Proc finding failed. Normal for non-SUSY samples." );
566  }
567 
568  if( pdgid1!=0 && pdgid2!=0){ //(just to avoid warnings)
569  // --- Deprecated usage of procID
570  ANA_MSG_INFO( "--- SIGNAL ID1 : " << pdgid1 );
571  ANA_MSG_INFO( " SIGNAL ID2 : " << pdgid2 );
572  ANA_MSG_INFO( "--- XSECTION DETAILS" );
573  }
574  ANA_MSG_INFO( " Xsec (high order) " << my_XsecDB->xsectTimesEff(ei->mcChannelNumber(),0) );
575  ANA_MSG_INFO( " kfactor (high order) " << my_XsecDB->kfactor(ei->mcChannelNumber(),0) );
576  ANA_MSG_INFO( " filter efficiency " << my_XsecDB->efficiency(ei->mcChannelNumber(),0) );
577  }
578  }
579 
580 
581  //Check PV in the event
582  if (objTool.GetPrimVtx() == nullptr) {
583  Warning(APP_NAME , "No PV found for this event! Skipping...");
584  store.clear();
585  continue;
586  }
587 
588 
589  // ====================================================================================================
590  // Object containers - nominal
591  xAOD::ElectronContainer* electrons_nominal(nullptr);
592  xAOD::ShallowAuxContainer* electrons_nominal_aux(nullptr);
593  xAOD::PhotonContainer* photons_nominal(nullptr);
594  xAOD::ShallowAuxContainer* photons_nominal_aux(nullptr);
595  xAOD::MuonContainer* muons_nominal(nullptr);
596  xAOD::ShallowAuxContainer* muons_nominal_aux(nullptr);
597  xAOD::JetContainer* jets_nominal(nullptr);
598  xAOD::ShallowAuxContainer* jets_nominal_aux(nullptr);
599  xAOD::JetContainer* trkjets_nominal(nullptr);
600  xAOD::ShallowAuxContainer* trkjets_nominal_aux(nullptr);
601  xAOD::JetContainer* fatjets_nominal(nullptr);
602  xAOD::ShallowAuxContainer* fatjets_nominal_aux(nullptr);
603  xAOD::TauJetContainer* taus_nominal(nullptr);
604  xAOD::ShallowAuxContainer* taus_nominal_aux(nullptr);
609 
610  // ====================================================================================================
611  // Get the nominal object containers from the event
612  // Electrons
613  if (slices["ele"]) {
614  ANA_MSG_DEBUG( "Nominal electron step" );
615  ANA_CHECK( objTool.GetElectrons(electrons_nominal, electrons_nominal_aux, true, isPHYSLite?"AnalysisElectrons":"Electrons") );
616  ANA_MSG_DEBUG( electrons_nominal->size() << " electrons");
617 
618  for (const auto& electron : *electrons_nominal){
619  if (debug>0 && entry<10) {
620  bool accepted=false;
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 " );
624  }
625  }
626  }
627 
628  // Photons
629  if( slices["pho"] && stream.find("SUSY12")==std::string::npos) {
630  ANA_MSG_DEBUG( "Nominal photon step" );
631  ANA_CHECK( objTool.GetPhotons(photons_nominal,photons_nominal_aux, true, isPHYSLite?"AnalysisPhotons":"Photons") );
632  ANA_MSG_DEBUG( photons_nominal->size() << " photons");
633  }
634 
635  // Muons
636  if (slices["mu"]) {
637  ANA_MSG_DEBUG( "Nominal muon step" );
638  ANA_CHECK( objTool.GetMuons(muons_nominal, muons_nominal_aux, true, isPHYSLite?"AnalysisMuons":"Muons") );
639  ANA_MSG_DEBUG( muons_nominal->size() << " muons");
640 
641  // check HighPt muons (if required)
642  for (const auto& muon : *muons_nominal){
643  if (debug>0 && entry<10){
644  ANA_MSG_DEBUG("--------------------------------------" );
645  ANA_MSG_DEBUG("Muon pt = " << muon->pt()*0.001 << " , "
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) );
650  }
651  }
652  }
653 
654  // Jets
655  if (slices["jet"]) {
656  ANA_MSG_DEBUG( "Nominal jet step" );
657  ANA_CHECK( objTool.GetJets(jets_nominal, jets_nominal_aux, true, isPHYSLite?"AnalysisJets":"") );
658  ANA_MSG_DEBUG( jets_nominal->size() << " jets");
659  }
660 
661  // TrackJets
662  const xAOD::JetContainer* TJC = nullptr;
663  if (slices["tjet"] && hasTrkJets) {
664  ANA_MSG_DEBUG( "Nominal track jet step" );
665  if( event.retrieve(TJC, TrkJetCollection).isSuccess() ){
666  ANA_CHECK(objTool.GetTrackJets(trkjets_nominal, trkjets_nominal_aux));
667  ANA_MSG_DEBUG( trkjets_nominal->size() << " track jets");
668  } else {
669  ANA_MSG_ERROR("TrackJet collection " << TrkJetCollection.c_str() << " not available in input file. Please check!");
670  return 1;
671  }
672  }
673 
674  // FatJets
675  const xAOD::JetContainer* FJC = nullptr;
676  if(slices["fjet"] && hasFatJets) { // stream.Contains("SUSY10") || stream.Contains("PHYSVAL")){
677  ANA_MSG_DEBUG( "Nominal fat jet step, collection: " << FatJetCollection );
678  if( event.retrieve(FJC, FatJetCollection).isSuccess() ){
679  ANA_CHECK( objTool.GetFatJets(fatjets_nominal, fatjets_nominal_aux, true, "", true) );
680  ANA_MSG_DEBUG( fatjets_nominal->size() << " large R jets");
681  if (debug>0 && entry < 10) {
682  for (const auto& fatjet : *fatjets_nominal) {
683  ANA_MSG_INFO( " FatJet pt = " << fatjet->pt()*0.001 << ", Wtag = " << ST::acc_wtagged(*fatjet) << ", Ztag = " << ST::acc_ztagged(*fatjet) );
684  }
685  }
686  } else {
687  ANA_MSG_ERROR("LargeR jet collection " << FatJetCollection.c_str() << " not available in input file. Please check!");
688  return 1;
689  }
690  }
691 
692  // Taus
693  if(slices["tau"]) {
694  ANA_MSG_DEBUG( "Nominal tau step" );
695  ANA_CHECK( objTool.GetTaus(taus_nominal,taus_nominal_aux, true, isPHYSLite?"AnalysisTauJets":"TauJets") );
696  ANA_MSG_DEBUG( taus_nominal->size() << " taus");
697  }
698 
699  // MET Trigger
700  bool passMETtrig = objTool.IsMETTrigPassed();
701  ANA_MSG_DEBUG( "Pass MET trigger " << passMETtrig);
702 
703  // MET
704  metcst_nominal->setStore(metcst_nominal_aux);
705  metcst_nominal->reserve(10);
706  double metsig_cst (0.);
707  mettst_nominal->setStore(mettst_nominal_aux);
708  mettst_nominal->reserve(10);
709  double metsig_tst (0.);
710 
711 
712  // ============================================================================================
713  // Set up the event weights
714  // Base should include all weights that do not depend on individual objects
715  double base_event_weight(1.);
716  if (!isData){
717  base_event_weight *= ei->mcEventWeight();
718  //Check for the new Sherpa 2.2 Reweighting function
719  if(debug>0 && entry < 5){
720  float RW_sh22 = objTool.getSherpaVjetsNjetsWeight("AntiKt4TruthWZDressedJets");
721  Info(APP_NAME , "--- SHERPA2.2 REWEIGHTING : %f", RW_sh22);
722  }
723  }
724 
725  // ============================================================================================
726  // Nominal weights
727  // Additionally define a nominal weight for each object type
728  double elecSF_nominal(1.);
729  double muonSF_nominal(1.);
730  //double tauSF_nominal(1.);
731  double btagSF_nominal(1.);
732  double btagSF_trkJet_nominal(1.);
733 
734  // ====================
735  bool isNominal(true);
736  isys = 0;
737  // Now loop over all the systematic variations
738  for (const auto& sysInfo : systInfoList) {
739  const CP::SystematicSet& sys = sysInfo.systset;
740  ANA_MSG_DEBUG(">>>> Working on variation: \"" <<(sys.name()).c_str() << "\" <<<<<<" );
741 
742  size_t icut = 0;
743  // log all events
744  elcuts[isys][icut] += 1;
745  mucuts[isys][icut] += 1;
746  ++icut;
747 
748  // does the event pass the GRL + Cleaning?
749  if (!(eventPassesGRL && eventPassesCleaning)) {++isys; continue;}
750  elcuts[isys][icut] += 1;
751  mucuts[isys][icut] += 1;
752  ++icut;
753 
754  // Apply TileTrip
755  if (!eventPassesTileTrip) {++isys; continue;}
756  elcuts[isys][icut] += 1;
757  mucuts[isys][icut] += 1;
758  ++icut;
759 
760  if (debug>0 && entry==0) {
761  // Testing trigger
762  std::vector<std::string> trigItem = {"HLT_e26_lhtight_nod0_ivarloose","HLT_mu26_ivarmedium","HLT_mu50","HLT_xe100","HLT_noalg_.*"}; // Trigger for Run 2
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_.*"}; // Trigger for Run 3
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 );
768  //
769  // example of more sophisticated trigger access
770  const Trig::ChainGroup* cg = objTool.GetTrigChainGroup(trigItem[it]);
771  bool cg_passed = cg->isPassed();
772  float cg_prescale = cg->getPrescale();
773  ANA_MSG_DEBUG( "ChainGroup " << trigItem[it].c_str() << ": passing trigger? " << (int)cg_passed << ", prescale " << cg_prescale );
774  for (const auto& cg_trig : cg->getListOfTriggers()) {
775  ANA_MSG_DEBUG("\t\t includes trigger " << cg_trig.c_str() );
776  }
777  }
778  }
779 
780  // Trigger (coming soon...)
781  if (!eventPassesTrigger) {++isys; continue;}
782  elcuts[isys][icut] += 1;
783  mucuts[isys][icut] += 1;
784  ++icut;
785 
786  // ====================================================================================================
787  // Object containers - systematics
788 
789  // Generic pointers for either nominal or systematics copy
790  xAOD::ElectronContainer* electrons(electrons_nominal);
791  xAOD::PhotonContainer* photons(photons_nominal);
792  xAOD::MuonContainer* muons(muons_nominal);
793  xAOD::JetContainer* jets(jets_nominal);
794  xAOD::JetContainer* trkjets(trkjets_nominal);
795  xAOD::TauJetContainer* taus(taus_nominal);
796  xAOD::MissingETContainer* metcst(metcst_nominal);
797  xAOD::MissingETContainer* mettst(mettst_nominal);
798  xAOD::MissingETAuxContainer* metcst_aux(metcst_nominal_aux);
799  xAOD::MissingETAuxContainer* mettst_aux(mettst_nominal_aux);
800 
802 
803 
804  // Tell the SUSYObjDef_xAOD which variation to apply
805  if (objTool.applySystematicVariation(sys) != StatusCode::SUCCESS) {
806  ANA_MSG_INFO( "Cannot configure SUSYTools for systematic var. " << (sys.name()).c_str() );
807  } else {
808  ANA_MSG_DEBUG( "Variation " << (sys.name()).c_str() << " configured...");
809  }
810  if (sysInfo.affectsKinematics || sysInfo.affectsWeights) isNominal = false;
811 
812  // If nominal, compute the nominal weight, otherwise recompute the weight
813  double event_weight = base_event_weight;
814 
815  // If necessary (kinematics affected), make a shallow copy with the variation applied
816  bool syst_affectsElectrons = ST::testAffectsObject(xAOD::Type::Electron, sysInfo.affectsType);
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);
822  //bool syst_affectsMET = ST::testAffectsObject(xAOD::Type::MissingET, sysInfo.affectsType);
823 
824 
825  if (sysInfo.affectsKinematics) {
826  if (slices["ele"] && syst_affectsElectrons) {
827  xAOD::ElectronContainer* electrons_syst(nullptr);
828  xAOD::ShallowAuxContainer* electrons_syst_aux(nullptr);
829  ANA_CHECK( objTool.GetElectrons(electrons_syst, electrons_syst_aux, true, isPHYSLite?"AnalysisElectrons":"Electrons") );
830  electrons = electrons_syst;
831  }
832 
833  if (slices["mu"] && syst_affectsMuons) {
834  xAOD::MuonContainer* muons_syst(nullptr);
835  xAOD::ShallowAuxContainer* muons_syst_aux(nullptr);
836  ANA_CHECK( objTool.GetMuons(muons_syst, muons_syst_aux, true, isPHYSLite?"AnalysisMuons":"Muons") );
837  muons = muons_syst;
838  }
839 
840  if(slices["tau"] && syst_affectsTaus) {
841  xAOD::TauJetContainer* taus_syst(nullptr);
842  xAOD::ShallowAuxContainer* taus_syst_aux(nullptr);
843  ANA_CHECK( objTool.GetTaus(taus_syst,taus_syst_aux, true, isPHYSLite?"AnalysisTauJets":"TauJets") );
844  taus = taus_syst;
845  }
846 
847  if(slices["pho"] && syst_affectsPhotons) {
848  xAOD::PhotonContainer* photons_syst(nullptr);
849  xAOD::ShallowAuxContainer* photons_syst_aux(nullptr);
850  ANA_CHECK( objTool.GetPhotons(photons_syst,photons_syst_aux, true, isPHYSLite?"AnalysisPhotons":"Photons") );
851  photons = photons_syst;
852  }
853 
854  if (slices["jet"] && syst_affectsJets) {
855  xAOD::JetContainer* jets_syst(nullptr);
856  xAOD::ShallowAuxContainer* jets_syst_aux(nullptr);
857  ANA_CHECK( objTool.GetJetsSyst(*jets_nominal, jets_syst, jets_syst_aux, true, isPHYSLite?"AnalysisJets":"") );
858  jets = jets_syst;
859  }
860 
861  if (slices["btag"] && syst_affectsBTag) {
862  xAOD::JetContainer* trkjets_syst(nullptr);
863  xAOD::ShallowAuxContainer* trkjets_syst_aux(nullptr);
864  ANA_CHECK( objTool.GetTrackJets(trkjets_syst, trkjets_syst_aux) );
865  trkjets = trkjets_syst;
866  }
867 
872  if (slices["met"]) {
873  metcst_syst->setStore(metcst_syst_aux);
874  mettst_syst->setStore(mettst_syst_aux);
875  metcst_nominal->reserve(10);
876  metcst_nominal->reserve(10);
877 
878  metcst = metcst_syst;
879  mettst = mettst_syst;
880  metcst_aux = metcst_syst_aux;
881  mettst_aux = mettst_syst_aux;
882  }
883  }
884 
885 
886  // *************** ************************ *****************
887  // *************** Now start processing the event *****************
888  // *************** ************************ *****************
889 
890  // Electrons
891  if (slices["ele"] && (isNominal || (sysInfo.affectsKinematics && syst_affectsElectrons))) {
892  for (const auto& el : *electrons) {
893  //objTool.IsSignalElectron( *el ) ; // TODO: check that this should be removed /CO
894 
895  if (!isData) {
897  if (truthEle) {
898  ANA_MSG_DEBUG( " Truth Electron pt " << truthEle->pt() << " eta " << truthEle->eta() );
899  ANA_MSG_DEBUG( " IsPrompt() = " << objTool.isPrompt(el) );
900  } else { ANA_MSG_DEBUG( " Truth Electron not found" ); }
901  }
902  }
903  }
904 
905  // Muons
906  if (slices["mu"] && (isNominal || (sysInfo.affectsKinematics && syst_affectsMuons))) {
907  for (const auto& mu : *muons) {
908  // TODO: check that these should be removed too /CO
909  //objTool.IsSignalMuon( *mu ) ;
910  //objTool.IsCosmicMuon( *mu ) ;
911 
912  if (!isData) {
913  // Example to access MC type/origin
914  int muonTruthType = 0;
915  int muonTruthOrigin = 0;
916  const xAOD::TrackParticle* trackParticle = mu->primaryTrackParticle();
917  if (trackParticle) {
918  if (ST::acc_truthType.isAvailable(*trackParticle)) muonTruthType = ST::acc_truthType(*trackParticle);
919  if (ST::acc_truthOrigin.isAvailable(*trackParticle)) muonTruthOrigin = ST::acc_truthOrigin(*trackParticle);
920  const xAOD::TruthParticle* truthMu = xAOD::TruthHelpers::getTruthParticle(*trackParticle);
921  if (truthMu) {
922  ANA_MSG_DEBUG( " Truth Muon pt " << truthMu->pt() << " eta " << truthMu->eta() );
923  ANA_MSG_DEBUG( " type " << muonTruthType << " origin " << muonTruthOrigin );
924  } else { ANA_MSG_DEBUG( "Truth Muon not found" ); }
925  }
926  }
927  }
928  }
929 
930  // Jets
931  if (slices["jet"] && (isNominal || (sysInfo.affectsKinematics && syst_affectsJets))) {
932  for (const auto& jet : *jets) {
933  objTool.IsBJet( *jet) ;
934  }
935  }
936 
937  // Taus
938  if (slices["tau"] && (isNominal || (sysInfo.affectsKinematics && syst_affectsTaus))) {
939  for(const auto& tau : *taus){
940  if (!isData){
941  const xAOD::TruthParticle* truthTau = T2MT->getTruth(*tau) ;
942  if (acc_IsTruthMatched(*tau) || !truthTau){
943  ANA_MSG_DEBUG("Tau was matched to a truth tau, which has "
944  << int(acc_TruthProng(*tau))
945  << " prongs and a charge of "
946  << acc_TruthCharge(*tau));
947  } else { ANA_MSG_DEBUG( "Tau was not matched to truth" ); }
948  }
949  }
950  }
951 
952  // Overlap Removal
953  ANA_MSG_DEBUG( "Overlap removal" );
954  if (isNominal || (sysInfo.affectsKinematics && (syst_affectsElectrons || syst_affectsMuons || syst_affectsJets))) {
955  if(stream.find("SUSY3")!=std::string::npos) { ANA_CHECK( objTool.OverlapRemoval(electrons, muons, jets, 0, taus) ); }
956  else if(stream.find("SUSY10")!=std::string::npos) { ANA_CHECK( objTool.OverlapRemoval(electrons, muons, jets, 0, 0, fatjets_nominal) ); }
957  else{ ANA_CHECK( objTool.OverlapRemoval(electrons, muons, jets, photons) ); }
958  }
959 
960  // Jets - get goodjets
961  if (slices["jet"]) {
963  ANA_MSG_DEBUG("GoodJets?");
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) ) {
969  goodJets->push_back(jet);
970  }
971  // PHYSLITE doesn't bother trying to keep JetInputType as a decoration
972  if (stream.compare("PHYSVAL")==0) jetInputType = jet->getInputType();
973  else if (stream.find("PHYS")!=std::string::npos) jetInputType = xAOD::JetInput::PFlow;
974  else if (stream.find("SUSY")!=std::string::npos) {
975  std::string jetcoll = jets_nominal_aux->name();
976  if (jetcoll.find("EMTopo")!=std::string::npos) jetInputType = xAOD::JetInput::EMTopo;
977  else if (jetcoll.find("EMPFlow")!=std::string::npos) jetInputType = xAOD::JetInput::PFlow;
978  }
979  }
980 
981  std::string jetCollection = xAOD::JetInput::typeName(jetInputType);
982  ANA_MSG_DEBUG ("xAOD::JetInputtypeName: " << jetCollection);
983  if (jetCollection == "EMPFlow") {
984  if (objTool.treatAsYear()<2017 && !objTool.IsPFlowCrackVetoCleaning(electrons, photons)) {
985  ANA_MSG_WARNING( "Event failed 2015+2016 IsPFlowCrackVetoCleaning(electrons, photons), skipping..." );
986  store.clear();
987  continue;
988  }
989  }
990  }
991 
992  if (slices["met"] && (isNominal || sysInfo.affectsKinematics)) {
993  ANA_MSG_DEBUG( "MET step" );
994  if(stream.find("SUSY3")!=std::string::npos){
995  if (debug>0) Info(APP_NAME, "METCST?");
996  ANA_CHECK( objTool.GetMET(*metcst, jets, electrons, muons, photons, taus, false, false) ); // CST=false, JVT=false (No JVT if you use CST)
997  if (debug>0) Info(APP_NAME, "METSignificance CST?");
998  ANA_CHECK( objTool.GetMETSig(*metcst, metsig_cst, false, false) );
999 
1000  if (debug>0) Info(APP_NAME, "METTST?");
1001  ANA_CHECK( objTool.GetMET(*mettst, jets, electrons, muons, photons, taus, true, true) );
1002  if (debug>0) Info(APP_NAME, "METSignificance TST?");
1003  ANA_CHECK( objTool.GetMETSig(*mettst, metsig_tst, true, true) );
1004  }
1005  else{
1006  if (debug>0) Info(APP_NAME, "METCST?");
1007  ANA_CHECK( objTool.GetMET(*metcst, jets, electrons, muons, photons, 0, false, false) ); // CST=false, JVT=false (No JVT if you use CST)
1008  if (debug>0) Info(APP_NAME, "METSignificance CST?");
1009  ANA_CHECK( objTool.GetMETSig(*metcst, metsig_cst, false, false) );
1010 
1011  if (debug>0) Info(APP_NAME, "METTST?");
1012  ANA_CHECK( objTool.GetMET(*mettst, jets, electrons, muons, photons, 0, true, true) );
1013  if (debug>0) Info(APP_NAME, "METSignificance TST?");
1014  ANA_CHECK( objTool.GetMETSig(*mettst, metsig_tst, true, true) );
1015  }
1016  if (debug>0) Info(APP_NAME, "MET done");
1017  }
1018 
1019  // ========================================
1020  // Electrons
1021  float elecSF = 1.0;
1022  int el_idx[nSel] = {0};
1023  if (slices["ele"]) {
1024  ANA_MSG_DEBUG( "Electron step - selection" );
1025  for (const auto& el : *electrons) {
1026  if ( ST::acc_passOR(*el) == 0 ) {
1027  el_idx[passOR]++;
1028  continue;
1029  }
1030  if ( ST::acc_baseline(*el) == 1 ) {
1031  el_idx[baseline]++;
1032  }
1033  if ( ST::acc_signal(*el) == 1 ) {
1034  el_idx[signallep]++;
1035  if ( el->pt() > 20000. ) {
1036  el_idx[goodpt]++;
1037 
1038  bool passTM=false;
1039  for(const auto& t : el_triggers){
1040  passTM |= (objTool.IsTrigPassed(t) && objTool.IsTrigMatched(el, t));
1041  }
1042  if(passTM)
1043  el_idx[trgmatch]++;
1044 
1045  //check ChID BDT
1046  // static const SG::ConstAccessor<char> passChIDAcc("passChID");
1047  // static const SG::ConstAccessor<double> ecisBDTAcc("ecisBDT");
1048  //Info(APP_NAME, "electron passChID : %d , BDT : %.3f", passChIDAcc(*el), ecisBDTAcc(*el));
1049  }
1050  }
1051  }
1052  if (isNominal || syst_affectsElectrons) {
1053  if(!isData) elecSF = objTool.GetTotalElectronSF(*electrons);
1054  }
1055 
1056  if (isNominal) {elecSF_nominal = elecSF;}
1057  else if (!syst_affectsElectrons) {elecSF = elecSF_nominal;}
1058  event_weight *= elecSF;
1059  }
1060 
1061  // ====================
1062  // Muons
1063  float muonSF = 1.0;
1064  int mu_idx[nSel] = {0};
1065  bool passTMtest = false;
1066 
1067  TString muTrig2015 = "HLT_mu20_iloose_L1MU15_OR_HLT_mu50"; //"HLT_mu18_mu8noL1"; //"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";
1071 
1072  std::vector<std::string> muTrigs2015 = {"HLT_mu20_iloose_L1MU15","HLT_mu50"}; //"HLT_mu18_mu8noL1"; //"HLT_mu20_iloose_L1MU15_OR_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"};
1076 
1077  if (slices["mu"]) {
1078  ANA_MSG_DEBUG( "Muon step - selection" );
1079  for (const auto& mu : *muons) {
1080  if ( ST::acc_passOR(*mu) == 0 ) {
1081  mu_idx[passOR]++;
1082  continue;
1083  }
1084  if ( ST::acc_baseline(*mu) == 1 ) {
1085  mu_idx[baseline]++;
1086  if ( ST::acc_cosmic(*mu) == 1 ) {
1087  mu_idx[cosmic]++;
1088  }
1089  }
1090  if ( ST::acc_signal(*mu) == 1 ) {
1091  mu_idx[signallep]++;
1092  if ( mu->pt() > 20000. ) {
1093  mu_idx[goodpt]++;
1094 
1095  bool passTM=false;
1096  for(const auto& t : mu_triggers){
1097  if (objTool.IsTrigPassed(t)) ANA_MSG_DEBUG("Pass " << t << " : " << (int)objTool.IsTrigMatched(mu, t));
1098  else ANA_MSG_DEBUG("Pass " << t << " : " << 0);
1099  passTM |= (objTool.IsTrigPassed(t) && objTool.IsTrigMatched(mu, t));
1100  }
1101  if(passTM)
1102  mu_idx[trgmatch]++;
1103 
1104  }
1105 
1106  std::vector<std::string> my_mu_trigs;
1107  if(!isData){
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;
1114  else
1115  my_mu_trigs=muTrigs2022;
1116  }
1117  else{
1118  my_mu_trigs=muTrigs2016;
1119  }
1120  for (auto& t : my_mu_trigs) passTMtest |= (objTool.IsTrigPassed(t) && objTool.IsTrigMatched(mu,t));
1121  }
1122  }
1123  }
1124 
1125 
1126  // ========================================
1127  // Photons
1128  if (slices["pho"]) {
1129  ANA_MSG_DEBUG( "Photon step - selection" );
1130  int n_SignalPhotons = 0;
1131  for (const auto& y : *photons) {
1132  if ( ST::acc_passOR(*y) && ST::acc_signal(*y)) {
1133  n_SignalPhotons++;
1134  ANA_MSG_DEBUG( "Photon pt = "<< y->pt()*1e-3
1135  << ", idSF = " << objTool.GetSignalPhotonSF(*y,true,false,false)
1136  << ", isoSF = " << objTool.GetSignalPhotonSF(*y,false,true,false)
1137  << ", trigSF = " << objTool.GetSignalPhotonSF(*y,false,false,true)
1138  );
1139  }
1140  }
1141  if(n_SignalPhotons>0) ANA_MSG_DEBUG( "Total Event photon SF = " << objTool.GetTotalPhotonSF(*photons, true, true, true));
1142  }
1143 
1144  // ====================
1145  // Check for combined e-mu triggers
1146  bool comb_trig_check = false;
1147 
1148  if (slices["ele"] && slices["mu"] && comb_trig_check) {
1149  ANA_MSG_DEBUG( "Electron/Muon step - trigger" );
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") );
1182  }
1183 
1184  if (slices["mu"] && ((!isData && isNominal) || syst_affectsMuons)) {
1185  ANA_MSG_DEBUG( "Muon step - trigger" );
1186  if(passTMtest || 1){ //objTool.IsTrigPassed(muTrig.ReplaceAll("_OR_",",").Data())){
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() );
1194  }
1195  }
1196 
1197  if (slices["mu"]) {
1198  if (isNominal) { muonSF_nominal = muonSF; }
1199  else if (!syst_affectsMuons) { muonSF = muonSF_nominal; }
1200  event_weight *= muonSF;
1201  }
1202 
1203  // ====================
1204  // Taus
1205  if (slices["tau"] && isNominal && !isData && stream.find("SUSY3")!=std::string::npos) {
1206  ANA_MSG_DEBUG( "Tau step - SF" );
1207  if (entry<10){
1208  // CP::SystematicSet testSet("TAUS_TRUEHADTAU_EFF_TRIGGER_TOTAL2016__1up");
1209  // testSet.insert( CP::SystematicVariation("TAUS_TRUEHADTAU_EFF_TRIGGER_TOTAL2016", 1) );
1210 
1211  // CP::SystematicSet testSet("TAUS_TRUEHADTAU_EFF_TRIGGER_SYST2015__1up");
1212  // testSet.insert( CP::SystematicVariation("TAUS_TRUEHADTAU_EFF_TRIGGER_SYST2015", 1) );
1213  // if(objTool.applySystematicVariation(testSet) != StatusCode::SUCCESS){
1214  // Error( APP_NAME, "Problems with tau trig eff systematic settings!");
1215  // }
1216 
1217  for (const auto& tau : *taus) {
1218  ANA_MSG_INFO( "Tau pt = "<< tau->pt()*1e-3
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")
1222  );
1223  }
1224  ANA_MSG_INFO( "Total Event Tau SF = " << objTool.GetTotalTauSF(*taus, true, true, "tau125_medium1_tracktwo") );
1225  }
1226  }
1227 
1228  ANA_MSG_DEBUG( "Lepton SF done" );
1229 
1230  // ====================
1231  // Jets
1232  int jet_idx[nSel] = {0};
1233  if (slices["jet"]) {
1234  ANA_MSG_DEBUG( "Jet step - selection" );
1235  for (const auto& jet : *goodJets) {
1236  if ( ST::acc_bad(*jet) == 1 )
1237  jet_idx[bad]++;
1238  if ( ST::acc_passOR(*jet) == 0 ) {
1239  jet_idx[passOR]++;
1240  continue;
1241  }
1242  if ( ST::acc_baseline(*jet) == 1 ) {
1243  jet_idx[baseline]++;
1244  if ( jet->pt() > 50000. )
1245  jet_idx[goodpt]++;
1246  }
1247  if ( ST::acc_bjet(*jet) == 1 )
1248  jet_idx[btagged]++;
1249  }
1250  }
1251 
1252  // compute b-tagging SF
1253  float btagSF(1.);
1254  if (slices["jet"] && slices["btag"]) {
1255  ANA_MSG_DEBUG( "(b)Jet step - selection" );
1256  if (!isData) {
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;}
1260  }
1261  event_weight *= btagSF;
1262 
1263  // checking BtagSF
1264  if ( stream.find("SUSY1")!=std::string::npos ) { // PHYSVAL doesn't contain truthlabel for VR jets
1265  float btagSF_trkJet(1.);
1266  if (!isData) {
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;}
1270  }
1271  event_weight *= btagSF_trkJet;
1272  }
1273  }
1274 
1275  ANA_MSG_DEBUG("Jet SF done");
1276 
1277  // ====================
1278  // Cosmics
1279  if (slices["ele"] && slices["mu"] && mu_idx[cosmic] == 0 ) {
1280  elcuts[isys][icut] += 1;
1281  mucuts[isys][icut] += 1;
1282  ++icut;
1283 
1284  bool passlep = (el_idx[baseline] + mu_idx[baseline]) == 1;
1285  if (passlep) {
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;
1290  ++icut;
1291 
1292  passel = el_idx[signallep] == 1;
1293  passmu = mu_idx[signallep] == 1;
1294  if (passel) elcuts[isys][icut] += 1;
1295  if (passmu) mucuts[isys][icut] += 1;
1296  ++icut;
1297 
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;
1302  ++icut;
1303 
1304  passel = el_idx[trgmatch] == 1;
1305  passmu = mu_idx[trgmatch] == 1;
1306  if (passel) elcuts[isys][icut] += 1;
1307  if (passmu) mucuts[isys][icut] += 1;
1308  ++icut;
1309 
1310  if (jet_idx[goodpt] >= 2) {
1311  if (passel) elcuts[isys][icut] += 1;
1312  if (passmu) mucuts[isys][icut] += 1;
1313  ++icut;
1314  } // good jets
1315  } // passlep
1316  } // cosmics
1317 
1318  ANA_MSG_DEBUG("Lepton SF done");
1319  ANA_MSG_DEBUG("Final event weight = " << event_weight);
1320 
1321  // Clean up the systematics copies
1322  if (sysInfo.affectsKinematics) {
1323  delete metcst;
1324  delete metcst_aux;
1325  delete mettst;
1326  delete mettst_aux;
1327  }
1328 
1329  isNominal = false;
1330  ANA_MSG_DEBUG(">>>> Finished with variation: \"" <<(sys.name()).c_str() << "\" <<<<<<" );
1331 
1332 
1333  ++isys;
1334  }
1335 
1336 
1337  //Reset systematics settings for next event
1338  ANA_CHECK( objTool.resetSystematics());
1339 
1340 
1341  // The containers created by the shallow copy are owned by you. Remember to delete them.
1342  // In our case, all of these were put into the store
1343 
1344  // store.print();
1345  store.clear();
1346 
1347  // Close with a message:
1348  if (entry==0 || entry % period == 99) {
1349  Info( APP_NAME,
1350  "===>>> done processing event #%i, "
1351  "run #%i %i events processed so far <<<===",
1352  static_cast< int >( ei->eventNumber() ),
1353  static_cast< int >( ei->runNumber() ),
1354  static_cast< int >( entry + 1 ) );
1355  }
1356 
1357 
1358  }
1359 
1360  m_clock0.Stop();
1361  m_clock2.Stop();
1362 
1363  // CALLGRIND_TOGGLE_COLLECT;
1364  // CALLGRIND_DUMP_STATS;
1365  // ProfilerStop();
1366 
1367  Info( APP_NAME,
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",
1372  m_clock0.CpuTime() * 1e3 / entries, m_clock0.RealTime() * 1e3 / entries,
1373  m_clock1.CpuTime() * 1e3, m_clock1.RealTime() * 1e3,
1374  m_clock2.CpuTime() * 1e3 / (entries - 1), m_clock2.RealTime() * 1e3 / (entries - 1));
1375 
1376 
1377  // Dump the cutflow:
1378  isys = 0;
1379  for (const auto& sysInfo : systInfoList) {
1380  const CP::SystematicSet& sys = sysInfo.systset;
1381  ANA_MSG_INFO( "-- Dummy Cutflow -- >>>> Variation " << sys.name().c_str() << " <<<<" );
1382  for (size_t icut = 0; icut < Ncuts; ++icut) {
1383  ANA_MSG_INFO( "Cut " << icut << "(" << cut_name[icut] << ")"
1384  << "-> el: " << elcuts[isys][icut] << ", mu: " << mucuts[isys][icut] );
1385  }
1386  ++isys;
1387  }
1388 
1389  // Return gracefully:
1390  return 0;
1391 }

Variable Documentation

◆ cut_name

const char* cut_name[]
Initial value:
=
{ "All",
"GRL+Cleaning",
"TileTrip",
"Trigger",
"Cosmic veto",
"==1 baseline lepton",
"==1 signal lepton",
"lepton pT>20 GeV",
"trig. matched lepton",
"Njet(pT>50 GeV)>=2"
}

Definition at line 83 of file SUSYToolsTester.cxx.

◆ Ncuts

const size_t Ncuts = 10

Definition at line 82 of file SUSYToolsTester.cxx.

◆ nSel

const unsigned int nSel =8

Definition at line 96 of file SUSYToolsTester.cxx.

DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
POOL::TEvent::retrieveMetaInput
StatusCode retrieveMetaInput(const T *&obj, const std::string &key)
Definition: PhysicsAnalysis/POOLRootAccess/POOLRootAccess/TEvent.h:90
bad
@ bad
Definition: SUSYToolsTester.cxx:100
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
SGTest::store
TestStore store
Definition: TestStore.cxx:23
python.AtlRunQueryAMI.period
period
Definition: AtlRunQueryAMI.py:225
TrigJetMonitorAlgorithm.jetcoll
jetcoll
Definition: TrigJetMonitorAlgorithm.py:1306
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
checkFileSG.line
line
Definition: checkFileSG.py:75
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
get_generator_info.result
result
Definition: get_generator_info.py:21
ST::ISUSYObjDef_xAODTool::DataSource
DataSource
Definition: ISUSYObjDef_xAODTool.h:475
xAOD::MissingETAuxContainer
MissingETAuxContainer_v1 MissingETAuxContainer
Definition: MissingETAuxContainer.h:16
xAOD::JetInput::PFlow
@ PFlow
Definition: JetContainerInfo.h:62
TrigCompositeUtils::passed
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
Definition: TrigCompositeUtilsRoot.cxx:117
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ST::SUSYObjDef_xAOD
Definition: SUSYObjDef_xAOD.h:141
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
CP::CorrectionCode::enableFailure
static void enableFailure() noexcept
Definition: CorrectionCode.h:64
SUSY::CrossSectionDB::kfactor
float kfactor(int id, int proc=0) const
Definition: SUSYCrossSection.h:101
xAOD::CutBookkeeper_v1
Description of the class that is used to keep track of event counts.
Definition: CutBookkeeper_v1.h:29
skel.it
it
Definition: skel.GENtoEVGEN.py:396
xAOD::ShallowAuxContainer
Class creating a shallow copy of an existing auxiliary container.
Definition: ShallowAuxContainer.h:54
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
PlotCalibFromCool.ib
ib
Definition: PlotCalibFromCool.py:419
xAOD::CutBookkeeper_v1::sumOfEventWeightsSquared
double sumOfEventWeightsSquared() const
Get the sum-of-(event-weights-squared) that this CutBookkeeper has seen.
Definition: CutBookkeeper_v1.cxx:327
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
xAOD::MissingETContainer
MissingETContainer_v1 MissingETContainer
Definition: Event/xAOD/xAODMissingET/xAODMissingET/MissingETContainer.h:16
SG::ConstAccessor< float >
cosmic
@ cosmic
Definition: SUSYToolsTester.cxx:101
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
beamspotman.tokens
tokens
Definition: beamspotman.py:1284
xAOD::TEvent::kClassAccess
@ kClassAccess
Access auxiliary data using the aux containers.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:100
ZDCMsg::Info
@ Info
Definition: ZDCMsg.h:20
xAOD::JetInput::typeName
const std::string & typeName(Type id)
Definition: JetContainerInfo.cxx:199
x
#define x
trgmatch
@ trgmatch
Definition: SUSYToolsTester.cxx:104
xAOD::EventInfo_v1::LAr
@ LAr
The LAr calorimeter.
Definition: EventInfo_v1.h:335
SUSY::CrossSectionDB::efficiency
float efficiency(int id, int proc=0) const
Definition: SUSYCrossSection.h:103
Ncuts
const size_t Ncuts
Definition: SUSYToolsTester.cxx:82
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
ExpressionParsing::isAvailable
bool isAvailable(const T_Aux &cont, SG::auxid_t auxid)
xAOD::EventInfo_v1::Error
@ Error
The sub-detector issued an error.
Definition: EventInfo_v1.h:349
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
xAOD::EventInfo_v1::mcChannelNumber
uint32_t mcChannelNumber() const
The MC generator's channel number.
getTokens
std::vector< std::string > getTokens(TString line, const TString &delim)
Definition: SUSYToolsTester.cxx:1395
POOL::TEvent::readFrom
StatusCode readFrom(TFile *file)
Definition: PhysicsAnalysis/POOLRootAccess/src/TEvent.cxx:133
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
IsoCloseByCorrectionTest.containers
containers
Associate the close-by pflow objects and the calorimeter clusters.
Definition: IsoCloseByCorrectionTest.py:82
asg::StandaloneToolHandle::setProperty
StatusCode setProperty(const std::string &name, T2 &&value)
Definition: StandaloneToolHandle.h:105
lumiFormat.i
int i
Definition: lumiFormat.py:85
btagged
@ btagged
Definition: SUSYToolsTester.cxx:103
POOL::TEvent::getEntries
long getEntries()
Definition: PhysicsAnalysis/POOLRootAccess/src/TEvent.cxx:124
asg::StandaloneToolHandle
an "initializing" ToolHandle for stand-alone applications
Definition: StandaloneToolHandle.h:44
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
ST::ISUSYObjDef_xAODTool::Data
@ Data
Definition: ISUSYObjDef_xAODTool.h:477
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
ANA_MSG_WARNING
#define ANA_MSG_WARNING(xmsg)
Macro printing warning messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:292
APP_NAME
#define APP_NAME
Definition: BoostedXbbTag.cxx:23
baseline
@ baseline
Definition: SUSYToolsTester.cxx:99
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
xAOD::MissingETAuxContainer_v1
Auxiliary data store for xAOD::MissingETContainer.
Definition: MissingETAuxContainer_v1.h:20
hist_file_dump.f
f
Definition: hist_file_dump.py:135
xAOD::CutBookkeeperContainer_v1
Container that holds the Container of all CutBookkeepers.
Definition: CutBookkeeperContainer_v1.h:27
ST::SystInfo::affectsType
unsigned int affectsType
Definition: ISUSYObjDef_xAODTool.h:67
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
ST::ISUSYObjDef_xAODTool::FullSim
@ FullSim
Definition: ISUSYObjDef_xAODTool.h:478
cut_name
const char * cut_name[]
Definition: SUSYToolsTester.cxx:83
xAOD::JetInput::Type
Type
Definition: JetContainerInfo.h:54
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
calibdata.exit
exit
Definition: calibdata.py:236
asg::StandaloneToolHandle::retrieve
StatusCode retrieve()
initialize the tool, will succeed if the tool was already initialized
Definition: StandaloneToolHandle.h:147
xAOD::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
CaloCondBlobAlgs_fillNoiseFromASCII.comment
string comment
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:27
Trig::ChainGroup
Definition: ChainGroup.h:51
ST::SystInfo::affectsKinematics
bool affectsKinematics
Definition: ISUSYObjDef_xAODTool.h:65
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
Trig::ChainGroup::isPassed
bool isPassed(unsigned int condition=TrigDefs::Physics) const
tells if chain group passed
Definition: ChainGroup.cxx:208
xAOD::MissingETContainer_v1
Container for xAOD::MissingET_v1 objects.
Definition: MissingETContainer_v1.h:21
nSel
const unsigned int nSel
Definition: SUSYToolsTester.cxx:96
xAOD::CutBookkeeper_v1::nAcceptedEvents
uint64_t nAcceptedEvents() const
Get the number of accepted events that this CutBookkeeper has seen.
Definition: CutBookkeeper_v1.cxx:291
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
xAOD::TruthHelpers::getTruthParticle
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any)
Definition: xAODTruthHelpers.cxx:25
ST::SystInfo
Definition: ISUSYObjDef_xAODTool.h:63
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
xAOD::CutBookkeeper_v1::sumOfEventWeights
double sumOfEventWeights() const
Get the sum-of-event-weights that this CutBookkeeper has seen.
Definition: CutBookkeeper_v1.cxx:309
xAOD::TruthParticle_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: TruthParticle_v1.cxx:174
xAOD::CutBookkeeper_v1::name
const std::string & name() const
Get the name of this CutBookkeeper.
Definition: CutBookkeeper_v1.cxx:156
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
Muon
struct TBPatternUnitContext Muon
xAOD::JetInput::EMTopo
@ EMTopo
Definition: JetContainerInfo.h:56
asg::StandaloneToolHandle::setTypeAndName
void setTypeAndName(const std::string &typeAndName)
Definition: StandaloneToolHandle.h:101
FlavorTagDiscriminants::hbb_key::fatjet
const std::string fatjet
Definition: HbbConstants.h:19
xAOD::EventInfo_v1::Tile
@ Tile
The Tile calorimeter.
Definition: EventInfo_v1.h:336
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition: TStore.h:44
y
#define y
SUSY::CrossSectionDB
Definition: SUSYCrossSection.h:29
ANA_CHECK_SET_TYPE
#define ANA_CHECK_SET_TYPE(TYPE)
set the type for ANA_CHECK to report failures
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:314
POOL::TEvent::retrieve
StatusCode retrieve(const T *&obj)
Definition: PhysicsAnalysis/POOLRootAccess/POOLRootAccess/TEvent.h:74
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
Trig::ChainGroup::getPrescale
float getPrescale(unsigned int condition=TrigDefs::Physics) const
returns prescale factor for chain group with single chain in returns real prescale factor for real ch...
Definition: ChainGroup.cxx:407
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
ST::ISUSYObjDef_xAODTool::AtlfastII
@ AtlfastII
Definition: ISUSYObjDef_xAODTool.h:479
xAOD::EventInfo_v1::errorState
EventFlagErrorState errorState(EventFlagSubDet subDet) const
Get the error state for a particular sub-detector.
Definition: EventInfo_v1.cxx:817
entries
double entries
Definition: listroot.cxx:49
IGoodRunsListSelectionTool::passRunLB
virtual bool passRunLB(const std::vector< std::string > &grlnameVec=std::vector< std::string >(), const std::vector< std::string > &brlnameVec=std::vector< std::string >()) const =0
Check if the current event passes the selection.
xAOD::TruthParticle_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: TruthParticle_v1.cxx:166
xAOD::EventInfo_v1::isEventFlagBitSet
bool isEventFlagBitSet(EventFlagSubDet subDet, size_t bit) const
Check one particular bit of one particular sub-detector.
Definition: EventInfo_v1.cxx:703
xAODType::Tau
@ Tau
The object is a tau (jet)
Definition: ObjectType.h:49
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
signallep
@ signallep
Definition: SUSYToolsTester.cxx:98
ST::SystInfo::affectsWeights
bool affectsWeights
Definition: ISUSYObjDef_xAODTool.h:66
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
ST::Unknown
@ Unknown
Definition: ISUSYObjDef_xAODTool.h:73
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
xAOD::EventInfo_v1::mcEventWeight
float mcEventWeight(size_t i=0) const
The weight of one specific MC event used in the simulation.
Definition: EventInfo_v1.cxx:203
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition: JetContainer.h:17
LArCellNtuple.ifile
string ifile
Definition: LArCellNtuple.py:133
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
xAODType::BTag
@ BTag
The object is a b-tagging object.
Definition: ObjectType.h:60
getFileContainers
std::map< std::string, std::string > getFileContainers(std::unique_ptr< TFile > &)
Definition: SUSYToolsTester.cxx:1412
Trig::ChainGroup::getListOfTriggers
std::vector< std::string > getListOfTriggers() const
Definition: ChainGroup.cxx:467
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
passOR
@ passOR
Definition: SUSYToolsTester.cxx:105
runIDPVM.jetCollection
jetCollection
Definition: runIDPVM.py:112
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition: Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::EventInfo_v1::Core
@ Core
Core flags describing the event.
Definition: EventInfo_v1.h:339
xAOD::JetInput::Uncategorized
@ Uncategorized
Definition: JetContainerInfo.h:100
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:84
keylayer_zslicemap.slices
slices
Definition: keylayer_zslicemap.py:112
match
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition: hcg.cxx:356
SUSY::CrossSectionDB::xsectTimesEff
float xsectTimesEff(int id, int proc=0) const
Definition: SUSYCrossSection.h:94
xAOD::EventInfo_v1::SCT
@ SCT
The SCT.
Definition: EventInfo_v1.h:333
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
ANA_MSG_DEBUG
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288
goodpt
@ goodpt
Definition: SUSYToolsTester.cxx:102