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 
84  EventSetupsController const& operator=(EventSetupsController const&) = delete;
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.
104  void eventSetupForInstance(IOVSyncValue const&,
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 
159  bool hasNonconcurrentFinder() const { return hasNonconcurrentFinder_; }
160  bool mustFinishConfiguration() const { return mustFinishConfiguration_; }
161 
162  private:
163  void checkESProducerSharing();
164  void initializeEventSetupRecordIOVQueues();
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 
187  bool hasNonconcurrentFinder_ = false;
188  bool mustFinishConfiguration_ = true;
189  };
190  } // namespace eventsetup
191 } // namespace edm
192 #endif
std::shared_ptr< EventSetupRecordIntervalFinder > const & finder()
std::vector< unsigned > const & subProcessIndexes() const
std::vector< unsigned > subProcessIndexes_
ParameterSet const * pset() const
std::vector< propagate_const< std::unique_ptr< EventSetupRecordIOVQueue > > > eventSetupRecordIOVQueues_
std::vector< unsigned > & subProcessIndexes()
std::multimap< ParameterSetID, ESSourceInfo > const & essources() const
Definition: Hash.h:43
std::vector< unsigned > & subProcessIndexes()
std::vector< unsigned > const & subProcessIndexes() const
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
std::vector< propagate_const< std::shared_ptr< EventSetupProvider > > > const & providers() const
std::multimap< ParameterSetID, ESProducerInfo > const & esproducers() const
T & get_underlying(propagate_const< T > &)
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)
propagate_const< std::shared_ptr< DataProxyProvider > > provider_
ESSourceInfo(ParameterSet const *ps, std::shared_ptr< EventSetupRecordIntervalFinder > const &fi)
std::vector< unsigned > subProcessIndexes_
HLT enums.
propagate_const< std::shared_ptr< EventSetupRecordIntervalFinder > > finder_
EventSetupRecordIntervalFinder const * finderGet() const
std::vector< propagate_const< std::shared_ptr< EventSetupProvider > > > providers_
ParameterSet const * pset() const