ATLAS Offline Software
Loading...
Searching...
No Matches
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

namespace  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 92 of file SUSYToolsTester.cxx.

92 {
95 bad,
96 cosmic,
97 goodpt,
98 btagged,
100 passOR
101};
@ trgmatch
@ baseline
@ cosmic
@ btagged
@ goodpt
@ signallep

Function Documentation

◆ getFileContainers()

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

Definition at line 1409 of file SUSYToolsTester.cxx.

1409 {
1410 std::map< std::string, std::string > containers;
1411 std::unique_ptr< TTree > ctree( dynamic_cast<TTree*>( f->Get("CollectionTree") ) );
1412 TObjArray *blist = dynamic_cast<TObjArray*>( ctree->GetListOfBranches() );
1413 std::smatch match;
1414 std::string result, bname;
1415 for (int ib=0; ib<blist->GetEntries(); ++ib) {
1416 TBranch *b = dynamic_cast<TBranch*>( blist->At(ib) );
1417 bname = b->GetName();
1418 if (bname.find("Aux")==std::string::npos) continue;
1419 //
1420 if (std::regex_search(bname, match, std::regex("(.*)Aux\\..*")) && match.size() > 1) { result = match.str(1); } // static
1421 else if (std::regex_search(bname, match, std::regex("(.*)AuxDyn\\..*")) && match.size() > 1) { result = match.str(1); } // dynamic
1422 //
1423 if ((!result.empty()) && (containers.find(result)==containers.end()) && (ctree->GetBranch(result.c_str()))) {
1424 containers[result] = ctree->GetBranch(result.c_str())->GetClassName();
1425 }
1426 result = "";
1427 }
1428 return containers;
1429}
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition hcg.cxx:359

◆ getTokens()

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

Definition at line 1392 of file SUSYToolsTester.cxx.

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

◆ main()

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

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

Definition at line 110 of file SUSYToolsTester.cxx.

