CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
edm::eventsetup::EventSetupsController Class Reference

#include <EventSetupsController.h>

Public Member Functions

void clearComponents ()
 
std::multimap< ParameterSetID, ESProducerInfo > const & esproducers () const
 
std::multimap< ParameterSetID, ESSourceInfo > const & essources () const
 
void eventSetupForInstance (IOVSyncValue const &syncValue)
 
 EventSetupsController ()
 
void finishConfiguration ()
 
void forceCacheClear () const
 
std::shared_ptr< DataProxyProvidergetESProducerAndRegisterProcess (ParameterSet const &pset, unsigned subProcessIndex)
 
ParameterSet const * getESProducerPSet (ParameterSetID const &psetID, unsigned subProcessIndex) const
 
std::shared_ptr< EventSetupRecordIntervalFindergetESSourceAndRegisterProcess (ParameterSet const &pset, unsigned subProcessIndex)
 
unsigned indexOfNextProcess () const
 
bool isFirstMatch (ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
 
bool isLastMatch (ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
 
bool isMatchingESProducer (ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
 
bool isMatchingESSource (ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
 
bool isWithinValidityInterval (IOVSyncValue const &syncValue) const
 
void lookForMatches (ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex, bool &firstProcessWithThisPSet, bool &precedingHasMatchingPSet) const
 
std::shared_ptr< EventSetupProvidermakeProvider (ParameterSet &, ActivityRegistry *)
 
bool mustFinishConfiguration () const
 
std::vector< std::shared_ptr< EventSetupProvider > > const & providers () const
 
void putESProducer (ParameterSet const &pset, std::shared_ptr< DataProxyProvider > const &component, unsigned subProcessIndex)
 
void putESSource (ParameterSet const &pset, std::shared_ptr< EventSetupRecordIntervalFinder > const &component, unsigned subProcessIndex)
 

Private Member Functions

void checkESProducerSharing ()
 
 EventSetupsController (EventSetupsController const &)=delete
 
EventSetupsController const & operator= (EventSetupsController const &)=delete
 

Private Attributes

std::multimap< ParameterSetID, ESProducerInfoesproducers_
 
std::multimap< ParameterSetID, ESSourceInfoessources_
 
bool mustFinishConfiguration_
 
std::vector< std::shared_ptr< EventSetupProvider > > providers_
 

Detailed Description

Description: Manages a group of EventSetups which can share components

Usage: <usage>

Definition at line 71 of file EventSetupsController.h.

Constructor & Destructor Documentation

edm::eventsetup::EventSetupsController::EventSetupsController ( )
edm::eventsetup::EventSetupsController::EventSetupsController ( EventSetupsController const &  )
privatedelete

Member Function Documentation

void edm::eventsetup::EventSetupsController::checkESProducerSharing ( )
private

Definition at line 295 of file EventSetupsController.cc.

References providers_.

Referenced by finishConfiguration().

295  {
296  // Loop over SubProcesses, skip the top level process.
297  auto esProvider = providers_.begin();
298  auto const esProviderEnd = providers_.end();
299  if (esProvider != esProviderEnd)
300  ++esProvider;
301  for (; esProvider != esProviderEnd; ++esProvider) {
302  // An element is added to this set for each ESProducer
303  // when we have determined which preceding process
304  // this process can share that ESProducer with or
305  // we have determined that it cannot be shared with
306  // any preceding process.
307  // Note the earliest possible preceding process
308  // will be the one selected if there is more than one.
309  std::set<ParameterSetIDHolder> sharingCheckDone;
310 
311  // This will hold an entry for DataProxy's that are
312  // referenced by an EventSetupRecord in this SubProcess.
313  // But only for DataProxy's that are associated with
314  // an ESProducer (not the ones associated with ESSource's
315  // or EDLooper's)
316  std::map<EventSetupRecordKey, std::vector<ComponentDescription const*> > referencedESProducers;
317 
318  // For each EventSetupProvider from a SubProcess, loop over the
319  // EventSetupProviders from the preceding processes (the first
320  // preceding process will be the top level process and the others
321  // SubProcess's)
322  for (auto precedingESProvider = providers_.begin(); precedingESProvider != esProvider; ++precedingESProvider) {
323  (*esProvider)->checkESProducerSharing(**precedingESProvider, sharingCheckDone, referencedESProducers, *this);
324  }
325 
326  (*esProvider)->resetRecordToProxyPointers();
327  }
328  esProvider = providers_.begin();
329  for (; esProvider != esProviderEnd; ++esProvider) {
330  (*esProvider)->clearInitializationData();
331  }
332  }
std::vector< std::shared_ptr< EventSetupProvider > > providers_
void edm::eventsetup::EventSetupsController::clearComponents ( )

Definition at line 138 of file EventSetupsController.cc.

References esproducers_, and essources_.

Referenced by finishConfiguration().

138  {
139  esproducers_.clear();
140  essources_.clear();
141  }
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
std::multimap< ParameterSetID, ESSourceInfo > essources_
std::multimap<ParameterSetID, ESProducerInfo> const& edm::eventsetup::EventSetupsController::esproducers ( ) const
inline

Definition at line 122 of file EventSetupsController.h.

122 { return esproducers_; }
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
std::multimap<ParameterSetID, ESSourceInfo> const& edm::eventsetup::EventSetupsController::essources ( ) const
inline

Definition at line 124 of file EventSetupsController.h.

124 { return essources_; }
std::multimap< ParameterSetID, ESSourceInfo > essources_
void edm::eventsetup::EventSetupsController::eventSetupForInstance ( IOVSyncValue const &  syncValue)

Definition at line 64 of file EventSetupsController.cc.

References finishConfiguration(), and providers_.

64  {
66  std::for_each(providers_.begin(), providers_.end(), [&syncValue](std::shared_ptr<EventSetupProvider> const& esp) {
67  esp->eventSetupForInstance(syncValue);
68  });
69  }
std::vector< std::shared_ptr< EventSetupProvider > > providers_
void edm::eventsetup::EventSetupsController::finishConfiguration ( )

Definition at line 47 of file EventSetupsController.cc.

References checkESProducerSharing(), clearComponents(), mustFinishConfiguration_, and providers_.

Referenced by eventSetupForInstance().

47  {
49  std::for_each(providers_.begin(), providers_.end(), [](std::shared_ptr<EventSetupProvider> const& esp) {
50  esp->finishConfiguration();
51  });
52  // When the ESSources and ESProducers were constructed a first pass was
53  // done which attempts to get component sharing between SubProcesses
54  // correct, but in this pass only the configuration of the components
55  // being shared are compared. This is not good enough for ESProducers.
56  // In the following function, all the other components that contribute
57  // to the same record and also the records that record depends on are
58  // also checked. The component sharing is appropriately fixed as necessary.
62  }
63  }
std::vector< std::shared_ptr< EventSetupProvider > > providers_
void edm::eventsetup::EventSetupsController::forceCacheClear ( ) const

Definition at line 71 of file EventSetupsController.cc.

References providers_.

71  {
72  std::for_each(providers_.begin(), providers_.end(), [](std::shared_ptr<EventSetupProvider> const& esp) {
73  esp->forceCacheClear();
74  });
75  }
std::vector< std::shared_ptr< EventSetupProvider > > providers_
std::shared_ptr< DataProxyProvider > edm::eventsetup::EventSetupsController::getESProducerAndRegisterProcess ( ParameterSet const &  pset,
unsigned  subProcessIndex 
)

Definition at line 86 of file EventSetupsController.cc.

References allElectronIsolations_cfi::elements, esproducers_, edm::ParameterSet::id(), and edm::isTransientEqual().

Referenced by edm::eventsetup::ModuleMakerTraits::getComponentAndRegisterProcess().

87  {
88  // Try to find a DataProxyProvider with a matching ParameterSet
89  auto elements = esproducers_.equal_range(pset.id());
90  for (auto it = elements.first; it != elements.second; ++it) {
91  // Untracked parameters must also match, do complete comparison if IDs match
92  if (isTransientEqual(pset, *it->second.pset())) {
93  // Register processes with an exact match
94  it->second.subProcessIndexes().push_back(subProcessIndex);
95  // Return the DataProxyProvider
96  return it->second.provider();
97  }
98  }
99  // Could not find it
100  return std::shared_ptr<DataProxyProvider>();
101  }
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
bool isTransientEqual(ParameterSet const &a, ParameterSet const &b)
ParameterSet const * edm::eventsetup::EventSetupsController::getESProducerPSet ( ParameterSetID const &  psetID,
unsigned  subProcessIndex 
) const

Definition at line 277 of file EventSetupsController.cc.

References allElectronIsolations_cfi::elements, esproducers_, Exception, spr::find(), and edm::errors::LogicError.

Referenced by edm::eventsetup::EventSetupProvider::checkESProducerSharing().

278  {
279  auto elements = esproducers_.equal_range(psetID);
280  for (auto it = elements.first; it != elements.second; ++it) {
281  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
282 
283  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
284  if (iFound == subProcessIndexes.end()) {
285  continue;
286  }
287  return it->second.pset();
288  }
289  throw edm::Exception(edm::errors::LogicError) << "EventSetupsController::getESProducerPSet\n"
290  << "Subprocess index not found. This should never happen\n"
291  << "Please report this to a Framework Developer\n";
292  return nullptr;
293  }
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::shared_ptr< EventSetupRecordIntervalFinder > edm::eventsetup::EventSetupsController::getESSourceAndRegisterProcess ( ParameterSet const &  pset,
unsigned  subProcessIndex 
)

Definition at line 112 of file EventSetupsController.cc.

References allElectronIsolations_cfi::elements, essources_, edm::ParameterSet::id(), and edm::isTransientEqual().

Referenced by edm::eventsetup::SourceMakerTraits::getComponentAndRegisterProcess().

113  {
114  // Try to find a EventSetupRecordIntervalFinder with a matching ParameterSet
115  auto elements = essources_.equal_range(pset.id());
116  for (auto it = elements.first; it != elements.second; ++it) {
117  // Untracked parameters must also match, do complete comparison if IDs match
118  if (isTransientEqual(pset, *it->second.pset())) {
119  // Register processes with an exact match
120  it->second.subProcessIndexes().push_back(subProcessIndex);
121  // Return the EventSetupRecordIntervalFinder
122  return it->second.finder();
123  }
124  }
125  // Could not find it
126  return std::shared_ptr<EventSetupRecordIntervalFinder>();
127  }
std::multimap< ParameterSetID, ESSourceInfo > essources_
bool isTransientEqual(ParameterSet const &a, ParameterSet const &b)
unsigned edm::eventsetup::EventSetupsController::indexOfNextProcess ( ) const
inline
bool edm::eventsetup::EventSetupsController::isFirstMatch ( ParameterSetID const &  psetID,
unsigned  subProcessIndex,
unsigned  precedingProcessIndex 
) const

Definition at line 177 of file EventSetupsController.cc.

References allElectronIsolations_cfi::elements, esproducers_, Exception, spr::find(), and edm::errors::LogicError.

Referenced by edm::eventsetup::EventSetupProvider::checkESProducerSharing().

179  {
180  auto elements = esproducers_.equal_range(psetID);
181  for (auto it = elements.first; it != elements.second; ++it) {
182  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
183 
184  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
185  if (iFound == subProcessIndexes.end()) {
186  continue;
187  }
188 
189  auto iFoundPreceding = std::find(subProcessIndexes.begin(), iFound, precedingProcessIndex);
190  if (iFoundPreceding == iFound) {
191  break;
192  } else {
193  return iFoundPreceding == subProcessIndexes.begin();
194  }
195  }
196  throw edm::Exception(edm::errors::LogicError) << "EventSetupsController::isFirstMatch\n"
197  << "Subprocess index not found. This should never happen\n"
198  << "Please report this to a Framework Developer\n";
199  return false;
200  }
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
bool edm::eventsetup::EventSetupsController::isLastMatch ( ParameterSetID const &  psetID,
unsigned  subProcessIndex,
unsigned  precedingProcessIndex 
) const

Definition at line 202 of file EventSetupsController.cc.

References allElectronIsolations_cfi::elements, esproducers_, Exception, spr::find(), and edm::errors::LogicError.

Referenced by edm::eventsetup::EventSetupProvider::checkESProducerSharing().

204  {
205  auto elements = esproducers_.equal_range(psetID);
206  for (auto it = elements.first; it != elements.second; ++it) {
207  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
208 
209  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
210  if (iFound == subProcessIndexes.end()) {
211  continue;
212  }
213 
214  auto iFoundPreceding = std::find(subProcessIndexes.begin(), iFound, precedingProcessIndex);
215  if (iFoundPreceding == iFound) {
216  break;
217  } else {
218  return (++iFoundPreceding) == iFound;
219  }
220  }
221  throw edm::Exception(edm::errors::LogicError) << "EventSetupsController::isLastMatch\n"
222  << "Subprocess index not found. This should never happen\n"
223  << "Please report this to a Framework Developer\n";
224  return false;
225  }
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
bool edm::eventsetup::EventSetupsController::isMatchingESProducer ( ParameterSetID const &  psetID,
unsigned  subProcessIndex,
unsigned  precedingProcessIndex 
) const

Definition at line 252 of file EventSetupsController.cc.

References allElectronIsolations_cfi::elements, esproducers_, Exception, spr::find(), and edm::errors::LogicError.

Referenced by edm::eventsetup::EventSetupProvider::doRecordsMatch().

254  {
255  auto elements = esproducers_.equal_range(psetID);
256  for (auto it = elements.first; it != elements.second; ++it) {
257  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
258 
259  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
260  if (iFound == subProcessIndexes.end()) {
261  continue;
262  }
263 
264  auto iFoundPreceding = std::find(subProcessIndexes.begin(), iFound, precedingProcessIndex);
265  if (iFoundPreceding == iFound) {
266  return false;
267  } else {
268  return true;
269  }
270  }
271  throw edm::Exception(edm::errors::LogicError) << "EventSetupsController::lookForMatchingESSource\n"
272  << "Subprocess index not found. This should never happen\n"
273  << "Please report this to a Framework Developer\n";
274  return false;
275  }
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
bool edm::eventsetup::EventSetupsController::isMatchingESSource ( ParameterSetID const &  psetID,
unsigned  subProcessIndex,
unsigned  precedingProcessIndex 
) const

Definition at line 227 of file EventSetupsController.cc.

References allElectronIsolations_cfi::elements, essources_, Exception, spr::find(), and edm::errors::LogicError.

Referenced by edm::eventsetup::EventSetupProvider::doRecordsMatch().

229  {
230  auto elements = essources_.equal_range(psetID);
231  for (auto it = elements.first; it != elements.second; ++it) {
232  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
233 
234  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
235  if (iFound == subProcessIndexes.end()) {
236  continue;
237  }
238 
239  auto iFoundPreceding = std::find(subProcessIndexes.begin(), iFound, precedingProcessIndex);
240  if (iFoundPreceding == iFound) {
241  return false;
242  } else {
243  return true;
244  }
245  }
246  throw edm::Exception(edm::errors::LogicError) << "EventSetupsController::lookForMatchingESSource\n"
247  << "Subprocess index not found. This should never happen\n"
248  << "Please report this to a Framework Developer\n";
249  return false;
250  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::multimap< ParameterSetID, ESSourceInfo > essources_
bool edm::eventsetup::EventSetupsController::isWithinValidityInterval ( IOVSyncValue const &  syncValue) const

Definition at line 77 of file EventSetupsController.cc.

References providers_.

77  {
78  for (auto const& provider : providers_) {
79  if (not provider->isWithinValidityInterval(syncValue)) {
80  return false;
81  }
82  }
83  return true;
84  }
std::vector< std::shared_ptr< EventSetupProvider > > providers_
void edm::eventsetup::EventSetupsController::lookForMatches ( ParameterSetID const &  psetID,
unsigned  subProcessIndex,
unsigned  precedingProcessIndex,
bool &  firstProcessWithThisPSet,
bool &  precedingHasMatchingPSet 
) const

Definition at line 143 of file EventSetupsController.cc.

References allElectronIsolations_cfi::elements, esproducers_, Exception, spr::find(), and edm::errors::LogicError.

Referenced by edm::eventsetup::EventSetupProvider::checkESProducerSharing().

147  {
148  auto elements = esproducers_.equal_range(psetID);
149  for (auto it = elements.first; it != elements.second; ++it) {
150  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
151 
152  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
153  if (iFound == subProcessIndexes.end()) {
154  continue;
155  }
156 
157  if (iFound == subProcessIndexes.begin()) {
158  firstProcessWithThisPSet = true;
159  precedingHasMatchingPSet = false;
160  } else {
161  auto iFoundPreceding = std::find(subProcessIndexes.begin(), iFound, precedingProcessIndex);
162  if (iFoundPreceding == iFound) {
163  firstProcessWithThisPSet = false;
164  precedingHasMatchingPSet = false;
165  } else {
166  firstProcessWithThisPSet = false;
167  precedingHasMatchingPSet = true;
168  }
169  }
170  return;
171  }
172  throw edm::Exception(edm::errors::LogicError) << "EventSetupsController::lookForMatches\n"
173  << "Subprocess index not found. This should never happen\n"
174  << "Please report this to a Framework Developer\n";
175  }
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::shared_ptr< EventSetupProvider > edm::eventsetup::EventSetupsController::makeProvider ( ParameterSet iPSet,
ActivityRegistry activityRegistry 
)

Definition at line 30 of file EventSetupsController.cc.

References edm::eventsetup::fillEventSetupProvider(), edm::eventsetup::makeEventSetupProvider(), and providers_.

Referenced by edm::SubProcess::SubProcess().

31  {
32  // Makes an EventSetupProvider
33  // Also parses the prefer information from ParameterSets and puts
34  // it in a map that is stored in the EventSetupProvider
35  std::shared_ptr<EventSetupProvider> returnValue(
36  makeEventSetupProvider(iPSet, providers_.size(), activityRegistry));
37 
38  // Construct the ESProducers and ESSources
39  // shared_ptrs to them are temporarily stored in this
40  // EventSetupsController and in the EventSetupProvider
41  fillEventSetupProvider(*this, *returnValue, iPSet);
42 
43  providers_.push_back(returnValue);
44  return returnValue;
45  }
void fillEventSetupProvider(EventSetupsController &esController, EventSetupProvider &cp, ParameterSet &params)
std::unique_ptr< EventSetupProvider > makeEventSetupProvider(ParameterSet const &params, unsigned subProcessIndex, ActivityRegistry *)
std::vector< std::shared_ptr< EventSetupProvider > > providers_
bool edm::eventsetup::EventSetupsController::mustFinishConfiguration ( ) const
inline
EventSetupsController const& edm::eventsetup::EventSetupsController::operator= ( EventSetupsController const &  )
privatedelete
std::vector<std::shared_ptr<EventSetupProvider> > const& edm::eventsetup::EventSetupsController::providers ( ) const
inline

Definition at line 120 of file EventSetupsController.h.

120 { return providers_; }
std::vector< std::shared_ptr< EventSetupProvider > > providers_
void edm::eventsetup::EventSetupsController::putESProducer ( ParameterSet const &  pset,
std::shared_ptr< DataProxyProvider > const &  component,
unsigned  subProcessIndex 
)

Definition at line 103 of file EventSetupsController.cc.

References esproducers_, and edm::ParameterSet::id().

Referenced by edm::eventsetup::ModuleMakerTraits::putComponent().

105  {
106  auto newElement =
107  esproducers_.insert(std::pair<ParameterSetID, ESProducerInfo>(pset.id(), ESProducerInfo(&pset, component)));
108  // Register processes with an exact match
109  newElement->second.subProcessIndexes().push_back(subProcessIndex);
110  }
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
void edm::eventsetup::EventSetupsController::putESSource ( ParameterSet const &  pset,
std::shared_ptr< EventSetupRecordIntervalFinder > const &  component,
unsigned  subProcessIndex 
)

Definition at line 129 of file EventSetupsController.cc.

References essources_, and edm::ParameterSet::id().

Referenced by edm::eventsetup::SourceMakerTraits::putComponent().

131  {
132  auto newElement =
133  essources_.insert(std::pair<ParameterSetID, ESSourceInfo>(pset.id(), ESSourceInfo(&pset, component)));
134  // Register processes with an exact match
135  newElement->second.subProcessIndexes().push_back(subProcessIndex);
136  }
std::multimap< ParameterSetID, ESSourceInfo > essources_

Member Data Documentation

std::multimap<ParameterSetID, ESProducerInfo> edm::eventsetup::EventSetupsController::esproducers_
private
std::multimap<ParameterSetID, ESSourceInfo> edm::eventsetup::EventSetupsController::essources_
private
bool edm::eventsetup::EventSetupsController::mustFinishConfiguration_
private

Definition at line 151 of file EventSetupsController.h.

Referenced by finishConfiguration().

std::vector<std::shared_ptr<EventSetupProvider> > edm::eventsetup::EventSetupsController::providers_
private