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

#include <TrigComposite.h>

Collaboration diagram for TrigComposite:

Public Member Functions

 TrigComposite (const std::string &name)
 Constructs empty composite, no objects no details. More...
 
 TrigComposite (const std::string &name, std::string &label1, TrigFeatureLink t1, std::string &label2, TrigFeatureLink t2)
 Constructs composite with the links to two trigger objects/links to them The validity of the links is not checked during the construction. More...
 
const std::string & name () const
 
template<typename T >
void setFormat (const std::vector< std::string > &keys, bool mustBeSet=false)
 defines the content (details which must to be stored) The method can be used to enforce certain content of the object (set the demand that the deail are set). More...
 
bool isValid () const
 Checks the validity of the format, i.e. More...
 
void lockFormat ()
 makes further addition of the details impossible More...
 
bool isFormatLocked () const
 return true if the format can not be further changed (no addDetail can be called) More...
 
void unlockFormat ()
 makes addition of further details possible again More...
 
void addObject (const std::string &key, TrigFeatureLink link)
 adds the link More...
 
void setObject (const std::string &key, TrigFeatureLink link)
 sets the link More...
 
bool hasObject (const std::string &key) const
 checks if the object has link to the object under the key More...
 
const TrigFeatureLinkgetObject (const std::string &key) const
 returns More...
 
template<typename T >
std::vector< TrigFeatureLinkgetObjectsByType (const std::string &keypart="") const
 get all links which point to objects of given type More...
 
template<typename T >
void addDetail (const std::string &key, const T &value=T())
 adds the value user the key, if they detail under that key already exists the exception is thrown If the format is locked the exception is thrown each time More...
 
template<typename T >
void setDetail (const std::string &key, const T &value)
 sets the value user the key, if they detail under that key already exists it's value is overwritten, If the key does not exists, the exception is thrown More...
 
template<typename T >
bool hasDetail (const std::string &key) const
 Checks if the object contains detail of the type T No verification is made if it is set. More...
 
template<typename T >
const T & getDetail (const std::string &key) const
 return the value of the detail, if the key is absent the default is returned More...
 
template<class T >
const std::map< std::string, T > & allDetails () const
 return the map of all the details Notie that the non-const version is not provided because it would allow to circumvent format fixing whcih may be defined for this object. More...
 
template<typename T >
void eraseDetail (const std::string &key)
 erases the detail if it existed If the details inder that key did not exist, no action is performed. More...
 
 TrigComposite ()
 Deafault constructor, should not be normally used, needed by the persistency layer. More...
 
 ~TrigComposite ()
 Destructor, does nothing special in fact, no links are touched. More...
 

Private Types

typedef std::set< std::string > MustSetList
 

Private Member Functions

template<class T >
void mustSet (const std::string &key)
 
template<typename T >
std::map< std::string, T > & detailsMap ()
 
template<typename T >
const std::map< std::string, T > & detailsMap () const
 
template<typename T >
MustSetListdetailsMustSetList ()
 
template<typename T >
const T & specimen () const
 

Private Attributes

std::map< std::string, TrigFeatureLinkm_links
 
MustSetList m_linksToBeSet
 
std::map< std::string, float > m_floats
 
MustSetList m_floatsToBeSet
 
std::map< std::string, int > m_ints
 
MustSetList m_intsToBeSet
 
std::map< std::string, std::string > m_strings
 
MustSetList m_stringsToBeSet
 
std::map< std::string, std::vector< float > > m_v_floats
 
MustSetList m_v_floatsToBeSet
 
std::map< std::string, std::vector< int > > m_v_ints
 
MustSetList m_v_intsToBeSet
 
std::map< std::string, std::vector< std::string > > m_v_strings
 
MustSetList m_v_stringsToBeSet
 
std::string m_name
 
bool m_locked
 

Detailed Description

The class is meant to store links (of type TrigFeatureLink) to trigger objects and arbitrary details (of type, float, int, string, or vectors of those)

Author
Camille Belanger-Champagne
Tomasz Bold

Definition at line 26 of file Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h.

Member Typedef Documentation

◆ MustSetList

typedef std::set<std::string> TrigComposite::MustSetList
private

