CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
std::shared_ptr< EventSetupRecordIntervalFinder > const & finder()
void lookForMatches(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex, bool &firstProcessWithThisPSet, bool &precedingHasMatchingPSet) const
std::shared_ptr< EventSetupRecordIntervalFinder > getESSourceAndRegisterProcess(ParameterSet const &pset, unsigned subProcessIndex)
std::vector< unsigned > const & subProcessIndexes() const
bool isFirstMatch(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
std::vector< unsigned > subProcessIndexes_
ParameterSet const * pset() const
bool isMatchingESProducer(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
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::multimap< ParameterSetID, ESSourceInfo > const & essources() const
std::vector< unsigned > & subProcessIndexes()
std::vector< unsigned > const & subProcessIndexes() const
void putESProducer(ParameterSet const &pset, std::shared_ptr< DataProxyProvider > const &component, unsigned subProcessIndex)
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
bool isLastMatch(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
std::vector< propagate_const< std::shared_ptr< EventSetupProvider > > > const & providers() const
ParameterSet const * getESProducerPSet(ParameterSetID const &psetID, unsigned subProcessIndex) const
std::multimap< ParameterSetID, ESProducerInfo > const & esproducers() const
std::shared_ptr< DataProxyProvider > getESProducerAndRegisterProcess(ParameterSet const &pset, unsigned subProcessIndex)
void synchronousEventSetupForInstance(IOVSyncValue const &syncValue, tbb::task_group &iGroup, eventsetup::EventSetupsController &espController)
std::shared_ptr< DataProxyProvider > const & provider()
DataProxyProvider const * providerGet() const
std::multimap< ParameterSetID, ESSourceInfo > essources_
ESProducerInfo(ParameterSet const *ps, std::shared_ptr< DataProxyProvider > const &pr)
std::shared_ptr< EventSetupProvider > makeProvider(ParameterSet &, ActivityRegistry *, ParameterSet const *eventSetupPset=nullptr, unsigned int maxConcurrentIOVs=0, bool dumpOptions=false)
bool doWeNeedToWaitForIOVsToFinish(IOVSyncValue const &) const
propagate_const< std::shared_ptr< DataProxyProvider > > provider_
void eventSetupForInstanceAsync(IOVSyncValue const &, WaitingTaskHolder const &taskToStartAfterIOVInit, WaitingTaskList &endIOVWaitingTasks, std::vector< std::shared_ptr< const EventSetupImpl >> &)
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 > &)
void endIOVsAsync(edm::WaitingTaskHolder iEndTask)
bool isMatchingESSource(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
propagate_const< std::shared_ptr< EventSetupRecordIntervalFinder > > finder_
EventSetupRecordIntervalFinder const * finderGet() const
std::vector< propagate_const< std::shared_ptr< EventSetupProvider > > > providers_
ParameterSet const * pset() const