CMS 3D CMS Logo

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  if (quad.size() == 3)
19  seedingHitSetsFiller.emplace_back(quad[0], quad[1], quad[2]);
20  if (quad.size() == 4)
21  seedingHitSetsFiller.emplace_back(quad[0], quad[1], quad[2], quad[3]);
22  }
23  }
24 } // namespace
25 
26 template <typename T_Generator>
28 public:
30  ~CAHitNtupletEDProducerT() override = default;
31 
32  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
33 
34  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
35 
36 private:
38 
40 
41  T_Generator generator_;
42 };
43 
44 template <typename T_Generator>
46  : doubletToken_(consumes<IntermediateHitDoublets>(iConfig.getParameter<edm::InputTag>("doublets"))),
47  generator_(iConfig, consumesCollector()) {
48  produces<RegionsSeedingHitSets>();
49 }
50 
51 template <typename T_Generator>
54 
55  desc.add<edm::InputTag>("doublets", edm::InputTag("hitPairEDProducer"));
57 
58  auto label = T_Generator::fillDescriptionsLabel() + std::string("EDProducer");
59  descriptions.add(label, desc);
60 }
61 
62 template <typename T_Generator>
65  iEvent.getByToken(doubletToken_, hdoublets);
66  const auto& regionDoublets = *hdoublets;
67 
68  const SeedingLayerSetsHits& seedingLayerHits = regionDoublets.seedingLayerHits();
69  if (seedingLayerHits.numberOfLayersInSet() < T_Generator::minLayers) {
70  throw cms::Exception("LogicError")
71  << "CAHitNtupletEDProducer expects SeedingLayerSetsHits::numberOfLayersInSet() to be >= "
72  << T_Generator::minLayers << ", got " << seedingLayerHits.numberOfLayersInSet()
73  << ". This is likely caused by a configuration error of this module, HitPairEDProducer, or "
74  "SeedingLayersEDProducer.";
75  }
76 
77  auto seedingHitSets = std::make_unique<RegionsSeedingHitSets>();
78  if (regionDoublets.empty()) {
80  return;
81  }
82  seedingHitSets->reserve(regionDoublets.regionSize(), localRA_.upper());
83  generator_.initEvent(iEvent, iSetup);
84 
85  LogDebug("CAHitNtupletEDProducer") << "Creating ntuplets for " << regionDoublets.regionSize() << " regions, and "
86  << regionDoublets.layerPairsSize() << " layer pairs";
87  std::vector<OrderedHitSeeds> ntuplets;
88  ntuplets.resize(regionDoublets.regionSize());
89  for (auto& ntuplet : ntuplets)
90  ntuplet.reserve(localRA_.upper());
91 
92  generator_.hitNtuplets(regionDoublets, ntuplets, seedingLayerHits);
93  int index = 0;
94  for (const auto& regionLayerPairs : regionDoublets) {
95  const TrackingRegion& region = regionLayerPairs.region();
96  auto seedingHitSetsFiller = seedingHitSets->beginRegion(&region);
97 
98  fillNtuplets(seedingHitSetsFiller, ntuplets[index]);
99  ntuplets[index].clear();
100  index++;
101  }
102  localRA_.update(seedingHitSets->size());
103 
105 }
106 
112 
#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
edm::EDGetTokenT< IntermediateHitDoublets > doubletToken_
unsigned short numberOfLayersInSet() const
Get number of layers in each SeedingLayerSets.
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)
HLT enums.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
~CAHitNtupletEDProducerT() override=default
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)