DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConditionsPrinter.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation for LCD
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 
14 // Framework includes
15 #include "DD4hep/Printout.h"
16 #include "DD4hep/DetConditions.h"
19 
20 using namespace DD4hep;
21 using namespace DD4hep::Conditions;
22 
24 ConditionsPrinter::ConditionsPrinter(const std::string& pref, int flg)
25  : ConditionsProcessor(0), name("Condition"), prefix(pref), m_flag(flg)
26 {
27 }
28 
31  if ( cond.isValid() ) {
32  std::string repr = cond.str(m_flag);
33  if ( repr.length() > 100 )
34  printout(INFO,name,"++ %s%s", prefix.c_str(), repr.c_str());
35  else
36  printout(INFO,name,"++ %s%s [%p]", prefix.c_str(), repr.c_str(), cond.ptr());
37  const OpaqueData& data = cond.data();
38  std::string values = data.str();
39  if ( values.length() > 132 ) values = values.substr(0,130)+"...";
40  std::string new_prefix = prefix;
41  new_prefix.assign(prefix.length(),' ');
42  printout(INFO,name,"++ %s \tPath:%s Key:%08X Type:%s",
43  new_prefix.c_str(), cond.name(), cond.key(), data.dataType().c_str());
44  printout(INFO,name,"++ %s \tData:%s", new_prefix.c_str(), values.c_str());
45  }
46  return 1;
47 }
48 
51  if ( m_pool ) {
52  printout(INFO,name,"++ Conditions of DE %s [%d entries]",
53  container->detector.path().c_str(), int(container.keys().size()));
54  for(const auto& k : container.keys() ) {
55  Condition c = container.get(k.first,*m_pool);
56  std::string nam = c.name();
57  std::string cn = nam.substr(nam.find('#')+1);
59  printout(INFO,name,"++ %s %s %s [%08X] -> %s [%08X]",
60  prefix.c_str(), "Condition:", cn.c_str(), key==k.first ? key : k.first,
61  c.name(), k.second.first);
62  (*this)(c);
63  }
64  return 1;
65  }
66  except(name,"Cannot dump conditions container without user-pool.");
67  return 0;
68 }
OpaqueData & data() const
Access the IOV block.
Definition: Conditions.cpp:92
const char * name() const
Access the object name (or "" if not supported by the object)
Definition: Handle.inl:36
virtual int operator()(Condition cond)
Callback to output conditions information.
bool isValid() const
Check the validity of the object held by the handle.
Definition: Handle.h:124
Generic Conditions processor.
Class describing an opaque data block.
Definition: OpaqueData.h:36
Main condition object handle.
Definition: Conditions.h:70
Container class for condition handles aggregated by a detector element.
Definition: Conditions.h:206
int m_flag
Printout processing and customization flag.
unsigned int key_type
Forward definition of the key type.
Definition: Conditions.h:75
Condition get(const std::string &condition_key, const iov_type &iov)
Access to condition objects by key and IOV.
Definition: Conditions.cpp:189
int except(const std::string &src, const std::string &fmt,...)
Calls the display action with ERROR and throws an std::runtime_error exception.
Definition: Printout.cpp:217
pool_type * m_pool
Reference to the user pool.
T * ptr() const
Access to the held object.
Definition: Handle.h:149
std::string str(int with_data=WITH_IOV|WITH_ADDRESS|WITH_DATATYPE) const
Output method.
Definition: Conditions.cpp:65
const Keys & keys() const
Known keys of conditions in this container.
Definition: Conditions.cpp:180
std::string str() const
Create string representation of the data block.
Definition: OpaqueData.cpp:58
ConditionsPrinter(const std::string &prefix="", int flag=Condition::NO_NAME|Condition::WITH_IOV|Condition::WITH_ADDRESS)
Initializing constructor.
std::string name
Printer name. Want to know who is printing what.
key_type key() const
Hash identifier.
Definition: Conditions.cpp:132
std::string prefix
Printout prefix.
static key_type hashCode(const char *value)
Hash code generation from input string.
Definition: Conditions.h:323
int printout(PrintLevel severity, const char *src, const char *fmt,...)
Calls the display action with a given severity level.
Definition: Printout.cpp:111