CMS 3D CMS Logo

EventSetupsController.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_EventSetupsController_h
2 #define FWCore_Framework_EventSetupsController_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : EventSetupsController
7 //
16 //
17 // Original Authors: Chris Jones, David Dagenhart
18 // Created: Wed Jan 12 14:30:42 CST 2011
19 //
20 
25 
26 #include <map>
27 #include <memory>
28 #include <vector>
29 
30 namespace edm {
31 
32  class ActivityRegistry;
33  class EventSetupImpl;
35  class ParameterSet;
36  class IOVSyncValue;
37  class WaitingTaskHolder;
38  class WaitingTaskList;
39 
40  namespace eventsetup {
41 
42  class DataProxyProvider;
43  class EventSetupProvider;
44 
46  public:
47  ESProducerInfo(ParameterSet const* ps, std::shared_ptr<DataProxyProvider> const& pr)
48  : pset_(ps), provider_(pr), subProcessIndexes_() {}
49 
50  ParameterSet const* pset() const { return pset_; }
51  std::shared_ptr<DataProxyProvider> const& provider() { return get_underlying(provider_); }
52  DataProxyProvider const* providerGet() const { return provider_.get(); }
53  std::vector<unsigned>& subProcessIndexes() { return subProcessIndexes_; }
54  std::vector<unsigned> const& subProcessIndexes() const { return subProcessIndexes_; }
55 
56  private:
59  std::vector<unsigned> subProcessIndexes_;
60  };
61 
62  class ESSourceInfo {
63  public:
64  ESSourceInfo(ParameterSet const* ps, std::shared_ptr<EventSetupRecordIntervalFinder> const& fi)
65  : pset_(ps), finder_(fi), subProcessIndexes_() {}
66 
67  ParameterSet const* pset() const { return pset_; }
68  std::shared_ptr<EventSetupRecordIntervalFinder> const& finder() { return get_underlying(finder_); }
69  EventSetupRecordIntervalFinder const* finderGet() const { return finder_.get(); }
70  std::vector<unsigned>& subProcessIndexes() { return subProcessIndexes_; }
71  std::vector<unsigned> const& subProcessIndexes() const { return subProcessIndexes_; }
72 
73  private:
76  std::vector<unsigned> subProcessIndexes_;
77  };
78 
80  public:
82 
85 
86  std::shared_ptr<EventSetupProvider> makeProvider(ParameterSet&,
88  ParameterSet const* eventSetupPset = nullptr);
89 
90  void setMaxConcurrentIOVs(unsigned int nStreams, unsigned int nConcurrentLumis);
91 
92  // Pass in an IOVSyncValue to let the EventSetup system know which run and lumi
93  // need to be processed and prepare IOVs for it (also could be a time or only a run).
94  // Pass in a WaitingTaskHolder that allows the EventSetup to communicate when all
95  // the IOVs are ready to process this IOVSyncValue. Note this preparation is often
96  // done in asynchronous tasks and the function might return before all the preparation
97  // is complete.
98  // Pass in endIOVWaitingTasks, additions to this WaitingTaskList allow the lumi to notify
99  // the EventSetup when the lumi is done and no longer needs its EventSetup IOVs.
100  // Pass in a vector of EventSetupImpl that gets filled and is used to give clients
101  // of EventSetup access to the EventSetup system such that for each record the IOV
102  // associated with this IOVSyncValue will be used. The first element of the vector
103  // is for the top level process and each additional element corresponds to a SubProcess.
105  WaitingTaskHolder const& taskToStartAfterIOVInit,
106  WaitingTaskList& endIOVWaitingTasks,
107  std::vector<std::shared_ptr<const EventSetupImpl>>&);
108 
109  // Version to use when IOVs are not allowed to run concurrently
110  void eventSetupForInstance(IOVSyncValue const&);
111 
112  bool doWeNeedToWaitForIOVsToFinish(IOVSyncValue const&) const;
113 
114  void forceCacheClear();
115 
116  std::shared_ptr<DataProxyProvider> getESProducerAndRegisterProcess(ParameterSet const& pset,
117  unsigned subProcessIndex);
118  void putESProducer(ParameterSet const& pset,
119  std::shared_ptr<DataProxyProvider> const& component,
120  unsigned subProcessIndex);
121 
122  std::shared_ptr<EventSetupRecordIntervalFinder> getESSourceAndRegisterProcess(ParameterSet const& pset,
123  unsigned subProcessIndex);
124  void putESSource(ParameterSet const& pset,
125  std::shared_ptr<EventSetupRecordIntervalFinder> const& component,
126  unsigned subProcessIndex);
127 
128  void finishConfiguration();
129  void clearComponents();
130 
131  unsigned indexOfNextProcess() const { return providers_.size(); }
132 
133  void lookForMatches(ParameterSetID const& psetID,
134  unsigned subProcessIndex,
135  unsigned precedingProcessIndex,
136  bool& firstProcessWithThisPSet,
137  bool& precedingHasMatchingPSet) const;
138 
139  bool isFirstMatch(ParameterSetID const& psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const;
140 
141  bool isLastMatch(ParameterSetID const& psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const;
142 
143  bool isMatchingESSource(ParameterSetID const& psetID,
144  unsigned subProcessIndex,
145  unsigned precedingProcessIndex) const;
146 
147  bool isMatchingESProducer(ParameterSetID const& psetID,
148  unsigned subProcessIndex,
149  unsigned precedingProcessIndex) const;
150 
151  ParameterSet const* getESProducerPSet(ParameterSetID const& psetID, unsigned subProcessIndex) const;
152 
153  std::vector<propagate_const<std::shared_ptr<EventSetupProvider>>> const& providers() const { return providers_; }
154 
155  std::multimap<ParameterSetID, ESProducerInfo> const& esproducers() const { return esproducers_; }
156 
157  std::multimap<ParameterSetID, ESSourceInfo> const& essources() const { return essources_; }
158 
161 
162  private:
163  void checkESProducerSharing();
165 
166  // ---------- member data --------------------------------
167  std::vector<propagate_const<std::shared_ptr<EventSetupProvider>>> providers_;
169 
170  // This data member is intentionally declared after providers_
171  // It is important that this is destroyed first.
172  std::vector<propagate_const<std::unique_ptr<EventSetupRecordIOVQueue>>> eventSetupRecordIOVQueues_;
173 
174  // The following two multimaps have one entry for each unique
175  // ParameterSet. The ESProducerInfo or ESSourceInfo object
176  // contains a list of the processes that use that ParameterSet
177  // (0 for the top level process, then the SubProcesses are
178  // identified by counting their execution order starting at 1).
179  // There can be multiple entries for a single ParameterSetID because
180  // of a difference in untracked parameters. These are only
181  // used during initialization. The Info objects also contain
182  // a pointer to the full validated ParameterSet and a shared_ptr
183  // to the component.
184  std::multimap<ParameterSetID, ESProducerInfo> esproducers_;
185  std::multimap<ParameterSetID, ESSourceInfo> essources_;
186 
189  };
190  } // namespace eventsetup
191 } // namespace edm
192 #endif
edm::eventsetup::DataProxyProvider
Definition: DataProxyProvider.h:64
edm::eventsetup::ESProducerInfo
Definition: EventSetupsController.h:45
edm::eventsetup::ESProducerInfo::subProcessIndexes_
std::vector< unsigned > subProcessIndexes_
Definition: EventSetupsController.h:59
edm::eventsetup::EventSetupsController::eventSetupForInstance
void eventSetupForInstance(IOVSyncValue const &, WaitingTaskHolder const &taskToStartAfterIOVInit, WaitingTaskList &endIOVWaitingTasks, std::vector< std::shared_ptr< const EventSetupImpl >> &)
Definition: EventSetupsController.cc:86
edm::eventsetup::EventSetupsController::makeProvider
std::shared_ptr< EventSetupProvider > makeProvider(ParameterSet &, ActivityRegistry *, ParameterSet const *eventSetupPset=nullptr)
Definition: EventSetupsController.cc:36
edm::eventsetup::ESSourceInfo::finderGet
EventSetupRecordIntervalFinder const * finderGet() const
Definition: EventSetupsController.h:69
EventSetupRecordIntervalFinder
ActivityRegistry
propagate_const.h
edm::eventsetup::EventSetupsController::EventSetupsController
EventSetupsController()
Definition: EventSetupsController.cc:34
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::eventsetup::EventSetupsController::essources
std::multimap< ParameterSetID, ESSourceInfo > const & essources() const
Definition: EventSetupsController.h:157
edm::eventsetup::EventSetupsController::providers
std::vector< propagate_const< std::shared_ptr< EventSetupProvider > > > const & providers() const
Definition: EventSetupsController.h:153
edm::eventsetup::EventSetupsController::esproducers
std::multimap< ParameterSetID, ESProducerInfo > const & esproducers() const
Definition: EventSetupsController.h:155
edm::eventsetup::EventSetupsController::eventSetupRecordIOVQueues_
std::vector< propagate_const< std::unique_ptr< EventSetupRecordIOVQueue > > > eventSetupRecordIOVQueues_
Definition: EventSetupsController.h:172
edm::eventsetup::EventSetupsController::forceCacheClear
void forceCacheClear()
Definition: EventSetupsController.cc:175
edm::eventsetup::EventSetupsController::putESSource
void putESSource(ParameterSet const &pset, std::shared_ptr< EventSetupRecordIntervalFinder > const &component, unsigned subProcessIndex)
Definition: EventSetupsController.cc:224
edm::get_underlying
T & get_underlying(propagate_const< T > &)
Definition: propagate_const.h:103
edm::EventSetupRecordIntervalFinder
Definition: EventSetupRecordIntervalFinder.h:33
edm::eventsetup::EventSetupsController::isLastMatch
bool isLastMatch(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
Definition: EventSetupsController.cc:297
EventSetupRecordIOVQueue.h
edm::WaitingTaskList
Definition: WaitingTaskList.h:101
edm::eventsetup::EventSetupsController::getESProducerPSet
ParameterSet const * getESProducerPSet(ParameterSetID const &psetID, unsigned subProcessIndex) const
Definition: EventSetupsController.cc:372
edm::eventsetup::ESSourceInfo::pset_
ParameterSet const * pset_
Definition: EventSetupsController.h:74
edm::eventsetup::EventSetupsController::lookForMatches
void lookForMatches(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex, bool &firstProcessWithThisPSet, bool &precedingHasMatchingPSet) const
Definition: EventSetupsController.cc:238
edm::eventsetup::ESProducerInfo::ESProducerInfo
ESProducerInfo(ParameterSet const *ps, std::shared_ptr< DataProxyProvider > const &pr)
Definition: EventSetupsController.h:47
edm::eventsetup::ESProducerInfo::subProcessIndexes
std::vector< unsigned > & subProcessIndexes()
Definition: EventSetupsController.h:53
edm::propagate_const
Definition: propagate_const.h:32
edm::eventsetup::EventSetupsController::operator=
EventSetupsController const & operator=(EventSetupsController const &)=delete
edm::eventsetup::ESSourceInfo
Definition: EventSetupsController.h:62
edm::eventsetup::ESSourceInfo::finder_
propagate_const< std::shared_ptr< EventSetupRecordIntervalFinder > > finder_
Definition: EventSetupsController.h:75
edm::eventsetup::ESProducerInfo::provider_
propagate_const< std::shared_ptr< DataProxyProvider > > provider_
Definition: EventSetupsController.h:58
edm::eventsetup::ESProducerInfo::pset
ParameterSet const * pset() const
Definition: EventSetupsController.h:50
edm::eventsetup::EventSetupsController::providers_
std::vector< propagate_const< std::shared_ptr< EventSetupProvider > > > providers_
Definition: EventSetupsController.h:167
edm::eventsetup::EventSetupsController::essources_
std::multimap< ParameterSetID, ESSourceInfo > essources_
Definition: EventSetupsController.h:185
edm::ActivityRegistry
Definition: ActivityRegistry.h:132
WaitingTaskHolder
IOVSyncValue
edm::Hash< ParameterSetType >
edm::eventsetup::ESSourceInfo::subProcessIndexes_
std::vector< unsigned > subProcessIndexes_
Definition: EventSetupsController.h:76
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
edm::eventsetup::EventSetupsController::setMaxConcurrentIOVs
void setMaxConcurrentIOVs(unsigned int nStreams, unsigned int nConcurrentLumis)
Definition: EventSetupsController.cc:56
edm::eventsetup::ESProducerInfo::provider
std::shared_ptr< DataProxyProvider > const & provider()
Definition: EventSetupsController.h:51
edm::eventsetup::EventSetupsController::numberOfConcurrentIOVs_
NumberOfConcurrentIOVs numberOfConcurrentIOVs_
Definition: EventSetupsController.h:168
edm::eventsetup::ESSourceInfo::subProcessIndexes
std::vector< unsigned > const & subProcessIndexes() const
Definition: EventSetupsController.h:71
edm::eventsetup::EventSetupsController::checkESProducerSharing
void checkESProducerSharing()
Definition: EventSetupsController.cc:390
edm::eventsetup::EventSetupsController::mustFinishConfiguration
bool mustFinishConfiguration() const
Definition: EventSetupsController.h:160
edm::eventsetup::ESProducerInfo::subProcessIndexes
std::vector< unsigned > const & subProcessIndexes() const
Definition: EventSetupsController.h:54
edm::eventsetup::EventSetupsController::putESProducer
void putESProducer(ParameterSet const &pset, std::shared_ptr< DataProxyProvider > const &component, unsigned subProcessIndex)
Definition: EventSetupsController.cc:198
edm::eventsetup::NumberOfConcurrentIOVs
Definition: NumberOfConcurrentIOVs.h:35
edm::ParameterSet
Definition: ParameterSet.h:36
edm::eventsetup::EventSetupsController::isMatchingESSource
bool isMatchingESSource(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
Definition: EventSetupsController.cc:322
sipixeldigitoraw
Definition: SiPixelDigiToRaw.cc:38
ParameterSet
Definition: Functions.h:16
edm::WaitingTaskHolder
Definition: WaitingTaskHolder.h:30
edm::eventsetup::EventSetupsController::indexOfNextProcess
unsigned indexOfNextProcess() const
Definition: EventSetupsController.h:131
edm::eventsetup::EventSetupsController::hasNonconcurrentFinder_
bool hasNonconcurrentFinder_
Definition: EventSetupsController.h:187
edm::eventsetup::EventSetupsController::isMatchingESProducer
bool isMatchingESProducer(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
Definition: EventSetupsController.cc:347
edm::eventsetup::EventSetupsController::finishConfiguration
void finishConfiguration()
Definition: EventSetupsController.cc:60
WaitingTaskList
edm::eventsetup::EventSetupsController::getESProducerAndRegisterProcess
std::shared_ptr< DataProxyProvider > getESProducerAndRegisterProcess(ParameterSet const &pset, unsigned subProcessIndex)
Definition: EventSetupsController.cc:181
edm::eventsetup::EventSetupsController
Definition: EventSetupsController.h:79
edm::eventsetup::EventSetupsController::getESSourceAndRegisterProcess
std::shared_ptr< EventSetupRecordIntervalFinder > getESSourceAndRegisterProcess(ParameterSet const &pset, unsigned subProcessIndex)
Definition: EventSetupsController.cc:207
edm::eventsetup::ESSourceInfo::finder
std::shared_ptr< EventSetupRecordIntervalFinder > const & finder()
Definition: EventSetupsController.h:68
edm::eventsetup::EventSetupsController::hasNonconcurrentFinder
bool hasNonconcurrentFinder() const
Definition: EventSetupsController.h:159
edm::eventsetup::ESSourceInfo::subProcessIndexes
std::vector< unsigned > & subProcessIndexes()
Definition: EventSetupsController.h:70
edm::eventsetup::ESProducerInfo::pset_
ParameterSet const * pset_
Definition: EventSetupsController.h:57
edm::eventsetup::EventSetupsController::initializeEventSetupRecordIOVQueues
void initializeEventSetupRecordIOVQueues()
Definition: EventSetupsController.cc:428
edm::eventsetup::EventSetupsController::mustFinishConfiguration_
bool mustFinishConfiguration_
Definition: EventSetupsController.h:188
edm::eventsetup::EventSetupsController::isFirstMatch
bool isFirstMatch(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
Definition: EventSetupsController.cc:272
ParameterSetID.h
edm::eventsetup::EventSetupsController::clearComponents
void clearComponents()
Definition: EventSetupsController.cc:233
edm::eventsetup::EventSetupsController::esproducers_
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
Definition: EventSetupsController.h:184
edm::eventsetup::ESProducerInfo::providerGet
DataProxyProvider const * providerGet() const
Definition: EventSetupsController.h:52
NumberOfConcurrentIOVs.h
edm::eventsetup::ESSourceInfo::pset
ParameterSet const * pset() const
Definition: EventSetupsController.h:67
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::eventsetup::EventSetupsController::doWeNeedToWaitForIOVsToFinish
bool doWeNeedToWaitForIOVsToFinish(IOVSyncValue const &) const
Definition: EventSetupsController.cc:164
edm::eventsetup::ESSourceInfo::ESSourceInfo
ESSourceInfo(ParameterSet const *ps, std::shared_ptr< EventSetupRecordIntervalFinder > const &fi)
Definition: EventSetupsController.h:64