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 
36  const reco::BeamSpot &beamSpot) const override;
37 
38  CombinedTrajectoryFactory *clone() const override { return new CombinedTrajectoryFactory(*this); }
39 
40 private:
42  : TrajectoryFactoryBase(other), theUseAllFactories{other.theUseAllFactories} {
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, iC), 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, iC));
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 
def create(alignables, pedeDump, additionalData, outputFile, config)
CombinedTrajectoryFactory * clone() const override
Definition: config.py:1
CombinedTrajectoryFactory(const edm::ParameterSet &config, edm::ConsumesCollector &iC)
std::vector< std::unique_ptr< TrajectoryFactoryBase > > theFactories
double f[11][100]
CombinedTrajectoryFactory(const CombinedTrajectoryFactory &other)
const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const override
AlignmentAlgorithmBase::ConstTrajTrackPairCollection ConstTrajTrackPairCollection
std::vector< TrajectoryStateOnSurface > ExternalPredictionCollection
#define DEFINE_EDM_PLUGIN(factory, type, name)
#define get
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection