ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
xAOD::BPhysMetaDataHelper Class Reference

Helper class providing easy access to FileMetaData object holding file-level metadata about an xAOD file specific to B-physics derivations. More...

#include <BPhysMetaDataHelper.h>

Collaboration diagram for xAOD::BPhysMetaDataHelper:

Public Member Functions

 BPhysMetaDataHelper (const xAOD::FileMetaData *fm)
 Main constructor. More...
 
const xAOD::FileMetaDatametaObj () const
 Getter method for the cached xAOD::FileMetaData object. More...
 
void setPrefix (std::string prefix)
 Set prefix for variable names. More...
 
std::map< std::string, const std::type_info * > varTypes () const
 Map of metadata names and types. More...
 
TString varTypesToString (TString header="") const
 List of metadata names and types as string. More...
 
TString metaDataToString (TString header="") const
 Complete metadata contents as TString. More...
 
Getter methods for different metadata types
Parameters
[in]namename of metadata variable (without prefix)
[out]valvalue of metadata variable
Returns
true if named variable exists
Note
applies prefix to each variable name
bool value (const std::string &name, int &val) const
 
bool value (const std::string &name, float &val) const
 
bool value (const std::string &name, double &val) const
 
bool value (const std::string &name, bool &val) const
 
bool value (const std::string &name, std::string &val) const
 
bool value (const std::string &name, std::vector< int > &val) const
 
bool value (const std::string &name, std::vector< float > &val) const
 
bool value (const std::string &name, std::vector< double > &val) const
 
bool value (const std::string &name, std::vector< bool > &val) const
 
bool value (const std::string &name, std::vector< std::string > &val) const
 
Getter methods for maps of different metadata types
std::map< std::string, intvaluesI () const
 
std::map< std::string, floatvaluesF () const
 
std::map< std::string, doublevaluesD () const
 
std::map< std::string, boolvaluesB () const
 
std::map< std::string, std::string > valuesS () const
 
std::map< std::string, std::vector< int > > valuesVI () const
 
std::map< std::string, std::vector< float > > valuesVF () const
 
std::map< std::string, std::vector< double > > valuesVD () const
 
std::map< std::string, std::vector< bool > > valuesVB () const
 
std::map< std::string, std::vector< std::string > > valuesVS () const
 

Protected Member Functions

void cacheVarTypes () const
 Updating internal variable-to-variable-type cache. More...
 

Protected Attributes

const xAOD::FileMetaDatam_fm
 FileMetaData object pointer. More...
 
std::string m_prefix
 Prefix for variable names. More...
 
Internal caches and corresponding switches
std::map< std::string, const std::type_info * > m_tmap
 map of metadata names and variable types More...
 
bool m_tmapOk
 flag indicating an up-to-date cache More...
 

Detailed Description

Helper class providing easy access to FileMetaData object holding file-level metadata about an xAOD file specific to B-physics derivations.

Author
Wolfgang Walkowiak Wolfg.nosp@m.ang..nosp@m.Walko.nosp@m.wiak.nosp@m.@cern.nosp@m..ch

Definition at line 58 of file BPhysMetaDataHelper.h.

Constructor & Destructor Documentation

◆ BPhysMetaDataHelper()

xAOD::BPhysMetaDataHelper::BPhysMetaDataHelper ( const xAOD::FileMetaData fm)

Main constructor.

The main contructor. BPhysMetaDataHelper does NOT take ownership of the class "metaObj".

Parameters
[in]fmPointer to the xAOD::FileMetaData.

Definition at line 26 of file BPhysMetaDataHelper.cxx.

27  : m_fm(fm), m_tmapOk(false) {
28 
29  assert(m_fm != 0); // sanity check: m_fm must not be null
30  }

Member Function Documentation

◆ cacheVarTypes()

void xAOD::BPhysMetaDataHelper::cacheVarTypes ( ) const
protected

Updating internal variable-to-variable-type cache.

Definition at line 128 of file BPhysMetaDataHelper.cxx.

128  {
129 
130  // Get the variable types
131  const SG::auxid_set_t& auxids = m_fm->getAuxIDs();
132  for ( SG::auxid_t auxid : auxids ) {
134  m_tmap[reg.getName(auxid)] = reg.getType(auxid);
135  }
136  m_tmapOk = true;
137  }

