|
DD4hep
1.30.0
Detector Description Toolkit for High Energy Physics
|
Go to the documentation of this file.
21 #include <TTimeStamp.h>
45 pool.emplace_back(c.
ptr());
56 object->duration = stop.AsDouble()-start.AsDouble();
67 :
TNamed(name.c_str(), title.c_str())
79 std::vector<Condition>& conditions)
81 DurationStamp stamp(
this);
85 key.first = identifier;
87 key.second.second = iov.
key();
89 for(
auto c : ent) c.ptr()->addRef();
95 DurationStamp stamp(
this);
100 key.first = identifier;
102 key.second.second = iov->
key();
104 for(
auto c : ent) c.ptr()->addRef();
111 DurationStamp stamp(
this);
112 for(
const auto& p : pool.
elements ) {
113 iovPools.emplace_back(std::pair<iov_key_type, pool_type>());
116 const IOV* iov = p.second->iov;
117 key.first = identifier;
119 key.second.second = p.first;
120 p.second->select_all(ent);
121 for(
auto c : ent) c.ptr()->addRef();
129 DurationStamp stamp(
this);
130 userPools.emplace_back(std::pair<iov_key_type, pool_type>());
134 key.first = identifier;
136 key.second.second = iov.
key();
137 pool.
scan(Scanner(ent));
138 for(
auto c : ent) c.ptr()->addRef();
144 TDirectory::TContext context;
145 TFile* file = TFile::Open(fname.c_str());
146 if ( file && !file->IsZombie())
return file;
147 except(
"ConditionsRootPersistency",
"+++ FAILED to open ROOT file %s in read-mode.",fname.c_str());
154 for (
auto& p : pool ) {
171 std::unique_ptr<ConditionsRootPersistency>
173 std::unique_ptr<ConditionsRootPersistency> p;
174 if ( file && !file->IsZombie()) {
179 p->duration = stop.AsDouble()-start.AsDouble();
182 except(
"ConditionsRootPersistency",
183 "+++ FAILED to load object %s from file %s",
184 obj.c_str(), file->GetName());
186 except(
"ConditionsRootPersistency",
187 "+++ FAILED to load object %s from file [Invalid file]",obj.c_str());
194 const std::string&
id,
195 const std::string& iov_type,
199 std::pair<bool,const IOVType*> iovTyp(
false,0);
200 for (
auto& iovp : persistent_pools ) {
203 if ( !(
id.empty() ||
id==
"*" ||
key.first ==
id) )
205 if ( !(iov_type.empty() || iov_type ==
"*" ||
key.second.first.first == iov_type) )
212 use =
key.second.second == iov_key;
239 if ( iovTyp.second ) {
250 printout(WARNING,
"ConditionsRootPersistency",
251 "+++ Ignore condition %s from %s iov:%s [Already present]",
252 c.
name(),
id.c_str(), iov_type.c_str());
262 const std::string& iov_type,
265 DurationStamp stamp(
this);
271 const std::string& iov_type,
274 DurationStamp stamp(
this);
280 const std::string& iov_type,
283 DurationStamp stamp(
this);
289 const std::string& identifier,
290 const std::string& iov_type,
298 DurationStamp stamp(
this);
300 int nBytes = file->WriteTObject(
this,
GetName());
306 DurationStamp stamp(
this);
308 TFile* file = TFile::Open(fname.c_str(),
"RECREATE");
309 if ( file && !file->IsZombie()) {
310 int nBytes =
save(file);
DurationStamp(ConditionsRootPersistency *obj)
ConditionsPool * registerIOV(const IOV &iov) const
Register IOV with type and key.
std::string name
String name.
ConditionsRootPersistency::pool_type & pool
Helper to select conditions.
int save(TFile *file)
Save the data content to a root file.
virtual bool insert(Condition cond)=0
Register a new condition to this pool.
virtual int process(dd4hep::Condition c) const override
Conditions callback for object processing.
std::pair< Key_value_type, Key_value_type > Key
Elements elements
Container of IOV dependent conditions pools.
ConditionObject * addRef()
Increase reference counter (Used by persistency mechanism)
static TFile * openFile(const std::string &fname)
Open ROOT file in read mode.
const char * name() const
Access the object name (or "" if not supported by the object)
const IOV & validity() const
Access the interval of validity for this user pool.
virtual size_t select_all(RangeConditions &result)=0
Select all conditions contained.
Main condition object handle.
std::pair< bool, const IOVType * > registerIOVType(size_t iov_type, const std::string &iov_name) const
Register new IOV type if it does not (yet) exist.
Namespace for implementation details of the AIDA detector description toolkit.
Class describing the interval of validty.
size_t importUserPool(const std::string &id, const std::string &iov_type, ConditionsManager mgr)
Load conditions user pool and populate conditions manager.
std::pair< std::string, std::pair< std::pair< std::string, int >, IOV::Key > > iov_key_type
ConditionsRootPersistency()
Default constructor.
const char * GetName(T *p)
Class implementing the conditions collection for a given IOV type.
static bool key_overlaps_lower_end(const Key &key, const Key &test)
Check if IOV 'test' has an overlap on the lower interval edge with IOV 'key'.
Class of the ROOT toolkit. See http://root.cern.ch/root/htmldoc/ClassIndex.html.
IOV * iov
The IOV of the conditions hosted.
static bool key_overlaps_higher_end(const Key &key, const Key &test)
Check if IOV 'test' has an overlap on the upper interval edge with IOV 'key'.
void release()
Release object (Used by persistency mechanism)
void _clear(persistent_type &pool)
Clear object content and release allocated memory.
Scanner(ConditionsRootPersistency::pool_type &p)
Constructor.
static bool key_is_contained(const Key &key, const Key &test)
Check if IOV 'test' is fully contained in IOV 'key'.
Key key() const
Get the local key of the IOV.
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.
The data class behind a conditions handle.
Manager class for condition handles.
dd4hep::cond::ConditionsRootPersistency __ConditionsRootPersistency
unsigned int type
IOV buffer type: Must be a bitmap!
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!
Interface for conditions pool optimized to host conditions updates.
virtual void scan(const Condition::Processor &processor) const =0
ConditionsMap overload: Interface to scan data content of the conditions mapping.
size_t importConditionsPool(const std::string &id, const std::string &iov_type, ConditionsManager mgr)
Load conditions pool and populate conditions manager.
Helper to save conditions pools to ROOT.
T * ptr() const
Access to the held object.
persistent_type conditionPools
const IOVType * iovType
Reference to IOV type.
void clear()
Clear object content and release allocated memory.
ClassImp(DD4hepRootPersistency) using namespace dd4hep
size_t importIOVPool(const std::string &id, const std::string &iov_type, ConditionsManager mgr)
Load conditions IOV pool and populate conditions manager.
const IOV * iov
Interval of validity.
Pool of conditions satisfying one IOV type (epoch, run, fill, etc)
persistent_type userPools
std::list< std::pair< iov_key_type, pool_type > > persistent_type
Abstract base for processing callbacks to conditions objects.
static std::unique_ptr< ConditionsRootPersistency > load(TFile *file, const std::string &object)
Load conditions content from file.
std::vector< Condition > pool_type
virtual ~ConditionsRootPersistency()
Default destructor.