CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Attributes
edm::ProductResolverIndexHelper Class Reference

#include <ProductResolverIndexHelper.h>

Classes

class  IndexAndNames
 
class  Item
 
class  Matches
 
class  Range
 

Public Types

using ModulesToIndiciesMap = std::unordered_multimap< std::string, std::tuple< TypeID const *, const char *, ProductResolverIndex > >
 

Public Member Functions

unsigned int beginElements () const
 
ProductResolverIndex index (KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=nullptr) const
 
std::vector< IndexAndNames > const & indexAndNames () const
 
unsigned int indexToIndexAndNames (KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process) const
 
unsigned int indexToType (KindOfType kindOfType, TypeID const &typeID) const
 
ModulesToIndiciesMap indiciesForModulesInProcess (const std::string &iProcessName) const
 
ProductResolverIndex insert (TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process)
 
ProductResolverIndex insert (TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process, TypeID const &containedTypeID, std::vector< TypeWithDict > *baseTypesOfContainedType)
 
std::vector< std::string > const & lookupProcessNames () const
 
ProductResolverIndex nextIndexValue () const
 
void print (std::ostream &os) const
 
unsigned int processIndex (char const *process) const
 
std::vector< char > const & processNames () const
 
 ProductResolverIndexHelper ()
 
std::vector< Range > const & ranges () const
 
Matches relatedIndexes (KindOfType kindOfType, TypeID const &typeID) const
 
Matches relatedIndexes (KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
 
void sanityCheck () const
 
void setFrozen ()
 
std::vector< TypeID > const & sortedTypeIDs () const
 

Private Attributes

unsigned int beginElements_
 
std::vector< char > bigNamesContainer_
 
std::vector< IndexAndNamesindexAndNames_
 
edm::propagate_const< std::unique_ptr< std::set< Item > > > items_
 
std::vector< std::string > lookupProcessNames_
 
ProductResolverIndex nextIndexValue_
 
edm::propagate_const< std::unique_ptr< std::set< std::string > > > processItems_
 
std::vector< char > processNames_
 
std::vector< Rangeranges_
 
std::vector< TypeIDsortedTypeIDs_
 

Detailed Description

This class assigns and gets the ProductResolverIndex associated with a type, module label, instance, and process. The ProductResolverIndex is used to tell the Principal where to store a ProductResolver and how to find it quickly.

One can also look up the same ProductResolverIndex's using the type or base type of an element in a container in the product (if the product is a container). In this case the KindOfType argument to the Principal::getByLabel function is ELEMENT_TYPE, whereas normally it is PRODUCT_TYPE.

There are also special ProductResolverIndex's generated where the process name is empty. These indexes refer to a special ProductResolvers that search for a matching product from the most recent process that has a matching type, label and instance. There is ProductResolverIndex generated for each type/label/instance combination which has at least one entry in the tables in this class. Both PRODUCT_TYPEs and ELEMENT_TYPEs get these special ProductResolvers.

The ProductResolverIndex for a particular product will not change during a process after the ProductRegistry has been frozen. Nor will any of the other member data of this class. Multiple threads can access it concurrently without problems. The ProductResolverIndexes can be safely cached in InputTags and possibly other places, because they never change within a process. The ProductResolverIndex for a particular product is not intended to be persistent and will be different in different processes.

The ProductResolverIndex is used to order the placement of the ProductResolvers in the Principal that are either present in the input or produced in the current process. Be aware that there are other ProductResolvers for products that come after ProductResolvers placed by this class. For example, the placement of dropped products is not handled by this class, instead by the ProductRegistry. The reason for this distinction is that those other ProductResolvers can change and be added as a process runs. The content of this class never changes after the ProductRegistry is frozen.

Author
W. David Dagenhart, created 10 December, 2012

Definition at line 89 of file ProductResolverIndexHelper.h.

Member Typedef Documentation

◆ ModulesToIndiciesMap

using edm::ProductResolverIndexHelper::ModulesToIndiciesMap = std::unordered_multimap<std::string, std::tuple<TypeID const*, const char*, ProductResolverIndex> >

Definition at line 124 of file ProductResolverIndexHelper.h.

Constructor & Destructor Documentation

◆ ProductResolverIndexHelper()

edm::ProductResolverIndexHelper::ProductResolverIndexHelper ( )

Definition at line 75 of file ProductResolverIndexHelper.cc.

76  : nextIndexValue_(0),
77  beginElements_(0),
78  items_(new std::set<ProductResolverIndexHelper::Item>),
79  processItems_(new std::set<std::string>) {}

Member Function Documentation

◆ beginElements()

unsigned int edm::ProductResolverIndexHelper::beginElements ( ) const
inline

Definition at line 223 of file ProductResolverIndexHelper.h.

223 { return beginElements_; }

References beginElements_.

◆ index()

ProductResolverIndex edm::ProductResolverIndexHelper::index ( KindOfType  kindOfType,
TypeID const &  typeID,
char const *  moduleLabel,
char const *  instance,
char const *  process = nullptr 
) const

◆ indexAndNames()

std::vector<IndexAndNames> const& edm::ProductResolverIndexHelper::indexAndNames ( ) const
inline

Definition at line 226 of file ProductResolverIndexHelper.h.

226 { return indexAndNames_; }

References indexAndNames_.

Referenced by indiciesForModulesInProcess().

◆ indexToIndexAndNames()

unsigned int edm::ProductResolverIndexHelper::indexToIndexAndNames ( KindOfType  kindOfType,
TypeID const &  typeID,
char const *  moduleLabel,
char const *  instance,
char const *  process 
) const

Definition at line 420 of file ProductResolverIndexHelper.cc.

424  {
425  // Look for the type and check to see if it found it
426  unsigned iType = indexToType(kindOfType, typeID);
428  unsigned startProcess = 0;
429  if (process) {
430  startProcess = processIndex(process);
431  if (startProcess == std::numeric_limits<unsigned int>::max()) {
433  }
434  }
435 
437  unsigned int begin = range.begin();
438  unsigned int end = range.end();
439 
440  while (begin < end) {
441  unsigned int midpoint = begin + ((end - begin) / 2);
442  char const* namePtr = &bigNamesContainer_[indexAndNames_[midpoint].startInBigNamesContainer()];
443 
444  // Compare the module label
445  char const* label = moduleLabel;
446  while (*namePtr && (*namePtr == *label)) {
447  ++namePtr;
448  ++label;
449  }
450  if (*namePtr == *label) { // true only if both are at the '\0' at the end of the C string
451  ++namePtr; // move to the next C string
452 
453  // Compare the instance name
454  char const* instanceName = instance;
455  while (*namePtr && (*namePtr == *instanceName)) {
456  ++namePtr;
457  ++instanceName;
458  }
459  if (*namePtr == *instanceName) {
460  // Compare the process name
461  if (startProcess == indexAndNames_[midpoint].startInProcessNames()) {
462  return midpoint;
463  } else {
464  if (indexAndNames_[midpoint].startInProcessNames() > startProcess) {
465  while (true) {
466  --midpoint;
467  if (indexAndNames_[midpoint].startInProcessNames() == startProcess) {
468  return midpoint;
469  }
470  if (indexAndNames_[midpoint].startInProcessNames() == 0)
471  break;
472  }
473  } else {
474  while (true) {
475  ++midpoint;
476  if (midpoint == indexAndNames_.size())
477  break;
478  if (indexAndNames_[midpoint].startInProcessNames() == 0)
479  break;
480  if (indexAndNames_[midpoint].startInProcessNames() == startProcess) {
481  return midpoint;
482  }
483  }
484  }
485  break;
486  }
487  } else if (*namePtr < *instanceName) {
488  if (begin == midpoint)
489  break;
490  begin = midpoint;
491  } else {
492  end = midpoint;
493  }
494  } else if (*namePtr < *label) {
495  if (begin == midpoint)
496  break;
497  begin = midpoint;
498  } else {
499  end = midpoint;
500  }
501  } // end while (begin < end)
502  }
504  }

