![]() |
ATLAS Offline Software
|
#include <Database.h>
Classes | |
| struct | EfficiencyTable |
| struct | GenericError |
| This propagates an error message. More... | |
| struct | Param |
| struct | StatDef |
| could try to keep track of the bin number, for the description More... | |
| struct | StringRef |
| Note: the following structure is used (instead of a simple std::string) so that XML line numbers can be printed in the error message, which requires keeping track of the position of the string in the original file. More... | |
| struct | SystDef |
| struct | XmlError |
| This propagates an error message + the reference to the faulty piece of XML when an exception is raised. More... | |
Public Types | |
| enum | EfficiencyType { ELECTRON_REAL_EFFICIENCY = 0 , ELECTRON_FAKE_EFFICIENCY , ELECTRON_FAKE_FACTOR , MUON_REAL_EFFICIENCY , MUON_FAKE_EFFICIENCY , MUON_FAKE_FACTOR , TAU_REAL_EFFICIENCY , TAU_FAKE_EFFICIENCY , TAU_FAKE_FACTOR , PHOTON_ELE_FAKE_FACTOR , PHOTON_ELE_FAKE_FACTOR_SF , N_EFFICIENCY_TYPES } |
| enum class | InputType { CENTRAL_VALUE , CORRECTION } |
| enum class | StatMode { GLOBAL , PER_BIN , NONE , UNSPECIFIED } |
Public Member Functions | |
| Database (Client client, bool useGeV, bool convertWhenMissing) | |
| void | importXML (std::string filename) |
| void | importDefaultROOT (std::string filename) |
| bool | ready () const |
| void | reset () |
| bool | needEventInfo () const |
| bool | fillEfficiencies (ParticleData &pd, const xAOD::IParticle &p, const xAOD::EventInfo &eventInfo, std::string &error) const |
| unsigned | getXmlLineNumber (const char *pos) const |
| unsigned | numberOfStats () const |
| unsigned | numberOfSysts () const |
| const SystDef * | findSyst (unsigned short uid) const |
| const StatDef * | findStat (unsigned short uid) const |
Static Public Member Functions | |
| static constexpr unsigned short | indexFromUID (unsigned short uid) |
| static constexpr unsigned short | systIndexToUID (unsigned short index) |
| static constexpr unsigned short | statIndexToUID (unsigned short index) |
| static constexpr bool | isSystUID (unsigned short uid) |
| static constexpr bool | isStatUID (unsigned short uid) |
Protected Types | |
| using | AttributesMap = std::map<std::string, StringRef> |
Protected Member Functions | |
| void | dropXmlComments (std::string &buffer) |
| Methods used to parse XML files. | |
| void | dropRootTag (std::string &buffer) |
| void | readNextTag (StringRef &stream, StringRef &tag, AttributesMap &attributes, StringRef &contents) |
| void | readTagAttributes (StringRef stream, const std::string &tag, AttributesMap &attributes) |
| void | resetAttributes (AttributesMap &attributes) |
| void | importCustomROOT (const StringRef &tag, const StringRef &contents, const AttributesMap &attributes) |
| void | addParams (const StringRef &tag, const StringRef &contents, AttributesMap &attributes) |
| void | addSysts (const StringRef &tag, const StringRef &contents, const AttributesMap &attributes) |
| unsigned short | addStat (EfficiencyType type, const StringRef &pos=StringRef()) |
| void | addTables (const StringRef &particleType, const AttributesMap &attributes, const StringRef &contents, TFile *source=nullptr) |
| void | addDimension (EfficiencyTable &table, unsigned paramUID, const StringRef &contents) |
| void | addValues (const StringRef &contents, EfficiencyTable &table, EfficiencyType type, StatMode statMode, unsigned short &globalStatUID) |
| void | importNominalTH1 (const TH1 *hist, EfficiencyType type, const StringRef ¶mX, const StringRef ¶mY, const StringRef ¶mZ, float scale, StatMode statMode, unsigned short &globalStatUID, const StringRef &xmlStream) |
| Methods used to load from ROOT files. | |
| void | importSystTH1 (const TH1 *hist, EfficiencyType type, const std::string &sysname) |
| float | getWeightedAverage (const TH1 *hist, const StringRef &xmlStream) |
| float | getNormalizationFactor (const TH1 *hist, EfficiencyType type, const StringRef &norm, const StringRef &xmlStream) |
| bool | retrieveParameterValue (const xAOD::IParticle &p, const xAOD::EventInfo &eventInfo, const Param ¶m, EfficiencyTable::BoundType &val) const |
| EfficiencyType | getSourceType (EfficiencyType wantedType) const |
| int | readEfficiencyFromTable (Efficiency &eff, const EfficiencyTable &table, std::map< unsigned, EfficiencyTable::BoundType > &cachedParamVals, const xAOD::IParticle &p, const xAOD::EventInfo &eventInfo, std::string &error) const |
| std::vector< std::string > | getListOfNames (const StringRef &stream) |
Static Protected Member Functions | |
| static FakeBkgTools::Efficiency * | selectEfficiency (FakeBkgTools::ParticleData &pd, const xAOD::IParticle &p, EfficiencyType type) |
| Methods used to fill efficiencies. | |
| template<typename ReturnValue, typename... Args> | |
| static ReturnValue | getAttribute (const StringRef &tag, const AttributesMap &attributes, const std::string &type, const char *ref, ReturnValue rv, Args... args) |
| Helper methods. | |
| static void | assertNoLeftover (std::stringstream &ss, const StringRef &pos) |
| static constexpr unsigned short | maxIndex () |
| static std::string | getTypeAsString (EfficiencyType type) |
| static std::bitset< N_EFFICIENCY_TYPES > | selectTypesToFill (Client client) |
| This function is only called by the Database constructor. | |
Protected Attributes | |
| const bool | m_useGeV |
| const std::bitset< N_EFFICIENCY_TYPES > | m_typesToFill |
| const bool | m_convertWhenMissing |
| bool | m_storeAllUncertainties = true |
| std::vector< Param > | m_params |
| Permanent buffers. | |
| std::vector< SystDef > | m_systs |
| std::vector< StatDef > | m_stats |
| std::map< int, std::vector< EfficiencyTable > > | m_tables |
| std::string | m_xmlBuffer |
| Temporary buffers (only used while importing data) | |
| std::vector< std::size_t > | m_lineOffset |
| std::map< std::string, float > | m_normFactors |
Static Private Member Functions | |
| template<typename ReturnValue> | |
| static ReturnValue | getAttribute (const StringRef &attr, const char *ref, ReturnValue rv) |
| don't call these methods directly, use getAttribute(AttributesMap, string, ...) instead | |
| template<typename ReturnValue, typename... Args> | |
| static ReturnValue | getAttribute (const StringRef &attr, const char *ref, ReturnValue rv, Args... args) |
Definition at line 28 of file Database.h.
|
protected |
Definition at line 175 of file Database.h.
Definition at line 42 of file Database.h.
|
strong |
| Enumerator | |
|---|---|
| CENTRAL_VALUE | |
| CORRECTION | |
Definition at line 58 of file Database.h.
|
strong |
| Database::Database | ( | Client | client, |
| bool | useGeV, | ||
| bool | convertWhenMissing ) |
Definition at line 26 of file Database.cxx.
|
protected |
Also accept a simpler syntax for integers (e.g. nJets = "2")
the stream might have consumed the leading '-' in its failed attempt to read a number, so recover it
Definition at line 511 of file Database.cxx.
|
protected |
Definition at line 360 of file Database.cxx.
|
protected |
Definition at line 409 of file Database.cxx.
|
protected |
Definition at line 377 of file Database.cxx.
|
protected |
using the StringRef as map key ensures that dimensions will be listed in the same order as they were written
Definition at line 420 of file Database.cxx.
|
protected |
Definition at line 581 of file Database.cxx.
|
inlinestaticprotected |
|
protected |
Definition at line 305 of file Database.cxx.
|
protected |
Methods used to parse XML files.
Definition at line 289 of file Database.cxx.
| bool Database::fillEfficiencies | ( | ParticleData & | pd, |
| const xAOD::IParticle & | p, | ||
| const xAOD::EventInfo & | eventInfo, | ||
| std::string & | error ) const |
Loop over all the type of efficiencies (real, fake, fake factor) that were requested to be filled
pointer to the proper member of ParticleData that needs to be filled
The efficiency tables to look for might be for a different type (if a Fake efficiency <--> Fake factor conversion is needed)
Loop over all the tables found for that type of efficiency
an error occurred
this table contained the central values
only a single table should be providing central values (the other tables might provide corrections)
Transform the fake efficiency into fake factor (or reciprocally)
Definition at line 65 of file Database.cxx.
|
inline |
Definition at line 232 of file Database.h.
|
inline |
Definition at line 226 of file Database.h.
|
inlinestaticprivate |
don't call these methods directly, use getAttribute(AttributesMap, string, ...) instead
Definition at line 338 of file Database.cxx.
|
inlinestaticprivate |
Definition at line 345 of file Database.cxx.
|
inlinestaticprotected |
|
protected |
Definition at line 319 of file Database.cxx.
|
protected |
Should be called only when processing XMLs
in principle the denominator has been checked not to be 0
Definition at line 830 of file Database.cxx.
|
protected |
Definition at line 1111 of file Database.cxx.
|
staticprotected |
This function is only meant to be used to display meaningful error messages
Definition at line 1141 of file Database.cxx.
|
protected |
compute weighted average of all bins
central value of the correction will be 1, but uncertainties may matter, so this is also a valid case
Definition at line 803 of file Database.cxx.
| unsigned Database::getXmlLineNumber | ( | const char * | pos | ) | const |
Definition at line 1132 of file Database.cxx.
|
protected |
Definition at line 681 of file Database.cxx.
| void Database::importDefaultROOT | ( | std::string | filename | ) |
step 0 = central value + stats step 1 = systs
Efficiency type
Definition at line 742 of file Database.cxx.
|
protected |
Methods used to load from ROOT files.
Parameters and ranges
Copy, and include under/overflow into first/last bin:
Efficiencies + stat uncertainties
Definition at line 845 of file Database.cxx.
|
protected |
Definition at line 925 of file Database.cxx.
| void Database::importXML | ( | std::string | filename | ) |
not guaranteed that the above works, so truncating the buffer to a reasonable size if seemingly too large
Definition at line 186 of file Database.cxx.
|
inlinestaticconstexpr |
Definition at line 219 of file Database.h.
|
inlinestaticconstexpr |
Definition at line 223 of file Database.h.
|
inlinestaticconstexpr |
Definition at line 222 of file Database.h.
|
inlinestaticconstexprprotected |
Definition at line 209 of file Database.h.
| bool Database::needEventInfo | ( | ) | const |
will no longer work if some event-level parameteres are predefined
Definition at line 56 of file Database.cxx.
|
inline |
Definition at line 224 of file Database.h.
|
inline |
Definition at line 225 of file Database.h.
|
protected |
Check if the particle falls in one bin of this table
if not, return
Yes! So read the central value / correction / uncertainties
=> tool will return weight + all uncertainties at once
Definition at line 130 of file Database.cxx.
|
protected |
Note: when modifying the pattern, make sure to also change readTagAttributes() if required!
Perhaps here do some looser pattern-matching to figure out where the format was not good: missing quotation marks? missing attribute value? no closing tag?
Definition at line 235 of file Database.cxx.
|
protected |
Definition at line 258 of file Database.cxx.
| bool Database::ready | ( | ) | const |
Could do some more careful check here; for the moment just check that there's at least one table
Definition at line 46 of file Database.cxx.
| void Database::reset | ( | ) |
|
protected |
for now only a TH1 attribute
NB. the list of attributes allowed for bin or table tags can be further extended by new param tags. This is done inside addParams().
Definition at line 708 of file Database.cxx.
|
protected |
Definition at line 1012 of file Database.cxx.
|
staticprotected |
Methods used to fill efficiencies.
Definition at line 1055 of file Database.cxx.
|
staticprotected |
This function is only called by the Database constructor.
Definition at line 1084 of file Database.cxx.
|
inlinestaticconstexpr |
Definition at line 221 of file Database.h.
|
inlinestaticconstexpr |
Definition at line 220 of file Database.h.
|
protected |
Definition at line 244 of file Database.h.
|
protected |
Definition at line 255 of file Database.h.
|
protected |
Definition at line 256 of file Database.h.
|
protected |
Permanent buffers.
Definition at line 248 of file Database.h.
|
protected |
Definition at line 250 of file Database.h.
|
protected |
Definition at line 245 of file Database.h.
|
protected |
Definition at line 249 of file Database.h.
|
protected |
Definition at line 251 of file Database.h.
|
protected |
Definition at line 242 of file Database.h.
|
protected |
Definition at line 241 of file Database.h.
|
protected |
Temporary buffers (only used while importing data)
Definition at line 254 of file Database.h.