DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
ConditionsPool.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_CONDITIONSPOOL_H
14 #define DDCOND_CONDITIONSPOOL_H
15 
16 // Framework include files
17 #include "DD4hep/NamedObject.h"
18 #include "DD4hep/ConditionsMap.h"
20 
21 // C/C++ include files
22 
24 namespace dd4hep {
25 
27  namespace cond {
28 
29  // Forward declarations
30  class ConditionsSlice;
31  class ConditionsIOVPool;
32  class ConditionDependency;
33 
35 
54  class ConditionsPool : public NamedObject {
55  protected:
58 
59  public:
60  enum { AGE_NONE = 0,
61  AGE_ANY = 9999999,
62  AGE_EXPIRED = 12345678
63  };
65  IOV* iov;
67  int age_value;
68 
69  public:
71  void onRegister(Condition condition);
73  void onRemove(Condition condition);
74 
75  public:
79  virtual ~ConditionsPool();
81  void print() const;
83  void print(const std::string& opt) const;
85  virtual size_t size() const = 0;
87  virtual void clear() = 0;
89  virtual bool insert(Condition cond) = 0;
91  virtual void insert(RangeConditions& cond) = 0;
95  virtual size_t select(Condition::key_type key, RangeConditions& result) = 0;
97  virtual size_t select_all(RangeConditions& result) = 0;
99  virtual size_t select_all(const ConditionsSelect& predicate) = 0;
101  virtual size_t select_all(ConditionsPool& selection_pool) = 0;
102  };
103 
105 
109  class UpdatePool : public ConditionsPool {
110 
111  public:
112  typedef std::vector<Condition> ConditionEntries;
114  typedef std::map<const IOV*, ConditionEntries> UpdateEntries;
115 
116  public:
120  virtual ~UpdatePool();
122  virtual size_t popEntries(UpdateEntries& entries) = 0;
125  const IOV& req_validity,
126  RangeConditions& result) = 0;
127  };
128 
130 
134  class UserPool : public ConditionsMap {
135  public:
137  typedef std::map<Condition::key_type,const ConditionDependency*> Dependencies;
138 
139  protected:
144 
145  public:
147  enum {
149  PRINT_INSERT = 1<<0,
150  PRINT_CLEAR = 1<<1,
151  PRINT_LOAD = 1<<2,
153  PRINT_LAST
154  };
156  unsigned int flags = 0;
157 
159  virtual bool insert(Condition condition) = 0;
160 
161  public:
165  virtual ~UserPool();
167  const IOV& validity() const { return m_iov; }
169  const IOV* validityPtr() const { return &m_iov; }
171  virtual void print(const std::string& opt) const = 0;
173  virtual size_t size() const = 0;
175  virtual void clear() = 0;
177  virtual bool exists(Condition::key_type key) const = 0;
179  virtual bool exists(const ConditionKey& key) const = 0;
181  virtual Condition get(Condition::key_type key) const = 0;
183  virtual Condition get(const ConditionKey& key) const = 0;
185  virtual bool remove(Condition::key_type hash_key) = 0;
187  virtual bool remove(const ConditionKey& key) = 0;
189 
190  virtual bool registerOne(const IOV& iov, Condition cond) = 0;
192  virtual size_t registerMany(const IOV& iov, const std::vector<Condition>& values) = 0;
194  template <typename CONT> size_t registerUnmapped(const IOV& iov, CONT& c) {
195  std::vector<Condition> conditions;
196  conditions.reserve(c.size());
197  std::copy(std::begin(c), std::end(c), std::back_inserter(conditions));
198  return this->registerMany(iov, conditions);
199  }
201  template <typename CONT> size_t registerMapping(const IOV& iov, CONT& c) {
202  std::vector<Condition> conditions;
203  conditions.reserve(c.size());
204  std::transform(std::begin(c), std::end(c), std::back_inserter(conditions), detail::get_2nd<CONT>());
205  return this->registerMany(iov, conditions);
206  }
208  virtual bool insert(DetElement detector, Condition::itemkey_type key, Condition condition) = 0;
209 
211  virtual Condition get(DetElement detector, Condition::itemkey_type key) const = 0;
213  virtual std::vector<Condition> get(Condition::key_type lower,
214  Condition::key_type upper) const = 0;
216  virtual std::vector<Condition> get(DetElement detector,
218  Condition::itemkey_type upper) const = 0;
219 
221  virtual void scan(const Condition::Processor& processor) const = 0;
223  virtual void scan(Condition::key_type lower,
224  Condition::key_type upper,
225  const Condition::Processor& processor) const = 0;
227  virtual void scan(DetElement detector,
230  const Condition::Processor& processor) const = 0;
231 
233  virtual ConditionsManager::Result prepare(const IOV& required,
234  ConditionsSlice& slice,
235  ConditionUpdateUserContext* user_param = 0) = 0;
236 
238  virtual ConditionsManager::Result load(const IOV& required_validity,
239  ConditionsSlice& slice,
240  ConditionUpdateUserContext* ctxt=0) = 0;
242  virtual ConditionsManager::Result compute(const IOV& required_validity,
243  ConditionsSlice& slice,
244  ConditionUpdateUserContext* ctxt=0) = 0;
245 
247  virtual size_t compute(const Dependencies& dependencies,
248  ConditionUpdateUserContext* user_param,
249  bool force) = 0;
250  };
251  } /* End namespace cond */
252 } /* End namespace dd4hep */
253 #endif // DDCOND_CONDITIONSPOOL_H
dd4hep::RangeConditions
std::vector< Condition > RangeConditions
Definition: Conditions.h:491
dd4hep::cond::UserPool::exists
virtual bool exists(Condition::key_type key) const =0
Check a condition for existence.
dd4hep::cond::UserPool::compute
virtual size_t compute(const Dependencies &dependencies, ConditionUpdateUserContext *user_param, bool force)=0
Evaluate and register all derived conditions from the dependency list.
dd4hep::cond::UserPool::get
virtual std::vector< Condition > get(Condition::key_type lower, Condition::key_type upper) const =0
No ConditionsMap overload: Access all conditions within a key range in the interval [lower,...
cond
AlignmentCondition::Object * cond
Definition: AlignmentsCalculator.cpp:68
dd4hep::cond::UserPool::registerMany
virtual size_t registerMany(const IOV &iov, const std::vector< Condition > &values)=0
Do block insertions of conditions with identical IOV.
dd4hep::cond::ConditionsPool::age_value
int age_value
Aging value.
Definition: ConditionsPool.h:67
dd4hep::cond::UserPool::validityPtr
const IOV * validityPtr() const
Access the interval of validity for this user pool.
Definition: ConditionsPool.h:169
dd4hep::cond::UpdatePool::ConditionEntries
std::vector< Condition > ConditionEntries
Definition: ConditionsPool.h:112
dd4hep::cond::UserPool::insert
virtual bool insert(DetElement detector, Condition::itemkey_type key, Condition condition)=0
ConditionsMap overload: Add a condition directly to the slice.
dd4hep::cond::ConditionsPool::onRegister
void onRegister(Condition condition)
Listener invocation when a condition is registered to the cache.
Definition: ConditionsPool.cpp:63
dd4hep::cond::ConditionsPool::insert
virtual bool insert(Condition cond)=0
Register a new condition to this pool.
dd4hep::cond::UserPool::exists
virtual bool exists(const ConditionKey &key) const =0
Check a condition for existence.
dd4hep::cond::UserPool::scan
virtual void scan(DetElement detector, Condition::itemkey_type lower, Condition::itemkey_type upper, const Condition::Processor &processor) const =0
No ConditionsMap overload: Interface to scan data content of the conditions mapping.
dd4hep::ConditionKey
Key definition to optimize ans simplyfy the access to conditions entities.
Definition: Conditions.h:280
ConditionsManager.h
dd4hep::cond::UserPool::m_manager
ConditionsManager m_manager
Handle to conditions manager object.
Definition: ConditionsPool.h:143
dd4hep::cond::ConditionUpdateUserContext
ConditionUpdateUserContext class used by the derived conditions calculation mechanism.
Definition: ConditionDerived.h:49
dd4hep::cond::UserPool::validity
const IOV & validity() const
Access the interval of validity for this user pool.
Definition: ConditionsPool.h:167
dd4hep::ConditionsSelect
Conditions selector functor. Default implementation selects everything evaluated.
Definition: Conditions.h:422
dd4hep::cond::UserPool::PRINT_NONE
@ PRINT_NONE
Definition: ConditionsPool.h:148
dd4hep::cond::UpdatePool::popEntries
virtual size_t popEntries(UpdateEntries &entries)=0
Adopt all entries sorted by IOV. Entries will be removed from the pool.
dd4hep::cond::UserPool::PRINT_LAST
@ PRINT_LAST
Definition: ConditionsPool.h:153
dd4hep::cond::UserPool::get
virtual Condition get(const ConditionKey &key) const =0
Check if a condition exists in the pool and return it to the caller.
dd4hep::cond::UserPool::remove
virtual bool remove(Condition::key_type hash_key)=0
Remove condition by key from pool.
dd4hep::cond::ConditionsPool::AGE_ANY
@ AGE_ANY
Definition: ConditionsPool.h:61
entries
Entries entries
Definition: AlignmentsCalculator.cpp:81
dd4hep::cond::UserPool::load
virtual ConditionsManager::Result load(const IOV &required_validity, ConditionsSlice &slice, ConditionUpdateUserContext *ctxt=0)=0
Load all updates to the clients with the defined IOV (1rst step of prepare)
dd4hep::cond::ConditionsPool::select_all
virtual size_t select_all(RangeConditions &result)=0
Select all conditions contained.
dd4hep::Condition
Main condition object handle.
Definition: Conditions.h:51
dd4hep::cond::ConditionsPool::~ConditionsPool
virtual ~ConditionsPool()
Default destructor. Note: pool must be cleared by the subclass!
Definition: ConditionsPool.cpp:36
dd4hep::cond::UserPool::scan
virtual void scan(Condition::key_type lower, Condition::key_type upper, const Condition::Processor &processor) const =0
No ConditionsMap overload: Interface to scan data content of the conditions mapping.
dd4hep::cond::UserPool::PRINT_CLEAR
@ PRINT_CLEAR
Definition: ConditionsPool.h:150
dd4hep::IOV
Class describing the interval of validty.
Definition: IOV.h:67
dd4hep::cond::ConditionsPool::AGE_EXPIRED
@ AGE_EXPIRED
Definition: ConditionsPool.h:62
dd4hep::cond::UserPool::print
virtual void print(const std::string &opt) const =0
Print pool content.
dd4hep::cond::UserPool::flags
unsigned int flags
Processing flags (printout etc.)
Definition: ConditionsPool.h:156
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::cond::UserPool::UserPool
UserPool(ConditionsManager mgr)
Default constructor.
Definition: ConditionsPool.cpp:82
dd4hep::cond::UserPool::registerUnmapped
size_t registerUnmapped(const IOV &iov, CONT &c)
Insert multiple conditions. Note: the conditions must already have a hash key.
Definition: ConditionsPool.h:194
dd4hep::cond::UserPool::insert
virtual bool insert(Condition condition)=0
ConditionsMap overload: Add a condition directly to the slice.
dd4hep::cond::UserPool::PRINT_COMPUTE
@ PRINT_COMPUTE
Definition: ConditionsPool.h:152
dd4hep::cond::ConditionsPool
Class implementing the conditions collection for a given IOV type.
Definition: ConditionsPool.h:54
dd4hep::cond::UserPool::registerOne
virtual bool registerOne(const IOV &iov, Condition cond)=0
Do single insertion of condition including registration to the manager.
dd4hep::cond::ConditionsPool::exists
virtual Condition exists(Condition::key_type key) const =0
Check if a condition exists in the pool.
dd4hep::cond::ConditionsPool::select_all
virtual size_t select_all(ConditionsPool &selection_pool)=0
Select all conditions contained.
dd4hep::cond::ConditionsPool::print
void print() const
Print pool basics.
Definition: ConditionsPool.cpp:42
dd4hep::cond::UserPool::m_iov
IOV m_iov
The pool's interval of validity.
Definition: ConditionsPool.h:141
dd4hep::cond::ConditionsPool::iov
IOV * iov
The IOV of the conditions hosted.
Definition: ConditionsPool.h:65
dd4hep::cond::ConditionsPool::select
virtual size_t select(Condition::key_type key, RangeConditions &result)=0
Select the conditions matching the DetElement and the conditions name.
dd4hep::cond::ConditionsPool::size
virtual size_t size() const =0
Total entry count.
NamedObject.h
dd4hep::cond::ConditionsPool::onRemove
void onRemove(Condition condition)
Listener invocation when a condition is deregistered from the cache.
Definition: ConditionsPool.cpp:68
dd4hep::Condition::itemkey_type
unsigned int itemkey_type
Low part of the key identifies the item identifier.
Definition: Conditions.h:58
dd4hep::cond::ConditionsPool::select_all
virtual size_t select_all(const ConditionsSelect &predicate)=0
Select the conditons, passing a predicate.
dd4hep::cond::UserPool::compute
virtual ConditionsManager::Result compute(const IOV &required_validity, ConditionsSlice &slice, ConditionUpdateUserContext *ctxt=0)=0
Compute all derived conditions with the defined IOV (2nd step of prepare)
dd4hep::cond::UserPool::PRINT_LOAD
@ PRINT_LOAD
Definition: ConditionsPool.h:151
dd4hep::cond::UserPool::size
virtual size_t size() const =0
Total entry count.
dd4hep::Condition::key_type
unsigned long long int key_type
Forward definition of the key type.
Definition: Conditions.h:54
ConditionsMap.h
dd4hep::cond::UserPool::get
virtual std::vector< Condition > get(DetElement detector, Condition::itemkey_type lower, Condition::itemkey_type upper) const =0
No ConditionsMap overload: Access all conditions within a key range in the interval [lower,...
dd4hep::cond::UpdatePool::~UpdatePool
virtual ~UpdatePool()
Default destructor.
Definition: ConditionsPool.cpp:78
dd4hep::cond::UserPool::PRINT_INSERT
@ PRINT_INSERT
Definition: ConditionsPool.h:149
dd4hep::cond::UpdatePool::select_range
virtual void select_range(Condition::key_type key, const IOV &req_validity, RangeConditions &result)=0
Select the conditions matching the key.
dd4hep::cond::ConditionsManager
Manager class for condition handles.
Definition: ConditionsManager.h:46
dd4hep::cond::UserPool
Interface for conditions pool optimized to host conditions updates.
Definition: ConditionsPool.h:134
dd4hep::cond::UserPool::scan
virtual void scan(const Condition::Processor &processor) const =0
ConditionsMap overload: Interface to scan data content of the conditions mapping.
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::ConditionsPool::m_manager
ConditionsManager m_manager
Handle to conditions manager object.
Definition: ConditionsPool.h:57
dd4hep::cond::UserPool::clear
virtual void clear()=0
Full cleanup of all managed conditions.
dd4hep::cond::ConditionsPool::insert
virtual void insert(RangeConditions &cond)=0
Register a new condition to this pool. May overload for performance reasons.
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::NamedObject
Implementation of a named object.
Definition: NamedObject.h:30
dd4hep::cond::UpdatePool::UpdateEntries
std::map< const IOV *, ConditionEntries > UpdateEntries
Update container specification.
Definition: ConditionsPool.h:114
dd4hep::cond::UpdatePool::UpdatePool
UpdatePool(ConditionsManager mgr, IOV *iov)
Default constructor.
Definition: ConditionsPool.cpp:73
dd4hep::cond::UserPool::remove
virtual bool remove(const ConditionKey &key)=0
Remove condition by key from pool.
dd4hep::cond::UserPool::get
virtual Condition get(Condition::key_type key) const =0
Check if a condition exists in the pool and return it to the caller.
dd4hep::cond::UserPool::~UserPool
virtual ~UserPool()
Default destructor.
Definition: ConditionsPool.cpp:89
dd4hep::cond::UpdatePool
Interface for conditions pool optimized to host conditions updates.
Definition: ConditionsPool.h:109
dd4hep::detail::tools::copy
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
Definition: AlignmentTools.cpp:43
dd4hep::cond::UserPool::get
virtual Condition get(DetElement detector, Condition::itemkey_type key) const =0
ConditionsMap overload: Access a single condition.
dd4hep::cond::UserPool::prepare
virtual ConditionsManager::Result prepare(const IOV &required, ConditionsSlice &slice, ConditionUpdateUserContext *user_param=0)=0
Prepare user pool for usage (load, fill etc.) according to required IOV.
dd4hep::cond::ConditionsPool::AGE_NONE
@ AGE_NONE
Definition: ConditionsPool.h:60
dd4hep::cond::UserPool::registerMapping
size_t registerMapping(const IOV &iov, CONT &c)
Insert multiple conditions. Note: the conditions must already have a hash key.
Definition: ConditionsPool.h:201
dd4hep::Condition::Processor
Abstract base for processing callbacks to conditions objects.
Definition: Conditions.h:112
dd4hep::cond::ConditionsPool::clear
virtual void clear()=0
Full cleanup of all managed conditions.
dd4hep::ConditionsMap
ConditionsMap class.
Definition: ConditionsMap.h:59
dd4hep::cond::UserPool::Dependencies
std::map< Condition::key_type, const ConditionDependency * > Dependencies
Forward definition of the key type.
Definition: ConditionsPool.h:137
dd4hep::cond::ConditionsSlice
Conditions slice object. Defines which conditions should be loaded by the ConditionsManager.
Definition: ConditionsSlice.h:53
dd4hep::cond::ConditionsPool::ConditionsPool
ConditionsPool(ConditionsManager mgr, IOV *iov)
Default constructor.
Definition: ConditionsPool.cpp:29