CMS 3D CMS Logo

Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes

SimpleNavigationSchool Class Reference

#include <SimpleNavigationSchool.h>

Inheritance diagram for SimpleNavigationSchool:
NavigationSchool BeamHaloNavigationSchool CfgNavigationSchool CosmicNavigationSchool SkippingLayerCosmicNavigationSchool

List of all members.

Public Member Functions

virtual StateType navigableLayers () const
 SimpleNavigationSchool (const GeometricSearchTracker *theTracker, const MagneticField *field)
 SimpleNavigationSchool ()
 ~SimpleNavigationSchool ()

Protected Types

typedef std::vector
< BarrelDetLayer * > 
BDLC
typedef BDLC::iterator BDLI
typedef std::vector
< SimpleBarrelNavigableLayer * > 
BNLCType
typedef BDLC::const_iterator ConstBDLI
typedef FDLC::const_iterator ConstFDLI
typedef std::vector< const
DetLayer * > 
DLC
typedef DLC::iterator DLI
typedef std::vector
< ForwardDetLayer * > 
FDLC
typedef FDLC::iterator FDLI
typedef std::vector
< SimpleForwardNavigableLayer * > 
FNLCType

Protected Member Functions

virtual float barrelLength ()
void cleanMemory ()
virtual void establishInverseRelations ()
virtual void linkBarrelLayers (SymmetricLayerFinder &symFinder)
virtual void linkForwardLayers (SymmetricLayerFinder &symFinder)
virtual void linkNextBarrelLayer (ForwardDetLayer *fl, BDLC &)
virtual void linkNextForwardLayer (BarrelDetLayer *, FDLC &)
virtual void linkNextLargerLayer (BDLI, BDLI, BDLC &)
virtual void linkNextLayerInGroup (FDLI fli, const FDLC &group, FDLC &reachableFL)
virtual void linkOuterGroup (ForwardDetLayer *fl, const FDLC &group, FDLC &reachableFL)
virtual void linkWithinGroup (FDLI fl, const FDLC &group, FDLC &reachableFL)
virtual ConstFDLI outerRadiusIncrease (FDLI fl, const FDLC &group)
virtual std::vector< FDLCsplitForwardLayers ()

Protected Attributes

BDLC theBarrelLayers
float theBarrelLength
BNLCType theBarrelNLC
const MagneticFieldtheField
FDLC theForwardLayers
FNLCType theForwardNLC
FDLC theLeftLayers
FDLC theRightLayers
const GeometricSearchTrackertheTracker

Detailed Description

Concrete navigation school for the Tracker

Definition at line 20 of file SimpleNavigationSchool.h.


Member Typedef Documentation

typedef std::vector<BarrelDetLayer*> SimpleNavigationSchool::BDLC [protected]

Definition at line 34 of file SimpleNavigationSchool.h.

typedef BDLC::iterator SimpleNavigationSchool::BDLI [protected]

Definition at line 37 of file SimpleNavigationSchool.h.

typedef std::vector< SimpleBarrelNavigableLayer*> SimpleNavigationSchool::BNLCType [protected]

Definition at line 48 of file SimpleNavigationSchool.h.

typedef BDLC::const_iterator SimpleNavigationSchool::ConstBDLI [protected]

Definition at line 39 of file SimpleNavigationSchool.h.

typedef FDLC::const_iterator SimpleNavigationSchool::ConstFDLI [protected]

Definition at line 40 of file SimpleNavigationSchool.h.

typedef std::vector<const DetLayer*> SimpleNavigationSchool::DLC [protected]

Definition at line 33 of file SimpleNavigationSchool.h.

typedef DLC::iterator SimpleNavigationSchool::DLI [protected]

Definition at line 36 of file SimpleNavigationSchool.h.

typedef std::vector<ForwardDetLayer*> SimpleNavigationSchool::FDLC [protected]

Definition at line 35 of file SimpleNavigationSchool.h.

typedef FDLC::iterator SimpleNavigationSchool::FDLI [protected]

Definition at line 38 of file SimpleNavigationSchool.h.

typedef std::vector< SimpleForwardNavigableLayer*> SimpleNavigationSchool::FNLCType [protected]

Definition at line 49 of file SimpleNavigationSchool.h.


Constructor & Destructor Documentation