References begin, bigNamesContainer_, end, indexAndNames_, indexToType(), instance, MuonErrorMatrixAdjuster_cfi::instanceName, label, SiStripPI::max, HerwigMaxPtPartonFilter_cfi::moduleLabel, LaserDQM_cfg::process, processIndex(), FastTimerService_cff::range, and ranges_.

Referenced by index(), and relatedIndexes().

◆ indexToType()

unsigned int edm::ProductResolverIndexHelper::indexToType ( KindOfType  kindOfType,
TypeID const &  typeID 
) const

Definition at line 506 of file ProductResolverIndexHelper.cc.

506  {
507  unsigned int beginType = 0;
508  unsigned int endType = beginElements_;
509  if (kindOfType == ELEMENT_TYPE) {
510  beginType = beginElements_;
511  endType = sortedTypeIDs_.size();
512  }
513 
514  while (beginType < endType) {
515  unsigned int midpointType = beginType + ((endType - beginType) / 2);
516  if (sortedTypeIDs_[midpointType] == typeID) {
517  return midpointType; // Found it
518  } else if (sortedTypeIDs_[midpointType] < typeID) {
519  if (beginType == midpointType)
520  break;
521  beginType = midpointType;
522  } else {
523  endType = midpointType;
524  }
525  }
526  return std::numeric_limits<unsigned int>::max(); // Failed to find it
527  }

References beginElements_, edm::ELEMENT_TYPE, SiStripPI::max, and sortedTypeIDs_.

Referenced by indexToIndexAndNames(), and relatedIndexes().

◆ indiciesForModulesInProcess()