110 {
111
112 using namespace asg::msgSTT;
113 ANA_CHECK_SET_TYPE (int);
114 setMsgLevel(MSG::INFO);
115
117
118 // The application's name:
119 const char* APP_NAME = argv[ 0 ];
120
121 // Check if we received a file name:
122 if ( argc < 2 ) {
123 ANA_MSG_ERROR( "No file name received!" );
124 ANA_MSG_ERROR( " Usage: " << APP_NAME << " [xAOD file name] [maxEvents] [isData=0/1 isAtlfast=0/1] [NoSyst=0/1] [Debug=0/1/2] [ConfigFile=<cfile.conf>] [PRWFile=<prwfile.root>] [autoconfigPRW=0/1] [commonPRWFile=0/1]" );
125 return 1;
126 }
127
128
130
131 int autoconfigPRW = 1;
132 int commonPRWFile = 1;
133 int isData = -1;
134 int isAtlfast = -1;
135 int NoSyst = 1;
136 int debug = 1;
137 bool isPHYSLite = false;
138 bool hasLRT = false;
139 Long64_t entries=-1;
140
141 // Open the input file:
142 TString fileName = argv[1];
143 ANA_MSG_INFO( "Opening file: " << fileName );
144 std::unique_ptr< TFile > ifile( TFile::Open( fileName, "READ" ) );
145 ANA_CHECK( ifile.get() );
146
147 bool isRun3 = false;
148 if ((fileName.Contains("mc23") || fileName.Contains("mc21") || fileName.Contains("data2")) && fileName.Contains("13p6TeV")) isRun3 = true;
149 std::string config_file = (PathResolverFindCalibFile("SUSYTools/SUSYTools_Default.conf")).c_str();
150 if (fileName.Contains("LITE")) config_file = (PathResolverFindCalibFile("SUSYTools/SUSYTools_Default_LITE.conf")).c_str();
151 if (isRun3) {
152 config_file = (PathResolverFindCalibFile("SUSYTools/SUSYTools_Default_Run3.conf")).c_str();
153 if (fileName.Contains("LITE")) config_file = (PathResolverFindCalibFile("SUSYTools/SUSYTools_Default_Run3_LITE.conf")).c_str();
154 ANA_MSG_INFO("Configuring for Run 3");
155 }
156 std::string prw_file = "DUMMY";
157 std::string ilumicalc_file = "DUMMY";
158
159 for (int i = 1 ; i < argc ; i++) {
160 const char* key = strtok(argv[i], "=") ;
161 const char* val = strtok(0, " ") ;
162
163 ANA_MSG_INFO( "===== Processing key " << TString(key) << " with value " << TString(val) );
164 if (strcmp(key, "autoconfigPRW") == 0) autoconfigPRW = atoi(val);
165 if (strcmp(key, "commonPRWFile") == 0) commonPRWFile = atoi(val);
166 if (strcmp(key, "isData") == 0) isData = atoi(val);
167 if (strcmp(key, "isAtlfast") == 0) isAtlfast = atoi(val);
168 if (strcmp(key, "NoSyst") == 0) NoSyst = atoi(val);
169 if (strcmp(key, "Debug") == 0) debug = atoi(val);
170 if (strcmp(key, "ConfigFile") == 0) config_file = (PathResolverFindCalibFile(val)).c_str();
171 if (strcmp(key, "PRWFile") == 0) prw_file = std::string(val);
172 if (strcmp(key, "ilumicalcFile") == 0) ilumicalc_file = std::string(val);
173 if (strcmp(key, "maxEvents") == 0) entries = atoi(val);
174
175 }
176
177 if (debug>0) setMsgLevel((MSG::Level)(3-debug)); // NIL=0, VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL, ALWAYS
178
179 if (isData < 0 || isAtlfast < 0) {
180 ANA_MSG_ERROR( "One of the flags isData or isAtlfast was not set! Must provide isData or isAtlfast." );
181 ANA_MSG_ERROR( " Usage: " << APP_NAME << " [xAOD file name] [maxEvents] [isData=0/1 isAtlfast=0/1] [NoSyst=0/1] [Debug=0/1/2] [ConfigFile=<cfile.conf>] [PRWFile=<prwfile.root>] [autoconfigPRW=0/1] [commonPRWFile=0/1]");
182 return 10;
183 }
185
186
187 // Open file and check available containers
188 std::map<std::string, std::string> containers = getFileContainers(ifile);
189 bool hasTrkJets(false), hasFatJets(false);
190 for (auto& x : containers) {
191 if (x.first.find("AntiKtVR30Rmax4Rmin02TrackJets")!=std::string::npos) hasTrkJets = true;
192 if (x.first.find("AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets")!=std::string::npos) hasFatJets = true;
193 if (x.first.find("AnalysisElectrons")!=std::string::npos) isPHYSLite = true;
194 if (isPHYSLite && x.first.find("AnalysisLargeRJets")!=std::string::npos) hasFatJets = false;
195 if (x.first.find("InDetLargeD0TrackParticles") != std::string::npos) hasLRT = true;
196 }
197 if (debug>0) {
198 ANA_MSG_INFO("Checking file contents (containers):");
199 for (auto& x : containers) ANA_MSG_INFO(" - found " << x.first.c_str() << " (" << x.second.c_str() << ")");
200 ANA_MSG_INFO("hasTrkJets: " << (hasTrkJets?"true":"false"));
201 ANA_MSG_INFO("hasFatJets: " << (hasFatJets?"true":"false"));
202 ANA_MSG_INFO("isPHYSLite: " << (isPHYSLite?"true":"false"));
203 ANA_MSG_INFO("hasLRT : " << (hasLRT?"true":"false"));
204 }
205
206 // Create a TEvent object:
207
209 ANA_CHECK( event.readFrom( ifile.get() ) );
210 ANA_MSG_INFO( "Number of events in the file: " << static_cast< int >( event.getEntries() ) );
211
213
214 // Open up an output file. Not needed for this example. If you wish to enable
215 // this, please don't forget to add the call to fill towards the end of the code!
216 //std::unique_ptr< TFile > ofile( TFile::Open( "out.root", "RECREATE" ) );
217 //ANA_CHECK( event.writeTo( ofile.get() ) );
218
219 // If we haven't set the number of events, then run over the whole tree
220 if (entries<0){
221 entries = event.getEntries();
222 }
223
224 // GRL tool
226 if (isData) {
227 m_grl.setTypeAndName("GoodRunsListSelectionTool/grl");
228 std::vector<std::string> myGRLs;
229
230 myGRLs.push_back(PathResolverFindCalibFile("GoodRunsLists/data15_13TeV/20170619/physics_25ns_21.0.19.xml"));
231 myGRLs.push_back(PathResolverFindCalibFile("GoodRunsLists/data16_13TeV/20180129/physics_25ns_21.0.19.xml"));
232 myGRLs.push_back(PathResolverFindCalibFile("GoodRunsLists/data17_13TeV/20180619/physics_25ns_Triggerno17e33prim.xml"));
233 myGRLs.push_back(PathResolverFindCalibFile("GoodRunsLists/data18_13TeV/20190219/physics_25ns_Triggerno17e33prim.xml"));
234 myGRLs.push_back(PathResolverFindCalibFile("GoodRunsLists/data22_13p6TeV/20250321/data22_13p6TeV.periodAllYear_DetStatus-v134-pro28-09_MERGED_PHYS_StandardGRL_All_Good_25ns.xml"));
235 myGRLs.push_back(PathResolverFindCalibFile("GoodRunsLists/data23_13p6TeV/20250321/data23_13p6TeV.periodAllYear_DetStatus-v133-pro31-11_MERGED_PHYS_StandardGRL_All_Good_25ns.xml"));
236 //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"));
237 ANA_CHECK( m_grl.setProperty("GoodRunsListVec", myGRLs) );
238 ANA_CHECK( m_grl.setProperty("PassThrough", false) );
239 ANA_CHECK( m_grl.retrieve() );
240
241 ANA_MSG_INFO( "GRL tool retrieve & initialized... " );
242 }
243
244 //xsec DB
245 SUSY::CrossSectionDB *my_XsecDB = nullptr;
246 if (!isData){
247 ANA_MSG_INFO(fileName);
248 if (isRun3 && fileName.Contains("mc21")) { my_XsecDB = new SUSY::CrossSectionDB(PathResolverFindCalibFile("dev/PMGTools/PMGxsecDB_mc21.txt"));}
249 else if (isRun3 && fileName.Contains("mc23")) { my_XsecDB = new SUSY::CrossSectionDB(PathResolverFindCalibFile("dev/PMGTools/PMGxsecDB_mc23.txt"));}
250 else { my_XsecDB = new SUSY::CrossSectionDB(PathResolverFindCalibFile("dev/PMGTools/PMGxsecDB_mc16.txt"));}
251 ANA_MSG_INFO( "xsec DB initialized" );
252 }
253
254 // Create the tool(s) to test:
255 ST::SUSYObjDef_xAOD objTool("SUSYObjDef_xAOD");
256
257 ANA_MSG_INFO(" ABOUT TO INITIALIZE SUSYTOOLS " );
258
260 // Configure the SUSYObjDef instance
261
262 ANA_CHECK( objTool.setProperty("DataSource", datasource) ) ;
263 if(!config_file.empty())
264 ANA_CHECK( objTool.setProperty("ConfigFile", config_file) );
265
272
273 std::vector<std::string> prw_conf;
274 if (!isData) {
275 if ( autoconfigPRW == 1 ) {
276 ANA_CHECK( objTool.setBoolProperty("AutoconfigurePRWTool", true) );
277 if ( commonPRWFile == 1 )
278 ANA_CHECK( objTool.setBoolProperty("PRWUseCommonMCFiles", true) );
279 } else {
280 if (prw_file == "DUMMY") {
281 prw_conf.push_back("dev/SUSYTools/merged_prw_mc16a_latest.root");
282 } else {
283 prw_conf = getTokens(prw_file,",");
284 }
285 ANA_CHECK( objTool.setProperty("PRWConfigFiles", prw_conf) );
286 }
287 }
288
289 // Tau Trigger Efficiency Tool requires proper MC campaign, which requires proper ilumicalc file
290 std::string mcCampaign = "mc16e";
291 std::string ilumi = "GoodRunsLists/data18_13TeV/20190318/ilumicalc_histograms_None_348885-364292_OflLumi-13TeV-010.root";
292 if ((fileName.Contains("mc23a") || fileName.Contains("data22")) && fileName.Contains("13p6TeV")) {
293 mcCampaign = "mc23a";
294 ilumi = "GoodRunsLists/data22_13p6TeV/20250321/ilumicalc_histograms_None_431810-440613_OflLumi-Run3-004.root";
295 } else if ((fileName.Contains("mc23d") || fileName.Contains("data23")) && fileName.Contains("13p6TeV")) {
296 mcCampaign = "mc23d";
297 ilumi = "GoodRunsLists/data23_13p6TeV/20250321/ilumicalc_histograms_None_451587-456749_OflLumi-Run3-004.root";
298 } else if ((fileName.Contains("mc23e") || fileName.Contains("data24")) && fileName.Contains("13p6TeV")) {
299 mcCampaign = "mc23e";
300 ilumi = "GoodRunsLists/data24_13p6TeV/20241118/ilumicalc_histograms_None_473235-486706_OflLumi-Run3-005.root";
301 } else if (fileName.Contains("mc20a") || fileName.Contains("data15") || fileName.Contains("data16")) {
302 mcCampaign = "mc20a";
303 // Just use 2016 ilumicalc file for mc20a
304 ilumi = "GoodRunsLists/data16_13TeV/20180129/PHYS_StandardGRL_All_Good_25ns_297730-311481_OflLumi-13TeV-009.root";
305 } else if (fileName.Contains("mc20d") || fileName.Contains("data17")) {
306 mcCampaign = "mc20d";
307 ilumi = "GoodRunsLists/data17_13TeV/20180619/physics_25ns_Triggerno17e33prim.lumicalc.OflLumi-13TeV-010.root";
308 } else if (fileName.Contains("mc20e") || fileName.Contains("data18")) {
309 mcCampaign = "mc20e";
310 ilumi = "GoodRunsLists/data18_13TeV/20190318/ilumicalc_histograms_None_348885-364292_OflLumi-13TeV-010.root";
311 }
312
329
330 ANA_CHECK( objTool.setProperty( "mcCampaign", mcCampaign ) );
331 std::vector<std::string> prw_lumicalc;
332 if (ilumicalc_file == "DUMMY") {
333 prw_lumicalc.push_back(PathResolverFindCalibFile(ilumi));
334 } else {
335 prw_lumicalc = getTokens(ilumicalc_file,",");
336 }
337 ANA_CHECK( objTool.setProperty("PRWLumiCalcFiles", prw_lumicalc) );
338
339 // ============================================================================================
340 // Guess shower type for btagging MC/MC SFs
341 if(!isData){
342 int ishower = objTool.getMCShowerType("PhPy8EG","GN2v01"); //get your sample name here!
343 ANA_CHECK( objTool.setProperty("ShowerType", (int)ishower) );
344 }
345
347 // ANA_CHECK( objTool.setBoolProperty("EleForceNoId", false) );
348 // ANA_CHECK( objTool.setBoolProperty("MuForceNoId", false) );
350
351 ANA_CHECK(objTool.setProperty("OutputLevel", msg().level() ));
352 ANA_CHECK(objTool.setBoolProperty("DebugMode", (debug>1))); // debug=0:INFO,1:DEBUG->0, debug=2:VERBOSE->1
353
354 if ( objTool.initialize() != StatusCode::SUCCESS) {
355 ANA_MSG_ERROR( "Cannot initialize SUSYObjDef_xAOD, exiting." );
356 return 1;
357 } else {
358 ANA_MSG_INFO( "SUSYObjDef_xAOD initialized..." );
359 }
360
361 ANA_MSG_INFO( "Initialized SUSYTools" );
362
363 // ============================================================================================
364 // Configuration
365 TEnv rEnv;
366 if ( rEnv.ReadFile(config_file.c_str(), kEnvAll) != 0 ) {
367 ANA_MSG_ERROR( "Cannot open config file, exiting.");
368 return 1;
369 }
370 ANA_MSG_INFO( "Config file opened" );
371
372 std::map<std::string,std::string> configDict = {};
373 configDict["Jet.LargeRcollection"] = rEnv.GetValue("Jet.LargeRcollection", "AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets" );
374 configDict["TrackJet.Collection"] = rEnv.GetValue("TrackJet.Collection", "AntiKtVR30Rmax4Rmin02TrackJets" );
375 configDict["Jet.WtaggerConfig"] = rEnv.GetValue("Jet.WtaggerConfig", "None");
376 configDict["Jet.ZtaggerConfig"] = rEnv.GetValue("Jet.ZtaggerConfig", "None");
377 configDict["Jet.ToptaggerConfig"] = rEnv.GetValue("Jet.ToptaggerConfig", "None");
378 // Trim comments and extra spaces from config entries
379 std::regex comment("#.*$");
380 std::regex trimspaces("^ +| +$|( ) +");
381 for (auto& keyval : configDict) {
382 configDict[keyval.first] = regex_replace(configDict[keyval.first], comment, "");
383 configDict[keyval.first] = regex_replace(configDict[keyval.first], trimspaces, "$1");
384 ANA_MSG_DEBUG("config " << keyval.first << " : " << configDict[keyval.first]);
385 }
386 std::string FatJetCollection = configDict["Jet.LargeRcollection"];
387 std::string TrkJetCollection = configDict["TrackJet.Collection"];
388 if (configDict["TrackJet.Collection"].find("None")!=std::string::npos) TrkJetCollection = "";
389
390 std::map<std::string,bool> slices = {};
391 slices["ele"] = bool(rEnv.GetValue("Slices.Ele", true));
392 slices["pho"] = bool(rEnv.GetValue("Slices.Pho", true));
393 slices["mu"] = bool(rEnv.GetValue("Slices.Mu", true));
394 slices["tau"] = bool(rEnv.GetValue("Slices.Tau", true));
395 slices["jet"] = bool(rEnv.GetValue("Slices.Jet", true));
396 slices["bjet"] = bool(rEnv.GetValue("Slices.BJet", true));
397 slices["fjet"] = bool(rEnv.GetValue("Slices.FJet", true));
398 slices["tjet"] = bool(rEnv.GetValue("Slices.TJet", true));
399 slices["met"] = bool(rEnv.GetValue("Slices.MET", true));
400 for (auto& x : slices) { ANA_MSG_DEBUG( "Slice " << x.first << ": " << ((x.second)?"true":"false")); }
401
402 // ============================================================================================
403 ToolHandle<TauAnalysisTools::ITauTruthMatchingTool> T2MT = 0;
404 if (slices["tau"] && !isData) {
405 // borrow the T2MT from SUSYTools
407 ANA_CHECK(T2MT.retrieve());
408 }
409
410 // ============================================================================================
411 // Triggers from https://twiki.cern.ch/twiki/bin/view/Atlas/LowestUnprescaled
412 std::vector<std::string> el_triggers,mu_triggers,ph_triggers,tau_triggers,emu_triggers;
413 if (isRun3){
414 el_triggers = {"HLT_e26_lhtight_ivarloose_L1EM22VHI","HLT_e26_lhtight_ivarloose_L1eEM26M","HLT_e60_lhmedium_L1EM22VHI", "HLT_e140_lhloose_L1EM22VHI"};//,"HLT_e300_etcut_L1EM22VHI"
415 mu_triggers = {"HLT_mu24_ivarmedium_L1MU14FCH","HLT_mu50_L1MU14FCH","HLT_mu60_0eta105_msonly_L1MU14FCH","HLT_mu60_L1MU14FCH","HLT_mu80_msonly_3layersEC_L1MU14FCH"};
416 ph_triggers = {"HLT_g140_loose_L1EM22VHI","HLT_g300_etcut_L1EM22VHI"};
417 tau_triggers = {"HLT_tau160_mediumRNN_tracktwoMVA_L1TAU100", "HLT_tau40_mediumRNN_tracktwoMVA_tau35_mediumRNN_tracktwoMVA_03dRAB_L1TAU25IM_2TAU20IM_2J25_3J20"};
418 emu_triggers = {"HLT_2e12_lhloose_mu10_L12EM8VH_MU8F", "HLT_e12_lhloose_2mu10_L12MU8F", "HLT_e17_lhloose_mu14_L1EM15VH_MU8F", "HLT_e7_lhmedium_mu24_L1MU14FCH"};
419 }
420 else
421 {
422 el_triggers = {"HLT_e24_lhmedium_L1EM20VH","HLT_e26_lhtight_nod0_ivarloose", "HLT_e60_lhmedium_nod0", "HLT_e160_lhloose_nod0"};
423 mu_triggers = {"HLT_mu26_ivarmedium","HLT_mu50","HLT_mu20_mu8noL1"};
424 ph_triggers = {"HLT_g120_loose"};
425 tau_triggers = {"HLT_tau125_medium1_tracktwo", "HLT_tau40_mediumRNN_tracktwoMVA_tau35_mediumRNN_tracktwoMVA"};
426 emu_triggers = {"HLT_2e12_lhloose_nod0_mu10", "HLT_e12_lhloose_nod0_2mu10", "HLT_e17_lhloose_nod0_mu14", "HLT_e7_lhmedium_nod0_mu24"};
427 }
428 // ============================================================================================
429 // Systematics and counts
430 std::vector<ST::SystInfo> systInfoList;
431 if (NoSyst) {
432 ST::SystInfo infodef;
433 infodef.affectsKinematics = false;
434 infodef.affectsWeights = false;
435 infodef.affectsType = ST::Unknown;
436 systInfoList.push_back(infodef);
437 } else {
438 systInfoList = objTool.getSystInfoList();
439 }
440
441 size_t isys = 0;
442 const size_t Nsyst = systInfoList.size();
443 std::vector<std::vector<int> > elcuts;
444 std::vector<std::vector<int> > mucuts;
445 for (isys = 0; isys < Nsyst; ++isys) {
446 std::vector<int> elcutsCurrentSyst;
447 std::vector<int> mucutsCurrentSyst;
448 for (size_t icut = 0; icut < Ncuts; ++icut) {
449 elcutsCurrentSyst.push_back(0);
450 mucutsCurrentSyst.push_back(0);
451 }
452 elcuts.push_back(elcutsCurrentSyst);
453 mucuts.push_back(elcutsCurrentSyst);
454 }
455
456 if (objTool.resetSystematics() != StatusCode::SUCCESS) {
457 Error(APP_NAME, "Cannot reset SUSYTools systematics" );
458 exit(-2);
459 }
460
461 // ===============================================================================================
462 // Event Loop
463 TStopwatch m_clock0;
464 m_clock0.Start();
465 TStopwatch m_clock1;
466 m_clock1.Start();
467 TStopwatch m_clock2;
468
469 int period = (debug>0) ? 1 : 100;
470 std::string cbkname, stream, ostream, kernel;
471
472 // Loop over the events:
473 for ( Long64_t entry = 0; entry < entries; ++entry ) {
474
475 if (entry == 1) {
476 m_clock1.Stop();
477 m_clock2.Start();
478 // CALLGRIND_TOGGLE_COLLECT;
479 // ProfilerStart("gperftools.profile.out");
480 }
481
482
483 // Tell the object which entry to look at:
484 event.getEntry( entry );
485
486 if(entry == 0){
487 // Read the CutBookkeeper container
488 const xAOD::CutBookkeeperContainer* completeCBC = nullptr;
489 if (!event.retrieveMetaInput(completeCBC, "CutBookkeepers").isSuccess()) {
490 ANA_MSG_ERROR("Failed to retrieve CutBookkeepers from MetaData, exiting.");
491 return 1;
492 }
493
494 // Let's find the right CBK (latest with StreamAOD input before derivations)
495 const xAOD::CutBookkeeper* allEventsCBK = nullptr;
496 int maxcycle=-1;
497 for ( const auto *cbk : *completeCBC ) {
498 cbkname = cbk->name();
499 stream = cbk->inputStream();
500 ostream = (cbk->outputStreams().size() ? cbk->outputStreams()[0] : "");
501 ANA_MSG_INFO("== cbkname: " << cbkname << ", description: " << cbk->description() << ", stream: " << stream);
502 ANA_MSG_INFO(" inputStream: " << cbk->inputStream() << ", outputStreams: " << ostream);
503 ANA_MSG_INFO(" cycle: " << cbk->cycle() << ", allEvents = " << cbk->nAcceptedEvents());
504 if (cbkname.find("PHYSVAL")!=std::string::npos) kernel="PHYSVAL";
505 else if (cbkname.find("PHYSLITE")!=std::string::npos) kernel="PHYSLITE";
506 else if (cbkname.find("PHYS")!=std::string::npos) kernel="PHYS";
507 else if (stream.find("StreamAOD")!=std::string::npos) kernel=stream.replace(stream.find("Stream"),6,"");
508 else kernel="other";
509 if (cbkname.find("AllExecutedEvents")!=std::string::npos && ostream.find("StreamAOD")!=std::string::npos && cbk->cycle() > maxcycle) {
510 maxcycle = cbk->cycle();
511 allEventsCBK = cbk;
512 }
513 }
514
515 if (allEventsCBK) {
516 uint64_t nEventsProcessed = allEventsCBK->nAcceptedEvents();
517 double sumOfWeights = allEventsCBK->sumOfEventWeights();
518 double sumOfWeightsSquared = allEventsCBK->sumOfEventWeightsSquared();
519 ANA_MSG_INFO( "CutBookkeepers Accepted " << nEventsProcessed << " SumWei " << sumOfWeights << " sumWei2 " << sumOfWeightsSquared);
520 } else { ANA_MSG_INFO( "No relevent CutBookKeepers found" ); }
521
522 ANA_MSG_INFO("Found kernel: " << kernel);
523 ANA_MSG_INFO("Found stream: " << stream);
524
525 // No special jets when running on PHYSLITE
526 if (isPHYSLite) {
527 hasTrkJets = false;
528 }
529 }
530
531 // Only need to PRW if we aren't running on PHYSLITE
532 if (!isPHYSLite) {
533 ANA_CHECK( objTool.ApplyPRWTool());
534 }
535
536 // Only need LRT uncertainty tool if there are LRT tracks!
537 if (hasLRT) {
538 ANA_MSG_DEBUG( "Applying LRT uncertainty decorations" );
539 ANA_CHECK( objTool.ApplyLRTUncertainty());
540 }
541
542 // ============================================================================================
543 // Print some event information for fun:
544 const xAOD::EventInfo* ei = nullptr;
545 ANA_CHECK( event.retrieve( ei, "EventInfo" ) );
546
547 if (entry==0 || entry % period == 999) {
548 ANA_MSG_INFO( "===>>> start processing event #, " << static_cast< int >( ei->eventNumber() ) <<
549 "run #" << static_cast< int >( ei->runNumber() ) << " " << static_cast< int >( entry ) << " events processed so far <<<===");
550 }
551
552 if (!isData && entry % period == 0) {
553 float xsectTimesEff = my_XsecDB->xsectTimesEff(ei->mcChannelNumber());
554 ANA_MSG_INFO( "===>>> process cross section " << xsectTimesEff );
555 }
556
557 bool eventPassesGRL(true);
558 bool eventPassesCleaning(true);
559 bool eventPassesTileTrip(true); // move to xAOD tool!
560 bool eventPassesTrigger(true); // coming soon!
561
562 if (!isData){
563 static const SG::ConstAccessor<float> pileupWeightAcc("PileupWeight_NOSYS");
564 float PRW_weight = isPHYSLite? pileupWeightAcc(*ei): objTool.GetPileupWeight();
565 ANA_MSG_DEBUG( "PRW Weight = " << PRW_weight);
566 }
567
568 if (isData) {
569 eventPassesGRL = m_grl->passRunLB(ei->runNumber(), ei->lumiBlock());
570
571 eventPassesCleaning = !((ei->errorState(xAOD::EventInfo::LAr) == xAOD::EventInfo::Error ) ||
575 }
576 else {
577 // Check SUSY Proc. ID for signal MC (only for first event for now!)
578 if(entry<5){
579 int pdgid1 = 0;
580 int pdgid2 = 0;
581
582 if( objTool.FindSusyHP(pdgid1, pdgid2) != StatusCode::SUCCESS ){
583 ANA_MSG_WARNING( "SUSY Proc finding failed. Normal for non-SUSY samples." );
584 }
585
586 if( pdgid1!=0 && pdgid2!=0){ //(just to avoid warnings)
587 // --- Deprecated usage of procID
588 ANA_MSG_INFO( "--- SIGNAL ID1 : " << pdgid1 );
589 ANA_MSG_INFO( " SIGNAL ID2 : " << pdgid2 );
590 ANA_MSG_INFO( "--- XSECTION DETAILS" );
591 }
592 ANA_MSG_INFO( " Xsec (high order) " << my_XsecDB->xsectTimesEff(ei->mcChannelNumber(),0) );
593 ANA_MSG_INFO( " kfactor (high order) " << my_XsecDB->kfactor(ei->mcChannelNumber(),0) );
594 ANA_MSG_INFO( " filter efficiency " << my_XsecDB->efficiency(ei->mcChannelNumber(),0) );
595 }
596 }
597
598
599 //Check PV in the event
600 if (objTool.GetPrimVtx() == nullptr) {
601 Warning(APP_NAME , "No PV found for this event! Skipping...");
602 store.clear();
603 continue;
604 }
605
606
607 // ====================================================================================================
608 // Object containers - nominal
609 xAOD::ElectronContainer* electrons_nominal(nullptr);
610 xAOD::ShallowAuxContainer* electrons_nominal_aux(nullptr);
611 xAOD::PhotonContainer* photons_nominal(nullptr);
612 xAOD::ShallowAuxContainer* photons_nominal_aux(nullptr);
613 xAOD::MuonContainer* muons_nominal(nullptr);
614 xAOD::ShallowAuxContainer* muons_nominal_aux(nullptr);
615 xAOD::JetContainer* jets_nominal(nullptr);
616 xAOD::ShallowAuxContainer* jets_nominal_aux(nullptr);
617 xAOD::JetContainer* trkjets_nominal(nullptr);
618 xAOD::ShallowAuxContainer* trkjets_nominal_aux(nullptr);
619 xAOD::JetContainer* fatjets_nominal(nullptr);
620 xAOD::ShallowAuxContainer* fatjets_nominal_aux(nullptr);
621 xAOD::TauJetContainer* taus_nominal(nullptr);
622 xAOD::ShallowAuxContainer* taus_nominal_aux(nullptr);
627
628 // ====================================================================================================
629 // Get the nominal object containers from the event
630 // Electrons
631 if (slices["ele"]) {
632 ANA_MSG_DEBUG( "Nominal electron step" );
633 ANA_CHECK( objTool.GetElectrons(electrons_nominal, electrons_nominal_aux, true, isPHYSLite?"AnalysisElectrons":"Electrons") );
634 ANA_MSG_DEBUG( electrons_nominal->size() << " electrons");
635
636 for (const auto& electron : *electrons_nominal){
637 if (debug>0 && entry<10) {
638 bool accepted=false;
639 bool idok = electron->passSelection(accepted, "passBaseID");
640 if(idok) ANA_MSG_DEBUG("Electron Baseline ID Decision : " << accepted );
641 else ANA_MSG_DEBUG("Electron Baseline ID Decision not available " );
642 }
643 }
644 }
645
646 // Photons
647 if( slices["pho"] && stream.find("SUSY12")==std::string::npos) {
648 ANA_MSG_DEBUG( "Nominal photon step" );
649 ANA_CHECK( objTool.GetPhotons(photons_nominal,photons_nominal_aux, true, isPHYSLite?"AnalysisPhotons":"Photons") );
650 ANA_MSG_DEBUG( photons_nominal->size() << " photons");
651 }
652
653 // Muons
654 if (slices["mu"]) {
655 ANA_MSG_DEBUG( "Nominal muon step" );
656 ANA_CHECK( objTool.GetMuons(muons_nominal, muons_nominal_aux, true, isPHYSLite?"AnalysisMuons":"Muons") );
657 ANA_MSG_DEBUG( muons_nominal->size() << " muons");
658
659 // check HighPt muons (if required)
660 for (const auto& muon : *muons_nominal){
661 if (debug>0 && entry<10){
662 ANA_MSG_DEBUG("--------------------------------------" );
663 ANA_MSG_DEBUG("Muon pt = " << muon->pt()*0.001 << " , "
664 << "baseline = " << (int)ST::acc_baseline(*muon) << " ,"
665 << "bad = " << (int)ST::acc_bad(*muon) << " ,"
666 << "IsHighPt(deco) = " << (int)ST::acc_passedHighPtCuts(*muon) << " , "
667 << "IsHighPt(only) = " << (int)objTool.IsHighPtMuon(*muon) );
668 }
669 }
670 }
671
672 // Jets
673 if (slices["jet"]) {
674 ANA_MSG_DEBUG( "Nominal jet step" );
675 ANA_CHECK( objTool.GetJets(jets_nominal, jets_nominal_aux, true, isPHYSLite?"AnalysisJets":"") );
676 ANA_MSG_DEBUG( jets_nominal->size() << " jets");
677 }
678
679 // TrackJets
680 const xAOD::JetContainer* TJC = nullptr;
681 if (slices["tjet"] && hasTrkJets) {
682 ANA_MSG_DEBUG( "Nominal track jet step" );
683 if( event.retrieve(TJC, TrkJetCollection).isSuccess() ){
684 ANA_CHECK(objTool.GetTrackJets(trkjets_nominal, trkjets_nominal_aux));
685 ANA_MSG_DEBUG( trkjets_nominal->size() << " track jets");
686 } else {
687 ANA_MSG_ERROR("TrackJet collection " << TrkJetCollection.c_str() << " not available in input file. Please check!");
688 return 1;
689 }
690 }
691
692 // FatJets
693 const xAOD::JetContainer* FJC = nullptr;
694 if(slices["fjet"] && hasFatJets) { // stream.Contains("SUSY10") || stream.Contains("PHYSVAL")){
695 ANA_MSG_DEBUG( "Nominal fat jet step, collection: " << FatJetCollection );
696 if( event.retrieve(FJC, FatJetCollection).isSuccess() ){
697 ANA_CHECK( objTool.GetFatJets(fatjets_nominal, fatjets_nominal_aux, true, "", true) );
698 ANA_MSG_DEBUG( fatjets_nominal->size() << " large R jets");
699 if (debug>0 && entry < 10) {
700 for (const auto& fatjet : *fatjets_nominal) {
701 ANA_MSG_INFO( " FatJet pt = " << fatjet->pt()*0.001 << ", Wtag = " << ST::acc_wtagged(*fatjet) << ", Ztag = " << ST::acc_ztagged(*fatjet) );
702 }
703 }
704 } else {
705 ANA_MSG_ERROR("LargeR jet collection " << FatJetCollection.c_str() << " not available in input file. Please check!");
706 return 1;
707 }
708 }
709
710 // Taus
711 if(slices["tau"]) {
712 ANA_MSG_DEBUG( "Nominal tau step" );
713 ANA_CHECK( objTool.GetTaus(taus_nominal,taus_nominal_aux, true, isPHYSLite?"AnalysisTauJets":"TauJets") );
714 ANA_MSG_DEBUG( taus_nominal->size() << " taus");
715 }
716
717 // MET Trigger
718 bool passMETtrig = objTool.IsMETTrigPassed();
719 ANA_MSG_DEBUG( "Pass MET trigger " << passMETtrig);
720
721 // MET
722 metcst_nominal->setStore(metcst_nominal_aux);
723 metcst_nominal->reserve(10);
724 double metsig_cst (0.);
725 mettst_nominal->setStore(mettst_nominal_aux);
726 mettst_nominal->reserve(10);
727 double metsig_tst (0.);
728
729
730 // ============================================================================================
731 // Set up the event weights
732 // Base should include all weights that do not depend on individual objects
733 double base_event_weight(1.);
734 if (!isData){
735 base_event_weight *= ei->mcEventWeight();
736 //Check for the new Sherpa 2.2 Reweighting function
737 if(debug>0 && entry < 5){
738 float RW_sh22 = objTool.getSherpaVjetsNjetsWeight("AntiKt4TruthWZDressedJets");
739 Info(APP_NAME , "--- SHERPA2.2 REWEIGHTING : %f", RW_sh22);
740 }
741 }
742
743 // ============================================================================================
744 // Nominal weights
745 // Additionally define a nominal weight for each object type
746 double elecSF_nominal(1.);
747 double muonSF_nominal(1.);
748 //double tauSF_nominal(1.);
749 double btagSF_nominal(1.);
750 double btagSF_trkJet_nominal(1.);
751
752 // ====================
753 bool isNominal(true);
754 isys = 0;
755 // Now loop over all the systematic variations
756 for (const auto& sysInfo : systInfoList) {
757 const CP::SystematicSet& sys = sysInfo.systset;
758 ANA_MSG_DEBUG(">>>> Working on variation: \"" <<(sys.name()).c_str() << "\" <<<<<<" );
759
760 size_t icut = 0;
761 // log all events
762 elcuts[isys][icut] += 1;
763 mucuts[isys][icut] += 1;
764 ++icut;
765
766 // does the event pass the GRL + Cleaning?
767 if (!(eventPassesGRL && eventPassesCleaning)) {++isys; continue;}
768 elcuts[isys][icut] += 1;
769 mucuts[isys][icut] += 1;
770 ++icut;
771
772 // Apply TileTrip
773 if (!eventPassesTileTrip) {++isys; continue;}
774 elcuts[isys][icut] += 1;
775 mucuts[isys][icut] += 1;
776 ++icut;
777
778 if (debug>0 && entry==0) {
779 // Testing trigger
780 std::vector<std::string> trigItem = {"HLT_e26_lhtight_nod0_ivarloose","HLT_mu26_ivarmedium","HLT_mu50","HLT_xe100","HLT_noalg_.*"}; // Trigger for Run 2
781 if (isRun3) trigItem = {"HLT_e26_lhtight_ivarloose_L1EM22VHI","HLT_e26_lhtight_ivarloose_L1eEM26M","HLT_mu24_ivarmedium_L1MU14FCH","HLT_mu50_L1MU14FCH","HLT_xe100","HLT_noalg_.*"}; // Trigger for Run 3
782 for (int it = 0; it < (int) trigItem.size(); it++) {
783 bool passed = objTool.IsTrigPassed(trigItem[it]);
784 float prescale = objTool.GetTrigPrescale(trigItem[it]);
785 ANA_MSG_DEBUG( "Pass " << trigItem[it].c_str() << " trigger? " << (int)passed << ", prescale " << prescale );
786 //
787 // example of more sophisticated trigger access
788 const Trig::ChainGroup* cg = objTool.GetTrigChainGroup(trigItem[it]);
789 bool cg_passed = cg->isPassed();
790 float cg_prescale = cg->getPrescale();
791 ANA_MSG_DEBUG( "ChainGroup " << trigItem[it].c_str() << ": passing trigger? " << (int)cg_passed << ", prescale " << cg_prescale );
792 for (const auto& cg_trig : cg->getListOfTriggers()) {
793 ANA_MSG_DEBUG("\t\t includes trigger " << cg_trig.c_str() );
794 }
795 }
796 }
797
798 // Trigger (coming soon...)
799 if (!eventPassesTrigger) {++isys; continue;}
800 elcuts[isys][icut] += 1;
801 mucuts[isys][icut] += 1;
802 ++icut;
803
804 // ====================================================================================================
805 // Object containers - systematics
806
807 // Generic pointers for either nominal or systematics copy
808 xAOD::ElectronContainer* electrons(electrons_nominal);
809 xAOD::PhotonContainer* photons(photons_nominal);
810 xAOD::MuonContainer* muons(muons_nominal);
811 xAOD::JetContainer* jets(jets_nominal);
812 xAOD::JetContainer* trkjets(trkjets_nominal);
813 xAOD::TauJetContainer* taus(taus_nominal);
814 xAOD::MissingETContainer* metcst(metcst_nominal);
815 xAOD::MissingETContainer* mettst(mettst_nominal);
816 xAOD::MissingETAuxContainer* metcst_aux(metcst_nominal_aux);
817 xAOD::MissingETAuxContainer* mettst_aux(mettst_nominal_aux);
818
820
821
822 // Tell the SUSYObjDef_xAOD which variation to apply
823 if (objTool.applySystematicVariation(sys) != StatusCode::SUCCESS) {
824 ANA_MSG_INFO( "Cannot configure SUSYTools for systematic var. " << (sys.name()).c_str() );
825 } else {
826 ANA_MSG_DEBUG( "Variation " << (sys.name()).c_str() << " configured...");
827 }
828 if (sysInfo.affectsKinematics || sysInfo.affectsWeights) isNominal = false;
829
830 // If nominal, compute the nominal weight, otherwise recompute the weight
831 double event_weight = base_event_weight;
832
833 // If necessary (kinematics affected), make a shallow copy with the variation applied
834 bool syst_affectsElectrons = ST::testAffectsObject(xAOD::Type::Electron, sysInfo.affectsType);
835 bool syst_affectsMuons = ST::testAffectsObject(xAOD::Type::Muon, sysInfo.affectsType);
836 bool syst_affectsTaus = ST::testAffectsObject(xAOD::Type::Tau, sysInfo.affectsType);
837 bool syst_affectsPhotons = ST::testAffectsObject(xAOD::Type::Photon, sysInfo.affectsType);
838 bool syst_affectsJets = ST::testAffectsObject(xAOD::Type::Jet, sysInfo.affectsType);
839 bool syst_affectsBTag = ST::testAffectsObject(xAOD::Type::BTag, sysInfo.affectsType);
840 //bool syst_affectsMET = ST::testAffectsObject(xAOD::Type::MissingET, sysInfo.affectsType);
841
842
843 if (sysInfo.affectsKinematics) {
844 if (slices["ele"] && syst_affectsElectrons) {
845 xAOD::ElectronContainer* electrons_syst(nullptr);
846 xAOD::ShallowAuxContainer* electrons_syst_aux(nullptr);
847 ANA_CHECK( objTool.GetElectrons(electrons_syst, electrons_syst_aux, true, isPHYSLite?"AnalysisElectrons":"Electrons") );
848 electrons = electrons_syst;
849 }
850
851 if (slices["mu"] && syst_affectsMuons) {
852 xAOD::MuonContainer* muons_syst(nullptr);
853 xAOD::ShallowAuxContainer* muons_syst_aux(nullptr);
854 ANA_CHECK( objTool.GetMuons(muons_syst, muons_syst_aux, true, isPHYSLite?"AnalysisMuons":"Muons") );
855 muons = muons_syst;
856 }
857
858 if(slices["tau"] && syst_affectsTaus) {
859 xAOD::TauJetContainer* taus_syst(nullptr);
860 xAOD::ShallowAuxContainer* taus_syst_aux(nullptr);
861 ANA_CHECK( objTool.GetTaus(taus_syst,taus_syst_aux, true, isPHYSLite?"AnalysisTauJets":"TauJets") );
862 taus = taus_syst;
863 }
864
865 if(slices["pho"] && syst_affectsPhotons) {
866 xAOD::PhotonContainer* photons_syst(nullptr);
867 xAOD::ShallowAuxContainer* photons_syst_aux(nullptr);
868 ANA_CHECK( objTool.GetPhotons(photons_syst,photons_syst_aux, true, isPHYSLite?"AnalysisPhotons":"Photons") );
869 photons = photons_syst;
870 }
871
872 if (slices["jet"] && syst_affectsJets) {
873 xAOD::JetContainer* jets_syst(nullptr);
874 xAOD::ShallowAuxContainer* jets_syst_aux(nullptr);
875 ANA_CHECK( objTool.GetJetsSyst(*jets_nominal, jets_syst, jets_syst_aux, true, isPHYSLite?"AnalysisJets":"") );
876 jets = jets_syst;
877 }
878
879 if (slices["btag"] && syst_affectsBTag) {
880 xAOD::JetContainer* trkjets_syst(nullptr);
881 xAOD::ShallowAuxContainer* trkjets_syst_aux(nullptr);
882 ANA_CHECK( objTool.GetTrackJets(trkjets_syst, trkjets_syst_aux) );
883 trkjets = trkjets_syst;
884 }
885
890 if (slices["met"]) {
891 metcst_syst->setStore(metcst_syst_aux);
892 mettst_syst->setStore(mettst_syst_aux);
893 metcst_nominal->reserve(10);
894 metcst_nominal->reserve(10);
895
896 metcst = metcst_syst;
897 mettst = mettst_syst;
898 metcst_aux = metcst_syst_aux;
899 mettst_aux = mettst_syst_aux;
900 }
901 }
902
903
904 // *************** ************************ *****************
905 // *************** Now start processing the event *****************
906 // *************** ************************ *****************
907
908 // Electrons
909 if (slices["ele"] && (isNominal || (sysInfo.affectsKinematics && syst_affectsElectrons))) {
910 for (const auto& el : *electrons) {
911 //objTool.IsSignalElectron( *el ) ; // TODO: check that this should be removed /CO
912
913 if (!isData) {
915 if (truthEle) {
916 ANA_MSG_DEBUG( " Truth Electron pt " << truthEle->pt() << " eta " << truthEle->eta() );
917 ANA_MSG_DEBUG( " IsPrompt() = " << objTool.isPrompt(el) );
918 } else { ANA_MSG_DEBUG( " Truth Electron not found" ); }
919 }
920 }
921 }
922
923 // Muons
924 if (slices["mu"] && (isNominal || (sysInfo.affectsKinematics && syst_affectsMuons))) {
925 for (const auto& mu : *muons) {
926 // TODO: check that these should be removed too /CO
927 //objTool.IsSignalMuon( *mu ) ;
928 //objTool.IsCosmicMuon( *mu ) ;
929
930 if (!isData) {
931 // Example to access MC type/origin
932 int muonTruthType = 0;
933 int muonTruthOrigin = 0;
934 const xAOD::TrackParticle* trackParticle = mu->primaryTrackParticle();
935 if (trackParticle) {
936 if (ST::acc_truthType.isAvailable(*trackParticle)) muonTruthType = ST::acc_truthType(*trackParticle);
937 if (ST::acc_truthOrigin.isAvailable(*trackParticle)) muonTruthOrigin = ST::acc_truthOrigin(*trackParticle);
938 const xAOD::TruthParticle* truthMu = xAOD::TruthHelpers::getTruthParticle(*trackParticle);
939 if (truthMu) {
940 ANA_MSG_DEBUG( " Truth Muon pt " << truthMu->pt() << " eta " << truthMu->eta() );
941 ANA_MSG_DEBUG( " type " << muonTruthType << " origin " << muonTruthOrigin );
942 } else { ANA_MSG_DEBUG( "Truth Muon not found" ); }
943 }
944 }
945 }
946 }
947
948 // Jets
949 if (slices["jet"] && (isNominal || (sysInfo.affectsKinematics && syst_affectsJets))) {
950 for (const auto& jet : *jets) {
951 objTool.IsBJet( *jet) ;
952 }
953 }
954
955 // Taus
956 if (slices["tau"] && (isNominal || (sysInfo.affectsKinematics && syst_affectsTaus))) {
957 for(const auto& tau : *taus){
958 if (!isData){
959 const xAOD::TruthParticle* truthTau = T2MT->getTruth(*tau);
960 if (truthTau){
961 ANA_MSG_DEBUG("Tau was matched to a truth particle, which has a charge of "
962 << static_cast<int>(truthTau->charge()));
963 } else { ANA_MSG_DEBUG( "Tau was not matched to truth" ); }
964 }
965 }
966 }
967
968 // Overlap Removal
969 ANA_MSG_DEBUG( "Overlap removal" );
970 if (isNominal || (sysInfo.affectsKinematics && (syst_affectsElectrons || syst_affectsMuons || syst_affectsJets))) {
971 if(stream.find("SUSY3")!=std::string::npos) { ANA_CHECK( objTool.OverlapRemoval(electrons, muons, jets, 0, taus) ); }
972 else if(stream.find("SUSY10")!=std::string::npos) { ANA_CHECK( objTool.OverlapRemoval(electrons, muons, jets, 0, 0, fatjets_nominal) ); }
973 else{ ANA_CHECK( objTool.OverlapRemoval(electrons, muons, jets, photons) ); }
974 }
975
976 // Jets - get goodjets
977 if (slices["jet"]) {
978 ANA_MSG_DEBUG("GoodJets?");
979 for (const auto& jet : *jets) {
980 if (ST::acc_baseline(*jet) == 1 &&
981 ST::acc_passOR(*jet) == 1 &&
982 ST::acc_signal(*jet) == 1 &&
983 jet->pt() > 20000. && ( std::abs(jet->eta()) < 2.5) ) {
984 goodJets->push_back(jet);
985 }
986 }
987 }
988
989 if (slices["met"] && (isNominal || sysInfo.affectsKinematics)) {
990 ANA_MSG_DEBUG( "MET step" );
991 if(stream.find("SUSY3")!=std::string::npos){
992 if (debug>0) Info(APP_NAME, "METCST?");
993 ANA_CHECK( objTool.GetMET(*metcst, jets, electrons, muons, photons, taus, false, false) ); // CST=false, JVT=false (No JVT if you use CST)
994 if (debug>0) Info(APP_NAME, "METSignificance CST?");
995 ANA_CHECK( objTool.GetMETSig(*metcst, metsig_cst, false, false) );
996
997 if (debug>0) Info(APP_NAME, "METTST?");
998 ANA_CHECK( objTool.GetMET(*mettst, jets, electrons, muons, photons, taus, true, true) );
999 if (debug>0) Info(APP_NAME, "METSignificance TST?");
1000 ANA_CHECK( objTool.GetMETSig(*mettst, metsig_tst, true, true) );
1001 }
1002 else{
1003 if (debug>0) Info(APP_NAME, "METCST?");
1004 ANA_CHECK( objTool.GetMET(*metcst, jets, electrons, muons, photons, 0, false, false) ); // CST=false, JVT=false (No JVT if you use CST)
1005 if (debug>0) Info(APP_NAME, "METSignificance CST?");
1006 ANA_CHECK( objTool.GetMETSig(*metcst, metsig_cst, false, false) );
1007
1008 if (debug>0) Info(APP_NAME, "METTST?");
1009 ANA_CHECK( objTool.GetMET(*mettst, jets, electrons, muons, photons, 0, true, true) );
1010 if (debug>0) Info(APP_NAME, "METSignificance TST?");
1011 ANA_CHECK( objTool.GetMETSig(*mettst, metsig_tst, true, true) );
1012 }
1013 if (debug>0) Info(APP_NAME, "MET done");
1014 }
1015
1016 // ========================================
1017 // Electrons
1018 float elecSF = 1.0;
1019 int el_idx[nSel] = {0};
1020 if (slices["ele"]) {
1021 ANA_MSG_DEBUG( "Electron step - selection" );
1022 for (const auto& el : *electrons) {
1023 if ( ST::acc_passOR(*el) == 0 ) {
1024 el_idx[passOR]++;
1025 continue;
1026 }
1027 if ( ST::acc_baseline(*el) == 1 ) {
1028 el_idx[baseline]++;
1029 }
1030 if ( ST::acc_signal(*el) == 1 ) {
1031 el_idx[signallep]++;
1032 if ( el->pt() > 20000. ) {
1033 el_idx[goodpt]++;
1034
1035 bool passTM=false;
1036 for(const auto& t : el_triggers){
1037 passTM |= (objTool.IsTrigPassed(t) && objTool.IsTrigMatched(el, t));
1038 }
1039 if(passTM)
1040 el_idx[trgmatch]++;
1041
1042 //check ChID BDT
1043 // static const SG::ConstAccessor<char> passChIDAcc("passChID");
1044 // static const SG::ConstAccessor<double> ecisBDTAcc("ecisBDT");
1045 //Info(APP_NAME, "electron passChID : %d , BDT : %.3f", passChIDAcc(*el), ecisBDTAcc(*el));
1046 }
1047 }
1048 }
1049 if (isNominal || syst_affectsElectrons) {
1050 if(!isData) elecSF = objTool.GetTotalElectronSF(*electrons);
1051 }
1052
1053 if (isNominal) {elecSF_nominal = elecSF;}
1054 else if (!syst_affectsElectrons) {elecSF = elecSF_nominal;}
1055 event_weight *= elecSF;
1056 }
1057
1058 // ====================
1059 // Muons
1060 float muonSF = 1.0;
1061 int mu_idx[nSel] = {0};
1062 bool passTMtest = false;
1063
1064 TString muTrig2015 = "HLT_mu20_iloose_L1MU15_OR_HLT_mu50"; //"HLT_mu18_mu8noL1"; //"HLT_mu20_iloose_L1MU15_OR_HLT_mu50";
1065 TString muTrig2016 = "HLT_mu26_ivarmedium_OR_HLT_mu50";
1066 TString muTrig2017 = "HLT_mu26_ivarmedium_OR_HLT_mu50";
1067 TString muTrig2022 = "HLT_mu24_ivarmedium_L1MU14FCH_OR_HLT_mu50_L1MU14FCH";
1068
1069 std::vector<std::string> muTrigs2015 = {"HLT_mu20_iloose_L1MU15","HLT_mu50"}; //"HLT_mu18_mu8noL1"; //"HLT_mu20_iloose_L1MU15_OR_HLT_mu50";
1070 std::vector<std::string> muTrigs2016 = {"HLT_mu26_ivarmedium","HLT_mu50"};
1071 std::vector<std::string> muTrigs2017 = {"HLT_mu26_ivarmedium","HLT_mu50"};
1072 std::vector<std::string> muTrigs2022 = {"HLT_mu24_ivarmedium_L1MU14FCH","HLT_mu50_L1MU14FCH"};
1073
1074 if (slices["mu"]) {
1075 ANA_MSG_DEBUG( "Muon step - selection" );
1076 for (const auto& mu : *muons) {
1077 if ( ST::acc_passOR(*mu) == 0 ) {
1078 mu_idx[passOR]++;
1079 continue;
1080 }
1081 if ( ST::acc_baseline(*mu) == 1 ) {
1082 mu_idx[baseline]++;
1083 if ( ST::acc_cosmic(*mu) == 1 ) {
1084 mu_idx[cosmic]++;
1085 }
1086 }
1087 if ( ST::acc_signal(*mu) == 1 ) {
1088 mu_idx[signallep]++;
1089 if ( mu->pt() > 20000. ) {
1090 mu_idx[goodpt]++;
1091
1092 bool passTM=false;
1093 for(const auto& t : mu_triggers){
1094 if (objTool.IsTrigPassed(t)) ANA_MSG_DEBUG("Pass " << t << " : " << (int)objTool.IsTrigMatched(mu, t));
1095 else ANA_MSG_DEBUG("Pass " << t << " : " << 0);
1096 passTM |= (objTool.IsTrigPassed(t) && objTool.IsTrigMatched(mu, t));
1097 }
1098 if(passTM)
1099 mu_idx[trgmatch]++;
1100
1101 }
1102
1103 std::vector<std::string> my_mu_trigs;
1104 if(!isData){
1105 if(objTool.treatAsYear()==2015)
1106 my_mu_trigs=muTrigs2015;
1107 else if(objTool.treatAsYear()==2016)
1108 my_mu_trigs=muTrigs2016;
1109 else if(objTool.treatAsYear()==2017 || objTool.treatAsYear()==2018)
1110 my_mu_trigs=muTrigs2017;
1111 else
1112 my_mu_trigs=muTrigs2022;
1113 }
1114 else{
1115 my_mu_trigs=muTrigs2016;
1116 }
1117 for (auto& t : my_mu_trigs) passTMtest |= (objTool.IsTrigPassed(t) && objTool.IsTrigMatched(mu,t));
1118 }
1119 }
1120 }
1121
1122
1123 // ========================================
1124 // Photons
1125 if (slices["pho"]) {
1126 ANA_MSG_DEBUG( "Photon step - selection" );
1127 int n_SignalPhotons = 0;
1128 for (const auto& y : *photons) {
1129 if ( ST::acc_passOR(*y) && ST::acc_signal(*y)) {
1130 n_SignalPhotons++;
1131 ANA_MSG_DEBUG( "Photon pt = "<< y->pt()*1e-3
1132 << ", idSF = " << objTool.GetSignalPhotonSF(*y,true,false,false)
1133 << ", isoSF = " << objTool.GetSignalPhotonSF(*y,false,true,false)
1134 << ", trigSF = " << objTool.GetSignalPhotonSF(*y,false,false,true)
1135 );
1136 }
1137 }
1138 if(n_SignalPhotons>0) ANA_MSG_DEBUG( "Total Event photon SF = " << objTool.GetTotalPhotonSF(*photons, true, true, true));
1139 }
1140
1141 // ====================
1142 // Check for combined e-mu triggers
1143 bool comb_trig_check = false;
1144
1145 if (slices["ele"] && slices["mu"] && comb_trig_check) {
1146 ANA_MSG_DEBUG( "Electron/Muon step - trigger" );
1147 if (objTool.IsTrigPassed("HLT_2e12_lhloose_L12EM10VH"))
1148 ANA_MSG_DEBUG(" 2e12_lhloose_L12EM10VH SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal, "diLepton"));
1149 if (objTool.IsTrigPassed("HLT_e17_lhloose_mu14"))
1150 ANA_MSG_DEBUG("e17_lhloose_mu14 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal, "diLepton") );
1151 if (objTool.IsTrigPassed("HLT_2e17_lhvloose_nod0"))
1152 ANA_MSG_DEBUG(" 2e17_lhvloose_nod0 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal, "diLepton") );
1153 if (objTool.IsTrigPassed("HLT_2e17_lhvloose_nod0_L12EM15VHI"))
1154 ANA_MSG_DEBUG(" 2e17_lhvloose_nod0_L12EM15VHI SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal, "diLepton") );
1155 if (objTool.IsTrigPassed("HLT_e17_lhloose_nod0_mu14"))
1156 ANA_MSG_DEBUG(" e17_lhloose_nod0_mu14 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal, "diLepton") );
1157 if (objTool.IsTrigPassed("HLT_e7_lhmedium_mu24"))
1158 ANA_MSG_DEBUG(" e7_lhmedium_mu24 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal, "diLepton") );
1159 if (objTool.IsTrigPassed("HLT_e7_lhmedium_nod0_mu24"))
1160 ANA_MSG_DEBUG(" e7_lhmedium_nod0_mu24 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal, "diLepton") );
1161 if (objTool.IsTrigPassed("HLT_mu18_mu8noL1"))
1162 ANA_MSG_DEBUG(" mu18_mu8noL1 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal, "diLepton") );
1163 if (objTool.IsTrigPassed("HLT_mu20_mu8noL1"))
1164 ANA_MSG_DEBUG(" mu20_mu8noL1 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal, "diLepton") );
1165 if (objTool.IsTrigPassed("HLT_2mu10"))
1166 ANA_MSG_DEBUG(" 2mu10 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal, "diLepton") );
1167 if (objTool.IsTrigPassed("HLT_2mu14"))
1168 ANA_MSG_DEBUG(" 2mu14 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal, "diLepton") );
1169 if (objTool.IsTrigPassed("HLT_2e12_lhloose_mu10"))
1170 ANA_MSG_DEBUG(" 2e12_lhloose_mu10 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal, "multiLepton") );
1171 if (objTool.IsTrigPassed("HLT_2e12_lhloose_nod0_mu10"))
1172 ANA_MSG_DEBUG(" 2e12_lhloose_nod0_mu10 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal, "multiLepton") );
1173 if (objTool.IsTrigPassed("HLT_e12_lhloose_2mu10"))
1174 ANA_MSG_DEBUG(" e12_lhloose_2mu10 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal, "multiLepton") );
1175 if (objTool.IsTrigPassed("HLT_e12_lhloose_nod0_2mu10"))
1176 ANA_MSG_DEBUG(" e12_lhloose_nod0_2mu10 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal, "multiLepton") );
1177 if (objTool.IsTrigPassed("HLT_3mu6"))
1178 ANA_MSG_DEBUG(" 3mu6 SF: " << objTool.GetTriggerGlobalEfficiencySF(*electrons_nominal, *muons_nominal, "multiLepton") );
1179 }
1180
1181 if (slices["mu"] && ((!isData && isNominal) || syst_affectsMuons)) {
1182 ANA_MSG_DEBUG( "Muon step - trigger" );
1183 if(passTMtest || 1){ //objTool.IsTrigPassed(muTrig.ReplaceAll("_OR_",",").Data())){
1184 ANA_MSG_DEBUG("MUON BEFORE SF = " << muonSF << " " << objTool.treatAsYear() << " " << objTool.GetRandomRunNumber() << " " << objTool.GetPileupWeight() );
1185 if(objTool.treatAsYear()==2015) muonSF = objTool.GetTotalMuonSF(*muons, true, true, muTrig2015.Data());
1186 else if(objTool.treatAsYear()==2016) muonSF = objTool.GetTotalMuonSF(*muons, true, true, muTrig2016.Data());
1187 else if(objTool.treatAsYear()==2017) muonSF = objTool.GetTotalMuonSF(*muons, true, true, muTrig2017.Data());
1188 else if(objTool.treatAsYear()==2018) muonSF = objTool.GetTotalMuonSF(*muons, true, true, muTrig2017.Data());
1189 else if(objTool.treatAsYear()==2022) muonSF = objTool.GetTotalMuonSF(*muons, true, true, muTrig2022.Data());
1190 ANA_MSG_DEBUG("MUON AFTER SF = " << muonSF << " " << objTool.treatAsYear() << " " << objTool.GetRandomRunNumber() << " " << objTool.GetPileupWeight() );
1191 }
1192 }
1193
1194 if (slices["mu"]) {
1195 if (isNominal) { muonSF_nominal = muonSF; }
1196 else if (!syst_affectsMuons) { muonSF = muonSF_nominal; }
1197 event_weight *= muonSF;
1198 }
1199
1200 // ====================
1201 // Taus
1202 if (slices["tau"] && isNominal && !isData && stream.find("SUSY3")!=std::string::npos) {
1203 ANA_MSG_DEBUG( "Tau step - SF" );
1204 if (entry<10){
1205 // CP::SystematicSet testSet("TAUS_TRUEHADTAU_EFF_TRIGGER_TOTAL2016__1up");
1206 // testSet.insert( CP::SystematicVariation("TAUS_TRUEHADTAU_EFF_TRIGGER_TOTAL2016", 1) );
1207
1208 // CP::SystematicSet testSet("TAUS_TRUEHADTAU_EFF_TRIGGER_SYST2015__1up");
1209 // testSet.insert( CP::SystematicVariation("TAUS_TRUEHADTAU_EFF_TRIGGER_SYST2015", 1) );
1210 // if(objTool.applySystematicVariation(testSet) != StatusCode::SUCCESS){
1211 // Error( APP_NAME, "Problems with tau trig eff systematic settings!");
1212 // }
1213
1214 for (const auto& tau : *taus) {
1215 ANA_MSG_INFO( "Tau pt = "<< tau->pt()*1e-3
1216 << ", idSF = " << objTool.GetSignalTauSF(*tau,true,false,"tau125_medium1_tracktwo")
1217 << ", trigSF = " << objTool.GetSignalTauSF(*tau,false,true,"tau125_medium1_tracktwo")
1218 << ", totSF = " << objTool.GetSignalTauSF(*tau,true,true,"tau125_medium1_tracktwo")
1219 );
1220 }
1221 ANA_MSG_INFO( "Total Event Tau SF = " << objTool.GetTotalTauSF(*taus, true, true, "tau125_medium1_tracktwo") );
1222 }
1223 }
1224
1225 ANA_MSG_DEBUG( "Lepton SF done" );
1226
1227 // ====================
1228 // Jets
1229 int jet_idx[nSel] = {0};
1230 if (slices["jet"]) {
1231 ANA_MSG_DEBUG( "Jet step - selection" );
1232 for (const auto& jet : *goodJets) {
1233 if ( ST::acc_bad(*jet) == 1 )
1234 jet_idx[bad]++;
1235 if ( ST::acc_passOR(*jet) == 0 ) {
1236 jet_idx[passOR]++;
1237 continue;
1238 }
1239 if ( ST::acc_baseline(*jet) == 1 ) {
1240 jet_idx[baseline]++;
1241 if ( jet->pt() > 50000. )
1242 jet_idx[goodpt]++;
1243 }
1244 if ( ST::acc_bjet(*jet) == 1 )
1245 jet_idx[btagged]++;
1246 }
1247 }
1248
1249 // compute b-tagging SF
1250 float btagSF(1.);
1251 if (slices["jet"] && slices["btag"]) {
1252 ANA_MSG_DEBUG( "(b)Jet step - selection" );
1253 if (!isData) {
1254 if (isNominal) {btagSF = btagSF_nominal = objTool.BtagSF(jets);}
1255 else if (syst_affectsBTag || (sysInfo.affectsKinematics && syst_affectsJets)) {btagSF = objTool.BtagSF(jets);}
1256 else {btagSF = btagSF_nominal;}
1257 }
1258 event_weight *= btagSF;
1259
1260 // checking BtagSF
1261 if ( stream.find("SUSY1")!=std::string::npos ) { // PHYSVAL doesn't contain truthlabel for VR jets
1262 float btagSF_trkJet(1.);
1263 if (!isData) {
1264 if (isNominal) {btagSF_trkJet = btagSF_trkJet_nominal = objTool.BtagSF_trkJet(trkjets);}
1265 else if (syst_affectsBTag || (sysInfo.affectsKinematics && syst_affectsJets)) {btagSF_trkJet = objTool.BtagSF_trkJet(trkjets);}
1266 else {btagSF_trkJet = btagSF_trkJet_nominal;}
1267 }
1268 event_weight *= btagSF_trkJet;
1269 }
1270 }
1271
1272 ANA_MSG_DEBUG("Jet SF done");
1273
1274 // ====================
1275 // Cosmics
1276 if (slices["ele"] && slices["mu"] && mu_idx[cosmic] == 0 ) {
1277 elcuts[isys][icut] += 1;
1278 mucuts[isys][icut] += 1;
1279 ++icut;
1280
1281 bool passlep = (el_idx[baseline] + mu_idx[baseline]) == 1;
1282 if (passlep) {
1283 bool passel = el_idx[baseline] == 1;
1284 bool passmu = mu_idx[baseline] == 1;
1285 if (passel) elcuts[isys][icut] += 1;
1286 if (passmu) mucuts[isys][icut] += 1;
1287 ++icut;
1288
1289 passel = el_idx[signallep] == 1;
1290 passmu = mu_idx[signallep] == 1;
1291 if (passel) elcuts[isys][icut] += 1;
1292 if (passmu) mucuts[isys][icut] += 1;
1293 ++icut;
1294
1295 passel = el_idx[goodpt] == 1;
1296 passmu = mu_idx[goodpt] == 1;
1297 if (passel) elcuts[isys][icut] += 1;
1298 if (passmu) mucuts[isys][icut] += 1;
1299 ++icut;
1300
1301 passel = el_idx[trgmatch] == 1;
1302 passmu = mu_idx[trgmatch] == 1;
1303 if (passel) elcuts[isys][icut] += 1;
1304 if (passmu) mucuts[isys][icut] += 1;
1305 ++icut;
1306
1307 if (jet_idx[goodpt] >= 2) {
1308 if (passel) elcuts[isys][icut] += 1;
1309 if (passmu) mucuts[isys][icut] += 1;
1310 ++icut;
1311 } // good jets
1312 } // passlep
1313 } // cosmics
1314
1315 ANA_MSG_DEBUG("Lepton SF done");
1316 ANA_MSG_DEBUG("Final event weight = " << event_weight);
1317
1318 // Clean up the systematics copies
1319 if (sysInfo.affectsKinematics) {
1320 delete metcst;
1321 delete metcst_aux;
1322 delete mettst;
1323 delete mettst_aux;
1324 }
1325
1326 isNominal = false;
1327 ANA_MSG_DEBUG(">>>> Finished with variation: \"" <<(sys.name()).c_str() << "\" <<<<<<" );
1328
1329
1330 ++isys;
1331 }
1332
1333
1334 //Reset systematics settings for next event
1335 ANA_CHECK( objTool.resetSystematics());
1336
1337
1338 // The containers created by the shallow copy are owned by you. Remember to delete them.
1339 // In our case, all of these were put into the store
1340
1341 // store.print();
1342 store.clear();
1343
1344 // Close with a message:
1345 if (entry==0 || entry % period == 99) {
1346 Info( APP_NAME,
1347 "===>>> done processing event #%i, "
1348 "run #%i %i events processed so far <<<===",
1349 static_cast< int >( ei->eventNumber() ),
1350 static_cast< int >( ei->runNumber() ),
1351 static_cast< int >( entry + 1 ) );
1352 }
1353
1354
1355 }
1356
1357 m_clock0.Stop();
1358 m_clock2.Stop();
1359
1360 // CALLGRIND_TOGGLE_COLLECT;
1361 // CALLGRIND_DUMP_STATS;
1362 // ProfilerStop();
1363
1364 Info( APP_NAME,
1365 "Time per event: (CPU / WALL)\n"
1366 " Entire loop - %f / %f ms\n"
1367 " First event - %f / %f ms\n"
1368 " Excluding first event - %f / %f ms",
1369 m_clock0.CpuTime() * 1e3 / entries, m_clock0.RealTime() * 1e3 / entries,
1370 m_clock1.CpuTime() * 1e3, m_clock1.RealTime() * 1e3,
1371 m_clock2.CpuTime() * 1e3 / (entries - 1), m_clock2.RealTime() * 1e3 / (entries - 1));
1372
1373
1374 // Dump the cutflow:
1375 isys = 0;
1376 for (const auto& sysInfo : systInfoList) {
1377 const CP::SystematicSet& sys = sysInfo.systset;
1378 ANA_MSG_INFO( "-- Dummy Cutflow -- >>>> Variation " << sys.name().c_str() << " <<<<" );
1379 for (size_t icut = 0; icut < Ncuts; ++icut) {
1380 ANA_MSG_INFO( "Cut " << icut << "(" << cut_name[icut] << ")"
1381 << "-> el: " << elcuts[isys][icut] << ", mu: " << mucuts[isys][icut] );
1382 }
1383 ++isys;
1384 }
1385
1386 // Return gracefully:
1387 return 0;
1388}
#define APP_NAME
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_MSG_WARNING(xmsg)
Macro printing warning messages.
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
#define ANA_CHECK_SET_TYPE(TYPE)
set the type for ANA_CHECK to report failures
bool passed(DecisionID id, const DecisionIDContainer &)
checks if required decision ID is in the set of IDs in the container
static Double_t taus
const bool debug
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
const size_t Ncuts
const unsigned int nSel
std::map< std::string, std::string > getFileContainers(std::unique_ptr< TFile > &)
std::vector< std::string > getTokens(TString line, const TString &delim)
const char * cut_name[]
size_t size() const
Number of registered mappings.
#define y
#define x
static void enableFailure() noexcept
Class to wrap a set of SystematicVariations.
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
Helper class to provide constant type-safe access to aux data.
float kfactor(int id, int proc=0) const
float efficiency(int id, int proc=0) const
float xsectTimesEff(int id, int proc=0) const
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...
bool isPassed(unsigned int condition=TrigDefs::Physics) const
tells if chain group passed
std::vector< std::string > getListOfTriggers() const
an "initializing" ToolHandle for stand-alone applications
StatusCode setProperty(const std::string &name, T2 &&value)
StatusCode retrieve()
initialize the tool, will succeed if the tool was already initialized
void setTypeAndName(const std::string &typeAndName)
static IAsgTool * get(const std::string &name, bool silent=false)
Retrieve a tool by name.
Definition ToolStore.cxx:57
STL class.
double sumOfEventWeightsSquared() const
Get the sum-of-(event-weights-squared) that this CutBookkeeper has seen.
double sumOfEventWeights() const
Get the sum-of-event-weights that this CutBookkeeper has seen.
uint64_t nAcceptedEvents() const
Get the number of accepted events that this CutBookkeeper has seen.
uint32_t lumiBlock() const
The current event's luminosity block number.
@ Tile
The Tile calorimeter.
@ Core
Core flags describing the event.
@ LAr
The LAr calorimeter.
bool isEventFlagBitSet(EventFlagSubDet subDet, size_t bit) const
Check one particular bit of one particular sub-detector.
@ Error
The sub-detector issued an error.
uint32_t runNumber() const
The current event's run number.
uint32_t mcChannelNumber() const
The MC generator's channel number.
EventFlagErrorState errorState(EventFlagSubDet subDet) const
Get the error state for a particular sub-detector.
uint64_t eventNumber() const
The current event's event number.
float mcEventWeight(size_t i=0) const
The weight of one specific MC event used in the simulation.
Class creating a shallow copy of an existing auxiliary container.
Tool for accessing xAOD files outside of Athena.
@ kClassAccess
Access auxiliary data using the aux containers.
A relatively simple transient store for objects created in analysis.
Definition TStore.h:45
virtual double pt() const override final
The transverse momentum ( ) of the particle.
double charge() const
Physical charge.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:140
double entries
Definition listroot.cxx:49
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition Error.h:16
TestStore store
Definition TestStore.cxx:23
XAOD_AUXDATA_DEPRECATED bool isAvailable(const std::string &name, const std::string &clsname="") const
Check if an aux variable is available for reading.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
static const SG::ConstAccessor< char > acc_bad("bad")
static const SG::ConstAccessor< int > acc_ztagged("ztagged")
static const SG::ConstAccessor< int > acc_truthType("truthType")
static const SG::ConstAccessor< int > acc_truthOrigin("truthOrigin")
static const SG::ConstAccessor< char > acc_passedHighPtCuts("passedHighPtCuts")
static const SG::ConstAccessor< char > acc_signal("signal")
static const SG::ConstAccessor< char > acc_baseline("baseline")
static bool testAffectsObject(xAOD::Type::ObjectType type, unsigned int test)
static const SG::ConstAccessor< char > acc_bjet("bjet")
static const SG::ConstAccessor< int > acc_wtagged("wtagged")
static const SG::ConstAccessor< char > acc_cosmic("cosmic")
static const SG::ConstAccessor< char > acc_passOR("passOR")
@ Info
Definition ZDCMsg.h:20
@ Jet
The object is a jet.
Definition ObjectType.h:40
@ Photon
The object is a photon.
Definition ObjectType.h:47
@ Muon
The object is a muon.
Definition ObjectType.h:48
@ BTag
The object is a b-tagging object.
Definition ObjectType.h:60
@ Electron
The object is an electron.
Definition ObjectType.h:46
@ Tau
The object is a tau (jet).
Definition ObjectType.h:49
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any).
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
EventInfo_v1 EventInfo
Definition of the latest event info version.
@ Unknown
Track fitter not defined.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.
CutBookkeeper_v1 CutBookkeeper
Define the latest version of the CutBookkeeper class.
setBGCode setTAP setLVL2ErrorBits bool
MissingETAuxContainer_v1 MissingETAuxContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
TauJetContainer_v3 TauJetContainer
Definition of the current "taujet container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
CutBookkeeperContainer_v1 CutBookkeeperContainer
Define the latest version of the CutBookkeeperContainer class.
unsigned int affectsType
MsgStream & msg
Definition testRead.cxx:32

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 78 of file SUSYToolsTester.cxx.

78 { "All",
79 "GRL+Cleaning",
80 "TileTrip",
81 "Trigger",
82 "Cosmic veto",
83 "==1 baseline lepton",
84 "==1 signal lepton",
85 "lepton pT>20 GeV",
86 "trig. matched lepton",
87 "Njet(pT>50 GeV)>=2"
88};

◆ Ncuts

const size_t Ncuts = 10

Definition at line 77 of file SUSYToolsTester.cxx.

◆ nSel

const unsigned int nSel =8

Definition at line 91 of file SUSYToolsTester.cxx.