CMS 3D CMS Logo

trackHitsToClusterRefs.h
Go to the documentation of this file.
1 #ifndef SimTracker_TrackAssociation_trackHitsToClusterRefs_h
2 #define SimTracker_TrackAssociation_trackHitsToClusterRefs_h
3 
12 
13 namespace track_associator {
15  return &(**iter);
16  }
17 
18  const TrackingRecHit* getHitFromIter(TrackingRecHitCollection::const_iterator iter) {
19  return &(*iter);
20  }
21 
22  template<typename iter>
23  std::vector<OmniClusterRef> hitsToClusterRefs(iter begin, iter end) {
24  std::vector<OmniClusterRef> returnValue;
25  for (iter iRecHit = begin; iRecHit != end; ++iRecHit) {
26  const TrackingRecHit* rhit = getHitFromIter(iRecHit);
27  if (trackerHitRTTI::isFromDet(*rhit) ) {
28  int subdetid = rhit->geographicalId().subdetId();
30  const SiPixelRecHit* pRHit = dynamic_cast<const SiPixelRecHit*>(rhit);
31  if (pRHit && !pRHit->cluster().isNonnull())
32  edm::LogError("TrackAssociator") << ">>> RecHit does not have an associated cluster!" << " file: " << __FILE__ << " line: " << __LINE__;
33  returnValue.push_back(pRHit->omniClusterRef());
34  }
35  else if (subdetid==SiStripDetId::TIB||subdetid==SiStripDetId::TOB||subdetid==SiStripDetId::TID||subdetid==SiStripDetId::TEC) {
36  const std::type_info &tid = typeid(*rhit);
37  if (tid == typeid(SiStripMatchedRecHit2D)) {
38  const SiStripMatchedRecHit2D* sMatchedRHit = dynamic_cast<const SiStripMatchedRecHit2D*>(rhit);
39  if (!sMatchedRHit->monoHit().cluster().isNonnull() || !sMatchedRHit->stereoHit().cluster().isNonnull())
40  edm::LogError("TrackAssociator") << ">>> RecHit does not have an associated cluster!" << " file: " << __FILE__ << " line: " << __LINE__;
41  returnValue.push_back(sMatchedRHit->monoClusterRef());
42  returnValue.push_back(sMatchedRHit->stereoClusterRef());
43  }
44  else if (tid == typeid(SiStripRecHit2D)) {
45  const SiStripRecHit2D* sRHit = dynamic_cast<const SiStripRecHit2D*>(rhit);
46  if (!sRHit->cluster().isNonnull())
47  edm::LogError("TrackAssociator") << ">>> RecHit does not have an associated cluster!" << " file: " << __FILE__ << " line: " << __LINE__;
48  returnValue.push_back(sRHit->omniClusterRef());
49  }
50  else if (tid == typeid(SiStripRecHit1D)) {
51  const SiStripRecHit1D* sRHit = dynamic_cast<const SiStripRecHit1D*>(rhit);
52  if (!sRHit->cluster().isNonnull())
53  edm::LogError("TrackAssociator") << ">>> RecHit does not have an associated cluster!" << " file: " << __FILE__ << " line: " << __LINE__;
54  returnValue.push_back(sRHit->omniClusterRef());
55  }
56  else if (tid == typeid(Phase2TrackerRecHit1D)) {
57  const Phase2TrackerRecHit1D* ph2Hit = dynamic_cast<const Phase2TrackerRecHit1D*>(rhit);
58  if (!ph2Hit->cluster().isNonnull() )
59  edm::LogError("TrackAssociator") << ">>> RecHit does not have an associated cluster!" << " file: " << __FILE__ << " line: " << __LINE__;
60  returnValue.push_back(ph2Hit->omniClusterRef());
61  }
62  else {
63  auto const & thit = static_cast<BaseTrackerRecHit const&>(*rhit);
64  if ( thit.isProjected() ) {
65  } else {
66  edm::LogError("TrackAssociator") << ">>> getMatchedClusters: TrackingRecHit not associated to any SiStripCluster! subdetid = " << subdetid;
67  }
68  }
69  }
70  else {
71  edm::LogError("TrackAssociator") << ">>> getMatchedClusters: TrackingRecHit not associated to any cluster! subdetid = " << subdetid;
72  }
73  }
74  }
75  return returnValue;
76  }
77 }
78 
79 #endif
ClusterRef cluster() const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
bool isFromDet(TrackingRecHit const &hit)
OmniClusterRef const & stereoClusterRef() const
std::vector< OmniClusterRef > hitsToClusterRefs(iter begin, iter end)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
ClusterRef cluster() const
#define end
Definition: vmac.h:39
OmniClusterRef const & monoClusterRef() const
OmniClusterRef const & omniClusterRef() const
SiStripRecHit2D stereoHit() const
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
const TrackingRecHit * getHitFromIter(trackingRecHit_iterator iter)
SiStripRecHit2D monoHit() const
#define begin
Definition: vmac.h:32
DetId geographicalId() const
Our base class.
Definition: SiPixelRecHit.h:23