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 {
43  edm::ParameterSet comparitorPSet = iConfig.getParameter<edm::ParameterSet>("SeedComparitorPSet");
44  std::string comparitorName = comparitorPSet.getParameter<std::string>("ComponentName");
45  comparitor_.reset((comparitorName == "none") ? nullptr : SeedComparitorFactory::get()->create(comparitorName, comparitorPSet, iC));
46 
47  produces<TrajectorySeedCollection>();
48 }
49 
50 template <typename T_SeedCreator>
53 
54  desc.add<edm::InputTag>("seedingHitSets", edm::InputTag("hitPairEDProducer"));
55  T_SeedCreator::fillDescriptions(desc);
56 
57  edm::ParameterSetDescription descComparitor;
58  descComparitor.add<std::string>("ComponentName", "none");
59  descComparitor.setAllowAnything(); // until we have moved SeedComparitor too to EDProducers
60  desc.add<edm::ParameterSetDescription>("SeedComparitorPSet", descComparitor);
61 
62  auto label = std::string("seedCreatorFromRegion") + T_SeedCreator::fillDescriptionsLabel() + "EDProducer";
63  descriptions.add(label, desc);
64 }
65 
66 template <typename T_SeedCreator>
68  edm::Handle<RegionsSeedingHitSets> hseedingHitSets;
69  iEvent.getByToken(seedingHitSetsToken_, hseedingHitSets);
70  const auto& seedingHitSets = *hseedingHitSets;
71 
72  auto seeds = std::make_unique<TrajectorySeedCollection>();
73  seeds->reserve(seedingHitSets.size());
74 
75  if(comparitor_)
76  comparitor_->init(iEvent, iSetup);
77 
78  for(const auto& regionSeedingHitSets: seedingHitSets) {
79  const TrackingRegion& region = regionSeedingHitSets.region();
80  seedCreator_.init(region, iSetup, comparitor_.get());
81 
82  for(const SeedingHitSet& hits: regionSeedingHitSets) {
83  // TODO: do we really need a comparitor at this point? It is
84  // used in triplet and quadruplet generators, as well as inside
85  // seedCreator.
86  if(!comparitor_ || comparitor_->compatible(hits)) {
87  seedCreator_.makeSeed(*seeds, hits);
88  }
89  }
90  }
91 
92  seeds->shrink_to_fit();
93  iEvent.put(std::move(seeds));
94 }
95 
96 #endif
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
def create(alignables, pedeDump, additionalData, outputFile, config)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
void setAllowAnything()
allow any parameter label/value pairs
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< RegionsSeedingHitSets > seedingHitSetsToken_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void reserve(size_t nregions, size_t nhitsets)
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:510
T get(const Candidate &c)
Definition: component.h:55