CMS 3D CMS Logo

CombinedTrajectoryFactory.cc
Go to the documentation of this file.
1 #include <memory>
2 
5 
6 #include <TString.h>
7 #include <TObjArray.h>
8 
10 
23 
24 
26 {
27 
28 public:
29 
32 
35  const reco::BeamSpot &beamSpot) const override;
36 
38  const ConstTrajTrackPairCollection &tracks,
40  const reco::BeamSpot &beamSpot) const override;
41 
42  virtual CombinedTrajectoryFactory* clone() const override { return new CombinedTrajectoryFactory(*this); }
43 
44 private:
45 
46  std::vector<TrajectoryFactoryBase*> theFactories;
48 };
49 
53 
54 using namespace std;
55 
57  TrajectoryFactoryBase( config ), theUseAllFactories(config.getParameter<bool>("useAllFactories"))
58 {
59  vector<string> factoryNames = config.getParameter< vector<string> >( "TrajectoryFactoryNames" );
60  vector<string>::iterator itFactoryName;
61  for ( itFactoryName = factoryNames.begin(); itFactoryName != factoryNames.end(); ++itFactoryName )
62  {
63  // auto_ptr to avoid missing a delete due to throw...
64  std::auto_ptr<TObjArray> namePset(TString((*itFactoryName).c_str()).Tokenize(","));
65  if (namePset->GetEntriesFast() != 2) {
66  throw cms::Exception("BadConfig") << "@SUB=CombinedTrajectoryFactory"
67  << "TrajectoryFactoryNames must contain 2 comma "
68  << "separated strings, but is '" << *itFactoryName << "'";
69  }
70  const edm::ParameterSet factoryCfg
71  = config.getParameter<edm::ParameterSet>(namePset->At(1)->GetName());
72  theFactories.push_back(TrajectoryFactoryPlugin::get()->create(namePset->At(0)->GetName(),
73  factoryCfg));
74  }
75 }
76 
77 
79 
80 
84  const reco::BeamSpot &beamSpot) const
85 {
87  ReferenceTrajectoryCollection tmpTrajectories; // outside loop for efficiency
88 
89  vector< TrajectoryFactoryBase* >::const_iterator itFactory;
90  for ( itFactory = theFactories.begin(); itFactory != theFactories.end(); ++itFactory )
91  {
92  tmpTrajectories = ( *itFactory )->trajectories(setup, tracks, beamSpot);
93  trajectories.insert(trajectories.end(), tmpTrajectories.begin(), tmpTrajectories.end());
94 
95  if (!theUseAllFactories && !trajectories.empty()) break;
96  }
97 
98  return trajectories;
99 }
100 
105  const reco::BeamSpot &beamSpot) const
106 {
108  ReferenceTrajectoryCollection tmpTrajectories; // outside loop for efficiency
109 
110  vector< TrajectoryFactoryBase* >::const_iterator itFactory;
111  for ( itFactory = theFactories.begin(); itFactory != theFactories.end(); ++itFactory )
112  {
113  tmpTrajectories = ( *itFactory )->trajectories(setup, tracks, external, beamSpot);
114  trajectories.insert(trajectories.end(), tmpTrajectories.begin(), tmpTrajectories.end());
115 
116  if (!theUseAllFactories && !trajectories.empty()) break;
117  }
118 
119  return trajectories;
120 }
121 
122 
T getParameter(std::string const &) const
virtual const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const override
def create(alignables, pedeDump, additionalData, outputFile, config)
CombinedTrajectoryFactory(const edm::ParameterSet &config)
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
Definition: config.py:1
std::vector< TrajectoryFactoryBase * > theFactories
virtual CombinedTrajectoryFactory * clone() const override
AlignmentAlgorithmBase::ConstTrajTrackPairCollection ConstTrajTrackPairCollection
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< TrajectoryStateOnSurface > ExternalPredictionCollection
T get(const Candidate &c)
Definition: component.h:55