CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/RecoTracker/TkNavigation/src/TkLayerLess.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkNavigation/interface/TkLayerLess.h"
00002 #include "Utilities/General/interface/CMSexception.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 
00005 bool TkLayerLess::insideOutLess( const DetLayer* a, const DetLayer* b) const
00006 {
00007   if (a == b) return false;
00008 
00009   const BarrelDetLayer* bla = 
00010     dynamic_cast<BarrelDetLayer*>(const_cast<DetLayer*>(a));
00011   const BarrelDetLayer* blb = 
00012     dynamic_cast<BarrelDetLayer*>(const_cast<DetLayer*>(b));
00013 
00014   if      ( bla!=0 && blb!=0) {  // barrel with barrel
00015     return bla->specificSurface().radius() < blb->specificSurface().radius();
00016   }
00017 
00018   const ForwardDetLayer* flb = 
00019     dynamic_cast<ForwardDetLayer*>(const_cast<DetLayer*>(b));
00020 
00021   if ( bla!=0 && flb!=0) {  // barrel with forward
00022     return barrelForwardLess( bla, flb);
00023   }
00024 
00025   const ForwardDetLayer* fla = 
00026     dynamic_cast<ForwardDetLayer*>(const_cast<DetLayer*>(a));
00027 
00028   if (fla!=0 && flb!=0) {  //  forward with forward
00029     return fabs( fla->position().z()) < fabs( flb->position().z());
00030   }
00031   if ( fla!=0 && blb!=0) {  // forward with barrel
00032     return !barrelForwardLess( blb, fla);
00033   }
00034   //throw DetLogicError("TkLayerLess: arguments are not Barrel or Forward DetLayers");
00035   throw Genexception("TkLayerLess: arguments are not Barrel or Forward DetLayers");
00036 
00037 }
00038 
00039 bool TkLayerLess::barrelForwardLess( const BarrelDetLayer* bla, 
00040                                      const ForwardDetLayer* flb) const
00041 {
00042   return bla->surface().bounds().length()/2. < fabs( flb->position().z());
00043 }
00044 
00045 
00046 bool TkLayerLess::insideOutLessSigned( const DetLayer* a, const DetLayer* b) const
00047 {
00048   if (a == b) return false;
00049 
00050   const BarrelDetLayer* bla =
00051     dynamic_cast<BarrelDetLayer*>(const_cast<DetLayer*>(a));
00052   const BarrelDetLayer* blb =
00053     dynamic_cast<BarrelDetLayer*>(const_cast<DetLayer*>(b));
00054 
00055   if      ( bla!=0 && blb!=0) {  // barrel with barrel
00056     return bla->specificSurface().radius() < blb->specificSurface().radius();
00057   }
00058 
00059   const ForwardDetLayer* flb =
00060     dynamic_cast<ForwardDetLayer*>(const_cast<DetLayer*>(b));
00061 
00062   if ( bla!=0 && flb!=0) {  // barrel with forward
00063     return barrelForwardLess( bla, flb);
00064   }
00065 
00066   const ForwardDetLayer* fla =
00067     dynamic_cast<ForwardDetLayer*>(const_cast<DetLayer*>(a));
00068 
00069   if (fla!=0 && flb!=0) {  //  forward with forward
00070     if (fla->position().z()*flb->position().z() > 0) {// same z-sign
00071       //regular ordering when same sign
00072       LogDebug("BeamHaloTkLayerLess")<<"reaching this: "
00073                                      <<theFromLayerSign<<" "
00074                                      <<fla->position().z()<<" "
00075                                      <<flb->position().z();
00076       return (fabs(fla->position().z()) < fabs( flb->position().z()));
00077     }
00078     else{//layers compared are not on the same z-side
00079       LogDebug("BeamHaloTkLayerLess")<<"reaching this at least: "
00080                                      <<theFromLayerSign<<" "
00081                                      <<fla->position().z()<<" "
00082                                      <<flb->position().z();
00083 
00084       if (theFromLayerSign*fla->position().z()>0){
00085         //"fla" and original layer are on the same side
00086         //say that fla is less than flb
00087         return false;
00088       }else{
00089         return true;
00090       }
00091     }
00092   }
00093   if ( fla!=0 && blb!=0) {  // forward with barrel
00094     return !barrelForwardLess( blb, fla);
00095   }
00096   throw Genexception("BeamHaloTkLayerLess: arguments are not Barrel or Forward DetLayers");
00097 
00098 }
00099 
00100