CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Private Member Functions | Private Attributes
ClusterTPAssociation Class Reference

#include <ClusterTPAssociation.h>

Public Types

using const_iterator = typename map_type::const_iterator
 
using key_type = OmniClusterRef
 
using map_type = std::vector< value_type >
 
using mapped_type = TrackingParticleRef
 
using range = std::pair< const_iterator, const_iterator >
 
using value_type = std::pair< key_type, mapped_type >
 

Public Member Functions

void addKeyID (edm::ProductID id)
 
const_iterator begin () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
void checkKeyProductID (const edm::ProductID &id) const
 
void checkKeyProductID (const OmniClusterRef &key) const
 
void checkMappedProductID (const edm::HandleBase &mappedHandle) const
 
void checkMappedProductID (const edm::ProductID &id) const
 
void checkMappedProductID (const TrackingParticleRef &tp) const
 
 ClusterTPAssociation ()
 
 ClusterTPAssociation (const edm::HandleBase &mappedHandle)
 
 ClusterTPAssociation (const edm::ProductID &mappedProductId)
 
void emplace_back (const OmniClusterRef &cluster, const TrackingParticleRef &tp)
 
bool empty () const
 
const_iterator end () const
 
range equal_range (const OmniClusterRef &key) const
 
const map_typemap () const
 
size_t size () const
 
void sortAndUnique ()
 
void swap (ClusterTPAssociation &other)
 

Static Private Member Functions

static bool compare (const value_type &i, const value_type &j)
 
static bool compareSort (const value_type &i, const value_type &j)
 

Private Attributes

edm::VecArray< edm::ProductID, 2 > keyProductIDs_
 
map_type map_
 
edm::ProductID mappedProductId_
 

Detailed Description

Maps OmniClusterRefs to TrackingParticleRefs

Assumes that the TrackingParticleRefs point to a single TrackingParticle collection.

Definition at line 21 of file ClusterTPAssociation.h.

Member Typedef Documentation

◆ const_iterator

using ClusterTPAssociation::const_iterator = typename map_type::const_iterator

Definition at line 27 of file ClusterTPAssociation.h.

◆ key_type

Definition at line 23 of file ClusterTPAssociation.h.

◆ map_type

Definition at line 26 of file ClusterTPAssociation.h.

◆ mapped_type

Definition at line 24 of file ClusterTPAssociation.h.

◆ range

Definition at line 28 of file ClusterTPAssociation.h.

◆ value_type

Definition at line 25 of file ClusterTPAssociation.h.

Constructor & Destructor Documentation

◆ ClusterTPAssociation() [1/3]

ClusterTPAssociation::ClusterTPAssociation ( )
inline

Definition at line 30 of file ClusterTPAssociation.h.

30 {}

◆ ClusterTPAssociation() [2/3]

ClusterTPAssociation::ClusterTPAssociation ( const edm::HandleBase mappedHandle)
inlineexplicit

Definition at line 31 of file ClusterTPAssociation.h.

31 : ClusterTPAssociation(mappedHandle.id()) {}

◆ ClusterTPAssociation() [3/3]

ClusterTPAssociation::ClusterTPAssociation ( const edm::ProductID mappedProductId)
inlineexplicit

Definition at line 32 of file ClusterTPAssociation.h.

32 : mappedProductId_(mappedProductId) {}

Member Function Documentation

◆ addKeyID()

void ClusterTPAssociation::addKeyID ( edm::ProductID  id)
inline

Definition at line 34 of file ClusterTPAssociation.h.

34  {
35  auto foundKeyID = std::find(std::begin(keyProductIDs_), std::end(keyProductIDs_), id);
36  if (foundKeyID == std::end(keyProductIDs_)) {
38  }
39  }

References edm::VecArray< T, N >::emplace_back(), mps_fire::end, spr::find(), and keyProductIDs_.

◆ begin()

const_iterator ClusterTPAssociation::begin ( void  ) const
inline

Definition at line 60 of file ClusterTPAssociation.h.

60 { return map_.begin(); }

References map_.

◆ cbegin()

const_iterator ClusterTPAssociation::cbegin ( ) const
inline

Definition at line 61 of file ClusterTPAssociation.h.

61 { return map_.cbegin(); }

References map_.

◆ cend()

const_iterator ClusterTPAssociation::cend ( ) const
inline

Definition at line 63 of file ClusterTPAssociation.h.

