CMS 3D CMS Logo

CAHitNtupletEDProducerT.cc
Go to the documentation of this file.
10 
15 
16 namespace {
17  void fillNtuplets(RegionsSeedingHitSets::RegionFiller& seedingHitSetsFiller,
18  const OrderedHitSeeds& quadruplets) {
19  for(const auto& quad: quadruplets) {
20  seedingHitSetsFiller.emplace_back(quad[0], quad[1], quad[2], quad[3]);
21  }
22  }
23 }
24 
25 template <typename T_Generator>
27 public:
29  ~CAHitNtupletEDProducerT() = default;
30 
31  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
32 
33  virtual void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
34 
35 private:
37 
39 
40  T_Generator generator_;
41 };
42 
43 template <typename T_Generator>
45  doubletToken_(consumes<IntermediateHitDoublets>(iConfig.getParameter<edm::InputTag>("doublets"))),
47 {
48  produces<RegionsSeedingHitSets>();
49 }
50 
51 template <typename T_Generator>
54 
55  desc.add<edm::InputTag>("doublets", edm::InputTag("hitPairEDProducer"));
56  T_Generator::fillDescriptions(desc);
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") << "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.";
71  }
72 
73  auto seedingHitSets = std::make_unique<RegionsSeedingHitSets>();
74  if(regionDoublets.empty()) {
75  iEvent.put(std::move(seedingHitSets));
76  return;
77  }
78  seedingHitSets->reserve(regionDoublets.regionSize(), localRA_.upper());
79  generator_.initEvent(iEvent, iSetup);
80 
81  LogDebug("CAHitNtupletEDProducer") << "Creating ntuplets for " << regionDoublets.regionSize() << " regions, and " << regionDoublets.layerPairsSize() << " layer pairs";
82  std::vector<typename T_Generator::ResultType> ntuplets;
83  ntuplets.resize(regionDoublets.regionSize());
84  for(auto& ntuplet : ntuplets) ntuplet.reserve(localRA_.upper());
85 
86  generator_.hitNtuplets(regionDoublets, ntuplets, iSetup, seedingLayerHits);
87  int index = 0;
88  for(const auto& regionLayerPairs: regionDoublets) {
89  const TrackingRegion& region = regionLayerPairs.region();
90  auto seedingHitSetsFiller = seedingHitSets->beginRegion(&region);
91 
92  fillNtuplets(seedingHitSetsFiller, ntuplets[index]);
93  ntuplets[index].clear();
94  index++;
95  }
97 
98  iEvent.put(std::move(seedingHitSets));
99 }
100 
106 
107 #include "CAHitTripletGenerator.h"
#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:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
CAHitNtupletEDProducerT(const edm::ParameterSet &iConfig)
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int upper() const
int iEvent
Definition: GenABIO.cc:230
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< IntermediateHitDoublets > doubletToken_
~CAHitNtupletEDProducerT()=default
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)
def move(src, dest)
Definition: eostools.py:510
void update(unsigned int q)