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
track_associator::getHitFromIter
const TrackingRecHit * getHitFromIter(trackingRecHit_iterator iter)
Definition: trackHitsToClusterRefs.h:14
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
end
#define end
Definition: vmac.h:39
track_associator::hitsToClusterRefs
std::vector< OmniClusterRef > hitsToClusterRefs(iter begin, iter end)
Definition: trackHitsToClusterRefs.h:19
Phase2TrackerRecHit1D::cluster
CluRef cluster() const
Definition: Phase2TrackerRecHit1D.h:24
SiStripMatchedRecHit2D::stereoHit
SiStripRecHit2D stereoHit() const
Definition: SiStripMatchedRecHit2D.h:25
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
edm::LogError
Definition: MessageLogger.h:183
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:35
SiStripDetId::TOB
static constexpr auto TOB
Definition: SiStripDetId.h:39
SiStripRecHit1D::cluster
ClusterRef cluster() const
Definition: SiStripRecHit1D.h:18
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
track_associator
Definition: trackAssociationChi2.h:10
SiStripMatchedRecHit2D
Definition: SiStripMatchedRecHit2D.h:8
SiStripDetId::TIB
static constexpr auto TIB
Definition: SiStripDetId.h:37
SiStripMatchedRecHit2D.h
TrackerSingleRecHit::omniClusterRef
OmniClusterRef const & omniClusterRef() const
Definition: TrackerSingleRecHit.h:41
SiStripRecHit2D.h
begin
#define begin
Definition: vmac.h:32
Phase2TrackerRecHit1D
Definition: Phase2TrackerRecHit1D.h:10