◆ metaDataToString()

TString xAOD::BPhysMetaDataHelper::metaDataToString ( TString  header = "") const

Complete metadata contents as TString.

Parameters
[in]headeroptional header string for table
Returns
TString with metadata contents as table

Definition at line 53 of file BPhysMetaDataHelper.cxx.

53  {
54 
55  TString str = std::move(header);
56  std::map<std::string, std::string> ms = valuesS();
57  for ( auto it = ms.begin(); it != ms.end(); ++it ) {
58  str += Form("%-30s :S : %s\n", it->first.c_str(), it->second.c_str());
59  }
60  std::map<std::string, int> mi = valuesI();
61  for ( auto it = mi.begin(); it != mi.end(); ++it ) {
62  str += Form("%-30s :I : %d\n", it->first.c_str(), it->second);
63  }
64  std::map<std::string, float> mf = valuesF();
65  for ( auto it = mf.begin(); it != mf.end(); ++it ) {
66  str += Form("%-30s :F : %f\n", it->first.c_str(), it->second);
67  }
68  std::map<std::string, double> md = valuesD();
69  for ( auto it = md.begin(); it != md.end(); ++it ) {
70  str += Form("%-30s :D : %f\n", it->first.c_str(), it->second);
71  }
72  std::map<std::string, bool> mb = valuesB();
73  for ( auto it = mb.begin(); it != mb.end(); ++it ) {
74  str += Form("%-30s :B : %s\n", it->first.c_str(),
75  (it->second ? "True" : "False") );
76  }
77  std::map<std::string, std::vector<int> > mvi = valuesVI();
78  for ( auto it = mvi.begin(); it != mvi.end(); ++it ) {
79  TString strv;
80  for (auto &ent : it->second) {
81  strv += Form("%d,", ent);
82  }
83  strv.Remove(TString::kTrailing, ',');
84  str += Form("%-30s :VI: [%s]\n", it->first.c_str(), strv.Data());
85  }
86  std::map<std::string, std::vector<float> > mvf = valuesVF();
87  for ( auto it = mvf.begin(); it != mvf.end(); ++it ) {
88  TString strv;
89  for (auto &ent : it->second) {
90  strv += Form("%f,", ent);
91  }
92  strv.Remove(TString::kTrailing, ',');
93  str += Form("%-30s :VF: [%s]\n", it->first.c_str(), strv.Data());
94  }
95  std::map<std::string, std::vector<double> > mvd = valuesVD();
96  for ( auto it = mvd.begin(); it != mvd.end(); ++it ) {
97  TString strv;
98  for (auto &ent : it->second) {
99  strv += Form("%f,", ent);
100  }
101  strv.Remove(TString::kTrailing, ',');
102  str += Form("%-30s :VD: [%s]\n", it->first.c_str(), strv.Data());
103  }
104  std::map<std::string, std::vector<bool> > mvb = valuesVB();
105  for ( auto it = mvb.begin(); it != mvb.end(); ++it ) {
106  TString strv;
107  // vector<bool> needs special treatment
108  for (auto &&ent : it->second) {
109  strv += Form("%s,", ent ? "True" : "False");
110  }
111  strv.Remove(TString::kTrailing, ',');
112  str += Form("%-30s :VB: [%s]\n", it->first.c_str(), strv.Data());
113  }
114  std::map<std::string, std::vector<std::string> > mvs = valuesVS();
115  for ( auto it = mvs.begin(); it != mvs.end(); ++it ) {
116  TString strv;
117  for (auto &ent : it->second) {
118  strv += Form("%s,", ent.c_str());;
119  }
120  strv.Remove(TString::kTrailing, ',');
121  str += Form("%-30s :VS: [%s]\n", it->first.c_str(), strv.Data());
122  }
123  str.Remove(TString::kTrailing, '\n');
124 
125  return str;
126  }

◆ metaObj()

const xAOD::FileMetaData * xAOD::BPhysMetaDataHelper::metaObj ( ) const

Getter method for the cached xAOD::FileMetaData object.

