ATLAS Offline Software
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
xAOD::EventFormat_v1 Class Reference

Event format metadata for xAOD files. More...

#include <EventFormat_v1.h>

Collaboration diagram for xAOD::EventFormat_v1:

Public Types

typedef KeyedData_t::const_iterator const_iterator
 Iterator for looping over the elements of the object. More...
 

Public Member Functions

 EventFormat_v1 ()
 Default constructor. More...
 
void add (const EventFormatElement &element, bool updatePersistent=true)
 Add the description of a new branch. More...
 
bool exists (const std::string &key) const
 Check if a description exists about a given branch. More...
 
bool exists (uint32_t hash) const
 Check if a description exists about a given branch. More...
 
const EventFormatElementget (const std::string &key, bool quiet=false) const
 Get the description of a given branch. More...
 
const EventFormatElementget (uint32_t hash, bool quiet=false) const
 Get the description of a given branch. More...
 
void clear ()
 Clear the object. More...
 
const_iterator begin () const
 STL-like function for getting the beginning of the container. More...
 
const_iterator end () const
 STL-like function for getting the end of the container. More...
 
void toTransient ()
 Interpret the persistent members of the object. More...
 
void dump () const
 Dump the contents of this object. More...
 

Private Types

typedef std::map< std::string, EventFormatElementKeyedData_t
 Type of the key->data in-memory object. More...
 
typedef std::map< uint32_t, EventFormatElementHashedData_t
 Type of the hash->data in-memory object. More...
 

Private Attributes

KeyedData_t m_keyedData
 Object associating string keys with the descriptions. More...
 
HashedData_t m_hashedData
 Object associating hash keys with the descriptions. More...
 
std::vector< std::string > m_branchNames
 Names of the branches that we are describing. More...
 
std::vector< std::string > m_classNames
 Names of the transient objects belonging to the branch names. More...
 
std::vector< std::string > m_parentNames
 Names of the auxiliary parents of the branches. More...
 
std::vector< uint32_tm_branchHashes
 Hashed versions of the branch names. More...
 

Detailed Description

Event format metadata for xAOD files.

This class is used to save file-level metadata about the format of xAOD files. It is not meant to be used directly by analysers, but just by the code that they use, behind the scenes.

Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h
Revision
641134
Date
2015-01-22 20:35:12 +0100 (Thu, 22 Jan 2015)

Definition at line 38 of file EventFormat_v1.h.

Member Typedef Documentation

◆ const_iterator

typedef KeyedData_t::const_iterator xAOD::EventFormat_v1::const_iterator

Iterator for looping over the elements of the object.

Definition at line 67 of file EventFormat_v1.h.

◆ HashedData_t

Type of the hash->data in-memory object.

Definition at line 43 of file EventFormat_v1.h.

◆ KeyedData_t

typedef std::map< std::string, EventFormatElement > xAOD::EventFormat_v1::KeyedData_t
private

Type of the key->data in-memory object.

Definition at line 41 of file EventFormat_v1.h.

Constructor & Destructor Documentation

◆ EventFormat_v1()

xAOD::EventFormat_v1::EventFormat_v1 ( )

Default constructor.

Definition at line 35 of file EventFormat_v1.cxx.

36  : m_keyedData(), m_hashedData() {
37 
38  }

Member Function Documentation

◆ add()

void xAOD::EventFormat_v1::add ( const EventFormatElement element,
bool  updatePersistent = true 
)

Add the description of a new branch.

This function can be used to extend the object with a new element.

Parameters
elementThe element to add to the object

Definition at line 43 of file EventFormat_v1.cxx.

44  {
45 
46  // Set the transient-only variables:
47  m_keyedData[ element.branchName() ] = element;
48  m_hashedData[ element.hash() ] = element;
49 
50  // Set the persistent variables:
51  if( updatePersistent ) {
52  m_branchNames.push_back( element.branchName() );
53  m_classNames.push_back( element.className() );
54  m_parentNames.push_back( element.parentName() );
55  m_branchHashes.push_back( element.hash() );
56  }
57  return;
58  }

◆ begin()

EventFormat_v1::const_iterator xAOD::EventFormat_v1::begin ( ) const