SimpleNavigationSchool::SimpleNavigationSchool ( ) [inline]

Definition at line 23 of file SimpleNavigationSchool.h.

: theField(0),theTracker(0){};
SimpleNavigationSchool::SimpleNavigationSchool ( const GeometricSearchTracker theTracker,
const MagneticField field 
)

Definition at line 29 of file SimpleNavigationSchool.cc.

References GeometricSearchTracker::allLayers(), GeometricSearchTracker::barrelLayers(), establishInverseRelations(), GeometricSearchTracker::forwardLayers(), i, linkBarrelLayers(), linkForwardLayers(), NavigationSchool::theAllDetLayersInSystem, theBarrelLayers, theForwardLayers, theLeftLayers, theRightLayers, and theTracker.

                                                                           : 
  theBarrelLength(0),theField(field), theTracker(theInputTracker)
{

  theAllDetLayersInSystem=&theInputTracker->allLayers();

  // Get barrel layers
  vector<BarrelDetLayer*> blc = theTracker->barrelLayers(); 
  for ( vector<BarrelDetLayer*>::iterator i = blc.begin(); i != blc.end(); i++) {
    theBarrelLayers.push_back( (*i) );
  }

  // get forward layers
  vector<ForwardDetLayer*> flc = theTracker->forwardLayers(); 
  for ( vector<ForwardDetLayer*>::iterator i = flc.begin(); i != flc.end(); i++) {
    theForwardLayers.push_back( (*i) );
  }
  
  FDLI middle = find_if( theForwardLayers.begin(), theForwardLayers.end(),
                         not1(DetBelowZ(0)));
  theLeftLayers  = FDLC( theForwardLayers.begin(), middle);
  theRightLayers = FDLC( middle, theForwardLayers.end());
  
  SymmetricLayerFinder symFinder( theForwardLayers);

  // only work on positive Z side; negative by mirror symmetry later
  linkBarrelLayers( symFinder);
  linkForwardLayers( symFinder);
  establishInverseRelations();
}
SimpleNavigationSchool::~SimpleNavigationSchool ( ) [inline]

Definition at line 26 of file SimpleNavigationSchool.h.

References cleanMemory().


Member Function Documentation

float SimpleNavigationSchool::barrelLength ( ) [protected, virtual]

Definition at line 349 of file SimpleNavigationSchool.cc.

References i, LogDebug, max(), theBarrelLayers, and theBarrelLength.

Referenced by linkNextBarrelLayer().

{
  if ( theBarrelLength < 1.) {
    for (BDLI i=theBarrelLayers.begin(); i!=theBarrelLayers.end(); i++) {
      theBarrelLength = max( theBarrelLength,
                             (**i).surface().bounds().length() / 2.f);
    }

    LogDebug("TkNavigation") << "The barrel length is " << theBarrelLength ;
  }
  return theBarrelLength;
}
void SimpleNavigationSchool::cleanMemory ( ) [protected]
void SimpleNavigationSchool::establishInverseRelations ( ) [protected, virtual]

Reimplemented in BeamHaloNavigationSchool.

Definition at line 362 of file SimpleNavigationSchool.cc.

References GeometricSearchTracker::allLayers(), i, insideOut, SimpleNavigableLayer::setInwardLinks(), theBarrelLayers, theForwardLayers, and theTracker.

Referenced by CfgNavigationSchool::CfgNavigationSchool(), and SimpleNavigationSchool().

                                                       {

  NavigationSetter setter(*this);

    // find for each layer which are the barrel and forward
    // layers that point to it
    typedef map<const DetLayer*, vector<BarrelDetLayer*>, less<const DetLayer*> > BarrelMapType;
    typedef map<const DetLayer*, vector<ForwardDetLayer*>, less<const DetLayer*> > ForwardMapType;


    BarrelMapType reachedBarrelLayersMap;
    ForwardMapType reachedForwardLayersMap;


    for ( BDLI bli = theBarrelLayers.begin();
        bli!=theBarrelLayers.end(); bli++) {
      DLC reachedLC = (**bli).nextLayers( insideOut);
      for ( DLI i = reachedLC.begin(); i != reachedLC.end(); i++) {
        reachedBarrelLayersMap[*i].push_back( *bli);
      }
    }

    for ( FDLI fli = theForwardLayers.begin();
        fli!=theForwardLayers.end(); fli++) {
      DLC reachedLC = (**fli).nextLayers( insideOut);
      for ( DLI i = reachedLC.begin(); i != reachedLC.end(); i++) {
        reachedForwardLayersMap[*i].push_back( *fli);
      }
    }


    vector<DetLayer*> lc = theTracker->allLayers();
    for ( vector<DetLayer*>::iterator i = lc.begin(); i != lc.end(); i++) {
      SimpleNavigableLayer* navigableLayer =
        dynamic_cast<SimpleNavigableLayer*>((**i).navigableLayer());
      navigableLayer->setInwardLinks( reachedBarrelLayersMap[*i],reachedForwardLayersMap[*i] );
    }
    
}
void SimpleNavigationSchool::linkBarrelLayers ( SymmetricLayerFinder symFinder) [protected, virtual]

