CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CAHitNtupletEDProducerT.cc
Go to the documentation of this file.
10 
14 
15 namespace {
16  void fillNtuplets(RegionsSeedingHitSets::RegionFiller& seedingHitSetsFiller, const OrderedHitSeeds& quadruplets) {
17  for (const auto& quad : quadruplets) {
18  seedingHitSetsFiller.emplace_back(quad[0], quad[1], quad[2], quad[3]);
19  }
20  }
21 } // namespace
22 
23 template <typename T_Generator>
25 public:
27  ~CAHitNtupletEDProducerT() override = default;
28 
29  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
30 
31  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
32 
33 private:
35 
37 
38  T_Generator generator_;
39 };
40 
41 template <typename T_Generator>
43  : doubletToken_(consumes<IntermediateHitDoublets>(iConfig.getParameter<edm::InputTag>("doublets"))),
44  generator_(iConfig, consumesCollector()) {
45  produces<RegionsSeedingHitSets>();
46 }
47 
48 template <typename T_Generator>
51 
52  desc.add<edm::InputTag>("doublets", edm::InputTag("hitPairEDProducer"));
54 
55  auto label = T_Generator::fillDescriptionsLabel() + std::string("EDProducer");
56  descriptions.add(label, desc);
57 }
58 
59 template <typename T_Generator>
62  iEvent.getByToken(doubletToken_, hdoublets);
63  const auto& regionDoublets = *hdoublets;
64 
65  const SeedingLayerSetsHits& seedingLayerHits = regionDoublets.seedingLayerHits();
66  if (seedingLayerHits.numberOfLayersInSet() < T_Generator::minLayers) {
67  throw cms::Exception("LogicError")
68  << "CAHitNtupletEDProducer expects SeedingLayerSetsHits::numberOfLayersInSet() to be >= "
69  << T_Generator::minLayers << ", got " << seedingLayerHits.numberOfLayersInSet()
70  << ". This is likely caused by a configuration error of this module, HitPairEDProducer, or "
71  "SeedingLayersEDProducer.";
72  }
73 
74  auto seedingHitSets = std::make_unique<RegionsSeedingHitSets>();
75  if (regionDoublets.empty()) {
76  iEvent.put(std::move(seedingHitSets));
77  return;
78  }
79  seedingHitSets->reserve(regionDoublets.regionSize(), localRA_.upper());
80  generator_.initEvent(iEvent, iSetup);
81 
82  LogDebug("CAHitNtupletEDProducer") << "Creating ntuplets for " << regionDoublets.regionSize() << " regions, and "
83  << regionDoublets.layerPairsSize() << " layer pairs";
84  std::vector<OrderedHitSeeds> ntuplets;
85  ntuplets.resize(regionDoublets.regionSize());
86  for (auto& ntuplet : ntuplets)
87  ntuplet.reserve(localRA_.upper());
88 
89  generator_.hitNtuplets(regionDoublets, ntuplets, seedingLayerHits);
90  int index = 0;
91  for (const auto& regionLayerPairs : regionDoublets) {
92  const TrackingRegion& region = regionLayerPairs.region();
93  auto seedingHitSetsFiller = seedingHitSets->beginRegion(&region);
94 
95  fillNtuplets(seedingHitSetsFiller, ntuplets[index]);
96  ntuplets[index].clear();
97  index++;
98  }
99  localRA_.update(seedingHitSets->size());
100 
101  iEvent.put(std::move(seedingHitSets));
102 }
103 
109 
tuple seedingHitSets
unsigned short numberOfLayersInSet() const
Get number of layers in each SeedingLayerSets.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
CAHitNtupletEDProducerT(const edm::ParameterSet &iConfig)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
char const * label
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< IntermediateHitDoublets > doubletToken_
Helper class enforcing correct way of filling the doublets of a region.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
~CAHitNtupletEDProducerT() override=default
#define LogDebug(id)