Returns
cached xAOD::FileMetaData.

Definition at line 32 of file BPhysMetaDataHelper.cxx.

32  {
33 
34  return m_fm;
35  }

◆ setPrefix()

void xAOD::BPhysMetaDataHelper::setPrefix ( std::string  prefix)

Set prefix for variable names.

Definition at line 37 of file BPhysMetaDataHelper.cxx.

37  {
38 
39  m_prefix = std::move(prefix);
40  }

◆ value() [1/10]

bool xAOD::BPhysMetaDataHelper::value ( const std::string &  name,
bool val 
) const

◆ value() [2/10]

bool xAOD::BPhysMetaDataHelper::value ( const std::string &  name,
double val 
) const

◆ value() [3/10]

bool xAOD::BPhysMetaDataHelper::value ( const std::string &  name,
float val 
) const

◆ value() [4/10]

bool xAOD::BPhysMetaDataHelper::value ( const std::string &  name,
int val 
) const

◆ value() [5/10]

bool xAOD::BPhysMetaDataHelper::value ( const std::string &  name,
std::string &  val 
) const

◆ value() [6/10]

bool xAOD::BPhysMetaDataHelper::value ( const std::string &  name,
std::vector< bool > &  val 
) const

◆ value() [7/10]

bool xAOD::BPhysMetaDataHelper::value ( const std::string &  name,
std::vector< double > &  val 
) const

◆ value() [8/10]

bool xAOD::BPhysMetaDataHelper::value ( const std::string &  name,
std::vector< float > &  val 
) const

◆ value() [9/10]

bool xAOD::BPhysMetaDataHelper::value ( const std::string &  name,
std::vector< int > &  val 
) const

◆ value() [10/10]

bool xAOD::BPhysMetaDataHelper::value ( const std::string &  name,
std::vector< std::string > &  val 
) const

◆ valuesB()

std::map<std::string, bool> xAOD::BPhysMetaDataHelper::valuesB ( ) const

◆ valuesD()

std::map<std::string, double> xAOD::BPhysMetaDataHelper::valuesD ( ) const

◆ valuesF()

std::map<std::string, float> xAOD::BPhysMetaDataHelper::valuesF ( ) const

◆ valuesI()

std::map<std::string, int> xAOD::BPhysMetaDataHelper::valuesI ( ) const

◆ valuesS()

std::map<std::string, std::string> xAOD::BPhysMetaDataHelper::valuesS ( ) const

◆ valuesVB()

std::map<std::string, std::vector<bool> > xAOD::BPhysMetaDataHelper::valuesVB ( ) const

◆ valuesVD()

std::map<std::string, std::vector<double> > xAOD::BPhysMetaDataHelper::valuesVD ( ) const

◆ valuesVF()

std::map<std::string, std::vector<float> > xAOD::BPhysMetaDataHelper::valuesVF ( ) const

◆ valuesVI()

std::map<std::string, std::vector<int> > xAOD::BPhysMetaDataHelper::valuesVI ( ) const

◆ valuesVS()

std::map<std::string, std::vector<std::string> > xAOD::BPhysMetaDataHelper::valuesVS ( ) const

◆ varTypes()

std::map< std::string, const std::type_info * > xAOD::BPhysMetaDataHelper::varTypes ( ) const

Map of metadata names and types.

Definition at line 43 of file BPhysMetaDataHelper.cxx.

43  {
44 
45  if ( ! m_tmapOk ) cacheVarTypes();
46 
47  return m_tmap;
48  }

◆ varTypesToString()

TString xAOD::BPhysMetaDataHelper::varTypesToString ( TString  header = "") const

List of metadata names and types as string.

Parameters
[in]headeroptional header string for table
Returns
TString with list of variable types used by metadata

Definition at line 139 of file BPhysMetaDataHelper.cxx.

139  {
140 
141  TString str = std::move(header);
142  if ( !m_tmapOk ) cacheVarTypes();
143  for (auto &ent : m_tmap) {
144  str += Form("%-30s : %s\n", ent.first.c_str(),
145  SG::normalizedTypeinfoName( *ent.second ).c_str());
146  }
147  str.Remove(TString::kTrailing, '\n');
148  return str;
149  }

