CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | Friends
edm::helper::IndexRangeAssociation Class Reference

#include <MultiAssociation.h>

Classes

class  FastFiller
 
struct  IDComparator
 

Public Types

typedef std::pair< unsigned int, unsigned int > range
 

Public Member Functions

bool contains (ProductID id) const
 True if this IndexRangeAssociation has info for this product id. More...
 
bool empty () const
 True if it's empty (no keys) More...
 
range get (const edm::ProductID &id, unsigned int t) const
 
 IndexRangeAssociation ()
 
template<typename RefKey >
range operator[] (const RefKey &r) const
 
unsigned int size () const
 Size of this collection (number of keys) More...
 
void swap (IndexRangeAssociation &other)
 

Static Public Member Functions

static void throwUnexpectedProductID (ProductID found, ProductID expected, const char *where)
 

Private Types

typedef std::pair< edm::ProductID, unsigned int > id_off_pair
 
typedef std::vector< id_off_pairid_offset_vector
 
typedef std::vector< int > offset_vector
 

Private Attributes

id_offset_vector id_offsets_
 
bool isFilling_
 
offset_vector ref_offsets_
 

Friends

class FastFiller
 

Detailed Description

Base class to map to items one a range within a target collection. All items in a target collection must be mapped to one and only one key. The target collection will normally be a RefVector (also PtrVector and std::vector could work) To be used by MultiAssociation. Any other usage beyond MultiAssociation is not supported. This class holds:

Definition at line 72 of file MultiAssociation.h.

Member Typedef Documentation

◆ id_off_pair

typedef std::pair<edm::ProductID, unsigned int> edm::helper::IndexRangeAssociation::id_off_pair
private

Definition at line 133 of file MultiAssociation.h.

◆ id_offset_vector

Definition at line 134 of file MultiAssociation.h.

◆ offset_vector

typedef std::vector<int> edm::helper::IndexRangeAssociation::offset_vector
private

Definition at line 135 of file MultiAssociation.h.

◆ range

typedef std::pair<unsigned int, unsigned int> edm::helper::IndexRangeAssociation::range

Definition at line 74 of file MultiAssociation.h.

Constructor & Destructor Documentation

◆ IndexRangeAssociation()

edm::helper::IndexRangeAssociation::IndexRangeAssociation ( )
inline

Definition at line 76 of file MultiAssociation.h.

76 : isFilling_(false) {}

Member Function Documentation

◆ contains()

bool IndexRangeAssociation::contains ( ProductID  id) const

True if this IndexRangeAssociation has info for this product id.

Definition at line 29 of file MultiAssociation.cc.

29  {
30  typedef IndexRangeAssociation::id_offset_vector::const_iterator iter;
31  iter pos = std::lower_bound(id_offsets_.begin(), id_offsets_.end(), id, IDComparator());
32  return (pos != id_offsets_.end()) && (pos->first == id);
33 }

References triggerObjects_cff::id, id_offsets_, and cuda_std::lower_bound().

Referenced by LumiList.LumiList::__contains__(), and edm::MultiAssociation< C >::contains().

◆ empty()

bool edm::helper::IndexRangeAssociation::empty ( ) const
inline

True if it's empty (no keys)

Definition at line 96 of file MultiAssociation.h.

96 { return ref_offsets_.empty(); }

References ref_offsets_.

Referenced by edm::MultiAssociation< C >::empty().

◆ get()

IndexRangeAssociation::range IndexRangeAssociation::get ( const edm::ProductID id,
unsigned int  t 
) const

Get a range of indices for this product id and key (non-template version) And end value of -1 means 'until the end of the other collection, AFAICT'

Definition at line 9 of file MultiAssociation.cc.

9  {
10  typedef IndexRangeAssociation::id_offset_vector::const_iterator iter;
11  iter pos = std::lower_bound(id_offsets_.begin(), id_offsets_.end(), id, IDComparator());
12  if ((pos == id_offsets_.end()) || (pos->first != id)) {
13  throw cms::Exception("Bad Key") << "Product ID " << id << " not found in this IndexRangeAssociation\n";
14  }
15  // === Do we want this check ? I would say yes, even if it costs some extra CPU cycles
16  if ((pos + 1 != id_offsets_.end()) && (pos->second + key >= (pos + 1)->second)) {
17  throw cms::Exception("Bad Offset") << "Key " << key << " goes beyond bounds " << ((pos + 1)->second - pos->second)
18  << " of this key collection within IndexRangeAssociation\n";
19  }
20  // === End check
21  offset_vector::const_iterator offs = ref_offsets_.begin() + pos->second + key;
22  if (offs >= ref_offsets_.end() - 1) {
23  throw cms::Exception("Bad Offset") << "Key " << key << " goes beyond bounds " << ref_offsets_.size() - 1
24  << " of this IndexRangeAssociation\n";
25  }
26  return range(*offs, *(offs + 1));
27 }