Reimplemented in CosmicNavigationSchool.

Definition at line 91 of file SimpleNavigationSchool.cc.

References i, linkNextForwardLayer(), linkNextLargerLayer(), SymmetricLayerFinder::mirror(), theBarrelLayers, theBarrelNLC, and theField.

Referenced by SimpleNavigationSchool().

{
  // Link barrel layers outwards
  for ( BDLI i = theBarrelLayers.begin(); i != theBarrelLayers.end(); i++) {
    BDLC reachableBL;
    FDLC leftFL;
    FDLC rightFL;

    // always add next barrel layer first
    if ( i+1 != theBarrelLayers.end()) reachableBL.push_back(*(i+1));
 
    // Add closest reachable forward layer (except for last BarrelLayer)
    if (i != theBarrelLayers.end() - 1) {
      linkNextForwardLayer( *i, rightFL);
    }

    // Add next BarrelLayer with length larger than the current BL
    if ( i+2 < theBarrelLayers.end()) {
      linkNextLargerLayer( i, theBarrelLayers.end(), reachableBL);
    }

    theBarrelNLC.push_back( new 
       SimpleBarrelNavigableLayer( *i, reachableBL,
                                   symFinder.mirror(rightFL),
                                   rightFL,theField, 5.));
  }
}
void SimpleNavigationSchool::linkForwardLayers ( SymmetricLayerFinder symFinder) [protected, virtual]

Definition at line 151 of file SimpleNavigationSchool.cc.

References g, i, linkNextBarrelLayer(), linkNextLayerInGroup(), linkOuterGroup(), linkWithinGroup(), LogDebug, SymmetricLayerFinder::mirror(), splitForwardLayers(), theField, and theForwardNLC.

Referenced by SimpleNavigationSchool().

{

  // handle right side first, groups are only on the right 
  vector<FDLC> groups = splitForwardLayers();

  LogDebug("TkNavigation") << "SimpleNavigationSchool, Forward groups size = " << groups.size() ;
  for (vector<FDLC>::iterator g = groups.begin(); g != groups.end(); g++) {
    LogDebug("TkNavigation") << "group " << g - groups.begin() << " has " 
                             << g->size() << " layers " ;
  }

  for ( vector<FDLC>::iterator group = groups.begin();
        group != groups.end(); group++) {

    for ( FDLI i = group->begin(); i != group->end(); i++) {

      BDLC reachableBL;
      FDLC reachableFL;
 
      // Always connect to next barrel layer first, if exists
      linkNextBarrelLayer( *i, reachableBL);

      // Then always connect to next forward layer of "same" size, 
      // and layers of larger inner Radius
      linkNextLayerInGroup( i, *group, reachableFL);

      // Then connect to next N fw layers of next size
      if ( group+1 != groups.end()) {
        linkOuterGroup( *i, *(group+1), reachableFL);
      }

      // or connect within the group if outer radius increases
      linkWithinGroup( i, *group, reachableFL);

      theForwardNLC.push_back( new SimpleForwardNavigableLayer( *i,reachableBL,
                                                                reachableFL,
                                                                theField,
                                                                5.));
      theForwardNLC.push_back( new SimpleForwardNavigableLayer( symFinder.mirror(*i),
                                                                reachableBL,
                                                                symFinder.mirror(reachableFL),
                                                                theField,
                                                                5.));

    }
  }

//    // now the left side by symmetry
//    for ( FDLI ileft = theLeftLayers.begin(); 
//      ileft != theLeftLayers.end(); ileft++) {
//      ForwardDetLayer* right = symFinder.mirror( *ileft);
    
//      theForwardNLC.push_back( new 
//         SimpleForwardNavigableLayer( *ileft , right->nextBarrelLayers(),
//                            symFinder.mirror(right->nextForwardLayers())));
//    }
}
void SimpleNavigationSchool::linkNextBarrelLayer ( ForwardDetLayer fl,
BDLC reachableBL 
) [protected, virtual]

