CMS 3D CMS Logo

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

TwoBodyDecayTrajectoryFactory Class Reference

Inheritance diagram for TwoBodyDecayTrajectoryFactory:
TrajectoryFactoryBase

List of all members.

Public Types

typedef
TwoBodyDecayTrajectory::ConstRecHitCollection 
ConstRecHitCollection
typedef
TwoBodyDecayTrajectoryState::TsosContainer 
TsosContainer
typedef
TwoBodyDecayVirtualMeasurement 
VirtualMeasurement

Public Member Functions

virtual
TwoBodyDecayTrajectoryFactory
clone () const
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 trajectories.
 TwoBodyDecayTrajectoryFactory (const edm::ParameterSet &config)
 ~TwoBodyDecayTrajectoryFactory ()

Protected Member Functions

const ReferenceTrajectoryCollection constructTrajectories (const ConstTrajTrackPairCollection &tracks, const TwoBodyDecay &tbd, const MagneticField *magField, const reco::BeamSpot &beamSpot, bool setParameterErrors) const
bool match (const TrajectoryStateOnSurface &state, const TransientTrackingRecHit::ConstRecHitPointer &recHit) const

Protected Attributes

double theChi2CutValue
bool theConstructTsosWithErrorsFlag
TwoBodyDecayFittertheFitter
double theNSigmaCutValue
double thePrimaryMass
double thePrimaryWidth
double theSecondaryMass
bool theUseRefittedStateFlag

Detailed Description

by Edmund Widl, see CMS NOTE-2007/032. extension for BreakPoints or BrokenLines by Claus Kleinwort

Definition at line 31 of file TwoBodyDecayTrajectoryFactory.cc.


Member Typedef Documentation

Definition at line 37 of file TwoBodyDecayTrajectoryFactory.cc.

Definition at line 36 of file TwoBodyDecayTrajectoryFactory.cc.

Definition at line 35 of file TwoBodyDecayTrajectoryFactory.cc.


Constructor & Destructor Documentation

TwoBodyDecayTrajectoryFactory::TwoBodyDecayTrajectoryFactory ( const edm::ParameterSet config)

Definition at line 81 of file TwoBodyDecayTrajectoryFactory.cc.

References edm::ParameterSet::getParameter(), theChi2CutValue, theConstructTsosWithErrorsFlag, theNSigmaCutValue, thePrimaryMass, thePrimaryWidth, theSecondaryMass, and theUseRefittedStateFlag.

Referenced by clone().

  : TrajectoryFactoryBase( config ),
    theFitter( new TwoBodyDecayFitter( config ) )
{
  const edm::ParameterSet ppc = config.getParameter< edm::ParameterSet >( "ParticleProperties" );
  thePrimaryMass = ppc.getParameter< double >( "PrimaryMass" );
  thePrimaryWidth = ppc.getParameter< double >( "PrimaryWidth" );
  theSecondaryMass = ppc.getParameter< double >( "SecondaryMass" );

  theNSigmaCutValue = config.getParameter< double >( "NSigmaCut" );
  theChi2CutValue = config.getParameter< double >( "Chi2Cut" );
  theUseRefittedStateFlag = config.getParameter< bool >( "UseRefittedState" );
  theConstructTsosWithErrorsFlag = config.getParameter< bool >( "ConstructTsosWithErrors" );
}
TwoBodyDecayTrajectoryFactory::~TwoBodyDecayTrajectoryFactory ( )

Definition at line 96 of file TwoBodyDecayTrajectoryFactory.cc.

References theFitter.

{
  delete theFitter;
}

Member Function Documentation

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

Implements TrajectoryFactoryBase.

Definition at line 52 of file TwoBodyDecayTrajectoryFactory.cc.

References TwoBodyDecayTrajectoryFactory().

{ return new TwoBodyDecayTrajectoryFactory(*this); }
const TwoBodyDecayTrajectoryFactory::ReferenceTrajectoryCollection TwoBodyDecayTrajectoryFactory::constructTrajectories ( const ConstTrajTrackPairCollection tracks,
const TwoBodyDecay tbd,
const MagneticField magField,
const reco::BeamSpot beamSpot,
bool  setParameterErrors 
) const [protected]

Definition at line 199 of file TwoBodyDecayTrajectoryFactory.cc.

References TwoBodyDecay::covariance(), TwoBodyDecay::hasError(), TrajectoryFactoryBase::innermostStateAndRecHits(), input1, input2, TwoBodyDecayTrajectoryState::isValid(), match(), TrajectoryFactoryBase::materialEffects(), TrajectoryFactoryBase::propagationDirection(), query::result, ReferenceTrajectoryBase::setParameterErrors(), theConstructTsosWithErrorsFlag, theSecondaryMass, theUseRefittedStateFlag, trajectories(), and TwoBodyDecayTrajectoryState::trajectoryStates().