STL-like function for getting the beginning of the container.

Definition at line 158 of file EventFormat_v1.cxx.

158  {
159 
160  return m_keyedData.begin();
161  }

◆ clear()

void xAOD::EventFormat_v1::clear ( )

Clear the object.

Definition at line 144 of file EventFormat_v1.cxx.

144  {
145 
146  // Clear the transient variables:
147  m_keyedData.clear();
148  m_hashedData.clear();
149 
150  // Clear the persistent variables:
151  m_branchNames.clear();
152  m_classNames.clear();
153  m_parentNames.clear();
154  m_branchHashes.clear();
155  return;
156  }

◆ dump()

void xAOD::EventFormat_v1::dump ( ) const

Dump the contents of this object.

Definition at line 223 of file EventFormat_v1.cxx.

224  {
225  std::cout << *this;
226  }

◆ end()

EventFormat_v1::const_iterator xAOD::EventFormat_v1::end ( ) const

STL-like function for getting the end of the container.

Definition at line 163 of file EventFormat_v1.cxx.

163  {
164 
165  return m_keyedData.end();
166  }

◆ exists() [1/2]

bool xAOD::EventFormat_v1::exists ( const std::string &  key) const

Check if a description exists about a given branch.

Parameters
keyThe name of the branch to check
Returns
true if the branch is knows, false if not

Definition at line 65 of file EventFormat_v1.cxx.

65  {
66 
67  return ( m_keyedData.find( key ) != m_keyedData.end() );
68  }

◆ exists() [2/2]

bool xAOD::EventFormat_v1::exists ( uint32_t  hash) const

Check if a description exists about a given branch.

Parameters
hashHashed version of the branch name to check
Returns
true if the branch is knows, false if not

Definition at line 75 of file EventFormat_v1.cxx.

75  {
76 
77  return ( m_hashedData.find( hash ) != m_hashedData.end() );
78  }

◆ get() [1/2]

const EventFormatElement * xAOD::EventFormat_v1::get ( const std::string &  key,
bool  quiet = false 
) const

Get the description of a given branch.

This function can be used to get access to one element in the object.

Notice that the user code should first check if an element exists, and only use this function if it does.

Parameters
keyThe name of the branch to get the information for
quietIf true, silently return 0 if the hash isn't found; otherwise, print an error.
Returns
A pointer to the element describing the requested branch

Definition at line 91 of file EventFormat_v1.cxx.

91  {
92 
93  KeyedData_t::const_iterator itr = m_keyedData.find( key );
94  if( itr == m_keyedData.end() ) {
95  if (!quiet) {
96  std::cerr << "<xAOD::EventFormat_v1::get>"
97  << " Information requested about unknown branch ("
98  << key << ")" << std::endl;
99  }
100  return nullptr;
101  }
102 
103  return &( itr->second );
104  }

◆ get() [2/2]

const EventFormatElement * xAOD::EventFormat_v1::get ( uint32_t  hash,
bool  quiet = false 
) const

Get the description of a given branch.

This function can return the element describing a given branch.

Notice that the user code should first check if an element exists, and only use this function if it does.

Parameters
hashThe hashed version of the name of the branch
quietIf true, silently return 0 if the hash isn't found; otherwise, print an error.
Returns
A pointer to the element describing the requested branch

Definition at line 116 of file EventFormat_v1.cxx.

116  {
117 
118  HashedData_t::const_iterator itr = m_hashedData.find( hash );
119  if( itr == m_hashedData.end() ) {
120  if (!quiet) {
121  // Get the current state of the stream:
122  const char fillChar = std::cerr.fill();
123  const std::ios_base::fmtflags flags = std::cerr.flags();
124  const std::streamsize width = std::cerr.width();
125 
126  // Do the printout:
127  std::cerr << "<xAOD::EventFormat_v1::get>"
128  << " Information requested about unknown hash ("
129  << std::setw( 8 ) << std::hex << std::setfill( '0' )
130  << hash << ")" << std::endl;
131 
132  // Restore the original state of the stream:
133  std::cerr.fill( fillChar );
134  std::cerr.flags( flags );
135  std::cerr.width( width );
136  }
137 
138  return nullptr;
139  }
140 
141  return &( itr->second );
142  }

