ATLAS Offline Software
top-tool-ftag.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 #include <iostream>
6 
7 #include "TFile.h"
8 #include "TTree.h"
9 #include "TTreeFormula.h"
10 #include "TSystem.h"
11 
12 #include "xAODRootAccess/TEvent.h"
13 #include "xAODRootAccess/TStore.h"
15 
19 
20 #include "TopAnalysis/Tools.h"
22 
25 #include "TopEvent/EventTools.h"
26 #include "TopEvent/TopEventMaker.h"
30 
32 
33 // to disable the sending of file access statistics
35 
37 // use ATH_MSG macros defined in the namespace TopAnalysis
38 using namespace TopAnalysis;
39 
49 // Prototype functions
50 std::shared_ptr<top::TopConfig> InitialiseTopSoftware(int, char**);
51 int TestFTag(const std::shared_ptr<top::TopConfig>&);
52 
53 std::shared_ptr<top::TopConfig> InitialiseTopSoftware(int argc, char** argv) {
54  if (argc != 3) {
55  ATH_MSG_INFO("Code to read an input file and return information on the"
56  << "anticipated systematics list in the b-tagging calibration"
57  << "Use like:\n"
58  << " " << argv[0] << " cuts.txt input.txt\n"
59  << " cuts.txt - file containing TopConfig\n"
60  << " input.txt - file containing list of input files\n"
61  << "\n"
62  << "For example\n"
63  << " " << argv[0] <<
64  " $ROOTCOREBIN/data/TopAnalysis/nocuts.txt $ROOTCOREBIN/data/TopAnalysis/input-13TeV-fondueworld.txt\n");
65  return 0;
66  }
67 
68  // to disable the sending of file access statistics
70 
71  //magic xAOD stuff
72  //true = fail at even the slightest xaod issue
73  top::xAODInit(true);
74  StatusCode::enableFailure();
75 
77 
78  std::string settingsFilename = std::string(argv[1]);
79  ATH_MSG_INFO("Configuration Files:\n"
80  << settingsFilename << "\n"
81  << std::string(argv[2]) << "\n");
82 
83  //load the settings from the input file
84  auto* const settings = top::ConfigurationSettings::get();
85  settings->loadFromFile(settingsFilename);
86  ATH_MSG_INFO("Configuration:\n" << *settings << "\n");
87 
88  const std::string libraryNames = settings->value("LibraryNames");
89  top::loadLibraries(libraryNames);
90 
91  //load the event selection from the input file
92  std::string cutsFilename = std::string(settingsFilename);
93 
94  //open the files (to check they exist) and count how many events we have
95  std::vector<std::string> filenames = top::fileList(std::string(argv[2]));
96 
97  // A configuration that John can easily understand
98  // This is not the same as a good configuration
99  std::shared_ptr<top::TopConfig> topConfig(new top::TopConfig());
100 
101  topConfig->setMapIndex(410501);
102  topConfig->setConfigSettings(settings);
104  // Setup all asg::AsgTools
105  top::TopToolStore topTools("top::TopToolStore");
106  top::check(topTools.setProperty("config", topConfig),
107  "Failed to setProperty of topTools");
108  top::check(topTools.initialize(), "Failed to initialize topTools");
109  topConfig->fixConfiguration();
110  ATH_MSG_INFO(*topConfig);
111 
112  return topConfig;
113 }
114 
115 int TestFTag(const std::shared_ptr<top::TopConfig>& topConfig) {
116  // Here we need to access the flavour tagging CP tool
117  // and get it to tell us what systematics are available
118  // given the configuration we setup up
119 
120  // Get TopCPTool handle
121  top::BTagScaleFactorCalculator* m_btagSF = new top::BTagScaleFactorCalculator("top::BTagScaleFactorCalculator");
122  top::check(m_btagSF->setProperty("config", topConfig), "Failed to pass in the config");
123  top::check(m_btagSF->initialize(), "Failed to init");
124  top::check(m_btagSF->debug(), "Failed to debug");
125  return 0;
126 }
127 
128 int main(int argc, char** argv) {
129  std::shared_ptr<top::TopConfig> topConfig = InitialiseTopSoftware(argc, argv);
130  TestFTag(topConfig);
131 }
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:69
top::loadLibraries
void loadLibraries(const std::string &libraryNames)
So that we can load external libraries with (1) extra event selection tools in, (2) user defined obje...
Definition: Tools.cxx:275
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Tools.h
top::TopConfig::setConfigSettings
void setConfigSettings(top::ConfigurationSettings *const &settings)
Definition: TopConfig.cxx:740
TopObjectSelection.h
EventSaverBase.h
xAOD::TFileAccessTracer::enableDataSubmission
static void enableDataSubmission(::Bool_t value)
Function for turning data submission on/off.
Definition: TFileAccessTracer.cxx:281
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
SelectionConfigurationData.h
xAOD::TEvent::kClassAccess
@ kClassAccess
Access auxiliary data using the aux containers.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:97
SystematicEvent.h
top::TopConfig
Definition: TopConfig.h:41
top::fileList
std::vector< std::string > fileList(const std::string &filename)
Given a filename for a text file, parse it and extract a list of root files.
Definition: Tools.cxx:239
EventTools.h
A few functions for doing operations on particles / events. Currently holds code for dR,...
top::TopConfig::fixConfiguration
void fixConfiguration()
Definition: TopConfig.cxx:2480
EventCleaningSelection.h
MsgCategory.h
TopToolStore.h
TFileAccessTracer.h
top::ConfigurationSettings::get
static ConfigurationSettings * get(bool reset=false)
Design patterns 101.
Definition: ConfigurationSettings.cxx:714
top::xAODInit
void xAODInit(bool failOnUnchecked)
A little wrapper for the xAOD tools.
Definition: Tools.cxx:46
TEvent.h
top::check
void check(bool thingToCheck, const std::string &usefulFailureMessage)
Print an error message and terminate if thingToCheck is false.
Definition: EventTools.cxx:15
TopEventMaker.h
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
TestFTag
int TestFTag(const std::shared_ptr< top::TopConfig > &)
Definition: top-tool-ftag.cxx:115
ConfigurationSettings.h
top::TopToolStore::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: TopToolStore.cxx:26
top::TopToolStore
Definition: TopToolStore.h:49
top::BTagScaleFactorCalculator
Definition: BTagScaleFactorCalculator.h:39
top::BTagScaleFactorCalculator::debug
StatusCode debug()
Definition: BTagScaleFactorCalculator.cxx:172
top::BTagScaleFactorCalculator::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: BTagScaleFactorCalculator.cxx:31
TopConfig.h
grepfile.filenames
list filenames
Definition: grepfile.py:34
main
int main(int argc, char **argv)
Definition: top-tool-ftag.cxx:128
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition: TStore.h:44
top::TopConfig::setMapIndex
void setMapIndex(unsigned int value)
Definition: TopConfig.h:212
InitialiseTopSoftware
std::shared_ptr< top::TopConfig > InitialiseTopSoftware(int, char **)
Definition: top-tool-ftag.cxx:53
TActiveStore.h
ObjectLoaderBase.h
TStore.h
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:81
BTagScaleFactorCalculator.h