CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
tt::StubAssociation Class Reference

Class to associate reconstrucable TrackingParticles with TTStubs and vice versa. It may associate multiple TPs with a TTStub and can therefore be used to associate TTTracks with TrackingParticles. More...

#include <StubAssociation.h>

Public Member Functions

std::vector< TPPtrassociate (const std::vector< TTStubRef > &ttStubRefs) const
 
std::vector< TPPtrassociateFinal (const std::vector< TTStubRef > &ttStubRefs) const
 
std::vector< TPPtrfindTrackingParticlePtrs (const TTStubRef &ttStubRef) const
 
std::vector< TTStubReffindTTStubRefs (const TPPtr &tpPtr) const
 
const std::map< TPPtr, std::vector< TTStubRef > > & getTrackingParticleToTTStubsMap () const
 
const std::map< TTStubRef, std::vector< TPPtr > > & getTTStubToTrackingParticlesMap () const
 
void insert (const TPPtr &tpPtr, const std::vector< TTStubRef > &ttSTubRefs)
 
int numStubs () const
 
int numTPs () const
 
 StubAssociation ()
 
 StubAssociation (const Setup *setup)
 
 ~StubAssociation ()
 

Private Attributes

const std::vector< TPPtremptyTPPtrs_
 
const std::vector< TTStubRefemptyTTStubRefs_
 
std::map< TPPtr, std::vector< TTStubRef > > mapTPPtrsTTStubRefs_
 
std::map< TTStubRef, std::vector< TPPtr > > mapTTStubRefsTPPtrs_
 
const Setupsetup_
 

Detailed Description

Class to associate reconstrucable TrackingParticles with TTStubs and vice versa. It may associate multiple TPs with a TTStub and can therefore be used to associate TTTracks with TrackingParticles.

Author
Thomas Schuh
Date
2020, Apr

Definition at line 19 of file StubAssociation.h.

Constructor & Destructor Documentation

◆ StubAssociation() [1/2]

tt::StubAssociation::StubAssociation ( )
inline

Definition at line 21 of file StubAssociation.h.

References setup_.

21 { setup_ = nullptr; }
const Setup * setup_

◆ StubAssociation() [2/2]

tt::StubAssociation::StubAssociation ( const Setup setup)
inline

Definition at line 22 of file StubAssociation.h.

22 : setup_(setup) {}
const Setup * setup_

◆ ~StubAssociation()

tt::StubAssociation::~StubAssociation ( )
inline

Definition at line 23 of file StubAssociation.h.

23 {}

Member Function Documentation

◆ associate()

vector< TPPtr > tt::StubAssociation::associate ( const std::vector< TTStubRef > &  ttStubRefs) const

Definition at line 33 of file StubAssociation.cc.

References edm::eventsetup::heterocontainer::insert(), createfilelist::int, visualization-live-secondInstance_cfg::m, and AlCaHLTBitMon_ParallelJobs::p.

33  {
34  // count associated layer for each TP
35  map<TPPtr, set<int>> m;
36  map<TPPtr, set<int>> mPS;
37  for (const TTStubRef& ttStubRef : ttStubRefs) {
38  for (const TPPtr& tpPtr : findTrackingParticlePtrs(ttStubRef)) {
39  const int layerId = setup_->layerId(ttStubRef);
40  m[tpPtr].insert(layerId);
41  if (setup_->psModule(ttStubRef))
42  mPS[tpPtr].insert(layerId);
43  }
44  }
45  // count matched TPs
46  auto acc = [this](int sum, const pair<TPPtr, set<int>>& p) {
47  return sum + ((int)p.second.size() < setup_->tpMinLayers() ? 0 : 1);
48  };
49  const int nTPs = accumulate(m.begin(), m.end(), 0, acc);
50  vector<TPPtr> tpPtrs;
51  tpPtrs.reserve(nTPs);
52  // fill and return matched TPs
53  for (const auto& p : m)
54  if ((int)p.second.size() >= setup_->tpMinLayers() && (int)mPS[p.first].size() >= setup_->tpMinLayersPS())
55  tpPtrs.push_back(p.first);
56  return tpPtrs;
57  }
int tpMinLayersPS() const
Definition: Setup.h:198
int layerId(const TTStubRef &ttStubRef) const
Definition: Setup.cc:511
const Setup * setup_
bool psModule(int dtcId) const
Definition: Setup.cc:322
int tpMinLayers() const
Definition: Setup.h:196
void insert(const TPPtr &tpPtr, const std::vector< TTStubRef > &ttSTubRefs)
std::vector< TPPtr > findTrackingParticlePtrs(const TTStubRef &ttStubRef) const

◆ associateFinal()

std::vector< TPPtr > tt::StubAssociation::associateFinal ( const std::vector< TTStubRef > &  ttStubRefs) const

Definition at line 60 of file StubAssociation.cc.

References RPCNoise_example::check, and spr::find().

