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
track_associator::getHitFromIter
const TrackingRecHit * getHitFromIter(trackingRecHit_iterator iter)
Definition: trackHitsToClusterRefs.h:16
SiStripRecHit2D::cluster
ClusterRef cluster() const
Definition: SiStripRecHit2D.h:22
PixelSubdetector.h
MessageLogger.h
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
SiStripDetId.h
SiStripRecHit2D
Definition: SiStripRecHit2D.h:7
TrackingRecHitFwd.h
SiPixelRecHit::cluster
ClusterRef cluster() const
Definition: SiPixelRecHit.h:47
TrackingRecHit::geographicalId
DetId geographicalId() const
Definition: TrackingRecHit.h:120
SiPixelRecHit
Our base class.
Definition: SiPixelRecHit.h:23
track_associator::hitsToClusterRefs
std::vector< OmniClusterRef > hitsToClusterRefs(iter begin, iter end)
Definition: trackHitsToClusterRefs.h:21
Phase2TrackerRecHit1D::cluster
CluRef cluster() const
Definition: Phase2TrackerRecHit1D.h:24
mps_fire.end
end
Definition: mps_fire.py:242
SiStripMatchedRecHit2D::stereoHit
SiStripRecHit2D stereoHit() const
Definition: SiStripMatchedRecHit2D.h:25
VectorHit::cluster
ClusterRef cluster() const
Definition: VectorHit.h:108
SiPixelRecHit.h
SiStripDetId::TEC
static constexpr auto TEC
Definition: SiStripDetId.h:40
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
Phase2TrackerRecHit1D.h
VectorHit::firstClusterRef
OmniClusterRef const & firstClusterRef() const override
Definition: VectorHit.h:107
SiStripMatchedRecHit2D::stereoClusterRef
OmniClusterRef const & stereoClusterRef() const
Definition: SiStripMatchedRecHit2D.h:34
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
SiStripMatchedRecHit2D::monoHit
SiStripRecHit2D monoHit() const
Definition: SiStripMatchedRecHit2D.h:26
trackerHitRTTI::isFromDet
bool isFromDet(TrackingRecHit const &hit)
Definition: trackerHitRTTI.h:36
SiStripDetId::TOB
static constexpr auto TOB
Definition: SiStripDetId.h:39
SiStripRecHit1D::cluster
ClusterRef cluster() const
Definition: SiStripRecHit1D.h:18
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiStripRecHit1D
Definition: SiStripRecHit1D.h:8
SiStripMatchedRecHit2D::monoClusterRef
OmniClusterRef const & monoClusterRef() const
Definition: SiStripMatchedRecHit2D.h:35
TrackingRecHit
Definition: TrackingRecHit.h:21
SiStripRecHit1D.h
SiStripDetId::TID
static constexpr auto TID
Definition: SiStripDetId.h:38
VectorHit
Definition: VectorHit.h:28
track_associator
Definition: trackAssociationChi2.h:10
SiStripMatchedRecHit2D
Definition: SiStripMatchedRecHit2D.h:8
SiStripDetId::TIB
static constexpr auto TIB
Definition: SiStripDetId.h:37
SiStripMatchedRecHit2D.h
edm::Log
Definition: MessageLogger.h:70
TrackerSingleRecHit::omniClusterRef
OmniClusterRef const & omniClusterRef() const
Definition: TrackerSingleRecHit.h:41
SiStripRecHit2D.h
Phase2TrackerRecHit1D
Definition: Phase2TrackerRecHit1D.h:10
VectorHit.h