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