DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
ConditionsTreePersistency.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_CONDITIONSTREEPERSISTENCY_H
14 #define DDCOND_CONDITIONSTREEPERSISTENCY_H
15 
16 // Framework/ROOT include files
17 #include "DDCond/ConditionsPool.h"
18 
19 #include "TNamed.h"
20 class TFile;
21 
22 // C/C++ include files
23 #include <map>
24 #include <list>
25 #include <vector>
26 #include <memory>
27 
28 
30 namespace dd4hep {
31 
33  namespace cond {
34 
35  /*
36  * event (iov)
37  * |
38  * |
39  * | Link attribute:
40  * | (priority,tag-id)
41  * V 0..* valid for mutiple conditions
42  * global tag ----------------> condition tag (iov,version,pool-id)
43  * (named,iov) | 1 [cached, # of consecutive iov]
44  * [in memory] |
45  * |
46  * |
47  * V 0..1
48  * conditions pool (pool-id)
49  * | [DDCond cache/management]
50  * |
51  * |
52  * |
53  * V 0..*
54  * condition
55  *
56  *
57  */
58 
64  class ConditionsTag {
65  public:
67  std::string name;
69  IOV iov{0};
71  int version = -1;
73  int collectionID = -1;
75  ~ConditionsTag() = default;
77  ConditionsTag() = default;
79  ConditionsTag(const ConditionsTag& copy) = default;
82  };
83 
89  class GlobalTag {
90  public:
92  std::string name;
94  IOV iov{0};
95 
97 
98  std::map<std::pair<int,int>, int> tags;
99 
100 
102  ~GlobalTag() = default;
104  GlobalTag() = default;
106  GlobalTag(const GlobalTag& copy) = default;
108  GlobalTag& operator=(const GlobalTag& copy) = default;
109  };
110 
112  class ConditionsSlice;
113  class ConditionsIOVPool;
114 
116 
128  public:
129  typedef std::vector<Condition> pool_type;
130  typedef std::pair<std::string, pool_type> named_pool_type;
131  typedef std::pair<std::string,std::pair<std::pair<std::string,int>,IOV::Key> > iov_key_type;
132  typedef std::list<std::pair<iov_key_type, pool_type> > persistent_type;
133 
136  float duration {0};
138  IMPORT_ALL = 1<<0,
139  IMPORT_EXACT = 1<<1,
145  LAST
146  };
148  size_t _import(ImportStrategy strategy,
149  persistent_type& pers,
150  const std::string& id,
151  const std::string& iov_type,
152  const IOV::Key& iov_key,
153  ConditionsManager mgr);
154 
156  void _clear(persistent_type& pool);
157 
158  public:
162  ConditionsTreePersistency(const std::string& name, const std::string& title="DD4hep conditions container");
166  virtual ~ConditionsTreePersistency();
169 
171  void clear();
173  static TFile* openFile(const std::string& fname);
174 
176  size_t add(const std::string& tag, const IOV& iov, std::vector<Condition>& conditions);
178  size_t add(const std::string& tag, ConditionsPool& pool);
180  size_t add(const std::string& tag, const ConditionsIOVPool& pool);
181 
182 
184  static std::unique_ptr<ConditionsTreePersistency> load(TFile* file,const std::string& object);
185 
187  static std::unique_ptr<ConditionsTreePersistency> load(const std::string& file,const std::string& object) {
188  return load(openFile(file), object);
189  }
190 
192  size_t importIOVPool(const std::string& id, const std::string& iov_type, ConditionsManager mgr);
194  size_t importConditionsPool(const std::string& id, const std::string& iov_type, ConditionsManager mgr);
197  const std::string& id,
198  const std::string& iov_type,
199  const IOV::Key& key,
200  ConditionsManager mgr);
201 
203  int save(TFile* file);
205  int save(const std::string& file_name);
206 
209  };
210 
211  } /* End namespace cond */
212 } /* End namespace dd4hep */
213 #endif // DDCOND_CONDITIONSTREEPERSISTENCY_H
214 
dd4hep::cond::ConditionsTreePersistency::IMPORT_EDGE_LOWER
@ IMPORT_EDGE_LOWER
Definition: ConditionsTreePersistency.h:143
dd4hep::cond::ConditionsTreePersistency::openFile
static TFile * openFile(const std::string &fname)
Open ROOT file in read mode.
Definition: ConditionsTreePersistency.cpp:127
cond
AlignmentCondition::Object * cond
Definition: AlignmentsCalculator.cpp:68
dd4hep::cond::ConditionsTreePersistency::conditionPools
persistent_type conditionPools
Definition: ConditionsTreePersistency.h:134
dd4hep::cond::ConditionsTreePersistency::operator=
ConditionsTreePersistency & operator=(const ConditionsTreePersistency &copy)=delete
No assignment.
dd4hep::cond::ConditionsTreePersistency::_clear
void _clear(persistent_type &pool)
Clear object content and release allocated memory.
Definition: ConditionsTreePersistency.cpp:136
dd4hep::cond::GlobalTag::tags
std::map< std::pair< int, int >, int > tags
This vector contains all the individual tags contributing to this global tag.
Definition: ConditionsTreePersistency.h:98
dd4hep::cond::ConditionsTag::version
int version
Version number of the condition.
Definition: ConditionsTreePersistency.h:71
dd4hep::cond::ConditionsTreePersistency::importConditionsPool
size_t importConditionsPool(const std::string &id, const std::string &iov_type, ConditionsManager mgr)
Load conditions pool and populate conditions manager.
dd4hep::cond::ConditionsTreePersistency::_import
size_t _import(ImportStrategy strategy, persistent_type &pers, const std::string &id, const std::string &iov_type, const IOV::Key &iov_key, ConditionsManager mgr)
Load ConditionsIOVPool and populate conditions manager.
Definition: ConditionsTreePersistency.cpp:175
dd4hep::cond::ConditionsTreePersistency::save
int save(const std::string &file_name)
Save the data content to a root file.
dd4hep::cond::ConditionsTreePersistency::clear
void clear()
Clear object content and release allocated memory.
Definition: ConditionsTreePersistency.cpp:147
dd4hep::cond::ConditionsTreePersistency::IMPORT_ALL
@ IMPORT_ALL
Definition: ConditionsTreePersistency.h:138
dd4hep::cond::ConditionsTag
Definition: ConditionsTreePersistency.h:64
dd4hep::IOV::Key
std::pair< Key_value_type, Key_value_type > Key
Definition: IOV.h:74
dd4hep::cond::ConditionsTreePersistency::IMPORT_EDGE_UPPER
@ IMPORT_EDGE_UPPER
Definition: ConditionsTreePersistency.h:144
dd4hep::cond::ConditionsTag::ConditionsTag
ConditionsTag(const ConditionsTag &copy)=default
Copy contructor.
dd4hep::cond::GlobalTag::iov
IOV iov
The interval of validity for this global tag.
Definition: ConditionsTreePersistency.h:94
dd4hep::cond::GlobalTag::GlobalTag
GlobalTag()=default
Default constructor.
dd4hep::cond::ConditionsTreePersistency::ClassDef
ClassDef(ConditionsTreePersistency, 1)
ROOT object ClassDef.
dd4hep::cond::GlobalTag::~GlobalTag
~GlobalTag()=default
Default detructor.
dd4hep::cond::ConditionsTreePersistency::importConditionsPool
size_t importConditionsPool(ImportStrategy strategy, const std::string &id, const std::string &iov_type, const IOV::Key &key, ConditionsManager mgr)
Load conditions pool and populate conditions manager. Allow tro be selective also for the key.
dd4hep::cond::ConditionsTreePersistency::add
size_t add(const std::string &tag, const IOV &iov, std::vector< Condition > &conditions)
Add conditions content to be saved. Note, that dependent conditions shall not be saved!
dd4hep::cond::ConditionsTreePersistency::save
int save(TFile *file)
Save the data content to a root file.
Definition: ConditionsTreePersistency.cpp:272
dd4hep::IOV
Class describing the interval of validty.
Definition: IOV.h:67
dd4hep::cond::ConditionsTreePersistency::LAST
@ LAST
Definition: ConditionsTreePersistency.h:145
dd4hep::cond::ConditionsTreePersistency::load
static std::unique_ptr< ConditionsTreePersistency > load(TFile *file, const std::string &object)
Load conditions content from file.
dd4hep::cond::ConditionsTreePersistency::named_pool_type
std::pair< std::string, pool_type > named_pool_type
Definition: ConditionsTreePersistency.h:130
dd4hep::cond::ConditionsTag::iov
IOV iov
Interval of validity.
Definition: ConditionsTreePersistency.h:69
dd4hep::cond::ConditionsPool
Class implementing the conditions collection for a given IOV type.
Definition: ConditionsPool.h:54
dd4hep::cond::ConditionsTag::~ConditionsTag
~ConditionsTag()=default
Default destructor.
TNamed
Class of the ROOT toolkit. See http://root.cern.ch/root/htmldoc/ClassIndex.html.
Definition: ROOTClasses.h:37
dd4hep::cond::ConditionsTreePersistency::ConditionsTreePersistency
ConditionsTreePersistency(const ConditionsTreePersistency &copy)=delete
No copy constructor.
dd4hep::cond::ConditionsTreePersistency::IMPORT_CONTAINED
@ IMPORT_CONTAINED
Definition: ConditionsTreePersistency.h:140
dd4hep::cond::ConditionsTreePersistency::add
size_t add(const std::string &tag, ConditionsPool &pool)
Add conditions content to be saved. Note, that dependent conditions shall not be saved!
dd4hep::cond::GlobalTag::GlobalTag
GlobalTag(const GlobalTag &copy)=default
Copy contructor.
dd4hep::cond::ConditionsTreePersistency::IMPORT_CONTAINED_UPPER
@ IMPORT_CONTAINED_UPPER
Definition: ConditionsTreePersistency.h:142
dd4hep::cond::ConditionsTreePersistency::persistent_type
std::list< std::pair< iov_key_type, pool_type > > persistent_type
Definition: ConditionsTreePersistency.h:132
dd4hep::cond::GlobalTag::operator=
GlobalTag & operator=(const GlobalTag &copy)=default
Assignment operator.
dd4hep::cond::ConditionsTreePersistency::duration
float duration
Definition: ConditionsTreePersistency.h:136
dd4hep::cond::ConditionsTreePersistency
Helper to save conditions pools to ROOT.
Definition: ConditionsTreePersistency.h:127
dd4hep::cond::GlobalTag::name
std::string name
Name of the global tag.
Definition: ConditionsTreePersistency.h:92
dd4hep::cond::ConditionsTreePersistency::iovPools
persistent_type iovPools
Definition: ConditionsTreePersistency.h:135
dd4hep::cond::ConditionsTreePersistency::ConditionsTreePersistency
ConditionsTreePersistency(const std::string &name, const std::string &title="DD4hep conditions container")
Initializing constructor.
dd4hep::cond::ConditionsTreePersistency::pool_type
std::vector< Condition > pool_type
Definition: ConditionsTreePersistency.h:129
dd4hep::cond::ConditionsManager
Manager class for condition handles.
Definition: ConditionsManager.h:46
key
unsigned char key
Definition: AlignmentsCalculator.cpp:69
dd4hep::cond::ConditionsTreePersistency::ImportStrategy
ImportStrategy
Definition: ConditionsTreePersistency.h:137
dd4hep::cond::ConditionsTreePersistency::~ConditionsTreePersistency
virtual ~ConditionsTreePersistency()
Default destructor.
Definition: ConditionsTreePersistency.cpp:71
dd4hep::cond::ConditionsTreePersistency::load
static std::unique_ptr< ConditionsTreePersistency > load(const std::string &file, const std::string &object)
Load conditions content from file.
Definition: ConditionsTreePersistency.h:187
dd4hep::cond::ConditionsTag::operator=
ConditionsTag & operator=(const ConditionsTag &copy)=default
Assignment operator.
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::cond::GlobalTag
Definition: ConditionsTreePersistency.h:89
dd4hep::cond::ConditionsTag::collectionID
int collectionID
The collections contributing to this tag.
Definition: ConditionsTreePersistency.h:73
ConditionsPool.h
dd4hep::cond::ConditionsTreePersistency::iov_key_type
std::pair< std::string, std::pair< std::pair< std::string, int >, IOV::Key > > iov_key_type
Definition: ConditionsTreePersistency.h:131
dd4hep::cond::ConditionsTreePersistency::IMPORT_EXACT
@ IMPORT_EXACT
Definition: ConditionsTreePersistency.h:139
dd4hep::detail::tools::copy
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
Definition: AlignmentTools.cpp:43
dd4hep::cond::ConditionsTreePersistency::IMPORT_CONTAINED_LOWER
@ IMPORT_CONTAINED_LOWER
Definition: ConditionsTreePersistency.h:141
dd4hep::cond::ConditionsIOVPool
Pool of conditions satisfying one IOV type (epoch, run, fill, etc)
Definition: ConditionsIOVPool.h:38
dd4hep::cond::ConditionsTreePersistency::add
size_t add(const std::string &tag, const ConditionsIOVPool &pool)
Add conditions content to be saved. Note, that dependent conditions shall not be saved!
dd4hep::cond::ConditionsTreePersistency::ConditionsTreePersistency
ConditionsTreePersistency()
Default constructor.
Definition: ConditionsTreePersistency.cpp:61
dd4hep::cond::ConditionsTag::ConditionsTag
ConditionsTag()=default
Default constructor.
dd4hep::cond::ConditionsTreePersistency::importIOVPool
size_t importIOVPool(const std::string &id, const std::string &iov_type, ConditionsManager mgr)
Load conditions IOV pool and populate conditions manager.
Definition: ConditionsTreePersistency.cpp:245
dd4hep::cond::ConditionsTag::name
std::string name
Tag name.
Definition: ConditionsTreePersistency.h:67
dd4hep::cond::ConditionsSlice
Conditions slice object. Defines which conditions should be loaded by the ConditionsManager.
Definition: ConditionsSlice.h:53