ATLAS Offline Software
Loading...
Searching...
No Matches
Config Struct Reference
Collaboration diagram for Config:

Public Member Functions

bool initialize (int argc, char *argv[])
 Config (const char *name)
ConfigsetTriggers (const std::string &t)
ConfigsetLeptonPDF (unsigned nmin, unsigned nmax, std::initializer_list< float > ptvalues)
ConfigsetEfficiency (const std::string &leg, double eff)
ConfigsetEfficiency (const std::string &leg, std::function< double(float)> &&eff)
ConfigsetEventSelection (const decltype(eventSelection)&sel)
ConfigsetDebug ()
ConfigsetExpectedEfficiency (double eff, double tolerance)
ConfigsetUnavailable (const std::string &leg)
void parseProgramOptions (int argc, char *argv[])
void usage ()

Public Attributes

asg::AnaToolHandle< IAsgElectronEfficiencyCorrectionTooltool
std::vector< std::tuple< CP::SystematicSet, NP > > systematics {}
std::vector< Domaindomains {}
int run_number {0}
bool analysis_mode {false}
std::string testName
std::string triggers = ""
unsigned minLeptons = 1
unsigned maxLeptons = 5
std::vector< float > leptonPtValues
std::map< std::string, std::function< double(float)> > efficiencies
std::function< bool(const std::vector< const xAOD::Electron * > &, const std::vector< const xAOD::Muon * > &, const std::vector< const xAOD::Photon * > &)> eventSelection = nullptr
std::string unavailable
double expectedEfficiency = -1.
double expectedEfficiencyTolerance = 1e-6
bool generateElectrons = false
bool generateMuons = false
bool generatePhotons = false
bool debug = false
std::vector< std::string > knownParameters
std::vector< std::string > inputFiles {}
unsigned int smk { 0 }
unsigned int l1psk { 0 }
unsigned int hltpsk { 0 }
unsigned int bgsk { 0 }
std::string dbalias { "TRIGGERDB_RUN3" }
std::string crestDb { "" }
const std::string crestServerDefault { "http://crest-04.cern.ch/" }
std::string crestServer { crestServerDefault }
std::string crestApi { "" }
bool doCtp { false }
bool write { false }
bool writeFromDataStructure { false }
std::string base { "" }
bool help { false }
bool detail { false }
vector< stringerror

Private Member Functions

void updateFlavours (const std::string &leg)

Detailed Description

Definition at line 46 of file dumpNPs.cxx.

Constructor & Destructor Documentation

◆ Config()

Config::Config ( const char * name)
inline

Definition at line 142 of file TrigGlobEffCorrValidation.cxx.

142: testName(name), leptonPtValues {30e4f} { }
std::vector< float > leptonPtValues

Member Function Documentation

◆ initialize()

bool Config::initialize ( int argc,
char * argv[] )

Definition at line 159 of file dumpNPs.cxx.

