CMS 3D CMS Logo

TrackingRecHitLessFromGlobalPosition.cc
Go to the documentation of this file.
2 #include <cmath>
12 
14 
15  DetId ida(a.geographicalId());
16  DetId idb(b.geographicalId());
17 
18  unsigned int idetA = static_cast<unsigned int>(ida.subdetId());
19  unsigned int idetB = static_cast<unsigned int>(idb.subdetId());
20 
21  //check for mixed case...
22  bool same_det = (
23  (idetA == StripSubdetector::TIB && idetB == StripSubdetector::TIB) ||
24  (idetA == StripSubdetector::TID && idetB == StripSubdetector::TID) ||
25  (idetA == StripSubdetector::TIB && idetB == StripSubdetector::TID) ||
26  (idetA == StripSubdetector::TID && idetB == StripSubdetector::TIB) ||
27 
28  (idetA == StripSubdetector::TOB && idetB == StripSubdetector::TOB) ||
29  (idetA == StripSubdetector::TEC && idetB == StripSubdetector::TEC) ||
30  (idetA == StripSubdetector::TOB && idetB == StripSubdetector::TEC) ||
31  (idetA == StripSubdetector::TEC && idetB == StripSubdetector::TOB) ||
32 
37 
38  if (!same_det) return (idetA < idetB);
39 
40  if( (idetA == StripSubdetector::TIB || idetA == StripSubdetector::TOB || idetA == PixelSubdetector::PixelBarrel) &&
42  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);
43  }
44 
45  if( (idetA == StripSubdetector::TEC || idetA == StripSubdetector::TID || idetA == PixelSubdetector::PixelEndcap) &&
47  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);
48  }
49 
50  //
51  // here I have 1 barrel against one forward
52  //
53 
54  if( (idetA == StripSubdetector::TIB || idetA == StripSubdetector::TOB || idetA == PixelSubdetector::PixelBarrel) &&
56  return barrelForwardLess( a, b);
57  }else{
58  return !barrelForwardLess( b, a);
59  }
60 
61  throw cms::Exception("TrackingRecHitLessFromGlobalPosition", "Arguments are not Ok");
62 }
63 
65  //
66  // for the moment sort again in z, but since the z in the barrel is wrong (it is in the centre of the module)
67  // add the semi length
68  //
69  DetId ida(a.geographicalId());
70  DetId idb(b.geographicalId());
71  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);
72 }
bool barrelForwardLess(const TrackingRecHit &a, const TrackingRecHit &b) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool insideOutLess(const TrackingRecHit &a, const TrackingRecHit &b) const
virtual LocalPoint localPosition() const =0
Definition: DetId.h:18
double b
Definition: hdecay.h:120
T perp() const
Magnitude of transverse component.
double a
Definition: hdecay.h:121
DetId geographicalId() const