ProductResolverIndexHelper::ModulesToIndiciesMap edm::ProductResolverIndexHelper::indiciesForModulesInProcess ( const std::string &  iProcessName) const

Definition at line 553 of file ProductResolverIndexHelper.cc.

554  {
556  for (unsigned int i = 0; i < beginElements_; ++i) {
557  auto const& range = ranges_[i];
558  for (unsigned int j = range.begin(); j < range.end(); ++j) {
559  auto const& indexAndNames = indexAndNames_[j];
560  if (0 == strcmp(&processNames_[indexAndNames.startInProcessNames()], iProcessName.c_str())) {
561  //The first null terminated string is the module label
562  auto pModLabel = &bigNamesContainer_[indexAndNames.startInBigNamesContainer()];
563  auto l = strlen(pModLabel);
564  auto pInstance = pModLabel + l + 1;
565  result.emplace(pModLabel, std::make_tuple(&sortedTypeIDs_[i], pInstance, indexAndNames.index()));
566  }
567  }
568  }
569  return result;
570  }

References beginElements_, bigNamesContainer_, mps_fire::i, indexAndNames(), indexAndNames_, dqmiolumiharvest::j, cmsLHEtoEOSManager::l, processNames_, FastTimerService_cff::range, ranges_, mps_fire::result, and sortedTypeIDs_.

◆ insert() [1/2]

ProductResolverIndex edm::ProductResolverIndexHelper::insert ( TypeID const &  typeID,
char const *  moduleLabel,
char const *  instance,
char const *  process 
)

Definition at line 263 of file ProductResolverIndexHelper.cc.

266  {
267  TypeID containedTypeID = productholderindexhelper::getContainedType(typeID);
268  bool hasContainedType = (containedTypeID != TypeID(typeid(void)) && containedTypeID != TypeID());
269  std::vector<TypeWithDict> baseTypes;
270  std::vector<TypeWithDict>* baseTypesOfContainedType = &baseTypes;
271  if (hasContainedType) {
272  std::vector<std::string> missingDictionaries;
273  public_base_classes(missingDictionaries, containedTypeID, baseTypes);
274  }
275  return insert(typeID, moduleLabel, instance, process, containedTypeID, baseTypesOfContainedType);
276  }

References edm::productholderindexhelper::getContainedType(), insert(), instance, HerwigMaxPtPartonFilter_cfi::moduleLabel, LaserDQM_cfg::process, and edm::public_base_classes().

Referenced by BeautifulSoup.PageElement::append().

◆ insert() [2/2]

ProductResolverIndex edm::ProductResolverIndexHelper::insert ( TypeID const &  typeID,
char const *  moduleLabel,
char const *  instance,
char const *  process,
TypeID const &  containedTypeID,
std::vector< TypeWithDict > *  baseTypesOfContainedType 
)

Definition at line 178 of file ProductResolverIndexHelper.cc.

183  {
184  if (!items_) {
186  << "ProductResolverIndexHelper::insert - Attempt to insert more elements after frozen.\n";
187  }
188 
189  if (process == nullptr || *process == '\0') {
190  throw Exception(errors::LogicError) << "ProductResolverIndexHelper::insert - Empty process.\n";
191  }
192 
193  // Throw if this has already been inserted
194  Item item(PRODUCT_TYPE, typeID, moduleLabel, instance, process, 0);
195  std::set<Item>::iterator iter = items_->find(item);
196  if (iter != items_->end()) {
198  << "ProductResolverIndexHelper::insert - Attempt to insert duplicate entry.\n";
199  }
200 
201  // Put in an entry for the product
202  item.setIndex(nextIndexValue_);
203  unsigned int savedProductIndex = nextIndexValue_;
204  ++nextIndexValue_;
205  items_->insert(item);
206 
207  // Put in an entry for the product with an empty process name
208  // if it is not already there
209  item.clearProcess();
210  iter = items_->find(item);
211  if (iter == items_->end()) {
212  item.setIndex(nextIndexValue_);
213  ++nextIndexValue_;
214  items_->insert(item);
215  }
216 
217  // Now put in entries for a contained class if this is a
218  // recognized container.
219  if (containedTypeID != TypeID(typeid(void)) && containedTypeID != TypeID()) {
220  TypeWithDict containedType(containedTypeID.typeInfo());
221 
222  Item containedItem(ELEMENT_TYPE, containedTypeID, moduleLabel, instance, process, savedProductIndex);
223  iter = items_->find(containedItem);
224  if (iter != items_->end()) {
225  containedItem.setIndex(ProductResolverIndexAmbiguous);
226  items_->erase(iter);
227  }
228  items_->insert(containedItem);
229 
230  containedItem.clearProcess();
231  iter = items_->find(containedItem);
232  if (iter == items_->end()) {
233  containedItem.setIndex(nextIndexValue_);
234  ++nextIndexValue_;
235  items_->insert(containedItem);
236  }
237 
238  // Repeat this for all public base classes of the contained type
239  if (baseTypesOfContainedType) {
240  for (TypeWithDict const& baseType : *baseTypesOfContainedType) {
241  TypeID baseTypeID(baseType.typeInfo());
242  Item baseItem(ELEMENT_TYPE, baseTypeID, moduleLabel, instance, process, savedProductIndex);
243  iter = items_->find(baseItem);
244  if (iter != items_->end()) {
245  baseItem.setIndex(ProductResolverIndexAmbiguous);
246  items_->erase(iter);
247  }
248  items_->insert(baseItem);
249 
250  baseItem.clearProcess();
251  iter = items_->find(baseItem);
252  if (iter == items_->end()) {
253  baseItem.setIndex(nextIndexValue_);
254  ++nextIndexValue_;
255  items_->insert(baseItem);
256  }
257  }
258  }
259  }
260  return savedProductIndex;
261  }