Referenced by trajectories().

{
  ReferenceTrajectoryCollection trajectories;

  // get innermost valid trajectory state and hits from the tracks
  TrajectoryInput input1 = this->innermostStateAndRecHits( tracks[0] );
  TrajectoryInput input2 = this->innermostStateAndRecHits( tracks[1] );

  if ( !( input1.first.isValid() && input2.first.isValid() ) ) return trajectories;

  // produce TwoBodyDecayTrajectoryState (input for TwoBodyDecayTrajectory)
  TsosContainer tsos( input1.first, input2.first );
  ConstRecHitCollection recHits( input1.second, input2.second );
  TwoBodyDecayTrajectoryState trajectoryState( tsos, tbd, theSecondaryMass, magField );

  if ( !trajectoryState.isValid() )
  {
    trajectories.push_back( ReferenceTrajectoryPtr( new TwoBodyDecayTrajectory() ) );
    return trajectories;
  }

  // always use the refitted trajectory state for matching
  TransientTrackingRecHit::ConstRecHitPointer updatedRecHit1( recHits.first.front()->clone( tsos.first ) );
  bool valid1 = match( trajectoryState.trajectoryStates( true ).first,
                       updatedRecHit1 );

  TransientTrackingRecHit::ConstRecHitPointer updatedRecHit2( recHits.second.front()->clone( tsos.second ) );
  bool valid2 = match( trajectoryState.trajectoryStates( true ).second,
                       updatedRecHit2 );

  if ( !valid1 || !valid2 )
  {
    trajectories.push_back( ReferenceTrajectoryPtr( new TwoBodyDecayTrajectory() ) );
    return trajectories;
  }

  // set the flag for reversing the RecHits to false, since they are already in the correct order.
  TwoBodyDecayTrajectory* result = new TwoBodyDecayTrajectory( trajectoryState, recHits, magField,
                                                               materialEffects(), propagationDirection(),
                                                               false, beamSpot, theUseRefittedStateFlag,
                                                               theConstructTsosWithErrorsFlag );
  if ( setParameterErrors && tbd.hasError() ) result->setParameterErrors( tbd.covariance() );
  trajectories.push_back( ReferenceTrajectoryPtr( result ) );
  return trajectories;
}
bool TwoBodyDecayTrajectoryFactory::match ( const TrajectoryStateOnSurface state,
const TransientTrackingRecHit::ConstRecHitPointer recHit 
) const [protected]

Definition at line 250 of file TwoBodyDecayTrajectoryFactory.cc.

References AlignmentPositionError::globalError(), asciidump::le, TrajectoryStateOnSurface::localPosition(), mathSSE::sqrt(), theNSigmaCutValue, ErrorFrameTransformer::transform(), PV3DBase< T, PVType, FrameType >::x(), LocalError::xx(), PV3DBase< T, PVType, FrameType >::y(), and LocalError::yy().

Referenced by constructTrajectories().

{
  LocalPoint lp1 = state.localPosition();
  LocalPoint lp2 = recHit->localPosition();

  double deltaX = lp1.x() - lp2.x();
  double deltaY = lp1.y() - lp2.y();

  LocalError le = recHit->localPositionError();

  double varX = le.xx();
  double varY = le.yy();

  AlignmentPositionError* gape = recHit->det()->alignmentPositionError();
  if ( gape )
  {
    ErrorFrameTransformer eft;
    LocalError lape = eft.transform( gape->globalError(), recHit->det()->surface() );

    varX += lape.xx();
    varY += lape.yy();
  }

  return ( ( fabs(deltaX)/sqrt(varX) < theNSigmaCutValue ) && ( fabs(deltaY)/sqrt(varY) < theNSigmaCutValue ) );
}
const TrajectoryFactoryBase::ReferenceTrajectoryCollection TwoBodyDecayTrajectoryFactory::trajectories ( const edm::EventSetup setup,
const ConstTrajTrackPairCollection tracks,
const reco::BeamSpot beamSpot 
) const [virtual]

Produce the trajectories.

Implements TrajectoryFactoryBase.

Definition at line 102 of file TwoBodyDecayTrajectoryFactory.cc.

