CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes | Static Private Attributes
TTClusterAssociationMap< T > Class Template Reference

Stores association of Truth Particles (TP) to L1 Track-Trigger Clusters. More...

#include <TTClusterAssociationMap.h>

Public Member Functions

const TrackingParticlePtrfindTrackingParticlePtr (TTClusterRefT< T > aCluster) const
 Get main TP associated to a cluster. (Non-NULL if isGenuine() below is true). More...
 
const std::vector< TrackingParticlePtr > & findTrackingParticlePtrs (TTClusterRefT< T > aCluster) const
 Get all TPs associated to a cluster. More...
 
const std::vector< TTClusterRefT< T > > & findTTClusterRefs (TrackingParticlePtr aTrackingParticle) const
 Operations. More...
 
const MapTPToVecClus< T > & getTrackingParticleToTTClustersMap () const
 
const MapClusToVecTP< T > & getTTClusterToTrackingParticlesMap () const
 Get/set cluster <-> truth association maps. More...
 
bool isCombinatoric (TTClusterRefT< T > aCluster) const
 Cluster is not "genuine" or "unknown". More...
 
bool isGenuine (TTClusterRefT< T > aCluster) const
 
bool isUnknown (TTClusterRefT< T > aCluster) const
 Cluster "unknown": i.e. not associated with any TP. More...
 
void setTrackingParticleToTTClustersMap (const MapTPToVecClus< T > &aMap)
 
void setTTClusterToTrackingParticlesMap (const MapClusToVecTP< T > &aMap)
 
 TTClusterAssociationMap ()
 Constructors. More...
 
 ~TTClusterAssociationMap ()
 Destructor. More...
 

Private Attributes

MapClusToVecTP< TclusterToTrackingParticleVectorMap_
 Data members. More...
 
int nclus
 
MapTPToVecClus< TtrackingParticleToClusterVectorMap_
 

Static Private Attributes

static const TrackingParticlePtr nullTrackingParticlePtr_
 Close class. More...
 
static const std::vector< TTClusterRefT< T > > nullVecClusterRef_
 
static const std::vector< TrackingParticlePtrnullVecTrackingParticlePtr_
 

Detailed Description

template<typename T>
class TTClusterAssociationMap< T >

Stores association of Truth Particles (TP) to L1 Track-Trigger Clusters.

Contains two maps. One associates each cluster to a vector of all TPs that made its hits. The other associates each TP to a vector of all clusters it contributed to.

(The template structure is used to accomodate types other than PixelDigis, in case they are needed in future).

Author
Nicola Pozzobon
Date
2013, Jul 19 (tidy up: Ian Tomalin, 2020)

Definition at line 43 of file TTClusterAssociationMap.h.

Constructor & Destructor Documentation

◆ TTClusterAssociationMap()

template<typename T >
TTClusterAssociationMap< T >::TTClusterAssociationMap ( )

Constructors.

Default Constructor NOTE: to be used with setSomething(...) methods

Set default data members

Definition at line 112 of file TTClusterAssociationMap.h.

112  {
114  nclus = 0;
115 }

◆ ~TTClusterAssociationMap()

template<typename T >
TTClusterAssociationMap< T >::~TTClusterAssociationMap ( )

Destructor.

Definition at line 119 of file TTClusterAssociationMap.h.

119 {}

Member Function Documentation

◆ findTrackingParticlePtr()

template<typename T >
const TrackingParticlePtr & TTClusterAssociationMap< T >::findTrackingParticlePtr ( TTClusterRefT< T aCluster) const

Get main TP associated to a cluster. (Non-NULL if isGenuine() below is true).

Definition at line 143 of file TTClusterAssociationMap.h.

Referenced by tmtt::Stub::fillTruth().

143  {
144  if (this->isGenuine(aCluster)) {
145  return this->findTrackingParticlePtrs(aCluster).at(0);
146  } else {
148  }
149 }
static const TrackingParticlePtr nullTrackingParticlePtr_
Close class.
const std::vector< TrackingParticlePtr > & findTrackingParticlePtrs(TTClusterRefT< T > aCluster) const
Get all TPs associated to a cluster.
bool isGenuine(TTClusterRefT< T > aCluster) const

◆ findTrackingParticlePtrs()

template<typename T >
const std::vector< TrackingParticlePtr > & TTClusterAssociationMap< T >::findTrackingParticlePtrs ( TTClusterRefT< T aCluster) const

Get all TPs associated to a cluster.

Definition at line 133 of file TTClusterAssociationMap.h.

Referenced by l1tVertexFinder::Stub::fillTruth(), and tmtt::Stub::fillTruth().

134  {
136  return clusterToTrackingParticleVectorMap_.find(aCluster)->second;
137  } else {
139  }
140 }
MapClusToVecTP< T > clusterToTrackingParticleVectorMap_
Data members.
static const std::vector< TrackingParticlePtr > nullVecTrackingParticlePtr_

◆ findTTClusterRefs()

template<typename T >
const std::vector< TTClusterRefT< T > > & TTClusterAssociationMap< T >::findTTClusterRefs ( TrackingParticlePtr  aTrackingParticle) const

