DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
ConditionsManager.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DDCOND_CONDITIONSMANAGER_H
14 #define DDCOND_CONDITIONSMANAGER_H
15 
16 // Framework include files
17 #include "DD4hep/Conditions.h"
19 
20 // C/C++ include files
21 #include <set>
22 #include <memory>
23 
25 namespace dd4hep {
26 
28  namespace cond {
29 
30  // Forward declarations
31  class UserPool;
32  class ConditionsPool;
33  class ConditionsSlice;
34  class ConditionsCleanup;
35  class ConditionsIOVPool;
36  class ConditionsDataLoader;
37  class ConditionsManagerObject;
38  class ConditionUpdateUserContext;
39 
41 
46  class ConditionsManager : public Handle<ConditionsManagerObject> {
47  public:
48 
51  typedef std::vector<IOVType> IOVTypes;
52 
54 
59  class Result {
60  public:
61  size_t selected = 0;
62  size_t loaded = 0;
63  size_t computed = 0;
64  size_t missing = 0;
65  Result() = default;
66  Result(const Result& result) = default;
67  Result& operator=(const Result& result) = default;
68  size_t total() const { return selected+computed+loaded; }
70  Result& operator +=(const Result& result);
72  Result& operator -=(const Result& result);
73  };
74 
75  public:
76 
78 
85  template <typename T> static ConditionsManager from(T& host);
86 
88  ConditionsManager(Detector& description);
89 
91  ConditionsManager(Detector& description, const std::string& factory);
92 
94  ConditionsManager() = default;
95 
98 
101 
103  template <typename Q> ConditionsManager(const Handle<Q>& e) : Handle<Object>(e) {}
104 
106  ~ConditionsManager() = default;
107 
110 
113 
115  Detector& detectorDescription() const;
116 
118  Property& operator[](const std::string& property_name) const;
119 
121  PropertyManager& properties() const;
122 
124  ConditionsDataLoader& loader() const;
125 
127  const std::vector<const IOVType*> iovTypesUsed() const;
128 
130  const IOVType* iovType (const std::string& iov_name) const;
131 
133  ConditionsIOVPool* iovPool(const IOVType& type) const;
134 
136  void fromString(const std::string& iov_str, IOV& iov) const;
137 
139 
142  std::pair<bool, const IOVType*> registerIOVType(size_t iov_type, const std::string& iov_name) const;
143 
145  ConditionsPool* registerIOV(const IOV& iov) const;
146 
148  ConditionsPool* registerIOV(const IOVType& typ, IOV::Key key) const;
149 
151  ConditionsPool* registerIOV(const std::string& iov_rep) const;
152 
154  bool registerUnlocked(ConditionsPool& pool, Condition cond) const;
155 
157  size_t blockRegister(ConditionsPool& pool, const std::vector<Condition>& cond) const;
158 
160 
163  void pushUpdates() const;
164 
166 
171  void adoptCleanup(ConditionsCleanup* cleaner) const;
172 
174  void clean(const ConditionsCleanup& cleaner) const;
175 
177  void clean(const IOVType* typ, int max_age) const;
178 
180  void clear() const;
181 
183  std::unique_ptr<UserPool> createUserPool(const IOVType* iovT) const;
184 
186  Result prepare(const IOV& required_validity,
187  ConditionsSlice& slice,
188  ConditionUpdateUserContext* ctxt=0) const;
190  Result load(const IOV& required_validity,
191  ConditionsSlice& slice,
192  ConditionUpdateUserContext* ctxt=0) const;
194  Result compute(const IOV& required_validity,
195  ConditionsSlice& slice,
196  ConditionUpdateUserContext* ctxt=0) const;
197  };
198 
202  selected += result.selected;
203  loaded += result.loaded;
204  computed += result.computed;
205  missing += result.missing;
206  return *this;
207  }
211  selected -= result.selected;
212  loaded -= result.loaded;
213  computed -= result.computed;
214  missing -= result.missing;
215  return *this;
216  }
217  } /* End namespace cond */
218 } /* End namespace dd4hep */
219 #endif // DDCOND_CONDITIONSMANAGER_H
dd4hep::cond::ConditionsManager::iovType
const IOVType * iovType(const std::string &iov_name) const
Access IOV by its name.
Definition: ConditionsManager.cpp:199
dd4hep::cond::ConditionsManager::loader
ConditionsDataLoader & loader() const
Access the conditions loader.
Definition: ConditionsManager.cpp:188
dd4hep::cond::ConditionsManager::registerIOV
ConditionsPool * registerIOV(const IOV &iov) const
Register IOV with type and key.
Definition: ConditionsManager.cpp:231
dd4hep::cond::ConditionsManager::adoptCleanup
void adoptCleanup(ConditionsCleanup *cleaner) const
Adopt cleanup handler. If a handler is registered, it is invoked at every "prepare" step.
Definition: ConditionsManager.cpp:263
cond
AlignmentCondition::Object * cond
Definition: AlignmentsCalculator.cpp:68
dd4hep::Property
The property class to assign options to actions.
Definition: ComponentProperties.h:48
dd4hep::cond::ConditionsManager::clear
void clear() const
Full cleanup of all managed conditions.
Definition: ConditionsManager.cpp:278
dd4hep::cond::ConditionsManager::detectorDescription
Detector & detectorDescription() const
Access the detector description.
Definition: ConditionsManager.cpp:173
dd4hep::cond::ConditionsManager::Result::selected
size_t selected
Definition: ConditionsManager.h:61
dd4hep::cond::ConditionsManager::Result::operator+=
Result & operator+=(const Result &result)
Add results.
Definition: ConditionsManager.h:201
dd4hep::Handle
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
Definition: Handle.h:84
dd4hep::cond::ConditionsManager::operator=
ConditionsManager & operator=(const ConditionsManager &c)=default
Assignment operator.
dd4hep::cond::ConditionsManager::operator[]
Property & operator[](const std::string &property_name) const
Access to properties.
Definition: ConditionsManager.cpp:183
dd4hep::IOV::Key
std::pair< Key_value_type, Key_value_type > Key
Definition: IOV.h:74
dd4hep::cond::ConditionsManager::~ConditionsManager
~ConditionsManager()=default
Default destructor.
dd4hep::cond::ConditionsManager::Result::loaded
size_t loaded
Definition: ConditionsManager.h:62
dd4hep::cond::ConditionUpdateUserContext
ConditionUpdateUserContext class used by the derived conditions calculation mechanism.
Definition: ConditionDerived.h:49
dd4hep::IOVType
Class describing the interval of validty type.
Definition: IOV.h:37
dd4hep::cond::ConditionsManager::iovTypesUsed
const std::vector< const IOVType * > iovTypesUsed() const
Access the used/registered IOV types.
Definition: ConditionsManager.cpp:209
dd4hep::cond::ConditionsManagerObject
Basic conditions manager implementation.
Definition: ConditionsManagerObject.h:54
dd4hep::cond::ConditionsManager::iovPool
ConditionsIOVPool * iovPool(const IOVType &type) const
Access conditions multi IOV pool by iov type.
Definition: ConditionsManager.cpp:204
dd4hep::Condition
Main condition object handle.
Definition: Conditions.h:51
dd4hep::cond::ConditionsManager::registerIOVType
std::pair< bool, const IOVType * > registerIOVType(size_t iov_type, const std::string &iov_name) const
Register new IOV type if it does not (yet) exist.
Definition: ConditionsManager.cpp:194
dd4hep::cond::ConditionsManager::from
static ConditionsManager from(T &host)
Static accessor if installed as an extension.
dd4hep::IOV
Class describing the interval of validty.
Definition: IOV.h:67
dd4hep::cond::ConditionsManager::prepare
Result prepare(const IOV &required_validity, ConditionsSlice &slice, ConditionUpdateUserContext *ctxt=0) const
Prepare all updates to the clients with the defined IOV.
Definition: ConditionsManager.cpp:289
dd4hep::cond::ConditionsManager::Result::Result
Result()=default
dd4hep::cond::ConditionsManager::pushUpdates
void pushUpdates() const
Push all pending updates to the conditions store.
Definition: ConditionsManager.cpp:259
ComponentProperties.h
dd4hep::cond::ConditionsPool
Class implementing the conditions collection for a given IOV type.
Definition: ConditionsPool.h:54
dd4hep::cond::ConditionsManager::registerUnlocked
bool registerUnlocked(ConditionsPool &pool, Condition cond) const
Register new condition with the conditions store. Unlocked version, not multi-threaded.
Definition: ConditionsManager.cpp:254
dd4hep::cond::ConditionsManager::properties
PropertyManager & properties() const
Access to the property manager.
Definition: ConditionsManager.cpp:178
dd4hep::cond::ConditionsManager::load
Result load(const IOV &required_validity, ConditionsSlice &slice, ConditionUpdateUserContext *ctxt=0) const
Load all updates to the clients with the defined IOV (1rst step of prepare)
Definition: ConditionsManager.cpp:295
dd4hep::cond::ConditionsManager::ConditionsManager
ConditionsManager(const ConditionsManager &c)=default
Constructor to assing handle of the same type.
dd4hep::cond::ConditionsManager::Object
ConditionsManagerObject Object
Standard object type.
Definition: ConditionsManager.h:50
Conditions.h
dd4hep::cond::ConditionsManager::Result::missing
size_t missing
Definition: ConditionsManager.h:64
dd4hep::cond::ConditionsManager::IOVTypes
std::vector< IOVType > IOVTypes
Definition: ConditionsManager.h:51
dd4hep::cond::ConditionsManager::compute
Result compute(const IOV &required_validity, ConditionsSlice &slice, ConditionUpdateUserContext *ctxt=0) const
Compute all derived conditions with the defined IOV (2nd step of prepare)
Definition: ConditionsManager.cpp:301
dd4hep::cond::ConditionsManager
Manager class for condition handles.
Definition: ConditionsManager.h:46
dd4hep::cond::ConditionsManager::Result::Result
Result(const Result &result)=default
key
unsigned char key
Definition: AlignmentsCalculator.cpp:69
dd4hep::cond::ConditionsManager::Result
Result of a prepare call to the conditions manager.
Definition: ConditionsManager.h:59
dd4hep::cond::ConditionsDataLoader
Interface for a generic conditions loader.
Definition: ConditionsDataLoader.h:46
dd4hep::cond::ConditionsCleanup
Base class to handle conditions cleanups.
Definition: ConditionsCleanup.h:32
dd4hep::PropertyManager
Manager to ease the handling of groups of properties.
Definition: ComponentProperties.h:174
dd4hep::cond::ConditionsManager::initialize
ConditionsManager & initialize()
Initialize the object after having set the properties.
Definition: ConditionsManager.cpp:167
dd4hep::cond::ConditionsManager::clean
void clean(const ConditionsCleanup &cleaner) const
Invoke cache cleanup with user defined policy.
Definition: ConditionsManager.cpp:273
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::cond::ConditionsManager::ConditionsManager
ConditionsManager()=default
Default constructor.
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::cond::ConditionsManager::Result::operator=
Result & operator=(const Result &result)=default
dd4hep::cond::ConditionsManager::createUserPool
std::unique_ptr< UserPool > createUserPool(const IOVType *iovT) const
Create empty user pool object.
Definition: ConditionsManager.cpp:283
dd4hep::cond::ConditionsManager::blockRegister
size_t blockRegister(ConditionsPool &pool, const std::vector< Condition > &cond) const
Register a whole block of conditions with identical IOV.
Definition: ConditionsManager.cpp:249
dd4hep::cond::ConditionsManager::fromString
void fromString(const std::string &iov_str, IOV &iov) const
Create IOV from string.
Definition: ConditionsManager.cpp:244
dd4hep::cond::ConditionsManager::Result::computed
size_t computed
Definition: ConditionsManager.h:63
dd4hep::cond::ConditionsManager::ConditionsManager
ConditionsManager(const Handle< Q > &e)
Constructor to be used assigning from different type.
Definition: ConditionsManager.h:103
dd4hep::cond::ConditionsManager::ConditionsManager
ConditionsManager(Object *p)
Constructor to be used with valid pointer to object.
Definition: ConditionsManager.h:97
dd4hep::cond::ConditionsIOVPool
Pool of conditions satisfying one IOV type (epoch, run, fill, etc)
Definition: ConditionsIOVPool.h:38
dd4hep::cond::ConditionsManager::Result::operator-=
Result & operator-=(const Result &result)
Subtract results.
Definition: ConditionsManager.h:210
dd4hep::cond::ConditionsManager::Result::total
size_t total() const
Definition: ConditionsManager.h:68
dd4hep::cond::ConditionsSlice
Conditions slice object. Defines which conditions should be loaded by the ConditionsManager.
Definition: ConditionsSlice.h:53