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 44 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 113 of file TTClusterAssociationMap.h.

113  {
115  nclus = 0;
116 }

◆ ~TTClusterAssociationMap()

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

Destructor.

Definition at line 120 of file TTClusterAssociationMap.h.

120 {}

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 144 of file TTClusterAssociationMap.h.

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

144  {
145  if (this->isGenuine(aCluster)) {
146  return this->findTrackingParticlePtrs(aCluster).at(0);
147  } else {
149  }
150 }
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 134 of file TTClusterAssociationMap.h.

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

135  {
137  return clusterToTrackingParticleVectorMap_.find(aCluster)->second;
138  } else {
140  }
141 }
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 124 of file TTClusterAssociationMap.h.

125  {
126  if (trackingParticleToClusterVectorMap_.find(aTrackingParticle) != trackingParticleToClusterVectorMap_.end()) {
127  return trackingParticleToClusterVectorMap_.find(aTrackingParticle)->second;
128  } else {
129  return nullVecClusterRef_;
130  }
131 }
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 54 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 266 of file TTClusterAssociationMap.h.

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

266  {
268  const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
269 
271  if (theseTrackingParticles.empty())
272  return false;
273 
274  bool genuineClu = this->isGenuine(aCluster);
275  bool unknownClu = this->isUnknown(aCluster);
276 
277  if (genuineClu || unknownClu)
278  return false;
279 
280  return true;
281 
283  unsigned int goodDifferentTPs = 0;
284  std::vector<const TrackingParticle*> tpAddressVector;
285 
287  for (unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
289  TrackingParticlePtr curTP = theseTrackingParticles.at(itp);
290 
292  if (!curTP.isNull()) {
295  tpAddressVector.push_back(curTP.get());
296  }
297  }
298 
300  std::sort(tpAddressVector.begin(), tpAddressVector.end());
301  tpAddressVector.erase(std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
302  goodDifferentTPs = tpAddressVector.size();
303 
304  return (goodDifferentTPs > 1);
305 }
bool isUnknown(TTClusterRefT< T > aCluster) const
Cluster "unknown": i.e. not associated with any TP.
bool isNull() const
Checks for null.
Definition: Ptr.h:142
def unique(seq, keepstr=True)
Definition: tier0.py:24
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
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 177 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().

177  {
179  const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
180 
182  if (theseTrackingParticles.empty())
183  return false;
184 
186  unsigned int goodDifferentTPs = 0;
187  std::vector<const TrackingParticle*> tpAddressVector;
188 
189  std::vector<float> tp_mom;
190 
191  float tp_tot = 0;
192 
194  for (const auto& tp : theseTrackingParticles) {
196  const TrackingParticlePtr& curTP = tp;
197 
199  if (curTP.isNull()) {
200  tp_mom.push_back(0);
201  } else {
202  tp_mom.push_back(curTP.get()->p4().pt());
203  tp_tot += curTP.get()->p4().pt();
204  }
205  }
206 
207  if (tp_tot == 0)
208  return false;
209 
210  for (unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
212  TrackingParticlePtr curTP = theseTrackingParticles.at(itp);
213 
215  if (tp_mom.at(itp) > 0.01 * tp_tot) {
218  tpAddressVector.push_back(curTP.get());
219  }
220  }
221 
223  std::sort(tpAddressVector.begin(), tpAddressVector.end());
224  tpAddressVector.erase(std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
225  goodDifferentTPs = tpAddressVector.size();
226 
227  return (goodDifferentTPs == 1);
228 }
bool isNull() const
Checks for null.
Definition: Ptr.h:142
def unique(seq, keepstr=True)
Definition: tier0.py:24
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
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 231 of file TTClusterAssociationMap.h.

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

231  {
233  const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
234 
236  if (theseTrackingParticles.empty())
237  return true;
238 
240  unsigned int goodDifferentTPs = 0;
241  std::vector<const TrackingParticle*> tpAddressVector;
242 
244  for (unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
246  TrackingParticlePtr curTP = theseTrackingParticles.at(itp);
247 
249  if (!curTP.isNull()) {
252  tpAddressVector.push_back(curTP.get());
253  }
254  }
255 
257  std::sort(tpAddressVector.begin(), tpAddressVector.end());
258  tpAddressVector.erase(std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
259  goodDifferentTPs = tpAddressVector.size();
260 
262  return (goodDifferentTPs == 0);
263 }
bool isNull() const
Checks for null.
Definition: Ptr.h:142
def unique(seq, keepstr=True)
Definition: tier0.py:24
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
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 86 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 89 of file TTClusterAssociationMap.h.

◆ nullVecClusterRef_

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

Definition at line 91 of file TTClusterAssociationMap.h.

◆ nullVecTrackingParticlePtr_

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

Definition at line 90 of file TTClusterAssociationMap.h.

◆ trackingParticleToClusterVectorMap_

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