ATLAS Offline Software
Loading...
Searching...
No Matches
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>
13#include "GaudiKernel/ClassID.h"
15#include "GaudiKernel/MsgStream.h"
16
17
18
19
27
28 public:
32
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
147
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
165
170
171
172private:
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;
215
216};
217
221MsgStream& operator<< ( MsgStream& m, const TrigComposite& d );
222
223
224template<typename T>
225std::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
239CLASS_DEF( TrigComposite , 231914326 , 1 )
240
241
242
243#endif // __TrigComposite_h__
244
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
uint32_t CLID
The Class ID type.
MsgStream & operator<<(MsgStream &m, const TrigComposite &d)
Prints the content of the object.
The class is meant to store links (of type TrigFeatureLink) to trigger objects and arbitrary details ...
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...
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.
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.
~TrigComposite()
Destructor, does nothing special in fact, no links are touched.
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...
const T & specimen() const
void mustSet(const std::string &key)
bool isValid() const
Checks the validity of the format, i.e.
bool hasObject(const std::string &key) const
checks if the object has link to the object under the key
void lockFormat()
makes further addition of the details impossible
TrigComposite()
Deafault constructor, should not be normally used, needed by the persistency layer.
std::vector< TrigFeatureLink > getObjectsByType(const std::string &keypart="") const
get all links which point to objects of given type
void unlockFormat()
makes addition of further details possible again
std::map< std::string, std::vector< std::string > > m_v_strings
void setObject(const std::string &key, TrigFeatureLink link)
sets the link
bool isFormatLocked() const
return true if the format can not be further changed (no addDetail can be called)
const TrigFeatureLink & getObject(const std::string &key) const
returns
const T & getDetail(const std::string &key) const
return the value of the detail, if the key is absent the default is returned
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,...
MustSetList & detailsMustSetList()
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 ...
std::map< std::string, T > & detailsMap()
std::map< std::string, std::vector< float > > m_v_floats
TrigComposite(const std::string &name)
Constructs empty composite, no objects no details.
void addObject(const std::string &key, TrigFeatureLink link)
adds the link