160{
161 using namespace asg::msgUserCode;
162
163 auto help = [&]() {
164 Info(MSGSOURCE, "Usage (1): EgEfficiencyCorr_dumpNPs Year=<value> IdKey=<value> <property1=value1> ... <property N=value N>");
165 Info(MSGSOURCE, " ++ prints eta x pt region of influence of each nuisance parameter for the chosen year");
166 Info(MSGSOURCE, "Usage (2): EgEfficiencyCorr_dumpNPs AnalysisEta=<list> AnalysisPt=<list> IdKey=<value> <property1=value1> ... <property N=value N>");
167 Info(MSGSOURCE, " ++ prints a short list of all NPs relevant in the selected eta x pt (in MeV) region");
168 Info(MSGSOURCE, " ++ e.g. EgEfficiencyCorr_dumpNPs AnalysisEta=-2.0..2.0,nocrack AnalysisPt=20e3..150e3");
169 Info(MSGSOURCE, " ++ one of the Analysis* arguments can be omitted, in which case the full range is scanned");
170 Info(MSGSOURCE, " ++ several intervals can be specified, separated by commas, e.g. AnalysisEta=0..0.6,0.8..1.37");
171 Info(MSGSOURCE, " ++ recognized aliases: 'nocrack' (crack veto), 'sym' (duplicates for eta<0), 'barrel', 'endcap'");
172 Info(MSGSOURCE, "Common details:");
173 Info(MSGSOURCE, " ++ for other SFs, IdKey can be replaced by RecoKey/IsoKey/TriggerKey");
174 Info(MSGSOURCE, " ++ CorrectionFileNameList can also be used instead of keys");
175 Info(MSGSOURCE, " ++ optional arguments are other configurable properties of the AsgElectronEfficiencyCorrectionTool.");
176 Info(MSGSOURCE, " ++ e.g. EgEfficiencyCorr_dumpNPs Year=2015 IdKey=Tight CorrelationModel=SIMPLIFIED UncorrEtaBinsUser=0,1.37,2.47");
177 std::abort();
178 };
179
180 if (argc < 2) help();
181
182 const std::set<std::string> string_properties{
183 "MapFilePath", "RecoKey", "IdKey", "IsoKey", "TriggerKey",
184 "CorrelationModel"};
185 const std::set<std::string> int_properties{"ForceDataType"};
186 const std::set<std::string> vector_properties{
187 "UncorrEtaBinsUser", "UncorrEtBinsUser"};
188
189 // Set default values.
190 const int mc_type{static_cast<int>(PATCore::ParticleDataType::Full)};
191 ANA_CHECK( tool.setProperty("ForceDataType", mc_type) );
192 ANA_CHECK( tool.setProperty("CorrelationModel", "FULL") );
193 ANA_CHECK( tool.setProperty("UseRandomRunNumber", true) );
194
195 run_number = 0;
196 std::vector<int8_t> eta_flags(eta_edges.size()-1, 0);
197 std::vector<int8_t> pt_flags(pt_edges.size()-1, 0);
198
199 for (int i=1; i<argc; ++i) {
200 std::string key{argv[i]};
201 const std::size_t pos{key.find('=')};
202 if (pos == std::string::npos) help();
203 std::string val(key.substr(pos + 1));
204 key.resize(pos);
205 if (!key.length() || !val.length()) help();
206 if (key == "CorrectionFileNameList") {
207 std::vector<std::string> files{val};
208 ANA_CHECK( tool.setProperty(key, files) );
209 } else if (key == "Year") {
210 run_number = get_run_number(std::stoi(val));
211 } else if (string_properties.count(key)) {
212 ANA_CHECK( tool.setProperty(key, val) );
213 } else if (int_properties.count(key)) {
214 ANA_CHECK( tool.setProperty(key, std::stoi(val)) );
215 } else if (vector_properties.count(key)) {
216 std::vector<float> bins;
218 ANA_CHECK( tool.setProperty(key, bins) );
219 } else if (key == "AnalysisEta") {
220 ANA_CHECK( parse_csv_list(val, eta_flags, eta_edges) );
221 analysis_mode = true;
222 } else if (key == "AnalysisPt") {
223 ANA_CHECK( parse_csv_list(val, pt_flags, pt_edges) );
224 analysis_mode = true;
225 } else {
226 Error(MSGSOURCE, "Unrecognized property %s", key.c_str());
227 help();
228 }
229 }
230
231 if (analysis_mode) {
232 if (run_number) {
233 Warning(MSGSOURCE,
234 "When Analysis* arguments are provided, "
235 "Year is ignored.");
236 }
237 } else if (!run_number) {
238 Error(MSGSOURCE, "Command-line arguments must include Year");
239 help();
240 }
241
242 // Enable negative-eta bins, when the 'sym' alias was specified:
243 for (std::size_t i{0}; i<eta_flags.size(); ++i) {
244 if (eta_flags[i] != 2) continue;
245 float z{0.5f * (eta_edges[i] + eta_edges[i+1])};
246 auto eeb{eta_edges.cbegin()}, eee{eta_edges.cend()};
247 const auto j = static_cast<std::size_t>(
248 std::upper_bound(eeb, eee, -z) - eeb - 1);
249 if (i == j) continue;
250 if (j >= eta_edges.size()) return false;
251 eta_flags[i] = eta_flags[j];
252 }
253
254 // By default, scan whole ranges (except crack if vetoed)
255 auto efb{eta_flags.begin()}, efe{eta_flags.end()};
256 if (!std::count(efb, efe, 1)) {
257 std::replace(efb, efe, 0, 1);
258 }
259 auto pfb{pt_flags.begin()}, pfe{pt_flags.end()};
260 if (!std::count(pfb, pfe, 1)) {
261 std::fill(pfb, pfe, 1);
262 }
263
264 domains.clear();
265 for (std::size_t i{0}; i<eta_flags.size(); ++i) {
266 if (eta_flags[i] < 1) continue;
267 for (std::size_t j{0}; j<pt_flags.size(); ++j) {
268 if (pt_flags[j] < 1) continue;
269 domains.emplace_back(Domain{
270 eta_edges[i], eta_edges[i+1],
271 pt_edges[j], pt_edges[j+1]
272 });
273 }
274 }
275 return true;
276}
#define ANA_CHECK(EXP)
check whether the given expression was successful
static const std::vector< std::string > bins
#define z
int get_run_number(const int year)
Definition dumpNPs.cxx:576
std::vector< float > pt_edges
Definition dumpNPs.cxx:76
std::vector< float > eta_edges
Definition dumpNPs.cxx:71
bool parse_csv_list(std::string val, Args &... args)
Definition dumpNPs.cxx:562
std::vector< std::string > files
file names and file pointers
Definition hcg.cxx:50
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition Error.h:16
@ Info
Definition ZDCMsg.h:20
bool analysis_mode
Definition dumpNPs.cxx:53
int run_number
Definition dumpNPs.cxx:52
std::vector< Domain > domains
Definition dumpNPs.cxx:51
asg::AnaToolHandle< IAsgElectronEfficiencyCorrectionTool > tool
Definition dumpNPs.cxx:48
#define MSGSOURCE
Test code to test ElectronPhotonVariableCorrectionTool Dictionaries.