References edm::ELEMENT_TYPE, Exception, instance, B2GTnPMonitor_cfi::item, items_, edm::errors::LogicError, HerwigMaxPtPartonFilter_cfi::moduleLabel, nextIndexValue_, LaserDQM_cfg::process, edm::PRODUCT_TYPE, edm::ProductResolverIndexAmbiguous, and edm::TypeID::typeInfo().

Referenced by BeautifulSoup.PageElement::append(), and insert().

◆ lookupProcessNames()

std::vector< std::string > const & edm::ProductResolverIndexHelper::lookupProcessNames ( ) const

Definition at line 412 of file ProductResolverIndexHelper.cc.

412  {
413  if (items_) {
415  << "ProductResolverIndexHelper::lookupProcessNames - Attempt to access names before frozen.\n";
416  }
417  return lookupProcessNames_;
418  }

References Exception, items_, edm::errors::LogicError, and lookupProcessNames_.

◆ nextIndexValue()

ProductResolverIndex edm::ProductResolverIndexHelper::nextIndexValue ( ) const
inline

Definition at line 251 of file ProductResolverIndexHelper.h.

251 { return nextIndexValue_; }

References nextIndexValue_.

◆ print()

void edm::ProductResolverIndexHelper::print ( std::ostream &  os) const

Definition at line 670 of file ProductResolverIndexHelper.cc.

670  {
671  os << "\n******* Dump ProductResolverIndexHelper *************************\n";
672 
673  os << "\nnextIndexValue_ = " << nextIndexValue_ << "\n";
674  os << "beginElements_ = " << beginElements_ << "\n";
675 
676  os << "\n******* sortedTypeIDs_ \n";
677  for (auto const& i : sortedTypeIDs_) {
678  os << i << "\n";
679  }
680  os << "******* ranges_ \n";
681  for (auto const& i : ranges_) {
682  os << i.begin() << " " << i.end() << "\n";
683  }
684  os << "******* indexAndNames_ \n";
685  for (auto const& i : indexAndNames_) {
686  os << i.index() << " " << i.startInBigNamesContainer() << " ";
687  char const* ptr = &bigNamesContainer_[i.startInBigNamesContainer()];
688  while (*ptr) {
689  os << *ptr;
690  ++ptr;
691  }
692  ++ptr;
693  os << " ";
694  while (*ptr) {
695  os << *ptr;
696  ++ptr;
697  }
698  os << " " << i.startInProcessNames() << " ";
699  ptr = &processNames_[i.startInProcessNames()];
700  while (*ptr) {
701  os << *ptr;
702  ++ptr;
703  }
704  os << "\n";
705  }
706  os << "******* bigNamesContainer_ \n";
707  for (auto i : bigNamesContainer_) {
708  if (i == '\0')
709  os << '\\' << '0';
710  else
711  os << i;
712  }
713  if (!bigNamesContainer_.empty())
714  os << "\n";
715  os << "******* processNames_ \n";
716  for (auto i : processNames_) {
717  if (i == '\0')
718  os << '\\' << '0';
719  else
720  os << i;
721  }
722  if (!processNames_.empty())
723  os << "\n";
724  if (items_) {
725  os << "******* items_ \n";
726  for (auto const& item : *items_) {
727  std::cout << item.kindOfType() << " " << item.moduleLabel() << " " << item.instance() << " " << item.process()
728  << " " << item.index() << " " << item.typeID() << "\n";
729  }
730  }
731  if (processItems_) {
732  os << "******* processItems_ \n";
733  for (auto const& item : *processItems_) {
734  os << item << "\n";
735  }
736  }
737  os << "sortedTypeIDs_.size() = " << sortedTypeIDs_.size() << "\n";
738  os << "indexAndNames_.size() = " << indexAndNames_.size() << "\n";
739  os << "bigNamesContainer_.size() = " << bigNamesContainer_.size() << "\n";
740  os << "processNames_.size() = " << processNames_.size() << "\n";
741  os << "\n";
742  }