Constructor & Destructor Documentation

◆ TrigComposite() [1/3]

TrigComposite::TrigComposite ( const std::string &  name)

Constructs empty composite, no objects no details.

Definition at line 19 of file TrigComposite.cxx.

20  : m_name(name),
21  m_locked(false)
22 {
23 }

◆ TrigComposite() [2/3]

TrigComposite::TrigComposite ( const std::string &  name,
std::string &  label1,
TrigFeatureLink  t1,
std::string &  label2,
TrigFeatureLink  t2 
)

Constructs composite with the links to two trigger objects/links to them The validity of the links is not checked during the construction.

Definition at line 26 of file TrigComposite.cxx.

27  : m_name(name),
28  m_locked(false)
29 {
30  addObject(label1, t1);
32 }

◆ TrigComposite() [3/3]

TrigComposite::TrigComposite ( )

Deafault constructor, should not be normally used, needed by the persistency layer.

Definition at line 13 of file TrigComposite.cxx.

14  : m_name("dummy"),
15  m_locked(false)
16 {
17 }

◆ ~TrigComposite()

TrigComposite::~TrigComposite ( )

Destructor, does nothing special in fact, no links are touched.

Definition at line 83 of file TrigComposite.cxx.

83 {}

Member Function Documentation

◆ addDetail()

template<typename T >
void TrigComposite::addDetail ( const std::string &  key,
const T &  value = T() 
)

adds the value user the key, if they detail under that key already exists the exception is thrown If the format is locked the exception is thrown each time

Definition at line 89 of file TrigComposite.cxx.

89  {
90  if ( isFormatLocked() )
91  throw std::invalid_argument("The format of TrigComposite object has been locked, addDetails can not be used anymore, see unlockFormat or setDetail");
92  if ( hasDetail<T>(key) )
93  throw std::invalid_argument("The TrigCompositeObejct already has key: "+ key);
94 
95  // now it needs to fins appropriate collection and add to it the value
96  detailsMap<T>()[key] = value;
97 }

◆ addObject()

void TrigComposite::addObject ( const std::string &  key,
TrigFeatureLink  link 
)

adds the link

See also
TrigFeatuerLink to the object, link is not checked for the validity,
addDetail

Definition at line 54 of file TrigComposite.cxx.

54  {
55  addDetail(key, link);
56 }

◆ allDetails()

template<class T >
const std::map<std::string, T>& TrigComposite::allDetails ( ) const
inline

return the map of all the details Notie that the non-const version is not provided because it would allow to circumvent format fixing whcih may be defined for this object.

Definition at line 149 of file Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h.

149  {
150  return detailsMap<T>();
151  }

◆ detailsMap() [1/2]

template<typename T >
std::map< std::string, T > & TrigComposite::detailsMap
private

Definition at line 135 of file TrigComposite.cxx.

135  {
136  // this should never be needed, need to add compile error here
137  [[maybe_unused]]
138  int z =
139  sizeof(struct TrigComposite_does_not_support_that_type_as_a_detail);
140  std::abort();
141 }

◆ detailsMap() [2/2]

template<typename T >
const std::map< std::string, T > & TrigComposite::detailsMap
private

Definition at line 144 of file TrigComposite.cxx.

144  {
145  // this should never be needed, need to add compile error here
146  [[maybe_unused]]
147  int z =
148  sizeof(struct TrigComposite_does_not_support_that_type_as_a_detail);
149  std::abort();
150 }

◆ detailsMustSetList()

template<typename T >
MustSetList& TrigComposite::detailsMustSetList ( )
private

◆ eraseDetail()

template<typename T >
void TrigComposite::eraseDetail ( const std::string &  key)

erases the detail if it existed If the details inder that key did not exist, no action is performed.

Definition at line 129 of file TrigComposite.cxx.

129  {
130  detailsMap<T>().erase(key);
131 }

◆ getDetail()

template<typename T >
const T & TrigComposite::getDetail ( const std::string &  key) const

return the value of the detail, if the key is absent the default is returned

Definition at line 121 of file TrigComposite.cxx.

121  {
122  if ( hasDetail<T>(key) )
123  return detailsMap<T>().find(key)->second;
124  return specimen<T>();
125 }