63 { return map_.end(); }

References map_.

◆ checkKeyProductID() [1/2]

void ClusterTPAssociation::checkKeyProductID ( const edm::ProductID id) const

Definition at line 4 of file ClusterTPAssociation.cc.

4  {
6  auto e = cms::Exception("InvalidReference");
7  e << "ClusterTPAssociation has OmniClusterRefs with ProductIDs ";
8  for (size_t i = 0; i < keyProductIDs_.size(); ++i) {
9  e << keyProductIDs_[i];
10  if (i < keyProductIDs_.size() - 1) {
11  e << ",";
12  }
13  }
14  e << " but got OmniClusterRef/ProductID with ID " << id << ". This is typically caused by a configuration error.";
15  throw e;
16  }
17 }

References MillePedeFileConverter_cfg::e, mps_fire::end, Exception, spr::find(), mps_fire::i, keyProductIDs_, and edm::VecArray< T, N >::size().

◆ checkKeyProductID() [2/2]

void ClusterTPAssociation::checkKeyProductID ( const OmniClusterRef key) const
inline

Definition at line 72 of file ClusterTPAssociation.h.

72 { checkKeyProductID(key.id()); }

References checkKeyProductID(), and crabWrapper::key.

Referenced by checkKeyProductID(), emplace_back(), and equal_range().

◆ checkMappedProductID() [1/3]

void ClusterTPAssociation::checkMappedProductID ( const edm::HandleBase mappedHandle) const
inline

Definition at line 75 of file ClusterTPAssociation.h.

75 { checkMappedProductID(mappedHandle.id()); }

References checkMappedProductID(), and edm::HandleBase::id().

Referenced by checkMappedProductID(), and emplace_back().

◆ checkMappedProductID() [2/3]

void ClusterTPAssociation::checkMappedProductID ( const edm::ProductID id) const

Definition at line 19 of file ClusterTPAssociation.cc.

19  {
20  if (id != mappedProductId_) {
21  throw cms::Exception("InvalidReference")
22  << "ClusterTPAssociation has TrackingParticles with ProductID " << mappedProductId_
23  << ", but got TrackingParticleRef/Handle/ProductID with ID " << id
24  << ". This is typically caused by a configuration error.";
25  }
26 }

References Exception, and mappedProductId_.

◆ checkMappedProductID() [3/3]

void ClusterTPAssociation::checkMappedProductID ( const TrackingParticleRef tp) const
inline

Definition at line 76 of file ClusterTPAssociation.h.

76 { checkMappedProductID(tp.id()); }

References checkMappedProductID(), and cmsswSequenceInfo::tp.

Referenced by checkMappedProductID().

◆ compare()

static bool ClusterTPAssociation::compare ( const value_type i,
const value_type j 
)
inlinestaticprivate

Definition at line 80 of file ClusterTPAssociation.h.

80 { return i.first.rawIndex() > j.first.rawIndex(); }

References mps_fire::i, and dqmiolumiharvest::j.

Referenced by compareSort(), and equal_range().

◆ compareSort()

static bool ClusterTPAssociation::compareSort ( const value_type i,
const value_type j 
)
inlinestaticprivate

Definition at line 82 of file ClusterTPAssociation.h.

82  {
83  // For sorting compare also TrackingParticle keys in order to
84  // remove duplicate matches
85  return compare(i, j) || (i.first.rawIndex() == j.first.rawIndex() && i.second.key() > j.second.key());
86  }

References compare(), mps_fire::i, and dqmiolumiharvest::j.

Referenced by sortAndUnique().

◆ emplace_back()

void ClusterTPAssociation::emplace_back ( const OmniClusterRef cluster,
const TrackingParticleRef tp 
)
inline

Definition at line 41 of file ClusterTPAssociation.h.

41  {
43  checkKeyProductID(cluster.id());
44  map_.emplace_back(cluster, tp);
45  }

References checkKeyProductID(), checkMappedProductID(), OmniClusterRef::id(), map_, and cmsswSequenceInfo::tp.

◆ empty()

bool ClusterTPAssociation::empty ( void  ) const
inline

Definition at line 57 of file ClusterTPAssociation.h.

57 { return map_.empty(); }

References map_.

Referenced by QuickTrackAssociatorByHitsImpl::associateTrack().

◆ end()

const_iterator ClusterTPAssociation::end ( void  ) const
inline