Operations.

Definition at line 123 of file TTClusterAssociationMap.h.

124  {
125  if (trackingParticleToClusterVectorMap_.find(aTrackingParticle) != trackingParticleToClusterVectorMap_.end()) {
126  return trackingParticleToClusterVectorMap_.find(aTrackingParticle)->second;
127  } else {
128  return nullVecClusterRef_;
129  }
130 }
static const std::vector< TTClusterRefT< T > > nullVecClusterRef_
MapTPToVecClus< T > trackingParticleToClusterVectorMap_

◆ getTrackingParticleToTTClustersMap()

template<typename T >
const MapTPToVecClus<T>& TTClusterAssociationMap< T >::getTrackingParticleToTTClustersMap ( ) const
inline

◆ getTTClusterToTrackingParticlesMap()

template<typename T >
const MapClusToVecTP<T>& TTClusterAssociationMap< T >::getTTClusterToTrackingParticlesMap ( ) const
inline

Get/set cluster <-> truth association maps.

Definition at line 53 of file TTClusterAssociationMap.h.

References TTClusterAssociationMap< T >::clusterToTrackingParticleVectorMap_.

MapClusToVecTP< T > clusterToTrackingParticleVectorMap_
Data members.

◆ isCombinatoric()

template<typename T >
bool TTClusterAssociationMap< T >::isCombinatoric ( TTClusterRefT< T aCluster) const

Cluster is not "genuine" or "unknown".

Get the TrackingParticles

If the vector is empty, then the cluster is UNKNOWN

If we are here, it means there are some TrackingParticles

Loop over the TrackingParticles

Get the TrackingParticle

Count the NULL TrackingParticles

Store the pointers (addresses) of the TrackingParticle to be able to count how many different there are
Count how many different TrackingParticle there are

Definition at line 265 of file TTClusterAssociationMap.h.

References edm::Ptr< T >::get(), edm::Ptr< T >::isNull(), jetUpdater_cfi::sort, and tier0::unique().