Definition at line 210 of file SimpleNavigationSchool.cc.

References barrelLength(), GeometricSearchDet::position(), ForwardDetLayer::specificSurface(), theBarrelLayers, and PV3DBase< T, PVType, FrameType >::z().

Referenced by linkForwardLayers().

{
  if ( fl->position().z() > barrelLength()) return;

  float outerRadius = fl->specificSurface().outerRadius();
  float zpos        = fl->position().z();
  for ( BDLI bli = theBarrelLayers.begin(); bli != theBarrelLayers.end(); bli++) {
    if ( outerRadius < (**bli).specificSurface().radius() &&
         zpos        < (**bli).surface().bounds().length() / 2.) {
      reachableBL.push_back( *bli);
      return;
    }
  }
}
void SimpleNavigationSchool::linkNextForwardLayer ( BarrelDetLayer bl,
FDLC rightFL 
) [protected, virtual]

Definition at line 119 of file SimpleNavigationSchool.cc.

References CosmicsPD_Skims::radius, BarrelDetLayer::specificSurface(), BarrelDetLayer::surface(), and theRightLayers.

Referenced by linkBarrelLayers().

{
  // find first forward layer with larger Z and larger outer radius
  float length = bl->surface().bounds().length() / 2.;
  float radius = bl->specificSurface().radius();
  for ( FDLI fli = theRightLayers.begin();
        fli != theRightLayers.end(); fli++) {
    if ( length < (**fli).position().z() &&
         radius < (**fli).specificSurface().outerRadius()) {
      rightFL.push_back( *fli);
      return;
    }
  }
}
void SimpleNavigationSchool::linkNextLargerLayer ( BDLI  bli,
BDLI  end,
BDLC reachableBL 
) [protected, virtual]

Definition at line 135 of file SimpleNavigationSchool.cc.

References end, epsilon, and i.

Referenced by linkBarrelLayers().

{
  // compare length of next layer with length of following ones
  float length = (**(bli+1)).surface().bounds().length();
  float epsilon = 0.1;

  for ( BDLI i = bli+2; i < end; i++) {
    if ( length + epsilon < (**i).surface().bounds().length()) {
      reachableBL.push_back( *i);
      return;
    }
  }
}
void SimpleNavigationSchool::linkNextLayerInGroup ( FDLI  fli,
const FDLC group,
FDLC reachableFL 
) [protected, virtual]

Definition at line 227 of file SimpleNavigationSchool.cc.

References epsilon, and i.

Referenced by linkForwardLayers().

{
  // Always connect to next forward layer of "same" size, if exists
  if ( fli+1 != group.end()) {
    reachableFL.push_back( *(fli+1));
    // If that layer has an inner radius larger then the current one
    // also connect ALL next disks of same radius.
    float innerRThis = (**fli).specificSurface().innerRadius();
    float innerRNext =  (**(fli+1)).specificSurface().innerRadius();
    const float epsilon = 2.f;

    if (innerRNext > innerRThis + epsilon) {
      // next disk is smaller, so it doesn't cover fully subsequent ones
      // of same radius

      int i = 2;
      while ( (fli+i) != group.end()) {
        if ( (**(fli+i)).specificSurface().innerRadius() < 
             innerRNext + epsilon) {
          // following disk has not increased in ineer radius 
          reachableFL.push_back( *(fli+i));
          i++;
        } else {
          break;
        }
      }
    }
  }
}
void SimpleNavigationSchool::linkOuterGroup ( ForwardDetLayer fl,
const FDLC group,
FDLC reachableFL 
) [protected, virtual]

Definition at line 260 of file SimpleNavigationSchool.cc.

