CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions

TIDLayer Class Reference

#include <TIDLayer.h>

Inheritance diagram for TIDLayer:
RingedForwardLayer GeometricSearchDetWithGroups ForwardDetLayer GeometricSearchDet DetLayer GeometricSearchDet

List of all members.

Public Member Functions

virtual const std::vector
< const GeomDet * > & 
basicComponents () const
virtual const std::vector
< const GeometricSearchDet * > & 
components () const
 Returns basic components, if any.
void groupedCompatibleDetsV (const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const
virtual SubDetector subDetector () const
 The type of detector (PixelBarrel, PixelEndcap, TIB, TOB, TID, TEC, CSC, DT, RPCBarrel, RPCEndcap)
 TIDLayer (std::vector< const TIDRing * > &rings)
 ~TIDLayer ()

Protected Member Functions

float computeWindowSize (const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const
int findClosest (const GlobalPoint[3]) const
int findNextIndex (const GlobalPoint[3], int) const
bool overlapInR (const TrajectoryStateOnSurface &tsos, int i, double ymax) const

Static Protected Member Functions

static void orderAndMergeLevels (const TrajectoryStateOnSurface &tsos, const Propagator &prop, const std::vector< std::vector< DetGroup > > &groups, const std::vector< int > &indices, std::vector< DetGroup > &result)

Protected Attributes

std::vector< const GeomDet * > theBasicComps
std::vector< const
GeometricSearchDet * > 
theComps

Private Member Functions

virtual BoundDiskcomputeDisk (const std::vector< const TIDRing * > &rings) const
virtual std::vector< int > ringIndicesByCrossingProximity (const TrajectoryStateOnSurface &startingState, const Propagator &prop) const

Detailed Description

A concrete implementation for TID layer built out of TIDRings

Definition at line 13 of file TIDLayer.h.


Constructor & Destructor Documentation

TIDLayer::TIDLayer ( std::vector< const TIDRing * > &  rings)

Definition at line 34 of file TIDLayer.cc.

References BoundSurface::bounds(), computeDisk(), BoundDisk::innerRadius(), LogDebug, BoundDisk::outerRadius(), PV3DBase< T, PVType, FrameType >::perp(), GeometricSearchDet::position(), ForwardDetLayer::setSurface(), ForwardDetLayer::specificSurface(), theBasicComps, theComps, Bounds::thickness(), and PV3DBase< T, PVType, FrameType >::z().

                                               :
  theComps(rings.begin(),rings.end())
{
  //They should be already R-ordered. TO BE CHECKED!!
  //sort( theRings.begin(), theRings.end(), DetLessR());
  setSurface( computeDisk( rings ) );

  if ( theComps.size() != 3) throw DetLayerException("Number of rings in TID layer is not equal to 3 !!");

  for(vector<const GeometricSearchDet*>::const_iterator it=theComps.begin();
      it!=theComps.end();it++){  
    theBasicComps.insert(theBasicComps.end(),   
                         (**it).basicComponents().begin(),
                         (**it).basicComponents().end());
  }

 
  LogDebug("TkDetLayers") << "==== DEBUG TIDLayer =====" ; 
  LogDebug("TkDetLayers") << "r,zed pos  , thickness, innerR, outerR: " 
                          << this->position().perp() << " , "
                          << this->position().z() << " , "
                          << this->specificSurface().bounds().thickness() << " , "
                          << this->specificSurface().innerRadius() << " , "
                          << this->specificSurface().outerRadius() ;
}
TIDLayer::~TIDLayer ( )

Definition at line 92 of file TIDLayer.cc.

References i, and theComps.

                   {
  vector<const GeometricSearchDet*>::const_iterator i;
  for (i=theComps.begin(); i!=theComps.end(); i++) {
    delete *i;
  }

} 

Member Function Documentation

virtual const std::vector<const GeomDet*>& TIDLayer::basicComponents ( ) const [inline, virtual]

Implements GeometricSearchDet.

Definition at line 20 of file TIDLayer.h.

References theBasicComps.

{return theBasicComps;}
virtual const std::vector<const GeometricSearchDet*>& TIDLayer::components ( ) const [inline, virtual]

Returns basic components, if any.

Returns direct components, if any

Implements GeometricSearchDet.

Definition at line 22 of file TIDLayer.h.

References theComps.

{return theComps;}
BoundDisk * TIDLayer::computeDisk ( const std::vector< const TIDRing * > &  rings) const [private, virtual]

Definition at line 265 of file TECLayer.cc.

References i, BoundDiskSector::innerRadius(), max(), min, BoundDiskSector::outerRadius(), pos, ForwardDetLayer::rmax(), ForwardDetLayer::rmin(), ForwardDetLayer::zmax(), ForwardDetLayer::zmin(), and zPos.

Referenced by TIDLayer().

{
  // Attention: it is assumed that the petals do belong to one layer, and are all
  // of the same rmin/rmax extension !!  
  
  const BoundDiskSector&  diskSector = static_cast<const BoundDiskSector&>(petals.front()->surface());

  float rmin = diskSector.innerRadius();
  float rmax = diskSector.outerRadius();
  
  float theZmax(petals.front()->position().z());
  float theZmin(theZmax);
  for ( vector<const GeometricSearchDet*>::const_iterator i = petals.begin(); i != petals.end(); i++ ) {
    float zmin = (**i).position().z() - (**i).surface().bounds().thickness()/2.;
    float zmax = (**i).position().z() + (**i).surface().bounds().thickness()/2.;
    theZmax = max( theZmax, zmax);
    theZmin = min( theZmin, zmin);
  }

  float zPos = (theZmax+theZmin)/2.;
  PositionType pos(0.,0.,zPos);
  RotationType rot;

  return new BoundDisk( pos, rot,SimpleDiskBounds(rmin, rmax,    
                                                  theZmin-zPos, theZmax-zPos));
}
float TIDLayer::computeWindowSize ( const GeomDet det,
const TrajectoryStateOnSurface tsos,
const MeasurementEstimator est 
) const [protected]

Definition at line 218 of file TIDLayer.cc.

References MeasurementEstimator::maximalLocalDisplacement(), GeomDet::surface(), and PV2DBase< T, PVType, FrameType >::y().

Referenced by groupedCompatibleDetsV().

{
  const BoundPlane& startPlane = det->surface();  
  MeasurementEstimator::Local2DVector maxDistance = 
    est.maximalLocalDisplacement( tsos, startPlane);
  return maxDistance.y();
}
int TIDLayer::findClosest ( const GlobalPoint  ringCrossing[3]) const [protected]

Definition at line 293 of file TIDLayer.cc.

References i, BoundDisk::innerRadius(), BoundDisk::outerRadius(), perp(), and theComps.

Referenced by ringIndicesByCrossingProximity().

{
  int theBin = 0;
  const BoundDisk & theFrontRing  = static_cast<const BoundDisk &>(theComps[0]->surface());
  float initialR = 0.5*( theFrontRing.innerRadius() +
                         theFrontRing.outerRadius());
  float rDiff = fabs( ringCrossing[0].perp() - initialR);
  for (int i = 1; i < 3 ; i++){
    const BoundDisk & theRing  = static_cast<const BoundDisk &>(theComps[i]->surface());
    float ringR = 0.5*( theRing.innerRadius() + 
                        theRing.outerRadius());
    float testDiff = fabs( ringCrossing[i].perp() - ringR);
    if ( theBin<0 || testDiff<rDiff ) {
      rDiff = testDiff;
      theBin = i;
    }
  }
  return theBin;
}
int TIDLayer::findNextIndex ( const GlobalPoint  ringCrossing[3],
int  closest 
) const [protected]

Definition at line 314 of file TIDLayer.cc.

References i, BoundDisk::innerRadius(), BoundDisk::outerRadius(), perp(), and theComps.

Referenced by ringIndicesByCrossingProximity().

{

  int firstIndexToCheck = (closest != 0)? 0 : 1; 
  const BoundDisk & theFrontRing  = static_cast<const BoundDisk &>(theComps[firstIndexToCheck]->surface());
  float initialR = ( theFrontRing.innerRadius() +
                     theFrontRing.outerRadius())/2.;         

  float rDiff = fabs( ringCrossing[0].perp() - initialR);
  int theBin = firstIndexToCheck;
  for (int i = firstIndexToCheck+1; i < 3 ; i++){
    if ( i != closest) {
      const BoundDisk & theRing  = static_cast<const BoundDisk &>(theComps[i]->surface());
      float ringR = ( theRing.innerRadius() + 
                      theRing.outerRadius())/2.;
      float testDiff = fabs( ringCrossing[i].perp() - ringR);
      if ( testDiff<rDiff ) {
        rDiff = testDiff;
        theBin = i;
      }
    }
  }
  return theBin;
}
void TIDLayer::groupedCompatibleDetsV ( const TrajectoryStateOnSurface tsos,
const Propagator prop,
const MeasurementEstimator est,
std::vector< DetGroup > &  result 
) const [virtual]

Reimplemented from GeometricSearchDet.

Definition at line 103 of file TIDLayer.cc.

References computeWindowSize(), orderAndMergeLevels(), overlapInR(), query::result, ringIndicesByCrossingProximity(), and theComps.

{
  vector<int> ringIndices = ringIndicesByCrossingProximity(startingState,prop);
  if ( ringIndices.size()!=3 ) {
    edm::LogError("TkDetLayers") << "TkRingedForwardLayer::groupedCompatibleDets : ringIndices.size() = "
                                 << ringIndices.size() << " and not =3!!" ;
    return;
  }

  vector<DetGroup> closestResult;
  vector<DetGroup> nextResult;
  vector<DetGroup> nextNextResult;
  vector<vector<DetGroup> > groupsAtRingLevel;

  theComps[ringIndices[0]]->groupedCompatibleDetsV( startingState, prop, est, closestResult);           
  if ( closestResult.empty() ){
    theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, result); 
    return;
  }

  groupsAtRingLevel.push_back(closestResult);

  DetGroupElement closestGel( closestResult.front().front());  
  float rWindow = computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est); 
  if(!overlapInR(closestGel.trajectoryState(),ringIndices[1],rWindow)) {
    result.swap(closestResult);
    return;
  };

  nextResult.clear();
  theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, nextResult);
  if(nextResult.empty()) {
    result.swap(closestResult);
    return;
  }
  groupsAtRingLevel.push_back(nextResult);

  if(!overlapInR(closestGel.trajectoryState(),ringIndices[2],rWindow) ) {
    //then merge 2 levels & return 
    orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,ringIndices,result);      
    return;
  }

  theComps[ringIndices[2]]->groupedCompatibleDetsV( startingState, prop, est, nextNextResult);   
  if(nextNextResult.empty()) {
    // then merge 2 levels and return 
    orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,ringIndices,result);
    return;
  }

  groupsAtRingLevel.push_back(nextNextResult);
  // merge 3 level and return merged   
  orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,ringIndices, result);  
}
void TIDLayer::orderAndMergeLevels ( const TrajectoryStateOnSurface tsos,
const Propagator prop,
const std::vector< std::vector< DetGroup > > &  groups,
const std::vector< int > &  indices,
std::vector< DetGroup > &  result 
) [static, protected]