References beginElements_, bigNamesContainer_, gather_cfg::cout, mps_fire::i, indexAndNames_, B2GTnPMonitor_cfi::item, items_, nextIndexValue_, processItems_, processNames_, ranges_, and sortedTypeIDs_.

◆ processIndex()

unsigned int edm::ProductResolverIndexHelper::processIndex ( char const *  process) const

Definition at line 529 of file ProductResolverIndexHelper.cc.

529  {
530  char const* ptr = &processNames_[0];
531  char const* begin = ptr;
532  while (true) {
533  char const* p = process;
534  char const* beginName = ptr;
535  while (*ptr && (*ptr == *p)) {
536  ++ptr;
537  ++p;
538  }
539  if (*ptr == *p) {
540  return beginName - begin;
541  }
542  while (*ptr) {
543  ++ptr;
544  }
545  ++ptr;
546  if (static_cast<unsigned>(ptr - begin) >= processNames_.size()) {
548  }
549  }
550  return 0;
551  }

References begin, SiStripPI::max, AlCaHLTBitMon_ParallelJobs::p, LaserDQM_cfg::process, and processNames_.

Referenced by indexToIndexAndNames(), and setFrozen().

◆ processNames()

std::vector<char> const& edm::ProductResolverIndexHelper::processNames ( ) const
inline

Definition at line 227 of file ProductResolverIndexHelper.h.

227 { return processNames_; }

References processNames_.

◆ ranges()

std::vector<Range> const& edm::ProductResolverIndexHelper::ranges ( ) const
inline

Definition at line 225 of file ProductResolverIndexHelper.h.

225 { return ranges_; }

References ranges_.

◆ relatedIndexes() [1/2]

ProductResolverIndexHelper::Matches edm::ProductResolverIndexHelper::relatedIndexes ( KindOfType  kindOfType,
TypeID const &  typeID 
) const

Definition at line 161 of file ProductResolverIndexHelper.cc.

162  {
163  unsigned int startInIndexAndNames = std::numeric_limits<unsigned int>::max();
164  unsigned int numberOfMatches = 0;
165 
166  // Look for the type and check to see if it found it
167  unsigned iType = indexToType(kindOfType, typeID);
169  // Get the range of entries with a matching TypeID
170  Range const& range = ranges_[iType];
171 
172  startInIndexAndNames = range.begin();
173  numberOfMatches = range.end() - range.begin();
174  }
175  return Matches(this, startInIndexAndNames, numberOfMatches);
176  }

References indexToType(), SiStripPI::max, FastTimerService_cff::range, and ranges_.

◆ relatedIndexes() [2/2]

ProductResolverIndexHelper::Matches edm::ProductResolverIndexHelper::relatedIndexes ( KindOfType  kindOfType,
TypeID const &  typeID,
char const *  moduleLabel,
char const *  instance 
) const

Definition at line 142 of file ProductResolverIndexHelper.cc.

145  {
146  unsigned int startInIndexAndNames = indexToIndexAndNames(kindOfType, typeID, moduleLabel, instance, nullptr);
147  unsigned int numberOfMatches = 1;
148 
149  if (startInIndexAndNames == std::numeric_limits<unsigned int>::max()) {
150  numberOfMatches = 0;
151  } else {
152  auto vSize = indexAndNames_.size();
153  for (unsigned int j = startInIndexAndNames + 1U; j < vSize && (indexAndNames_[j].startInProcessNames() != 0U);
154  ++j) {
155  ++numberOfMatches;
156  }
157  }
158  return Matches(this, startInIndexAndNames, numberOfMatches);
159  }

References indexAndNames_, indexToIndexAndNames(), instance, dqmiolumiharvest::j, SiStripPI::max, HerwigMaxPtPartonFilter_cfi::moduleLabel, and mitigatedMETSequence_cff::U.

Referenced by edm::Principal::getManyByType(), edm::EDConsumerBase::modulesWhoseProductsAreConsumed(), and edm::EDConsumerBase::updateLookup().

◆ sanityCheck()

void edm::ProductResolverIndexHelper::sanityCheck ( ) const

Definition at line 572 of file ProductResolverIndexHelper.cc.

