CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Protected Attributes

ReferenceTrajectoryFactory Class Reference

Inheritance diagram for ReferenceTrajectoryFactory:
TrajectoryFactoryBase

List of all members.

Public Member Functions

virtual
ReferenceTrajectoryFactory
clone () const
 ReferenceTrajectoryFactory (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 ~ReferenceTrajectoryFactory ()

Protected Member Functions

const TrajectoryFactoryBasebzeroFactory () const
 ReferenceTrajectoryFactory (const ReferenceTrajectoryFactory &other)

Protected Attributes

const TrajectoryFactoryBasetheBzeroFactory
double theMass
bool theUseBzeroIfFieldOff

Detailed Description

A factory that produces instances of class ReferenceTrajectory from a given TrajTrackPairCollection. If |B| = 0 T and configuration parameter UseBzeroIfFieldOff is True, hand-over to the BzeroReferenceTrajectoryFactory.

Definition at line 20 of file ReferenceTrajectoryFactory.cc.


Constructor & Destructor Documentation

ReferenceTrajectoryFactory::ReferenceTrajectoryFactory ( const edm::ParameterSet config)

Definition at line 51 of file ReferenceTrajectoryFactory.cc.

References theMass, and theUseBzeroIfFieldOff.

Referenced by clone().

                                                                                       :
  TrajectoryFactoryBase( config ),
  theMass(config.getParameter<double>("ParticleMass")),
  theUseBzeroIfFieldOff(config.getParameter<bool>("UseBzeroIfFieldOff")),
  theBzeroFactory(0)
{
  edm::LogInfo("Alignment") << "@SUB=ReferenceTrajectoryFactory"
                            << "mass: " << theMass
                            << "\nusing Bzero if |B| = 0: " 
                            << (theUseBzeroIfFieldOff ? "yes" : "no");
}
ReferenceTrajectoryFactory::~ReferenceTrajectoryFactory ( void  ) [virtual]

Definition at line 71 of file ReferenceTrajectoryFactory.cc.

References theBzeroFactory.

{
  delete theBzeroFactory;
}
ReferenceTrajectoryFactory::ReferenceTrajectoryFactory ( const ReferenceTrajectoryFactory other) [protected]

Definition at line 63 of file ReferenceTrajectoryFactory.cc.

                                                                                              :
  TrajectoryFactoryBase(other),
  theMass(other.theMass),
  theUseBzeroIfFieldOff(other.theUseBzeroIfFieldOff),
  theBzeroFactory(0) // copy data members, but no double pointing to same Bzero factory...
{
}

Member Function Documentation

const TrajectoryFactoryBase * ReferenceTrajectoryFactory::bzeroFactory ( ) const [protected]

Definition at line 173 of file ReferenceTrajectoryFactory.cc.

References edm::ParameterSet::addParameter(), TrajectoryFactories_cff::BzeroReferenceTrajectoryFactory, TrajectoryFactoryBase::configuration(), edm::ParameterSet::copyForModify(), edm::ParameterSet::eraseSimpleParameter(), edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, and theBzeroFactory.

Referenced by trajectories().

{
  if (!theBzeroFactory) {
    const edm::ParameterSet &myPset = this->configuration();
    edm::LogInfo("Alignment") << "@SUB=ReferenceTrajectoryFactory::bzeroFactory"
                              << "Using BzeroReferenceTrajectoryFactory for some (all?) events.";
    // We take the config of this factory, copy it, replace its name and add 
    // the momentum parameter as expected by BzeroReferenceTrajectoryFactory and create it:
    edm::ParameterSet pset;
    pset.copyForModify(myPset);
    // next two lines not needed, but may help to better understand log file:
    pset.eraseSimpleParameter("TrajectoryFactoryName");
    pset.addParameter("TrajectoryFactoryName", std::string("BzeroReferenceTrajectoryFactory"));
    pset.addParameter("MomentumEstimate", myPset.getParameter<double>("MomentumEstimateFieldOff"));
    theBzeroFactory = new BzeroReferenceTrajectoryFactory(pset);
  }
  return theBzeroFactory;
}
virtual ReferenceTrajectoryFactory* ReferenceTrajectoryFactory::clone ( void  ) const [inline, virtual]

Implements TrajectoryFactoryBase.

Definition at line 36 of file ReferenceTrajectoryFactory.cc.

References ReferenceTrajectoryFactory().

{ return new ReferenceTrajectoryFactory(*this); }
const ReferenceTrajectoryFactory::ReferenceTrajectoryCollection ReferenceTrajectoryFactory::trajectories ( const edm::EventSetup setup,
const ConstTrajTrackPairCollection tracks,
const reco::BeamSpot beamSpot 
) const [virtual]

Produce the reference trajectories.

Implements TrajectoryFactoryBase.

Definition at line 78 of file ReferenceTrajectoryFactory.cc.

References SiPixelRawToDigiRegional_cfi::beamSpot, bzeroFactory(), edm::EventSetup::get(), TrajectoryFactoryBase::innermostStateAndRecHits(), LaserDQM_cfg::input, TrajectoryFactoryBase::materialEffects(), edm::ESHandle< T >::product(), TrajectoryFactoryBase::propagationDirection(), theMass, TrajectoryFactoryBase::theUseBeamSpot, theUseBzeroIfFieldOff, and TrajectoryFactoryBase::trajectories().

Referenced by trajectories().

{
  edm::ESHandle< MagneticField > magneticField;
  setup.get< IdealMagneticFieldRecord >().get( magneticField );
  if (theUseBzeroIfFieldOff && magneticField->inTesla(GlobalPoint(0.,0.,0.)).mag2() < 1.e-6) {
    return this->bzeroFactory()->trajectories(setup, tracks, beamSpot);
  }

  ReferenceTrajectoryCollection trajectories;

  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
  
  while ( itTracks != tracks.end() )
  { 
    TrajectoryInput input = this->innermostStateAndRecHits( *itTracks );
    
    // Check input: If all hits were rejected, the TSOS is initialized as invalid.
    if ( input.first.isValid() )
    {
      // set the flag for reversing the RecHits to false, since they are already in the correct order.
      trajectories.push_back(ReferenceTrajectoryPtr(new ReferenceTrajectory(input.first, input.second, false,
                                                                            magneticField.product(), materialEffects(),
                                                                            propagationDirection(), theMass, 
                                                                            theUseBeamSpot, beamSpot)));
    }

    ++itTracks;
  }

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

Implements TrajectoryFactoryBase.

Definition at line 114 of file ReferenceTrajectoryFactory.cc.

References SiPixelRawToDigiRegional_cfi::beamSpot, bzeroFactory(), edm::EventSetup::get(), TrajectoryFactoryBase::innermostStateAndRecHits(), LaserDQM_cfg::input, TrajectoryFactoryBase::materialEffects(), edm::ESHandle< T >::product(), TrajectoryFactoryBase::propagationDirection(), TrajectoryFactoryBase::sameSurface(), theMass, TrajectoryFactoryBase::theUseBeamSpot, theUseBzeroIfFieldOff, TrajectoryFactoryBase::trajectories(), and trajectories().

{
  ReferenceTrajectoryCollection trajectories;

  if ( tracks.size() != external.size() )
  {
    edm::LogInfo("ReferenceTrajectories") << "@SUB=ReferenceTrajectoryFactory::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 (theUseBzeroIfFieldOff && magneticField->inTesla(GlobalPoint(0.,0.,0.)).mag2() < 1.e-6) {
    return this->bzeroFactory()->trajectories(setup, tracks, external, beamSpot);
  }

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

  while ( itTracks != tracks.end() )
  {
    TrajectoryInput input = innermostStateAndRecHits( *itTracks );
    // Check input: If all hits were rejected, the TSOS is initialized as invalid.
    if ( input.first.isValid() )
    {
      if ( (*itExternal).isValid() && sameSurface( (*itExternal).surface(), input.first.surface() ) )
      {
        // set the flag for reversing the RecHits to false, since they are already in the correct order.
        ReferenceTrajectoryPtr refTraj( new ReferenceTrajectory( *itExternal, input.second, false,
                                                                 magneticField.product(), materialEffects(),
                                                                 propagationDirection(), theMass,
                                                                 theUseBeamSpot, beamSpot) );
          
        AlgebraicSymMatrix externalParamErrors( asHepMatrix<5>( (*itExternal).localError().matrix() ) );
        refTraj->setParameterErrors( externalParamErrors );
        trajectories.push_back( refTraj );
      }
      else
      {
        trajectories.push_back(ReferenceTrajectoryPtr(new ReferenceTrajectory(input.first, input.second, false,
                                                                              magneticField.product(), materialEffects(),
                                                                              propagationDirection(), theMass,
                                                                              theUseBeamSpot, beamSpot)));
      }
    }
    
    ++itTracks;
    ++itExternal;
  }
  
  return trajectories;
}

Member Data Documentation

Definition at line 44 of file ReferenceTrajectoryFactory.cc.

Referenced by bzeroFactory(), and ~ReferenceTrajectoryFactory().

Definition at line 42 of file ReferenceTrajectoryFactory.cc.

Referenced by ReferenceTrajectoryFactory(), and trajectories().

Definition at line 43 of file ReferenceTrajectoryFactory.cc.

Referenced by ReferenceTrajectoryFactory(), and trajectories().