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 
25 public:
27  ~CombinedTrajectoryFactory() override;
28 
31  const reco::BeamSpot &beamSpot) const override;
32 
34  const ConstTrajTrackPairCollection &tracks,
36  const reco::BeamSpot &beamSpot) const override;
37 
38  CombinedTrajectoryFactory *clone() const override { return new CombinedTrajectoryFactory(*this); }
39 
40 private:
41  std::vector<TrajectoryFactoryBase *> theFactories;
43 };
44 
48 
49 using namespace std;
50 
52  : TrajectoryFactoryBase(config), theUseAllFactories(config.getParameter<bool>("useAllFactories")) {
53  vector<string> factoryNames = config.getParameter<vector<string> >("TrajectoryFactoryNames");
54  vector<string>::iterator itFactoryName;
55  for (itFactoryName = factoryNames.begin(); itFactoryName != factoryNames.end(); ++itFactoryName) {
56  // auto_ptr to avoid missing a delete due to throw...
57  std::unique_ptr<TObjArray> namePset(TString((*itFactoryName).c_str()).Tokenize(","));
58  if (namePset->GetEntriesFast() != 2) {
59  throw cms::Exception("BadConfig") << "@SUB=CombinedTrajectoryFactory"
60  << "TrajectoryFactoryNames must contain 2 comma "
61  << "separated strings, but is '" << *itFactoryName << "'";
62  }
63  const edm::ParameterSet factoryCfg = config.getParameter<edm::ParameterSet>(namePset->At(1)->GetName());
64  theFactories.push_back(TrajectoryFactoryPlugin::get()->create(namePset->At(0)->GetName(), factoryCfg));
65  }
66 }
67 
69 
73  ReferenceTrajectoryCollection tmpTrajectories; // outside loop for efficiency
74 
75  vector<TrajectoryFactoryBase *>::const_iterator itFactory;
76  for (itFactory = theFactories.begin(); itFactory != theFactories.end(); ++itFactory) {
77  tmpTrajectories = (*itFactory)->trajectories(setup, tracks, beamSpot);
78  trajectories.insert(trajectories.end(), tmpTrajectories.begin(), tmpTrajectories.end());
79 
80  if (!theUseAllFactories && !trajectories.empty())
81  break;
82  }
83 
84  return trajectories;
85 }
86 
88  const edm::EventSetup &setup,
91  const reco::BeamSpot &beamSpot) const {
93  ReferenceTrajectoryCollection tmpTrajectories; // outside loop for efficiency
94 
95  vector<TrajectoryFactoryBase *>::const_iterator itFactory;
96  for (itFactory = theFactories.begin(); itFactory != theFactories.end(); ++itFactory) {
97  tmpTrajectories = (*itFactory)->trajectories(setup, tracks, external, beamSpot);
98  trajectories.insert(trajectories.end(), tmpTrajectories.begin(), tmpTrajectories.end());
99 
100  if (!theUseAllFactories && !trajectories.empty())
101  break;
102  }
103 
104  return trajectories;
105 }
106 
T getParameter(std::string const &) const
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:2
Definition: config.py:1
CombinedTrajectoryFactory * clone() const override
AlignmentAlgorithmBase::ConstTrajTrackPairCollection ConstTrajTrackPairCollection
std::vector< TrajectoryFactoryBase * > theFactories
std::vector< TrajectoryStateOnSurface > ExternalPredictionCollection
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection
T get(const Candidate &c)
Definition: component.h:55