◆ toTransient()

void xAOD::EventFormat_v1::toTransient ( )

Interpret the persistent members of the object.

Definition at line 168 of file EventFormat_v1.cxx.

168  {
169 
170  // Clear the transient variables:
171  m_keyedData.clear();
172  m_hashedData.clear();
173 
174  // A little sanity check:
175  if( ( m_branchNames.size() != m_classNames.size() ) ||
176  ( m_branchNames.size() != m_parentNames.size() ) ||
177  ( m_branchNames.size() != m_branchHashes.size() ) ) {
178  std::cerr << "<xAOD::EventFormat_v1::toTransient> "
179  << "Internal inconsistency in the persistent data"
180  << std::endl;
181  std::cerr << " m_branchNames = " << m_branchNames << std::endl;
182  std::cerr << " m_classNames = " << m_classNames << std::endl;
183  std::cerr << " m_parentNames = " << m_parentNames << std::endl;
184  std::cerr << " m_branchHashes = " << m_branchHashes << std::endl;
185  return;
186  }
187 
188  // Set up the transient variables:
189  for( size_t i = 0; i < m_branchNames.size(); ++i ) {
190  add( EventFormatElement( m_branchNames[ i ],
191  m_classNames[ i ],
192  m_parentNames[ i ],
193  m_branchHashes[ i ] ),
194  false );
195  }
196 
197  return;
198  }

Member Data Documentation

◆ m_branchHashes

std::vector< uint32_t > xAOD::EventFormat_v1::m_branchHashes
private

Hashed versions of the branch names.

Definition at line 92 of file EventFormat_v1.h.

◆ m_branchNames

std::vector< std::string > xAOD::EventFormat_v1::m_branchNames
private

Names of the branches that we are describing.

Definition at line 86 of file EventFormat_v1.h.

◆ m_classNames

std::vector< std::string > xAOD::EventFormat_v1::m_classNames
private

Names of the transient objects belonging to the branch names.

Definition at line 88 of file EventFormat_v1.h.

◆ m_hashedData

HashedData_t xAOD::EventFormat_v1::m_hashedData
private

Object associating hash keys with the descriptions.

Definition at line 83 of file EventFormat_v1.h.

◆ m_keyedData

KeyedData_t xAOD::EventFormat_v1::m_keyedData
private

Object associating string keys with the descriptions.

Definition at line 81 of file EventFormat_v1.h.

◆ m_parentNames

std::vector< std::string > xAOD::EventFormat_v1::m_parentNames
private

Names of the auxiliary parents of the branches.

Definition at line 90 of file EventFormat_v1.h.


The documentation for this class was generated from the following files:
quiet
bool quiet
Definition: TrigGlobEffCorrValidation.cxx:170
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
xAOD::EventFormat_v1::m_classNames
std::vector< std::string > m_classNames
Names of the transient objects belonging to the branch names.
Definition: EventFormat_v1.h:88
xAOD::EventFormat_v1::m_hashedData
HashedData_t m_hashedData
Object associating hash keys with the descriptions.
Definition: EventFormat_v1.h:83
xAOD::EventFormat_v1::m_keyedData
KeyedData_t m_keyedData
Object associating string keys with the descriptions.
Definition: EventFormat_v1.h:81
xAOD::EventFormat_v1::m_branchHashes
std::vector< uint32_t > m_branchHashes
Hashed versions of the branch names.
Definition: EventFormat_v1.h:92
xAOD::EventFormat_v1::m_parentNames
std::vector< std::string > m_parentNames
Names of the auxiliary parents of the branches.
Definition: EventFormat_v1.h:90
lumiFormat.i
int i
Definition: lumiFormat.py:92
xAOD::EventFormat_v1::m_branchNames
std::vector< std::string > m_branchNames
Names of the branches that we are describing.
Definition: EventFormat_v1.h:86
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
xAOD::EventFormat_v1::add
void add(const EventFormatElement &element, bool updatePersistent=true)
Add the description of a new branch.
Definition: EventFormat_v1.cxx:43
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37