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.

144  {
145  if (this->isGenuine(aCluster)) {
146  return this->findTrackingParticlePtrs(aCluster).at(0);
147  } else {
149  }
150 }

◆ 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.

135  {
137  return clusterToTrackingParticleVectorMap_.find(aCluster)->second;
138  } else {
140  }
141 }

◆ 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 }

◆ 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_.

◆ 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

COMBINATORIC means no NULLs and more than one good TP OR, in alternative, only one good TP but non-zero NULLS

Definition at line 270 of file TTClusterAssociationMap.h.

270  {
272  const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
273 
275  if (theseTrackingParticles.empty())
276  return false;
277 
278  bool genuineClu = this->isGenuine(aCluster);
279  bool unknownClu = this->isUnknown(aCluster);
280 
281  if (genuineClu || unknownClu)
282  return false;
283 
284  return true;
285 
287  unsigned int nullTPs = 0;
288  unsigned int goodDifferentTPs = 0;
289  std::vector<const TrackingParticle*> tpAddressVector;
290 
292  for (unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
294  TrackingParticlePtr curTP = theseTrackingParticles.at(itp);
295 
297  if (curTP.isNull()) {
298  nullTPs++;
299  } else {
302  tpAddressVector.push_back(curTP.get());
303  }
304  }
305 
307  std::sort(tpAddressVector.begin(), tpAddressVector.end());
308  tpAddressVector.erase(std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
309  goodDifferentTPs = tpAddressVector.size();
310 
313  //return ( ( nullTPs == 0 && goodDifferentTPs > 1 ) || ( nullTPs > 0 && goodDifferentTPs > 0 ) );
314  return (goodDifferentTPs > 1);
315 }

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

◆ 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 | C NEW 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.

177  {
179  const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
180 
182  if (theseTrackingParticles.empty())
183  return false;
184 
186  unsigned int nullTPs = 0;
187  unsigned int goodDifferentTPs = 0;
188  std::vector<const TrackingParticle*> tpAddressVector;
189 
190  std::vector<float> tp_mom;
191 
192  float tp_tot = 0;
193 
195  for (const auto& tp : theseTrackingParticles) {
197  const TrackingParticlePtr& curTP = tp;
198 
200  if (curTP.isNull()) {
201  // nullTPs++;
202  tp_mom.push_back(0);
203  } else {
204  tp_mom.push_back(curTP.get()->p4().pt());
205  tp_tot += curTP.get()->p4().pt();
206  }
207  }
208 
209  if (tp_tot == 0)
210  return false;
211 
212  for (unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
214  TrackingParticlePtr curTP = theseTrackingParticles.at(itp);
215 
217  if (tp_mom.at(itp) <= 0.01 * tp_tot) {
218  nullTPs++;
219  } else {
222  tpAddressVector.push_back(curTP.get());
223  }
224  }
225 
227  std::sort(tpAddressVector.begin(), tpAddressVector.end());
228  tpAddressVector.erase(std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
229  goodDifferentTPs = tpAddressVector.size();
230 
231  return (goodDifferentTPs == 1);
232 }

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

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

235  {
237  const std::vector<TrackingParticlePtr>& theseTrackingParticles = this->findTrackingParticlePtrs(aCluster);
238 
240  if (theseTrackingParticles.empty())
241  return true;
242 
244  unsigned int goodDifferentTPs = 0;
245  std::vector<const TrackingParticle*> tpAddressVector;
246 
248  for (unsigned int itp = 0; itp < theseTrackingParticles.size(); itp++) {
250  TrackingParticlePtr curTP = theseTrackingParticles.at(itp);
251 
253  if (!curTP.isNull()) {
256  tpAddressVector.push_back(curTP.get());
257  }
258  }
259 
261  std::sort(tpAddressVector.begin(), tpAddressVector.end());
262  tpAddressVector.erase(std::unique(tpAddressVector.begin(), tpAddressVector.end()), tpAddressVector.end());
263  goodDifferentTPs = tpAddressVector.size();
264 
266  return (goodDifferentTPs == 0);
267 }

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

◆ 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
TTClusterAssociationMap::findTrackingParticlePtrs
const std::vector< TrackingParticlePtr > & findTrackingParticlePtrs(TTClusterRefT< T > aCluster) const
Get all TPs associated to a cluster.
Definition: TTClusterAssociationMap.h:134
TTClusterAssociationMap::isGenuine
bool isGenuine(TTClusterRefT< T > aCluster) const
Definition: TTClusterAssociationMap.h:177
TrackingParticle::p4
const LorentzVector & p4() const
Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.
Definition: TrackingParticle.h:103
TTClusterAssociationMap::nullVecClusterRef_
static const std::vector< TTClusterRefT< T > > nullVecClusterRef_
Definition: TTClusterAssociationMap.h:91
TTClusterAssociationMap::clusterToTrackingParticleVectorMap_
MapClusToVecTP< T > clusterToTrackingParticleVectorMap_
Data members.
Definition: TTClusterAssociationMap.h:83
edm::Ptr::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
TTClusterAssociationMap::isUnknown
bool isUnknown(TTClusterRefT< T > aCluster) const
Cluster "unknown": i.e. not associated with any TP.
Definition: TTClusterAssociationMap.h:235
TTClusterAssociationMap::nullVecTrackingParticlePtr_
static const std::vector< TrackingParticlePtr > nullVecTrackingParticlePtr_
Definition: TTClusterAssociationMap.h:90
TTClusterAssociationMap::nullTrackingParticlePtr_
static const TrackingParticlePtr nullTrackingParticlePtr_
Close class.
Definition: TTClusterAssociationMap.h:89
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
TTClusterAssociationMap::trackingParticleToClusterVectorMap_
MapTPToVecClus< T > trackingParticleToClusterVectorMap_
Definition: TTClusterAssociationMap.h:84
edm::Ptr< TrackingParticle >
tier0.unique
def unique(seq, keepstr=True)
Definition: tier0.py:24
TTClusterAssociationMap::nclus
int nclus
Definition: TTClusterAssociationMap.h:86
edm::Ptr::isNull
bool isNull() const
Checks for null.
Definition: Ptr.h:142