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 28 of file EventSetupsController.cc.

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

Member Function Documentation

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

Definition at line 310 of file EventSetupsController.cc.

References providers_.

Referenced by eventSetupForInstance().

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

Definition at line 130 of file EventSetupsController.cc.

References esproducers_, and essources_.

Referenced by eventSetupForInstance().

130  {
131  esproducers_.clear();
132  essources_.clear();
133  }
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 49 of file EventSetupsController.cc.

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

49  {
50 
52  std::for_each(providers_.begin(), providers_.end(), [](boost::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](boost::shared_ptr<EventSetupProvider> const& esp) {
68  esp->eventSetupForInstance(syncValue);
69  });
70  }
std::vector< boost::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(), [](boost::shared_ptr<EventSetupProvider> const& esp) {
75  esp->forceCacheClear();
76  });
77  }
std::vector< boost::shared_ptr< EventSetupProvider > > providers_
boost::shared_ptr< DataProxyProvider > edm::eventsetup::EventSetupsController::getESProducerAndRegisterProcess ( ParameterSet const &  pset,
unsigned  subProcessIndex 
)

Definition at line 80 of file EventSetupsController.cc.

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

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

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

Definition at line 288 of file EventSetupsController.cc.

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

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

289  {
290 
291  auto elements = esproducers_.equal_range(psetID);
292  for (auto it = elements.first; it != elements.second; ++it) {
293 
294  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
295 
296  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
297  if (iFound == subProcessIndexes.end()) {
298  continue;
299  }
300  return it->second.pset();
301  }
303  << "EventSetupsController::getESProducerPSet\n"
304  << "Subprocess index not found. This should never happen\n"
305  << "Please report this to a Framework Developer\n";
306  return 0;
307  }
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:7
dictionary elements
boost::shared_ptr< EventSetupRecordIntervalFinder > edm::eventsetup::EventSetupsController::getESSourceAndRegisterProcess ( ParameterSet const &  pset,
unsigned  subProcessIndex 
)

Definition at line 105 of file EventSetupsController.cc.

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

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

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

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

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

176  {
177 
178  auto elements = esproducers_.equal_range(psetID);
179  for (auto it = elements.first; it != elements.second; ++it) {
180 
181  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
182 
183  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
184  if (iFound == subProcessIndexes.end()) {
185  continue;
186  }
187 
188  auto iFoundPreceding = std::find(subProcessIndexes.begin(), iFound, precedingProcessIndex);
189  if (iFoundPreceding == iFound) {
190  break;
191  } else {
192  return iFoundPreceding == subProcessIndexes.begin();
193  }
194  }
196  << "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:7
dictionary elements
bool edm::eventsetup::EventSetupsController::isLastMatch ( ParameterSetID const &  psetID,
unsigned  subProcessIndex,
unsigned  precedingProcessIndex 
) const

Definition at line 203 of file EventSetupsController.cc.

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

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

205  {
206 
207  auto elements = esproducers_.equal_range(psetID);
208  for (auto it = elements.first; it != elements.second; ++it) {
209 
210  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
211 
212  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
213  if (iFound == subProcessIndexes.end()) {
214  continue;
215  }
216 
217  auto iFoundPreceding = std::find(subProcessIndexes.begin(), iFound, precedingProcessIndex);
218  if (iFoundPreceding == iFound) {
219  break;
220  } else {
221  return (++iFoundPreceding) == iFound;
222  }
223  }
225  << "EventSetupsController::isLastMatch\n"
226  << "Subprocess index not found. This should never happen\n"
227  << "Please report this to a Framework Developer\n";
228  return false;
229  }
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:7
dictionary elements
bool edm::eventsetup::EventSetupsController::isMatchingESProducer ( ParameterSetID const &  psetID,
unsigned  subProcessIndex,
unsigned  precedingProcessIndex 
) const

Definition at line 260 of file EventSetupsController.cc.

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

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

262  {
263  auto elements = esproducers_.equal_range(psetID);
264  for (auto it = elements.first; it != elements.second; ++it) {
265 
266  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
267 
268  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
269  if (iFound == subProcessIndexes.end()) {
270  continue;
271  }
272 
273  auto iFoundPreceding = std::find(subProcessIndexes.begin(), iFound, precedingProcessIndex);
274  if (iFoundPreceding == iFound) {
275  return false;
276  } else {
277  return true;
278  }
279  }
281  << "EventSetupsController::lookForMatchingESSource\n"
282  << "Subprocess index not found. This should never happen\n"
283  << "Please report this to a Framework Developer\n";
284  return false;
285  }
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:7
dictionary elements
bool edm::eventsetup::EventSetupsController::isMatchingESSource ( ParameterSetID const &  psetID,
unsigned  subProcessIndex,
unsigned  precedingProcessIndex 
) const

Definition at line 232 of file EventSetupsController.cc.

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

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

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

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

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

140  {
141 
142  auto elements = esproducers_.equal_range(psetID);
143  for (auto it = elements.first; it != elements.second; ++it) {
144 
145  std::vector<unsigned> const& subProcessIndexes = it->second.subProcessIndexes();
146 
147  auto iFound = std::find(subProcessIndexes.begin(), subProcessIndexes.end(), subProcessIndex);
148  if (iFound == subProcessIndexes.end()) {
149  continue;
150  }
151 
152  if (iFound == subProcessIndexes.begin()) {
153  firstProcessWithThisPSet = true;
154  precedingHasMatchingPSet = false;
155  } else {
156  auto iFoundPreceding = std::find(subProcessIndexes.begin(), iFound, precedingProcessIndex);
157  if (iFoundPreceding == iFound) {
158  firstProcessWithThisPSet = false;
159  precedingHasMatchingPSet = false;
160  } else {
161  firstProcessWithThisPSet = false;
162  precedingHasMatchingPSet = true;
163  }
164  }
165  return;
166  }
168  << "EventSetupsController::lookForMatches\n"
169  << "Subprocess index not found. This should never happen\n"
170  << "Please report this to a Framework Developer\n";
171  }
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:7
dictionary elements
boost::shared_ptr< EventSetupProvider > edm::eventsetup::EventSetupsController::makeProvider ( ParameterSet iPSet)

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  boost::shared_ptr<EventSetupProvider> returnValue(makeEventSetupProvider(iPSet, providers_.size()) );
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::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 97 of file EventSetupsController.cc.

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

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

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

Definition at line 122 of file EventSetupsController.cc.

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

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

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