◆ parseProgramOptions()

void Config::parseProgramOptions ( int argc,
char * argv[] )

Definition at line 103 of file TriggerMenuRW.cxx.

103 {
104
105 std::string currentParameter("");
106 std::string listofUnknownParameters = "";
107
108 for(int i=1; i<argc; i++) {
109
110 std::string currentWord(argv[i]);
111 bool isParam = currentWord[0]=='-'; // string starts with a '-', so it is a parameter name
112
113 // get the parameter name
114 int firstChar = currentWord.find_first_not_of('-');
115 string paramName = currentWord.substr(firstChar);
116
117 // check if the parameter is known
118 if ( isParam && std::find(knownParameters.begin(), knownParameters.end(), paramName) == knownParameters.end() ) {
119 listofUnknownParameters += " " + currentWord;
120 continue;
121 }
122
123 if(isParam) {
124 currentParameter = "";
125 // check the boolean parameters
126 if(paramName == "h" || paramName == "help" ) { help = true; continue; }
127 if(paramName == "d" || paramName == "detail" ) { detail = true; continue; }
128 if(paramName == "w" || paramName == "write" ) { write = true; }
129 if(paramName == "W" || paramName == "Write" ) { writeFromDataStructure = true; }
130 if(paramName == "c" || paramName == "ctp" ) { doCtp = true; }
131 currentParameter = std::move(paramName);
132 continue;
133 }
134
135 // now treat the parameter values
136
137 // inputs
138 if(currentParameter == "file" || currentParameter == "f") {
139 inputFiles.push_back(std::move(currentWord));
140 continue;
141 }
142 if(currentParameter == "smk") {
143 smk = stoul(currentWord);
144 continue;
145 }
146 if(currentParameter == "l1psk") {
147 l1psk = stoul(currentWord);
148 continue;
149 }
150 if(currentParameter == "hltpsk") {
151 hltpsk = stoul(currentWord);
152 continue;
153 }
154 if(currentParameter == "bgsk") {
155 bgsk = stoul(currentWord);
156 continue;
157 }
158 if(currentParameter == "db") {
159 dbalias = std::move(currentWord);
160 continue;
161 }
162 if(currentParameter == "crest-db") {
163 crestDb = std::move(currentWord);
164 continue;
165 }
166 if(currentParameter == "crest-server") {
167 crestServer = std::move(currentWord);
168 continue;
169 }
170 if(currentParameter == "crest-api") {
171 crestApi = std::move(currentWord);
172 continue;
173 }
174 // output
175 if(currentParameter == "write" || currentParameter == "w" || currentParameter == "Write" || currentParameter == "W") {
176 base = std::move(currentWord);
177 continue;
178 }
179
180 }
181
182 // some sanity checks
183 if ( inputFiles.size() == 0 and smk == 0 and l1psk == 0 and hltpsk == 0 and bgsk == 0 ) {
184 error.push_back("No input specified! Please provide either one of the following: input file(s), smk, l1psk, hltpsk, or bgsk");
185 }
186
187 if ( listofUnknownParameters.size() > 0 ) {
188 error.push_back( string("Unknown parameter(s):") + listofUnknownParameters);
189 }
190
191}
std::string crestDb
std::string dbalias
std::vector< std::string > knownParameters
unsigned int hltpsk
std::string crestApi
bool writeFromDataStructure
vector< string > error
std::string base
unsigned int smk
unsigned int bgsk
std::vector< std::string > inputFiles
std::string crestServer
unsigned int l1psk