572  {
573  bool sanityChecksPass = true;
574  if (sortedTypeIDs_.size() != ranges_.size())
575  sanityChecksPass = false;
576 
577  unsigned int previousEnd = 0;
578  for (auto const& range : ranges_) {
579  if (range.begin() != previousEnd)
580  sanityChecksPass = false;
581  if (range.begin() >= range.end())
582  sanityChecksPass = false;
583  previousEnd = range.end();
584  }
585  if (previousEnd != indexAndNames_.size())
586  sanityChecksPass = false;
587 
588  unsigned maxStart = 0;
589  unsigned maxStartProcess = 0;
590  for (auto const& indexAndName : indexAndNames_) {
591  if (indexAndName.index() >= nextIndexValue_ && indexAndName.index() != ProductResolverIndexAmbiguous)
592  sanityChecksPass = false;
593 
594  if (indexAndName.startInBigNamesContainer() >= bigNamesContainer_.size())
595  sanityChecksPass = false;
596  if (indexAndName.startInProcessNames() >= processNames_.size())
597  sanityChecksPass = false;
598 
599  if (indexAndName.startInBigNamesContainer() > maxStart)
600  maxStart = indexAndName.startInBigNamesContainer();
601  if (indexAndName.startInProcessNames() > maxStartProcess)
602  maxStartProcess = indexAndName.startInProcessNames();
603  }
604 
605  if (!indexAndNames_.empty()) {
606  if (bigNamesContainer_.back() != '\0')
607  sanityChecksPass = false;
608  if (processNames_.back() != '\0')
609  sanityChecksPass = false;
610  if (maxStart >= bigNamesContainer_.size())
611  sanityChecksPass = false;
612  unsigned int countZeroes = 0;
613  for (unsigned j = maxStart; j < bigNamesContainer_.size(); ++j) {
614  if (bigNamesContainer_[j] == '\0') {
615  ++countZeroes;
616  }
617  }
618  if (countZeroes != 2)
619  sanityChecksPass = false;
620  if (maxStartProcess >= processNames_.size())
621  sanityChecksPass = false;
622  countZeroes = 0;
623  for (unsigned j = maxStartProcess; j < processNames_.size(); ++j) {
624  if (processNames_[j] == '\0') {
625  ++countZeroes;
626  }
627  }
628  if (countZeroes != 1)
629  sanityChecksPass = false;
630  }
631 
632  if (!sanityChecksPass) {
633  throw Exception(errors::LogicError) << "ProductResolverIndexHelper::setFrozen - Detected illegal state.\n";
634  }
635  }

References bigNamesContainer_, Exception, indexAndNames_, dqmiolumiharvest::j, edm::errors::LogicError, nextIndexValue_, processNames_, edm::ProductResolverIndexAmbiguous, FastTimerService_cff::range, ranges_, and sortedTypeIDs_.

Referenced by setFrozen().

◆ setFrozen()

void edm::ProductResolverIndexHelper::setFrozen ( )

Definition at line 278 of file ProductResolverIndexHelper.cc.

