DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
ConditionsContent.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_CONDITIONSCONTENT_H
14 #define DDCOND_CONDITIONSCONTENT_H
15 
16 // Framework include files
17 #include "DD4hep/Memory.h"
18 #include "DD4hep/Conditions.h"
20 
21 // C/C++ include files
22 #include <memory>
23 #include <unordered_map>
24 
26 namespace dd4hep {
27 
29  namespace cond {
30 
32 
40  public:
41  int refCount = 0;
42  protected:
44  virtual ~ConditionsLoadInfo();
45  public:
54  ConditionsLoadInfo* addRef() { ++refCount; return this; }
55  void release() { --refCount; if ( refCount <= 0 ) delete this; }
56  virtual const std::type_info& type() const = 0;
57  virtual const void* ptr() const = 0;
58  virtual ConditionsLoadInfo* clone() const = 0;
59  virtual std::string toString() const = 0;
60  template<typename T> T* data() const { return (T*)ptr(); }
61  };
62 
64 
75  public:
77 
82  template <typename T> class LoadInfo : public ConditionsLoadInfo {
83  public:
84  T info;
85  LoadInfo(const T& i) : info(i) {}
86  LoadInfo() = default;
87  LoadInfo(const LoadInfo& c) = delete;
88  virtual ~LoadInfo() = default;
89  LoadInfo& operator=(const LoadInfo& copy) = delete;
90  virtual const std::type_info& type() const override
91  { return typeid(T); }
92  virtual const void* ptr() const override
93  { return &info; }
94  virtual ConditionsLoadInfo* clone() const override
95  { return new LoadInfo<T>(info); }
96  virtual std::string toString() const override;
97  };
98 
99  // Looks like tree-maps are a bit slower.
100  typedef std::map<Condition::key_type,ConditionDependency* > Dependencies;
101  typedef std::map<Condition::key_type,ConditionsLoadInfo* > Conditions;
102  //typedef std::unordered_map<Condition::key_type,ConditionDependency* > Dependencies;
103  //typedef std::unordered_map<Condition::key_type,ConditionsLoadInfo* > Conditions;
104 
105  protected:
110 
111  private:
116 
117  public:
121  virtual ~ConditionsContent();
125  const Conditions& conditions() const { return m_conditions; }
129  const Dependencies& derived() const { return m_derived; }
131  void clear();
133  void merge(const ConditionsContent& to_add);
135  bool remove(Condition::key_type condition);
137  std::pair<Condition::key_type, ConditionsLoadInfo*>
140  std::pair<Condition::key_type, ConditionsLoadInfo*>
143  template <typename T> std::pair<Condition::key_type, ConditionsLoadInfo*>
145  return addLocationInfo(hash, new LoadInfo<T>(info));
146  }
148  template <typename T> std::pair<Condition::key_type, ConditionsLoadInfo*>
150  return addLocationInfo(ConditionKey(de, item).hash, new LoadInfo<T>(info));
151  }
153  std::pair<Condition::key_type, ConditionDependency*>
156  std::pair<Condition::key_type, ConditionDependency*>
157  addDependency(DetElement de, Condition::itemkey_type item, std::shared_ptr<ConditionUpdateCall> callback);
158  };
159 
160  template <> inline
162  return this->info;
163  }
164 
165  } /* End namespace cond */
166 } /* End namespace dd4hep */
167 #endif // DDCOND_CONDITIONSCONTENT_H
dd4hep::cond::ConditionsContent::LoadInfo::operator=
LoadInfo & operator=(const LoadInfo &copy)=delete
dd4hep::cond::ConditionsContent::m_derived
Dependencies m_derived
Container of derived conditions required by this content.
Definition: ConditionsContent.h:109
cond
AlignmentCondition::Object * cond
Definition: AlignmentsCalculator.cpp:68
dd4hep::cond::ConditionsContent::LoadInfo::~LoadInfo
virtual ~LoadInfo()=default
dd4hep::cond::ConditionsContent::m_conditions
Conditions m_conditions
Container of conditions required by this content.
Definition: ConditionsContent.h:107
dd4hep::cond::ConditionsContent::conditions
Conditions & conditions()
Access to the real condition entries to be loaded.
Definition: ConditionsContent.h:123
dd4hep::cond::ConditionsLoadInfo::addRef
ConditionsLoadInfo * addRef()
Definition: ConditionsContent.h:54
dd4hep::cond::ConditionsContent::Dependencies
std::map< Condition::key_type, ConditionDependency * > Dependencies
Definition: ConditionsContent.h:100
dd4hep::info
std::size_t info(const std::string &src, const std::string &msg)
Definition: RootDictionary.h:65
dd4hep::cond::ConditionsLoadInfo::ConditionsLoadInfo
ConditionsLoadInfo(ConditionsLoadInfo &&copy)=delete
Move constructor.
dd4hep::cond::ConditionsLoadInfo::toString
virtual std::string toString() const =0
dd4hep::cond::ConditionsContent::conditions
const Conditions & conditions() const
Access to the real condition entries to be loaded (CONST)
Definition: ConditionsContent.h:125
dd4hep::cond::ConditionsContent::~ConditionsContent
virtual ~ConditionsContent()
Default destructor.
Definition: ConditionsContent.cpp:38
dd4hep::ConditionKey
Key definition to optimize ans simplyfy the access to conditions entities.
Definition: Conditions.h:280
dd4hep::cond::ConditionsLoadInfo::ConditionsLoadInfo
ConditionsLoadInfo(const ConditionsLoadInfo &copy)=delete
Copy constructor.
dd4hep::cond::ConditionsContent::remove
bool remove(Condition::key_type condition)
Remove a condition from the content.
Definition: ConditionsContent.cpp:80
dd4hep::cond::ConditionsLoadInfo::~ConditionsLoadInfo
virtual ~ConditionsLoadInfo()
Default destructor.
Definition: ConditionsContent.cpp:27
dd4hep::cond::ConditionsContent::LoadInfo::LoadInfo
LoadInfo(const T &i)
Definition: ConditionsContent.h:85
dd4hep::cond::ConditionsContent
Conditions content object. Defines which conditions should be loaded by the ConditionsManager.
Definition: ConditionsContent.h:74
dd4hep::cond::ConditionDependency
Condition dependency definition.
Definition: ConditionDerived.h:316
dd4hep::cond::ConditionsContent::derived
Dependencies & derived()
Access to the derived condition entries to be computed.
Definition: ConditionsContent.h:127
dd4hep::cond::ConditionsContent::LoadInfo::LoadInfo
LoadInfo(const LoadInfo &c)=delete
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::cond::ConditionsContent::addLocationInfo
std::pair< Condition::key_type, ConditionsLoadInfo * > addLocationInfo(Condition::key_type hash, ConditionsLoadInfo *info)
Add a new conditions key. T must inherit from class ConditionsContent::Info.
Definition: ConditionsContent.cpp:106
dd4hep::cond::ConditionsLoadInfo::ptr
virtual const void * ptr() const =0
dd4hep::cond::ConditionsContent::merge
void merge(const ConditionsContent &to_add)
Merge the content of "to_add" into the this content.
Definition: ConditionsContent.cpp:51
dd4hep::cond::ConditionsContent::LoadInfo::ptr
virtual const void * ptr() const override
Definition: ConditionsContent.h:92
dd4hep::cond::ConditionsContent::ConditionsContent
ConditionsContent()
Default constructor.
Definition: ConditionsContent.cpp:32
dd4hep::cond::ConditionsContent::derived
const Dependencies & derived() const
Access to the derived condition entries to be computed (CONST)
Definition: ConditionsContent.h:129
dd4hep::cond::ConditionsContent::operator=
ConditionsContent & operator=(const ConditionsContent &copy)=delete
Default assignment operator.
dd4hep::cond::ConditionsContent::LoadInfo::toString
virtual std::string toString() const override
dd4hep::Condition::itemkey_type
unsigned int itemkey_type
Low part of the key identifies the item identifier.
Definition: Conditions.h:58
dd4hep::cond::ConditionsLoadInfo
Base class for data loading information.
Definition: ConditionsContent.h:39
Conditions.h
dd4hep::Condition::key_type
unsigned long long int key_type
Forward definition of the key type.
Definition: Conditions.h:54
dd4hep::cond::ConditionsLoadInfo::data
T * data() const
Definition: ConditionsContent.h:60
Memory.h
dd4hep::cond::ConditionsLoadInfo::refCount
int refCount
Definition: ConditionsContent.h:41
dd4hep::cond::ConditionsContent::LoadInfo::type
virtual const std::type_info & type() const override
Definition: ConditionsContent.h:90
dd4hep::cond::ConditionsContent::ConditionsContent
ConditionsContent(const ConditionsContent &copy)=delete
Copy constructor.
ConditionDerived.h
dd4hep::cond::ConditionsContent::LoadInfo::clone
virtual ConditionsLoadInfo * clone() const override
Definition: ConditionsContent.h:94
dd4hep::cond::ConditionsContent::LoadInfo::LoadInfo
LoadInfo()=default
dd4hep::cond::ConditionsLoadInfo::clone
virtual ConditionsLoadInfo * clone() const =0
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::cond::ConditionsContent::addDependency
std::pair< Condition::key_type, ConditionDependency * > addDependency(ConditionDependency *dep)
Add a new shared conditions dependency.
Definition: ConditionsContent.cpp:121
dd4hep::cond::ConditionsContent::Conditions
std::map< Condition::key_type, ConditionsLoadInfo * > Conditions
Definition: ConditionsContent.h:101
dd4hep::sim::hash
unsigned int hash(unsigned int initialSeed, unsigned int eventNumber, unsigned int runNumber)
calculate hash from initialSeed, eventID and runID
Definition: Geant4EventSeed.h:201
dd4hep::cond::ConditionsContent::LoadInfo
Concrete class for data loading information.
Definition: ConditionsContent.h:82
dd4hep::detail::tools::copy
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
Definition: AlignmentTools.cpp:43
dd4hep::cond::ConditionsLoadInfo::ConditionsLoadInfo
ConditionsLoadInfo()
Default constructor.
Definition: ConditionsContent.cpp:22
dd4hep::cond::ConditionsContent::clear
void clear()
Clear the conditions content definitions.
Definition: ConditionsContent.cpp:45
dd4hep::cond::ConditionsContent::addLocation
std::pair< Condition::key_type, ConditionsLoadInfo * > addLocation(Condition::key_type hash, const T &info)
Add a new conditions key. T must inherit from class ConditionsContent::Info.
Definition: ConditionsContent.h:144
dd4hep::cond::ConditionsLoadInfo::operator=
ConditionsLoadInfo & operator=(const ConditionsLoadInfo &copy)=delete
Assignment operator.
dd4hep::cond::ConditionsContent::LoadInfo::info
T info
Definition: ConditionsContent.h:84
dd4hep::cond::ConditionsContent::addLocation
std::pair< Condition::key_type, ConditionsLoadInfo * > addLocation(DetElement de, Condition::itemkey_type item, const T &info)
Add a new shared conditions dependency.
Definition: ConditionsContent.h:149
dd4hep::cond::ConditionsLoadInfo::release
void release()
Definition: ConditionsContent.h:55
dd4hep::cond::ConditionsContent::insertKey
std::pair< Condition::key_type, ConditionsLoadInfo * > insertKey(Condition::key_type hash)
Add a new conditions key representing a real (not derived) condition.
Definition: ConditionsContent.cpp:97
dd4hep::cond::ConditionsLoadInfo::type
virtual const std::type_info & type() const =0