References SiPixelRawToDigiRegional_cfi::beamSpot, TwoBodyDecay::chi2(), constructTrajectories(), TwoBodyDecayFitter::estimate(), funct::false, edm::EventSetup::get(), TwoBodyDecay::isValid(), edm::ESHandle< T >::product(), edm::second(), reco::TransientTrack::setES(), theChi2CutValue, theFitter, thePrimaryMass, thePrimaryWidth, and theSecondaryMass.

Referenced by constructTrajectories(), and trajectories().

{
  ReferenceTrajectoryCollection trajectories;

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

  if ( tracks.size() == 2 )
  {
    // produce transient tracks from persistent tracks
    std::vector< reco::TransientTrack > transientTracks( 2 );

    transientTracks[0] = reco::TransientTrack( *tracks[0].second, magneticField.product() );
    transientTracks[0].setES( setup );

    transientTracks[1] = reco::TransientTrack( *tracks[1].second, magneticField.product() );
    transientTracks[1].setES( setup );

    // estimate the decay parameters
    VirtualMeasurement vm( thePrimaryMass, thePrimaryWidth, theSecondaryMass, beamSpot );
    TwoBodyDecay tbd = theFitter->estimate( transientTracks, vm );

    if ( !tbd.isValid() || ( tbd.chi2() > theChi2CutValue ) )
    {
      trajectories.push_back( ReferenceTrajectoryPtr( new TwoBodyDecayTrajectory() ) );
      return trajectories;
    }

    return constructTrajectories( tracks, tbd, magneticField.product(), beamSpot, false );
  }
  else
  {
    edm::LogInfo( "ReferenceTrajectories" ) << "@SUB=TwoBodyDecayTrajectoryFactory::trajectories"
                                            << "Need 2 tracks, got " << tracks.size() << ".\n";
  }

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

Implements TrajectoryFactoryBase.

Definition at line 145 of file TwoBodyDecayTrajectoryFactory.cc.

References SiPixelRawToDigiRegional_cfi::beamSpot, TwoBodyDecay::chi2(), constructTrajectories(), TwoBodyDecayFitter::estimate(), edm::EventSetup::get(), TwoBodyDecay::isValid(), edm::ESHandle< T >::product(), edm::second(), reco::TransientTrack::setES(), theChi2CutValue, theFitter, thePrimaryMass, thePrimaryWidth, theSecondaryMass, trajectories(), and funct::true.

{
  ReferenceTrajectoryCollection trajectories;

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

  if ( tracks.size() == 2 && external.size() == 2 )
  {
    if ( external[0].isValid() && external[1].isValid() ) // Include external estimates
    {
      // produce transient tracks from persistent tracks
      std::vector< reco::TransientTrack > transientTracks( 2 );

      transientTracks[0] = reco::TransientTrack( *tracks[0].second, magneticField.product() );
      transientTracks[0].setES( setup );

      transientTracks[1] = reco::TransientTrack( *tracks[1].second, magneticField.product() );
      transientTracks[1].setES( setup );

      // estimate the decay parameters. the transient tracks are not really associated to the
      // the external tsos, but this is o.k., because the only information retrieved from them
      // is the magnetic field.
      VirtualMeasurement vm( thePrimaryMass, thePrimaryWidth, theSecondaryMass, beamSpot );
      TwoBodyDecay tbd = theFitter->estimate( transientTracks, external, vm );

      if ( !tbd.isValid()  || ( tbd.chi2() > theChi2CutValue ) )
      {
        trajectories.push_back( ReferenceTrajectoryPtr( new TwoBodyDecayTrajectory() ) );
        return trajectories;
      }

      return constructTrajectories( tracks, tbd, magneticField.product(), beamSpot, true );
    }
    else
    {
      // Return without external estimate
      trajectories = this->trajectories(setup, tracks, beamSpot);
    }
  }
  else
  {
    edm::LogInfo( "ReferenceTrajectories" ) << "@SUB=TwoBodyDecayTrajectoryFactory::trajectories"
                                            << "Need 2 tracks, got " << tracks.size() << ".\n";
  }

  return trajectories;
}

Member Data Documentation

Definition at line 71 of file TwoBodyDecayTrajectoryFactory.cc.

Referenced by trajectories(), and TwoBodyDecayTrajectoryFactory().

Definition at line 70 of file TwoBodyDecayTrajectoryFactory.cc.

Referenced by match(), and TwoBodyDecayTrajectoryFactory().

Definition at line 66 of file TwoBodyDecayTrajectoryFactory.cc.

Referenced by trajectories(), and TwoBodyDecayTrajectoryFactory().

Definition at line 67 of file TwoBodyDecayTrajectoryFactory.cc.

Referenced by trajectories(), and TwoBodyDecayTrajectoryFactory().