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 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 73 of file EventSetupsController.h.

Constructor & Destructor Documentation

edm::eventsetup::EventSetupsController::EventSetupsController ( )

Definition at line 28 of file EventSetupsController.cc.

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

Member Function Documentation

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

Definition at line 320 of file EventSetupsController.cc.

References providers_.

Referenced by eventSetupForInstance().

320  {
321 
322  // Loop over SubProcesses, skip the top level process.
323  auto esProvider = providers_.begin();
324  auto esProviderEnd = providers_.end();
325  if (esProvider != esProviderEnd) ++esProvider;
326  for ( ; esProvider != esProviderEnd; ++esProvider) {
327 
328  // An element is added to this set for each ESProducer
329  // when we have determined which preceding process
330  // this process can share that ESProducer with or
331  // we have determined that it cannot be shared with
332  // any preceding process.
333  // Note the earliest possible preceding process
334  // will be the one selected if there is more than one.
335  std::set<ParameterSetIDHolder> sharingCheckDone;
336 
337  // This will hold an entry for DataProxy's that are
338  // referenced by an EventSetupRecord in this SubProcess.
339  // But only for DataProxy's that are associated with
340  // an ESProducer (not the ones associated with ESSource's
341  // or EDLooper's)
342  std::map<EventSetupRecordKey, std::vector<ComponentDescription const*> > referencedESProducers;
343 
344  // For each EventSetupProvider from a SubProcess, loop over the
345  // EventSetupProviders from the preceding processes (the first
346  // preceding process will be the top level process and the others
347  // SubProcess's)
348  for (auto precedingESProvider = providers_.begin();
349  precedingESProvider != esProvider;
350  ++precedingESProvider) {
351 
352  (*esProvider)->checkESProducerSharing(**precedingESProvider, sharingCheckDone, referencedESProducers, *this);
353  }
354 
355  (*esProvider)->resetRecordToProxyPointers();
356  }
357  esProvider = providers_.begin();
358  for ( ; esProvider != esProviderEnd; ++esProvider) {
359  (*esProvider)->clearInitializationData();
360  }
361  }
std::vector< std::shared_ptr< EventSetupProvider > > providers_
void edm::eventsetup::EventSetupsController::clearComponents ( )

Definition at line 140 of file EventSetupsController.cc.

References esproducers_, and essources_.

Referenced by eventSetupForInstance().

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

Definition at line 123 of file EventSetupsController.h.

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

Definition at line 125 of file EventSetupsController.h.

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

Definition at line 49 of file EventSetupsController.cc.

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

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

Definition at line 73 of file EventSetupsController.cc.

References providers_.

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

Definition at line 90 of file EventSetupsController.cc.

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

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

90  {
91  // Try to find a DataProxyProvider with a matching ParameterSet
92  auto elements = esproducers_.equal_range(pset.id());
93  for (auto it = elements.first; it != elements.second; ++it) {
94  // Untracked parameters must also match, do complete comparison if IDs match
95  if (isTransientEqual(pset, *it->second.pset())) {
96  // Register processes with an exact match
97  it->second.subProcessIndexes().push_back(subProcessIndex);
98  // Return the DataProxyProvider
99  return it->second.provider();
100  }
101  }
102  // Could not find it
103  return std::shared_ptr<DataProxyProvider>();
104  }
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 298 of file EventSetupsController.cc.

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

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

299  {
300 
301  auto elements = esproducers_.equal_range(psetID);
302  for (auto it = elements.first; it != elements.second; ++it) {
303 
304  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
305 
306  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
307  if (iFound == subProcessIndexes.end()) {
308  continue;
309  }
310  return it->second.pset();
311  }
313  << "EventSetupsController::getESProducerPSet\n"
314  << "Subprocess index not found. This should never happen\n"
315  << "Please report this to a Framework Developer\n";
316  return nullptr;
317  }
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 115 of file EventSetupsController.cc.

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

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

115  {
116  // Try to find a EventSetupRecordIntervalFinder with a matching ParameterSet
117  auto elements = essources_.equal_range(pset.id());
118  for (auto it = elements.first; it != elements.second; ++it) {
119  // Untracked parameters must also match, do complete comparison if IDs match
120  if (isTransientEqual(pset, *it->second.pset())) {
121  // Register processes with an exact match
122  it->second.subProcessIndexes().push_back(subProcessIndex);
123  // Return the EventSetupRecordIntervalFinder
124  return it->second.finder();
125  }
126  }
127  // Could not find it
128  return std::shared_ptr<EventSetupRecordIntervalFinder>();
129  }
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 184 of file EventSetupsController.cc.

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

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

186  {
187 
188  auto elements = esproducers_.equal_range(psetID);
189  for (auto it = elements.first; it != elements.second; ++it) {
190 
191  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
192 
193  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
194  if (iFound == subProcessIndexes.end()) {
195  continue;
196  }
197 
198  auto iFoundPreceding = std::find(subProcessIndexes.begin(), iFound, precedingProcessIndex);
199  if (iFoundPreceding == iFound) {
200  break;
201  } else {
202  return iFoundPreceding == subProcessIndexes.begin();
203  }
204  }
206  << "EventSetupsController::isFirstMatch\n"
207  << "Subprocess index not found. This should never happen\n"
208  << "Please report this to a Framework Developer\n";
209  return false;
210  }
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 213 of file EventSetupsController.cc.

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

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

