CMS 3D CMS Logo

TrackerSingleRecHit.cc
Go to the documentation of this file.
2 #include <iostream>
3 #include <typeinfo>
9 
10 //#define DO_INTERNAL_CHECKS
11 #if defined(DO_INTERNAL_CHECKS)
12 namespace {
13 
14  void verify(OmniClusterRef const ref) {
15  std::cout << ref.rawIndex() << " " << ref.isValid() << " " << ref.isPixel() << " " << ref.isStrip() << " " <<
16  // ref.isRegional() << " " <<
17  ref.cluster_strip().isNull() << " " << ref.cluster_pixel().isNull() << " " << std::endl;
18  }
19 
20  void verify(TrackingRecHit const *thit) {
21  static bool once = true;
22  if (once) {
23  once = false;
24  DetId Lim(DetId::Tracker, 3);
25  std::cout << "detid lim " << (Lim.rawId() >> (DetId::kSubdetOffset)) << std::endl;
26  }
27  int id = thit->geographicalId().rawId();
28  int subd = thit->geographicalId().rawId() >> (DetId::kSubdetOffset);
29 
30  if (trackerHitRTTI::isNotFromDet(*thit)) {
31  static int n = 0;
32  if (++n < 5) {
33  std::cout << "NotFromDet:" << subd << " " << (id & 3) << " " << thit->dimension() << ". " << std::endl;
34  }
35  return;
36  }
37 
38  TrackerSingleRecHit const *hit = dynamic_cast<TrackerSingleRecHit const *>(thit);
39  BaseTrackerRecHit const *bhit = dynamic_cast<BaseTrackerRecHit const *>(thit);
40  if (!bhit)
41  std::cout << "not a tracker hit! " << typeid(*thit).name() << std::endl;
42 
43  if (trackerHitRTTI::isUndef(*thit))
44  std::cout << "undef hit! " << typeid(*thit).name() << std::endl;
45 
46  if (dynamic_cast<SiPixelRecHit const *>(hit)) {
47  static int n = 0;
48  if (++n < 5) {
49  std::cout << "Pixel:" << subd << " " << bhit->isSingle() << ". ";
50  verify(hit->omniCluster());
51  }
52  }
53  if (dynamic_cast<SiStripRecHit1D const *>(hit)) {
54  static int n = 0;
55  if (++n < 5) {
56  std::cout << "Strip1D:" << subd << " " << (id & 3) << " " << bhit->isSingle() << ". ";
57  verify(hit->omniCluster());
58  }
59  }
60  if (dynamic_cast<SiStripRecHit2D const *>(hit)) {
61  static int n = 0;
62  if (++n < 5) {
63  std::cout << "Strip2D:" << subd << " " << (id & 3) << " " << bhit->isSingle() << ". ";
64  verify(hit->omniCluster());
65  }
66  }
67  if (dynamic_cast<SiStripMatchedRecHit2D const *>(thit)) {
68  static int n = 0;
69  if (++n < 5) {
70  std::cout << "Strip Matched:" << subd << " " << (id & 3) << " " << bhit->isMatched() << ". " << std::endl;
71  // verify(hit->omniCluster());
72  }
73  }
74  if (dynamic_cast<ProjectedSiStripRecHit2D const *>(thit)) {
75  static int n = 0;
76  if (++n < 5) {
77  std::cout << "Strip Matched:" << subd << " " << (id & 3) << " " << bhit->isProjected() << ". " << std::endl;
78  // verify(hit->omniCluster());
79  }
80  }
81  }
82 
83  void problem(const TrackingRecHit *thit, const char *what) {
84  std::cout << "not sharing with itself! " << what << " " << typeid(*thit).name() << std::endl;
85  verify(thit);
86  }
87 
88  bool doingCheck = false;
89  inline void checkSelf(const TrackingRecHit *one, const TrackingRecHit *two) {
90  doingCheck = true;
91  if (!one->sharesInput(one, TrackingRecHit::all))
92  problem(one, "all");
93  if (!one->sharesInput(one, TrackingRecHit::some))
94  problem(one, "some");
95  if (!two->sharesInput(two, TrackingRecHit::all))
96  problem(two, "all");
97  if (!two->sharesInput(two, TrackingRecHit::some))
98  problem(two, "some");
99  doingCheck = false;
100  }
101 } // namespace
102 #endif
103 
105 #if defined(DO_INTERNAL_CHECKS)
106  verify(this);
107  verify(other);
108  if (!doingCheck && (other != this))
109  checkSelf(this, other);
110 #endif
111 
112  if (!sameDetModule(*other))
113  return false;
114 
115  // move to switch?
117  const TrackerSingleRecHit &otherCast = static_cast<const TrackerSingleRecHit &>(*other);
118  return sharesInput(otherCast);
119  }
120 
122  if (what == all)
123  return false;
124  return static_cast<SiStripMatchedRecHit2D const &>(*other).sharesInput(*this);
125  }
126 
127  // last resort, recur to 'recHits()', even if it returns a vector by value
128  std::vector<const TrackingRecHit *> otherHits = other->recHits();
129  int ncomponents = otherHits.size();
130  if (ncomponents == 0)
131  return false; //bho
132  if (ncomponents == 1)
133  return sharesInput(otherHits.front(), what);
134  // ncomponents>1
135  if (what == all)
136  return false;
137 
138  for (int i = 0; i < ncomponents; i++) {
139  if (sharesInput(otherHits[i], what))
140  return true;
141  }
142  return false;
143 }
144 
145 // a simple hit has no components
146 std::vector<const TrackingRecHit *> TrackerSingleRecHit::recHits() const {
147  std::vector<const TrackingRecHit *> nullvector;
148  return nullvector;
149 }
150 std::vector<TrackingRecHit *> TrackerSingleRecHit::recHits() {
151  std::vector<TrackingRecHit *> nullvector;
152  return nullvector;
153 }
TrackerSingleRecHit::recHits
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
Definition: TrackerSingleRecHit.cc:146
BaseTrackerRecHit::isMatched
bool isMatched() const
Definition: BaseTrackerRecHit.h:37
mps_fire.i
i
Definition: mps_fire.py:355
BaseTrackerRecHit::sameDetModule
bool sameDetModule(TrackingRecHit const &hit) const
Definition: BaseTrackerRecHit.h:133
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm::Ref::isNull
bool isNull() const
Checks for null.
Definition: Ref.h:235
OmniClusterRef::isPixel
bool isPixel() const
Definition: OmniClusterRef.h:79
gather_cfg.cout
cout
Definition: gather_cfg.py:144
trackerHitRTTI::isUndef
bool isUndef(TrackingRecHit const &hit)
Definition: trackerHitRTTI.h:23
OmniClusterRef::rawIndex
unsigned int rawIndex() const
Definition: OmniClusterRef.h:72
OmniClusterRef
Definition: OmniClusterRef.h:12
TrackingRecHit::geographicalId
DetId geographicalId() const
Definition: TrackingRecHit.h:120
DetId::kSubdetOffset
static const int kSubdetOffset
Definition: DetId.h:22
DetId
Definition: DetId.h:17
TrackerSingleRecHit::sharesInput
bool sharesInput(const TrackingRecHit *other, SharedInputType what) const final
Definition: TrackerSingleRecHit.cc:104
TrackingRecHit::SharedInputType
SharedInputType
definition of equality via shared input
Definition: TrackingRecHit.h:59
OmniClusterRef::cluster_strip
ClusterStripRef cluster_strip() const
Definition: OmniClusterRef.h:44
BaseTrackerRecHit
Definition: BaseTrackerRecHit.h:15
trackingPlots.other
other
Definition: trackingPlots.py:1465
TrackingRecHit::some
Definition: TrackingRecHit.h:59
SiPixelRecHit.h
trackerHitRTTI::isMatched
bool isMatched(TrackingRecHit const &hit)
Definition: trackerHitRTTI.h:32
DetId::Tracker
Definition: DetId.h:25
TrackingRecHit::all
Definition: TrackingRecHit.h:59
OmniClusterRef::isStrip
bool isStrip() const
Definition: OmniClusterRef.h:80
ProjectedSiStripRecHit2D.h
TrackingRecHit
Definition: TrackingRecHit.h:21
SiStripRecHit1D.h
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
TrackingRecHit::dimension
virtual int dimension() const =0
BaseTrackerRecHit::isSingle
bool isSingle() const
Definition: BaseTrackerRecHit.h:36
TrackerSingleRecHit
Definition: TrackerSingleRecHit.h:11
TrackingRecHit::sharesInput
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
Definition: TrackingRecHit.cc:12
BaseTrackerRecHit::isProjected
bool isProjected() const
Definition: BaseTrackerRecHit.h:38
TrackerSingleRecHit.h
trackerHitRTTI::isSingleType
bool isSingleType(TrackingRecHit const &hit)
Definition: trackerHitRTTI.h:34
SiStripMatchedRecHit2D.h
OmniClusterRef::isValid
bool isValid() const
Definition: OmniClusterRef.h:78
SiStripRecHit2D.h
OmniClusterRef::cluster_pixel
ClusterPixelRef cluster_pixel() const
Definition: OmniClusterRef.h:40
hit
Definition: SiStripHitEffFromCalibTree.cc:88