CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackingRecHitLessFromGlobalPosition.cc
Go to the documentation of this file.
2 
6 
8 
9  DetId ida(a.geographicalId());
10  DetId idb(b.geographicalId());
11 
12  unsigned int idetA = static_cast<unsigned int>(ida.subdetId());
13  unsigned int idetB = static_cast<unsigned int>(idb.subdetId());
14 
15  //check for mixed case...
16  bool same_det = (
17  (idetA == StripSubdetector::TIB && idetB == StripSubdetector::TIB) ||
18  (idetA == StripSubdetector::TID && idetB == StripSubdetector::TID) ||
19  (idetA == StripSubdetector::TIB && idetB == StripSubdetector::TID) ||
20  (idetA == StripSubdetector::TID && idetB == StripSubdetector::TIB) ||
21 
22  (idetA == StripSubdetector::TOB && idetB == StripSubdetector::TOB) ||
23  (idetA == StripSubdetector::TEC && idetB == StripSubdetector::TEC) ||
24  (idetA == StripSubdetector::TOB && idetB == StripSubdetector::TEC) ||
25  (idetA == StripSubdetector::TEC && idetB == StripSubdetector::TOB) ||
26 
31 
32  if (!same_det) return (idetA < idetB);
33 
34  if( (idetA == StripSubdetector::TIB || idetA == StripSubdetector::TOB || idetA == PixelSubdetector::PixelBarrel) &&
36  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);
37  }
38 
39  if( (idetA == StripSubdetector::TEC || idetA == StripSubdetector::TID || idetA == PixelSubdetector::PixelEndcap) &&
41  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);
42  }
43 
44  //
45  // here I have 1 barrel against one forward
46  //
47 
48  if( (idetA == StripSubdetector::TIB || idetA == StripSubdetector::TOB || idetA == PixelSubdetector::PixelBarrel) &&
50  return barrelForwardLess( a, b);
51  }else{
52  return !barrelForwardLess( b, a);
53  }
54 
55  throw cms::Exception("TrackingRecHitLessFromGlobalPosition", "Arguments are not Ok");
56 }
57 
59  //
60  // for the moment sort again in z, but since the z in the barrel is wrong (it is in the centre of the module)
61  // add the semi length
62  //
63  DetId ida(a.geographicalId());
64  DetId idb(b.geographicalId());
65  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);
66 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:114
bool barrelForwardLess(const TrackingRecHit &a, const TrackingRecHit &b) const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
float float float z
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool insideOutLess(const TrackingRecHit &a, const TrackingRecHit &b) const
Definition: DetId.h:18
virtual const GeomDet * idToDet(DetId) const =0
double b
Definition: hdecay.h:120
T perp() const
Magnitude of transverse component.
double a
Definition: hdecay.h:121
DetId geographicalId() const
virtual LocalPoint localPosition() const =0