CMS 3D CMS Logo

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