CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

TkLayerLess Class Reference

#include <TkLayerLess.h>

Inheritance diagram for TkLayerLess:
binary_function

List of all members.

Public Member Functions

bool operator() (const DetLayer *a, const DetLayer *b) const
 TkLayerLess (NavigationDirection dir=insideOut, const DetLayer *fromLayer=0)

Private Member Functions

bool barrelForwardLess (const BarrelDetLayer *blb, const ForwardDetLayer *fla) const
bool insideOutLess (const DetLayer *, const DetLayer *) const
bool insideOutLessSigned (const DetLayer *, const DetLayer *) const

Private Attributes

NavigationDirection theDir
int theFromLayerSign
bool theOriginLayer

Detailed Description

Defines order of layers in the Tracker as seen by straight tracks coming from the interaction region.

Definition at line 15 of file TkLayerLess.h.


Constructor & Destructor Documentation

TkLayerLess::TkLayerLess ( NavigationDirection  dir = insideOut,
const DetLayer fromLayer = 0 
) [inline]

Definition at line 19 of file TkLayerLess.h.

References theFromLayerSign, and theOriginLayer.

                                                                                      :
    theDir(dir) {
    if (fromLayer){
      theOriginLayer = true;
      theFromLayerSign = (fromLayer->position().z()>0 ? 1 : -1) ;
    }else theOriginLayer = false;
  }

Member Function Documentation

bool TkLayerLess::barrelForwardLess ( const BarrelDetLayer blb,
const ForwardDetLayer fla 
) const [private]

Definition at line 39 of file TkLayerLess.cc.

References BoundSurface::bounds(), Bounds::length(), GeometricSearchDet::position(), BarrelDetLayer::surface(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by insideOutLess(), and insideOutLessSigned().

{
  return bla->surface().bounds().length()/2. < fabs( flb->position().z());
}
bool TkLayerLess::insideOutLess ( const DetLayer a,
const DetLayer b 
) const [private]

Definition at line 5 of file TkLayerLess.cc.

References a, b, barrelForwardLess(), GeometricSearchDet::position(), Cylinder::radius(), BarrelDetLayer::specificSurface(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by operator()().

{
  if (a == b) return false;

  const BarrelDetLayer* bla = 
    dynamic_cast<BarrelDetLayer*>(const_cast<DetLayer*>(a));
  const BarrelDetLayer* blb = 
    dynamic_cast<BarrelDetLayer*>(const_cast<DetLayer*>(b));

  if      ( bla!=0 && blb!=0) {  // barrel with barrel
    return bla->specificSurface().radius() < blb->specificSurface().radius();
  }

  const ForwardDetLayer* flb = 
    dynamic_cast<ForwardDetLayer*>(const_cast<DetLayer*>(b));

  if ( bla!=0 && flb!=0) {  // barrel with forward
    return barrelForwardLess( bla, flb);
  }

  const ForwardDetLayer* fla = 
    dynamic_cast<ForwardDetLayer*>(const_cast<DetLayer*>(a));

  if (fla!=0 && flb!=0) {  //  forward with forward
    return fabs( fla->position().z()) < fabs( flb->position().z());
  }
  if ( fla!=0 && blb!=0) {  // forward with barrel
    return !barrelForwardLess( blb, fla);
  }
  //throw DetLogicError("TkLayerLess: arguments are not Barrel or Forward DetLayers");
  throw Genexception("TkLayerLess: arguments are not Barrel or Forward DetLayers");

}
bool TkLayerLess::insideOutLessSigned ( const DetLayer a,
const DetLayer b 
) const [private]

Definition at line 46 of file TkLayerLess.cc.

References a, b, barrelForwardLess(), LogDebug, GeometricSearchDet::position(), Cylinder::radius(), BarrelDetLayer::specificSurface(), theFromLayerSign, and PV3DBase< T, PVType, FrameType >::z().

Referenced by operator()().

{
  if (a == b) return false;

  const BarrelDetLayer* bla =
    dynamic_cast<BarrelDetLayer*>(const_cast<DetLayer*>(a));
  const BarrelDetLayer* blb =
    dynamic_cast<BarrelDetLayer*>(const_cast<DetLayer*>(b));

  if      ( bla!=0 && blb!=0) {  // barrel with barrel
    return bla->specificSurface().radius() < blb->specificSurface().radius();
  }

  const ForwardDetLayer* flb =
    dynamic_cast<ForwardDetLayer*>(const_cast<DetLayer*>(b));

  if ( bla!=0 && flb!=0) {  // barrel with forward
    return barrelForwardLess( bla, flb);
  }

  const ForwardDetLayer* fla =
    dynamic_cast<ForwardDetLayer*>(const_cast<DetLayer*>(a));

  if (fla!=0 && flb!=0) {  //  forward with forward
    if (fla->position().z()*flb->position().z() > 0) {// same z-sign
      //regular ordering when same sign
      LogDebug("BeamHaloTkLayerLess")<<"reaching this: "
                                     <<theFromLayerSign<<" "
                                     <<fla->position().z()<<" "
                                     <<flb->position().z();
      return (fabs(fla->position().z()) < fabs( flb->position().z()));
    }
    else{//layers compared are not on the same z-side
      LogDebug("BeamHaloTkLayerLess")<<"reaching this at least: "
                                     <<theFromLayerSign<<" "
                                     <<fla->position().z()<<" "
                                     <<flb->position().z();

      if (theFromLayerSign*fla->position().z()>0){
        //"fla" and original layer are on the same side
        //say that fla is less than flb
        return false;
      }else{
        return true;
      }
    }
  }
  if ( fla!=0 && blb!=0) {  // forward with barrel
    return !barrelForwardLess( blb, fla);
  }
  throw Genexception("BeamHaloTkLayerLess: arguments are not Barrel or Forward DetLayers");

}
bool TkLayerLess::operator() ( const DetLayer a,
const DetLayer b 
) const [inline]

Definition at line 27 of file TkLayerLess.h.

References insideOut, insideOutLess(), insideOutLessSigned(), theDir, and theOriginLayer.

                                                               {
    if (!theOriginLayer){
      if (theDir == insideOut) return insideOutLess( a, b);
      else return insideOutLess( b, a);
    }
    else{
      if (theDir == insideOut) return insideOutLessSigned( a, b);
      else return insideOutLessSigned(b, a);
    }
  }

Member Data Documentation

Definition at line 40 of file TkLayerLess.h.

Referenced by operator()().

Definition at line 42 of file TkLayerLess.h.

Referenced by insideOutLessSigned(), and TkLayerLess().

Definition at line 41 of file TkLayerLess.h.

Referenced by operator()(), and TkLayerLess().