CMS 3D CMS Logo

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

DualTrajectoryFactory Class Reference

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

Inheritance diagram for DualTrajectoryFactory:
TrajectoryFactoryBase

List of all members.

Classes

struct  DualTrajectoryInput

Public Member Functions

virtual DualTrajectoryFactoryclone () const
 DualTrajectoryFactory (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 ~DualTrajectoryFactory ()

Protected Member Functions

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

Protected Attributes

double theMass

Detailed Description

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

Definition at line 18 of file DualTrajectoryFactory.cc.


Constructor & Destructor Documentation

DualTrajectoryFactory::DualTrajectoryFactory ( const edm::ParameterSet config)

Definition at line 57 of file DualTrajectoryFactory.cc.

References theMass.

Referenced by clone().

                                                                             :
  TrajectoryFactoryBase( config ),
  theMass(config.getParameter<double>("ParticleMass"))
{
  edm::LogInfo("Alignment") << "@SUB=DualTrajectoryFactory"
                            << "mass: " << theMass;
}
DualTrajectoryFactory::~DualTrajectoryFactory ( void  ) [virtual]

Definition at line 66 of file DualTrajectoryFactory.cc.

{}

Member Function Documentation

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

Implements TrajectoryFactoryBase.

Definition at line 34 of file DualTrajectoryFactory.cc.

References DualTrajectoryFactory().

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

Definition at line 236 of file DualTrajectoryFactory.cc.

References AnalyticalPropagator_cfi::AnalyticalPropagator, anyDirection, 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 DualTrajectoryFactory::DualTrajectoryInput DualTrajectoryFactory::referenceStateAndRecHits ( const ConstTrajTrackPair track) const [protected]

Definition at line 189 of file DualTrajectoryFactory.cc.

References DualTrajectoryFactory::DualTrajectoryInput::bwdRecHits, DualTrajectoryFactory::DualTrajectoryInput::fwdRecHits, LaserDQM_cfg::input, TrajectoryFactoryBase::orderedTrajectoryMeasurements(), DualTrajectoryFactory::DualTrajectoryInput::refTsos, and TrajectoryFactoryBase::useRecHit().

Referenced by trajectories().

{
  DualTrajectoryInput 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 DualTrajectoryFactory::ReferenceTrajectoryCollection DualTrajectoryFactory::trajectories ( const edm::EventSetup setup,
const ConstTrajTrackPairCollection tracks,
const reco::BeamSpot beamSpot 
) const [virtual]

Produce the reference trajectories.

Implements TrajectoryFactoryBase.

Definition at line 70 of file DualTrajectoryFactory.cc.

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

Referenced by trajectories().

{
  ReferenceTrajectoryCollection trajectories;

  edm::ESHandle< MagneticField > magneticField;
  setup.get< IdealMagneticFieldRecord >().get( magneticField );
  if (magneticField->inTesla(GlobalPoint(0.,0.,0.)).mag2() < 1.e-6) {
    edm::LogWarning("Alignment") << "@SUB=DualTrajectoryFactory::trajectories"
                                 << "B-field in z is " << magneticField->inTesla(GlobalPoint(0.,0.,0.)).z()
                                 << ": You should probably use the DualBzeroTrajectoryFactory\n" 
                                 << "or fix this code to switch automatically as the ReferenceTrajectoryFactory does.";
  }

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

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

    ++itTracks;
  }

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

Implements TrajectoryFactoryBase.

Definition at line 111 of file DualTrajectoryFactory.cc.

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

{
  ReferenceTrajectoryCollection trajectories;

  if ( tracks.size() != external.size() )
  {
    edm::LogInfo("ReferenceTrajectories") << "@SUB=DualTrajectoryFactory::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 );
  if (magneticField->inTesla(GlobalPoint(0.,0.,0.)).mag2() < 1.e-6) {
    edm::LogWarning("Alignment") << "@SUB=DualTrajectoryFactory::trajectories"
                                 << "B-field in z is " << magneticField->inTesla(GlobalPoint(0.,0.,0.)).z()
                                 << ": You should probably use the DualBzeroTrajectoryFactory\n" 
                                 << "or fix this code to switch automatically as the ReferenceTrajectoryFactory does.";
  }

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

  while ( itTracks != tracks.end() )
  {
    const DualTrajectoryInput 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 DualReferenceTrajectory( propExternal,
                                                                 input.fwdRecHits,
                                                                 input.bwdRecHits,
                                                                 magneticField.product(),
                                                                 materialEffects(),
                                                                 propagationDirection(),
                                                                 theMass, 
                                                                 theUseBeamSpot, beamSpot ) );

        AlgebraicSymMatrix externalParamErrors( asHepMatrix<5>( propExternal.localError().matrix() ) );
        ptr->setParameterErrors( externalParamErrors );
        trajectories.push_back( ptr );
      }
      else
      {
        ReferenceTrajectoryPtr ptr( new DualReferenceTrajectory( input.refTsos,
                                                                 input.fwdRecHits,
                                                                 input.bwdRecHits,
                                                                 magneticField.product(),
                                                                 materialEffects(),
                                                                 propagationDirection(),
                                                                 theMass, 
                                                                 theUseBeamSpot, beamSpot ) );
        trajectories.push_back( ptr );
      }
    }

    ++itTracks;
    ++itExternal;
  }

  return trajectories;
}

Member Data Documentation

double DualTrajectoryFactory::theMass [protected]

Definition at line 50 of file DualTrajectoryFactory.cc.

Referenced by DualTrajectoryFactory(), and trajectories().