13 for (
auto& [name, entry] :
cache_) {
14 if (entry.obj_ && entry.provider_) {
15 entry.provider_->releaseConditionsObject(entry.obj_);
22 const std::string& classname,
const std::string& objname,
24 auto cop = ConditionsObjectProvider::Factory::get().make(
25 classname, objname, tagname, params,
process_);
27 EXCEPTION_RAISE(
"UnableToCreate",
28 "No ConditionsObjectProvider for " + classname);
31 std::string provides = cop.value()->getConditionObjectName();
34 "ConditionAmbiguityException",
35 "Multiple ConditonsObjectProviders configured to provide " + provides);
53 const std::string& condition_name)
const {
54 auto cacheptr =
cache_.find(condition_name);
55 if (cacheptr ==
cache_.end()) {
58 return cacheptr->second.iov_;
63 const std::string& condition_name) {
65 auto cacheptr =
cache_.find(condition_name);
67 if (cacheptr ==
cache_.end()) {
71 EXCEPTION_RAISE(
"ConditionUnavailable",
72 "No provider is available for : " + condition_name);
75 std::pair<const ConditionsObject*, ConditionsIOV> cond =
76 copptr->second->getCondition(context);
80 "ConditionUnavailable",
81 "Null condition returned for requested item : " + condition_name);
86 ce.
iov_ = cond.second;
89 cache_[condition_name] = ce;
93 if (cacheptr->second.iov_.validForEvent(context)) {
94 return cacheptr->second.obj_;
97 cacheptr->second.provider_->releaseConditionsObject(
98 cacheptr->second.obj_);
99 cacheptr->second.obj_ =
nullptr;
101 std::pair<const ConditionsObject*, ConditionsIOV> cond =
102 cacheptr->second.provider_->getCondition(context);
106 s <<
"Unable to update condition '" << condition_name <<
"' for event "
113 EXCEPTION_RAISE(
"ConditionUnavailable", s.str());
115 cacheptr->second.iov_ = cond.second;
116 cacheptr->second.obj_ = cond.first;
Base class for provider of conditions information like pedestals, gains, electronics maps,...
Container and caching class for conditions information.
Class which represents the process under execution.
Class which defines the run/event/type range for which a given condition is valid,...
Base class for all conditions objects, very simple.
Process & process_
Handle to the Process.
std::map< std::string, CacheEntry > cache_
Conditions cache.
std::map< std::string, std::shared_ptr< ConditionsObjectProvider > > provider_map_
Map of who provides which condition.
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.
~Conditions()
Class destructor.
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 ¶ms)
Create a ConditionsObjectProvider given the information.
Class which represents the process under execution.
const ldmx::EventHeader * getEventHeader() const
Get the pointer to the current event header, if defined.
Class encapsulating parameters for configuring a processor.
All classes in the ldmx-sw project use this namespace.
An entry to store an already loaded conditions object.
const ConditionsObject * obj_
Const pointer to the retrieved conditions object.
ConditionsIOV iov_
Interval Of Validity for this entry in the cache.
std::shared_ptr< ConditionsObjectProvider > provider_
Provider that gave us the conditions object.