215  {
216 
217  auto elements = esproducers_.equal_range(psetID);
218  for (auto it = elements.first; it != elements.second; ++it) {
219 
220  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
221 
222  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
223  if (iFound == subProcessIndexes.end()) {
224  continue;
225  }
226 
227  auto iFoundPreceding = std::find(subProcessIndexes.begin(), iFound, precedingProcessIndex);
228  if (iFoundPreceding == iFound) {
229  break;
230  } else {
231  return (++iFoundPreceding) == iFound;
232  }
233  }
235  << "EventSetupsController::isLastMatch\n"
236  << "Subprocess index not found. This should never happen\n"
237  << "Please report this to a Framework Developer\n";
238  return false;
239  }
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 270 of file EventSetupsController.cc.

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

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

272  {
273  auto elements = esproducers_.equal_range(psetID);
274  for (auto it = elements.first; it != elements.second; ++it) {
275 
276  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
277 
278  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
279  if (iFound == subProcessIndexes.end()) {
280  continue;
281  }
282 
283  auto iFoundPreceding = std::find(subProcessIndexes.begin(), iFound, precedingProcessIndex);
284  if (iFoundPreceding == iFound) {
285  return false;
286  } else {
287  return true;
288  }
289  }
291  << "EventSetupsController::lookForMatchingESSource\n"
292  << "Subprocess index not found. This should never happen\n"
293  << "Please report this to a Framework Developer\n";
294  return false;
295  }
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 242 of file EventSetupsController.cc.

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

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

244  {
245  auto elements = essources_.equal_range(psetID);
246  for (auto it = elements.first; it != elements.second; ++it) {
247 
248  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
249 
250  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
251  if (iFound == subProcessIndexes.end()) {
252  continue;
253  }
254 
255  auto iFoundPreceding = std::find(subProcessIndexes.begin(), iFound, precedingProcessIndex);
256  if (iFoundPreceding == iFound) {
257  return false;
258  } else {
259  return true;
260  }
261  }
263  << "EventSetupsController::lookForMatchingESSource\n"
264  << "Subprocess index not found. This should never happen\n"
265  << "Please report this to a Framework Developer\n";
266  return false;
267  }
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 80 of file EventSetupsController.cc.

References providers_.

80  {
81  for(auto const& provider: providers_) {
82  if( not provider->isWithinValidityInterval(syncValue)) {
83  return false;
84  }
85  }
86  return true;
87  }
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 146 of file EventSetupsController.cc.

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

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

150  {
151 
152  auto elements = esproducers_.equal_range(psetID);
153  for (auto it = elements.first; it != elements.second; ++it) {
154 
155  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
156 
157  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
158  if (iFound == subProcessIndexes.end()) {
159  continue;
160  }
161 
162  if (iFound == subProcessIndexes.begin()) {
163  firstProcessWithThisPSet = true;
164  precedingHasMatchingPSet = false;
165  } else {
166  auto iFoundPreceding = std::find(subProcessIndexes.begin(), iFound, precedingProcessIndex);
167  if (iFoundPreceding == iFound) {
168  firstProcessWithThisPSet = false;
169  precedingHasMatchingPSet = false;
170  } else {
171  firstProcessWithThisPSet = false;
172  precedingHasMatchingPSet = true;
173  }
174  }
175  return;
176  }
178  << "EventSetupsController::lookForMatches\n"
179  << "Subprocess index not found. This should never happen\n"
180  << "Please report this to a Framework Developer\n";
181  }
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 32 of file EventSetupsController.cc.

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

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

32  {
33 
34  // Makes an EventSetupProvider
35  // Also parses the prefer information from ParameterSets and puts
36  // it in a map that is stored in the EventSetupProvider
37  std::shared_ptr<EventSetupProvider> returnValue(makeEventSetupProvider(iPSet, providers_.size(), activityRegistry) );
38 
39  // Construct the ESProducers and ESSources
40  // shared_ptrs to them are temporarily stored in this
41  // EventSetupsController and in the EventSetupProvider
42  fillEventSetupProvider(*this, *returnValue, iPSet);
43 
44  providers_.push_back(returnValue);
45  return returnValue;
46  }
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 121 of file EventSetupsController.h.

121 { 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 107 of file EventSetupsController.cc.

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

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

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

Definition at line 132 of file EventSetupsController.cc.

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

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

132  {
133  auto newElement = essources_.insert(std::pair<ParameterSetID, ESSourceInfo>(pset.id(),
134  ESSourceInfo(&pset, component)));
135  // Register processes with an exact match
136  newElement->second.subProcessIndexes().push_back(subProcessIndex);
137  }
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 152 of file EventSetupsController.h.

Referenced by eventSetupForInstance().

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