DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
ConditionsSlice.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_CONDITIONSSLICE_H
14 #define DDCOND_CONDITIONSSLICE_H
15 
16 // Framework include files
17 #include "DD4hep/Conditions.h"
18 #include "DD4hep/ConditionsMap.h"
20 
21 #include "DDCond/ConditionsPool.h"
24 
25 // C/C++ include files
26 #include <memory>
27 
29 namespace dd4hep {
30 
32  namespace cond {
33 
34  // Forward declarations
35  class UserPool;
36  class ConditionsSlice;
37 
39 
53  class ConditionsSlice : public ConditionsMap {
54  public:
56  typedef std::vector<std::shared_ptr<ConditionsPool> > ContainedPools;
57 
58  enum ManageFlag {
60  REGISTER_POOL = 1<<1,
62  };
63  enum LoadFlags {
64  REF_POOLS = 1<<1
65  };
66 
68 
74  class Inserter {
77 
78  public:
80  const IOV& iov = s.pool->validity();
82  }
83  template <typename T> Inserter(ConditionsSlice& s, const T& data) : slice(s) {
84  const IOV& iov = slice.pool->validity();
86  std::for_each(std::begin(data), std::end(data), *this);
87  }
88  void operator()(Condition c) const {
90  slice.pool->insert(c);
91  }
92  void operator()(const std::pair<Condition::key_type,Condition>& e) const {
93  (*this)(e.second);
94  }
95  template <typename T> void process(const T& data) const {
96  std::for_each(std::begin(data), std::end(data), *this);
97  }
98  };
99 
100  public:
102 
107  std::unique_ptr<UserPool> pool;
109  std::shared_ptr<ConditionsContent> content;
110 
116  unsigned long flags = 0;
117 
118  protected:
123 
126 
128 
129  virtual bool manage(ConditionsPool* pool, Condition condition, ManageFlag flg);
130 
131  static Condition select_cond(Condition c) { return c; }
132  template <typename T>
133  static Condition select_cond(const std::pair<T,Condition>& c) { return c.second; }
134  public:
136  ConditionsSlice() = delete;
140  ConditionsSlice(ConditionsManager m, const std::shared_ptr<ConditionsContent>& c);
144  virtual ~ConditionsSlice();
145 
147  size_t size() const { return content->conditions().size()+content->derived().size(); }
149  void refPools() { this->flags |= REF_POOLS; }
151  void derefPools();
153  const ConditionsContent::Conditions& conditions() const { return content->conditions();}
155  const ConditionsContent::Dependencies& derived() const { return content->derived(); }
161  const IOV& iov() const;
163  void reset();
164 
166 
167  template <typename T> void manage(const T& conds, ManageFlag flg) {
168  if ( !conds.empty() ) {
169  ConditionsPool* p = (flg&REGISTER_MANAGER) ? manager.registerIOV(pool->validity()) : 0;
170  for( const auto& e : conds )
171  manage(p, select_cond(e), flg);
172  }
173  }
175 
176  virtual bool manage(Condition condition, ManageFlag flg);
177 
179  std::vector<Condition> get(DetElement detector) const;
180 
182  virtual bool insert(DetElement detector, Condition::itemkey_type key, Condition condition) override;
185  virtual Condition get(DetElement detector, Condition::itemkey_type key) const override;
187  virtual std::vector<Condition> get(DetElement detector,
189  Condition::itemkey_type upper) const override;
191  virtual void scan(const Condition::Processor& processor) const override;
193  virtual void scan(DetElement detector,
196  const Condition::Processor& processor) const override;
197  };
198 
200  void fill_content(ConditionsManager mgr, ConditionsContent& content, const IOVType& typ);
201 
202  } /* End namespace cond */
203 } /* End namespace dd4hep */
204 #endif // DDCOND_CONDITIONSSLICE_H
dd4hep::cond::ConditionsSlice::flags
unsigned long flags
Flag to steer conditions management.
Definition: ConditionsSlice.h:116
dd4hep::cond::ConditionsSlice::get
std::vector< Condition > get(DetElement detector) const
Access all conditions from a given detector element.
Definition: ConditionsSlice.cpp:108
dd4hep::cond::ConditionsManager::registerIOV
ConditionsPool * registerIOV(const IOV &iov) const
Register IOV with type and key.
Definition: ConditionsManager.cpp:231
dd4hep::cond::ConditionsSlice::manage
void manage(const T &conds, ManageFlag flg)
Insert a set of conditions to the slice AND register them to the conditions manager.
Definition: ConditionsSlice.h:167
dd4hep::cond::ConditionsSlice::LoadFlags
LoadFlags
Definition: ConditionsSlice.h:63
dd4hep::cond::ConditionsSlice::used_pools
ContainedPools used_pools
If requested refence the used pools with a shared pointer to inhibit cleanup.
Definition: ConditionsSlice.h:114
cond
AlignmentCondition::Object * cond
Definition: AlignmentsCalculator.cpp:68
dd4hep::cond::ConditionsSlice::select_cond
static Condition select_cond(Condition c)
Definition: ConditionsSlice.h:131
dd4hep::cond::ConditionsSlice::REF_POOLS
@ REF_POOLS
Definition: ConditionsSlice.h:64
dd4hep::cond::ConditionsSlice::derefPools
void derefPools()
Set flag to not reference the used pools during prepare (and drop possibly pending)
Definition: ConditionsSlice.cpp:50
dd4hep::cond::ConditionsSlice::Inserter::process
void process(const T &data) const
Definition: ConditionsSlice.h:95
dd4hep::cond::ConditionsContent::Dependencies
std::map< Condition::key_type, ConditionDependency * > Dependencies
Definition: ConditionsContent.h:100
dd4hep::cond::ConditionsSlice::REGISTER_POOL
@ REGISTER_POOL
Definition: ConditionsSlice.h:60
dd4hep::cond::ConditionsSlice::manage
virtual bool manage(ConditionsPool *pool, Condition condition, ManageFlag flg)
Local optimization: Insert a set of conditions to the slice AND register them to the conditions manag...
Definition: ConditionsSlice.cpp:70
dd4hep::cond::ConditionsSlice::Inserter
Helper to simplify the registration of new condtitions from arbitrary containers.
Definition: ConditionsSlice.h:74
dd4hep::cond::ConditionsSlice::key_type
Condition::key_type key_type
Definition: ConditionsSlice.h:55
dd4hep::cond::ConditionsSlice::manager
ConditionsManager manager
Reference to the conditions manager.
Definition: ConditionsSlice.h:105
dd4hep::cond::ConditionsSlice::reset
void reset()
Clear the conditions content and the user pool.
Definition: ConditionsSlice.cpp:64
dd4hep::cond::ConditionsSlice::content
std::shared_ptr< ConditionsContent > content
Container of conditions required by this slice.
Definition: ConditionsSlice.h:109
ConditionsManager.h
dd4hep::IOVType
Class describing the interval of validty type.
Definition: IOV.h:37
dd4hep::cond::ConditionsSlice::size
size_t size() const
Total size of all conditions contained in the slice.
Definition: ConditionsSlice.h:147
dd4hep::Condition
Main condition object handle.
Definition: Conditions.h:51
dd4hep::IOV
Class describing the interval of validty.
Definition: IOV.h:67
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::cond::ConditionsSlice::REGISTER_FULL
@ REGISTER_FULL
Definition: ConditionsSlice.h:61
dd4hep::cond::ConditionsSlice::refPools
void refPools()
Set flag to reference the used pools during prepare.
Definition: ConditionsSlice.h:149
dd4hep::cond::ConditionsSlice::ConditionsSlice
ConditionsSlice()=delete
Default constructor.
dd4hep::cond::ConditionsSlice::operator=
ConditionsSlice & operator=(const ConditionsSlice &copy)=delete
Default assignment operator.
dd4hep::cond::ConditionsPool
Class implementing the conditions collection for a given IOV type.
Definition: ConditionsPool.h:54
dd4hep::cond::ConditionsManager::registerUnlocked
bool registerUnlocked(ConditionsPool &pool, Condition cond) const
Register new condition with the conditions store. Unlocked version, not multi-threaded.
Definition: ConditionsManager.cpp:254
dd4hep::cond::ConditionsSlice::missingDerivations
ConditionsContent::Dependencies & missingDerivations()
Access the map of missing computational conditions (only valid after preparation)
Definition: ConditionsSlice.h:159
dd4hep::cond::ConditionsSlice::Inserter::Inserter
Inserter(ConditionsSlice &s)
Definition: ConditionsSlice.h:79
dd4hep::cond::ConditionsSlice::Inserter::slice
ConditionsSlice & slice
Definition: ConditionsSlice.h:75
dd4hep::Condition::itemkey_type
unsigned int itemkey_type
Low part of the key identifies the item identifier.
Definition: Conditions.h:58
Conditions.h
dd4hep::cond::ConditionsSlice::status
ConditionsManager::Result status
Store the result of the prepare step.
Definition: ConditionsSlice.h:112
dd4hep::IOV::key
Key key() const
Get the local key of the IOV.
Definition: IOV.h:115
dd4hep::cond::ConditionsSlice::m_missingDerivations
ConditionsContent::Dependencies m_missingDerivations
If flag conditonsManager["OutputUnloadedConditions"]=true: will contain conditions not computed.
Definition: ConditionsSlice.h:122
dd4hep::Condition::key_type
unsigned long long int key_type
Forward definition of the key type.
Definition: Conditions.h:54
ConditionsMap.h
dd4hep::cond::ConditionsSlice::scan
virtual void scan(const Condition::Processor &processor) const override
ConditionsMap overload: Interface to scan data content of the conditions mapping.
Definition: ConditionsSlice.cpp:147
dd4hep::cond::ConditionsSlice::iov
const IOV & iov() const
Access the combined IOV of the slice from the pool.
Definition: ConditionsSlice.cpp:56
dd4hep::cond::ConditionsManager
Manager class for condition handles.
Definition: ConditionsManager.h:46
dd4hep::cond::ConditionsSlice::pool
std::unique_ptr< UserPool > pool
Reference to the user pool managing all conditions of this slice.
Definition: ConditionsSlice.h:107
dd4hep::cond::ConditionsSlice::missingConditions
ConditionsContent::Conditions & missingConditions()
Access the map of missing conditions (only valid after preparation)
Definition: ConditionsSlice.h:157
key
unsigned char key
Definition: AlignmentsCalculator.cpp:69
dd4hep::cond::ConditionsManager::Result
Result of a prepare call to the conditions manager.
Definition: ConditionsManager.h:59
dd4hep::cond::ConditionsSlice::derived
const ConditionsContent::Dependencies & derived() const
Access the map of computational conditions from the desired content.
Definition: ConditionsSlice.h:155
dd4hep::cond::ConditionsSlice::Inserter::operator()
void operator()(const std::pair< Condition::key_type, Condition > &e) const
Definition: ConditionsSlice.h:92
dd4hep::cond::ConditionsSlice::conditions
const ConditionsContent::Conditions & conditions() const
Access the map of conditions from the desired content.
Definition: ConditionsSlice.h:153
ConditionDerived.h
dd4hep::IOV::iovType
const IOVType * iovType
Reference to IOV type.
Definition: IOV.h:80
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::cond::ConditionsSlice::m_missingConditions
ConditionsContent::Conditions m_missingConditions
If flag conditonsManager["OutputUnloadedConditions"]=true: will contain conditions not loaded.
Definition: ConditionsSlice.h:120
dd4hep::cond::ConditionsContent::Conditions
std::map< Condition::key_type, ConditionsLoadInfo * > Conditions
Definition: ConditionsContent.h:101
dd4hep::cond::ConditionsSlice::Inserter::iov_pool
ConditionsPool * iov_pool
Definition: ConditionsSlice.h:76
dd4hep::cond::fill_content
void fill_content(ConditionsManager mgr, ConditionsContent &content, const IOVType &typ)
Populate the conditions slice from the conditions manager (convenience)
Definition: ConditionsSlice.cpp:182
dd4hep::cond::ConditionsSlice::Inserter::Inserter
Inserter(ConditionsSlice &s, const T &data)
Definition: ConditionsSlice.h:83
ConditionsPool.h
dd4hep::cond::ConditionsSlice::REGISTER_MANAGER
@ REGISTER_MANAGER
Definition: ConditionsSlice.h:59
ConditionsContent.h
dd4hep::cond::ConditionsSlice::ContainedPools
std::vector< std::shared_ptr< ConditionsPool > > ContainedPools
Definition: ConditionsSlice.h:56
dd4hep::cond::ConditionsSlice::~ConditionsSlice
virtual ~ConditionsSlice()
Default destructor.
Definition: ConditionsSlice.cpp:44
dd4hep::cond::ConditionsSlice::select_cond
static Condition select_cond(const std::pair< T, Condition > &c)
Definition: ConditionsSlice.h:133
dd4hep::detail::tools::copy
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
Definition: AlignmentTools.cpp:43
dd4hep::cond::ConditionsSlice::Inserter::operator()
void operator()(Condition c) const
Definition: ConditionsSlice.h:88
dd4hep::cond::ConditionsSlice::insert
virtual bool insert(DetElement detector, Condition::itemkey_type key, Condition condition) override
ConditionsMap overload: Add a condition directly to the slice.
Definition: ConditionsSlice.cpp:120
dd4hep::cond::ConditionsSlice::ManageFlag
ManageFlag
Definition: ConditionsSlice.h:58
dd4hep::Condition::Processor
Abstract base for processing callbacks to conditions objects.
Definition: Conditions.h:112
dd4hep::ConditionsMap
ConditionsMap class.
Definition: ConditionsMap.h:59
dd4hep::cond::ConditionsSlice
Conditions slice object. Defines which conditions should be loaded by the ConditionsManager.
Definition: ConditionsSlice.h:53