DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
ConditionsSnapshotRootLoader.cpp
Go to the documentation of this file.
1 // AIDA Detector description implementation
2 //--------------------------------------------------------------------------
3 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
4 // All rights reserved.
5 //
6 // For the licensing terms see $DD4hepINSTALL/LICENSE.
7 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
8 //
9 // \author Markus Frank
10 // \date 2016-02-02
11 // \version 1.0
12 //
13 //==========================================================================
14 #ifndef DD4HEP_CONDITIONS_CONDIITONSSNAPSHOTROOTLOADER_H
15 #define DD4HEP_CONDITIONS_CONDIITONSSNAPSHOTROOTLOADER_H
16 
17 // Framework include files
20 #include <DD4hep/Printout.h>
21 
23 namespace dd4hep {
24 
26  namespace cond {
27 
29 
35  std::vector<ConditionsRootPersistency*> buffers;
36  void load_source (const std::string& nam);
37  public:
39  ConditionsSnapshotRootLoader(Detector& description, ConditionsManager mgr, const std::string& nam);
43  virtual size_t load_single(key_type key,
44  const IOV& req_validity,
45  RangeConditions& conditions);
47  virtual size_t load_range( key_type key,
48  const IOV& req_validity,
49  RangeConditions& conditions);
51  virtual size_t load_many( const IOV& /* req_validity */,
52  RequiredItems& /* work */,
53  LoadedItems& /* loaded */,
54  IOV& /* conditions_validity */)
55  {
56  except("ConditionsLoader","+++ update: Invalid call!");
57  return 0;
58  }
59  };
60  } /* End namespace cond */
61 } /* End namespace dd4hep */
62 #endif /* DD4HEP_CONDITIONS_CONDIITONSSNAPSHOTROOTLOADER_H */
63 
64 //#include <ConditionsSnapshotRootLoader.h>
65 #include <DD4hep/Printout.h>
66 #include <DD4hep/Factories.h>
67 #include <DD4hep/PluginCreators.h>
69 
70 #include <TFile.h>
71 
72 // C/C++ include files
73 #include <string>
74 
75 // Forward declartions
76 using namespace dd4hep::cond;
77 
78 namespace {
79  void* create_loader(dd4hep::Detector& description, int argc, char** argv) {
80  const char* name = argc>0 ? argv[0] : "XMLLoader";
81  ConditionsManagerObject* mgr = (ConditionsManagerObject*)(argc>0 ? argv[1] : 0);
82  return new ConditionsSnapshotRootLoader(description,ConditionsManager(mgr),name);
83  }
84 }
85 DECLARE_DD4HEP_CONSTRUCTOR(DD4hep_Conditions_root_snapshot_Loader,create_loader)
86 
87 ConditionsSnapshotRootLoader::ConditionsSnapshotRootLoader(Detector& description, ConditionsManager mgr, const std::string& nam)
89 : ConditionsDataLoader(description, mgr, nam)
90 {
91 }
92 
95  buffers.clear();
96 }
97 
98 void ConditionsSnapshotRootLoader::load_source(const std::string& nam) {
99  TFile* f = TFile::Open(nam.c_str());
100  std::unique_ptr<ConditionsRootPersistency> p =
101  ConditionsRootPersistency::load(f,"Conditions");
102  buffers.emplace_back(p.release());
103 }
104 
106  const IOV& /* req_validity */,
107  RangeConditions& conditions)
108 {
109  size_t len = conditions.size();
110  for(const auto& src : m_sources )
111  load_source(src.first);
112 
113  m_sources.clear();
114  return conditions.size()-len;
115 }
116 
118  const IOV& /* req_validity */,
119  RangeConditions& conditions)
120 {
121  size_t len = conditions.size();
122  for(const auto& src : m_sources )
123  load_source(src.first);
124  m_sources.clear();
125  return conditions.size()-len;
126 }
127 
dd4hep::cond::ConditionsDataLoader::key_type
Condition::key_type key_type
Definition: ConditionsDataLoader.h:51
dd4hep::RangeConditions
std::vector< Condition > RangeConditions
Definition: Conditions.h:491
dd4hep::cond::ConditionsSnapshotRootLoader
Implementation of a stack of conditions assembled before application.
Definition: ConditionsSnapshotRootLoader.cpp:34
cond
AlignmentCondition::Object * cond
Definition: AlignmentsCalculator.cpp:68
ConditionsInterna.h
dd4hep::cond::ConditionsSnapshotRootLoader::load_many
virtual size_t load_many(const IOV &, RequiredItems &, LoadedItems &, IOV &)
Optimized update using conditions slice data.
Definition: ConditionsSnapshotRootLoader.cpp:51
ConditionsRootPersistency.h
ConditionsDataLoader.h
dd4hep::cond::ConditionsDataLoader::m_sources
Sources m_sources
Property: input data source definitions.
Definition: ConditionsDataLoader.h:62
dd4hep::cond::ConditionsSnapshotRootLoader::~ConditionsSnapshotRootLoader
virtual ~ConditionsSnapshotRootLoader()
Default destructor.
Definition: ConditionsSnapshotRootLoader.cpp:94
Factories.h
dd4hep::cond::ConditionsSnapshotRootLoader::load_source
void load_source(const std::string &nam)
Definition: ConditionsSnapshotRootLoader.cpp:98
dd4hep::cond::ConditionsSnapshotRootLoader::load_range
virtual size_t load_range(key_type key, const IOV &req_validity, RangeConditions &conditions)
Load a condition set given a Detector Element and the conditions name according to their validity.
Definition: ConditionsSnapshotRootLoader.cpp:117
dd4hep::cond::ConditionsManagerObject
Basic conditions manager implementation.
Definition: ConditionsManagerObject.h:54
dd4hep::cond
Namespace for implementation details of the AIDA detector description toolkit.
Definition: ConditionsCleanup.h:23
dd4hep::IOV
Class describing the interval of validty.
Definition: IOV.h:67
dd4hep::cond::ConditionsDataLoader::RequiredItems
std::vector< std::pair< key_type, ConditionsLoadInfo * > > RequiredItems
Definition: ConditionsDataLoader.h:54
DECLARE_DD4HEP_CONSTRUCTOR
#define DECLARE_DD4HEP_CONSTRUCTOR(name, func)
Definition: Factories.h:291
dd4hep::cond::ConditionsSnapshotRootLoader::buffers
std::vector< ConditionsRootPersistency * > buffers
Definition: ConditionsSnapshotRootLoader.cpp:35
dd4hep::cond::ConditionsManager
Manager class for condition handles.
Definition: ConditionsManager.h:46
dd4hep::cond::ConditionsSnapshotRootLoader::ConditionsSnapshotRootLoader
ConditionsSnapshotRootLoader(Detector &description, ConditionsManager mgr, const std::string &nam)
Default constructor.
Definition: ConditionsSnapshotRootLoader.cpp:88
key
unsigned char key
Definition: AlignmentsCalculator.cpp:69
dd4hep::cond::ConditionsSnapshotRootLoader::load_single
virtual size_t load_single(key_type key, const IOV &req_validity, RangeConditions &conditions)
Load a condition set given a Detector Element and the conditions name according to their validity.
Definition: ConditionsSnapshotRootLoader.cpp:105
dd4hep::cond::ConditionsDataLoader
Interface for a generic conditions loader.
Definition: ConditionsDataLoader.h:46
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::cond::ConditionsDataLoader::LoadedItems
std::map< key_type, Condition > LoadedItems
Definition: ConditionsDataLoader.h:53
Printout.h
dd4hep::cond::ConditionsRootPersistency::load
static std::unique_ptr< ConditionsRootPersistency > load(TFile *file, const std::string &object)
Load conditions content from file.
PluginCreators.h