CMS 3D CMS Logo

SeedCreatorFromRegionHitsEDProducerT.h
Go to the documentation of this file.
1 #ifndef RecoTracker_TkSeedGenerator_SeedCreatorFromRegionHitsEDProducerT_H
2 #define RecoTracker_TkSeedGenerator_SeedCreatorFromRegionHitsEDProducerT_H
3 
13 
17 
19 
20 template <typename T_SeedCreator>
22 public:
23 
25  ~SeedCreatorFromRegionHitsEDProducerT() override = default;
26 
27  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
28 
29  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
30 
31 private:
33  T_SeedCreator seedCreator_;
34  std::unique_ptr<SeedComparitor> comparitor_;
35 };
36 
37 template <typename T_SeedCreator>
39  seedingHitSetsToken_(consumes<RegionsSeedingHitSets>(iConfig.getParameter<edm::InputTag>("seedingHitSets"))),
40  seedCreator_(iConfig)
41 {
42  edm::ConsumesCollector iC = consumesCollector();
43  edm::ParameterSet comparitorPSet = iConfig.getParameter<edm::ParameterSet>("SeedComparitorPSet");
44  std::string comparitorName = comparitorPSet.getParameter<std::string>("ComponentName");
45  if(comparitorName != "none") {
46  comparitor_ = std::unique_ptr<SeedComparitor>{SeedComparitorFactory::get()->create(comparitorName, comparitorPSet, iC)};
47  }
48 
49  produces<TrajectorySeedCollection>();
50 }
51 
52 template <typename T_SeedCreator>
55 
56  desc.add<edm::InputTag>("seedingHitSets", edm::InputTag("hitPairEDProducer"));
58 
59  edm::ParameterSetDescription descComparitor;
60  descComparitor.add<std::string>("ComponentName", "none");
61  descComparitor.setAllowAnything(); // until we have moved SeedComparitor too to EDProducers
62  desc.add<edm::ParameterSetDescription>("SeedComparitorPSet", descComparitor);
63 
64  auto label = std::string("seedCreatorFromRegion") + T_SeedCreator::fillDescriptionsLabel() + "EDProducer";
65  descriptions.add(label, desc);
66 }
67 
68 template <typename T_SeedCreator>
70  edm::Handle<RegionsSeedingHitSets> hseedingHitSets;
71  iEvent.getByToken(seedingHitSetsToken_, hseedingHitSets);
72  const auto& seedingHitSets = *hseedingHitSets;
73 
74  auto seeds = std::make_unique<TrajectorySeedCollection>();
75  seeds->reserve(seedingHitSets.size());
76 
77  if(comparitor_)
78  comparitor_->init(iEvent, iSetup);
79 
80  for(const auto& regionSeedingHitSets: seedingHitSets) {
81  const TrackingRegion& region = regionSeedingHitSets.region();
82  seedCreator_.init(region, iSetup, comparitor_.get());
83 
84  for(const SeedingHitSet& hits: regionSeedingHitSets) {
85  // TODO: do we really need a comparitor at this point? It is
86  // used in triplet and quadruplet generators, as well as inside
87  // seedCreator.
88  if(!comparitor_ || comparitor_->compatible(hits)) {
89  seedCreator_.makeSeed(*seeds, hits);
90  }
91  }
92  }
93 
94  seeds->shrink_to_fit();
95  iEvent.put(std::move(seeds));
96 }
97 
98 #endif
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void setAllowAnything()
allow any parameter label/value pairs
char const * label
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< RegionsSeedingHitSets > seedingHitSetsToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void reserve(size_t nregions, size_t nhitsets)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
SeedCreatorFromRegionHitsEDProducerT(const edm::ParameterSet &iConfig)
HLT enums.
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
~SeedCreatorFromRegionHitsEDProducerT() override=default
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55