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