DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
ConditionsRootPersistency.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_CONDITIONSROOTPERSISTENCY_H
14 #define DDCOND_CONDITIONSROOTPERSISTENCY_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 
36  class ConditionsSlice;
37  class ConditionsIOVPool;
38 
40 
52  public:
53  typedef std::vector<Condition> pool_type;
54  typedef std::pair<std::string, pool_type> named_pool_type;
55  typedef std::pair<std::string,std::pair<std::pair<std::string,int>,IOV::Key> > iov_key_type;
56  typedef std::list<std::pair<iov_key_type, pool_type> > persistent_type;
57 
61  float duration = 0;
63  IMPORT_ALL = 1<<0,
64  IMPORT_EXACT = 1<<1,
70  LAST
71  };
73  size_t _import(ImportStrategy strategy,
74  persistent_type& pers,
75  const std::string& id,
76  const std::string& iov_type,
77  const IOV::Key& iov_key,
78  ConditionsManager mgr);
79 
81  void _clear(persistent_type& pool);
82 
83  public:
87  ConditionsRootPersistency(const std::string& name, const std::string& title="DD4hep conditions container");
94 
96  void clear();
98  static TFile* openFile(const std::string& fname);
99 
101  size_t add(const std::string& identifier, const IOV& iov, std::vector<Condition>& conditions);
103  size_t add(const std::string& identifier, ConditionsPool& pool);
105  size_t add(const std::string& identifier, const UserPool& pool);
107  size_t add(const std::string& identifier, const ConditionsIOVPool& pool);
108 
110  static std::unique_ptr<ConditionsRootPersistency> load(TFile* file,const std::string& object);
111 
113  static std::unique_ptr<ConditionsRootPersistency> load(const std::string& file,const std::string& object) {
114  return load(openFile(file), object);
115  }
116 
118  size_t importIOVPool(const std::string& id, const std::string& iov_type, ConditionsManager mgr);
120  size_t importUserPool(const std::string& id, const std::string& iov_type, ConditionsManager mgr);
122  size_t importConditionsPool(const std::string& id, const std::string& iov_type, ConditionsManager mgr);
123 
126  const std::string& id,
127  const std::string& iov_type,
128  const IOV::Key& key,
129  ConditionsManager mgr);
130 
132  int save(TFile* file);
134  int save(const std::string& file_name);
135 
138  };
139 
140  } /* End namespace cond */
141 } /* End namespace dd4hep */
142 #endif // DDCOND_CONDITIONSROOTPERSISTENCY_H
dd4hep::cond::ConditionsRootPersistency::iovPools
persistent_type iovPools
Definition: ConditionsRootPersistency.h:60
cond
AlignmentCondition::Object * cond
Definition: AlignmentsCalculator.cpp:68
dd4hep::cond::ConditionsRootPersistency::save
int save(TFile *file)
Save the data content to a root file.
Definition: ConditionsRootPersistency.cpp:297
dd4hep::cond::ConditionsRootPersistency::ClassDef
ClassDef(ConditionsRootPersistency, 1)
ROOT object ClassDef.
dd4hep::cond::ConditionsRootPersistency::operator=
ConditionsRootPersistency & operator=(const ConditionsRootPersistency &copy)=delete
No assignment.
dd4hep::cond::ConditionsRootPersistency::IMPORT_CONTAINED
@ IMPORT_CONTAINED
Definition: ConditionsRootPersistency.h:65
dd4hep::cond::ConditionsRootPersistency::IMPORT_CONTAINED_LOWER
@ IMPORT_CONTAINED_LOWER
Definition: ConditionsRootPersistency.h:66
dd4hep::IOV::Key
std::pair< Key_value_type, Key_value_type > Key
Definition: IOV.h:74
dd4hep::cond::ConditionsRootPersistency::ImportStrategy
ImportStrategy
Definition: ConditionsRootPersistency.h:62
dd4hep::cond::ConditionsRootPersistency::IMPORT_EDGE_LOWER
@ IMPORT_EDGE_LOWER
Definition: ConditionsRootPersistency.h:68
dd4hep::cond::ConditionsRootPersistency::openFile
static TFile * openFile(const std::string &fname)
Open ROOT file in read mode.
Definition: ConditionsRootPersistency.cpp:143
dd4hep::cond::ConditionsRootPersistency::ConditionsRootPersistency
ConditionsRootPersistency(const std::string &name, const std::string &title="DD4hep conditions container")
Initializing constructor.
dd4hep::cond::ConditionsRootPersistency::LAST
@ LAST
Definition: ConditionsRootPersistency.h:70
dd4hep::cond::ConditionsRootPersistency::named_pool_type
std::pair< std::string, pool_type > named_pool_type
Definition: ConditionsRootPersistency.h:54
dd4hep::IOV
Class describing the interval of validty.
Definition: IOV.h:67
dd4hep::cond::ConditionsRootPersistency::importUserPool
size_t importUserPool(const std::string &id, const std::string &iov_type, ConditionsManager mgr)
Load conditions user pool and populate conditions manager.
Definition: ConditionsRootPersistency.cpp:270
dd4hep::cond::ConditionsRootPersistency::iov_key_type
std::pair< std::string, std::pair< std::pair< std::string, int >, IOV::Key > > iov_key_type
Definition: ConditionsRootPersistency.h:55
dd4hep::cond::ConditionsRootPersistency::ConditionsRootPersistency
ConditionsRootPersistency()
Default constructor.
Definition: ConditionsRootPersistency.cpp:62
dd4hep::cond::ConditionsRootPersistency::IMPORT_CONTAINED_UPPER
@ IMPORT_CONTAINED_UPPER
Definition: ConditionsRootPersistency.h:67
dd4hep::cond::ConditionsRootPersistency::duration
float duration
Definition: ConditionsRootPersistency.h:61
dd4hep::cond::ConditionsPool
Class implementing the conditions collection for a given IOV type.
Definition: ConditionsPool.h:54
dd4hep::cond::ConditionsRootPersistency::IMPORT_EXACT
@ IMPORT_EXACT
Definition: ConditionsRootPersistency.h:64
TNamed
Class of the ROOT toolkit. See http://root.cern.ch/root/htmldoc/ClassIndex.html.
Definition: ROOTClasses.h:37
dd4hep::cond::ConditionsRootPersistency::save
int save(const std::string &file_name)
Save the data content to a root file.
dd4hep::cond::ConditionsRootPersistency::_clear
void _clear(persistent_type &pool)
Clear object content and release allocated memory.
Definition: ConditionsRootPersistency.cpp:152
dd4hep::cond::ConditionsRootPersistency::_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: ConditionsRootPersistency.cpp:192
dd4hep::cond::ConditionsManager
Manager class for condition handles.
Definition: ConditionsManager.h:46
dd4hep::cond::ConditionsRootPersistency::add
size_t add(const std::string &identifier, const IOV &iov, std::vector< Condition > &conditions)
Add conditions content to be saved. Note, that dependent conditions shall not be saved!
Definition: ConditionsRootPersistency.cpp:77
dd4hep::cond::UserPool
Interface for conditions pool optimized to host conditions updates.
Definition: ConditionsPool.h:134
key
unsigned char key
Definition: AlignmentsCalculator.cpp:69
dd4hep::cond::ConditionsRootPersistency::importConditionsPool
size_t importConditionsPool(const std::string &id, const std::string &iov_type, ConditionsManager mgr)
Load conditions pool and populate conditions manager.
dd4hep::cond::ConditionsRootPersistency::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::ConditionsRootPersistency
Helper to save conditions pools to ROOT.
Definition: ConditionsRootPersistency.h:51
dd4hep::cond::ConditionsRootPersistency::conditionPools
persistent_type conditionPools
Definition: ConditionsRootPersistency.h:58
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::cond::ConditionsRootPersistency::clear
void clear()
Clear object content and release allocated memory.
Definition: ConditionsRootPersistency.cpp:163
dd4hep::cond::ConditionsRootPersistency::IMPORT_ALL
@ IMPORT_ALL
Definition: ConditionsRootPersistency.h:63
ConditionsPool.h
dd4hep::cond::ConditionsRootPersistency::importIOVPool
size_t importIOVPool(const std::string &id, const std::string &iov_type, ConditionsManager mgr)
Load conditions IOV pool and populate conditions manager.
Definition: ConditionsRootPersistency.cpp:261
dd4hep::detail::tools::copy
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
Definition: AlignmentTools.cpp:43
dd4hep::cond::ConditionsRootPersistency::IMPORT_EDGE_UPPER
@ IMPORT_EDGE_UPPER
Definition: ConditionsRootPersistency.h:69
dd4hep::cond::ConditionsIOVPool
Pool of conditions satisfying one IOV type (epoch, run, fill, etc)
Definition: ConditionsIOVPool.h:38
dd4hep::cond::ConditionsRootPersistency::userPools
persistent_type userPools
Definition: ConditionsRootPersistency.h:59
dd4hep::cond::ConditionsRootPersistency::persistent_type
std::list< std::pair< iov_key_type, pool_type > > persistent_type
Definition: ConditionsRootPersistency.h:56
dd4hep::cond::ConditionsRootPersistency::ConditionsRootPersistency
ConditionsRootPersistency(const ConditionsRootPersistency &copy)=delete
No copy constructor.
dd4hep::cond::ConditionsRootPersistency::load
static std::unique_ptr< ConditionsRootPersistency > load(TFile *file, const std::string &object)
Load conditions content from file.
dd4hep::cond::ConditionsRootPersistency::pool_type
std::vector< Condition > pool_type
Definition: ConditionsRootPersistency.h:53
dd4hep::cond::ConditionsRootPersistency::~ConditionsRootPersistency
virtual ~ConditionsRootPersistency()
Default destructor.
Definition: ConditionsRootPersistency.cpp:72
dd4hep::cond::ConditionsRootPersistency::load
static std::unique_ptr< ConditionsRootPersistency > load(const std::string &file, const std::string &object)
Load conditions content from file.
Definition: ConditionsRootPersistency.h:113