CMS 3D CMS Logo

Classes | Public Member Functions | Protected Member Functions | Protected Attributes

DualBzeroTrajectoryFactory Class Reference

A factory that produces instances of class ReferenceTrajectory from a given TrajTrackPairCollection. More...

Inheritance diagram for DualBzeroTrajectoryFactory:
TrajectoryFactoryBase

List of all members.

Classes

struct  DualBzeroTrajectoryInput

Public Member Functions

virtual
DualBzeroTrajectoryFactory
clone () const
 DualBzeroTrajectoryFactory (const edm::ParameterSet &config)
virtual const
ReferenceTrajectoryCollection 
trajectories (const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const ExternalPredictionCollection &external, const reco::BeamSpot &beamSpot) const
virtual const
ReferenceTrajectoryCollection 
trajectories (const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const
 Produce the reference trajectories.
virtual ~DualBzeroTrajectoryFactory ()

Protected Member Functions

const TrajectoryStateOnSurface propagateExternal (const TrajectoryStateOnSurface &external, const Surface &surface, const MagneticField *magField) const
const DualBzeroTrajectoryInput referenceStateAndRecHits (const ConstTrajTrackPair &track) const

Protected Attributes

double theMass
double theMomentumEstimate

Detailed Description

A factory that produces instances of class ReferenceTrajectory from a given TrajTrackPairCollection.

Definition at line 18 of file DualBzeroTrajectoryFactory.cc.


Constructor & Destructor Documentation

DualBzeroTrajectoryFactory::DualBzeroTrajectoryFactory ( const edm::ParameterSet config)

Definition at line 59 of file DualBzeroTrajectoryFactory.cc.

References edm::ParameterSet::getParameter(), theMass, and theMomentumEstimate.

Referenced by clone().

                                                                                       :
  TrajectoryFactoryBase( config )
{
  theMass = config.getParameter< double >( "ParticleMass" );
  theMomentumEstimate = config.getParameter< double >( "MomentumEstimate" );
}
DualBzeroTrajectoryFactory::~DualBzeroTrajectoryFactory ( void  ) [virtual]

Definition at line 67 of file DualBzeroTrajectoryFactory.cc.

{}

Member Function Documentation

virtual DualBzeroTrajectoryFactory* DualBzeroTrajectoryFactory::clone ( void  ) const [inline, virtual]

Implements TrajectoryFactoryBase.

Definition at line 34 of file DualBzeroTrajectoryFactory.cc.

References DualBzeroTrajectoryFactory().

{ return new DualBzeroTrajectoryFactory(*this); }
const TrajectoryStateOnSurface DualBzeroTrajectoryFactory::propagateExternal ( const TrajectoryStateOnSurface external,
const Surface surface,
const MagneticField magField 
) const [protected]

Definition at line 240 of file DualBzeroTrajectoryFactory.cc.

References anyDirection, AnalyticalPropagator::propagateWithPath(), and LargeD0_PixelPairStep_cff::propagator.

Referenced by trajectories().

{
  AnalyticalPropagator propagator( magField, anyDirection );
  const std::pair< TrajectoryStateOnSurface, double > tsosWithPath =
    propagator.propagateWithPath( external, surface );
  return tsosWithPath.first;
}
const DualBzeroTrajectoryFactory::DualBzeroTrajectoryInput DualBzeroTrajectoryFactory::referenceStateAndRecHits ( const ConstTrajTrackPair track) const [protected]

Definition at line 193 of file DualBzeroTrajectoryFactory.cc.

References DualBzeroTrajectoryFactory::DualBzeroTrajectoryInput::bwdRecHits, DualBzeroTrajectoryFactory::DualBzeroTrajectoryInput::fwdRecHits, LaserDQM_cfg::input, TrajectoryFactoryBase::orderedTrajectoryMeasurements(), DualBzeroTrajectoryFactory::DualBzeroTrajectoryInput::refTsos, and TrajectoryFactoryBase::useRecHit().

Referenced by trajectories().

{
  DualBzeroTrajectoryInput input;
 
  // get the trajectory measurements in the correct order, i.e. reverse if needed
  Trajectory::DataContainer allTrajMeas = this->orderedTrajectoryMeasurements( *track.first );
  Trajectory::DataContainer usedTrajMeas;
  Trajectory::DataContainer::iterator itM;
  // get all relevant trajectory measurements
  for ( itM = allTrajMeas.begin(); itM != allTrajMeas.end(); itM++ )
  {
    if ( useRecHit( ( *itM ).recHit() ) ) usedTrajMeas.push_back( *itM );
  }

  unsigned int iMeas = 0;
  unsigned int nMeas = usedTrajMeas.size();
  unsigned int nRefStateMeas = nMeas/2;
  // get the valid RecHits
  for ( itM = usedTrajMeas.begin(); itM != usedTrajMeas.end(); itM++, iMeas++ )
  {
    TransientTrackingRecHit::ConstRecHitPointer aRecHit = ( *itM ).recHit();

    if ( iMeas < nRefStateMeas ) {
      input.bwdRecHits.push_back( aRecHit );
    } else if ( iMeas > nRefStateMeas ) {
      input.fwdRecHits.push_back( aRecHit );
    } else { // iMeas == nRefStateMeas
      if ( ( *itM ).updatedState().isValid() )
      {
        input.refTsos = ( *itM ).updatedState();
        input.bwdRecHits.push_back( aRecHit );
        input.fwdRecHits.push_back( aRecHit );
      } else {
        // if the tsos of the middle hit is not valid, try the next one ...
        nRefStateMeas++;
        input.bwdRecHits.push_back( aRecHit );
      }
    }
  }

  // bring input.fwdRecHits into correct order
  std::reverse( input.bwdRecHits.begin(), input.bwdRecHits.end() );

  return input;
}
const DualBzeroTrajectoryFactory::ReferenceTrajectoryCollection DualBzeroTrajectoryFactory::trajectories ( const edm::EventSetup setup,
const ConstTrajTrackPairCollection tracks,
const reco::BeamSpot beamSpot 
) const [virtual]

Produce the reference trajectories.

Implements TrajectoryFactoryBase.

Definition at line 71 of file DualBzeroTrajectoryFactory.cc.

References SiPixelRawToDigiRegional_cfi::beamSpot, DualBzeroTrajectoryFactory::DualBzeroTrajectoryInput::bwdRecHits, DualBzeroTrajectoryFactory::DualBzeroTrajectoryInput::fwdRecHits, edm::EventSetup::get(), LaserDQM_cfg::input, TrajectoryStateOnSurface::isValid(), TrajectoryFactoryBase::materialEffects(), edm::ESHandle< T >::product(), TrajectoryFactoryBase::propagationDirection(), referenceStateAndRecHits(), DualBzeroTrajectoryFactory::DualBzeroTrajectoryInput::refTsos, theMass, theMomentumEstimate, and TrajectoryFactoryBase::theUseBeamSpot.

Referenced by trajectories().

{
  ReferenceTrajectoryCollection trajectories;

  edm::ESHandle< MagneticField > magneticField;
  setup.get< IdealMagneticFieldRecord >().get( magneticField );

  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();

  while ( itTracks != tracks.end() )
  { 
    const DualBzeroTrajectoryInput input = this->referenceStateAndRecHits( *itTracks );
    // Check input: If all hits were rejected, the TSOS is initialized as invalid.
    if ( input.refTsos.isValid() )
    {
      ReferenceTrajectoryPtr ptr( new DualBzeroReferenceTrajectory( input.refTsos,
                                                                    input.fwdRecHits,
                                                                    input.bwdRecHits,
                                                                    magneticField.product(),
                                                                    materialEffects(),
                                                                    propagationDirection(),
                                                                    theMass,
                                                                    theMomentumEstimate,
                                                                    theUseBeamSpot, beamSpot) );
      trajectories.push_back( ptr );
    }

    ++itTracks;
  }

  return trajectories;
}
const DualBzeroTrajectoryFactory::ReferenceTrajectoryCollection DualBzeroTrajectoryFactory::trajectories ( const edm::EventSetup setup,
const ConstTrajTrackPairCollection tracks,
const ExternalPredictionCollection external,
const reco::BeamSpot beamSpot 
) const [virtual]

Implements TrajectoryFactoryBase.

Definition at line 107 of file DualBzeroTrajectoryFactory.cc.

References SiPixelRawToDigiRegional_cfi::beamSpot, DualBzeroTrajectoryFactory::DualBzeroTrajectoryInput::bwdRecHits, DualBzeroTrajectoryFactory::DualBzeroTrajectoryInput::fwdRecHits, edm::EventSetup::get(), LaserDQM_cfg::input, TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localError(), TrajectoryFactoryBase::materialEffects(), LocalTrajectoryError::matrix(), edm::ESHandle< T >::product(), propagateExternal(), TrajectoryFactoryBase::propagationDirection(), referenceStateAndRecHits(), DualBzeroTrajectoryFactory::DualBzeroTrajectoryInput::refTsos, TrajectoryStateOnSurface::surface(), run_regression::test, theMass, theMomentumEstimate, TrajectoryFactoryBase::theUseBeamSpot, and trajectories().

{
  ReferenceTrajectoryCollection trajectories;

  if ( tracks.size() != external.size() )
  {
    edm::LogInfo("ReferenceTrajectories") << "@SUB=DualBzeroTrajectoryFactory::trajectories"
                                          << "Inconsistent input:\n"
                                          << "\tnumber of tracks = " << tracks.size()
                                          << "\tnumber of external predictions = " << external.size();
    return trajectories;
  }

  edm::ESHandle< MagneticField > magneticField;
  setup.get< IdealMagneticFieldRecord >().get( magneticField );

  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
  ExternalPredictionCollection::const_iterator itExternal = external.begin();

  while ( itTracks != tracks.end() )
  {
    const DualBzeroTrajectoryInput input = referenceStateAndRecHits( *itTracks );
    // Check input: If all hits were rejected, the TSOS is initialized as invalid.
    if ( input.refTsos.isValid() )
    {
      if ( (*itExternal).isValid() )
      {
        TrajectoryStateOnSurface propExternal =
          propagateExternal( *itExternal, input.refTsos.surface(), magneticField.product() );

        if ( !propExternal.isValid() ) continue;

        // set the flag for reversing the RecHits to false, since they are already in the correct order.
        ReferenceTrajectoryPtr ptr( new DualBzeroReferenceTrajectory( propExternal,
                                                                      input.fwdRecHits,
                                                                      input.bwdRecHits,
                                                                      magneticField.product(),
                                                                      materialEffects(),
                                                                      propagationDirection(),
                                                                      theMass,
                                                                      theMomentumEstimate,
                                                                      theUseBeamSpot, beamSpot ) );

        AlgebraicSymMatrix externalParamErrors( asHepMatrix<5>( propExternal.localError().matrix() ) );
        ptr->setParameterErrors( externalParamErrors.sub( 2, 5 ) );
        trajectories.push_back( ptr );
      }
      else
      {
// GF: Why is the following commented? That is different from the other factories
//     that usually have the non-external prediction ReferenceTrajectory as fall back...
//      ReferenceTrajectoryPtr ptr( new DualBzeroReferenceTrajectory( input.refTsos,
//                                                                    input.fwdRecHits,
//                                                                    input.bwdRecHits,
//                                                                    magneticField.product(),
//                                                                    materialEffects(),
//                                                                    propagationDirection(),
//                                                                    theMass,
//                                                                    theMomentumEstimate,
//                                                                    beamSpot ) );
        DualBzeroReferenceTrajectory test( input.refTsos,
                                           input.fwdRecHits,
                                           input.bwdRecHits,
                                           magneticField.product(),
                                           materialEffects(),
                                           propagationDirection(),
                                           theMass,
                                           theMomentumEstimate,
                                           theUseBeamSpot, beamSpot );

        //trajectories.push_back( ptr );
      }
    }

    ++itTracks;
    ++itExternal;
  }

  return trajectories;
}

Member Data Documentation

Definition at line 50 of file DualBzeroTrajectoryFactory.cc.

Referenced by DualBzeroTrajectoryFactory(), and trajectories().

Definition at line 51 of file DualBzeroTrajectoryFactory.cc.

Referenced by DualBzeroTrajectoryFactory(), and trajectories().