File indexing completed on 2025-02-21 09:58:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef DDCOND_CONDITIONSROOTPERSISTENCY_H
0014 #define DDCOND_CONDITIONSROOTPERSISTENCY_H
0015
0016
0017 #include "DDCond/ConditionsPool.h"
0018
0019 #include "TNamed.h"
0020 class TFile;
0021
0022
0023 #include <map>
0024 #include <list>
0025 #include <vector>
0026 #include <memory>
0027
0028
0029
0030 namespace dd4hep {
0031
0032
0033 namespace cond {
0034
0035
0036 class ConditionsSlice;
0037 class ConditionsIOVPool;
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 class ConditionsRootPersistency : public TNamed {
0052 public:
0053 typedef std::vector<Condition> pool_type;
0054 typedef std::pair<std::string, pool_type> named_pool_type;
0055 typedef std::pair<std::string,std::pair<std::pair<std::string,int>,IOV::Key> > iov_key_type;
0056 typedef std::list<std::pair<iov_key_type, pool_type> > persistent_type;
0057
0058 persistent_type conditionPools {};
0059 persistent_type userPools {};
0060 persistent_type iovPools {};
0061 float duration = 0;
0062 enum ImportStrategy {
0063 IMPORT_ALL = 1<<0,
0064 IMPORT_EXACT = 1<<1,
0065 IMPORT_CONTAINED = 1<<2,
0066 IMPORT_CONTAINED_LOWER = 1<<3,
0067 IMPORT_CONTAINED_UPPER = 1<<4,
0068 IMPORT_EDGE_LOWER = 1<<5,
0069 IMPORT_EDGE_UPPER = 1<<6,
0070 LAST
0071 };
0072
0073 size_t _import(ImportStrategy strategy,
0074 persistent_type& pers,
0075 const std::string& id,
0076 const std::string& iov_type,
0077 const IOV::Key& iov_key,
0078 ConditionsManager mgr);
0079
0080
0081 void _clear(persistent_type& pool);
0082
0083 public:
0084
0085 ConditionsRootPersistency(const ConditionsRootPersistency& copy) = delete;
0086
0087 ConditionsRootPersistency(const std::string& name, const std::string& title="DD4hep conditions container");
0088
0089 ConditionsRootPersistency();
0090
0091 virtual ~ConditionsRootPersistency();
0092
0093 ConditionsRootPersistency& operator=(const ConditionsRootPersistency& copy) = delete;
0094
0095
0096 void clear();
0097
0098 static TFile* openFile(const std::string& fname);
0099
0100
0101 size_t add(const std::string& identifier, const IOV& iov, std::vector<Condition>& conditions);
0102
0103 size_t add(const std::string& identifier, ConditionsPool& pool);
0104
0105 size_t add(const std::string& identifier, const UserPool& pool);
0106
0107 size_t add(const std::string& identifier, const ConditionsIOVPool& pool);
0108
0109
0110 static std::unique_ptr<ConditionsRootPersistency> load(TFile* file,const std::string& object);
0111
0112
0113 static std::unique_ptr<ConditionsRootPersistency> load(const std::string& file,const std::string& object) {
0114 return load(openFile(file), object);
0115 }
0116
0117
0118 size_t importIOVPool(const std::string& id, const std::string& iov_type, ConditionsManager mgr);
0119
0120 size_t importUserPool(const std::string& id, const std::string& iov_type, ConditionsManager mgr);
0121
0122 size_t importConditionsPool(const std::string& id, const std::string& iov_type, ConditionsManager mgr);
0123
0124
0125 size_t importConditionsPool(ImportStrategy strategy,
0126 const std::string& id,
0127 const std::string& iov_type,
0128 const IOV::Key& key,
0129 ConditionsManager mgr);
0130
0131
0132 int save(TFile* file);
0133
0134 int save(const std::string& file_name);
0135
0136
0137 ClassDef(ConditionsRootPersistency,1);
0138 };
0139
0140 }
0141 }
0142 #endif