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), 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 
CombinedTrajectoryFactory::theFactories
std::vector< std::unique_ptr< TrajectoryFactoryBase > > theFactories
Definition: CombinedTrajectoryFactory.cc:49
electrons_cff.bool
bool
Definition: electrons_cff.py:366
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
CombinedTrajectoryFactory
Definition: CombinedTrajectoryFactory.cc:24
CombinedTrajectoryFactory::~CombinedTrajectoryFactory
~CombinedTrajectoryFactory() override
Definition: CombinedTrajectoryFactory.cc:75
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
CombinedTrajectoryFactory::CombinedTrajectoryFactory
CombinedTrajectoryFactory(const CombinedTrajectoryFactory &other)
Definition: CombinedTrajectoryFactory.cc:41
beamerCreator.create
def create(alignables, pedeDump, additionalData, outputFile, config)
Definition: beamerCreator.py:44
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
CombinedTrajectoryFactory::trajectories
const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const override
Definition: CombinedTrajectoryFactory.cc:77
config
Definition: config.py:1
external
Definition: HEPTopTaggerV2.h:20
reco::BeamSpot
Definition: BeamSpot.h:21
trackingPlots.other
other
Definition: trackingPlots.py:1460
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
TrajectoryFactoryBase::ReferenceTrajectoryCollection
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection
Definition: TrajectoryFactoryBase.h:26
edm::ParameterSet
Definition: ParameterSet.h:47
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
TrajectoryFactoryBase
Definition: TrajectoryFactoryBase.h:20
TrajectoryFactoryPlugin.h
edmplugin::PluginFactory
Definition: PluginFactory.h:34
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
CombinedTrajectoryFactory::CombinedTrajectoryFactory
CombinedTrajectoryFactory(const edm::ParameterSet &config)
Definition: CombinedTrajectoryFactory.cc:59
TrajectoryFactoryBase::ConstTrajTrackPairCollection
AlignmentAlgorithmBase::ConstTrajTrackPairCollection ConstTrajTrackPairCollection
Definition: TrajectoryFactoryBase.h:25
std
Definition: JetResolutionObject.h:76
CombinedTrajectoryFactory::clone
CombinedTrajectoryFactory * clone() const override
Definition: CombinedTrajectoryFactory.cc:38
Exception
Definition: hltDiff.cc:245
CombinedTrajectoryFactory::theUseAllFactories
bool theUseAllFactories
Definition: CombinedTrajectoryFactory.cc:50
ParameterSet.h
TrajectoryFactoryBase.h
TrajectoryFactoryBase::ExternalPredictionCollection
std::vector< TrajectoryStateOnSurface > ExternalPredictionCollection
Definition: TrajectoryFactoryBase.h:28