CMS 3D CMS Logo

CAHitNtupletEDProducerT.cc
Go to the documentation of this file.
10 
14 
15 namespace {
16  void fillNtuplets(RegionsSeedingHitSets::RegionFiller& seedingHitSetsFiller,
17  const OrderedHitSeeds& quadruplets) {
18  for(const auto& quad: quadruplets) {
19  seedingHitSetsFiller.emplace_back(quad[0], quad[1], quad[2], quad[3]);
20  }
21  }
22 }
23 
24 template <typename T_Generator>
26 public:
28  ~CAHitNtupletEDProducerT() override = default;
29 
30  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
31 
32  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
33 
34 private:
36 
38 
39  T_Generator generator_;
40 };
41 
42 template <typename T_Generator>
44  doubletToken_(consumes<IntermediateHitDoublets>(iConfig.getParameter<edm::InputTag>("doublets"))),
45  generator_(iConfig, consumesCollector())
46 {
47  produces<RegionsSeedingHitSets>();
48 }
49 
50 template <typename T_Generator>
53 
54  desc.add<edm::InputTag>("doublets", edm::InputTag("hitPairEDProducer"));
56 
57  auto label = T_Generator::fillDescriptionsLabel() + std::string("EDProducer");
58  descriptions.add(label, desc);
59 }
60 
61 template <typename T_Generator>
64  iEvent.getByToken(doubletToken_, hdoublets);
65  const auto& regionDoublets = *hdoublets;
66 
67  const SeedingLayerSetsHits& seedingLayerHits = regionDoublets.seedingLayerHits();
68  if(seedingLayerHits.numberOfLayersInSet() < T_Generator::minLayers) {
69  throw cms::Exception("LogicError") << "CAHitNtupletEDProducer expects SeedingLayerSetsHits::numberOfLayersInSet() to be >= " << T_Generator::minLayers << ", got " << seedingLayerHits.numberOfLayersInSet() << ". This is likely caused by a configuration error of this module, HitPairEDProducer, or SeedingLayersEDProducer.";
70  }
71 
72  auto seedingHitSets = std::make_unique<RegionsSeedingHitSets>();
73  if(regionDoublets.empty()) {
74  iEvent.put(std::move(seedingHitSets));
75  return;
76  }
77  seedingHitSets->reserve(regionDoublets.regionSize(), localRA_.upper());
78  generator_.initEvent(iEvent, iSetup);
79 
80  LogDebug("CAHitNtupletEDProducer") << "Creating ntuplets for " << regionDoublets.regionSize() << " regions, and " << regionDoublets.layerPairsSize() << " layer pairs";
81  std::vector<OrderedHitSeeds> ntuplets;
82  ntuplets.resize(regionDoublets.regionSize());
83  for(auto& ntuplet : ntuplets) ntuplet.reserve(localRA_.upper());
84 
85  generator_.hitNtuplets(regionDoublets, ntuplets, iSetup, seedingLayerHits);
86  int index = 0;
87  for(const auto& regionLayerPairs: regionDoublets) {
88  const TrackingRegion& region = regionLayerPairs.region();
89  auto seedingHitSetsFiller = seedingHitSets->beginRegion(&region);
90 
91  fillNtuplets(seedingHitSetsFiller, ntuplets[index]);
92  ntuplets[index].clear();
93  index++;
94  }
96 
97  iEvent.put(std::move(seedingHitSets));
98 }
99 
105 
#define LogDebug(id)
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:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
CAHitNtupletEDProducerT(const edm::ParameterSet &iConfig)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
int upper() const
int iEvent
Definition: GenABIO.cc:230
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< IntermediateHitDoublets > doubletToken_
Helper class enforcing correct way of filling the doublets of a region.
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:510
void update(unsigned int q)