◆ getObject()

const TrigFeatureLink & TrigComposite::getObject ( const std::string &  key) const

returns

See also
TrigFeatureLink associated to the key, if there is none, the invalid TrigFeatureLink is returned

Definition at line 67 of file TrigComposite.cxx.

67  {
68  return getDetail<TrigFeatureLink>(key);
69 }

◆ getObjectsByType()

template<typename T >
std::vector< TrigFeatureLink > TrigComposite::getObjectsByType ( const std::string &  keypart = "") const

get all links which point to objects of given type

  • keypart retrieve only objects with matching key, (checked by means of string::find)

Definition at line 225 of file Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h.

225  {
226  const CLID requested_clid = ClassID_traits<T>::ID();
227  std::vector<TrigFeatureLink> result;
228  for ( std::map<std::string, TrigFeatureLink>::const_iterator i = m_links.begin(); i != m_links.end(); ++i ) {
229  if ( i->second.clid() == requested_clid and i->first.find(keypart) != std::string::npos)
230  result.push_back(i->second);
231  }
232  return result;
233 }

◆ hasDetail()

template<typename T >
bool TrigComposite::hasDetail ( const std::string &  key) const

Checks if the object contains detail of the type T No verification is made if it is set.

Definition at line 112 of file TrigComposite.cxx.

112  {
113  return detailsMap<T>().find(key) != detailsMap<T>().end();
114 }

◆ hasObject()

bool TrigComposite::hasObject ( const std::string &  key) const

checks if the object has link to the object under the key

Definition at line 63 of file TrigComposite.cxx.

63  {
64  return hasDetail<TrigFeatureLink>(key);
65 }

◆ isFormatLocked()

bool TrigComposite::isFormatLocked ( ) const
inline

return true if the format can not be further changed (no addDetail can be called)

Definition at line 71 of file Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h.

71 {return m_locked; }

◆ isValid()

bool TrigComposite::isValid ( ) const

Checks the validity of the format, i.e.

if all the details which were meant to be added are added

Definition at line 71 of file TrigComposite.cxx.

71  {
72  if ( m_linksToBeSet.empty()
73  and m_floatsToBeSet.empty()
74  and m_intsToBeSet.empty()
75  and m_stringsToBeSet.empty()
76  and m_v_intsToBeSet.empty()
77  and m_v_floatsToBeSet.empty()
78  and m_v_stringsToBeSet.empty() )
79  return true;
80  return false;
81 }

◆ lockFormat()

void TrigComposite::lockFormat ( )
inline

makes further addition of the details impossible

Definition at line 66 of file Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h.

66 {m_locked=true;}

◆ mustSet()

template<class T >
void TrigComposite::mustSet ( const std::string &  key)
private

Definition at line 47 of file TrigComposite.cxx.

47  {
48  detailsMustSetList<T>().insert(key);
49 }

◆ name()

const std::string& TrigComposite::name ( ) const
inline

◆ setDetail()

template<typename T >
void TrigComposite::setDetail ( const std::string &  key,
const T &  value 
)

sets the value user the key, if they detail under that key already exists it's value is overwritten, If the key does not exists, the exception is thrown

Definition at line 101 of file TrigComposite.cxx.

101  {
102  if ( hasDetail<T>(key) == false )
103  throw std::invalid_argument("The TrigCompositeObejct does not have key: "+ key);
104 
105  // now it needs to fins appropriate collection and set the value
106  detailsMap<T>()[key] = value;
107  detailsMustSetList<T>().erase(key);
108 }

◆ setFormat()

template<typename T >
void TrigComposite::setFormat ( const std::vector< std::string > &  keys,
bool  mustBeSet = false 
)

defines the content (details which must to be stored) The method can be used to enforce certain content of the object (set the demand that the deail are set).


Each type of the details can be fixed independently. Also the links can be demanded to be set this way.

This functionality can be used in some sort factories producing TrigComposite of fixed content/contract for the numer of algorithms which they will be "forced" to fill. The enforcement is weak, the isValid method can be then called and so the fulfillment of the contract.

Definition at line 37 of file TrigComposite.cxx.