278  {
279  if (!items_)
280  return;
281 
282  // Make a first pass and count things so we
283  // can reserve memory in the vectors. Also
284  // fill processItems_ on the first pass.
285  bool iFirstThisType = true;
286  bool beginElementsWasSet = false;
287  TypeID previousTypeID;
288  KindOfType previousKindOfType = PRODUCT_TYPE;
289  std::string previousModuleLabel;
290  std::string previousInstance;
291  unsigned int iCountTypes = 0;
292  unsigned int iCountCharacters = 0;
293  for (auto const& item : *items_) {
294  if (iFirstThisType || item.typeID() != previousTypeID || item.kindOfType() != previousKindOfType) {
295  ++iCountTypes;
296  iFirstThisType = true;
297 
298  if (!beginElementsWasSet) {
299  if (item.kindOfType() == ELEMENT_TYPE) {
300  beginElementsWasSet = true;
301  } else {
302  beginElements_ = iCountTypes;
303  }
304  }
305  }
306 
307  processItems_->insert(item.process());
308 
309  if (iFirstThisType || item.moduleLabel() != previousModuleLabel || item.instance() != previousInstance) {
310  iCountCharacters += item.moduleLabel().size();
311  iCountCharacters += item.instance().size();
312  iCountCharacters += 2;
313  }
314 
315  iFirstThisType = false;
316  previousTypeID = item.typeID();
317  previousKindOfType = item.kindOfType();
318  previousModuleLabel = item.moduleLabel();
319  previousInstance = item.instance();
320  }
321 
322  // Size and fill the process name vector
323  unsigned int processNamesSize = 0;
324  for (auto const& processItem : *processItems_) {
325  processNamesSize += processItem.size();
326  ++processNamesSize;
327  }
328  processNames_.reserve(processNamesSize);
329  for (auto const& processItem : *processItems_) {
330  for (auto const& c : processItem) {
331  processNames_.push_back(c);
332  }
333  processNames_.push_back('\0');
334  lookupProcessNames_.push_back(processItem);
335  }
336 
337  // Reserve memory in the vectors
338  sortedTypeIDs_.reserve(iCountTypes);
339  ranges_.reserve(iCountTypes);
340  indexAndNames_.reserve(items_->size());
341  bigNamesContainer_.reserve(iCountCharacters);
342 
343  // Second pass. Really fill the vectors this time.
344  bool iFirstType = true;
345  iFirstThisType = true;
346  previousTypeID = TypeID();
347  unsigned int iCount = 0;
348  unsigned int iBeginning = 0;
349  iCountCharacters = 0;
350  unsigned int previousCharacterCount = 0;
351  if (!items_->empty()) {
352  for (auto const& item : *items_) {
353  if (iFirstThisType || item.typeID() != previousTypeID || item.kindOfType() != previousKindOfType) {
354  iFirstThisType = true;
355  sortedTypeIDs_.push_back(item.typeID());
356  if (iFirstType) {
357  iFirstType = false;
358  } else {
359  ranges_.push_back(Range(iBeginning, iCount));
360  }
361  iBeginning = iCount;
362  }
363  ++iCount;
364 
365  if (iFirstThisType || item.moduleLabel() != previousModuleLabel || item.instance() != previousInstance) {
366  unsigned int labelSize = item.moduleLabel().size();
367  for (unsigned int j = 0; j < labelSize; ++j) {
368  bigNamesContainer_.push_back(item.moduleLabel()[j]);
369  }
370  bigNamesContainer_.push_back('\0');
371 
372  unsigned int instanceSize = item.instance().size();
373  for (unsigned int j = 0; j < instanceSize; ++j) {
374  bigNamesContainer_.push_back(item.instance()[j]);
375  }
376  bigNamesContainer_.push_back('\0');
377 
378  previousCharacterCount = iCountCharacters;
379 
380  iCountCharacters += labelSize;
381  iCountCharacters += instanceSize;
382  iCountCharacters += 2;
383  }
384 
385  unsigned int processStart = processIndex(item.process().c_str());
386  if (processStart == std::numeric_limits<unsigned int>::max()) {
388  << "ProductResolverIndexHelper::setFrozen - Process not found in processNames_.\n";
389  }
390  indexAndNames_.emplace_back(item.index(), previousCharacterCount, processStart);
391 
392  iFirstThisType = false;
393  previousTypeID = item.typeID();
394  previousKindOfType = item.kindOfType();
395  previousModuleLabel = item.moduleLabel();
396  previousInstance = item.instance();
397  }
398  ranges_.push_back(Range(iBeginning, iCount));
399  }
400 
401  // Some sanity checks to protect against out of bounds vector accesses
402  // These should only fail if there is a bug. If profiling ever shows
403  // them to be expensive one might delete them.
404  sanityCheck();
405 
406  // Cleanup, do not need the temporary containers anymore
407  // propagate_const<T> has no reset() function
408  items_ = nullptr;
409  processItems_ = nullptr;
410  }

References beginElements_, bigNamesContainer_, HltBtagPostValidation_cff::c, edm::ELEMENT_TYPE, Exception, indexAndNames_, B2GTnPMonitor_cfi::item, items_, dqmiolumiharvest::j, edm::errors::LogicError, lookupProcessNames_, SiStripPI::max, processIndex(), processItems_, processNames_, edm::PRODUCT_TYPE, ranges_, sanityCheck(), sortedTypeIDs_, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ sortedTypeIDs()

std::vector<TypeID> const& edm::ProductResolverIndexHelper::sortedTypeIDs ( ) const
inline

Definition at line 224 of file ProductResolverIndexHelper.h.

224 { return sortedTypeIDs_; }

References sortedTypeIDs_.

Member Data Documentation

◆ beginElements_

unsigned int edm::ProductResolverIndexHelper::beginElements_
private

◆ bigNamesContainer_

std::vector<char> edm::ProductResolverIndexHelper::bigNamesContainer_
private

◆ indexAndNames_

std::vector<IndexAndNames> edm::ProductResolverIndexHelper::indexAndNames_
private

◆ items_

edm::propagate_const<std::unique_ptr<std::set<Item> > > edm::ProductResolverIndexHelper::items_
private

Definition at line 341 of file ProductResolverIndexHelper.h.

Referenced by insert(), lookupProcessNames(), print(), and setFrozen().

◆ lookupProcessNames_

std::vector<std::string> edm::ProductResolverIndexHelper::lookupProcessNames_
private

Definition at line 307 of file ProductResolverIndexHelper.h.

Referenced by lookupProcessNames(), and setFrozen().

◆ nextIndexValue_

ProductResolverIndex edm::ProductResolverIndexHelper::nextIndexValue_
private

Definition at line 259 of file ProductResolverIndexHelper.h.

Referenced by insert(), nextIndexValue(), print(), and sanityCheck().

◆ processItems_

edm::propagate_const<std::unique_ptr<std::set<std::string> > > edm::ProductResolverIndexHelper::processItems_
private

Definition at line 343 of file ProductResolverIndexHelper.h.

Referenced by print(), and setFrozen().

◆ processNames_

