CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SortHitPointersByGlobalPosition Class Reference

#include <RoadSearchHitSorting.h>

List of all members.

Public Member Functions

bool operator() (const TrackingRecHit *a, const TrackingRecHit *b) const
 SortHitPointersByGlobalPosition (const TrackingGeometry *geometry_, PropagationDirection dir=alongMomentum)

Private Member Functions

bool barrelForwardLess (const TrackingRecHit *a, const TrackingRecHit *b) const
bool insideOutLess (const TrackingRecHit *a, const TrackingRecHit *b) const

Private Attributes

const TrackingGeometrygeometry
PropagationDirection theDir

Detailed Description

Definition at line 53 of file RoadSearchHitSorting.h.


Constructor & Destructor Documentation

SortHitPointersByGlobalPosition::SortHitPointersByGlobalPosition ( const TrackingGeometry geometry_,
PropagationDirection  dir = alongMomentum 
) [inline]

Definition at line 56 of file RoadSearchHitSorting.h.

                                                                      :
    geometry(geometry_), theDir(dir){}

Member Function Documentation

bool SortHitPointersByGlobalPosition::barrelForwardLess ( const TrackingRecHit a,
const TrackingRecHit b 
) const [private]

Definition at line 136 of file RoadSearchHitSorting.cc.

References abs, TrackingRecHit::geographicalId(), geometry, TrackingGeometry::idToDet(), TrackingRecHit::localPosition(), GeomDet::surface(), Surface::toGlobal(), and z.

Referenced by insideOutLess().

                                                                                                               {
  //
  // for the moment sort again in z, but since the z in the barrel is wrong (it is in the centre of the module)
  // add the semi length
  //
  DetId ida(a->geographicalId());
  DetId idb(b->geographicalId());
  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);
}
bool SortHitPointersByGlobalPosition::insideOutLess ( const TrackingRecHit a,
const TrackingRecHit b 
) const [private]

Definition at line 85 of file RoadSearchHitSorting.cc.

References abs, barrelForwardLess(), TrackingRecHit::geographicalId(), geometry, TrackingGeometry::idToDet(), TrackingRecHit::localPosition(), perp(), PixelSubdetector::PixelBarrel, GeomDetEnumerators::PixelBarrel, PixelSubdetector::PixelEndcap, GeomDetEnumerators::PixelEndcap, GeomDet::surface(), StripSubdetector::TEC, sistripsummary::TEC, sistripsummary::TIB, StripSubdetector::TIB, sistripsummary::TID, StripSubdetector::TID, StripSubdetector::TOB, sistripsummary::TOB, Surface::toGlobal(), and z.

Referenced by operator()().

                                                                                                           {
  
  DetId ida(a->geographicalId());
  DetId idb(b->geographicalId());

  unsigned int idetA = static_cast<unsigned int>(ida.subdetId());
  unsigned int idetB = static_cast<unsigned int>(idb.subdetId());

  //check for mixed case...
  bool same_det = ( 
                   (idetA == StripSubdetector::TIB && idetB == StripSubdetector::TIB) ||
                   (idetA == StripSubdetector::TID && idetB == StripSubdetector::TID) ||
                   (idetA == StripSubdetector::TIB && idetB == StripSubdetector::TID) ||
                   (idetA == StripSubdetector::TID && idetB == StripSubdetector::TIB) ||

                   (idetA == StripSubdetector::TOB && idetB == StripSubdetector::TOB) ||
                   (idetA == StripSubdetector::TEC && idetB == StripSubdetector::TEC) ||
                   (idetA == StripSubdetector::TOB && idetB == StripSubdetector::TEC) ||
                   (idetA == StripSubdetector::TEC && idetB == StripSubdetector::TOB) ||

                   (idetA == PixelSubdetector::PixelBarrel && idetB == PixelSubdetector::PixelBarrel) ||
                   (idetA == PixelSubdetector::PixelEndcap && idetB == PixelSubdetector::PixelEndcap) ||
                   (idetA == PixelSubdetector::PixelBarrel && idetB == PixelSubdetector::PixelEndcap) ||
                   (idetA == PixelSubdetector::PixelEndcap && idetB == PixelSubdetector::PixelBarrel) );

  if (!same_det) return (idetA < idetB);

  if( (idetA == StripSubdetector::TIB || idetA == StripSubdetector::TOB || idetA == PixelSubdetector::PixelBarrel) &&
      (idetB == StripSubdetector::TIB || idetB == StripSubdetector::TOB || idetB == PixelSubdetector::PixelBarrel)) {  
    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);
  }
  
  if( (idetA == StripSubdetector::TEC || idetA == StripSubdetector::TID || idetA == PixelSubdetector::PixelEndcap) &&
      (idetB == StripSubdetector::TEC || idetB == StripSubdetector::TID || idetB == PixelSubdetector::PixelEndcap)) {  
    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);
  }
  
  //
  //  here I have 1 barrel against one forward
  //
  
  if( (idetA == StripSubdetector::TIB || idetA == StripSubdetector::TOB || idetA == PixelSubdetector::PixelBarrel) &&
      (idetB == StripSubdetector::TEC || idetB == StripSubdetector::TID || idetB == PixelSubdetector::PixelEndcap)) {
    return barrelForwardLess( a, b);
  }else{
    return !barrelForwardLess( b, a);
  }
  
  throw Genexception("SortHitPointersByGlobalPosition: arguments are not Ok");
}
bool SortHitPointersByGlobalPosition::operator() ( const TrackingRecHit a,
const TrackingRecHit b 
) const [inline]

Definition at line 61 of file RoadSearchHitSorting.h.

References alongMomentum, insideOutLess(), and theDir.

                                                                           {
    if (theDir == alongMomentum) return insideOutLess( a, b);
    else return insideOutLess( b, a);
  }

Member Data Documentation

Definition at line 72 of file RoadSearchHitSorting.h.

Referenced by barrelForwardLess(), and insideOutLess().

Definition at line 73 of file RoadSearchHitSorting.h.

Referenced by operator()().