30 using namespace DD4hep::Conditions;
36 namespace Conditions {
46 char text_format[1024];
47 const T& value = access_val<T>(c);
50 ::snprintf(text_format,
sizeof(text_format),
" Bound value %%s : value:%s [%s] Type: %%s",
55 ::snprintf(text_format,
sizeof(text_format),
" Bound value %%s : value:%s Type: %%s",
60 const string&
v = access_val<string>(c);
61 printout(
INFO,
"Cond_Value",
" Bound value %s : string value:%s Type: %s Ptr:%016X",
62 c.name(), c.get<
string>().c_str(),
typeName(c.typeInfo()).c_str(),
66 const T&
v = access_val<T>(c);
67 printout(
INFO,
"Cond_Value",
" Bound value %s : size:%d = %s Type: %s Ptr:%016X",
73 #define TEMPLATE_SIMPLE_TYPE(x) \
74 template <> void print_bound_value<x>(Condition c, const char* norm) \
75 { __print_bound_val<x>(c, norm); }
77 #define TEMPLATE_CONTAINER_TYPE(container,x) \
78 template void __print_bound_container<container >(Condition c, const char* norm); \
79 template <> void print_bound_value<container >(Condition c, const char* norm) \
80 { __print_bound_container<container >(c, norm); }
82 #if defined(DD4HEP_HAVE_ALL_PARSERS)
83 #define TEMPLATE_TYPE(x,f) \
84 TEMPLATE_SIMPLE_TYPE(x) \
85 TEMPLATE_CONTAINER_TYPE(vector<x>,x) \
86 TEMPLATE_CONTAINER_TYPE(list<x>,x) \
87 TEMPLATE_CONTAINER_TYPE(set<x>,x) \
88 TEMPLATE_CONTAINER_TYPE(Primitive<x>::int_map_t,x) \
89 TEMPLATE_CONTAINER_TYPE(Primitive<x>::size_map_t,x) \
90 TEMPLATE_CONTAINER_TYPE(Primitive<x>::string_map_t,x)
99 #define TEMPLATE_TYPE(x,f) \
100 TEMPLATE_SIMPLE_TYPE(x) \
101 TEMPLATE_CONTAINER_TYPE(vector<x>,x) \
102 TEMPLATE_CONTAINER_TYPE(list<x>,x) \
103 TEMPLATE_CONTAINER_TYPE(set<x>,x) \
104 TEMPLATE_CONTAINER_TYPE(Primitive<x>::int_map_t,x) \
105 TEMPLATE_CONTAINER_TYPE(Primitive<x>::string_map_t,x)
106 #endif // DD4HEP_HAVE_ALL_PARSERS
115 string type = c.type();
117 c.name(), c.type().c_str(),
118 c.value().c_str(), c->validity.c_str());
119 if ( type ==
"alignment" )
120 print_bound_value<string>(c);
121 else if ( type ==
"temperature" )
122 print_bound_value<double>(c);
123 else if ( type ==
"pressure" )
124 print_bound_value<double>(c,
"1.0/hPa");
125 else if ( type ==
"whatever" )
126 print_bound_value<vector<double> >(c);
127 else if ( type ==
"integer" )
128 print_bound_value<int>(c);
129 else if ( type ==
"long" )
130 print_bound_value<long>(c);
131 #if defined(DD4HEP_HAVE_ALL_PARSERS)
132 else if ( type ==
"short" )
133 print_bound_value<short>(c);
134 else if ( type ==
"unsigned short" )
135 print_bound_value<unsigned short>(c);
136 else if ( type ==
"unsigned integer" )
137 print_bound_value<unsigned int>(c);
138 else if ( type ==
"unsigned long" )
139 print_bound_value<unsigned long>(c);
141 else if ( type ==
"float" )
142 print_bound_value<float>(c);
143 else if ( type ==
"double" )
144 print_bound_value<double>(c);
145 else if ( type ==
"vector<double>" )
146 print_bound_value<vector<double> >(c);
150 for(RangeConditions::const_iterator k=rc.begin(); k != rc.end(); ++k)
151 print_condition<T>(*k);
163 except(
"Example",
"+++ The condition %s [%s] is not fully contained in iov:%s",
164 c->
name.c_str(), i->
str().c_str(), iov.
str().c_str());
166 except(
"Example",
"+++ The condition %s [%s] has no discrete type matching iov:%s",
167 c->
name.c_str(), i->
str().c_str(), iov.
str().c_str());
173 Test::TestEnv::TestEnv(LCDD& _lcdd,
const string& detector_name)
174 : lcdd(_lcdd), detector(), manager()
177 manager[
"LoaderType"] =
"multi";
178 manager[
"PoolType"] =
"DD4hep_ConditionsLinearPool";
179 manager[
"UpdatePoolType"] =
"DD4hep_ConditionsLinearUpdatePool";
180 manager[
"UserPoolType"] =
"DD4hep_ConditionsLinearUserPool";
187 if ( e.first && r.first ) {
192 invalidHandleError<IOVType>();
194 invalidHandleError<DetElement>();
203 string source =
"xml:"+string(::getenv(
"DD4hepINSTALL"))+file;
205 this->manager->fromString(iov_str, iov);
206 this->loader->addSource(source, iov);
215 const _P& p = manager->conditionsPool();
216 for(_P::const_iterator i=p.begin(); i != p.end(); ++i, ++cnt) {
220 const IOVType* typ = this->manager->iovType(cnt);
221 printout(
INFO,
"Example",
"+++ ConditionsIOVPool for type %s", typ->
str().c_str());
222 for (_E::const_iterator j=e.begin(); j != e.end(); ++j) {
226 printout(
INFO,
"Example",
"+++ Conditions for pool with IOV: %s age:%d",
232 printout(
INFO,
"Example",
"SUCCESS: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
233 printout(
INFO,
"Example",
"SUCCESS: +++ Conditions pools successfully dumped");
234 printout(
INFO,
"Example",
"SUCCESS: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
242 printout(
INFO,
"conditions",
"DetElement:%s # of conditons keys:%d",elt.path().c_str(),int(conds.
numKeys()));
244 const Container::Elements& elements = conds.elements();
245 for(Container::Elements::const_iterator i=elements.begin(); i!=elements.end(); ++i) {
256 if ( !elt->conditions.isValid() )
257 printout(
INFO,
"conditions_tree",
"DetElement:%s NO CONDITIONS present",elt.path().c_str());
259 dump_detector_element(elt);
260 for(DetElement::Children::const_iterator j=children.begin(); j!=children.end(); ++j)
261 dump_conditions_tree((*j).second);
void dump_conditions_pools()
std::string str() const
Conversion to string.
Container conditions() const
Access to the conditions information.
OpaqueData & data() const
Access the IOV block.
virtual void select_all(RangeConditions &result)=0
Select all conditions contained.
const char * name() const
Access the object name (or "" if not supported by the object)
T & get()
Generic getter. Specify the exact type, not a polymorph type.
void print_condition< void >(Condition c)
std::string typeName(const std::type_info &type)
ABI information about type names.
bool contains(const IOV &iov) const
Check for validity containment.
Main condition object handle.
DetElement daughter(const std::string &sub_path) const
Find daughter element of the detector object.
Elements elements
Container of IOV dependent conditions pools.
Container class for condition handles aggregated by a detector element.
T _multiply(const std::string &left, T right)
Generic multiplication using the evaluator: result = left * right.
template void print_conditions< void >(const RangeConditions &rc)
ConditionsManager & initialize()
Initialize the object after having set the properties.
int age_value
Aging value.
int except(const std::string &src, const std::string &fmt,...)
Calls the display action with ERROR and throws an std::runtime_error exception.
void print_conditions(const RangeConditions &rc)
DD4hep::Geometry::DetElement DetElement
std::vector< ConditionsIOVPool * > TypedConditionPool
std::pair< bool, const IOVType * > registerIOVType(size_t iov_type, const std::string &iov_name)
Register new IOV type if it does not (yet) exist.
Class describing the interval of validty.
std::string str() const
Create string representation of the data block.
void print_condition(Condition condition)
void print_bound_condition(Condition, const char *)
const std::type_info & typeInfo() const
Access to the type information.
std::map< IOV::Key, Element > Elements
IOV * iov
The IOV of the conditions hosted.
Class describing the interval of validty type.
void check_discrete_condition(Condition c, const IOV &iov)
Handle< Loader > loader() const
Access the conditions loader.
Class implementing the conditions collection for a given IOV type.
A bit of support for printing primitives.
Handle class describing the access to DetElement dependent conditions.
const iov_type & iov() const
Access the IOV block.
static ConditionsManager from(T &host)
Static accessor if installed as an extension.
#define TEMPLATE_TYPE(x, f)
Pool of conditions satisfying one IOV type (epoch, run, fill, etc)
static void dump_conditions_tree(DetElement elt)
Dump conditions tree of a detector element.
ConditionsManager manager
void __print_bound_val(Condition c, const char *norm)
std::vector< Condition > RangeConditions
std::map< std::string, DetElement > Children
int printout(PrintLevel severity, const char *src, const char *fmt,...)
Calls the display action with a given severity level.
bool is_discrete() const
Check if the IOV corresponds to a range.
static void dump_detector_element(DetElement elt)
Dump the conditions of one detectpr element.
void __print_bound_val< string >(Condition c, const char *)
void __print_bound_container(Condition c, const char *)
size_t numKeys() const
Access the number of conditons keys available for this detector element.
void add_xml_data_source(const std::string &file, const std::string &iov)
Handle< ConditionsDataLoader > loader
std::string str() const
Create string representation of the IOV.