std::vector<char> edm::ProductResolverIndexHelper::processNames_
private

◆ ranges_

std::vector<Range> edm::ProductResolverIndexHelper::ranges_
private

◆ sortedTypeIDs_

std::vector<TypeID> edm::ProductResolverIndexHelper::sortedTypeIDs_
private
edm::ProductResolverIndexHelper::indexAndNames_
std::vector< IndexAndNames > indexAndNames_
Definition: ProductResolverIndexHelper.h:290
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
edm::ProductResolverIndexHelper::items_
edm::propagate_const< std::unique_ptr< std::set< Item > > > items_
Definition: ProductResolverIndexHelper.h:341
mps_fire.i
i
Definition: mps_fire.py:355
edm::productholderindexhelper::getContainedType
TypeID getContainedType(TypeID const &typeID)
Definition: ProductResolverIndexHelper.cc:67
edm::PRODUCT_TYPE
Definition: ProductKindOfType.h:5
Range
PixelRecoRange< float > Range
Definition: PixelTripletHLTGenerator.cc:31
edm::errors::LogicError
Definition: EDMException.h:37
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::ProductResolverIndexHelper::ModulesToIndiciesMap
std::unordered_multimap< std::string, std::tuple< TypeID const *, const char *, ProductResolverIndex > > ModulesToIndiciesMap
Definition: ProductResolverIndexHelper.h:124
edm::ProductResolverIndexHelper::indexToIndexAndNames
unsigned int indexToIndexAndNames(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process) const
Definition: ProductResolverIndexHelper.cc:420
end
#define end
Definition: vmac.h:39
edm::ProductResolverIndexHelper::bigNamesContainer_
std::vector< char > bigNamesContainer_
Definition: ProductResolverIndexHelper.h:302
edm::ProductResolverIndexHelper::sortedTypeIDs_
std::vector< TypeID > sortedTypeIDs_
Definition: ProductResolverIndexHelper.h:271
edm::ProductResolverIndexHelper::lookupProcessNames_
std::vector< std::string > lookupProcessNames_
Definition: ProductResolverIndexHelper.h:307
edm::ProductResolverIndexHelper::beginElements_
unsigned int beginElements_
Definition: ProductResolverIndexHelper.h:264
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ProductResolverIndexHelper::processNames_
std::vector< char > processNames_
Definition: ProductResolverIndexHelper.h:303
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
LaserDQM_cfg.process
process
Definition: LaserDQM_cfg.py:3
edm::ProductResolverIndexInvalid
Definition: ProductResolverIndex.h:16
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
edm::ProductResolverIndexHelper::indexToType
unsigned int indexToType(KindOfType kindOfType, TypeID const &typeID) const
Definition: ProductResolverIndexHelper.cc:506
instance
static PFTauRenderPlugin instance
Definition: PFTauRenderPlugin.cc:70
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
edm::ProductResolverIndexAmbiguous
Definition: ProductResolverIndex.h:18
edm::KindOfType
KindOfType
Definition: ProductKindOfType.h:5
edm::public_base_classes
bool public_base_classes(std::vector< std::string > &missingDictionaries, TypeID const &typeID, std::vector< TypeWithDict > &baseTypes)
Definition: DictionaryTools.cc:319
edm::ProductResolverIndexHelper::processItems_
edm::propagate_const< std::unique_ptr< std::set< std::string > > > processItems_
Definition: ProductResolverIndexHelper.h:343
edm::ELEMENT_TYPE
Definition: ProductKindOfType.h:5
Exception
Definition: hltDiff.cc:246
edm::ProductResolverIndexHelper::insert
ProductResolverIndex insert(TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process, TypeID const &containedTypeID, std::vector< TypeWithDict > *baseTypesOfContainedType)
Definition: ProductResolverIndexHelper.cc:178
edm::ProductResolverIndexHelper::indexAndNames
std::vector< IndexAndNames > const & indexAndNames() const
Definition: ProductResolverIndexHelper.h:226
mps_fire.result
result
Definition: mps_fire.py:303
edm::ProductResolverIndexHelper::processIndex
unsigned int processIndex(char const *process) const
Definition: ProductResolverIndexHelper.cc:529
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::ProductResolverIndexHelper::ranges_
std::vector< Range > ranges_
Definition: ProductResolverIndexHelper.h:278
edm::ProductResolverIndexHelper::sanityCheck
void sanityCheck() const
Definition: ProductResolverIndexHelper.cc:572
MuonErrorMatrixAdjuster_cfi.instanceName
instanceName
Definition: MuonErrorMatrixAdjuster_cfi.py:16
edm::ProductResolverIndexHelper::nextIndexValue_
ProductResolverIndex nextIndexValue_
Definition: ProductResolverIndexHelper.h:259
begin
#define begin
Definition: vmac.h:32
label
const char * label
Definition: PFTauDecayModeTools.cc:11