|
DD4hep
1.30.0
Detector Description Toolkit for High Energy Physics
|
Go to the documentation of this file.
19 #include <TTimeStamp.h>
25 #if defined(DD4HEP_CONDITIONS_HAVE_NAME)
30 ::snprintf(text,
sizeof(text),
"%08X %08X",
key.values.det_key,
key.values.item_key);
39 this->
_iov = *iov_ptr;
50 Work* previous = current;
54 printout(ERROR,
"DependencyHandler",
"ERROR: Cannot resolve not existing conditions.");
56 context.dependency->callback->resolve(condition, context);
71 unsigned char* p =
new unsigned char[dependencies.size()*
sizeof(
Work)];
73 for(
const auto& d : dependencies) {
74 Work* w =
new(p)
Work(
this,d.second,user_param,iov);
96 for(
const auto& i :
m_todo ) {
97 if ( !i.second->condition ) {
99 if ( !i.second->condition ) {
100 except(
"DependencyHandler",
101 "Derived condition was not created after calling the creation callback!");
110 PrintLevel prt_lvl = INFO;
111 std::vector<Condition> tmp;
112 std::map<IOV::Key,std::vector<Condition> > work_pools;
116 for(
const auto& c :
m_todo ) {
123 auto ret = work_pools.emplace(w->
iov->
keyData,tmp);
126 ret.first->second.reserve(
m_todo.size());
130 for(
const auto& c :
m_todo ) {
135 printout(prt_lvl,
"DependencyHandler",
"++ Register %s %s %s [%s]",
139 typeName(
typeid(*w->
condition)).c_str());
145 for(
const auto& section : work_pools ) {
149 if ( result != section.second.size() ) {
153 printout(prt_lvl,
"DependencyHandler",
"Inserted %ld [%ld] conditions to pool-iov: %s [%7.5f seconds]",
154 result, section.second.size(), iov.
str().c_str(),
155 stop.AsDouble()-start.AsDouble());
171 std::vector<dd4hep::Condition>
173 return this->
get(de.
key());
177 std::vector<dd4hep::Condition>
180 struct item_selector {
181 std::vector<Condition> conditions;
190 item_selector proc(
key);
193 return proc.conditions;
195 except(
"DependencyHandler",
196 "Conditions bulk accesses are only possible during conditions resolution!");
197 return std::vector<Condition>();
201 std::vector<dd4hep::Condition>
210 except(
"DependencyHandler",
211 "Conditions bulk accesses are only possible during conditions resolution!");
212 return std::vector<Condition>();
218 return this->
get(key,
nullptr, throw_if_not);
234 if ( i !=
m_todo.end() ) {
250 if ( throw_if_not ) {
254 #if defined(DD4HEP_CONDITIONS_HAVE_NAME)
255 std::string cond_from = dependency->
target.name;
256 std::string cond_to =
"UNKNOWN";
258 if ( d.hash ==
key ) {
263 printout(ERROR,
"DependencyHandler",
264 "Failed to resolve conditon:%016lX for DetElement: %s",
265 key, de_path.c_str());
266 printout(ERROR,
"DependencyHandler",
267 "Condition: %s dependent on missing condition: %s",
268 cond_from.c_str(), cond_to.c_str());
273 printout(ERROR,
"DependencyHandler",
274 "Failed to resolve conditon:%016lX for DetElement: %s",
275 key, de_path.c_str());
276 printout(ERROR,
"DependencyHandler",
277 "Condition: %s#%s dependent on missing condition item: %s",
278 de_path.c_str(), item_from.c_str(), item_to.c_str());
281 except(
"DependencyHandler",
282 "Failed to resolve conditon:%016lX for DetElement: %s",
283 key,de_path.c_str());
285 except(
"ConditionsDependencyHandler",
"Failed to resolve conditon:%016lX",
key);
301 except(
"DependencyHandler",
302 "++ Handler caught in infinite recursion loop. Key:%s %c%s%c",
304 #
if defined(DD4HEP_CONDITIONS_DEBUG)
330 printout(ERROR,
"DependencyHandler",
331 "+++ Callback handler returned invalid condition. Key:%s %c%s%c",
333 #
if defined(DD4HEP_CONDITIONS_DEBUG)
339 throw std::runtime_error(
"Invalid derived condition callback");
344 printout(ERROR,
"DependencyHandler",
345 "+++ Exception while creating dependent Condition %s:",
346 dependency_name(dep).c_str());
347 printout(ERROR,
"DependencyHandler",
"\t\t%s", e.what());
350 printout(ERROR,
"DependencyHandler",
351 "+++ UNKNOWN exception while creating dependent Condition %s.",
352 dependency_name(dep).c_str());
355 except(
"DependencyHandler",
356 "++ Exception while creating dependent Condition %s.",
357 dependency_name(dep).c_str());
void iov_intersection(const IOV &comparator)
Set the intersection of this IOV with the argument IOV.
~ConditionsDependencyHandler()
Default destructor.
const std::string & path() const
Path of the detector element (not necessarily identical to placement path!)
virtual Detector & detectorDescription() const override
Access to the detector description instance.
ConditionsManagerObject * m_manager
Reference to conditions manager.
int have_condition_item_inventory(int value=-1)
Setup conditions item name inventory for debugging.
AlignmentCondition::Object * cond
virtual size_t registerMany(const IOV &iov, const std::vector< Condition > &values)=0
Do block insertions of conditions with identical IOV.
unsigned int key() const
Access hash key of this detector element (Only valid once geometry is closed!)
ConditionsDependencyHandler(ConditionsManager mgr, UserPool &pool, const Dependencies &dependencies, ConditionUpdateUserContext *user_param)
Initializing constructor.
Condition::key_type hash
Hash value of the name.
void exception(const std::string &src, const std::string &msg)
Condition::key_type hash
Hashed key representation.
ConditionKey target
Key to the condition to be updated.
bool isValid() const
Check the validity of the object held by the handle.
std::string str() const
Create string representation of the IOV.
std::pair< Key_value_type, Key_value_type > Key
DetElement detector
Reference to the target's detector element.
std::string toString() const
Conversion to string.
ConditionUpdateUserContext class used by the derived conditions calculation mechanism.
Helper union to interprete conditions keys.
const IOV & validity() const
Access the interval of validity for this user pool.
Condition::Object * condition
The final result: the condition object.
ConditionUpdateUserContext * m_userParam
User defined optional processing parameter.
unsigned int detkey_type
High part of the key identifies the detector element.
void do_intersection(const IOV *iov)
Helper to determine the IOV intersection taking into account dependencies.
Main condition object handle.
Namespace for implementation details of the AIDA detector description toolkit.
Condition dependency definition.
Class describing the interval of validty.
Detector & detectorDescription() const
Access to the detector description instance.
virtual void print(const std::string &opt) const =0
Print pool content.
Handle class describing a detector element.
UserPool & m_pool
Reference to the user pool object.
size_t num_callback
Number of callbacks to the handler for monitoring.
ConditionUpdateContext context
Auxiliary information to resolve condition callbacks.
void do_callback(Work *dep)
Internal call to trigger update callback.
virtual bool registerOne(const IOV &iov, Condition cond)=0
Do single insertion of condition including registration to the manager.
void compute()
Access the conditions created during processing.
Key keyData
IOV key (if second==first, discrete, otherwise range)
void resolve()
2nd pass: Handler callback for the second turn to resolve missing dependencies
std::shared_ptr< ConditionUpdateCall > callback
Reference to the update callback. No auto pointer. callback may be shared.
virtual bool registerOne(const IOV &iov, Condition cond) override
Interface to handle multi-condition inserts by callbacks: One single insert.
virtual std::vector< Condition > getByItem(Condition::itemkey_type key) override
Interface to access conditions by hash value of the item (only valid at resolve!)
unsigned int itemkey_type
Low part of the key identifies the item identifier.
State m_state
Handler's state.
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.
void setFlag(Condition::mask_type option)
Flag operations: Set a conditons flag.
unsigned long long int key_type
Forward definition of the key type.
Helper structure to define the current update item.
Manager class for condition handles.
Interface for conditions pool optimized to host conditions updates.
std::vector< ConditionKey > dependencies
Dependency keys this condition depends on.
virtual void scan(const Condition::Processor &processor) const =0
ConditionsMap overload: Interface to scan data content of the conditions mapping.
static constexpr Key_value_type MIN_KEY
const Dependencies & m_dependencies
Dependency container to be resolved.
State state
Current conversion state of the item.
const IOVType * iovType
Reference to IOV type.
std::string get_condition_item_name(Condition::itemkey_type key)
Resolve key from conditions item name inventory for debugging.
Work * m_currentWork
Current item of the block.
const IOVType * m_iovType
Local cacheL pool's IOV type.
The main interface to the dd4hep detector description package.
virtual Condition get(Condition::key_type key) const =0
Check if a condition exists in the pool and return it to the caller.
int callstack
Flag to detect non resolvable circular dependencies.
Condition resolve(Work *¤t)
Helper function for the second level dependency resolution.
WorkConditions m_todo
The objects created during processing.
static constexpr Key_value_type MAX_KEY
const IOV * iov
Interval of validity.
Work * m_block
Current block work item.
ConditionsProcessor< typename std::remove_reference< T >::type > conditionsProcessor(T &&obj)
Creator utility function for ConditionsProcessor objects.
const ConditionDependency * dependency
The dependency to be handled within this context.
struct dd4hep::ConditionKey::KeyMaker::@2 values
const IOV & iov() const
Access the IOV block.
std::map< Condition::key_type, const ConditionDependency * > Dependencies
Condition::itemkey_type item_key
virtual Condition get(const ConditionKey &key) override
ConditionResolver implementation: Interface to access conditions.