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 
12 
16 
18 
19 template <typename T_SeedCreator>
21 public:
22 
25 
26  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
27 
28  virtual void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
29 
30 private:
32  T_SeedCreator seedCreator_;
33  std::unique_ptr<SeedComparitor> comparitor_;
34 };
35 
36 template <typename T_SeedCreator>
38  seedingHitSetsToken_(consumes<RegionsSeedingHitSets>(iConfig.getParameter<edm::InputTag>("seedingHitSets"))),
39  seedCreator_(iConfig)
40 {
42  edm::ParameterSet comparitorPSet = iConfig.getParameter<edm::ParameterSet>("SeedComparitorPSet");
43  std::string comparitorName = comparitorPSet.getParameter<std::string>("ComponentName");
44  comparitor_.reset((comparitorName == "none") ? nullptr : SeedComparitorFactory::get()->create(comparitorName, comparitorPSet, iC));
45 
46  produces<TrajectorySeedCollection>();
47 }
48 
49 template <typename T_SeedCreator>
52 
53  desc.add<edm::InputTag>("seedingHitSets", edm::InputTag("hitPairEDProducer"));
54  T_SeedCreator::fillDescriptions(desc);
55 
56  edm::ParameterSetDescription descComparitor;
57  descComparitor.add<std::string>("ComponentName", "none");
58  descComparitor.setAllowAnything(); // until we have moved SeedComparitor too to EDProducers
59  desc.add<edm::ParameterSetDescription>("SeedComparitorPSet", descComparitor);
60 
61  auto label = std::string("seedCreatorFromRegion") + T_SeedCreator::fillDescriptionsLabel() + "EDProducer";
62  descriptions.add(label, desc);
63 }
64 
65 template <typename T_SeedCreator>
67  edm::Handle<RegionsSeedingHitSets> hseedingHitSets;
68  iEvent.getByToken(seedingHitSetsToken_, hseedingHitSets);
69  const auto& seedingHitSets = *hseedingHitSets;
70 
71  auto seeds = std::make_unique<TrajectorySeedCollection>();
72  seeds->reserve(seedingHitSets.size());
73 
74  if(comparitor_)
75  comparitor_->init(iEvent, iSetup);
76 
77  for(const auto& regionSeedingHitSets: seedingHitSets) {
78  const TrackingRegion& region = regionSeedingHitSets.region();
79  seedCreator_.init(region, iSetup, comparitor_.get());
80 
81  for(const SeedingHitSet& hits: regionSeedingHitSets) {
82  // TODO: do we really need a comparitor at this point? It is
83  // used in triplet and quadruplet generators, as well as inside
84  // seedCreator.
85  if(!comparitor_ || comparitor_->compatible(hits)) {
86  seedCreator_.makeSeed(*seeds, hits);
87  }
88  }
89  }
90 
91  seeds->shrink_to_fit();
92  iEvent.put(std::move(seeds));
93 }
94 
95 #endif
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
def create(alignables, pedeDump, additionalData, outputFile, config)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
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.
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
def move(src, dest)
Definition: eostools.py:510
T get(const Candidate &c)
Definition: component.h:55