LDMX Software
Conditions.h
Go to the documentation of this file.
1
7#ifndef FRAMEWORK_CONDITIONS_H_
8#define FRAMEWORK_CONDITIONS_H_
9
10/*~~~~~~~~~~~*/
11/* Event */
12/*~~~~~~~~~~~*/
14#include "Framework/Exception/Exception.h"
15
16/*~~~~~~~~~~~~~~~*/
17/* Framework */
18/*~~~~~~~~~~~~~~~*/
20#include "Framework/Configure/Parameters.h"
21#include "Framework/Logger.h"
22
23/*~~~~~~~~~~~~~~~~*/
24/* C++ StdLib */
25/*~~~~~~~~~~~~~~~~*/
26#include <any>
27#include <map>
28
29namespace ldmx {
30class RunHeader;
31}
32
33namespace framework {
34
35class Process;
37class ConditionsObject;
38
44 public:
49
53 ~Conditions() = default;
54
68 const ConditionsObject* getConditionPtr(const std::string& condition_name);
69
82 template <class T>
83 const T& getCondition(const std::string& condition_name) {
84 return dynamic_cast<const T&>(*getConditionPtr(condition_name));
85 }
86
93 ConditionsIOV getConditionIOV(const std::string& condition_name) const;
94
98 void onProcessStart();
99
103 void onProcessEnd();
104
109
114 const std::string& classname, const std::string& instancename,
115 const std::string& tagname, const framework::config::Parameters& params);
116
117 private:
120
122 std::map<std::string, std::shared_ptr<ConditionsObjectProvider>>
124
128 struct CacheEntry {
132 std::shared_ptr<ConditionsObjectProvider> provider_;
135 };
136
138 std::map<std::string, CacheEntry> cache_;
139};
140
141} // namespace framework
142
143#endif
Interval-of-validity object for conditions information.
Class that provides header information about an event such as event number and timestamp.
be configured to load conditions objects from CSV files.
Class which defines the run/event/type range for which a given condition is valid,...
Base class for all conditions objects, very simple.
Container and cache for conditions and conditions providers.
Definition Conditions.h:43
~Conditions()=default
Class destructor.
const T & getCondition(const std::string &condition_name)
Primary request action for a conditions object If the object is in the cache and still valid (IOV),...
Definition Conditions.h:83
Process & process_
Handle to the Process.
Definition Conditions.h:119
std::map< std::string, CacheEntry > cache_
Conditions cache.
Definition Conditions.h:138
std::map< std::string, std::shared_ptr< ConditionsObjectProvider > > provider_map_
Map of who provides which condition.
Definition Conditions.h:123
const ConditionsObject * getConditionPtr(const std::string &condition_name)
Primary request action for a conditions object If the object is in the cache and still valid (IOV),...
void onProcessEnd()
Calls onProcessEnd for all ConditionsObjectProviders.
ConditionsIOV getConditionIOV(const std::string &condition_name) const
Access the IOV for the given condition.
Conditions(Process &)
Constructor.
void onProcessStart()
Calls onProcessStart for all ConditionsObjectProviders.
void onNewRun(ldmx::RunHeader &)
Calls onNewRun for all ConditionsObjectProviders.
void createConditionsObjectProvider(const std::string &classname, const std::string &instancename, const std::string &tagname, const framework::config::Parameters &params)
Create a ConditionsObjectProvider given the information.
Class which represents the process under execution.
Definition Process.h:36
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
Run-specific configuration and data stored in its own output TTree alongside the event TTree in the o...
Definition RunHeader.h:57
All classes in the ldmx-sw project use this namespace.
An entry to store an already loaded conditions object.
Definition Conditions.h:128
const ConditionsObject * obj_
Const pointer to the retrieved conditions object.
Definition Conditions.h:134
ConditionsIOV iov_
Interval Of Validity for this entry in the cache.
Definition Conditions.h:130
std::shared_ptr< ConditionsObjectProvider > provider_
Provider that gave us the conditions object.
Definition Conditions.h:132