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