◆ setDebug()

Config & Config::setDebug ( )
inline

Definition at line 164 of file TrigGlobEffCorrValidation.cxx.

164{ debug = true; return *this; };

◆ setEfficiency() [1/2]

Config & Config::setEfficiency ( const std::string & leg,
double eff )
inline

Definition at line 151 of file TrigGlobEffCorrValidation.cxx.

152 {
153 efficiencies.emplace(leg, [=](float){return eff;});
154 updateFlavours(leg);
155 return *this;
156 }
void updateFlavours(const std::string &leg)
std::map< std::string, std::function< double(float)> > efficiencies

◆ setEfficiency() [2/2]

Config & Config::setEfficiency ( const std::string & leg,
std::function< double(float)> && eff )
inline

Definition at line 157 of file TrigGlobEffCorrValidation.cxx.

158 {
159 efficiencies.emplace(leg, eff);
160 updateFlavours(leg);
161 return *this;
162 }

◆ setEventSelection()

Config & Config::setEventSelection ( const decltype(eventSelection)& sel)
inline

Definition at line 163 of file TrigGlobEffCorrValidation.cxx.

163{ eventSelection = sel; return *this; }
std::function< bool(const std::vector< const xAOD::Electron * > &, const std::vector< const xAOD::Muon * > &, const std::vector< const xAOD::Photon * > &)> eventSelection

◆ setExpectedEfficiency()

Config & Config::setExpectedEfficiency ( double eff,
double tolerance )
inline

Definition at line 165 of file TrigGlobEffCorrValidation.cxx.

166 {
169 return *this;
170 }
constexpr double tolerance

◆ setLeptonPDF()

Config & Config::setLeptonPDF ( unsigned nmin,
unsigned nmax,
std::initializer_list< float > ptvalues )
inline

Definition at line 144 of file TrigGlobEffCorrValidation.cxx.

145 {
146 minLeptons = nmin;
148 leptonPtValues = ptvalues;
149 return *this;
150 }
const int nmax(200)

◆ setTriggers()

Config & Config::setTriggers ( const std::string & t)
inline

Definition at line 143 of file TrigGlobEffCorrValidation.cxx.

143{ triggers = t; return *this; }

◆ setUnavailable()

Config & Config::setUnavailable ( const std::string & leg)
inline

Definition at line 171 of file TrigGlobEffCorrValidation.cxx.

172 {
173 if (!unavailable.empty()) unavailable += ',';
174 unavailable += leg;
175 updateFlavours(leg);
176 return *this;
177 }

◆ updateFlavours()

void Config::updateFlavours ( const std::string & leg)
inlineprivate

Definition at line 179 of file TrigGlobEffCorrValidation.cxx.

180 {
181 if (leg[0] == 'e') generateElectrons = true;
182 else if (leg[0] == 'm') generateMuons = true;
183 else if (leg[0] == 'g') generatePhotons = true;
184 }

◆ usage()

void Config::usage ( )

Definition at line 72 of file TriggerMenuRW.cxx.

