CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RoadSearchHitSorting.cc
Go to the documentation of this file.
1 //
2 // Package: TrackingTools/RoadSearchHitSorting
3 // Class: SortHitsByGlobalPosition
4 // SortHitPointersByGLobalPosition
5 //
6 // Description: various sortings for TrackingRecHits
7 //
8 // Original Author: Oliver Gutsche, gutsche@fnal.gov
9 // Created: Fri Jul 6 13:37:38 UTC 2007
10 //
11 // $Author: gutsche $
12 // $Date: 2007/07/10 00:15:14 $
13 // $Revision: 1.2 $
14 //
15 
17 
19 
23 
25 
26  DetId ida(a.geographicalId());
27  DetId idb(b.geographicalId());
28 
29  unsigned int idetA = static_cast<unsigned int>(ida.subdetId());
30  unsigned int idetB = static_cast<unsigned int>(idb.subdetId());
31 
32  //check for mixed case...
33  bool same_det = (
34  (idetA == StripSubdetector::TIB && idetB == StripSubdetector::TIB) ||
35  (idetA == StripSubdetector::TID && idetB == StripSubdetector::TID) ||
36  (idetA == StripSubdetector::TIB && idetB == StripSubdetector::TID) ||
37  (idetA == StripSubdetector::TID && idetB == StripSubdetector::TIB) ||
38 
39  (idetA == StripSubdetector::TOB && idetB == StripSubdetector::TOB) ||
40  (idetA == StripSubdetector::TEC && idetB == StripSubdetector::TEC) ||
41  (idetA == StripSubdetector::TOB && idetB == StripSubdetector::TEC) ||
42  (idetA == StripSubdetector::TEC && idetB == StripSubdetector::TOB) ||
43 
48 
49  if (!same_det) return (idetA < idetB);
50 
51  if( (idetA == StripSubdetector::TIB || idetA == StripSubdetector::TOB || idetA == PixelSubdetector::PixelBarrel) &&
53  return static_cast<unsigned int>(geometry->idToDet(ida)->surface().toGlobal(a.localPosition()).perp() * 1E7) < static_cast<unsigned int>(geometry->idToDet(idb)->surface().toGlobal(b.localPosition()).perp() * 1E7);
54  }
55 
56  if( (idetA == StripSubdetector::TEC || idetA == StripSubdetector::TID || idetA == PixelSubdetector::PixelEndcap) &&
58  return static_cast<unsigned int>(std::abs(geometry->idToDet(ida)->surface().toGlobal(a.localPosition()).z()) * 1E7) < static_cast<unsigned int>(std::abs(geometry->idToDet(idb)->surface().toGlobal(b.localPosition()).z()) * 1E7);
59  }
60 
61  //
62  // here I have 1 barrel against one forward
63  //
64 
65  if( (idetA == StripSubdetector::TIB || idetA == StripSubdetector::TOB || idetA == PixelSubdetector::PixelBarrel) &&
67  return barrelForwardLess( a, b);
68  }else{
69  return !barrelForwardLess( b, a);
70  }
71 
72  throw Genexception("SortHitsByGlobalPosition: arguments are not Ok");
73 }
74 
76  //
77  // for the moment sort again in z, but since the z in the barrel is wrong (it is in the centre of the module)
78  // add the semi length
79  //
80  DetId ida(a.geographicalId());
81  DetId idb(b.geographicalId());
82  return static_cast<unsigned int>(std::abs( geometry->idToDet(ida)->surface().toGlobal(a.localPosition()).z()) * 1E7) < static_cast<unsigned int>(std::abs( geometry->idToDet(idb)->surface().toGlobal(b.localPosition()).z()) * 1E7);
83 }
84 
86 
87  DetId ida(a->geographicalId());
88  DetId idb(b->geographicalId());
89 
90  unsigned int idetA = static_cast<unsigned int>(ida.subdetId());
91  unsigned int idetB = static_cast<unsigned int>(idb.subdetId());
92 
93  //check for mixed case...
94  bool same_det = (
95  (idetA == StripSubdetector::TIB && idetB == StripSubdetector::TIB) ||
96  (idetA == StripSubdetector::TID && idetB == StripSubdetector::TID) ||
97  (idetA == StripSubdetector::TIB && idetB == StripSubdetector::TID) ||
98  (idetA == StripSubdetector::TID && idetB == StripSubdetector::TIB) ||
99 
100  (idetA == StripSubdetector::TOB && idetB == StripSubdetector::TOB) ||
101  (idetA == StripSubdetector::TEC && idetB == StripSubdetector::TEC) ||
102  (idetA == StripSubdetector::TOB && idetB == StripSubdetector::TEC) ||
103  (idetA == StripSubdetector::TEC && idetB == StripSubdetector::TOB) ||
104 
109 
110  if (!same_det) return (idetA < idetB);
111 
112  if( (idetA == StripSubdetector::TIB || idetA == StripSubdetector::TOB || idetA == PixelSubdetector::PixelBarrel) &&
113  (idetB == StripSubdetector::TIB || idetB == StripSubdetector::TOB || idetB == PixelSubdetector::PixelBarrel)) {
114  return static_cast<unsigned int>(geometry->idToDet(ida)->surface().toGlobal(a->localPosition()).perp() * 1E7) < static_cast<unsigned int>(geometry->idToDet(idb)->surface().toGlobal(b->localPosition()).perp() * 1E7);
115  }
116 
117  if( (idetA == StripSubdetector::TEC || idetA == StripSubdetector::TID || idetA == PixelSubdetector::PixelEndcap) &&
118  (idetB == StripSubdetector::TEC || idetB == StripSubdetector::TID || idetB == PixelSubdetector::PixelEndcap)) {
119  return static_cast<unsigned int>(std::abs(geometry->idToDet(ida)->surface().toGlobal(a->localPosition()).z()) * 1E7) < static_cast<unsigned int>(std::abs(geometry->idToDet(idb)->surface().toGlobal(b->localPosition()).z()) * 1E7);
120  }
121 
122  //
123  // here I have 1 barrel against one forward
124  //
125 
126  if( (idetA == StripSubdetector::TIB || idetA == StripSubdetector::TOB || idetA == PixelSubdetector::PixelBarrel) &&
128  return barrelForwardLess( a, b);
129  }else{
130  return !barrelForwardLess( b, a);
131  }
132 
133  throw Genexception("SortHitPointersByGlobalPosition: arguments are not Ok");
134 }
135 
137  //
138  // for the moment sort again in z, but since the z in the barrel is wrong (it is in the centre of the module)
139  // add the semi length
140  //
141  DetId ida(a->geographicalId());
142  DetId idb(b->geographicalId());
143  return static_cast<unsigned int>(std::abs( geometry->idToDet(ida)->surface().toGlobal(a->localPosition()).z()) * 1E7) < static_cast<unsigned int>(std::abs( geometry->idToDet(idb)->surface().toGlobal(b->localPosition()).z()) * 1E7);
144 }
145 
146 bool SortHitTrajectoryPairsByGlobalPosition::InsideOutCompare(const std::pair<TransientTrackingRecHit::ConstRecHitPointer, TrajectoryMeasurement*>& HitTM1 ,
147  const std::pair<TransientTrackingRecHit::ConstRecHitPointer, TrajectoryMeasurement*>& HitTM2 ) const
148 {
149 
150 
151  DetId ida(HitTM1.first->det()->geographicalId());
152  DetId idb(HitTM2.first->det()->geographicalId());
153 
154 
155  LogDebug("RoadSearch")<<" Comparing (r/phi/z) Hit 1 on DetID "
156  << ida.rawId() << " : "
157  << HitTM1.first->globalPosition().perp() << " / "
158  << HitTM1.first->globalPosition().phi() << " / "
159  << HitTM1.first->globalPosition().z()
160  << " and Hit 2 on DetID "
161  << idb.rawId() << " : "
162  << HitTM2.first->globalPosition().perp() << " / "
163  << HitTM2.first->globalPosition().phi() << " / "
164  << HitTM2.first->globalPosition().z() ;
165 
166 
167  if( ((unsigned int)ida.subdetId() == StripSubdetector::TIB || (unsigned int)ida.subdetId() == StripSubdetector::TOB || (unsigned int)ida.subdetId() == PixelSubdetector::PixelBarrel) &&
168  ((unsigned int)idb.subdetId() == StripSubdetector::TIB || (unsigned int)idb.subdetId() == StripSubdetector::TOB || (unsigned int)idb.subdetId() == PixelSubdetector::PixelBarrel)) { // barrel with barrel
169  return static_cast<unsigned int>(HitTM1.first->globalPosition().perp() * 1E7) < static_cast<unsigned int>(HitTM2.first->globalPosition().perp() * 1E7);
170  }
171 
172  if( ((unsigned int)ida.subdetId() == StripSubdetector::TEC || (unsigned int)ida.subdetId() == StripSubdetector::TID || (unsigned int)ida.subdetId() == PixelSubdetector::PixelEndcap) &&
173  ((unsigned int)idb.subdetId() == StripSubdetector::TEC || (unsigned int)idb.subdetId() == StripSubdetector::TID || (unsigned int)idb.subdetId() == PixelSubdetector::PixelEndcap)) { // fwd with fwd
174  return static_cast<unsigned int>(std::abs(HitTM1.first->globalPosition().z()) * 1E7) < static_cast<unsigned int>(std::abs(HitTM2.first->globalPosition().z()) * 1E7);
175  }
176 
177  //
178  // here I have 1 barrel against one forward
179  //
180 
181  if( ((unsigned int)ida.subdetId() == StripSubdetector::TIB || (unsigned int)ida.subdetId() == StripSubdetector::TOB || (unsigned int)ida.subdetId() == PixelSubdetector::PixelBarrel) &&
182  ((unsigned int)idb.subdetId() == StripSubdetector::TEC || (unsigned int)idb.subdetId() == StripSubdetector::TID || (unsigned int)idb.subdetId() == PixelSubdetector::PixelEndcap)) { // barrel with barrel
183  LogDebug("RoadSearch") <<"*** How did this happen ?!?!? ***" ;
184  }else{
185  LogDebug("RoadSearch") <<"*** How did this happen ?!?!? ***" ;
186  }
187 
188  //throw DetLogicError("GeomDetLess: arguments are not Barrel or Forward GeomDets");
189  throw Genexception("SortHitTrajectoryPairsByGlobalPosition: arguments are not Ok");
190 
191 
192 }
193 
#define LogDebug(id)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:78
const TrackingGeometry * geometry
bool barrelForwardLess(const TrackingRecHit *a, const TrackingRecHit *b) const
bool insideOutLess(const TrackingRecHit *a, const TrackingRecHit *b) const
#define abs(x)
Definition: mlp_lapack.h:159
double double double z
bool InsideOutCompare(const std::pair< TransientTrackingRecHit::ConstRecHitPointer, TrajectoryMeasurement * > &HitTM1, const std::pair< TransientTrackingRecHit::ConstRecHitPointer, TrajectoryMeasurement * > &HitTM2) const
const TrackingGeometry * geometry
bool insideOutLess(const TrackingRecHit &a, const TrackingRecHit &b) const
Definition: DetId.h:20
virtual const GeomDet * idToDet(DetId) const =0
double b
Definition: hdecay.h:120
T perp() const
Magnitude of transverse component.
const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
double a
Definition: hdecay.h:121
DetId geographicalId() const
virtual LocalPoint localPosition() const =0
bool barrelForwardLess(const TrackingRecHit &a, const TrackingRecHit &b) const