|
DD4hep
1.30.0
Detector Description Toolkit for High Energy Physics
|
Go to the documentation of this file.
21 #include <TTimeStamp.h>
44 pool.emplace_back(c.
ptr());
48 struct DurationStamp {
55 object->duration = stop.AsDouble()-start.AsDouble();
66 :
TNamed(name.c_str(), title.c_str())
78 std::vector<Condition>& conditions)
80 DurationStamp stamp(
this);
84 key.first = identifier;
86 key.second.second = iov.
key();
88 for(
auto c : ent) c->addRef();
94 DurationStamp stamp(
this);
99 key.first = identifier;
101 key.second.second = iov->
key();
103 for(
auto c : ent) c.ptr()->addRef();
109 std::size_t count = 0;
110 DurationStamp stamp(
this);
111 for(
const auto& p : pool.
elements ) {
112 iovPools.emplace_back(std::pair<iov_key_type, pool_type>());
115 const IOV* iov = p.second->iov;
116 key.first = identifier;
117 key.second.first = make_pair(iov->iovType->name,iov->type);
118 key.second.second = p.first;
119 p.second->select_all(ent);
120 for(
auto c : ent) c.ptr()->addRef();
128 TDirectory::TContext context;
129 TFile* file = TFile::Open(fname.c_str());
130 if ( file && !file->IsZombie())
return file;
131 except(
"ConditionsTreePersistency",
"+++ FAILED to open ROOT file %s in read-mode.",fname.c_str());
138 for (
auto& p : pool ) {
154 std::unique_ptr<ConditionsTreePersistency>
156 std::unique_ptr<ConditionsTreePersistency> p;
157 if ( file && !file->IsZombie()) {
162 p->duration = stop.AsDouble()-start.AsDouble();
165 except(
"ConditionsTreePersistency",
166 "+++ FAILED to load object %s from file %s",
167 obj.c_str(), file->GetName());
169 except(
"ConditionsTreePersistency",
170 "+++ FAILED to load object %s from file [Invalid file]",obj.c_str());
177 const std::string&
id,
178 const std::string& iov_type,
182 std::size_t count = 0;
183 std::pair<bool,const IOVType*> iovTyp(
false,0);
184 for (
auto& iovp : persistent_pools ) {
187 if ( !(
id.empty() ||
id==
"*" ||
key.first ==
id) )
189 if ( !(iov_type.empty() || iov_type ==
"*" ||
key.second.first.first == iov_type) )
196 use =
key.second.second == iov_key;
223 if ( iovTyp.second ) {
234 printout(WARNING,
"ConditionsTreePersistency",
235 "+++ Ignore condition %s from %s iov:%s [Already present]",
236 c.
name(),
id.c_str(), iov_type.c_str());
246 const std::string& iov_type,
249 DurationStamp stamp(
this);
255 const std::string& iov_type,
258 DurationStamp stamp(
this);
264 const std::string& identifier,
265 const std::string& iov_type,
273 DurationStamp stamp(
this);
275 int nBytes = file->WriteTObject(
this,
GetName());
281 DurationStamp stamp(
this);
283 TFile* file = TFile::Open(fname.c_str(),
"RECREATE");
284 if ( file && !file->IsZombie()) {
285 int nBytes =
save(file);
ConditionsPool * registerIOV(const IOV &iov) const
Register IOV with type and key.
static TFile * openFile(const std::string &fname)
Open ROOT file in read mode.
std::string name
String name.
persistent_type conditionPools
ConditionsTreePersistency::pool_type & pool
void _clear(persistent_type &pool)
Clear object content and release allocated memory.
dd4hep::cond::ConditionsTreePersistency __ConditionsTreePersistency
size_t importConditionsPool(const std::string &id, const std::string &iov_type, ConditionsManager mgr)
Load conditions pool and populate conditions manager.
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.
void clear()
Clear object content and release allocated memory.
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)
const char * name() const
Access the object name (or "" if not supported by the object)
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!
int save(TFile *file)
Save the data content to a root file.
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.
static std::unique_ptr< ConditionsTreePersistency > load(TFile *file, const std::string &object)
Load conditions content from file.
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)
std::list< std::pair< iov_key_type, pool_type > > persistent_type
static bool key_is_contained(const Key &key, const Key &test)
Check if IOV 'test' is fully contained in IOV 'key'.
Scanner(ConditionsTreePersistency::pool_type &p)
Constructor.
Key key() const
Get the local key of the IOV.
Helper to save conditions pools to ROOT.
The data class behind a conditions handle.
std::vector< Condition > pool_type
Manager class for condition handles.
unsigned int type
IOV buffer type: Must be a bitmap!
virtual ~ConditionsTreePersistency()
Default destructor.
T * ptr() const
Access to the held object.
const IOVType * iovType
Reference to IOV type.
ClassImp(DD4hepRootPersistency) using namespace dd4hep
DurationStamp(ConditionsTreePersistency *obj)
std::pair< std::string, std::pair< std::pair< std::string, int >, IOV::Key > > iov_key_type
const IOV * iov
Interval of validity.
Pool of conditions satisfying one IOV type (epoch, run, fill, etc)
ConditionsTreePersistency()
Default constructor.
Abstract base for processing callbacks to conditions objects.
size_t importIOVPool(const std::string &id, const std::string &iov_type, ConditionsManager mgr)
Load conditions IOV pool and populate conditions manager.