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/ISystematicsTool.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 38 of file MuonTriggerSFRootCoreTest.cxx.

38#define CHECK_CPSys(Arg) \
39 if (Arg.isFailure()){ \
40 Warning(#Arg,"Unsupported systematic (in line %i) ",__LINE__); \
41 }

Function Documentation

◆ getThreshold()

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

Definition at line 48 of file MuonTriggerSFRootCoreTest.cxx.

48 {
49 std::size_t index = trigger.find("HLT_mu");
50 if (index != std::string::npos) {
51 std::string rawNumber = trigger.substr(index + 6);
52 if (!rawNumber.empty() && isdigit(rawNumber[0])) {
53 std::stringstream(rawNumber) >> threshold;
54 if (threshold < 10) threshold = 10000;
55 else threshold = (threshold + 1) * 1000;
57 }
58 }
60}
@ 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 317 of file MuonTriggerSFRootCoreTest.cxx.

317 {
318
319 const char* APP_NAME = argv[0];
321 // Read the config provided by the user
322 const char* xAODFileName = "";
323 std::string customInputFolder = "";
324 std::string customFileName = "";
325 const char* nrOfEntries = "";
326 std::string trigger = "";
327 int year = -1;
328 std::string period = "";
329 for (int i = 1; i < argc - 1; i++) {
330 std::string arg = std::string(argv[i]);
331 if (arg == "-x") {
332 xAODFileName = argv[i + 1];
333 }
334 else if (arg == "-d")
335 customInputFolder = argv[i + 1];
336 else if (arg == "-f")
337 customFileName = argv[i + 1];
338 else if (arg == "-e")
339 nrOfEntries = argv[i + 1];
340 else if (arg == "-t")
341 trigger = argv[i + 1];
342 else if (arg == "-y")
343 year = atoi(argv[i + 1]);
344 else if (arg == "-p")
345 period = argv[i + 1];
346 }
347
348 bool error = false;
349 if (xAODFileName[0] == '\0') {
350 Error(APP_NAME, "xAOD file name missing!");
351 error = true;
352 }
353 if (trigger == "") {
354 Error(APP_NAME, "trigger missing!");
355 error = true;
356 }
357 if (error) {
358 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);
359 return 1;
360 }
361
363
364 Info(APP_NAME, "Opening file: %s", xAODFileName);
365 std::unique_ptr<TFile> ifile(TFile::Open(xAODFileName, "READ"));
366 if (!ifile.get()) {
367 Error(APP_NAME, " Unable to load xAOD input file");
368 return 1;
369 }
370
373 Info(APP_NAME, "Number of events in the file: %i", static_cast<int>(event.getEntries()));
374
375 // Decide how many events to run over:
376 int nrOfEntriesToRunOver = 1000;//event.getEntries();
377 if (!std::string(nrOfEntries).empty()) {
378 int e = atoll(nrOfEntries);
379 if (e < nrOfEntriesToRunOver) {
380 nrOfEntriesToRunOver = e;
381 }
382 }
383
384
385 MuonTriggerSFTester sfChecker(APP_NAME, trigger);
386 sfChecker.initialiseTools(customFileName, customInputFolder, year, period);
387 for(Long64_t entry = 0; entry < nrOfEntriesToRunOver; entry++) {
388 // Tell the object which entry to look at:
389 event.getEntry(entry);
390 sfChecker.processEvent(event, year, period);
391
392 }
393
394 Info(APP_NAME, "%i events successfully processed, %i warnings, %i errors detected.", nrOfEntriesToRunOver, sfChecker.m_warningsCount, sfChecker.m_errorsCount);
395 return 0;
396}
#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 44 of file MuonTriggerSFRootCoreTest.cxx.

44{ "coarse", "fine" };

◆ qualities

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

Definition at line 43 of file MuonTriggerSFRootCoreTest.cxx.

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

◆ types

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

Definition at line 45 of file MuonTriggerSFRootCoreTest.cxx.

45{ "data", "mc" };