diff --git a/DDCond/CMakeLists.txt b/DDCond/CMakeLists.txt index ad62c1702eee7e104e5b23863225294f1d1a6a5e..1756569ac1b84d7db1bf0bfa0fb730caea10b400 100644 --- a/DDCond/CMakeLists.txt +++ b/DDCond/CMakeLists.txt @@ -13,8 +13,17 @@ dd4hep_package( DDCond INCLUDE_DIRS include INSTALL_INCLUDES include/DDCond) +#---Generate ROOT dictionary----------------------------------------------------- +dd4hep_add_dictionary( G__DDCond + SOURCES include/ROOT/Warnings.h + src/ConditionsDictionary.h + LINKDEF include/ROOT/LinkDef.h ) + #---DDCond library -------------------------------------------------------------- -dd4hep_add_package_library(DDCond SOURCES src/*.cpp ) +dd4hep_add_package_library(DDCond + SOURCES src/*.cpp + GENERATED G__DDCond.cxx + ) #---DDCond components ----------------------------------------------------------- dd4hep_add_plugin(DDCondPlugins SOURCES src/plugins/*.cpp src/Type1/*.cpp ) diff --git a/DDCond/include/DDCond/ConditionsIOVPool.h b/DDCond/include/DDCond/ConditionsIOVPool.h index 992bb70acaa0a366f4782adaf43576e201a168b8..46e03375863f230cf5e7502518dbc6b60c1bfc5b 100644 --- a/DDCond/include/DDCond/ConditionsIOVPool.h +++ b/DDCond/include/DDCond/ConditionsIOVPool.h @@ -37,12 +37,15 @@ namespace dd4hep { */ class ConditionsIOVPool { public: + /// Shortcut name for the actual container elements typedef std::shared_ptr<ConditionsPool> Element; + /// Shortcut name for the actual conditions container typedef std::map<IOV::Key, Element > Elements; /// Container of IOV dependent conditions pools - Elements elements; - const IOVType* type; + Elements elements; //! Not ROOT persistent + /// Reference to the IOV container + const IOVType* type; //! Not ROOT persistent public: /// Default constructor diff --git a/DDCond/include/DDCond/ConditionsPool.h b/DDCond/include/DDCond/ConditionsPool.h index adc52186ec3cb01d0958f6100f510223739fd4f6..e2d5854d796beac14dd0f3bd4775a23d4914eb04 100644 --- a/DDCond/include/DDCond/ConditionsPool.h +++ b/DDCond/include/DDCond/ConditionsPool.h @@ -10,8 +10,8 @@ // Author : M.Frank // //========================================================================== -#ifndef DDCOND_CONDITIONSPOOL_H -#define DDCOND_CONDITIONSPOOL_H +#ifndef DDCOND_CONDITIONS_CONDITIONSPOOL_H +#define DDCOND_CONDITIONS_CONDITIONSPOOL_H // Framework include files #include "DD4hep/NamedObject.h" @@ -217,6 +217,6 @@ namespace dd4hep { void* user_param, bool force) = 0; }; - } /* End namespace cond */ + } /* End namespace cond */ } /* End namespace dd4hep */ -#endif /* DDCOND_CONDITIONSPOOL_H */ +#endif /* DDCOND_CONDITIONS_CONDITIONSPOOL_H */ diff --git a/DDCond/include/DDCond/ConditionsRootPersistency.h b/DDCond/include/DDCond/ConditionsRootPersistency.h new file mode 100644 index 0000000000000000000000000000000000000000..00c1b13518a0cea53f2b0098b226220a6c25a67d --- /dev/null +++ b/DDCond/include/DDCond/ConditionsRootPersistency.h @@ -0,0 +1,114 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//========================================================================== +#ifndef DD4HEP_CONDITIONS_CONDITIONSROOTPERSISTENCY_H +#define DD4HEP_CONDITIONS_CONDITIONSROOTPERSISTENCY_H + +// Framework/ROOT include files +#include "DDCond/ConditionsPool.h" + +#include "TNamed.h" +class TFile; + +// C/C++ include files +#include <map> +#include <list> +#include <vector> +#include <memory> + + +/// Namespace for the AIDA detector description toolkit +namespace dd4hep { + + /// Namespace for implementation details of the AIDA detector description toolkit + namespace cond { + + /// Forward declarations + class ConditionsSlice; + class ConditionsIOVPool; + + /// Helper to save conditions pools to ROOT + /** + * \author M.Frank + * \version 1.0 + */ + class ConditionsRootPersistency : public TNamed { + public: + typedef std::vector<Condition> pool_type; + typedef std::pair<std::string, pool_type> named_pool_type; + typedef std::pair<std::string,std::pair<std::pair<std::string,int>,IOV::Key> > iov_key_type; + typedef std::list<std::pair<iov_key_type, pool_type> > persistent_type; + persistent_type conditionPools; + persistent_type userPools; + persistent_type iovPools; + float duration; + + /// Load ConditionsIOVPool and populate conditions manager + size_t _import(persistent_type& pers, + const std::string& id, + const std::string& iov_type, + ConditionsManager mgr); + + /// Clear object content and release allocated memory + void _clear(persistent_type& pool); + + public: + /// No copy constructor + ConditionsRootPersistency(const ConditionsRootPersistency& copy) = delete; + /// Initializing constructor + ConditionsRootPersistency(const std::string& name, const std::string& title="DD4hep conditions container"); + /// Default constructor + ConditionsRootPersistency(); + /// Default destructor + virtual ~ConditionsRootPersistency(); + /// No assignment + ConditionsRootPersistency& operator=(const ConditionsRootPersistency& copy) = delete; + + /// Clear object content and release allocated memory + void clear(); + /// Open ROOT file in read mode + static TFile* openFile(const std::string& fname); + + /// Add conditions content to the saved. Note, that dependent conditions shall not be saved! + size_t add(const std::string& identifier, ConditionsPool& pool); + /// Add conditions content to the saved. Note, that dependent conditions shall not be saved! + size_t add(const std::string& identifier, const UserPool& pool); + /// Add conditions content to the saved. Note, that dependent conditions shall not be saved! + size_t add(const std::string& identifier, const ConditionsIOVPool& pool); + + /// Load conditions content from file. + static std::unique_ptr<ConditionsRootPersistency> load(TFile* file,const std::string& object); + + /// Load conditions content from file. + static std::unique_ptr<ConditionsRootPersistency> load(const std::string& file,const std::string& object) { + return load(openFile(file), object); + } + + /// Load conditions IOV pool and populate conditions manager + size_t importIOVPool(const std::string& id,const std::string& iov_type,ConditionsManager mgr); + /// Load conditions user pool and populate conditions manager + size_t importUserPool(const std::string& id,const std::string& iov_type,ConditionsManager mgr); + /// Load conditions pool and populate conditions manager + size_t importConditionsPool(const std::string& id,const std::string& iov_type,ConditionsManager mgr); + + /// Save the data content to a root file + int save(TFile* file); + /// Save the data content to a root file + int save(const std::string& file_name); + + /// ROOT object ClassDef + ClassDef(ConditionsRootPersistency,1); + }; + + } /* End namespace cond */ +} /* End namespace dd4hep */ +#endif /* DD4HEP_CONDITIONS_CONDITIONSROOTPERSISTENCY_H */ diff --git a/DDCond/src/ConditionsDictionary.h b/DDCond/src/ConditionsDictionary.h new file mode 100644 index 0000000000000000000000000000000000000000..bbd000c2ea5fde725f5967febe8323576990271a --- /dev/null +++ b/DDCond/src/ConditionsDictionary.h @@ -0,0 +1,69 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//========================================================================== +#ifndef DD4HEP_CONDITIONS_CONDITIONSDICTIONARY_H +#define DD4HEP_CONDITIONS_CONDITIONSDICTIONARY_H + +// Framework include files +#include "DDCond/ConditionsPool.h" +#include "DDCond/ConditionsSlice.h" +#include "DDCond/ConditionsIOVPool.h" +#include "DDCond/ConditionsContent.h" +#include "DDCond/ConditionsManager.h" +#include "DDCond/ConditionsManagerObject.h" +#include "DDCond/ConditionsRootPersistency.h" + +// ------------------------------------------------------------------------- +// Regular dd4hep dictionaries +// ------------------------------------------------------------------------- +#if defined(__CINT__) || defined(__MAKECINT__) || defined(__CLING__) || defined(__ROOTCLING__) +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ namespace dd4hep; +#pragma link C++ namespace dd4hep::detail; +#pragma link C++ namespace dd4hep::cond; + +using namespace dd4hep; + +// These are necessary to support interactivity +#pragma link C++ class cond::UserPool-; +#pragma link C++ class cond::UpdatePool-; +#pragma link C++ class cond::ConditionsPool-; +#pragma link C++ class cond::ConditionsManager-; +#pragma link C++ class cond::ConditionsManagerObject-; +#pragma link C++ class cond::ConditionsIOVPool-; +#pragma link C++ class cond::ConditionsContent-; +#pragma link C++ class cond::ConditionsLoadInfo-; +#pragma link C++ class cond::ConditionsContent::LoadInfo<std::string>-; +#pragma link C++ class std::map<Condition::key_type,cond::ConditionsLoadInfo* >-; +#pragma link C++ class std::map<Condition::key_type,cond::ConditionDependency* >-; + +// std::shared_ptr<T> is not yet supported by ROOT! +//#pragma link C++ class std::shared_ptr<cond::ConditionsPool>-; +//#pragma link C++ class std::map<IOV::Key,std::shared_ptr<cond::ConditionsPool> >-; + +// This one we need to save conditions pool to file +#pragma link C++ class std::pair<std::string,IOV::Key>+; +#pragma link C++ class std::pair<std::pair<std::string,int>, IOV::Key>+; +#pragma link C++ class std::pair<std::string,std::pair<std::pair<std::string,int>,IOV::Key> >+; +#pragma link C++ class std::list<std::pair<std::pair<std::string,std::pair<std::pair<std::string,int>,IOV::Key> >, std::vector<Condition> >+; + +//#pragma link C++ class std::list<cond::ConditionsRootPersistency::Pool>+; +//#pragma link C++ class std::list<cond::ConditionsRootPersistency::IOVPool>+; + +#pragma link C++ class cond::ConditionsRootPersistency+; + +#endif + +#endif /* DD4HEP_CONDITIONS_CONDITIONSDICTIONARY_H */ diff --git a/DDCond/src/ConditionsRootPersistency.cpp b/DDCond/src/ConditionsRootPersistency.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9a281add82fe5955bf0d5255ddad49431769bd6c --- /dev/null +++ b/DDCond/src/ConditionsRootPersistency.cpp @@ -0,0 +1,255 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//========================================================================== + +// Framework include files +#include "DD4hep/Printout.h" +#include "DDCond/ConditionsSlice.h" +#include "DDCond/ConditionsIOVPool.h" +#include "DDCond/ConditionsRootPersistency.h" + +#include "TFile.h" +#include "TTimeStamp.h" + +typedef dd4hep::cond::ConditionsRootPersistency __ConditionsRootPersistency; +ClassImp(__ConditionsRootPersistency) + + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::cond; + +namespace { + /// Helper to select conditions + /* + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_CONDITIONS + */ + struct Scanner : public Condition::Processor { + ConditionsRootPersistency::pool_type& pool; + /// Constructor + Scanner(ConditionsRootPersistency::pool_type& p) : pool(p) {} + /// Conditions callback for object processing + virtual int process(Condition c) const override { + pool.push_back(c.ptr()); + return 1; + } + }; + struct DurationStamp { + TTimeStamp start; + ConditionsRootPersistency* object = 0; + DurationStamp(ConditionsRootPersistency* obj) : object(obj) { + } + ~DurationStamp() { + TTimeStamp stop; + object->duration = stop.AsDouble()-start.AsDouble(); + } + }; +} + +/// Default constructor +ConditionsRootPersistency::ConditionsRootPersistency() : TNamed() { +} + +/// Initializing constructor +ConditionsRootPersistency::ConditionsRootPersistency(const string& name, const string& title) + : TNamed(name.c_str(), title.c_str()) +{ +} + +/// Default destructor +ConditionsRootPersistency::~ConditionsRootPersistency() { + clear(); +} + +/// Add conditions content to the saved. Note, that dependent conditions shall not be saved! +size_t ConditionsRootPersistency::add(const string& identifier, ConditionsPool& pool) { + DurationStamp stamp(this); + conditionPools.push_back(pair<iov_key_type, pool_type>()); + pool_type& ent = conditionPools.back().second; + iov_key_type& key = conditionPools.back().first; + const IOV* iov = pool.iov; + key.first = identifier; + key.second.first = make_pair(iov->iovType->name,iov->type); + key.second.second = iov->key(); + pool.select_all(ent); + for(auto c : ent) c.ptr()->addRef(); + return ent.size(); +} + +/// Add conditions content to the saved. Note, that dependent conditions shall not be saved! +size_t ConditionsRootPersistency::add(const string& identifier, const ConditionsIOVPool& pool) { + size_t count = 0; + DurationStamp stamp(this); + for( const auto& p : pool.elements ) { + iovPools.push_back(pair<iov_key_type, pool_type>()); + pool_type& ent = iovPools.back().second; + iov_key_type& key = iovPools.back().first; + const IOV* iov = p.second->iov; + key.first = identifier; + key.second.first = make_pair(iov->iovType->name,iov->type); + key.second.second = p.first; + p.second->select_all(ent); + for(auto c : ent) c.ptr()->addRef(); + count += ent.size(); + } + return count; +} + +/// Add conditions content to the saved. Note, that dependent conditions shall not be saved! +size_t ConditionsRootPersistency::add(const string& identifier, const UserPool& pool) { + DurationStamp stamp(this); + userPools.push_back(pair<iov_key_type, pool_type>()); + pool_type& ent = userPools.back().second; + iov_key_type& key = userPools.back().first; + const IOV& iov = pool.validity(); + key.first = identifier; + key.second.first = make_pair(iov.iovType->name,iov.type); + key.second.second = iov.key(); + pool.scan(Scanner(ent)); + for(auto c : ent) c.ptr()->addRef(); + return ent.size(); +} + +/// Open ROOT file in read mode +TFile* ConditionsRootPersistency::openFile(const string& fname) { + TDirectory::TContext context; + TFile* file = TFile::Open(fname.c_str()); + if ( file && !file->IsZombie()) return file; + except("ConditionsRootPersistency","+++ FAILED to open ROOT file %s in read-mode.",fname.c_str()); + return 0; +} + +/// Clear object content and release allocated memory +void ConditionsRootPersistency::_clear(persistent_type& pool) { + /// Cleanup all the stuff not useful.... + for (auto& p : pool ) { + for(Condition c : p.second ) + c.ptr()->release(); + p.second.clear(); + } + pool.clear(); +} + +/// Clear object content and release allocated memory +void ConditionsRootPersistency::clear() { + /// Cleanup all the stuff not useful.... + _clear(conditionPools); + _clear(userPools); + _clear(iovPools); +} + +/// Add conditions content to the saved. Note, that dependent conditions shall not be saved! +std::unique_ptr<ConditionsRootPersistency> +ConditionsRootPersistency::load(TFile* file,const string& obj) { + std::unique_ptr<ConditionsRootPersistency> p; + if ( file && !file->IsZombie()) { + TTimeStamp start; + p.reset((ConditionsRootPersistency*)file->Get(obj.c_str())); + TTimeStamp stop; + if ( p.get() ) { + p->duration = stop.AsDouble()-start.AsDouble(); + return p; + } + except("ConditionsRootPersistency", + "+++ FAILED to load object %s from file %s", + obj.c_str(), file->GetName()); + } + except("ConditionsRootPersistency", + "+++ FAILED to load object %s from file [Invalid file]",obj.c_str()); + return p; +} + +/// Load ConditionsPool(s) and populate conditions manager +size_t ConditionsRootPersistency::_import(persistent_type& persistent_pools, + const std::string& id, + const std::string& iov_type, + ConditionsManager mgr) { + size_t count = 0; + std::pair<bool,const IOVType*> iovTyp(false,0); + for (auto& iovp : persistent_pools ) { + const iov_key_type& key = iovp.first; + if ( !(id.empty() || id=="*" || key.first == id) ) + continue; + if ( !(iov_type.empty() || iov_type == "*" || key.second.first.first == iov_type) ) + continue; + iovTyp = mgr.registerIOVType(key.second.first.second,key.second.first.first); + if ( iovTyp.second ) { + ConditionsPool* pool = mgr.registerIOV(*iovTyp.second, key.second.second); + for (Condition c : iovp.second) { + Condition::Object* o = c.ptr(); + o->iov = pool->iov; + if ( pool->insert(o->addRef()) ) { + //printout(WARNING,"ConditionsRootPersistency","%p: [%016llX] %s -> %s", + // o, o->hash,o->GetName(),o->data.str().c_str()); + ++count; + } + else { + printout(WARNING,"ConditionsRootPersistency", + "+++ Ignore condition %s from %s iov:%s [Already present]", + c.name(),id.c_str(), iov_type.c_str()); + } + } + } + } + return count; +} + +/// Load ConditionsIOVPool and populate conditions manager +size_t ConditionsRootPersistency::importIOVPool(const std::string& identifier, + const std::string& iov_type, + ConditionsManager mgr) +{ + DurationStamp stamp(this); + return _import(iovPools,identifier,iov_type,mgr); +} + +/// Load ConditionsIOVPool and populate conditions manager +size_t ConditionsRootPersistency::importUserPool(const std::string& identifier, + const std::string& iov_type, + ConditionsManager mgr) +{ + DurationStamp stamp(this); + return _import(userPools,identifier,iov_type,mgr); +} + +/// Load ConditionsIOVPool and populate conditions manager +size_t ConditionsRootPersistency::importConditionsPool(const std::string& identifier, + const std::string& iov_type, + ConditionsManager mgr) +{ + DurationStamp stamp(this); + return _import(conditionPools,identifier,iov_type,mgr); +} + +/// Save the data content to a root file +int ConditionsRootPersistency::save(TFile* file) { + DurationStamp stamp(this); + //TDirectory::TContext context; + int nBytes = file->WriteTObject(this,GetName()); + return nBytes; +} + +/// Save the data content to a root file +int ConditionsRootPersistency::save(const string& fname) { + DurationStamp stamp(this); + //TDirectory::TContext context; + TFile* file = TFile::Open(fname.c_str(),"RECREATE"); + if ( file && !file->IsZombie()) { + int nBytes = save(file); + file->Close(); + delete file; + return nBytes; + } + return -1; +} diff --git a/DDCond/src/plugins/ConditionsUserPool.cpp b/DDCond/src/plugins/ConditionsUserPool.cpp index d1dd05665d1ffbf2dde59c4f1fd88c0cc2e625e7..1acc6e17bb79c937570dd7cea9d69fcaf34fc7da 100644 --- a/DDCond/src/plugins/ConditionsUserPool.cpp +++ b/DDCond/src/plugins/ConditionsUserPool.cpp @@ -437,10 +437,10 @@ size_t ConditionsMappedUserPool<MAPPING>::compute(const Dependencies& deps, namespace { struct COMP { - typedef pair<Condition::key_type,const ConditionDependency*> Dep; - typedef pair<const Condition::key_type,detail::ConditionObject*> Cond; - typedef pair<const Condition::key_type,ConditionsLoadInfo* > Info; - typedef pair<const Condition::key_type,Condition> Cond2; + typedef pair<Condition::key_type,const ConditionDependency*> Dep; + typedef pair<const Condition::key_type,detail::ConditionObject*> Cond; + typedef pair<const Condition::key_type,ConditionsLoadInfo* > Info; + typedef pair<const Condition::key_type,Condition> Cond2; bool operator()(const Dep& a,const Cond& b) const { return a.first < b.first; } bool operator()(const Cond& a,const Dep& b) const { return a.first < b.first; } @@ -498,7 +498,12 @@ ConditionsMappedUserPool<MAPPING>::prepare(const IOV& required, printout(num_calc_miss==0 ? DEBUG : INFO,"UserPool", "Found %ld missing derived conditions out of %ld conditions.", num_calc_miss, slice_calc.size()); - +#if 0 + auto iter = begin(calc_missing); + for(auto i=0; i<num_calc_miss; ++i, ++iter) { + printout(INFO,""," Missing derived: %016llX -> %s",(*iter).first,(*iter).second->target.name.c_str()); + } +#endif result.loaded = 0; result.computed = 0; result.selected = m_conditions.size(); diff --git a/DDCore/CMakeLists.txt b/DDCore/CMakeLists.txt index c43a1dc689cb8a6f4314d06756e21d0d62c19551..dbd82c4699ddfc12527ca09873c20fba16fac468 100644 --- a/DDCore/CMakeLists.txt +++ b/DDCore/CMakeLists.txt @@ -23,6 +23,7 @@ dd4hep_add_dictionary( G__DD4hep include/DD4hep/detail/*.h include/XML/*.h src/DetectorImp.h + src/RootDictionary.h EXCLUDE include/DD4hep/DetFactoryHelper.h include/DD4hep/Factories.h include/DD4hep/Plugins.h @@ -34,11 +35,32 @@ dd4hep_add_dictionary( G__DD4hep include/XML/tinystring.h LINKDEF include/ROOT/LinkDef.h ) +#---Generate ROOT dictionary------------------------------------------------------ +dd4hep_add_dictionary( G__DD4hepGeo + SOURCES include/ROOT/Warnings.h + src/GeoDictionary.h + LINKDEF include/ROOT/LinkDef.h ) + +#---Generate ROOT dictionary------------------------------------------------------ +dd4hep_add_dictionary( G__DD4hepProperties + SOURCES include/ROOT/Warnings.h + src/PropertyDictionary.h + LINKDEF include/ROOT/LinkDef.h ) + +#---Generate ROOT dictionary------------------------------------------------------ +dd4hep_add_dictionary( G__DD4hepSegmentations + SOURCES include/ROOT/Warnings.h + src/SegmentationDictionary.h + LINKDEF include/ROOT/LinkDef.h ) + #---Generate DDCore Library------------------------------------------------------- dd4hep_add_package_library ( DDCore SOURCES src/*.cpp src/segmentations/*.cpp src/XML/*.cpp OPTIONAL [BOOST SOURCES src/JSON/*.cpp] - GENERATED G__DD4hep.cxx + GENERATED G__DD4hep.cxx + G__DD4hepProperties.cxx + G__DD4hepSegmentations.cxx + G__DD4hepGeo.cxx INCLUDE_DIRS ${GaudiPluginService_INCLUDE_DIRS} LINK_LIBRARIES DDParsers ${GaudiPluginService_LIBRARIES} ) diff --git a/DDCore/include/DD4hep/ComponentProperties.h b/DDCore/include/DD4hep/ComponentProperties.h index 50ea5cdb0d6b6ed4e09d0dc29faeac1d9bf67324..1d6587e5fa04959be07e3705c7f52ad867484e23 100644 --- a/DDCore/include/DD4hep/ComponentProperties.h +++ b/DDCore/include/DD4hep/ComponentProperties.h @@ -10,7 +10,6 @@ // Author : M.Frank // //========================================================================== - #ifndef DD4HEP_DDG4_COMPONENTPROPERTIES_H #define DD4HEP_DDG4_COMPONENTPROPERTIES_H @@ -36,7 +35,7 @@ namespace dd4hep { * * \author M.Frank * \version 1.0 - * \ingroup DD4HEP_SIMULATION + * \ingroup DD4HEP_CORE */ class PropertyConfigurator { protected: @@ -49,14 +48,16 @@ namespace dd4hep { /// Class describing the grammar representation of a given data type /** + * Note: This class cannot be saved to a ROOT file! + * * \author M.Frank * \version 1.0 - * \ingroup DD4HEP_SIMULATION + * \ingroup DD4HEP_CORE */ class PropertyGrammar { protected: friend class Property; - const BasicGrammar& m_grammar; + const BasicGrammar& m_grammar; //! This member is not ROOT persistent as the entire class is not. public: /// Default constructor PropertyGrammar(const BasicGrammar& g); @@ -82,9 +83,11 @@ namespace dd4hep { * between types, which are initially unrelated such as * e.g. vector<int> and list<short>. * + * Note: This class cannot be saved to a ROOT file! + * * \author M.Frank * \version 1.0 - * \ingroup DD4HEP_SIMULATION + * \ingroup DD4HEP_CORE */ class Property { protected: @@ -138,9 +141,11 @@ namespace dd4hep { /// Concrete template instantiation of a combined property value pair. /** + * Note: This class cannot be saved to a ROOT file! + * * \author M.Frank * \version 1.0 - * \ingroup DD4HEP_SIMULATION + * \ingroup DD4HEP_CORE */ template <class TYPE> class PropertyValue : private Property { public: @@ -170,9 +175,11 @@ namespace dd4hep { /// Manager to ease the handling of groups of properties. /** + * Note: This class cannot be saved to a ROOT file! + * * \author M.Frank * \version 1.0 - * \ingroup DD4HEP_SIMULATION + * \ingroup DD4HEP_CORE */ class PropertyManager { public: @@ -230,6 +237,8 @@ namespace dd4hep { /// Property object as base class for all objects supporting properties /** + * Note: This class cannot be saved to a ROOT file! + * * \author M.Frank * \version 1.0 */ diff --git a/DDCore/include/DD4hep/ConditionDerived.h b/DDCore/include/DD4hep/ConditionDerived.h index 980e9042294dbfd80297c1113703a7373ed046eb..0a73dd03ec792554c939e6d96e5502db24026ad8 100644 --- a/DDCore/include/DD4hep/ConditionDerived.h +++ b/DDCore/include/DD4hep/ConditionDerived.h @@ -71,6 +71,8 @@ namespace dd4hep { const ConditionDependency& d, void* parameter, IOV& iov); + /// Throw exception on conditions access failure + void accessFailure(const ConditionKey& key_value) const; /// Access to dependency keys const ConditionKey& key(size_t which) const; /// Access to condition object by dependency index @@ -90,7 +92,8 @@ namespace dd4hep { iov->iov_intersection(cond.iov()); return data; } - throw std::runtime_error("ConditionUpdateCall: Failed to access non-existing item:"+key_value.name); + accessFailure(key_value); + throw std::runtime_error("ConditionUpdateCall"); } /// Access of other conditions data from the resolver template<typename T> const T& get(const ConditionKey& key_value) const { @@ -101,7 +104,8 @@ namespace dd4hep { iov->iov_intersection(cond.iov()); return data; } - throw std::runtime_error("ConditionUpdateCall: Failed to access non-existing item:"+key_value.name); + accessFailure(key_value); + throw std::runtime_error("ConditionUpdateCall"); } /// Access of other conditions data from the resolver template<typename T> T& get(size_t key_id) { diff --git a/DDCore/include/DD4hep/Conditions.h b/DDCore/include/DD4hep/Conditions.h index 717ec5f7b07950ab72b38fa43a04c40c0f5afa36..ef1295a83720d1003da89d5658e3d6993a4de6ee 100644 --- a/DDCore/include/DD4hep/Conditions.h +++ b/DDCore/include/DD4hep/Conditions.h @@ -408,7 +408,6 @@ namespace dd4hep { // Utility type definitions typedef std::vector<Condition> RangeConditions; - typedef std::pair<RangeConditions,bool> RangeStatus; - + } /* End namespace dd4hep */ -#endif /* DD4HEP_DDCORE_CONDITIONS_H */ +#endif /* DD4HEP_DDCORE_CONDITIONS_H */ diff --git a/DDCore/include/DD4hep/detail/ConditionsInterna.h b/DDCore/include/DD4hep/detail/ConditionsInterna.h index b60184ef1988cd1907cfb421259b3e502a066948..2aebdf9083bbfc83546e01d0be91e10ff812a235 100644 --- a/DDCore/include/DD4hep/detail/ConditionsInterna.h +++ b/DDCore/include/DD4hep/detail/ConditionsInterna.h @@ -58,29 +58,33 @@ namespace dd4hep { class ConditionObject : public NamedObject { public: /// Condition value (in string form) - std::string value; + std::string value; /// Condition validity (in string form) - std::string validity; + std::string validity; /// Condition address - std::string address; + std::string address; /// Comment string - std::string comment; + std::string comment; /// Data block - OpaqueDataBlock data; + OpaqueDataBlock data; /// Interval of validity - const IOV* iov = 0; //! No ROOT persistency + const IOV* iov = 0; //! No ROOT persistency /// Hash value of the name Condition::key_type hash = 0; /// Flags Condition::mask_type flags = 0; /// Reference count - int refCount = 0; + int refCount = 1; /// Default constructor ConditionObject(); /// Standard constructor ConditionObject(const std::string& nam,const std::string& tit=""); /// Standard Destructor virtual ~ConditionObject(); + /// Increase reference counter (Used by persistency mechanism) + ConditionObject* addRef() { ++refCount; return this; } + /// Release object (Used by persistency mechanism) + void release(); /// Data offset from the opaque data block pointer to the condition static size_t offset(); /// Move data content: 'from' will be reset to NULL diff --git a/DDCore/include/ROOT/Warnings.h b/DDCore/include/ROOT/Warnings.h index a089de108dc8a7e05ca1d51db42e24f78739d7cb..6b09d0d721288ae0c51b559c499292589f0abde2 100644 --- a/DDCore/include/ROOT/Warnings.h +++ b/DDCore/include/ROOT/Warnings.h @@ -28,3 +28,12 @@ #pragma clang diagnostic ignored "-Wunused" #pragma clang diagnostic ignored "-Woverlength-strings" #endif + +#if defined(__CINT__) || defined(__MAKECINT__) || defined(__CLANG__) || defined(__ROOTCLING__) +#define DD4HEP_DICTIONARY_MODE 1 +#endif + +#if defined(G__DICTIONARY) && defined(G__ROOT) +#define DD4HEP_DICTIONARY_CODE 1 +#endif + diff --git a/DDCore/src/ConditionDerived.cpp b/DDCore/src/ConditionDerived.cpp index e662ae3baf428a9bb27d68345892c4ecbcb80e86..bea9c0d451c6b314b7d03694f9c35b8b837a5c09 100644 --- a/DDCore/src/ConditionDerived.cpp +++ b/DDCore/src/ConditionDerived.cpp @@ -35,6 +35,13 @@ ConditionUpdateCall::~ConditionUpdateCall() { ConditionResolver::~ConditionResolver() { } +/// Throw exception on conditions access failure +void ConditionUpdateContext::accessFailure(const ConditionKey& key_value) const { + except("ConditionUpdateCall", + "%s [%016llX]: FAILED to access non-existing item:%s [%016llX]", + dependency.target.name, dependency.target.hash, key_value.name, key_value.hash); +} + /// Initializing constructor ConditionDependency::ConditionDependency(DetElement de, unsigned int item_key, diff --git a/DDCore/src/ConditionsInterna.cpp b/DDCore/src/ConditionsInterna.cpp index d1e1730e56f6c63f4cdf952da8f60bf973e234d0..c760e8922f084a9c56cb2563ac998004f977df32 100644 --- a/DDCore/src/ConditionsInterna.cpp +++ b/DDCore/src/ConditionsInterna.cpp @@ -52,6 +52,11 @@ detail::ConditionObject::~ConditionObject() { InstanceCount::decrement(this); } +/// Release object (Used by persistency mechanism) +void detail::ConditionObject::release() { + if ( --refCount <= 0 ) delete this; +} + /// Data offset from the opaque data block pointer to the condition size_t detail::ConditionObject::offset() { static _P p((void*)0x1000); diff --git a/DDCore/src/GeoDictionary.h b/DDCore/src/GeoDictionary.h new file mode 100644 index 0000000000000000000000000000000000000000..aa3d3d8ff3c0e6a241b13806b40fe276c8ecc621 --- /dev/null +++ b/DDCore/src/GeoDictionary.h @@ -0,0 +1,126 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// RootDictionary.h +// +// +// M.Frank +// +//========================================================================== +#ifndef DD4HEP_DDCORE_ROOTDICTIONARY_H +#define DD4HEP_DDCORE_ROOTDICTIONARY_H + +// Framework include files +#include "DD4hep/Volumes.h" +#include "DD4hep/Shapes.h" + +// C/C++ include files +#include <vector> +#include <map> +#include <string> + +// ------------------------------------------------------------------------- +// Regular dd4hep dictionaries +// ------------------------------------------------------------------------- +#ifdef DD4HEP_DICTIONARY_MODE +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +using namespace std; + +#pragma link C++ namespace dd4hep; + +// Volume.h +#pragma link C++ class dd4hep::Volume+; +#pragma link C++ class dd4hep::VolumeExtension+; +#pragma link C++ class vector<dd4hep::Volume>+; +#pragma link C++ class dd4hep::Handle<TGeoVolume>+; + +#pragma link C++ class dd4hep::PlacedVolume+; +#ifndef __ROOTCLING__ +template vector<pair<string, int> >; +template vector<pair<string, int> >::iterator; +#endif +#pragma link C++ class vector<pair<string, int> >+; +#pragma link C++ class vector<pair<string, int> >::iterator; +#pragma link C++ class dd4hep::PlacedVolumeExtension::VolIDs+; +#pragma link C++ class dd4hep::PlacedVolumeExtension+; +#pragma link C++ class vector<dd4hep::PlacedVolume>+; +#pragma link C++ class dd4hep::Handle<TGeoNode>+; +#pragma link C++ class vector<TGeoNode*>+; +#pragma link C++ class vector<TGeoVolume*>+; + + +// Shapes.h +#pragma link C++ class dd4hep::Handle<TGeoShape>+; +#pragma link C++ class dd4hep::Solid_type<TGeoShape>+; + +#pragma link C++ class dd4hep::Polycone+; +#pragma link C++ class dd4hep::Solid_type<TGeoPcon>+; +#pragma link C++ class dd4hep::Handle<TGeoPcon>+; + +#pragma link C++ class dd4hep::ConeSegment+; +#pragma link C++ class dd4hep::Solid_type<TGeoConeSeg>+; +#pragma link C++ class dd4hep::Handle<TGeoConeSeg>+; + +#pragma link C++ class dd4hep::Box+; +#pragma link C++ class dd4hep::Solid_type<TGeoBBox>+; +#pragma link C++ class dd4hep::Handle<TGeoBBox>+; + +#pragma link C++ class dd4hep::Torus+; +#pragma link C++ class dd4hep::Solid_type<TGeoTorus>+; +#pragma link C++ class dd4hep::Handle<TGeoTorus>+; + +#pragma link C++ class dd4hep::Cone+; +#pragma link C++ class dd4hep::Solid_type<TGeoCone>+; +#pragma link C++ class dd4hep::Handle<TGeoCone>+; + +#pragma link C++ class dd4hep::Tube+; +#pragma link C++ class dd4hep::Solid_type<TGeoTubeSeg>+; +#pragma link C++ class dd4hep::Handle<TGeoTubeSeg>+; + +#pragma link C++ class dd4hep::EllipticalTube+; +#pragma link C++ class dd4hep::Solid_type<TGeoEltu>+; +#pragma link C++ class dd4hep::Handle<TGeoEltu>+; + +#pragma link C++ class dd4hep::Trap+; +#pragma link C++ class dd4hep::Solid_type<TGeoTrap>+; +#pragma link C++ class dd4hep::Handle<TGeoTrap>+; + +#pragma link C++ class dd4hep::Trapezoid+; +#pragma link C++ class dd4hep::Solid_type<TGeoTrd2>+; +#pragma link C++ class dd4hep::Handle<TGeoTrd2>+; + +#pragma link C++ class dd4hep::Sphere+; +#pragma link C++ class dd4hep::Solid_type<TGeoSphere>+; +#pragma link C++ class dd4hep::Handle<TGeoSphere>+; + +#pragma link C++ class dd4hep::Paraboloid+; +#pragma link C++ class dd4hep::Solid_type<TGeoParaboloid>+; +#pragma link C++ class dd4hep::Handle<TGeoParaboloid>+; + +#pragma link C++ class dd4hep::Hyperboloid+; +#pragma link C++ class dd4hep::Solid_type<TGeoHype>+; +#pragma link C++ class dd4hep::Handle<TGeoHype>+; + +#pragma link C++ class dd4hep::PolyhedraRegular+; +#pragma link C++ class dd4hep::Solid_type<TGeoPgon>+; +#pragma link C++ class dd4hep::Handle<TGeoPgon>+; + +#pragma link C++ class dd4hep::BooleanSolid+; +#pragma link C++ class dd4hep::Solid_type<TGeoCompositeShape>+; +#pragma link C++ class dd4hep::Handle<TGeoCompositeShape>+; + +#pragma link C++ class dd4hep::SubtractionSolid+; +#pragma link C++ class dd4hep::UnionSolid+; +#pragma link C++ class dd4hep::IntersectionSolid+; + +#endif // __CINT__ +#endif /* DD4HEP_DDCORE_ROOTDICTIONARY_H */ diff --git a/DDCore/src/PropertyDictionary.h b/DDCore/src/PropertyDictionary.h new file mode 100644 index 0000000000000000000000000000000000000000..8621a88a65bf1ceca97a64e573f9b0fabbac296c --- /dev/null +++ b/DDCore/src/PropertyDictionary.h @@ -0,0 +1,104 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// PropertyDictionary.h +// +// +// M.Frank +// +//========================================================================== +#ifndef DD4HEP_DDCORE_PROPERTYDICTIONARY_H +#define DD4HEP_DDCORE_PROPERTYDICTIONARY_H + +// Framework include files +#include "DD4hep/ComponentProperties.h" + +// C/C++ include files +#include <vector> +#include <map> +#include <string> + +#include "TRint.h" +namespace dd4hep { + namespace detail {} +} + +// ------------------------------------------------------------------------- +// Regular dd4hep dictionaries +// ------------------------------------------------------------------------- +#ifdef DD4HEP_DICTIONARY_MODE +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +using namespace std; + +#pragma link C++ class dd4hep::Property; +#if defined(DD4HEP_HAVE_ALL_PARSERS) +#pragma link C++ class dd4hep::PropertyValue<char>-; +#pragma link C++ class dd4hep::PropertyValue<unsigned char>-; +#pragma link C++ class dd4hep::PropertyValue<short>-; +#pragma link C++ class dd4hep::PropertyValue<unsigned short>-; +#pragma link C++ class dd4hep::PropertyValue<unsigned int>-; +#pragma link C++ class dd4hep::PropertyValue<long>-; +#pragma link C++ class dd4hep::PropertyValue<unsigned long>-; + +#pragma link C++ class dd4hep::PropertyValue<std::vector<char> >-; +#pragma link C++ class dd4hep::PropertyValue<std::vector<unsigned char> >-; +#pragma link C++ class dd4hep::PropertyValue<std::vector<short> >-; +#pragma link C++ class dd4hep::PropertyValue<std::vector<unsigned short> >-; +#pragma link C++ class dd4hep::PropertyValue<std::vector<unsigned int> >-; +#pragma link C++ class dd4hep::PropertyValue<std::vector<long> >-; +#pragma link C++ class dd4hep::PropertyValue<std::vector<unsigned long> >-; + +#pragma link C++ class dd4hep::PropertyValue<std::list<char> >-; +#pragma link C++ class dd4hep::PropertyValue<std::list<unsigned char> >-; +#pragma link C++ class dd4hep::PropertyValue<std::list<short> >-; +#pragma link C++ class dd4hep::PropertyValue<std::list<unsigned short> >-; +#pragma link C++ class dd4hep::PropertyValue<std::list<unsigned int> >-; +#pragma link C++ class dd4hep::PropertyValue<std::list<long> >-; +#pragma link C++ class dd4hep::PropertyValue<std::list<unsigned long> >-; + +#pragma link C++ class dd4hep::PropertyValue<std::set<char> >-; +#pragma link C++ class dd4hep::PropertyValue<std::set<unsigned char> >-; +#pragma link C++ class dd4hep::PropertyValue<std::set<short> >-; +#pragma link C++ class dd4hep::PropertyValue<std::set<unsigned short> >-; +#pragma link C++ class dd4hep::PropertyValue<std::set<unsigned int> >-; +#pragma link C++ class dd4hep::PropertyValue<std::set<long> >-; +#pragma link C++ class dd4hep::PropertyValue<std::set<unsigned long> >-; +#endif + +#pragma link C++ class dd4hep::PropertyValue<int>-; +#pragma link C++ class dd4hep::PropertyValue<float>-; +#pragma link C++ class dd4hep::PropertyValue<double>-; +#pragma link C++ class dd4hep::PropertyValue<std::string>-; + +#pragma link C++ class dd4hep::PropertyValue<std::vector<int> >-; +#pragma link C++ class dd4hep::PropertyValue<std::vector<float> >-; +#pragma link C++ class dd4hep::PropertyValue<std::vector<double> >-; +#pragma link C++ class dd4hep::PropertyValue<std::vector<std::string> >-; + +#pragma link C++ class dd4hep::PropertyValue<std::list<int> >-; +#pragma link C++ class dd4hep::PropertyValue<std::list<float> >-; +#pragma link C++ class dd4hep::PropertyValue<std::list<double> >-; +#pragma link C++ class dd4hep::PropertyValue<std::list<std::string> >-; + +#pragma link C++ class dd4hep::PropertyValue<std::set<int> >-; +#pragma link C++ class dd4hep::PropertyValue<std::set<float> >-; +#pragma link C++ class dd4hep::PropertyValue<std::set<double> >-; +#pragma link C++ class dd4hep::PropertyValue<std::set<std::string> >-; + +#pragma link C++ class std::map<std::string, dd4hep::Property>-; +#pragma link C++ class PropertyManager-; +#pragma link C++ class PropertyConfigurable-; +#pragma link C++ class dd4hep::PropertyConfigurator-; +#pragma link C++ class dd4hep::PropertyGrammar-; + +#endif // __CINT__ +#endif /* DD4HEP_DDCORE_PROPERTYDICTIONARY_H */ diff --git a/DDCore/include/DD4hep/Dictionary.h b/DDCore/src/RootDictionary.h similarity index 63% rename from DDCore/include/DD4hep/Dictionary.h rename to DDCore/src/RootDictionary.h index e53df5bc29d9be920a46e69b3bcc7d503b078e95..8009d57e0e926bb2fac34df263aa043166ad4666 100644 --- a/DDCore/include/DD4hep/Dictionary.h +++ b/DDCore/src/RootDictionary.h @@ -7,14 +7,14 @@ // For the licensing terms see $DD4hepINSTALL/LICENSE. // For the list of contributors see $DD4hepINSTALL/doc/CREDITS. // -// LinkDef.h +// RootDictionary.h // // -// Created by Pere Mato on 22/1/12. +// M.Frank // //========================================================================== -#ifndef DD4HEP_DDCORE_DICTIONARY_H -#define DD4HEP_DDCORE_DICTIONARY_H +#ifndef DD4HEP_DDCORE_ROOTDICTIONARY_H +#define DD4HEP_DDCORE_ROOTDICTIONARY_H // Framework include files #include "DDParsers/Evaluator.h" @@ -33,6 +33,7 @@ #include "DD4hep/Conditions.h" #include "DD4hep/Alignments.h" #include "DD4hep/FieldTypes.h" +#include "DD4hep/ComponentProperties.h" // C/C++ include files #include <vector> @@ -61,7 +62,7 @@ namespace dd4hep { namespace Parsers { // ------------------------------------------------------------------------- // Regular dd4hep dictionaries // ------------------------------------------------------------------------- -#if defined(__CINT__) || defined(__MAKECINT__) || defined(__CLING__) || defined(__ROOTCLING__) +#ifdef DD4HEP_DICTIONARY_MODE #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; @@ -263,93 +264,6 @@ template class dd4hep::Handle<TNamed>; #pragma link C++ class dd4hep::Handle<dd4hep::SensitiveDetectorObject>+; #pragma link C++ class vector<dd4hep::SensitiveDetector>+; -// Volume.h -#pragma link C++ class dd4hep::Volume+; -#pragma link C++ class dd4hep::VolumeExtension+; -#pragma link C++ class vector<dd4hep::Volume>+; -#pragma link C++ class dd4hep::Handle<TGeoVolume>+; - -#pragma link C++ class dd4hep::PlacedVolume+; -#ifndef __ROOTCLING__ -template vector<pair<string, int> >; -template vector<pair<string, int> >::iterator; -#endif -#pragma link C++ class vector<pair<string, int> >+; -#pragma link C++ class vector<pair<string, int> >::iterator; -#pragma link C++ class dd4hep::PlacedVolumeExtension::VolIDs+; -#pragma link C++ class dd4hep::PlacedVolumeExtension+; -#pragma link C++ class vector<dd4hep::PlacedVolume>+; -#pragma link C++ class dd4hep::Handle<TGeoNode>+; -#pragma link C++ class vector<TGeoNode*>+; -#pragma link C++ class vector<TGeoVolume*>+; - - -// Shapes.h -#pragma link C++ class dd4hep::Handle<TGeoShape>+; -#pragma link C++ class dd4hep::Solid_type<TGeoShape>+; - -#pragma link C++ class dd4hep::Polycone+; -#pragma link C++ class dd4hep::Solid_type<TGeoPcon>+; -#pragma link C++ class dd4hep::Handle<TGeoPcon>+; - -#pragma link C++ class dd4hep::ConeSegment+; -#pragma link C++ class dd4hep::Solid_type<TGeoConeSeg>+; -#pragma link C++ class dd4hep::Handle<TGeoConeSeg>+; - -#pragma link C++ class dd4hep::Box+; -#pragma link C++ class dd4hep::Solid_type<TGeoBBox>+; -#pragma link C++ class dd4hep::Handle<TGeoBBox>+; - -#pragma link C++ class dd4hep::Torus+; -#pragma link C++ class dd4hep::Solid_type<TGeoTorus>+; -#pragma link C++ class dd4hep::Handle<TGeoTorus>+; - -#pragma link C++ class dd4hep::Cone+; -#pragma link C++ class dd4hep::Solid_type<TGeoCone>+; -#pragma link C++ class dd4hep::Handle<TGeoCone>+; - -#pragma link C++ class dd4hep::Tube+; -#pragma link C++ class dd4hep::Solid_type<TGeoTubeSeg>+; -#pragma link C++ class dd4hep::Handle<TGeoTubeSeg>+; - -#pragma link C++ class dd4hep::EllipticalTube+; -#pragma link C++ class dd4hep::Solid_type<TGeoEltu>+; -#pragma link C++ class dd4hep::Handle<TGeoEltu>+; - -#pragma link C++ class dd4hep::Trap+; -#pragma link C++ class dd4hep::Solid_type<TGeoTrap>+; -#pragma link C++ class dd4hep::Handle<TGeoTrap>+; - -#pragma link C++ class dd4hep::Trapezoid+; -#pragma link C++ class dd4hep::Solid_type<TGeoTrd2>+; -#pragma link C++ class dd4hep::Handle<TGeoTrd2>+; - -#pragma link C++ class dd4hep::Sphere+; -#pragma link C++ class dd4hep::Solid_type<TGeoSphere>+; -#pragma link C++ class dd4hep::Handle<TGeoSphere>+; - -#pragma link C++ class dd4hep::Paraboloid+; -#pragma link C++ class dd4hep::Solid_type<TGeoParaboloid>+; -#pragma link C++ class dd4hep::Handle<TGeoParaboloid>+; - -#pragma link C++ class dd4hep::Hyperboloid+; -#pragma link C++ class dd4hep::Solid_type<TGeoHype>+; -#pragma link C++ class dd4hep::Handle<TGeoHype>+; - -#pragma link C++ class dd4hep::PolyhedraRegular+; -#pragma link C++ class dd4hep::Solid_type<TGeoPgon>+; -#pragma link C++ class dd4hep::Handle<TGeoPgon>+; - -#pragma link C++ class dd4hep::BooleanSolid+; -#pragma link C++ class dd4hep::Solid_type<TGeoCompositeShape>+; -#pragma link C++ class dd4hep::Handle<TGeoCompositeShape>+; - -#pragma link C++ class dd4hep::SubtractionSolid+; -#pragma link C++ class dd4hep::UnionSolid+; -#pragma link C++ class dd4hep::IntersectionSolid+; - - - #pragma link C++ class pair<string, string>+; #pragma link C++ class map<string, string>+; #pragma link C++ class map<string, string>::iterator; @@ -383,79 +297,4 @@ template vector<pair<string, int> >::iterator; #pragma link C++ class dd4hep::cond::AbstractMap::Params+; #endif // __CINT__ - - -// ------------------------------------------------------------------------- -// DDSegmentation dictionaries -#define __HAVE_DDSEGMENTATION__ -// ------------------------------------------------------------------------- -#ifdef __HAVE_DDSEGMENTATION__ -#include "DDSegmentation/Segmentation.h" -#include "DDSegmentation/NoSegmentation.h" -#include "DDSegmentation/CartesianGrid.h" -#include "DDSegmentation/CartesianGridXY.h" -#include "DDSegmentation/CartesianGridXYZ.h" -#include "DDSegmentation/CartesianGridXZ.h" -#include "DDSegmentation/CartesianGridYZ.h" -#include "DDSegmentation/CylindricalSegmentation.h" -#include "DDSegmentation/GridPhiEta.h" -#include "DDSegmentation/GridRPhiEta.h" -#include "DDSegmentation/MegatileLayerGridXY.h" -#include "DDSegmentation/MultiSegmentation.h" -#include "DDSegmentation/NoSegmentation.h" -#include "DDSegmentation/PolarGrid.h" -#include "DDSegmentation/PolarGridRPhi2.h" -#include "DDSegmentation/PolarGridRPhi.h" -#include "DDSegmentation/ProjectiveCylinder.h" - -#include "DDSegmentation/SegmentationParameter.h" -#include "DDSegmentation/TiledLayerGridXY.h" -#include "DDSegmentation/TiledLayerSegmentation.h" -#include "DDSegmentation/WaferGridXY.h" -typedef dd4hep::DDSegmentation::VolumeID VolumeID; -typedef dd4hep::DDSegmentation::CellID CellID; - -#if defined(__CINT__) || defined(__MAKECINT__) || defined(__CLANG__) || defined(__ROOTCLING__) -#pragma link C++ class dd4hep::DDSegmentation::SegmentationParameter+; -#pragma link C++ class dd4hep::DDSegmentation::TypedSegmentationParameter<int>+; - -#pragma link C++ class dd4hep::DDSegmentation::TypedSegmentationParameter<float>+; -#pragma link C++ class dd4hep::DDSegmentation::TypedSegmentationParameter<double>+; -#pragma link C++ class dd4hep::DDSegmentation::TypedSegmentationParameter<string>+; -#pragma link C++ class map<string,dd4hep::DDSegmentation::TypedSegmentationParameter<string>* >+; -#pragma link C++ class map<string,dd4hep::DDSegmentation::TypedSegmentationParameter<double>* >+; -#pragma link C++ class map<string,dd4hep::DDSegmentation::TypedSegmentationParameter<float>* >+; - -/// Severe problem due to template specialization! -#pragma link C++ class dd4hep::DDSegmentation::TypedSegmentationParameter<vector<int> >+; -#pragma link C++ class dd4hep::DDSegmentation::TypedSegmentationParameter<vector<float> >+; -#pragma link C++ class dd4hep::DDSegmentation::TypedSegmentationParameter<vector<double> >+; -#pragma link C++ class dd4hep::DDSegmentation::TypedSegmentationParameter<vector<string> >+; - -#pragma link C++ class dd4hep::DDSegmentation::Segmentation+; -#pragma link C++ class dd4hep::DDSegmentation::CartesianGrid+; -#pragma link C++ class dd4hep::DDSegmentation::CartesianGridXY+; -#pragma link C++ class dd4hep::DDSegmentation::CartesianGridXYZ+; -#pragma link C++ class dd4hep::DDSegmentation::CartesianGridXZ+; -#pragma link C++ class dd4hep::DDSegmentation::CartesianGridYZ+; -#pragma link C++ class dd4hep::DDSegmentation::CylindricalSegmentation+; -#pragma link C++ class dd4hep::DDSegmentation::GridPhiEta+; -#pragma link C++ class dd4hep::DDSegmentation::GridRPhiEta+; -#pragma link C++ class dd4hep::DDSegmentation::MegatileLayerGridXY+; -#pragma link C++ class dd4hep::DDSegmentation::MultiSegmentation+; -#pragma link C++ class dd4hep::DDSegmentation::NoSegmentation+; -#pragma link C++ class dd4hep::DDSegmentation::PolarGrid+; -#pragma link C++ class dd4hep::DDSegmentation::PolarGridRPhi2+; -#pragma link C++ class dd4hep::DDSegmentation::PolarGridRPhi+; -#pragma link C++ class dd4hep::DDSegmentation::ProjectiveCylinder+; -#pragma link C++ class dd4hep::DDSegmentation::TiledLayerGridXY+; -#pragma link C++ class dd4hep::DDSegmentation::TiledLayerSegmentation+; -#pragma link C++ class dd4hep::DDSegmentation::WaferGridXY+; - -#pragma link C++ class dd4hep::DDSegmentation::BitFieldValue+; -#pragma link C++ class dd4hep::DDSegmentation::BitField64+; - -#endif // __CINT__ -#endif // __HAVE_DDSEGMENTATION__ - -#endif /* DD4HEP_DDCORE_DICTIONARY_H */ +#endif /* DD4HEP_DDCORE_ROOTDICTIONARY_H */ diff --git a/DDCore/src/SegmentationDictionary.h b/DDCore/src/SegmentationDictionary.h new file mode 100644 index 0000000000000000000000000000000000000000..f7ba2cb898ed677d7ea728b68e3cc82a181ef03d --- /dev/null +++ b/DDCore/src/SegmentationDictionary.h @@ -0,0 +1,93 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// RootDictionary.h +// +// +// M.Frank +// +//========================================================================== +#ifndef DD4HEP_DDCORE_ROOTDICTIONARY_H +#define DD4HEP_DDCORE_ROOTDICTIONARY_H + +// Framework include files +#define __HAVE_DDSEGMENTATION__ +// ------------------------------------------------------------------------- +#ifdef __HAVE_DDSEGMENTATION__ +#include "DDSegmentation/Segmentation.h" +#include "DDSegmentation/NoSegmentation.h" +#include "DDSegmentation/CartesianGrid.h" +#include "DDSegmentation/CartesianGridXY.h" +#include "DDSegmentation/CartesianGridXYZ.h" +#include "DDSegmentation/CartesianGridXZ.h" +#include "DDSegmentation/CartesianGridYZ.h" +#include "DDSegmentation/CylindricalSegmentation.h" +#include "DDSegmentation/GridPhiEta.h" +#include "DDSegmentation/GridRPhiEta.h" +#include "DDSegmentation/MegatileLayerGridXY.h" +#include "DDSegmentation/MultiSegmentation.h" +#include "DDSegmentation/NoSegmentation.h" +#include "DDSegmentation/PolarGrid.h" +#include "DDSegmentation/PolarGridRPhi2.h" +#include "DDSegmentation/PolarGridRPhi.h" +#include "DDSegmentation/ProjectiveCylinder.h" + +#include "DDSegmentation/SegmentationParameter.h" +#include "DDSegmentation/TiledLayerGridXY.h" +#include "DDSegmentation/TiledLayerSegmentation.h" +#include "DDSegmentation/WaferGridXY.h" +typedef dd4hep::DDSegmentation::VolumeID VolumeID; +typedef dd4hep::DDSegmentation::CellID CellID; + +// ------------------------------------------------------------------------- +// DDSegmentation dictionaries +#ifdef DD4HEP_DICTIONARY_MODE +#pragma link C++ class dd4hep::DDSegmentation::SegmentationParameter+; +#pragma link C++ class dd4hep::DDSegmentation::TypedSegmentationParameter<int>+; + +#pragma link C++ class dd4hep::DDSegmentation::TypedSegmentationParameter<float>+; +#pragma link C++ class dd4hep::DDSegmentation::TypedSegmentationParameter<double>+; +#pragma link C++ class dd4hep::DDSegmentation::TypedSegmentationParameter<string>+; +#pragma link C++ class map<string,dd4hep::DDSegmentation::TypedSegmentationParameter<string>* >+; +#pragma link C++ class map<string,dd4hep::DDSegmentation::TypedSegmentationParameter<double>* >+; +#pragma link C++ class map<string,dd4hep::DDSegmentation::TypedSegmentationParameter<float>* >+; + +/// Severe problem due to template specialization! +#pragma link C++ class dd4hep::DDSegmentation::TypedSegmentationParameter<vector<int> >+; +#pragma link C++ class dd4hep::DDSegmentation::TypedSegmentationParameter<vector<float> >+; +#pragma link C++ class dd4hep::DDSegmentation::TypedSegmentationParameter<vector<double> >+; +#pragma link C++ class dd4hep::DDSegmentation::TypedSegmentationParameter<vector<string> >+; + +#pragma link C++ class dd4hep::DDSegmentation::Segmentation+; +#pragma link C++ class dd4hep::DDSegmentation::CartesianGrid+; +#pragma link C++ class dd4hep::DDSegmentation::CartesianGridXY+; +#pragma link C++ class dd4hep::DDSegmentation::CartesianGridXYZ+; +#pragma link C++ class dd4hep::DDSegmentation::CartesianGridXZ+; +#pragma link C++ class dd4hep::DDSegmentation::CartesianGridYZ+; +#pragma link C++ class dd4hep::DDSegmentation::CylindricalSegmentation+; +#pragma link C++ class dd4hep::DDSegmentation::GridPhiEta+; +#pragma link C++ class dd4hep::DDSegmentation::GridRPhiEta+; +#pragma link C++ class dd4hep::DDSegmentation::MegatileLayerGridXY+; +#pragma link C++ class dd4hep::DDSegmentation::MultiSegmentation+; +#pragma link C++ class dd4hep::DDSegmentation::NoSegmentation+; +#pragma link C++ class dd4hep::DDSegmentation::PolarGrid+; +#pragma link C++ class dd4hep::DDSegmentation::PolarGridRPhi2+; +#pragma link C++ class dd4hep::DDSegmentation::PolarGridRPhi+; +#pragma link C++ class dd4hep::DDSegmentation::ProjectiveCylinder+; +#pragma link C++ class dd4hep::DDSegmentation::TiledLayerGridXY+; +#pragma link C++ class dd4hep::DDSegmentation::TiledLayerSegmentation+; +#pragma link C++ class dd4hep::DDSegmentation::WaferGridXY+; + +#pragma link C++ class dd4hep::DDSegmentation::BitFieldValue+; +#pragma link C++ class dd4hep::DDSegmentation::BitField64+; + +#endif // __CINT__ +#endif // __HAVE_DDSEGMENTATION__ + +#endif /* DD4HEP_DDCORE_ROOTDICTIONARY_H */ diff --git a/examples/Conditions/CMakeLists.txt b/examples/Conditions/CMakeLists.txt index ee6cb58d743bc8396e27727a1bc4f5c77ebc0648..8a256ca380a176bd0f4ee990af2c254a8dc5458f 100644 --- a/examples/Conditions/CMakeLists.txt +++ b/examples/Conditions/CMakeLists.txt @@ -52,7 +52,7 @@ dd4hep_add_test_reg( Conditions_Telescope_populate COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_Conditions.sh" EXEC_ARGS geoPluginRun -volmgr -destroy -plugin DD4hep_ConditionExample_populate -input file:${DD4hep_DIR}/examples/AlignDet/compact/Telescope.xml -iovs 5 - REGEX_PASS "Accessed Total 800 conditions \\(S: 500,L: 0,C: 300,M:0\\)" + REGEX_PASS "Accessed a total of 800 conditions \\(S: 500,L: 0,C: 300,M:0\\)" REGEX_FAIL " ERROR ;EXCEPTION;Exception" ) # @@ -61,7 +61,7 @@ dd4hep_add_test_reg( Conditions_Telescope_stress COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_Conditions.sh" EXEC_ARGS geoPluginRun -volmgr -destroy -plugin DD4hep_ConditionExample_stress -input file:${DD4hep_DIR}/examples/AlignDet/compact/Telescope.xml -iovs 10 -runs 20 - REGEX_PASS "\\+ Accessed Total 3200 conditions \\(S: 2660,L: 0,C: 540,M:0\\)" + REGEX_PASS "\\+ Accessed a total of 3200 conditions \\(S: 2660,L: 0,C: 540,M:0\\)" REGEX_FAIL " ERROR ;EXCEPTION;Exception" ) # @@ -70,7 +70,7 @@ dd4hep_add_test_reg( Conditions_Telescope_stress2 COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_Conditions.sh" EXEC_ARGS geoPluginRun -volmgr -destroy -plugin DD4hep_ConditionExample_stress2 -input file:${DD4hep_DIR}/examples/AlignDet/compact/Telescope.xml -iovs 10 - REGEX_PASS "\\+ Accessed Total 1600 conditions \\(S: 1000,L: 0,C: 600,M:0\\)" + REGEX_PASS "\\+ Accessed a total of 1600 conditions \\(S: 1000,L: 0,C: 600,M:0\\)" REGEX_FAIL " ERROR ;EXCEPTION;Exception" ) # @@ -83,12 +83,32 @@ dd4hep_add_test_reg( Conditions_Telescope_MT_LONGTEST REGEX_FAIL " ERROR ;EXCEPTION;Exception" ) # +#---Testing: Save conditions to ROOT file +dd4hep_add_test_reg( Conditions_Telescope_root_save + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_Conditions.sh" + EXEC_ARGS geoPluginRun -print WARNING -volmgr -destroy -plugin DD4hep_ConditionExample_save + -input file:${DD4hep_DIR}/examples/AlignDet/compact/Telescope.xml -iovs 30 + -conditions TelescopeConditions.root + REGEX_PASS "\\+ Successfully saved 14400 condition to file." + REGEX_FAIL " ERROR ;EXCEPTION;Exception" + ) +# +#---Testing: Save conditions to ROOT file +dd4hep_add_test_reg( Conditions_Telescope_root_load + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_Conditions.sh" + EXEC_ARGS geoPluginRun -print WARNING -volmgr -destroy -plugin DD4hep_ConditionExample_load + -input file:${DD4hep_DIR}/examples/AlignDet/compact/Telescope.xml + -conditions TelescopeConditions.root + REGEX_PASS "\\+ Accessed a total of 1600 conditions \\(S: 1600,L: 0,C: 0,M:0\\)" + REGEX_FAIL " ERROR ;EXCEPTION;Exception" + ) +# #---Testing: Simple stress: Load CLICSiD geometry and have multiple runs on IOVs dd4hep_add_test_reg( Conditions_CLICSiD_stress_LONGTEST COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_Conditions.sh" EXEC_ARGS geoPluginRun -volmgr -destroy -plugin DD4hep_ConditionExample_stress -input file:${DD4hep_DIR}/examples/CLICSiD/compact/compact.xml -iovs 10 -runs 100 - REGEX_PASS "\\+ Accessed Total 28008800 conditions \\(S:26958470,L: 0,C:1050330,M:0\\)" + REGEX_PASS "\\+ Accessed a total of 28008800 conditions \\(S:26958470,L: 0,C:1050330,M:0\\)" REGEX_FAIL " ERROR ;EXCEPTION;Exception" ) # @@ -97,7 +117,7 @@ dd4hep_add_test_reg( Conditions_CLICSiD_stress2_LONGTEST COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_Conditions.sh" EXEC_ARGS geoPluginRun -volmgr -destroy -plugin DD4hep_ConditionExample_stress2 -input file:${DD4hep_DIR}/examples/CLICSiD/compact/compact.xml -iovs 20 - REGEX_PASS "\\+ Accessed Total 5601760 conditions \\(S:3501100,L: 0,C:2100660,M:0\\)" + REGEX_PASS "\\+ Accessed a total of 5601760 conditions \\(S:3501100,L: 0,C:2100660,M:0\\)" REGEX_FAIL " ERROR ;EXCEPTION;Exception" ) # @@ -109,3 +129,23 @@ dd4hep_add_test_reg( Conditions_CLICSiD_MT_LONGTEST REGEX_PASS "\\+ Accessed a total of 9522992 conditions \\(S:8892794,L: 0,C:630198,M:0\\)" REGEX_FAIL " ERROR ;EXCEPTION;Exception" ) +# +#---Testing: Save conditions to ROOT file +dd4hep_add_test_reg( Conditions_CLICSiD_root_save_LONGTEST + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_Conditions.sh" + EXEC_ARGS geoPluginRun -print WARNING -volmgr -destroy -plugin DD4hep_ConditionExample_save + -input file:${DD4hep_DIR}/examples/CLICSiD/compact/compact.xml -iovs 3 + -conditions CLICSiDConditions.root + REGEX_PASS "\\+ Successfully saved 2520792 condition to file." + REGEX_FAIL " ERROR ;EXCEPTION;Exception" + ) +# +#---Testing: Save conditions to ROOT file +dd4hep_add_test_reg( Conditions_CLICSiD_root_load_LONGTEST + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_Conditions.sh" + EXEC_ARGS geoPluginRun -print WARNING -volmgr -destroy -plugin DD4hep_ConditionExample_load + -input file:${DD4hep_DIR}/examples/CLICSiD/compact/compact.xml -iovs 3 + -conditions CLICSiDConditions.root + REGEX_PASS "\\+ Accessed a total of 840264 conditions \\(S:840264,L: 0,C: 0,M:0\\)" + REGEX_FAIL " ERROR ;EXCEPTION;Exception" + ) diff --git a/examples/Conditions/src/ConditionExampleObjects.cpp b/examples/Conditions/src/ConditionExampleObjects.cpp index 560f74e0b2165139b3399f5fed7c2e24560833a4..e140dd678c8ad3e9561e0a7936e5524919b248b4 100644 --- a/examples/Conditions/src/ConditionExampleObjects.cpp +++ b/examples/Conditions/src/ConditionExampleObjects.cpp @@ -110,12 +110,15 @@ ConditionsDependencyCreator::~ConditionsDependencyCreator() { /// Callback to process a single detector element int ConditionsDependencyCreator::operator()(DetElement de, int) const { ConditionKey key(de,"derived_data"); - ConditionKey target1(de,"derived_1"); - ConditionKey target2(de,"derived_2"); - ConditionKey target3(de,"derived_3"); + ConditionKey target1(de,"derived_data/derived_1"); + ConditionKey target2(de,"derived_data/derived_2"); + ConditionKey target3(de,"derived_data/derived_3"); DependencyBuilder build_1(de, target1.item_key(), call1->addRef()); DependencyBuilder build_2(de, target2.item_key(), call2->addRef()); DependencyBuilder build_3(de, target3.item_key(), call3->addRef()); + //DependencyBuilder build_1(de, "derived_data/derived_1", call1->addRef()); + //DependencyBuilder build_2(de, "derived_data/derived_2", call2->addRef()); + //DependencyBuilder build_3(de, "derived_data/derived_3", call3->addRef()); // Compute the derived stuff build_1.add(key); diff --git a/examples/Conditions/src/ConditionExample_load.cpp b/examples/Conditions/src/ConditionExample_load.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a333bc179ea3a3c1707f78a5d8ba4c3bc740b529 --- /dev/null +++ b/examples/Conditions/src/ConditionExample_load.cpp @@ -0,0 +1,121 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//========================================================================== +/* + Plugin invocation: + ================== + This plugin behaves like a main program. + Invoke the plugin with something like this: + + geoPluginRun -volmgr -destroy -plugin DD4hep_ConditionExample_load \ + -input file:${DD4hep_DIR}/examples/AlignDet/compact/Telescope.xml \ + -conditions Conditions.root + + Save the conditions store by hand for a set of IOVs. + Then compute the corresponding alignment entries.... + +*/ +// Framework include files +#include "ConditionExampleObjects.h" +#include "DDCond/ConditionsIOVPool.h" +#include "DDCond/ConditionsManager.h" +#include "DDCond/ConditionsRootPersistency.h" +#include "DD4hep/Factories.h" + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::ConditionExamples; + +/// Plugin function: Condition program example +/** + * Factory: DD4hep_ConditionExample_load + * + * \author M.Frank + * \version 1.0 + * \date 01/12/2016 + */ +static int condition_example (Detector& description, int argc, char** argv) { + string input, conditions; + int num_iov = 10; + bool arg_error = false; + for(int i=0; i<argc && argv[i]; ++i) { + if ( 0 == ::strncmp("-input",argv[i],4) ) + input = argv[++i]; + else if ( 0 == ::strncmp("-conditions",argv[i],4) ) + conditions = argv[++i]; + else if ( 0 == ::strncmp("-iovs",argv[i],4) ) + num_iov = ::atol(argv[++i]); + else + arg_error = true; + } + if ( arg_error || input.empty() || conditions.empty() ) { + /// Help printout describing the basic command line interface + cout << + "Usage: -plugin <name> -arg [-arg] \n" + " name: factory name DD4hep_ConditionExample_load \n" + " -input <string> Geometry file \n" + " -conditions <string> Conditions input file \n" + " -iovs <number> Number of parallel IOV slots for processing. \n" + "\tArguments given: " << arguments(argc,argv) << endl << flush; + ::exit(EINVAL); + } + + // First we load the geometry + description.fromXML(input); + + /******************** Initialize the conditions manager *****************/ + ConditionsManager manager = installManager(description); + shared_ptr<ConditionsContent> content(new ConditionsContent()); + shared_ptr<ConditionsSlice> slice(new ConditionsSlice(manager,content)); + Scanner(ConditionsKeys(*content,INFO),description.world()); + Scanner(ConditionsDependencyCreator(*content,DEBUG),description.world()); + + /******************** Load the conditions from file *********************/ + { + auto pers = cond::ConditionsRootPersistency::load(conditions.c_str(),"DD4hep Conditions"); + printout(ALWAYS,"Statistics","+========================================================================="); + printout(ALWAYS,"Statistics","+ Loaded conditions object from file %s. Took %8.3f seconds.", + conditions.c_str(),pers->duration); + size_t num_cond = pers->importIOVPool("ConditionsIOVPool No 1","run",manager); + printout(ALWAYS,"Statistics","+ Imported %ld conditions to IOV pool. Took %8.3f seconds.", + num_cond, pers->duration); + printout(ALWAYS,"Statistics","+========================================================================="); + } + // ++++++++++++++++++++++++ Now compute the conditions for each of these IOVs + const IOVType* iov_typ = manager.iovType("run"); + cond::ConditionsIOVPool* pool = manager.iovPool(*iov_typ); + for( const auto& p : pool->elements ) + p.second->print("*"); + + ConditionsManager::Result total; + for(int i=0; i<num_iov; ++i) { + IOV req_iov(iov_typ,i*10+5); + // Select the proper set of conditions and attach them to the user pool + ConditionsManager::Result r = manager.prepare(req_iov,*slice); + total += r; + if ( 0 == i ) { // First one we print... + Scanner(ConditionsPrinter(slice.get(),"Example"),description.world()); + } + // Now compute the tranformation matrices + printout(ALWAYS,"Prepare","Total %ld conditions (S:%ld,L:%ld,C:%ld,M:%ld) of IOV %s", + r.total(), r.selected, r.loaded, r.computed, r.missing, req_iov.str().c_str()); + } + printout(ALWAYS,"Statistics","+========================================================================="); + printout(ALWAYS,"Statistics","+ Accessed a total of %ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%ld)", + total.total(), total.selected, total.loaded, total.computed, total.missing); + printout(ALWAYS,"Statistics","+========================================================================="); + // All done. + return 1; +} + +// first argument is the type from the xml file +DECLARE_APPLY(DD4hep_ConditionExample_load,condition_example) diff --git a/examples/Conditions/src/ConditionExample_populate.cpp b/examples/Conditions/src/ConditionExample_populate.cpp index fa4fcf63c3ed714d39e549d0fe8c990daa72ae8b..b960ff7ab2aa6e3c65e0eca9c2e01526bd319d7f 100644 --- a/examples/Conditions/src/ConditionExample_populate.cpp +++ b/examples/Conditions/src/ConditionExample_populate.cpp @@ -102,7 +102,7 @@ static int condition_example (Detector& description, int argc, char** argv) { r.total(), r.selected, r.loaded, r.computed, r.missing, req_iov.str().c_str()); } printout(INFO,"Statistics","+========================================================================="); - printout(INFO,"Statistics","+ Accessed Total %ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%ld)", + printout(INFO,"Statistics","+ Accessed a total of %ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%ld)", total.total(), total.selected, total.loaded, total.computed, total.missing); printout(INFO,"Statistics","+========================================================================="); // All done. diff --git a/examples/Conditions/src/ConditionExample_save.cpp b/examples/Conditions/src/ConditionExample_save.cpp new file mode 100644 index 0000000000000000000000000000000000000000..996cea289b5ac6ec8f54c5c0ac83d720c3ebb3e7 --- /dev/null +++ b/examples/Conditions/src/ConditionExample_save.cpp @@ -0,0 +1,162 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//========================================================================== +/* + Plugin invocation: + ================== + This plugin behaves like a main program. + Invoke the plugin with something like this: + + geoPluginRun -volmgr -destroy -plugin DD4hep_ConditionExample_save \ + -input file:${DD4hep_DIR}/examples/AlignDet/compact/Telescope.xml \ + -conditions Conditions.root + + Save the conditions store by hand for a set of IOVs. + Then compute the corresponding alignment entries.... + +*/ +// Framework include files +#include "ConditionExampleObjects.h" +#include "DDCond/ConditionsManager.h" +#include "DDCond/ConditionsIOVPool.h" +#include "DDCond/ConditionsRootPersistency.h" +#include "DD4hep/Factories.h" + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::ConditionExamples; + +/// Plugin function: Condition program example +/** + * Factory: DD4hep_ConditionExample_save + * + * \author M.Frank + * \version 1.0 + * \date 01/12/2016 + */ +static int condition_example (Detector& description, int argc, char** argv) { + + string input, conditions; + int num_iov = 10; + bool arg_error = false; + for(int i=0; i<argc && argv[i]; ++i) { + if ( 0 == ::strncmp("-input",argv[i],4) ) + input = argv[++i]; + else if ( 0 == ::strncmp("-conditions",argv[i],4) ) + conditions = argv[++i]; + else if ( 0 == ::strncmp("-iovs",argv[i],4) ) + num_iov = ::atol(argv[++i]); + else + arg_error = true; + } + if ( arg_error || input.empty() || conditions.empty() ) { + /// Help printout describing the basic command line interface + cout << + "Usage: -plugin <name> -arg [-arg] \n" + " name: factory name DD4hep_ConditionExample_save \n" + " -input <string> Geometry file \n" + " -conditions <string> Conditions output file \n" + " -iovs <number> Number of parallel IOV slots for processing. \n" + "\tArguments given: " << arguments(argc,argv) << endl << flush; + ::exit(EINVAL); + } + + // First we load the geometry + description.fromXML(input); + + /******************** Initialize the conditions manager *****************/ + ConditionsManager manager = installManager(description); + const IOVType* iov_typ = manager.registerIOVType(0,"run").second; + if ( 0 == iov_typ ) + except("ConditionsPrepare","++ Unknown IOV type supplied."); + + /******************** Now as usual: create the slice ********************/ + shared_ptr<ConditionsContent> content(new ConditionsContent()); + shared_ptr<ConditionsSlice> slice(new ConditionsSlice(manager,content)); + Scanner(ConditionsKeys(*content,INFO),description.world()); + Scanner(ConditionsDependencyCreator(*content,DEBUG),description.world()); + + /******************** Save the conditions store *********************/ + // Have 10 run-slices [11,20] .... [91,100] + for(int i=0; i<num_iov; ++i) { + IOV iov(iov_typ, IOV::Key(1+i*10,(i+1)*10)); + ConditionsPool* iov_pool = manager.registerIOV(*iov.iovType, iov.key()); + // Create conditions with all deltas. Use a generic creator + Scanner(ConditionsCreator(*slice, *iov_pool, INFO),description.world(),0,true); + } + + char text[132]; + bool output_iovpool = true; + bool output_userpool = true; + bool output_condpool = true; + size_t count = 0, total_count = 0; + auto* persist = new cond::ConditionsRootPersistency("DD4hep Conditions"); + // ++++++++++++++++++++++++ Now compute the conditions for each of these IOVs + ConditionsManager::Result total; + for(int i=0; i<num_iov; ++i) { + IOV req_iov(iov_typ,i*10+5); + // Select the proper set of conditions and attach them to the user pool + ConditionsManager::Result r = manager.prepare(req_iov,*slice); + total += r; + if ( 0 == i ) { // First one we print... + Scanner(ConditionsPrinter(slice.get(),"Example"),description.world()); + } + // Now compute the tranformation matrices + printout(ALWAYS,"Prepare","Total %ld conditions (S:%ld,L:%ld,C:%ld,M:%ld) of IOV %s", + r.total(), r.selected, r.loaded, r.computed, r.missing, req_iov.str().c_str()); + if ( output_userpool ) { + /// Add the conditions UserPool to the persistent file + ::snprintf(text,sizeof(text),"User pool %s:[%ld]",iov_typ->name.c_str(),req_iov.key().first); + count = persist->add(text,*slice->pool); + total_count += count; + printout(ALWAYS,"Example","+++ Added %ld conditions to persistent user pool.",count); + } + } + if ( output_condpool ) { + cond::ConditionsIOVPool* iov_pool = manager.iovPool(*iov_typ); + for( const auto& p : iov_pool->elements ) { + ::snprintf(text,sizeof(text),"Conditions pool %s:[%ld,%ld]", + iov_typ->name.c_str(),p.second->iov->key().first,p.second->iov->key().second); + count = persist->add(text,*p.second); + total_count += count; + printout(ALWAYS,"Example","+++ Added %ld conditions to persistent conditions pool.",count); + } + } + if ( output_iovpool ) { + count = persist->add("ConditionsIOVPool No 1",*manager.iovPool(*iov_typ)); + total_count += count; + printout(ALWAYS,"Example","+++ Added %ld conditions to persistent IOV pool.",count); + //count = persist->add("ConditionsIOVPool No 2",*manager.iovPool(*iov_typ)); + //total_count += count; + printout(ALWAYS,"Example","+++ Added %ld conditions to persistent IOV pool.",count); + } + int nBytes = persist->save(conditions.c_str()); + printout(ALWAYS,"Example", + "+++ Wrote %d Bytes (%ld conditions) of data to '%s' [%8.3f seconds].", + nBytes, total_count, conditions.c_str(), persist->duration); + if ( nBytes > 0 ) { + printout(ALWAYS,"Example", + "+++ Successfully saved %ld condition to file.",total_count); + } + delete persist; + + printout(ALWAYS,"Statistics","+========================================================================="); + printout(ALWAYS,"Statistics","+ Accessed a total of %ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%ld)", + total.total(), total.selected, total.loaded, total.computed, total.missing); + printout(ALWAYS,"Statistics","+========================================================================="); + + // All done. + return 1; +} + +// first argument is the type from the xml file +DECLARE_APPLY(DD4hep_ConditionExample_save,condition_example) diff --git a/examples/Conditions/src/ConditionExample_stress.cpp b/examples/Conditions/src/ConditionExample_stress.cpp index c70242107a46c363f002cb376b421a2831803c32..26cc3061e42365d3b93d8560feb3ef8ac48f95fc 100644 --- a/examples/Conditions/src/ConditionExample_stress.cpp +++ b/examples/Conditions/src/ConditionExample_stress.cpp @@ -123,7 +123,7 @@ static int condition_example (Detector& description, int argc, char** argv) { cr_stat.GetName(), cr_stat.GetMean(), cr_stat.GetMeanErr(), cr_stat.GetRMS(), cr_stat.GetN()); printout(INFO,"Statistics","+ %-12s: %11.5g +- %11.4g RMS = %11.5g N = %lld", acc_stat.GetName(), acc_stat.GetMean(), acc_stat.GetMeanErr(), acc_stat.GetRMS(), acc_stat.GetN()); - printout(INFO,"Statistics","+ Accessed Total %ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%ld). Created:%ld", + printout(INFO,"Statistics","+ Accessed a total of %ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%ld). Created:%ld", total.total(), total.selected, total.loaded, total.computed, total.missing, total_created); printout(INFO,"Statistics","+========================================================================="); // All done. diff --git a/examples/Conditions/src/ConditionExample_stress2.cpp b/examples/Conditions/src/ConditionExample_stress2.cpp index b9f07658a7c7b36c10de8cdaf4e9a6578bfbee6e..f7daade3812536b65cc3faaedaa1dbf9f0811694 100644 --- a/examples/Conditions/src/ConditionExample_stress2.cpp +++ b/examples/Conditions/src/ConditionExample_stress2.cpp @@ -114,7 +114,7 @@ static int condition_example (Detector& description, int argc, char** argv) { cr_stat.GetName(), cr_stat.GetMean(), cr_stat.GetMeanErr(), cr_stat.GetRMS(), cr_stat.GetN()); printout(INFO,"Statistics","+ %-12s: %11.5g +- %11.4g RMS = %11.5g N = %lld", acc_stat.GetName(), acc_stat.GetMean(), acc_stat.GetMeanErr(), acc_stat.GetRMS(), acc_stat.GetN()); - printout(INFO,"Statistics","+ Accessed Total %ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%ld)", + printout(INFO,"Statistics","+ Accessed a total of %ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%ld)", total.total(), total.selected, total.loaded, total.computed, total.missing, total_created); printout(INFO,"Statistics","+========================================================================="); // All done.