60  {
61  // Get all TPs that are matched to these stubs in at least 'tpMinLayers' layers and 'tpMinLayersPS' ps layers
62  vector<TPPtr> tpPtrs = associate(ttStubRefs);
63  // remove TPs with more then 'tpMaxBadStubs2S' not associated 2S stubs and more then 'tpMaxBadStubsPS' not associated PS stubs
64  auto check = [this, &ttStubRefs](const TPPtr& tpPtr) {
65  int bad2S(0);
66  int badPS(0);
67  for (const TTStubRef& ttStubRef : ttStubRefs) {
68  const vector<TPPtr>& tpPtrs = findTrackingParticlePtrs(ttStubRef);
69  if (find(tpPtrs.begin(), tpPtrs.end(), tpPtr) == tpPtrs.end())
70  setup_->psModule(ttStubRef) ? badPS++ : bad2S++;
71  }
72  if (badPS > setup_->tpMaxBadStubsPS() || bad2S > setup_->tpMaxBadStubs2S())
73  return true;
74  return false;
75  };
76  tpPtrs.erase(remove_if(tpPtrs.begin(), tpPtrs.end(), check), tpPtrs.end());
77  return tpPtrs;
78  }
int tpMaxBadStubs2S() const
Definition: Setup.h:200
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
int tpMaxBadStubsPS() const
Definition: Setup.h:202
const Setup * setup_
bool psModule(int dtcId) const
Definition: Setup.cc:322
std::vector< TPPtr > findTrackingParticlePtrs(const TTStubRef &ttStubRef) const
std::vector< TPPtr > associate(const std::vector< TTStubRef > &ttStubRefs) const

◆ findTrackingParticlePtrs()

vector< TPPtr > tt::StubAssociation::findTrackingParticlePtrs ( const TTStubRef ttStubRef) const

Definition at line 20 of file StubAssociation.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it.

20  {
21  const auto it = mapTTStubRefsTPPtrs_.find(ttStubRef);
22  const vector<TPPtr> res = it != mapTTStubRefsTPPtrs_.end() ? it->second : emptyTPPtrs_;
23  return res;
24  }
const std::vector< TPPtr > emptyTPPtrs_
Definition: Electron.h:6
std::map< TTStubRef, std::vector< TPPtr > > mapTTStubRefsTPPtrs_

◆ findTTStubRefs()

vector< TTStubRef > tt::StubAssociation::findTTStubRefs ( const TPPtr tpPtr) const

Definition at line 27 of file StubAssociation.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it.

27  {
28  const auto it = mapTPPtrsTTStubRefs_.find(tpPtr);
29  return it != mapTPPtrsTTStubRefs_.end() ? it->second : emptyTTStubRefs_;
30  }
const std::vector< TTStubRef > emptyTTStubRefs_
std::map< TPPtr, std::vector< TTStubRef > > mapTPPtrsTTStubRefs_

◆ getTrackingParticleToTTStubsMap()

const std::map<TPPtr, std::vector<TTStubRef> >& tt::StubAssociation::getTrackingParticleToTTStubsMap ( ) const
inline

Definition at line 31 of file StubAssociation.h.

References mapTPPtrsTTStubRefs_.

31  {
32  return mapTPPtrsTTStubRefs_;
33  }
std::map< TPPtr, std::vector< TTStubRef > > mapTPPtrsTTStubRefs_

◆ getTTStubToTrackingParticlesMap()

const std::map<TTStubRef, std::vector<TPPtr> >& tt::StubAssociation::getTTStubToTrackingParticlesMap ( ) const
inline

Definition at line 27 of file StubAssociation.h.

References mapTTStubRefsTPPtrs_.

27  {
28  return mapTTStubRefsTPPtrs_;
29  }
std::map< TTStubRef, std::vector< TPPtr > > mapTTStubRefsTPPtrs_

◆ insert()

void tt::StubAssociation::insert ( const TPPtr tpPtr,
const std::vector< TTStubRef > &  ttSTubRefs 
)

Definition at line 13 of file StubAssociation.cc.

Referenced by tt::StubAssociator::produce().

13  {
14  mapTPPtrsTTStubRefs_.insert({tpPtr, ttSTubRefs});
15  for (const TTStubRef& ttSTubRef : ttSTubRefs)
16  mapTTStubRefsTPPtrs_[ttSTubRef].push_back(tpPtr);
17  }
std::map< TPPtr, std::vector< TTStubRef > > mapTPPtrsTTStubRefs_
std::map< TTStubRef, std::vector< TPPtr > > mapTTStubRefsTPPtrs_

◆ numStubs()

int tt::StubAssociation::numStubs ( ) const
inline

Definition at line 39 of file StubAssociation.h.

References mapTTStubRefsTPPtrs_.

39 { return mapTTStubRefsTPPtrs_.size(); };
std::map< TTStubRef, std::vector< TPPtr > > mapTTStubRefsTPPtrs_

◆ numTPs()

int tt::StubAssociation::numTPs ( ) const
inline

Definition at line 41 of file StubAssociation.h.

References mapTPPtrsTTStubRefs_.

41 { return mapTPPtrsTTStubRefs_.size(); };
std::map< TPPtr, std::vector< TTStubRef > > mapTPPtrsTTStubRefs_

Member Data Documentation

◆ emptyTPPtrs_

const std::vector<TPPtr> tt::StubAssociation::emptyTPPtrs_
private

Definition at line 55 of file StubAssociation.h.

◆ emptyTTStubRefs_

const std::vector<TTStubRef> tt::StubAssociation::emptyTTStubRefs_
private

Definition at line 57 of file StubAssociation.h.

◆ mapTPPtrsTTStubRefs_

std::map<TPPtr, std::vector<TTStubRef> > tt::StubAssociation::mapTPPtrsTTStubRefs_
private

Definition at line 53 of file StubAssociation.h.

Referenced by getTrackingParticleToTTStubsMap(), and numTPs().

◆ mapTTStubRefsTPPtrs_

std::map<TTStubRef, std::vector<TPPtr> > tt::StubAssociation::mapTTStubRefsTPPtrs_
private

Definition at line 51 of file StubAssociation.h.

Referenced by getTTStubToTrackingParticlesMap(), and numStubs().

◆ setup_

const Setup* tt::StubAssociation::setup_
private