CMS 3D CMS Logo

Public Member Functions | Private Attributes

CombinedTrajectoryFactory Class Reference

Inheritance diagram for CombinedTrajectoryFactory:
TrajectoryFactoryBase

List of all members.

Public Member Functions

virtual CombinedTrajectoryFactoryclone () const
 CombinedTrajectoryFactory (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
virtual ~CombinedTrajectoryFactory ()

Private Attributes

std::vector
< TrajectoryFactoryBase * > 
theFactories
bool theUseAllFactories

Detailed Description

A factory that can combine the functionality of several 'trajectory factories'. At construction time, it is given an ordered list of what kinds factories it should use. When called, all the factories are called one after each other,

Example: Combine TwoBodyDecayTrajectoryFactory and ReferenceTrajectoryFactory with useAllFactories = false. In case the former can't produce a trajectory from two given tracks, the tracks can still be used for 'ordinary' reference trajectories (see also TrajectoryFactories.cff).

Definition at line 25 of file CombinedTrajectoryFactory.cc.


Constructor & Destructor Documentation

CombinedTrajectoryFactory::CombinedTrajectoryFactory ( const edm::ParameterSet config)

Definition at line 56 of file CombinedTrajectoryFactory.cc.

References SurfaceDeformationFactory::create(), Exception, reco::get(), edm::ParameterSet::getParameter(), and theFactories.

Referenced by clone().

                                                                                     :
  TrajectoryFactoryBase( config ), theUseAllFactories(config.getParameter<bool>("useAllFactories"))
{
  vector<string> factoryNames = config.getParameter< vector<string> >( "TrajectoryFactoryNames" );
  vector<string>::iterator itFactoryName;
  for ( itFactoryName = factoryNames.begin(); itFactoryName != factoryNames.end(); ++itFactoryName )
  {
    // auto_ptr to avoid missing a delete due to throw...
    std::auto_ptr<TObjArray> namePset(TString((*itFactoryName).c_str()).Tokenize(","));
    if (namePset->GetEntriesFast() != 2) {
      throw cms::Exception("BadConfig") << "@SUB=CombinedTrajectoryFactory"
                                        << "TrajectoryFactoryNames must contain 2 comma "
                                        << "separated strings, but is '" << *itFactoryName << "'";
    }
    const edm::ParameterSet factoryCfg 
      = config.getParameter<edm::ParameterSet>(namePset->At(1)->GetName());
    theFactories.push_back(TrajectoryFactoryPlugin::get()->create(namePset->At(0)->GetName(),
                                                                  factoryCfg));
  }
}
CombinedTrajectoryFactory::~CombinedTrajectoryFactory ( void  ) [virtual]

Definition at line 78 of file CombinedTrajectoryFactory.cc.

{}

Member Function Documentation

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

Implements TrajectoryFactoryBase.

Definition at line 42 of file CombinedTrajectoryFactory.cc.

References CombinedTrajectoryFactory().

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

Implements TrajectoryFactoryBase.

Definition at line 82 of file CombinedTrajectoryFactory.cc.

References theFactories, and theUseAllFactories.

Referenced by trajectories().

{
  ReferenceTrajectoryCollection trajectories;
  ReferenceTrajectoryCollection tmpTrajectories; // outside loop for efficiency

  vector< TrajectoryFactoryBase* >::const_iterator itFactory;
  for ( itFactory = theFactories.begin(); itFactory != theFactories.end(); ++itFactory )
  {
    tmpTrajectories = ( *itFactory )->trajectories(setup, tracks, beamSpot);
    trajectories.insert(trajectories.end(), tmpTrajectories.begin(), tmpTrajectories.end());

    if (!theUseAllFactories && !trajectories.empty()) break;
  }

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

Implements TrajectoryFactoryBase.

Definition at line 102 of file CombinedTrajectoryFactory.cc.

References theFactories, theUseAllFactories, and trajectories().

{
  ReferenceTrajectoryCollection trajectories;
  ReferenceTrajectoryCollection tmpTrajectories; // outside loop for efficiency

  vector< TrajectoryFactoryBase* >::const_iterator itFactory;
  for ( itFactory = theFactories.begin(); itFactory != theFactories.end(); ++itFactory )
  {
    tmpTrajectories = ( *itFactory )->trajectories(setup, tracks, external, beamSpot);
    trajectories.insert(trajectories.end(), tmpTrajectories.begin(), tmpTrajectories.end());

    if (!theUseAllFactories && !trajectories.empty()) break;
  }

  return trajectories;
}

Member Data Documentation

Definition at line 46 of file CombinedTrajectoryFactory.cc.

Referenced by CombinedTrajectoryFactory(), and trajectories().

Definition at line 47 of file CombinedTrajectoryFactory.cc.

Referenced by trajectories().