CMS 3D CMS Logo

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