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:
43  theFactories.reserve(other.theFactories.size());
44  for (const auto &f : other.theFactories) {
45  theFactories.emplace_back(f->clone());
46  }
47  }
48 
49  std::vector<std::unique_ptr<TrajectoryFactoryBase>> theFactories;
51 };
52 
56 
57 using namespace std;
58 
60  : TrajectoryFactoryBase(config), theUseAllFactories(config.getParameter<bool>("useAllFactories")) {
61  vector<string> factoryNames = config.getParameter<vector<string>>("TrajectoryFactoryNames");
62  for (auto const &factoryName : factoryNames) {
63  // auto_ptr to avoid missing a delete due to throw...
64  std::unique_ptr<TObjArray> namePset(TString(factoryName.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 '" << factoryName << "'";
69  }
70  const edm::ParameterSet factoryCfg = config.getParameter<edm::ParameterSet>(namePset->At(1)->GetName());
71  theFactories.emplace_back(TrajectoryFactoryPlugin::get()->create(namePset->At(0)->GetName(), factoryCfg));
72  }
73 }
74 
76 
80  ReferenceTrajectoryCollection tmpTrajectories; // outside loop for efficiency
81 
82  for (auto const &factory : theFactories) {
83  tmpTrajectories = factory->trajectories(setup, tracks, beamSpot);
84  trajectories.insert(trajectories.end(), tmpTrajectories.begin(), tmpTrajectories.end());
85 
86  if (!theUseAllFactories && !trajectories.empty())
87  break;
88  }
89 
90  return trajectories;
91 }
92 
94  const edm::EventSetup &setup,
97  const reco::BeamSpot &beamSpot) const {
99  ReferenceTrajectoryCollection tmpTrajectories; // outside loop for efficiency
100 
101  for (auto const &factory : theFactories) {
102  tmpTrajectories = factory->trajectories(setup, tracks, external, beamSpot);
103  trajectories.insert(trajectories.end(), tmpTrajectories.begin(), tmpTrajectories.end());
104 
105  if (!theUseAllFactories && !trajectories.empty())
106  break;
107  }
108 
109  return trajectories;
110 }
111 
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)
Definition: config.py:1
std::vector< std::unique_ptr< TrajectoryFactoryBase > > theFactories
CombinedTrajectoryFactory * clone() const override
double f[11][100]
CombinedTrajectoryFactory(const CombinedTrajectoryFactory &other)
AlignmentAlgorithmBase::ConstTrajTrackPairCollection ConstTrajTrackPairCollection
std::vector< TrajectoryStateOnSurface > ExternalPredictionCollection
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection