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 #include "tbb/task_arena.h"
30 
31 namespace edm {
32 
33  class ActivityRegistry;
34  class EventSetupImpl;
36  class ParameterSet;
37  class IOVSyncValue;
38  class WaitingTaskHolder;
39  class WaitingTaskList;
40 
41  namespace eventsetup {
42 
43  class DataProxyProvider;
44  class EventSetupProvider;
45 
47  public:
48  ESProducerInfo(ParameterSet const* ps, std::shared_ptr<DataProxyProvider> const& pr)
49  : pset_(ps), provider_(pr), subProcessIndexes_() {}
50 
51  ParameterSet const* pset() const { return pset_; }
52  std::shared_ptr<DataProxyProvider> const& provider() { return get_underlying(provider_); }
53  DataProxyProvider const* providerGet() const { return provider_.get(); }
54  std::vector<unsigned>& subProcessIndexes() { return subProcessIndexes_; }
55  std::vector<unsigned> const& subProcessIndexes() const { return subProcessIndexes_; }
56 
57  private:
60  std::vector<unsigned> subProcessIndexes_;
61  };
62 
63  class ESSourceInfo {
64  public:
65  ESSourceInfo(ParameterSet const* ps, std::shared_ptr<EventSetupRecordIntervalFinder> const& fi)
66  : pset_(ps), finder_(fi), subProcessIndexes_() {}
67 
68  ParameterSet const* pset() const { return pset_; }
69  std::shared_ptr<EventSetupRecordIntervalFinder> const& finder() { return get_underlying(finder_); }
70  EventSetupRecordIntervalFinder const* finderGet() const { return finder_.get(); }
71  std::vector<unsigned>& subProcessIndexes() { return subProcessIndexes_; }
72  std::vector<unsigned> const& subProcessIndexes() const { return subProcessIndexes_; }
73 
74  private:
77  std::vector<unsigned> subProcessIndexes_;
78  };
79 
81  public:
83 
86 
87  void endIOVsAsync(edm::WaitingTaskHolder iEndTask);
88 
89  std::shared_ptr<EventSetupProvider> makeProvider(ParameterSet&,
91  ParameterSet const* eventSetupPset = nullptr,
92  unsigned int maxConcurrentIOVs = 0,
93  bool dumpOptions = false);
94 
95  // Pass in an IOVSyncValue to let the EventSetup system know which run and lumi
96  // need to be processed and prepare IOVs for it (also could be a time or only a run).
97  // Pass in a WaitingTaskHolder that allows the EventSetup to communicate when all
98  // the IOVs are ready to process this IOVSyncValue. Note this preparation is often
99  // done in asynchronous tasks and the function might return before all the preparation
100  // is complete.
101  // Pass in endIOVWaitingTasks, additions to this WaitingTaskList allow the lumi to notify
102  // the EventSetup when the lumi is done and no longer needs its EventSetup IOVs.
103  // Pass in a vector of EventSetupImpl that gets filled and is used to give clients
104  // of EventSetup access to the EventSetup system such that for each record the IOV
105  // associated with this IOVSyncValue will be used. The first element of the vector
106  // is for the top level process and each additional element corresponds to a SubProcess.
108  WaitingTaskHolder const& taskToStartAfterIOVInit,
109  WaitingTaskList& endIOVWaitingTasks,
110  std::vector<std::shared_ptr<const EventSetupImpl>>&);
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  tbb::task_arena taskArena_;
168  std::vector<propagate_const<std::shared_ptr<EventSetupProvider>>> providers_;
170 
171  // This data member is intentionally declared after providers_
172  // It is important that this is destroyed first.
173  std::vector<propagate_const<std::unique_ptr<EventSetupRecordIOVQueue>>> eventSetupRecordIOVQueues_;
174 
175  // The following two multimaps have one entry for each unique
176  // ParameterSet. The ESProducerInfo or ESSourceInfo object
177  // contains a list of the processes that use that ParameterSet
178  // (0 for the top level process, then the SubProcesses are
179  // identified by counting their execution order starting at 1).
180  // There can be multiple entries for a single ParameterSetID because
181  // of a difference in untracked parameters. These are only
182  // used during initialization. The Info objects also contain
183  // a pointer to the full validated ParameterSet and a shared_ptr
184  // to the component.
185  std::multimap<ParameterSetID, ESProducerInfo> esproducers_;
186  std::multimap<ParameterSetID, ESSourceInfo> essources_;
187 
190  };
191 
192  void synchronousEventSetupForInstance(IOVSyncValue const& syncValue,
193  tbb::task_group& iGroup,
194  eventsetup::EventSetupsController& espController);
195  } // namespace eventsetup
196 } // namespace edm
197 #endif
edm::eventsetup::DataProxyProvider
Definition: DataProxyProvider.h:64
edm::eventsetup::ESProducerInfo
Definition: EventSetupsController.h:46
edm::eventsetup::ESProducerInfo::subProcessIndexes_
std::vector< unsigned > subProcessIndexes_
Definition: EventSetupsController.h:60
edm::eventsetup::EventSetupsController::eventSetupForInstanceAsync
void eventSetupForInstanceAsync(IOVSyncValue const &, WaitingTaskHolder const &taskToStartAfterIOVInit, WaitingTaskList &endIOVWaitingTasks, std::vector< std::shared_ptr< const EventSetupImpl >> &)
Definition: EventSetupsController.cc:90
edm::eventsetup::ESSourceInfo::finderGet
EventSetupRecordIntervalFinder const * finderGet() const
Definition: EventSetupsController.h:70
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::taskArena_
tbb::task_arena taskArena_
Definition: EventSetupsController.h:167
edm::eventsetup::synchronousEventSetupForInstance
void synchronousEventSetupForInstance(IOVSyncValue const &syncValue, tbb::task_group &iGroup, eventsetup::EventSetupsController &espController)
Definition: EventSetupsController.cc:412
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:173
edm::eventsetup::EventSetupsController::forceCacheClear
void forceCacheClear()
Definition: EventSetupsController.cc:140
edm::eventsetup::EventSetupsController::putESSource
void putESSource(ParameterSet const &pset, std::shared_ptr< EventSetupRecordIntervalFinder > const &component, unsigned subProcessIndex)
Definition: EventSetupsController.cc:189
edm::EventSetupRecordIntervalFinder
Definition: EventSetupRecordIntervalFinder.h:33
edm::eventsetup::EventSetupsController::isLastMatch
bool isLastMatch(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
Definition: EventSetupsController.cc:262
EventSetupRecordIOVQueue.h
edm::WaitingTaskList
Definition: WaitingTaskList.h:84
edm::eventsetup::EventSetupsController::getESProducerPSet
ParameterSet const * getESProducerPSet(ParameterSetID const &psetID, unsigned subProcessIndex) const
Definition: EventSetupsController.cc:337
edm::eventsetup::ESSourceInfo::pset_
ParameterSet const * pset_
Definition: EventSetupsController.h:75
edm::eventsetup::EventSetupsController::lookForMatches
void lookForMatches(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex, bool &firstProcessWithThisPSet, bool &precedingHasMatchingPSet) const
Definition: EventSetupsController.cc:203
edm::eventsetup::ESProducerInfo::ESProducerInfo
ESProducerInfo(ParameterSet const *ps, std::shared_ptr< DataProxyProvider > const &pr)
Definition: EventSetupsController.h:48
edm::eventsetup::ESProducerInfo::subProcessIndexes
std::vector< unsigned > & subProcessIndexes()
Definition: EventSetupsController.h:54
edm::propagate_const
Definition: propagate_const.h:32
edm::eventsetup::EventSetupsController::operator=
EventSetupsController const & operator=(EventSetupsController const &)=delete
edm::eventsetup::ESSourceInfo
Definition: EventSetupsController.h:63
edm::eventsetup::ESSourceInfo::finder_
propagate_const< std::shared_ptr< EventSetupRecordIntervalFinder > > finder_
Definition: EventSetupsController.h:76
edm::eventsetup::ESProducerInfo::provider_
propagate_const< std::shared_ptr< DataProxyProvider > > provider_
Definition: EventSetupsController.h:59
edm::eventsetup::ESProducerInfo::pset
ParameterSet const * pset() const
Definition: EventSetupsController.h:51
edm::eventsetup::EventSetupsController::providers_
std::vector< propagate_const< std::shared_ptr< EventSetupProvider > > > providers_
Definition: EventSetupsController.h:168
edm::eventsetup::EventSetupsController::essources_
std::multimap< ParameterSetID, ESSourceInfo > essources_
Definition: EventSetupsController.h:186
edm::ActivityRegistry
Definition: ActivityRegistry.h:134
WaitingTaskHolder
IOVSyncValue
edm::Hash< ParameterSetType >
edm::eventsetup::ESSourceInfo::subProcessIndexes_
std::vector< unsigned > subProcessIndexes_
Definition: EventSetupsController.h:77
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
edm::eventsetup::ESProducerInfo::provider
std::shared_ptr< DataProxyProvider > const & provider()
Definition: EventSetupsController.h:52
edm::eventsetup::EventSetupsController::numberOfConcurrentIOVs_
NumberOfConcurrentIOVs numberOfConcurrentIOVs_
Definition: EventSetupsController.h:169
edm::eventsetup::ESSourceInfo::subProcessIndexes
std::vector< unsigned > const & subProcessIndexes() const
Definition: EventSetupsController.h:72
edm::eventsetup::EventSetupsController::checkESProducerSharing
void checkESProducerSharing()
Definition: EventSetupsController.cc:355
edm::eventsetup::EventSetupsController::mustFinishConfiguration
bool mustFinishConfiguration() const
Definition: EventSetupsController.h:160
edm::eventsetup::ESProducerInfo::subProcessIndexes
std::vector< unsigned > const & subProcessIndexes() const
Definition: EventSetupsController.h:55
edm::eventsetup::EventSetupsController::putESProducer
void putESProducer(ParameterSet const &pset, std::shared_ptr< DataProxyProvider > const &component, unsigned subProcessIndex)
Definition: EventSetupsController.cc:163
edm::eventsetup::NumberOfConcurrentIOVs
Definition: NumberOfConcurrentIOVs.h:35
edm::ParameterSet
Definition: ParameterSet.h:47
edm::eventsetup::EventSetupsController::isMatchingESSource
bool isMatchingESSource(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
Definition: EventSetupsController.cc:287
sipixeldigitoraw
Definition: SiPixelDigiToRaw.cc:32
ParameterSet
Definition: Functions.h:16
edm::WaitingTaskHolder
Definition: WaitingTaskHolder.h:32
edm::eventsetup::EventSetupsController::indexOfNextProcess
unsigned indexOfNextProcess() const
Definition: EventSetupsController.h:131
edm::get_underlying
constexpr T & get_underlying(propagate_const< T > &)
Definition: propagate_const.h:103
edm::eventsetup::EventSetupsController::hasNonconcurrentFinder_
bool hasNonconcurrentFinder_
Definition: EventSetupsController.h:188
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::eventsetup::EventSetupsController::isMatchingESProducer
bool isMatchingESProducer(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
Definition: EventSetupsController.cc:312
edm::eventsetup::EventSetupsController::finishConfiguration
void finishConfiguration()
Definition: EventSetupsController.cc:64
WaitingTaskList
edm::eventsetup::EventSetupsController::getESProducerAndRegisterProcess
std::shared_ptr< DataProxyProvider > getESProducerAndRegisterProcess(ParameterSet const &pset, unsigned subProcessIndex)
Definition: EventSetupsController.cc:146
edm::eventsetup::EventSetupsController
Definition: EventSetupsController.h:80
edm::eventsetup::EventSetupsController::endIOVsAsync
void endIOVsAsync(edm::WaitingTaskHolder iEndTask)
Definition: EventSetupsController.cc:36
edm::eventsetup::EventSetupsController::getESSourceAndRegisterProcess
std::shared_ptr< EventSetupRecordIntervalFinder > getESSourceAndRegisterProcess(ParameterSet const &pset, unsigned subProcessIndex)
Definition: EventSetupsController.cc:172
edm::eventsetup::ESSourceInfo::finder
std::shared_ptr< EventSetupRecordIntervalFinder > const & finder()
Definition: EventSetupsController.h:69
edm::eventsetup::EventSetupsController::hasNonconcurrentFinder
bool hasNonconcurrentFinder() const
Definition: EventSetupsController.h:159
edm::eventsetup::ESSourceInfo::subProcessIndexes
std::vector< unsigned > & subProcessIndexes()
Definition: EventSetupsController.h:71
edm::eventsetup::ESProducerInfo::pset_
ParameterSet const * pset_
Definition: EventSetupsController.h:58
edm::eventsetup::EventSetupsController::makeProvider
std::shared_ptr< EventSetupProvider > makeProvider(ParameterSet &, ActivityRegistry *, ParameterSet const *eventSetupPset=nullptr, unsigned int maxConcurrentIOVs=0, bool dumpOptions=false)
Definition: EventSetupsController.cc:42
edm::eventsetup::EventSetupsController::initializeEventSetupRecordIOVQueues
void initializeEventSetupRecordIOVQueues()
Definition: EventSetupsController.cc:393
edm::eventsetup::EventSetupsController::mustFinishConfiguration_
bool mustFinishConfiguration_
Definition: EventSetupsController.h:189
edm::eventsetup::EventSetupsController::isFirstMatch
bool isFirstMatch(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
Definition: EventSetupsController.cc:237
ParameterSetID.h
edm::eventsetup::EventSetupsController::clearComponents
void clearComponents()
Definition: EventSetupsController.cc:198
edm::eventsetup::EventSetupsController::esproducers_
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
Definition: EventSetupsController.h:185
edm::eventsetup::ESProducerInfo::providerGet
DataProxyProvider const * providerGet() const
Definition: EventSetupsController.h:53
NumberOfConcurrentIOVs.h
edm::eventsetup::ESSourceInfo::pset
ParameterSet const * pset() const
Definition: EventSetupsController.h:68
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::eventsetup::EventSetupsController::doWeNeedToWaitForIOVsToFinish
bool doWeNeedToWaitForIOVsToFinish(IOVSyncValue const &) const
Definition: EventSetupsController.cc:129
edm::eventsetup::ESSourceInfo::ESSourceInfo
ESSourceInfo(ParameterSet const *ps, std::shared_ptr< EventSetupRecordIntervalFinder > const &fi)
Definition: EventSetupsController.h:65