Definition at line 261 of file TIDLayer.cc.

References alongMomentum, TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), i, oppositeToMomentum, Propagator::propagationDirection(), python::multivaluedict::sort(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by groupedCompatibleDetsV().

{
  vector< pair<vector<DetGroup> const *,int> > groupPlusIndex;

  for(unsigned int i=0;i<groups.size();i++){
    groupPlusIndex.push_back(pair<vector<DetGroup> const *,int>(&groups[i],indices[i]) );
  }
  //order is ring3,ring1,ring2
  std::sort(groupPlusIndex.begin(),groupPlusIndex.end(),TIDringLess());
  

  float zpos = tsos.globalPosition().z();
  if(tsos.globalMomentum().z()*zpos>0){ // momentum points outwards
    if(prop.propagationDirection() == alongMomentum)
      mergeOutward(groupPlusIndex,result);
    else
      mergeInward(groupPlusIndex,result);
  }
  else{ //  momentum points inwards
    if(prop.propagationDirection() == oppositeToMomentum)
      mergeOutward(groupPlusIndex,result);
    else
      mergeInward(groupPlusIndex,result);    
  }  
  
}
bool TIDLayer::overlapInR ( const TrajectoryStateOnSurface tsos,
int  i,
double  ymax 
) const [protected]

Definition at line 342 of file TIDLayer.cc.

References BoundSurface::bounds(), TrajectoryStateOnSurface::globalPosition(), getHLTprescales::index, BoundDisk::innerRadius(), max(), BoundDisk::outerRadius(), PV3DBase< T, PVType, FrameType >::perp(), GloballyPositioned< T >::position(), theComps, Bounds::thickness(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by groupedCompatibleDetsV().

{
  // assume "fixed theta window", i.e. margin in local y = r is changing linearly with z
  float tsRadius = tsos.globalPosition().perp();
  float thetamin = ( max(0.,tsRadius-ymax))/(fabs(tsos.globalPosition().z())+10.); // add 10 cm contingency 
  float thetamax = ( tsRadius + ymax)/(fabs(tsos.globalPosition().z())-10.);
  
  const BoundDisk& ringDisk = static_cast<const BoundDisk&>(theComps[index]->surface());
  float ringMinZ = fabs( ringDisk.position().z()) - ringDisk.bounds().thickness()/2.;
  float ringMaxZ = fabs( ringDisk.position().z()) + ringDisk.bounds().thickness()/2.; 
  float thetaRingMin =  ringDisk.innerRadius()/ ringMaxZ;
  float thetaRingMax =  ringDisk.outerRadius()/ ringMinZ;

  // do the theta regions overlap ?

  return !( thetamin > thetaRingMax || thetaRingMin > thetamax);
}
vector< int > TIDLayer::ringIndicesByCrossingProximity ( const TrajectoryStateOnSurface startingState,
const Propagator prop 
) const [private, virtual]

Definition at line 163 of file TIDLayer.cc.

References findClosest(), findNextIndex(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), i, Propagator::propagationDirection(), rho, theComps, and TrajectoryStateOnSurface::transverseCurvature().

Referenced by groupedCompatibleDetsV().

{
  typedef HelixForwardPlaneCrossing Crossing; 
  typedef MeasurementEstimator::Local2DVector Local2DVector;

  HelixPlaneCrossing::PositionType startPos( startingState.globalPosition());
  HelixPlaneCrossing::DirectionType startDir( startingState.globalMomentum());
  PropagationDirection propDir( prop.propagationDirection());
  float rho( startingState.transverseCurvature());

  // calculate the crossings with the ring surfaces
  // rings are assumed to be sorted in R !
  
  Crossing myXing(  startPos, startDir, rho, propDir );

  GlobalPoint   ringCrossings[3];
  // vector<GlobalVector>  ringXDirections;

  for (int i = 0; i < 3 ; i++ ) {
    const BoundDisk & theRing  = static_cast<const BoundDisk &>(theComps[i]->surface());
    pair<bool,double> pathlen = myXing.pathLength( theRing);
    if ( pathlen.first ) { 
      ringCrossings[i] = GlobalPoint( myXing.position(pathlen.second ));
      // ringXDirections.push_back( GlobalVector( myXing.direction(pathlen.second )));
    } else {
      // TO FIX.... perhaps there is something smarter to do
      //throw DetLayerException("trajectory doesn't cross TID rings");
      ringCrossings[i] = GlobalPoint( 0.,0.,0.);
      //  ringXDirections.push_back( GlobalVector( 0.,0.,0.));
    }
  }

  int closestIndex = findClosest(ringCrossings);
  int nextIndex    = findNextIndex(ringCrossings,closestIndex);
  if ( closestIndex<0 || nextIndex<0 )  return vector<int>();
  int nextNextIndex = -1;
  for(int i=0; i<3 ; i++){
    if(i!= closestIndex && i!=nextIndex) {
      nextNextIndex = i;
      break;
    }
  }
  
  vector<int> indices;
  indices.push_back(closestIndex);
  indices.push_back(nextIndex);
  indices.push_back(nextNextIndex);
  return indices;
}
virtual SubDetector TIDLayer::subDetector ( ) const [inline, virtual]

The type of detector (PixelBarrel, PixelEndcap, TIB, TOB, TID, TEC, CSC, DT, RPCBarrel, RPCEndcap)

Implements DetLayer.

Definition at line 30 of file TIDLayer.h.

References sistripsummary::TID.


Member Data Documentation

std::vector<const GeomDet*> TIDLayer::theBasicComps [protected]

Definition at line 65 of file TIDLayer.h.

Referenced by basicComponents(), and TIDLayer().

std::vector<const GeometricSearchDet*> TIDLayer::theComps [protected]