Definition at line 62 of file ClusterTPAssociation.h.

62 { return map_.end(); }

References map_.

◆ equal_range()

range ClusterTPAssociation::equal_range ( const OmniClusterRef key) const
inline

◆ map()

const map_type& ClusterTPAssociation::map ( ) const
inline

Definition at line 70 of file ClusterTPAssociation.h.

70 { return map_; }

References map_.

Referenced by BDHadronTrackMonitoringAnalyzer::analyze().

◆ size()

size_t ClusterTPAssociation::size ( void  ) const
inline

Definition at line 58 of file ClusterTPAssociation.h.

58 { return map_.size(); }

References map_.

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

◆ sortAndUnique()

void ClusterTPAssociation::sortAndUnique ( )
inline

Definition at line 46 of file ClusterTPAssociation.h.

46  {
47  std::sort(map_.begin(), map_.end(), compareSort);
48  auto last = std::unique(map_.begin(), map_.end());
49  map_.erase(last, map_.end());
50  map_.shrink_to_fit();
51  }

References compareSort(), dqmdumpme::last, map_, and tier0::unique().

◆ swap()

void ClusterTPAssociation::swap ( ClusterTPAssociation other)
inline

Definition at line 52 of file ClusterTPAssociation.h.

52  {
53  map_.swap(other.map_);
54  mappedProductId_.swap(other.mappedProductId_);
55  }

References map_, mappedProductId_, trackingPlots::other, and edm::ProductID::swap().

Member Data Documentation

◆ keyProductIDs_

edm::VecArray<edm::ProductID, 2> ClusterTPAssociation::keyProductIDs_
private

Definition at line 89 of file ClusterTPAssociation.h.

Referenced by addKeyID(), and checkKeyProductID().

◆ map_

map_type ClusterTPAssociation::map_
private

◆ mappedProductId_

edm::ProductID ClusterTPAssociation::mappedProductId_
private

Definition at line 90 of file ClusterTPAssociation.h.

Referenced by checkMappedProductID(), and swap().

mps_fire.i
i
Definition: mps_fire.py:428
ClusterTPAssociation::compare
static bool compare(const value_type &i, const value_type &j)
Definition: ClusterTPAssociation.h:80
ClusterTPAssociation::keyProductIDs_
edm::VecArray< edm::ProductID, 2 > keyProductIDs_
Definition: ClusterTPAssociation.h:89
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
ClusterTPAssociation::value_type
std::pair< key_type, mapped_type > value_type
Definition: ClusterTPAssociation.h:25
ClusterTPAssociation::mappedProductId_
edm::ProductID mappedProductId_
Definition: ClusterTPAssociation.h:90
ClusterTPAssociation::ClusterTPAssociation
ClusterTPAssociation()
Definition: ClusterTPAssociation.h:30
dqmdumpme.last
last
Definition: dqmdumpme.py:56
mps_fire.end
end
Definition: mps_fire.py:242
ClusterTPAssociation::checkKeyProductID
void checkKeyProductID(const OmniClusterRef &key) const
Definition: ClusterTPAssociation.h:72
trackingPlots.other
other
Definition: trackingPlots.py:1467
ClusterTPAssociation::compareSort
static bool compareSort(const value_type &i, const value_type &j)
Definition: ClusterTPAssociation.h:82
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
ClusterTPAssociation::map_
map_type map_
Definition: ClusterTPAssociation.h:88
edm::ProductID::swap
void swap(ProductID &other)
Definition: ProductID.cc:16
edm::VecArray::emplace_back
void emplace_back(Args &&... args)
Definition: VecArray.h:90
ClusterTPAssociation::checkMappedProductID
void checkMappedProductID(const edm::HandleBase &mappedHandle) const
Definition: ClusterTPAssociation.h:75
OmniClusterRef::id
edm::ProductID id() const
Definition: OmniClusterRef.h:69
tier0.unique
def unique(seq, keepstr=True)
Definition: tier0.py:24
Exception
Definition: hltDiff.cc:246
edm::VecArray::size
constexpr size_type size() const noexcept
Definition: VecArray.h:70
TrackingParticleRef
edm::Ref< TrackingParticleCollection > TrackingParticleRef
Definition: TrackingParticleFwd.h:10
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
crabWrapper.key
key
Definition: crabWrapper.py:19
edm::HandleBase::id
ProductID id() const
Definition: HandleBase.cc:29
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37