CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/RecoTracker/TrackProducer/src/TrackingRecHitLessFromGlobalPosition.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TrackProducer/interface/TrackingRecHitLessFromGlobalPosition.h"
00002 
00003 #include "Utilities/General/interface/CMSexception.h"
00004 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00005 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00006 
00007 bool TrackingRecHitLessFromGlobalPosition::insideOutLess(  const TrackingRecHit& a, const TrackingRecHit& b) const{
00008   
00009   DetId ida(a.geographicalId());
00010   DetId idb(b.geographicalId());
00011 
00012   unsigned int idetA = static_cast<unsigned int>(ida.subdetId());
00013   unsigned int idetB = static_cast<unsigned int>(idb.subdetId());
00014 
00015   //check for mixed case...
00016   bool same_det = ( 
00017                    (idetA == StripSubdetector::TIB && idetB == StripSubdetector::TIB) ||
00018                    (idetA == StripSubdetector::TID && idetB == StripSubdetector::TID) ||
00019                    (idetA == StripSubdetector::TIB && idetB == StripSubdetector::TID) ||
00020                    (idetA == StripSubdetector::TID && idetB == StripSubdetector::TIB) ||
00021 
00022                    (idetA == StripSubdetector::TOB && idetB == StripSubdetector::TOB) ||
00023                    (idetA == StripSubdetector::TEC && idetB == StripSubdetector::TEC) ||
00024                    (idetA == StripSubdetector::TOB && idetB == StripSubdetector::TEC) ||
00025                    (idetA == StripSubdetector::TEC && idetB == StripSubdetector::TOB) ||
00026 
00027                    (idetA == PixelSubdetector::PixelBarrel && idetB == PixelSubdetector::PixelBarrel) ||
00028                    (idetA == PixelSubdetector::PixelEndcap && idetB == PixelSubdetector::PixelEndcap) ||
00029                    (idetA == PixelSubdetector::PixelBarrel && idetB == PixelSubdetector::PixelEndcap) ||
00030                    (idetA == PixelSubdetector::PixelEndcap && idetB == PixelSubdetector::PixelBarrel) );
00031 
00032   if (!same_det) return (idetA < idetB);
00033 
00034   if( (idetA == StripSubdetector::TIB || idetA == StripSubdetector::TOB || idetA == PixelSubdetector::PixelBarrel) &&
00035       (idetB == StripSubdetector::TIB || idetB == StripSubdetector::TOB || idetB == PixelSubdetector::PixelBarrel)) {  
00036     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);
00037   }
00038   
00039   if( (idetA == StripSubdetector::TEC || idetA == StripSubdetector::TID || idetA == PixelSubdetector::PixelEndcap) &&
00040       (idetB == StripSubdetector::TEC || idetB == StripSubdetector::TID || idetB == PixelSubdetector::PixelEndcap)) {  
00041     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);
00042   }
00043   
00044   //
00045   //  here I have 1 barrel against one forward
00046   //
00047   
00048   if( (idetA == StripSubdetector::TIB || idetA == StripSubdetector::TOB || idetA == PixelSubdetector::PixelBarrel) &&
00049       (idetB == StripSubdetector::TEC || idetB == StripSubdetector::TID || idetB == PixelSubdetector::PixelEndcap)) {
00050     return barrelForwardLess( a, b);
00051   }else{
00052     return !barrelForwardLess( b, a);
00053   }
00054   
00055   throw Genexception("TrackingRecHitLessFromGlobalPosition: arguments are not Ok");
00056 }
00057 
00058 bool TrackingRecHitLessFromGlobalPosition::barrelForwardLess(  const TrackingRecHit& a, const TrackingRecHit& b) const{
00059   //
00060   // for the moment sort again in z, but since the z in the barrel is wrong (it is in the centre of the module)
00061   // add the semi length
00062   //
00063   DetId ida(a.geographicalId());
00064   DetId idb(b.geographicalId());
00065   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);
00066 }