Member Data Documentation

◆ m_fm

const xAOD::FileMetaData* xAOD::BPhysMetaDataHelper::m_fm
protected

FileMetaData object pointer.

Definition at line 144 of file BPhysMetaDataHelper.h.

◆ m_prefix

std::string xAOD::BPhysMetaDataHelper::m_prefix
protected

Prefix for variable names.

Definition at line 147 of file BPhysMetaDataHelper.h.

◆ m_tmap

std::map<std::string, const std::type_info*> xAOD::BPhysMetaDataHelper::m_tmap
mutableprotected

map of metadata names and variable types

Definition at line 153 of file BPhysMetaDataHelper.h.

◆ m_tmapOk

bool xAOD::BPhysMetaDataHelper::m_tmapOk
mutableprotected

flag indicating an up-to-date cache

Definition at line 155 of file BPhysMetaDataHelper.h.


The documentation for this class was generated from the following files:
xAOD::BPhysMetaDataHelper::valuesVS
std::map< std::string, std::vector< std::string > > valuesVS() const
xAOD::BPhysMetaDataHelper::m_fm
const xAOD::FileMetaData * m_fm
FileMetaData object pointer.
Definition: BPhysMetaDataHelper.h:144
header
Definition: hcg.cxx:526
xAOD::BPhysMetaDataHelper::m_prefix
std::string m_prefix
Prefix for variable names.
Definition: BPhysMetaDataHelper.h:147
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:49
SG::normalizedTypeinfoName
std::string normalizedTypeinfoName(const std::type_info &info)
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
Definition: normalizedTypeinfoName.cxx:120
xAOD::BPhysMetaDataHelper::valuesS
std::map< std::string, std::string > valuesS() const
skel.it
it
Definition: skel.GENtoEVGEN.py:424
python.DomainsRegistry.reg
reg
globals -----------------------------------------------------------------—
Definition: DomainsRegistry.py:343
xAOD::BPhysMetaDataHelper::valuesVB
std::map< std::string, std::vector< bool > > valuesVB() const
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
xAOD::BPhysMetaDataHelper::cacheVarTypes
void cacheVarTypes() const
Updating internal variable-to-variable-type cache.
Definition: BPhysMetaDataHelper.cxx:128
DQPostProcessTest.mf
mf
Definition: DQPostProcessTest.py:19
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:62
xAOD::BPhysMetaDataHelper::valuesVD
std::map< std::string, std::vector< double > > valuesVD() const
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
xAOD::BPhysMetaDataHelper::valuesF
std::map< std::string, float > valuesF() const
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
SG::AuxElement::getAuxIDs
const SG::auxid_set_t & getAuxIDs() const
Return a set of identifiers for existing data items for this object.
Definition: AuxElement.cxx:335
xAOD::str
std::string str(const TrigT2MbtsBits_v1 &trigT2MbtsBits)
Definition: TrigT2MbtsBits_v1.cxx:37
xAOD::BPhysMetaDataHelper::valuesI
std::map< std::string, int > valuesI() const
xAOD::BPhysMetaDataHelper::m_tmap
std::map< std::string, const std::type_info * > m_tmap
map of metadata names and variable types
Definition: BPhysMetaDataHelper.h:153
xAOD::BPhysMetaDataHelper::valuesVF
std::map< std::string, std::vector< float > > valuesVF() const
xAOD::BPhysMetaDataHelper::m_tmapOk
bool m_tmapOk
flag indicating an up-to-date cache
Definition: BPhysMetaDataHelper.h:155
TRT_PAI_physicsConstants::mb
const double mb
1mb to cm2
Definition: TRT_PAI_physicsConstants.h:15
xAOD::BPhysMetaDataHelper::valuesVI
std::map< std::string, std::vector< int > > valuesVI() const
SG::auxid_set_t
A set of aux data identifiers.
Definition: AuxTypes.h:47
str
Definition: BTagTrackIpAccessor.cxx:11
xAOD::BPhysMetaDataHelper::valuesB
std::map< std::string, bool > valuesB() const
xAOD::BPhysMetaDataHelper::valuesD
std::map< std::string, double > valuesD() const