ATLAS Offline Software
Loading...
Searching...
No Matches
MuonTriggerSFRootCoreTest.cxx File Reference
#include <string>
#include <TFile.h>
#include <TError.h>
#include <TStopwatch.h>
#include <TString.h>
#include "xAODEventInfo/EventInfo.h"
#include "xAODMuon/MuonContainer.h"
#include "MuonEfficiencyCorrections/MuonTriggerScaleFactors.h"
#include "PATInterfaces/SystematicRegistry.h"
#include "PATInterfaces/SystematicsUtil.h"

Go to the source code of this file.

Classes

class  MuonTriggerSFTester

Macros

#define CHECK_CPSys(Arg)

Functions

CP::CorrectionCode getThreshold (Int_t &threshold, const std::string &trigger)
int main (int argc, char *argv[])

Variables

static const std::vector< std::string > qualities { "HighPt", "Tight", "Medium", "Loose", "LowPt" }
static const std::vector< std::string > binnings { "coarse", "fine" }
static const std::vector< std::string > types { "data", "mc" }

Macro Definition Documentation

◆ CHECK_CPSys

#define CHECK_CPSys ( Arg)
Value:
if (Arg.isFailure()){ \
Warning(#Arg,"Unsupported systematic (in line %i) ",__LINE__); \
}

Definition at line 34 of file MuonTriggerSFRootCoreTest.cxx.

34#define CHECK_CPSys(Arg) \
35 if (Arg.isFailure()){ \
36 Warning(#Arg,"Unsupported systematic (in line %i) ",__LINE__); \
37 }

Function Documentation

◆ getThreshold()

CP::CorrectionCode getThreshold ( Int_t & threshold,
const std::string & trigger )

Definition at line 44 of file MuonTriggerSFRootCoreTest.cxx.

44 {
45 std::size_t index = trigger.find("HLT_mu");
46 if (index != std::string::npos) {
47 std::string rawNumber = trigger.substr(index + 6);
48 if (!rawNumber.empty() && isdigit(rawNumber[0])) {
49 std::stringstream(rawNumber) >> threshold;
50 if (threshold < 10) threshold = 10000;
51 else threshold = (threshold + 1) * 1000;
53 }
54 }
56}
@ Error
Some error happened during the object correction.
@ Ok
The correction was done successfully.
Definition index.py:1

◆ main()

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

Definition at line 313 of file MuonTriggerSFRootCoreTest.cxx.

313 {
314
315 const char* APP_NAME = argv[0];
317 // Read the config provided by the user
318 const char* xAODFileName = "";
319 std::string customInputFolder = "";
320 std::string customFileName = "";
321 const char* nrOfEntries = "";
322 std::string trigger = "";
323 int year = -1;
324 std::string period = "";
325 for (int i = 1; i < argc - 1; i++) {
326 std::string arg = std::string(argv[i]);
327 if (arg == "-x") {
328 xAODFileName = argv[i + 1];
329 }
330 else if (arg == "-d")
331 customInputFolder = argv[i + 1];
332 else if (arg == "-f")
333 customFileName = argv[i + 1];
334 else if (arg == "-e")
335 nrOfEntries = argv[i + 1];
336 else if (arg == "-t")
337 trigger = argv[i + 1];
338 else if (arg == "-y")
339 year = atoi(argv[i + 1]);
340 else if (arg == "-p")
341 period = argv[i + 1];
342 }
343
344 bool error = false;
345 if (xAODFileName[0] == '\0') {
346 Error(APP_NAME, "xAOD file name missing!");
347 error = true;
348 }
349 if (trigger == "") {
350 Error(APP_NAME, "trigger missing!");
351 error = true;
352 }
353 if (error) {
354 Error(APP_NAME, " Usage: %s -x [xAOD file name] -y [year] -p [period] -t [trigger] -d [custom input folder] -f [custom file name] -e [number of events to process]", APP_NAME);
355 return 1;
356 }
357
359
360 Info(APP_NAME, "Opening file: %s", xAODFileName);
361 std::unique_ptr<TFile> ifile(TFile::Open(xAODFileName, "READ"));
362 if (!ifile.get()) {
363 Error(APP_NAME, " Unable to load xAOD input file");
364 return 1;
365 }
366
369 Info(APP_NAME, "Number of events in the file: %i", static_cast<int>(event.getEntries()));
370
371 // Decide how many events to run over:
372 int nrOfEntriesToRunOver = 1000;//event.getEntries();
373 if (!std::string(nrOfEntries).empty()) {
374 int e = atoll(nrOfEntries);
375 if (e < nrOfEntriesToRunOver) {
376 nrOfEntriesToRunOver = e;
377 }
378 }
379
380
381 MuonTriggerSFTester sfChecker(APP_NAME, trigger);
382 sfChecker.initialiseTools(customFileName, customInputFolder, year, period);
383 for(Long64_t entry = 0; entry < nrOfEntriesToRunOver; entry++) {
384 // Tell the object which entry to look at:
385 event.getEntry(entry);
386 sfChecker.processEvent(event, year, period);
387
388 }
389
390 Info(APP_NAME, "%i events successfully processed, %i warnings, %i errors detected.", nrOfEntriesToRunOver, sfChecker.m_warningsCount, sfChecker.m_errorsCount);
391 return 0;
392}
#define APP_NAME
#define RETURN_CHECK(CONTEXT, EXP)
Helper macro for checking return codes in a compact form in the code.
Definition ReturnCheck.h:26
static const Attributes_t empty
static void enableFailure() noexcept
Tool for accessing xAOD files outside of Athena.
@ kClassAccess
Access auxiliary data using the aux containers.
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
@ Info
Definition ZDCMsg.h:20
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition Init.cxx:31

Variable Documentation

◆ binnings

const std::vector<std::string> binnings { "coarse", "fine" }
static

Definition at line 40 of file MuonTriggerSFRootCoreTest.cxx.

40{ "coarse", "fine" };

◆ qualities

const std::vector<std::string> qualities { "HighPt", "Tight", "Medium", "Loose", "LowPt" }
static

Definition at line 39 of file MuonTriggerSFRootCoreTest.cxx.

39{ "HighPt", "Tight", "Medium", "Loose", "LowPt" };

◆ types

const std::vector<std::string> types { "data", "mc" }
static

Definition at line 41 of file MuonTriggerSFRootCoreTest.cxx.

41{ "data", "mc" };