265  {
267  const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
268 
270  if (theseTrackingParticles.empty())
271  return false;
272 
273  bool genuineClu = this->isGenuine(aCluster);
274  bool unknownClu = this->isUnknown(aCluster);
275 
276  if (genuineClu || unknownClu)
277  return false;
278 
279  return true;
280 
282  unsigned int goodDifferentTPs = 0;
283  std::vector<const TrackingParticle*> tpAddressVector;
284 
286  for (unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
288  TrackingParticlePtr curTP = theseTrackingParticles.at(itp);
289 
291  if (!curTP.isNull()) {
294  tpAddressVector.push_back(curTP.get());
295  }
296  }
297 
299  std::sort(tpAddressVector.begin(), tpAddressVector.end());
300  tpAddressVector.erase(std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
301  goodDifferentTPs = tpAddressVector.size();
302 
303  return (goodDifferentTPs > 1);
304 }
bool isUnknown(TTClusterRefT< T > aCluster) const
Cluster "unknown": i.e. not associated with any TP.
bool isNull() const
Checks for null.
Definition: Ptr.h:144
def unique(seq, keepstr=True)
Definition: tier0.py:24
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:141
const std::vector< TrackingParticlePtr > & findTrackingParticlePtrs(TTClusterRefT< T > aCluster) const
Get all TPs associated to a cluster.
bool isGenuine(TTClusterRefT< T > aCluster) const

◆ isGenuine()

template<typename T >
bool TTClusterAssociationMap< T >::isGenuine ( TTClusterRefT< T aCluster) const

— Get quality of L1 cluster based on truth info. (exactly 1 of following 3 functions is always true) Cluster "genuine": i.e. cluster associated to exactly 1 TP. (If other TPs are associated, but have in total < 1% of Pt of main TP, or if they are null, then they are neglected here).

MC truth Table to define Genuine, Combinatoric and Unknown

N = number of NULL TP pointers D = number of GOOD TP pointers different from each other

OLD DEFINITION

N / D–> | 0 | 1 | >1

0 | U | G | C

>0 | U | C | CNEW DEFINITION SV 060617

N / D–> | 0 | 1 | >1 (with 1 TP getting >99% of the total pT) | >1

0 | U | G | G | C

>0 | U | G | G | C

Get the TrackingParticles

If the vector is empty, then the cluster is UNKNOWN

If we are here, it means there are some TrackingParticles

Loop over the TrackingParticles

Get the TrackingParticle

Count the NULL TrackingParticles

Get the TrackingParticle

Count the NULL TrackingParticles

Store the pointers (addresses) of the TrackingParticle to be able to count how many different there are
Count how many different TrackingParticle there are

Definition at line 176 of file TTClusterAssociationMap.h.

References edm::Ptr< T >::get(), edm::Ptr< T >::isNull(), TrackingParticle::p4(), jetUpdater_cfi::sort, cmsswSequenceInfo::tp, and tier0::unique().

Referenced by tmtt::Stub::fillTruth().

176  {
178  const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
179 
181  if (theseTrackingParticles.empty())
182  return false;
183 
185  unsigned int goodDifferentTPs = 0;
186  std::vector<const TrackingParticle*> tpAddressVector;
187 
188  std::vector<float> tp_mom;
189 
190  float tp_tot = 0;
191 
193  for (const auto& tp : theseTrackingParticles) {
195  const TrackingParticlePtr& curTP = tp;
196 
198  if (curTP.isNull()) {
199  tp_mom.push_back(0);
200  } else {
201  tp_mom.push_back(curTP.get()->p4().pt());
202  tp_tot += curTP.get()->p4().pt();
203  }
204  }
205 
206  if (tp_tot == 0)
207  return false;
208 
209  for (unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
211  TrackingParticlePtr curTP = theseTrackingParticles.at(itp);
212 
214  if (tp_mom.at(itp) > 0.01 * tp_tot) {
217  tpAddressVector.push_back(curTP.get());
218  }
219  }
220 
222  std::sort(tpAddressVector.begin(), tpAddressVector.end());
223  tpAddressVector.erase(std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
224  goodDifferentTPs = tpAddressVector.size();
225 
226  return (goodDifferentTPs == 1);
227 }
bool isNull() const
Checks for null.
Definition: Ptr.h:144
def unique(seq, keepstr=True)
Definition: tier0.py:24
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:141
const LorentzVector & p4() const
Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.
const std::vector< TrackingParticlePtr > & findTrackingParticlePtrs(TTClusterRefT< T > aCluster) const
Get all TPs associated to a cluster.

◆ isUnknown()

template<typename T >
bool TTClusterAssociationMap< T >::isUnknown ( TTClusterRefT< T aCluster) const

Cluster "unknown": i.e. not associated with any TP.

Get the TrackingParticles

If the vector is empty, then the cluster is UNKNOWN

If we are here, it means there are some TrackingParticles

Loop over the TrackingParticles

Get the TrackingParticle

Count the non-NULL TrackingParticles

Store the pointers (addresses) of the TrackingParticle to be able to count how many different there are

Count how many different TrackingParticle there are

UNKNOWN means no good TP is found

Definition at line 230 of file TTClusterAssociationMap.h.

References edm::Ptr< T >::get(), edm::Ptr< T >::isNull(), jetUpdater_cfi::sort, and tier0::unique().

230  {
232  const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
233 
235  if (theseTrackingParticles.empty())
236  return true;
237 
239  unsigned int goodDifferentTPs = 0;
240  std::vector<const TrackingParticle*> tpAddressVector;
241 
243  for (unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
245  TrackingParticlePtr curTP = theseTrackingParticles.at(itp);
246 
248  if (!curTP.isNull()) {
251  tpAddressVector.push_back(curTP.get());
252  }
253  }
254 
256  std::sort(tpAddressVector.begin(), tpAddressVector.end());
257  tpAddressVector.erase(std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
258  goodDifferentTPs = tpAddressVector.size();
259 
261  return (goodDifferentTPs == 0);
262 }
bool isNull() const
Checks for null.
Definition: Ptr.h:144
def unique(seq, keepstr=True)
Definition: tier0.py:24
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:141
const std::vector< TrackingParticlePtr > & findTrackingParticlePtrs(TTClusterRefT< T > aCluster) const
Get all TPs associated to a cluster.

◆ setTrackingParticleToTTClustersMap()

template<typename T >
void TTClusterAssociationMap< T >::setTrackingParticleToTTClustersMap ( const MapTPToVecClus< T > &  aMap)
inline

◆ setTTClusterToTrackingParticlesMap()

template<typename T >
void TTClusterAssociationMap< T >::setTTClusterToTrackingParticlesMap ( const MapClusToVecTP< T > &  aMap)
inline

Member Data Documentation

◆ clusterToTrackingParticleVectorMap_

template<typename T >
MapClusToVecTP<T> TTClusterAssociationMap< T >::clusterToTrackingParticleVectorMap_
private

◆ nclus

template<typename T >
int TTClusterAssociationMap< T >::nclus
private

Definition at line 85 of file TTClusterAssociationMap.h.

◆ nullTrackingParticlePtr_

template<typename T >
const TrackingParticlePtr TTClusterAssociationMap< T >::nullTrackingParticlePtr_
staticprivate

Close class.

Implementation of methods

Here, in the header file, the methods which do not depend on the specific type <T> that can fit the template. Other methods, with type-specific features, are implemented in the source file.

Definition at line 88 of file TTClusterAssociationMap.h.

◆ nullVecClusterRef_

template<typename T >
const std::vector< TTClusterRefT< T > > TTClusterAssociationMap< T >::nullVecClusterRef_
staticprivate

Definition at line 90 of file TTClusterAssociationMap.h.

◆ nullVecTrackingParticlePtr_

template<typename T >
const std::vector< TrackingParticlePtr > TTClusterAssociationMap< T >::nullVecTrackingParticlePtr_
staticprivate

Definition at line 89 of file TTClusterAssociationMap.h.

◆ trackingParticleToClusterVectorMap_

template<typename T >
MapTPToVecClus<T> TTClusterAssociationMap< T >::trackingParticleToClusterVectorMap_
private