References first, prof2calltree::last, min, GeometricSearchDet::position(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by linkForwardLayers().

{

  // insert N layers with Z grater than fl

  ConstFDLI first = find_if( group.begin(), group.end(), 
                             not1( DetBelowZ( fl->position().z())));
  if ( first != group.end()) {

    // Hard-wired constant!!!!!!
    ConstFDLI last = min( first + 7, group.end());

    reachableFL.insert( reachableFL.end(), first, last);
  }
}
void SimpleNavigationSchool::linkWithinGroup ( FDLI  fl,
const FDLC group,
FDLC reachableFL 
) [protected, virtual]

Definition at line 278 of file SimpleNavigationSchool.cc.

References outerRadiusIncrease().

Referenced by linkForwardLayers().

{
  ConstFDLI biggerLayer = outerRadiusIncrease( fl, group);
  if ( biggerLayer != group.end() && biggerLayer != fl+1) {
    reachableFL.push_back( *biggerLayer);
  }
}
SimpleNavigationSchool::StateType SimpleNavigationSchool::navigableLayers ( ) const [virtual]

Implements NavigationSchool.

Definition at line 76 of file SimpleNavigationSchool.cc.

References cuy::ib, query::result, theBarrelNLC, and theForwardNLC.

{
  StateType result;
  for ( vector< SimpleBarrelNavigableLayer*>::const_iterator 
          ib = theBarrelNLC.begin(); ib != theBarrelNLC.end(); ib++) {
    result.push_back( *ib);
  }
  for ( vector< SimpleForwardNavigableLayer*>::const_iterator 
          ifl = theForwardNLC.begin(); ifl != theForwardNLC.end(); ifl++) {
    result.push_back( *ifl);
  }
  return result;
}
SimpleNavigationSchool::ConstFDLI SimpleNavigationSchool::outerRadiusIncrease ( FDLI  fl,
const FDLC group 
) [protected, virtual]

Definition at line 289 of file SimpleNavigationSchool.cc.

References epsilon.

Referenced by linkWithinGroup().

{
  const float epsilon = 5.f;
  float outerRadius = (**fl).specificSurface().outerRadius();
  while ( ++fl != group.end()) {
    if ( (**fl).specificSurface().outerRadius() > outerRadius + epsilon) {
      return fl;
    }
  }
  return fl;
}
vector< SimpleNavigationSchool::FDLC > SimpleNavigationSchool::splitForwardLayers ( ) [protected, virtual]

Definition at line 302 of file SimpleNavigationSchool.cc.

References begin, cond::rpcobimon::current, end, i, LogDebug, query::result, python::multivaluedict::sort(), and theRightLayers.

Referenced by linkForwardLayers().

{
  // only work on positive Z side; negative by mirror symmetry later

  FDLC myRightLayers( theRightLayers);
  FDLI begin = myRightLayers.begin();
  FDLI end   = myRightLayers.end();

  // sort according to inner radius
  sort ( begin, end, DiskLessInnerRadius()); 

  // partition in cylinders
  vector<FDLC> result;
  FDLC current;
  current.push_back( *begin);
  for ( FDLI i = begin+1; i != end; i++) {

    LogDebug("TkNavigation") << "(**i).specificSurface().innerRadius()      = "
                             << (**i).specificSurface().innerRadius() << endl
                             << "(**(i-1)).specificSurface().outerRadius()) = "
                             << (**(i-1)).specificSurface().outerRadius() ;

    // if inner radius of i is larger than outer radius of i-1 then split!
    if ( (**i).specificSurface().innerRadius() > 
         (**(i-1)).specificSurface().outerRadius()) {

      LogDebug("TkNavigation") << "found break between groups" ;

      // sort layers in group along Z
      sort ( current.begin(), current.end(), DetLessZ());

      result.push_back(current);
      current.clear();
    }
    current.push_back(*i);
  }
  result.push_back(current); // save last one too 

  // now sort subsets in Z
  for ( vector<FDLC>::iterator ivec = result.begin();
        ivec != result.end(); ivec++) {
    sort( ivec->begin(), ivec->end(), DetLessZ());
  }

  return result;
}

Member Data Documentation

Definition at line 46 of file SimpleNavigationSchool.h.

Referenced by barrelLength().

Definition at line 45 of file SimpleNavigationSchool.h.

Referenced by SimpleNavigationSchool().