72 {
73
74 cout << "The program needs to be run with the following specifications:\n\n";
75 cout << "TriggerMenuRW <options>\n";
76 cout << "\n";
77 cout << "[Input options]\n";
78 cout << " -f|--file file1 [file2 [file3 ...]] ... one or multiple json files\n";
79 cout << " --smk smk ... smk \n";
80 cout << " --l1psk l1psk ... the L1 prescale key \n";
81 cout << " --hltpsk hltpsk ... the HLT prescale key \n";
82 cout << " --bgsk bgsk ... the bunchgroup key \n";
83 cout << " --db dbalias ... dbalias for oracle/frontier access (default " << dbalias << ") \n";
84 cout << " --crest-db crestdb ... crest_db for Crest access, if specified Crest will be used (default '') \n";
85 cout << " possible values: CONF_DATA_RUN3, CONF_MC_RUN3, CONF_REPR_RUN3\n";
86 cout << " --crest-server server ... crest server (default " << crestServerDefault << ")\n";
87 cout << " --crest-api version ... crest api version (default taken from CrestApi)";
88 cout << " -c|--ctp ... if provided together with the SMK and DB then will read only CTP files from the DB and not the rest of the menu\n";
89 cout << "[Output options]\n";
90 cout << " -w|--write [base] ... to write out json files, e.g. L1menu[_<base>].json. base is optional.\n";
91 cout << " -W|--Write [base] ... to write out json files from the internal structure (only for L1Menu), e.g. L1menu[_<base>].json. base is optional.\n";
92 cout << "[Other options]\n";
93 cout << " -h|--help ... this help\n";
94 cout << " -d|--detail ... prints detailed job options\n";
95 cout << "\n\n";
96 cout << "Examples\n";
97 cout << " --file L1menu.json HLTMenu.json ... read L1Menu.json and HLTMenu.json and show some basic statistics\n";
98 cout << " --db TRIGGERDB_RUN3 --smk 3205 ... read the L1 menu, HLT menu, HLT job options, and HLT monitoring groups for SMK 3205\n";
99 cout << " --db TRIGGERDB_RUN3 --smk 3205 -w ... read the information and write DB content directly as json files\n";
100}
const std::string crestServerDefault

Member Data Documentation

◆ analysis_mode

bool Config::analysis_mode {false}

Definition at line 53 of file dumpNPs.cxx.

53{false};

◆ base

std::string Config::base { "" }

Definition at line 54 of file TriggerMenuRW.cxx.

54{ "" };

◆ bgsk

unsigned int Config::bgsk { 0 }

Definition at line 43 of file TriggerMenuRW.cxx.

43{ 0 };

◆ crestApi

std::string Config::crestApi { "" }

Definition at line 48 of file TriggerMenuRW.cxx.

48{ "" };

◆ crestDb

std::string Config::crestDb { "" }

Definition at line 45 of file TriggerMenuRW.cxx.

45{ "" };

◆ crestServer

std::string Config::crestServer { crestServerDefault }

Definition at line 47 of file TriggerMenuRW.cxx.

◆ crestServerDefault

const std::string Config::crestServerDefault { "http://crest-04.cern.ch/" }

Definition at line 46 of file TriggerMenuRW.cxx.

46{ "http://crest-04.cern.ch/" };

◆ dbalias

std::string Config::dbalias { "TRIGGERDB_RUN3" }

Definition at line 44 of file TriggerMenuRW.cxx.

44{ "TRIGGERDB_RUN3" };

◆ debug

bool Config::debug = false

Definition at line 140 of file TrigGlobEffCorrValidation.cxx.

◆ detail

bool Config::detail { false }

Definition at line 58 of file TriggerMenuRW.cxx.

58{ false };

◆ doCtp

bool Config::doCtp { false }

Definition at line 49 of file TriggerMenuRW.cxx.

49{ false }; // flag to read CTP files

◆ domains

std::vector<Domain> Config::domains {}

Definition at line 51 of file dumpNPs.cxx.

51{};

◆ efficiencies

std::map<std::string, std::function<double(float)> > Config::efficiencies

Definition at line 132 of file TrigGlobEffCorrValidation.cxx.

