CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
boost::shared_ptr
< DataProxyProvider
getESProducerAndRegisterProcess (ParameterSet const &pset, unsigned subProcessIndex)
 
ParameterSet const * getESProducerPSet (ParameterSetID const &psetID, unsigned subProcessIndex) const
 
boost::shared_ptr
< EventSetupRecordIntervalFinder
getESSourceAndRegisterProcess (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
 
void lookForMatches (ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex, bool &firstProcessWithThisPSet, bool &precedingHasMatchingPSet) const
 
boost::shared_ptr
< EventSetupProvider
makeProvider (ParameterSet &)
 
bool mustFinishConfiguration () const
 
std::vector< boost::shared_ptr
< EventSetupProvider > > const & 
providers () const
 
void putESProducer (ParameterSet const &pset, boost::shared_ptr< DataProxyProvider > const &component, unsigned subProcessIndex)
 
void putESSource (ParameterSet const &pset, boost::shared_ptr< EventSetupRecordIntervalFinder > const &component, unsigned subProcessIndex)
 

Private Member Functions

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

Private Attributes

std::multimap< ParameterSetID,
ESProducerInfo
esproducers_
 
std::multimap< ParameterSetID,
ESSourceInfo
essources_
 
bool mustFinishConfiguration_
 
std::vector< boost::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 29 of file EventSetupsController.cc.

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

Member Function Documentation

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

Definition at line 311 of file EventSetupsController.cc.

References providers_.

Referenced by eventSetupForInstance().

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

Definition at line 131 of file EventSetupsController.cc.

References esproducers_, and essources_.

Referenced by eventSetupForInstance().

131  {
132  esproducers_.clear();
133  essources_.clear();
134  }
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
std::multimap< ParameterSetID, ESSourceInfo > essources_
std::multimap<ParameterSetID, ESProducerInfo> const& edm::eventsetup::EventSetupsController::esproducers ( ) const
inline

Definition at line 121 of file EventSetupsController.h.

References esproducers_.

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

Definition at line 123 of file EventSetupsController.h.

References essources_.

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

Definition at line 50 of file EventSetupsController.cc.

References checkESProducerSharing(), clearComponents(), evf::utils::esp, mustFinishConfiguration_, and providers_.

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

Definition at line 74 of file EventSetupsController.cc.

References evf::utils::esp, and providers_.

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

Definition at line 81 of file EventSetupsController.cc.

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

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

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

Definition at line 289 of file EventSetupsController.cc.

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

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

290  {
291 
292  auto elements = esproducers_.equal_range(psetID);
293  for (auto it = elements.first; it != elements.second; ++it) {
294 
295  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
296 
297  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
298  if (iFound == subProcessIndexes.end()) {
299  continue;
300  }
301  return it->second.pset();
302  }
304  << "EventSetupsController::getESProducerPSet\n"
305  << "Subprocess index not found. This should never happen\n"
306  << "Please report this to a Framework Developer\n";
307  return 0;
308  }
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
list elements
Definition: asciidump.py:414
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
boost::shared_ptr< EventSetupRecordIntervalFinder > edm::eventsetup::EventSetupsController::getESSourceAndRegisterProcess ( ParameterSet const &  pset,
unsigned  subProcessIndex 
)

Definition at line 106 of file EventSetupsController.cc.

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

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

106  {
107  // Try to find a EventSetupRecordIntervalFinder with a matching ParameterSet
108  auto elements = essources_.equal_range(pset.id());
109  for (auto it = elements.first; it != elements.second; ++it) {
110  // Untracked parameters must also match, do complete comparison if IDs match
111  if (isTransientEqual(pset, *it->second.pset())) {
112  // Register processes with an exact match
113  it->second.subProcessIndexes().push_back(subProcessIndex);
114  // Return the EventSetupRecordIntervalFinder
115  return it->second.finder();
116  }
117  }
118  // Could not find it
119  return boost::shared_ptr<EventSetupRecordIntervalFinder>();
120  }
list elements
Definition: asciidump.py:414
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 175 of file EventSetupsController.cc.

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

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

177  {
178 
179  auto elements = esproducers_.equal_range(psetID);
180  for (auto it = elements.first; it != elements.second; ++it) {
181 
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  }
197  << "EventSetupsController::isFirstMatch\n"
198  << "Subprocess index not found. This should never happen\n"
199  << "Please report this to a Framework Developer\n";
200  return false;
201  }
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
list elements
Definition: asciidump.py:414
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
bool edm::eventsetup::EventSetupsController::isLastMatch ( ParameterSetID const &  psetID,
unsigned  subProcessIndex,
unsigned  precedingProcessIndex 
) const

Definition at line 204 of file EventSetupsController.cc.

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

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

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

Definition at line 261 of file EventSetupsController.cc.

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

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

263  {
264  auto elements = esproducers_.equal_range(psetID);
265  for (auto it = elements.first; it != elements.second; ++it) {
266 
267  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
268 
269  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
270  if (iFound == subProcessIndexes.end()) {
271  continue;
272  }
273 
274  auto iFoundPreceding = std::find(subProcessIndexes.begin(), iFound, precedingProcessIndex);
275  if (iFoundPreceding == iFound) {
276  return false;
277  } else {
278  return true;
279  }
280  }
282  << "EventSetupsController::lookForMatchingESSource\n"
283  << "Subprocess index not found. This should never happen\n"
284  << "Please report this to a Framework Developer\n";
285  return false;
286  }
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
list elements
Definition: asciidump.py:414
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
bool edm::eventsetup::EventSetupsController::isMatchingESSource ( ParameterSetID const &  psetID,
unsigned  subProcessIndex,
unsigned  precedingProcessIndex 
) const

Definition at line 233 of file EventSetupsController.cc.

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

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

235  {
236  auto elements = essources_.equal_range(psetID);
237  for (auto it = elements.first; it != elements.second; ++it) {
238 
239  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
240 
241  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
242  if (iFound == subProcessIndexes.end()) {
243  continue;
244  }
245 
246  auto iFoundPreceding = std::find(subProcessIndexes.begin(), iFound, precedingProcessIndex);
247  if (iFoundPreceding == iFound) {
248  return false;
249  } else {
250  return true;
251  }
252  }
254  << "EventSetupsController::lookForMatchingESSource\n"
255  << "Subprocess index not found. This should never happen\n"
256  << "Please report this to a Framework Developer\n";
257  return false;
258  }
list elements
Definition: asciidump.py:414
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::multimap< ParameterSetID, ESSourceInfo > essources_
void edm::eventsetup::EventSetupsController::lookForMatches ( ParameterSetID const &  psetID,
unsigned  subProcessIndex,
unsigned  precedingProcessIndex,
bool &  firstProcessWithThisPSet,
bool &  precedingHasMatchingPSet 
) const

Definition at line 137 of file EventSetupsController.cc.

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

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

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

Definition at line 33 of file EventSetupsController.cc.

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

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

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

Definition at line 119 of file EventSetupsController.h.

References providers_.

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

Definition at line 98 of file EventSetupsController.cc.

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

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

98  {
99  auto newElement = esproducers_.insert(std::pair<ParameterSetID, ESProducerInfo>(pset.id(),
100  ESProducerInfo(&pset, component)));
101  // Register processes with an exact match
102  newElement->second.subProcessIndexes().push_back(subProcessIndex);
103  }
std::multimap< ParameterSetID, ESProducerInfo > esproducers_
void edm::eventsetup::EventSetupsController::putESSource ( ParameterSet const &  pset,
boost::shared_ptr< EventSetupRecordIntervalFinder > const &  component,
unsigned  subProcessIndex 
)

Definition at line 123 of file EventSetupsController.cc.

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

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

123  {
124  auto newElement = essources_.insert(std::pair<ParameterSetID, ESSourceInfo>(pset.id(),
125  ESSourceInfo(&pset, component)));
126  // Register processes with an exact match
127  newElement->second.subProcessIndexes().push_back(subProcessIndex);
128  }
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 150 of file EventSetupsController.h.

Referenced by eventSetupForInstance(), and mustFinishConfiguration().

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