DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
ConditionsDependencyHandler.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_CONDITIONSDEPENDENCYHANDLER_H
14 #define DDCOND_CONDITIONSDEPENDENCYHANDLER_H
15 
16 // Framework include files
17 #include "DD4hep/DetElement.h"
19 #include "DDCond/ConditionsPool.h"
21 
23 namespace dd4hep {
24 
26  namespace cond {
27 
28  // Forward declarations
29  class UserPool;
30  class ConditionsPool;
31  class ConditionsManagerObject;
32 
34 
51  public:
55  struct Work {
56  public:
61  IOV* iov = 0;
65  int callstack = 0;
68  public:
70  Work() = delete;
73  const ConditionDependency* d,
75  const IOV& i)
76  : _iov(i), context(r,d,&_iov,u) {}
78  Work(const Work&) = default;
80  Work& operator=(const Work&) = default;
82  void do_intersection(const IOV* iov);
84  Condition resolve(Work*& current);
85  };
86  typedef std::map<Condition::key_type, const ConditionDependency*> Dependencies;
87  typedef std::map<Condition::key_type, Work*> WorkConditions;
88 
89  protected:
99  const IOVType* m_iovType = 0;
105  Work* m_block = 0;
108  public:
110  mutable size_t num_callback;
111 
112  protected:
114  void do_callback(Work* dep);
115 
116  public:
119  UserPool& pool,
120  const Dependencies& dependencies,
121  ConditionUpdateUserContext* user_param);
124 
126  //const CreatedConditions& created() const { return m_created; }
128  void compute();
130  void resolve();
131 
133  virtual Detector& detectorDescription() const override;
136  virtual Ref_t manager() const override { return m_manager; }
138  virtual const IOV& requiredValidity() const override { return m_pool.validity(); }
140  virtual ConditionsMap& conditionsMap() const override { return m_pool; }
142  virtual Condition get(const ConditionKey& key) override
143  { return get(key.hash, nullptr, true); }
145  virtual Condition get(const ConditionKey& key, bool throw_if_not) override
146  { return get(key.hash, nullptr, throw_if_not); }
149  { return get(key, nullptr, true); }
151  virtual Condition get(Condition::key_type key, bool throw_if_not) override;
154  const ConditionDependency* dependency,
155  bool throw_if_not) override;
157  virtual std::vector<Condition> get(DetElement de) override;
159  virtual std::vector<Condition> get(Condition::detkey_type key) override;
161  virtual std::vector<Condition> getByItem(Condition::itemkey_type key) override;
163  virtual bool registerOne(const IOV& iov, Condition cond) override;
165  virtual size_t registerMany(const IOV& iov, const std::vector<Condition>& values) override;
166  };
167 
168  } /* End namespace cond */
169 } /* End namespace dd4hep */
170 
171 #endif // DDCOND_CONDITIONSDEPENDENCYHANDLER_H
dd4hep::cond::ConditionsDependencyHandler::~ConditionsDependencyHandler
~ConditionsDependencyHandler()
Default destructor.
Definition: ConditionsDependencyHandler.cpp:82
dd4hep::cond::ConditionResolver
ConditionResolver class used by the derived conditions calculation mechanism.
Definition: ConditionDerived.h:61
dd4hep::cond::ConditionsDependencyHandler::detectorDescription
virtual Detector & detectorDescription() const override
Access to the detector description instance.
Definition: ConditionsDependencyHandler.cpp:89
dd4hep::cond::ConditionsDependencyHandler::m_manager
ConditionsManagerObject * m_manager
Reference to conditions manager.
Definition: ConditionsDependencyHandler.h:91
dd4hep::cond::ConditionsDependencyHandler::RESOLVED
@ RESOLVED
Definition: ConditionsDependencyHandler.h:53
cond
AlignmentCondition::Object * cond
Definition: AlignmentsCalculator.cpp:68
dd4hep::cond::ConditionsDependencyHandler::INVALID
@ INVALID
Definition: ConditionsDependencyHandler.h:53
dd4hep::cond::ConditionsDependencyHandler::State
State
Obect state definitions.
Definition: ConditionsDependencyHandler.h:53
dd4hep::cond::ConditionsDependencyHandler::ConditionsDependencyHandler
ConditionsDependencyHandler(ConditionsManager mgr, UserPool &pool, const Dependencies &dependencies, ConditionUpdateUserContext *user_param)
Initializing constructor.
Definition: ConditionsDependencyHandler.cpp:63
dd4hep::cond::ConditionsDependencyHandler::WorkConditions
std::map< Condition::key_type, Work * > WorkConditions
Definition: ConditionsDependencyHandler.h:87
dd4hep::cond::ConditionsDependencyHandler::conditionsMap
virtual ConditionsMap & conditionsMap() const override
Accessor for the current conditons mapping.
Definition: ConditionsDependencyHandler.h:140
dd4hep::Handle< NamedObject >
dd4hep::ConditionKey
Key definition to optimize ans simplyfy the access to conditions entities.
Definition: Conditions.h:280
ConditionsManager.h
dd4hep::cond::ConditionsDependencyHandler::Work::Work
Work()=delete
Inhibit default constructor.
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::IOVType
Class describing the interval of validty type.
Definition: IOV.h:37
dd4hep::cond::ConditionsDependencyHandler::Work::condition
Condition::Object * condition
The final result: the condition object.
Definition: ConditionsDependencyHandler.h:63
dd4hep::cond::ConditionsDependencyHandler::m_userParam
ConditionUpdateUserContext * m_userParam
User defined optional processing parameter.
Definition: ConditionsDependencyHandler.h:97
dd4hep::Condition::detkey_type
unsigned int detkey_type
High part of the key identifies the detector element.
Definition: Conditions.h:56
dd4hep::cond::ConditionsManagerObject
Basic conditions manager implementation.
Definition: ConditionsManagerObject.h:54
dd4hep::cond::ConditionsDependencyHandler::Work::do_intersection
void do_intersection(const IOV *iov)
Helper to determine the IOV intersection taking into account dependencies.
Definition: ConditionsDependencyHandler.cpp:36
dd4hep::Condition
Main condition object handle.
Definition: Conditions.h:51
dd4hep::cond::ConditionDependency
Condition dependency definition.
Definition: ConditionDerived.h:316
dd4hep::IOV
Class describing the interval of validty.
Definition: IOV.h:67
dd4hep::cond::ConditionsDependencyHandler::manager
virtual Ref_t manager() const override
Access to the conditions manager.
Definition: ConditionsDependencyHandler.h:136
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::cond::ConditionsDependencyHandler::m_pool
UserPool & m_pool
Reference to the user pool object.
Definition: ConditionsDependencyHandler.h:93
dd4hep::cond::ConditionsDependencyHandler::num_callback
size_t num_callback
Number of callbacks to the handler for monitoring.
Definition: ConditionsDependencyHandler.h:110
dd4hep::cond::ConditionsDependencyHandler::Work::context
ConditionUpdateContext context
Auxiliary information to resolve condition callbacks.
Definition: ConditionsDependencyHandler.h:59
dd4hep::cond::ConditionsDependencyHandler::Work::iov
IOV * iov
Condition IOV.
Definition: ConditionsDependencyHandler.h:61
dd4hep::cond::ConditionsDependencyHandler::do_callback
void do_callback(Work *dep)
Internal call to trigger update callback.
Definition: ConditionsDependencyHandler.cpp:291
dd4hep::cond::ConditionsDependencyHandler::compute
void compute()
Access the conditions created during processing.
Definition: ConditionsDependencyHandler.cpp:94
dd4hep::cond::ConditionsDependencyHandler::CREATED
@ CREATED
Definition: ConditionsDependencyHandler.h:53
dd4hep::cond::ConditionsDependencyHandler::resolve
void resolve()
2nd pass: Handler callback for the second turn to resolve missing dependencies
Definition: ConditionsDependencyHandler.cpp:109
dd4hep::cond::ConditionsDependencyHandler::registerOne
virtual bool registerOne(const IOV &iov, Condition cond) override
Interface to handle multi-condition inserts by callbacks: One single insert.
Definition: ConditionsDependencyHandler.cpp:160
dd4hep::cond::ConditionsDependencyHandler::getByItem
virtual std::vector< Condition > getByItem(Condition::itemkey_type key) override
Interface to access conditions by hash value of the item (only valid at resolve!)
Definition: ConditionsDependencyHandler.cpp:178
dd4hep::cond::ConditionsDependencyHandler::Work::operator=
Work & operator=(const Work &)=default
Assignment operator.
dd4hep::Condition::itemkey_type
unsigned int itemkey_type
Low part of the key identifies the item identifier.
Definition: Conditions.h:58
dd4hep::cond::ConditionsDependencyHandler::Work::Work
Work(ConditionResolver *r, const ConditionDependency *d, ConditionUpdateUserContext *u, const IOV &i)
Initializing constructor.
Definition: ConditionsDependencyHandler.h:72
dd4hep::cond::ConditionsDependencyHandler::m_state
State m_state
Handler's state.
Definition: ConditionsDependencyHandler.h:103
dd4hep::cond::ConditionsDependencyHandler::registerMany
virtual size_t registerMany(const IOV &iov, const std::vector< Condition > &values) override
Handle multi-condition inserts by callbacks: block insertions of conditions with identical IOV.
Definition: ConditionsDependencyHandler.cpp:166
dd4hep::Condition::key_type
unsigned long long int key_type
Forward definition of the key type.
Definition: Conditions.h:54
dd4hep::detail::ConditionObject
The data class behind a conditions handle.
Definition: ConditionsInterna.h:68
dd4hep::cond::ConditionsDependencyHandler::Work
Helper structure to define the current update item.
Definition: ConditionsDependencyHandler.h:55
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::ConditionsDependencyHandler::requiredValidity
virtual const IOV & requiredValidity() const override
Access to pool IOV.
Definition: ConditionsDependencyHandler.h:138
key
unsigned char key
Definition: AlignmentsCalculator.cpp:69
dd4hep::cond::ConditionsDependencyHandler::get
virtual Condition get(Condition::key_type key) override
ConditionResolver implementation: Interface to access conditions.
Definition: ConditionsDependencyHandler.h:148
dd4hep::cond::ConditionsDependencyHandler::m_dependencies
const Dependencies & m_dependencies
Dependency container to be resolved.
Definition: ConditionsDependencyHandler.h:95
dd4hep::cond::ConditionsDependencyHandler::Work::state
State state
Current conversion state of the item.
Definition: ConditionsDependencyHandler.h:67
DetElement.h
ConditionDerived.h
dd4hep::cond::ConditionsDependencyHandler::m_currentWork
Work * m_currentWork
Current item of the block.
Definition: ConditionsDependencyHandler.h:107
dd4hep::cond::ConditionsDependencyHandler::m_iovType
const IOVType * m_iovType
Local cacheL pool's IOV type.
Definition: ConditionsDependencyHandler.h:99
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::cond::ConditionsDependencyHandler::Work::_iov
IOV _iov
Definition: ConditionsDependencyHandler.h:57
dd4hep::cond::ConditionsDependencyHandler
Callback handler to update condition dependencies.
Definition: ConditionsDependencyHandler.h:50
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
ConditionsPool.h
dd4hep::cond::ConditionsDependencyHandler::Work::callstack
int callstack
Flag to detect non resolvable circular dependencies.
Definition: ConditionsDependencyHandler.h:65
dd4hep::cond::ConditionsDependencyHandler::Work::resolve
Condition resolve(Work *&current)
Helper function for the second level dependency resolution.
Definition: ConditionsDependencyHandler.cpp:49
dd4hep::cond::ConditionsDependencyHandler::m_todo
WorkConditions m_todo
The objects created during processing.
Definition: ConditionsDependencyHandler.h:101
dd4hep::cond::ConditionsDependencyHandler::Work::Work
Work(const Work &)=default
Copy constructor.
dd4hep::cond::ConditionsDependencyHandler::get
virtual Condition get(const ConditionKey &key, bool throw_if_not) override
Interface to access conditions by conditions key.
Definition: ConditionsDependencyHandler.h:145
dd4hep::cond::ConditionsDependencyHandler::m_block
Work * m_block
Current block work item.
Definition: ConditionsDependencyHandler.h:105
dd4hep::cond::ConditionUpdateContext
ConditionUpdateContext class used by the derived conditions calculation mechanism.
Definition: ConditionDerived.h:136
dd4hep::ConditionsMap
ConditionsMap class.
Definition: ConditionsMap.h:59
dd4hep::cond::ConditionsDependencyHandler::Dependencies
std::map< Condition::key_type, const ConditionDependency * > Dependencies
Definition: ConditionsDependencyHandler.h:86
dd4hep::cond::ConditionsDependencyHandler::get
virtual Condition get(const ConditionKey &key) override
ConditionResolver implementation: Interface to access conditions.
Definition: ConditionsDependencyHandler.h:142