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  void endIOVsAsync(edm::WaitingTaskHolder iEndTask);
87 
88  std::shared_ptr<EventSetupProvider> makeProvider(ParameterSet&,
90  ParameterSet const* eventSetupPset = nullptr,
91  unsigned int maxConcurrentIOVs = 0,
92  bool dumpOptions = false);
93 
94  // Pass in an IOVSyncValue to let the EventSetup system know which run and lumi
95  // need to be processed and prepare IOVs for it (also could be a time or only a run).
96  // Pass in a WaitingTaskHolder that allows the EventSetup to communicate when all
97  // the IOVs are ready to process this IOVSyncValue. Note this preparation is often
98  // done in asynchronous tasks and the function might return before all the preparation
99  // is complete.
100  // Pass in endIOVWaitingTasks, additions to this WaitingTaskList allow the lumi to notify
101  // the EventSetup when the lumi is done and no longer needs its EventSetup IOVs.
102  // Pass in a vector of EventSetupImpl that gets filled and is used to give clients
103  // of EventSetup access to the EventSetup system such that for each record the IOV
104  // associated with this IOVSyncValue will be used. The first element of the vector
105  // is for the top level process and each additional element corresponds to a SubProcess.
107  WaitingTaskHolder const& taskToStartAfterIOVInit,
108  WaitingTaskList& endIOVWaitingTasks,
109  std::vector<std::shared_ptr<const EventSetupImpl>>&);
110 
111  bool doWeNeedToWaitForIOVsToFinish(IOVSyncValue const&) const;
112 
113  void forceCacheClear();
114 
115  std::shared_ptr<DataProxyProvider> getESProducerAndRegisterProcess(ParameterSet const& pset,
116  unsigned subProcessIndex);
117  void putESProducer(ParameterSet const& pset,
118  std::shared_ptr<DataProxyProvider> const& component,
119  unsigned subProcessIndex);
120 
121  std::shared_ptr<EventSetupRecordIntervalFinder> getESSourceAndRegisterProcess(ParameterSet const& pset,
122  unsigned subProcessIndex);
123  void putESSource(ParameterSet const& pset,
124  std::shared_ptr<EventSetupRecordIntervalFinder> const& component,
125  unsigned subProcessIndex);
126 
127  void finishConfiguration();
128  void clearComponents();
129 
130  unsigned indexOfNextProcess() const { return providers_.size(); }
131 
132  void lookForMatches(ParameterSetID const& psetID,
133  unsigned subProcessIndex,
134  unsigned precedingProcessIndex,
135  bool& firstProcessWithThisPSet,
136  bool& precedingHasMatchingPSet) const;
137 
138  bool isFirstMatch(ParameterSetID const& psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const;
139 
140  bool isLastMatch(ParameterSetID const& psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const;
141 
142  bool isMatchingESSource(ParameterSetID const& psetID,
143  unsigned subProcessIndex,
144  unsigned precedingProcessIndex) const;
145 
146  bool isMatchingESProducer(ParameterSetID const& psetID,
147  unsigned subProcessIndex,
148  unsigned precedingProcessIndex) const;
149 
150  ParameterSet const* getESProducerPSet(ParameterSetID const& psetID, unsigned subProcessIndex) const;
151 
152  std::vector<propagate_const<std::shared_ptr<EventSetupProvider>>> const& providers() const { return providers_; }
153 
154  std::multimap<ParameterSetID, ESProducerInfo> const& esproducers() const { return esproducers_; }
155 
156  std::multimap<ParameterSetID, ESSourceInfo> const& essources() const { return essources_; }
157 
160 
161  private:
162  void checkESProducerSharing();
164 
165  // ---------- member data --------------------------------
166  std::vector<propagate_const<std::shared_ptr<EventSetupProvider>>> providers_;
168 
169  // This data member is intentionally declared after providers_
170  // It is important that this is destroyed first.
171  std::vector<propagate_const<std::unique_ptr<EventSetupRecordIOVQueue>>> eventSetupRecordIOVQueues_;
172 
173  // The following two multimaps have one entry for each unique
174  // ParameterSet. The ESProducerInfo or ESSourceInfo object
175  // contains a list of the processes that use that ParameterSet
176  // (0 for the top level process, then the SubProcesses are
177  // identified by counting their execution order starting at 1).
178  // There can be multiple entries for a single ParameterSetID because
179  // of a difference in untracked parameters. These are only
180  // used during initialization. The Info objects also contain
181  // a pointer to the full validated ParameterSet and a shared_ptr
182  // to the component.
183  std::multimap<ParameterSetID, ESProducerInfo> esproducers_;
184  std::multimap<ParameterSetID, ESSourceInfo> essources_;
185 
188  };
189 
190  void synchronousEventSetupForInstance(IOVSyncValue const& syncValue,
191  oneapi::tbb::task_group& iGroup,
192  eventsetup::EventSetupsController& espController);
193  } // namespace eventsetup
194 } // namespace edm
195 #endif
std::shared_ptr< EventSetupRecordIntervalFinder > const & finder()
std::shared_ptr< EventSetupRecordIntervalFinder > getESSourceAndRegisterProcess(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()
ParameterSet const * getESProducerPSet(ParameterSetID const &psetID, unsigned subProcessIndex) const
void putESProducer(ParameterSet const &pset, std::shared_ptr< DataProxyProvider > const &component, unsigned subProcessIndex)
bool isMatchingESSource(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
void lookForMatches(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex, bool &firstProcessWithThisPSet, bool &precedingHasMatchingPSet) const
void synchronousEventSetupForInstance(IOVSyncValue const &syncValue, oneapi::tbb::task_group &iGroup, eventsetup::EventSetupsController &espController)
bool isLastMatch(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
std::shared_ptr< DataProxyProvider > getESProducerAndRegisterProcess(ParameterSet const &pset, unsigned subProcessIndex)
std::vector< unsigned > const & subProcessIndexes() const
std::shared_ptr< DataProxyProvider > const & provider()
std::vector< unsigned > const & subProcessIndexes() const
std::multimap< ParameterSetID, ESSourceInfo > essources_
ESProducerInfo(ParameterSet const *ps, std::shared_ptr< DataProxyProvider > const &pr)
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
propagate_const< std::shared_ptr< DataProxyProvider > > provider_
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 > &)
bool isFirstMatch(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
void endIOVsAsync(edm::WaitingTaskHolder iEndTask)
DataProxyProvider const * providerGet() const
EventSetupRecordIntervalFinder const * finderGet() const
HLT enums.
std::multimap< ParameterSetID, ESProducerInfo > const & esproducers() const
std::multimap< ParameterSetID, ESSourceInfo > const & essources() const
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_