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 ModuleTypeResolverMaker;
38  class ServiceToken;
39  class WaitingTaskHolder;
40  class WaitingTaskList;
41 
42  namespace eventsetup {
43 
44  class ESProductResolverProvider;
45  class EventSetupProvider;
46 
48  public:
49  ESProducerInfo(ParameterSet* ps, std::shared_ptr<ESProductResolverProvider> const& pr)
50  : pset_(ps), provider_(pr), subProcessIndexes_() {}
51 
52  ParameterSet const* pset() const { return pset_.get(); }
53  ParameterSet* pset() { return pset_.get(); }
54  std::shared_ptr<ESProductResolverProvider> const& provider() { return get_underlying(provider_); }
55  ESProductResolverProvider const* providerGet() const { return provider_.get(); }
56  std::vector<unsigned>& subProcessIndexes() { return subProcessIndexes_; }
57  std::vector<unsigned> const& subProcessIndexes() const { return subProcessIndexes_; }
58 
59  private:
62  std::vector<unsigned> subProcessIndexes_;
63  };
64 
65  class ESSourceInfo {
66  public:
67  ESSourceInfo(ParameterSet const* ps, std::shared_ptr<EventSetupRecordIntervalFinder> const& fi)
68  : pset_(ps), finder_(fi), subProcessIndexes_() {}
69 
70  ParameterSet const* pset() const { return pset_; }
71  std::shared_ptr<EventSetupRecordIntervalFinder> const& finder() { return get_underlying(finder_); }
72  EventSetupRecordIntervalFinder const* finderGet() const { return finder_.get(); }
73  std::vector<unsigned>& subProcessIndexes() { return subProcessIndexes_; }
74  std::vector<unsigned> const& subProcessIndexes() const { return subProcessIndexes_; }
75 
76  private:
79  std::vector<unsigned> subProcessIndexes_;
80  };
81 
83  public:
85  explicit EventSetupsController(ModuleTypeResolverMaker const* resolverMaker);
86 
89 
90  void endIOVsAsync(edm::WaitingTaskHolder iEndTask);
91 
92  std::shared_ptr<EventSetupProvider> makeProvider(ParameterSet&,
94  ParameterSet const* eventSetupPset = nullptr,
95  unsigned int maxConcurrentIOVs = 0,
96  bool dumpOptions = false);
97 
98  // The main purpose of this function is to call eventSetupForInstanceAsync. It might
99  // be called immediately or we might need to wait until all the currently active
100  // IOVs end. If there is an exception, then a signal is emitted and the exception
101  // is propagated.
103  WaitingTaskHolder& taskToStartAfterIOVInit,
104  WaitingTaskList& endIOVWaitingTasks,
105  std::vector<std::shared_ptr<const EventSetupImpl>>&,
106  edm::SerialTaskQueue& queueWhichWaitsForIOVsToFinish,
108  ServiceToken const&,
109  bool iForceCacheClear = false);
110 
111  // Pass in an IOVSyncValue to let the EventSetup system know which run and lumi
112  // need to be processed and prepare IOVs for it (also could be a time or only a run).
113  // Pass in a WaitingTaskHolder that allows the EventSetup to communicate when all
114  // the IOVs are ready to process this IOVSyncValue. Note this preparation is often
115  // done in asynchronous tasks and the function might return before all the preparation
116  // is complete.
117  // Pass in endIOVWaitingTasks, additions to this WaitingTaskList allow the lumi or
118  // run to notify the EventSetup system when a lumi or run transition is done and no
119  // longer needs its EventSetup IOVs.
120  // Pass in a vector of EventSetupImpl that gets filled and is used to give clients
121  // of EventSetup access to the EventSetup system such that for each record the IOV
122  // associated with this IOVSyncValue will be used. The first element of the vector
123  // is for the top level process and each additional element corresponds to a SubProcess.
125  WaitingTaskHolder const& taskToStartAfterIOVInit,
126  WaitingTaskList& endIOVWaitingTasks,
127  std::vector<std::shared_ptr<const EventSetupImpl>>&);
128 
129  bool doWeNeedToWaitForIOVsToFinish(IOVSyncValue const&) const;
130 
131  void forceCacheClear();
132 
133  std::shared_ptr<ESProductResolverProvider> getESProducerAndRegisterProcess(ParameterSet const& pset,
134  unsigned subProcessIndex);
136  std::shared_ptr<ESProductResolverProvider> const& component,
137  unsigned subProcessIndex);
138 
139  std::shared_ptr<EventSetupRecordIntervalFinder> getESSourceAndRegisterProcess(ParameterSet const& pset,
140  unsigned subProcessIndex);
141  void putESSource(ParameterSet const& pset,
142  std::shared_ptr<EventSetupRecordIntervalFinder> const& component,
143  unsigned subProcessIndex);
144 
145  void finishConfiguration();
146  void clearComponents();
147 
148  unsigned indexOfNextProcess() const { return providers_.size(); }
149 
150  void lookForMatches(ParameterSetID const& psetID,
151  unsigned subProcessIndex,
152  unsigned precedingProcessIndex,
153  bool& firstProcessWithThisPSet,
154  bool& precedingHasMatchingPSet) const;
155 
156  bool isFirstMatch(ParameterSetID const& psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const;
157 
158  bool isLastMatch(ParameterSetID const& psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const;
159 
160  bool isMatchingESSource(ParameterSetID const& psetID,
161  unsigned subProcessIndex,
162  unsigned precedingProcessIndex) const;
163 
164  bool isMatchingESProducer(ParameterSetID const& psetID,
165  unsigned subProcessIndex,
166  unsigned precedingProcessIndex) const;
167 
168  ParameterSet& getESProducerPSet(ParameterSetID const& psetID, unsigned subProcessIndex);
169 
170  std::vector<propagate_const<std::shared_ptr<EventSetupProvider>>> const& providers() const { return providers_; }
171 
172  std::multimap<ParameterSetID, ESProducerInfo> const& esproducers() const { return esproducers_; }
173 
174  std::multimap<ParameterSetID, ESSourceInfo> const& essources() const { return essources_; }
175 
178 
179  private:
180  void checkESProducerSharing();
182 
183  // ---------- member data --------------------------------
184  std::vector<propagate_const<std::shared_ptr<EventSetupProvider>>> providers_;
186 
187  // This data member is intentionally declared after providers_
188  // It is important that this is destroyed first.
189  std::vector<propagate_const<std::unique_ptr<EventSetupRecordIOVQueue>>> eventSetupRecordIOVQueues_;
190 
191  // The following two multimaps have one entry for each unique
192  // ParameterSet. The ESProducerInfo or ESSourceInfo object
193  // contains a list of the processes that use that ParameterSet
194  // (0 for the top level process, then the SubProcesses are
195  // identified by counting their execution order starting at 1).
196  // There can be multiple entries for a single ParameterSetID because
197  // of a difference in untracked parameters. These are only
198  // used during initialization. The Info objects also contain
199  // a pointer to the full validated ParameterSet and a shared_ptr
200  // to the component.
201  std::multimap<ParameterSetID, ESProducerInfo> esproducers_;
202  std::multimap<ParameterSetID, ESSourceInfo> essources_;
203 
205 
208  };
209 
210  void synchronousEventSetupForInstance(IOVSyncValue const& syncValue,
211  oneapi::tbb::task_group& iGroup,
212  eventsetup::EventSetupsController& espController);
213  } // namespace eventsetup
214 } // namespace edm
215 #endif
std::shared_ptr< EventSetupRecordIntervalFinder > const & finder()
std::shared_ptr< EventSetupRecordIntervalFinder > getESSourceAndRegisterProcess(ParameterSet const &pset, unsigned subProcessIndex)
std::shared_ptr< ESProductResolverProvider > getESProducerAndRegisterProcess(ParameterSet const &pset, unsigned subProcessIndex)
std::vector< unsigned > subProcessIndexes_
std::vector< propagate_const< std::unique_ptr< EventSetupRecordIOVQueue > > > eventSetupRecordIOVQueues_
std::vector< unsigned > & subProcessIndexes()
void putESSource(ParameterSet const &pset, std::shared_ptr< EventSetupRecordIntervalFinder > const &component, unsigned subProcessIndex)
std::vector< unsigned > & subProcessIndexes()
bool isMatchingESSource(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
edm::propagate_const< ParameterSet * > pset_
void lookForMatches(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex, bool &firstProcessWithThisPSet, bool &precedingHasMatchingPSet) const
ESProducerInfo(ParameterSet *ps, std::shared_ptr< ESProductResolverProvider > const &pr)
void synchronousEventSetupForInstance(IOVSyncValue const &syncValue, oneapi::tbb::task_group &iGroup, eventsetup::EventSetupsController &espController)
ParameterSet & getESProducerPSet(ParameterSetID const &psetID, unsigned subProcessIndex)
bool isLastMatch(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
std::vector< unsigned > const & subProcessIndexes() const
propagate_const< std::shared_ptr< ESProductResolverProvider > > provider_
std::vector< unsigned > const & subProcessIndexes() const
std::multimap< ParameterSetID, ESSourceInfo > essources_
bool isMatchingESProducer(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
std::shared_ptr< EventSetupProvider > makeProvider(ParameterSet &, ActivityRegistry *, ParameterSet const *eventSetupPset=nullptr, unsigned int maxConcurrentIOVs=0, bool dumpOptions=false)
std::vector< propagate_const< std::shared_ptr< EventSetupProvider > > > const & providers() const
void putESProducer(ParameterSet &pset, std::shared_ptr< ESProductResolverProvider > const &component, unsigned subProcessIndex)
void eventSetupForInstanceAsync(IOVSyncValue const &, WaitingTaskHolder const &taskToStartAfterIOVInit, WaitingTaskList &endIOVWaitingTasks, std::vector< std::shared_ptr< const EventSetupImpl >> &)
ParameterSet const * pset() const
EventSetupsController const & operator=(EventSetupsController const &)=delete
ESSourceInfo(ParameterSet const *ps, std::shared_ptr< EventSetupRecordIntervalFinder > const &fi)
std::vector< unsigned > subProcessIndexes_
constexpr T & get_underlying(propagate_const< T > &)
ESProductResolverProvider const * providerGet() const
bool isFirstMatch(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
void endIOVsAsync(edm::WaitingTaskHolder iEndTask)
EventSetupRecordIntervalFinder const * finderGet() const
HLT enums.
void runOrQueueEventSetupForInstanceAsync(IOVSyncValue const &, WaitingTaskHolder &taskToStartAfterIOVInit, WaitingTaskList &endIOVWaitingTasks, std::vector< std::shared_ptr< const EventSetupImpl >> &, edm::SerialTaskQueue &queueWhichWaitsForIOVsToFinish, ActivityRegistry *, ServiceToken const &, bool iForceCacheClear=false)
std::multimap< ParameterSetID, ESProducerInfo > const & esproducers() const
std::multimap< ParameterSetID, ESSourceInfo > const & essources() const
std::shared_ptr< ESProductResolverProvider > const & provider()
ParameterSet const * pset() const
propagate_const< std::shared_ptr< EventSetupRecordIntervalFinder > > finder_
bool doWeNeedToWaitForIOVsToFinish(IOVSyncValue const &) const
std::vector< propagate_const< std::shared_ptr< EventSetupProvider > > > providers_
ModuleTypeResolverMaker const * typeResolverMaker_