ATLAS Offline Software
Loading...
Searching...
No Matches
testEgEfficiencyCorrWithoutFile.cxx File Reference
#include <memory>
#include <string>
#include <TFile.h>
#include <TString.h>
#include "ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h"
#include "CreateDummyEl.h"
#include "SFHelpers.h"
#include <boost/program_options.hpp>
#include "AsgMessaging/MessageCheck.h"
#include "AsgMessaging/MsgStream.h"
#include "AsgTools/StandaloneToolHandle.h"

Go to the source code of this file.

Namespaces

namespace  asg

Functions

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

Function Documentation

◆ main()

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

Definition at line 35 of file testEgEfficiencyCorrWithoutFile.cxx.

36{
37 StatusCode::enableFailure();
38 using namespace asg::msgSelectorCheck;
40 setMsgLevel(MSG::INFO);
41 /*
42 * Parse the input from the command line
43 */
44 std::string fileName{};
45 std::string mapfileName{};
46 std::string idkey{};
47 std::string recokey{};
48 std::string isokey{};
49 std::string triggerkey{};
50 std::string model{};
51 int runno{};
52 float eta{};
53 float pt{};
54 std::string type{};
55 int inputlevel{};
56
57 using namespace boost::program_options;
58 options_description desc{ "Options" };
59 desc.add_options()("help,h", "Help screen")(
60 "msgLevel,l",
61 value<int>(&inputlevel)->default_value(static_cast<int>(MSG::INFO)),
62 "message level")("file,f",
63 value<std::string>(&fileName)->default_value(""),
64 "scale factor file")(
65 "runno,r", value<int>(&runno)->required(), "run number: Required")(
66 "eta,e", value<float>(&eta)->required(), "eta: Required")(
67 "pt,p", value<float>(&pt)->required(), "pt: Required")(
68 "type,t",
69 value<std::string>(&type)->required(),
70 "Simulation type: Required")(
71 "correlation,c",
72 value<std::string>(&model)->default_value("FULL"),
73 "Correlation Model FULL (default),SIMPLIFIED,TOTAL,COMBMCTOYS")(
74 "keyreco,k",
75 value<std::string>(&recokey)->default_value(""),
76 "Reco working point Key")(
77 "mapfile,m",
78 value<std::string>(&mapfileName)->default_value(""),
79 "Map file name")("keyid,d",
80 value<std::string>(&idkey)->default_value(""),
81 "Identification working point Key")(
82 "keyiso,i",
83 value<std::string>(&isokey)->default_value(""),
84 "Isolation working point Key")(
85 "keytrigger,g",
86 value<std::string>(&triggerkey)->default_value(""),
87 "Trigger working point Key");
88 variables_map vm;
89 try {
90 store(parse_command_line(argc, argv, desc), vm);
91 if (vm.count("help")) {
92 ANA_MSG_INFO(desc << '\n');
93 return 0;
94 }
95 notify(vm);
96 } catch (const boost::program_options::error& ex) {
97 ANA_MSG_ERROR(ex.what() << '\n');
98 ANA_MSG_ERROR(desc << '\n');
99 return 0;
100 }
101
102 if (!(type == "FullSim" || type == "AtlFast2")) {
103 ANA_MSG_ERROR("No valid type given (FullSim or AtlFast2)");
104 ANA_MSG_ERROR(desc << '\n');
105 return 0;
106 }
110 if (!(model == "COMBMCTOYS" || model == "FULL" || model == "SIMPLIFIED" ||
111 model == "TOTAL")) {
112 ANA_MSG_ERROR("No valid correlation model");
113 ANA_MSG_ERROR(desc << '\n');
114 return 0;
115 }
116
117 // Initialize the xAOD application
118 const char* APP_NAME = argv[0];
119 msg().setName(APP_NAME);
120 MSG::Level mylevel = static_cast<MSG::Level>(inputlevel);
121 setMsgLevel(mylevel);
122 msg().setName(APP_NAME);
124
125 // Initialize the store
128
129 // Configure the tool based on the inputs
131 ElEffCorrectionTool(
132 "AsgElectronEfficiencyCorrectionTool/ElEffCorrectionTool");
133 if (!fileName.empty()) {
134 std::vector<std::string> inputFiles{ fileName };
135 ANA_CHECK(
136 ElEffCorrectionTool.setProperty("CorrectionFileNameList", inputFiles));
137 }
138 if (!mapfileName.empty()) {
139 ANA_CHECK(ElEffCorrectionTool.setProperty("MapFilePath", mapfileName));
140 }
141 if (!recokey.empty()) {
142 ANA_CHECK(ElEffCorrectionTool.setProperty("RecoKey", recokey));
143 }
144 if (!idkey.empty()) {
145 ANA_CHECK(ElEffCorrectionTool.setProperty("IdKey", idkey));
146 }
147 if (!isokey.empty()) {
148 ANA_CHECK(ElEffCorrectionTool.setProperty("IsoKey", isokey));
149 }
150 if (!triggerkey.empty()) {
151 ANA_CHECK(ElEffCorrectionTool.setProperty("TriggerKey", triggerkey));
152 }
153 ANA_CHECK(ElEffCorrectionTool.setProperty("ForceDataType", (int)SimType));
154 ANA_CHECK(ElEffCorrectionTool.setProperty("OutputLevel", mylevel));
155 ANA_CHECK(ElEffCorrectionTool.setProperty("CorrelationModel", model));
156 ANA_CHECK(ElEffCorrectionTool.initialize());
157 if (mylevel < MSG::INFO) {
158 asg::ToolStore::dumpToolConfig();
159 }
160 /*
161 * create and then retrieve the dummy electrons (in this case is 1)
162 * This also setups the store,so for done before the tool init
163 * it really is a pseudo "reconstruction"
164 */
165 std::vector<std::pair<double, double>> pt_eta{ { pt, eta } };
166 ANA_CHECK(getElectrons(pt_eta, runno, store).isSuccess());
167 const xAOD::ElectronContainer* electrons(nullptr);
168 ANA_CHECK(store.retrieve(electrons, "MyElectrons").isSuccess());
169 // Loop over electrons , here it is one
170 xAOD::Electron el = *(electrons->at(0));
171 /*
172 * Potentiallly we can make this part more clever, for now since it is an
173 * util I did not try to optimise too much.
174 */
175 int index = ElEffCorrectionTool->systUncorrVariationIndex(el);
176 /*
177 * Set up the systematic variations
178 * 2 cases one for "continuous" one for "toys"
179 */
180 bool isToys = model.find("TOY") != std::string::npos;
181 double nominalSF{};
182 double totalNeg{};
183 double totalPos{};
185 ElEffCorrectionTool, el, nominalSF, totalPos, totalNeg, isToys) ==
186 0);
187
188 ANA_MSG_INFO("===> Model : " << model << "| electron : Pt = " << el.pt()
189 << " : eta = " << el.eta() << " : Bin index = "
190 << index << " : SF = " << nominalSF << " + "
191 << totalPos << " - " << totalNeg << " <===");
192
193 return 0;
194}
Scalar eta() const
pseudorapidity method
#define APP_NAME
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
#define ANA_MSG_ERROR(xmsg)
Macro printing error 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
StatusCode getElectrons(const std::vector< std::pair< double, double > > &pt_eta, int runNumber, xAOD::TStore &store)
an "initializing" ToolHandle for stand-alone applications
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
int result(asg::StandaloneToolHandle< IAsgElectronEfficiencyCorrectionTool > &tool, const xAOD::Electron &el, double &nominalSF, double &totalPos, double &totalNeg, const bool isToys)
Definition SFHelpers.cxx:20
TestStore store
Definition TestStore.cxx:23
Definition index.py:1
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition Init.cxx:31
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
Electron_v1 Electron
Definition of the current "egamma version".
MsgStream & msg
Definition testRead.cxx:32