◆ error

vector<string> Config::error

Definition at line 61 of file TriggerMenuRW.cxx.

◆ eventSelection

std::function<bool(const std::vector<const xAOD::Electron*>&,const std::vector<const xAOD::Muon*>&,const std::vector<const xAOD::Photon*>&)> Config::eventSelection = nullptr

Definition at line 133 of file TrigGlobEffCorrValidation.cxx.

◆ expectedEfficiency

double Config::expectedEfficiency = -1.

Definition at line 135 of file TrigGlobEffCorrValidation.cxx.

◆ expectedEfficiencyTolerance

double Config::expectedEfficiencyTolerance = 1e-6

Definition at line 136 of file TrigGlobEffCorrValidation.cxx.

◆ generateElectrons

bool Config::generateElectrons = false

Definition at line 137 of file TrigGlobEffCorrValidation.cxx.

◆ generateMuons

bool Config::generateMuons = false

Definition at line 138 of file TrigGlobEffCorrValidation.cxx.

◆ generatePhotons

bool Config::generatePhotons = false

Definition at line 139 of file TrigGlobEffCorrValidation.cxx.

◆ help

bool Config::help { false }

Definition at line 57 of file TriggerMenuRW.cxx.

57{ false };

◆ hltpsk

unsigned int Config::hltpsk { 0 }

Definition at line 42 of file TriggerMenuRW.cxx.

42{ 0 };

◆ inputFiles

std::vector<std::string> Config::inputFiles {}

Definition at line 39 of file TriggerMenuRW.cxx.

39{};

◆ knownParameters

std::vector<std::string> Config::knownParameters
Initial value:
{
"file", "f", "smk", "l1psk", "hltpsk", "bgsk", "db", "crest-db", "crest-server", "crest-api", "write", "w",
"Write", "W", "help", "h", "detail", "d", "ctp", "c"
}

Definition at line 32 of file TriggerMenuRW.cxx.

32 {
33 "file", "f", "smk", "l1psk", "hltpsk", "bgsk", "db", "crest-db", "crest-server", "crest-api", "write", "w",
34 "Write", "W", "help", "h", "detail", "d", "ctp", "c"
35 };

◆ l1psk

unsigned int Config::l1psk { 0 }

Definition at line 41 of file TriggerMenuRW.cxx.

41{ 0 };

◆ leptonPtValues

std::vector<float> Config::leptonPtValues

Definition at line 131 of file TrigGlobEffCorrValidation.cxx.

◆ maxLeptons

unsigned Config::maxLeptons = 5

Definition at line 130 of file TrigGlobEffCorrValidation.cxx.

◆ minLeptons

unsigned Config::minLeptons = 1

Definition at line 129 of file TrigGlobEffCorrValidation.cxx.

◆ run_number

int Config::run_number {0}

Definition at line 52 of file dumpNPs.cxx.

52{0};

◆ smk

unsigned int Config::smk { 0 }

Definition at line 40 of file TriggerMenuRW.cxx.

40{ 0 };

◆ systematics

std::vector<std::tuple<CP::SystematicSet, NP> > Config::systematics {}

Definition at line 50 of file dumpNPs.cxx.

50{};

◆ testName

std::string Config::testName

Definition at line 127 of file TrigGlobEffCorrValidation.cxx.

◆ tool

Initial value:
{
"AsgElectronEfficiencyCorrectionTool/tool"}

Definition at line 48 of file dumpNPs.cxx.

48 {
49 "AsgElectronEfficiencyCorrectionTool/tool"};

◆ triggers

std::string Config::triggers = ""

Definition at line 128 of file TrigGlobEffCorrValidation.cxx.

◆ unavailable

std::string Config::unavailable

Definition at line 134 of file TrigGlobEffCorrValidation.cxx.

◆ write

bool Config::write { false }

Definition at line 52 of file TriggerMenuRW.cxx.

52{ false }; // flag to enable writing

◆ writeFromDataStructure

bool Config::writeFromDataStructure { false }

Definition at line 53 of file TriggerMenuRW.cxx.

53{ false }; // flag to enable writing of the L1Menu structure (if available)

The documentation for this struct was generated from the following files: