ATLAS Offline Software
Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIGCOMBINEDEVENT_TRIGCOMPOSITE_H
6 #define TRIGCOMBINEDEVENT_TRIGCOMPOSITE_H
7 #include <string>
8 #include <vector>
9 #include <cmath>
10 #include <limits>
11 #include <set>
12 #include "AthenaKernel/CLASS_DEF.h"
13 #include "GaudiKernel/ClassID.h"
15 #include "GaudiKernel/MsgStream.h"
16 
17 
18 
19 
27 
28  public:
33  TrigComposite(const std::string& name);
34 
39  TrigComposite(const std::string& name, std::string& label1, TrigFeatureLink t1, std::string& label2, TrigFeatureLink t2);
40 
41 
42  inline const std::string& name() const { return m_name; }
43 
44 
55  template<typename T>
56  void setFormat(const std::vector<std::string>& keys, bool mustBeSet=false);
57 
61  bool isValid() const;
62 
66  inline void lockFormat(){m_locked=true;}
67 
71  inline bool isFormatLocked() const {return m_locked; }
72 
73 
77  inline void unlockFormat(){m_locked=false;}
78 
79 
84  void addObject(const std::string& key, TrigFeatureLink link);
85 
86 
91  void setObject(const std::string& key, TrigFeatureLink link);
92 
96  bool hasObject(const std::string& key) const;
97 
101  const TrigFeatureLink& getObject(const std::string& key) const;
102 
103 
108  template<typename T>
109  std::vector<TrigFeatureLink> getObjectsByType(const std::string& keypart="") const;
110 
111 
112 
117  template<typename T>
118  void addDetail(const std::string& key, const T& value=T());
119 
124  template<typename T>
125  void setDetail(const std::string& key, const T& value);
126 
127 
132  template<typename T>
133  bool hasDetail(const std::string& key) const;
134 
135 
139  template<typename T>
140  const T& getDetail(const std::string& key) const;
141 
148  template<class T>
149  const std::map<std::string, T>& allDetails() const {
150  return detailsMap<T>();
151  }
152 
153 
158  template<typename T>
159  void eraseDetail(const std::string& key);
160 
164  TrigComposite();
165 
169  ~TrigComposite();
170 
171 
172 private:
173  template<class T>
174  void mustSet(const std::string& key);
175 
176  typedef std::set<std::string> MustSetList;
177 
178  std::map<std::string, TrigFeatureLink > m_links;
180 
181  std::map<std::string, float > m_floats;
183 
184  std::map<std::string, int> m_ints;
186 
187  std::map<std::string, std::string> m_strings;
189 
190  std::map<std::string, std::vector<float> > m_v_floats;
192 
193  std::map<std::string, std::vector<int> > m_v_ints;
195 
196  std::map<std::string, std::vector<std::string> > m_v_strings;
198 
199  template<typename T>
200  std::map<std::string, T>& detailsMap();
201 
202  template<typename T>
203  const std::map<std::string, T>& detailsMap() const;
204 
205  template<typename T>
207 
208 
209  template<typename T>
210  const T& specimen() const; // needed in order to produce the "NULL" detail
211 
212 
213  std::string m_name;
214  bool m_locked;
215 
216 };
217 
221 MsgStream& operator<< ( MsgStream& m, const TrigComposite& d );
222 
223 
224 template<typename T>
225 std::vector<TrigFeatureLink> TrigComposite::getObjectsByType(const std::string& keypart) const {
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 }
234 
235 
236 
237 
239 CLASS_DEF( TrigComposite , 231914326 , 1 )
240 
241 
242 
243 #endif // __TrigComposite_h__
244 
TrigComposite::m_v_stringsToBeSet
MustSetList m_v_stringsToBeSet
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:197
TrigComposite::getDetail
const T & getDetail(const std::string &key) const
return the value of the detail, if the key is absent the default is returned
Definition: TrigComposite.cxx:121
TrigComposite::m_linksToBeSet
MustSetList m_linksToBeSet
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:179
TrigComposite::m_v_ints
std::map< std::string, std::vector< int > > m_v_ints
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:193
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
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
TrigComposite::hasObject
bool hasObject(const std::string &key) const
checks if the object has link to the object under the key
Definition: TrigComposite.cxx:63
TrigComposite::m_locked
bool m_locked
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:214
TrigComposite::MustSetList
std::set< std::string > MustSetList
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:176
hist_file_dump.d
d
Definition: hist_file_dump.py:137
TrigComposite::specimen
const T & specimen() const
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
athena.value
value
Definition: athena.py:124
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
TrigComposite::lockFormat
void lockFormat()
makes further addition of the details impossible
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:66
TrigComposite::isValid
bool isValid() const
Checks the validity of the format, i.e.
Definition: TrigComposite.cxx:71
TrigComposite::getObject
const TrigFeatureLink & getObject(const std::string &key) const
returns
Definition: TrigComposite.cxx:67
TrigComposite
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:26
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
TrigComposite::detailsMap
std::map< std::string, T > & detailsMap()
Definition: TrigComposite.cxx:135
TrigComposite::m_ints
std::map< std::string, int > m_ints
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:184
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigComposite::setObject
void setObject(const std::string &key, TrigFeatureLink link)
sets the link
Definition: TrigComposite.cxx:58
TrigComposite::m_v_strings
std::map< std::string, std::vector< std::string > > m_v_strings
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:196
TrigComposite::unlockFormat
void unlockFormat()
makes addition of further details possible again
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:77
TrigComposite::~TrigComposite
~TrigComposite()
Destructor, does nothing special in fact, no links are touched.
Definition: TrigComposite.cxx:83
TrigComposite::m_v_floats
std::map< std::string, std::vector< float > > m_v_floats
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:190
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_floats
std::map< std::string, float > m_floats
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:181
TrigComposite::setFormat
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 conte...
Definition: TrigComposite.cxx:37
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::TrigComposite
TrigComposite()
Deafault constructor, should not be normally used, needed by the persistency layer.
Definition: TrigComposite.cxx:13
TrigComposite::getObjectsByType
std::vector< TrigFeatureLink > getObjectsByType(const std::string &keypart="") const
get all links which point to objects of given type
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:225
TrigComposite::m_name
std::string m_name
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:213
TrigComposite::eraseDetail
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.
Definition: TrigComposite.cxx:129
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::allDetails
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 a...
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:149
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
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:798
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_strings
std::map< std::string, std::string > m_strings
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:187
TrigComposite::detailsMustSetList
MustSetList & detailsMustSetList()
CLASS_DEF.h
macros to associate a CLID to a type
TrigComposite::hasDetail
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.
Definition: TrigComposite.cxx:112
TrigComposite::m_intsToBeSet
MustSetList m_intsToBeSet
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:185
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
TrigComposite::mustSet
void mustSet(const std::string &key)
Definition: TrigComposite.cxx:47
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
operator<<
MsgStream & operator<<(MsgStream &m, const TrigComposite &d)
Prints the content of the object.
Definition: TrigComposite.cxx:198