References Exception, triggerObjects_cff::id, id_offsets_, crabWrapper::key, cuda_std::lower_bound(), ref_offsets_, and edm::second().

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), util.rrapi.RRApi::columns(), rrapi.RRApi::columns(), rrapi.RRApi::count(), util.rrapi.RRApi::count(), rrapi.RRApi::data(), util.rrapi.RRApi::data(), edm::MultiAssociation< C >::get(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), operator[](), util.rrapi.RRApi::report(), rrapi.RRApi::report(), rrapi.RRApi::reports(), util.rrapi.RRApi::reports(), rrapi.RRApi::tables(), util.rrapi.RRApi::tables(), util.rrapi.RRApi::tags(), rrapi.RRApi::tags(), rrapi.RRApi::templates(), util.rrapi.RRApi::templates(), util.rrapi.RRApi::workspaces(), and rrapi.RRApi::workspaces().

◆ operator[]()

template<typename RefKey >
range edm::helper::IndexRangeAssociation::operator[] ( const RefKey &  r) const
inline

Get a range of indices for this key. RefKey can be edm::Ref, edm::Ptr, edm::RefToBase And end value of -1 means 'until the end of the other collection, AFAICT'

Definition at line 81 of file MultiAssociation.h.

81  {
82  return get(r.id(), r.key());
83  }

References get(), and alignCSCRings::r.

◆ size()

unsigned int edm::helper::IndexRangeAssociation::size ( void  ) const
inline

Size of this collection (number of keys)

Definition at line 93 of file MultiAssociation.h.

93 { return ref_offsets_.empty() ? 0 : ref_offsets_.size() - 1; }

References ref_offsets_.

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), edm::helper::IndexRangeAssociation::FastFiller::insert(), and edm::MultiAssociation< C >::size().

◆ swap()

void IndexRangeAssociation::swap ( IndexRangeAssociation other)

Definition at line 35 of file MultiAssociation.cc.

35  {
36  if (isFilling_ || other.isFilling_)
37  throw cms::Exception("Busy") << "Can't swap an IndexRangeAssociation while it's being filled!\n";
38  id_offsets_.swap(other.id_offsets_);
39  ref_offsets_.swap(other.ref_offsets_);
40 }

References Exception, id_offsets_, isFilling_, trackingPlots::other, and ref_offsets_.

Referenced by edm::helper::swap(), and edm::MultiAssociation< C >::swap().

◆ throwUnexpectedProductID()

void IndexRangeAssociation::throwUnexpectedProductID ( ProductID  found,
ProductID  expected,
const char *  where 
)
static

Definition at line 119 of file MultiAssociation.cc.

119  {
120  throw cms::Exception("Unexpected ProductID")
121  << where << ": found product id " << found << ", while expecting " << expected << ".\n"
122  << "Make sure you're not mismatching references from different collections.\n";
123 }

References Exception, and newFWLiteAna::found.

Referenced by edm::helper::IndexRangeAssociation::FastFiller::insert(), edm::MultiAssociation< C >::LazyFiller::setValues(), and edm::MultiAssociation< C >::LazyFiller::swapValues().

Friends And Related Function Documentation

◆ FastFiller

friend class FastFiller
friend

Definition at line 126 of file MultiAssociation.h.

Member Data Documentation

◆ id_offsets_

id_offset_vector edm::helper::IndexRangeAssociation::id_offsets_
private

◆ isFilling_

bool edm::helper::IndexRangeAssociation::isFilling_
private

◆ ref_offsets_

offset_vector edm::helper::IndexRangeAssociation::ref_offsets_
private
edm::helper::IndexRangeAssociation::range
std::pair< unsigned int, unsigned int > range
Definition: MultiAssociation.h:74
pos
Definition: PixelAliasList.h:18
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
edm::helper::IndexRangeAssociation::id_offsets_
id_offset_vector id_offsets_
Definition: MultiAssociation.h:136
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
trackingPlots.other
other
Definition: trackingPlots.py:1465
cuda_std::lower_bound
__host__ constexpr __device__ RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:27
edm::helper::IndexRangeAssociation::ref_offsets_
offset_vector ref_offsets_
Definition: MultiAssociation.h:137
alignCSCRings.r
r
Definition: alignCSCRings.py:93
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
Exception
Definition: hltDiff.cc:246
edm::helper::IndexRangeAssociation::isFilling_
bool isFilling_
Definition: MultiAssociation.h:139
crabWrapper.key
key
Definition: crabWrapper.py:19
edm::helper::IndexRangeAssociation::get
range get(const edm::ProductID &id, unsigned int t) const
Definition: MultiAssociation.cc:9