37  {
38  for(const std::string& key : keys) {
39  addDetail<T>(key);
40  if (mustBeSet) {
41  mustSet<T>(key);
42  }
43  }
44 }

◆ setObject()

void TrigComposite::setObject ( const std::string &  key,
TrigFeatureLink  link 
)

sets the link

See also
TrigFeatuerLink to the object, link is not checked for the validity
setDetail

Definition at line 58 of file TrigComposite.cxx.

58  {
59  setDetail(key, link);
60 }

◆ specimen()

template<typename T >
const T& TrigComposite::specimen ( ) const
private

◆ unlockFormat()

void TrigComposite::unlockFormat ( )
inline

makes addition of further details possible again

Definition at line 77 of file Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h.

77 {m_locked=false;}

Member Data Documentation

◆ m_floats

std::map<std::string, float > TrigComposite::m_floats
private

◆ m_floatsToBeSet

MustSetList TrigComposite::m_floatsToBeSet
private

◆ m_ints

std::map<std::string, int> TrigComposite::m_ints
private

◆ m_intsToBeSet

MustSetList TrigComposite::m_intsToBeSet
private

◆ m_links

std::map<std::string, TrigFeatureLink > TrigComposite::m_links
private

◆ m_linksToBeSet

MustSetList TrigComposite::m_linksToBeSet
private

◆ m_locked

bool TrigComposite::m_locked
private

◆ m_name

std::string TrigComposite::m_name
private

◆ m_strings

std::map<std::string, std::string> TrigComposite::m_strings
private

◆ m_stringsToBeSet

MustSetList TrigComposite::m_stringsToBeSet
private

◆ m_v_floats

std::map<std::string, std::vector<float> > TrigComposite::m_v_floats
private

◆ m_v_floatsToBeSet

MustSetList TrigComposite::m_v_floatsToBeSet
private

◆ m_v_ints

std::map<std::string, std::vector<int> > TrigComposite::m_v_ints
private

◆ m_v_intsToBeSet

MustSetList TrigComposite::m_v_intsToBeSet
private

◆ m_v_strings

std::map<std::string, std::vector<std::string> > TrigComposite::m_v_strings
private

◆ m_v_stringsToBeSet

MustSetList TrigComposite::m_v_stringsToBeSet
private

The documentation for this class was generated from the following files:
TrigComposite::m_v_stringsToBeSet
MustSetList m_v_stringsToBeSet
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:197
TrigComposite::m_linksToBeSet
MustSetList m_linksToBeSet
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:179
TrigComposite::addDetail
void addDetail(const std::string &key, const T &value=T())
adds the value user the key, if they detail under that key already exists the exception is thrown If ...
Definition: TrigComposite.cxx:89
get_generator_info.result
result
Definition: get_generator_info.py:21
TrigComposite::m_locked
bool m_locked
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:214
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
athena.value
value
Definition: athena.py:122
TrigComposite::isFormatLocked
bool isFormatLocked() const
return true if the format can not be further changed (no addDetail can be called)
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:71
PlotCalibFromCool.label2
label2
Definition: PlotCalibFromCool.py:79
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
TrigComposite::m_v_floatsToBeSet
MustSetList m_v_floatsToBeSet
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:191
TrigComposite::m_stringsToBeSet
MustSetList m_stringsToBeSet
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:188
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
TrigComposite::m_floatsToBeSet
MustSetList m_floatsToBeSet
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:182
TrigComposite::m_links
std::map< std::string, TrigFeatureLink > m_links
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:178
TrigComposite::m_name
std::string m_name
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:213
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
TrigComposite::name
const std::string & name() const
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:42
TrigComposite::addObject
void addObject(const std::string &key, TrigFeatureLink link)
adds the link
Definition: TrigComposite.cxx:54
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
TrigComposite::setDetail
void setDetail(const std::string &key, const T &value)
sets the value user the key, if they detail under that key already exists it's value is overwritten,...
Definition: TrigComposite.cxx:101
TrigComposite::m_v_intsToBeSet
MustSetList m_v_intsToBeSet
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:194
TrigComposite::m_intsToBeSet
MustSetList m_intsToBeSet
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:185
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37