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 {
14  const TrackingRecHit *getHitFromIter(trackingRecHit_iterator iter) { return &(**iter); }
15 
16  const TrackingRecHit *getHitFromIter(TrackingRecHitCollection::const_iterator iter) { return &(*iter); }
17 
18  template <typename iter>
19  std::vector<OmniClusterRef> hitsToClusterRefs(iter begin, iter end) {
20  std::vector<OmniClusterRef> returnValue;
21  for (iter iRecHit = begin; iRecHit != end; ++iRecHit) {
22  const TrackingRecHit *rhit = getHitFromIter(iRecHit);
23  if (trackerHitRTTI::isFromDet(*rhit)) {
24  int subdetid = rhit->geographicalId().subdetId();
25  if (subdetid == PixelSubdetector::PixelBarrel || subdetid == PixelSubdetector::PixelEndcap) {
26  const SiPixelRecHit *pRHit = dynamic_cast<const SiPixelRecHit *>(rhit);
27  if (pRHit && !pRHit->cluster().isNonnull())
28  edm::LogError("TrackAssociator") << ">>> RecHit does not have an associated cluster!"
29  << " file: " << __FILE__ << " line: " << __LINE__;
30  returnValue.push_back(pRHit->omniClusterRef());
31  } else if (subdetid == SiStripDetId::TIB || subdetid == SiStripDetId::TOB || subdetid == SiStripDetId::TID ||
32  subdetid == SiStripDetId::TEC) {
33  const std::type_info &tid = typeid(*rhit);
34  if (tid == typeid(SiStripMatchedRecHit2D)) {
35  const SiStripMatchedRecHit2D *sMatchedRHit = dynamic_cast<const SiStripMatchedRecHit2D *>(rhit);
36  if (!sMatchedRHit->monoHit().cluster().isNonnull() || !sMatchedRHit->stereoHit().cluster().isNonnull())
37  edm::LogError("TrackAssociator") << ">>> RecHit does not have an associated cluster!"
38  << " file: " << __FILE__ << " line: " << __LINE__;
39  returnValue.push_back(sMatchedRHit->monoClusterRef());
40  returnValue.push_back(sMatchedRHit->stereoClusterRef());
41  } else if (tid == typeid(SiStripRecHit2D)) {
42  const SiStripRecHit2D *sRHit = dynamic_cast<const SiStripRecHit2D *>(rhit);
43  if (!sRHit->cluster().isNonnull())
44  edm::LogError("TrackAssociator") << ">>> RecHit does not have an associated cluster!"
45  << " file: " << __FILE__ << " line: " << __LINE__;
46  returnValue.push_back(sRHit->omniClusterRef());
47  } else if (tid == typeid(SiStripRecHit1D)) {
48  const SiStripRecHit1D *sRHit = dynamic_cast<const SiStripRecHit1D *>(rhit);
49  if (!sRHit->cluster().isNonnull())
50  edm::LogError("TrackAssociator") << ">>> RecHit does not have an associated cluster!"
51  << " file: " << __FILE__ << " line: " << __LINE__;
52  returnValue.push_back(sRHit->omniClusterRef());
53  } else if (tid == typeid(Phase2TrackerRecHit1D)) {
54  const Phase2TrackerRecHit1D *ph2Hit = dynamic_cast<const Phase2TrackerRecHit1D *>(rhit);
55  if (!ph2Hit->cluster().isNonnull())
56  edm::LogError("TrackAssociator") << ">>> RecHit does not have an associated cluster!"
57  << " file: " << __FILE__ << " line: " << __LINE__;
58  returnValue.push_back(ph2Hit->omniClusterRef());
59  } else {
60  auto const &thit = static_cast<BaseTrackerRecHit const &>(*rhit);
61  if (thit.isProjected()) {
62  } else {
63  edm::LogError("TrackAssociator") << ">>> getMatchedClusters: TrackingRecHit not associated to "
64  "any SiStripCluster! subdetid = "
65  << subdetid;
66  }
67  }
68  } else {
69  edm::LogError("TrackAssociator") << ">>> getMatchedClusters: TrackingRecHit not associated to any "
70  "cluster! subdetid = "
71  << subdetid;
72  }
73  }
74  }
75  return returnValue;
76  }
77 } // namespace track_associator
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