CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CAHitNtupletEDProducerT.cc
Go to the documentation of this file.
10 
15 
16 namespace {
17  void fillNtuplets(RegionsSeedingHitSets::RegionFiller& seedingHitSetsFiller,
18  const OrderedHitTriplets& triplets) {
19  for(const auto& triplet: triplets) {
20  seedingHitSetsFiller.emplace_back(triplet[0], triplet[1], triplet[2]);
21  }
22  }
23 
24  void fillNtuplets(RegionsSeedingHitSets::RegionFiller& seedingHitSetsFiller,
25  const OrderedHitSeeds& quadruplets) {
26  for(const auto& quad: quadruplets) {
27  seedingHitSetsFiller.emplace_back(quad[0], quad[1], quad[2], quad[3]);
28  }
29  }
30 }
31 
32 template <typename T_Generator>
34 public:
36  ~CAHitNtupletEDProducerT() = default;
37 
38  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
39 
40  virtual void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
41 
42 private:
44 
46 
47  T_Generator generator_;
48 };
49 
50 template <typename T_Generator>
52  doubletToken_(consumes<IntermediateHitDoublets>(iConfig.getParameter<edm::InputTag>("doublets"))),
53  generator_(iConfig, consumesCollector(), false)
54 {
55  produces<RegionsSeedingHitSets>();
56 }
57 
58 template <typename T_Generator>
61 
62  desc.add<edm::InputTag>("doublets", edm::InputTag("hitPairEDProducer"));
63  T_Generator::fillDescriptions(desc);
64 
65  auto label = T_Generator::fillDescriptionsLabel() + std::string("EDProducer");
66  descriptions.add(label, desc);
67 }
68 
69 template <typename T_Generator>
72  iEvent.getByToken(doubletToken_, hdoublets);
73  const auto& regionDoublets = *hdoublets;
74 
75  const SeedingLayerSetsHits& seedingLayerHits = regionDoublets.seedingLayerHits();
76  if(seedingLayerHits.numberOfLayersInSet() < T_Generator::minLayers) {
77  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.";
78  }
79 
80  auto seedingHitSets = std::make_unique<RegionsSeedingHitSets>();
81  if(regionDoublets.empty()) {
82  iEvent.put(std::move(seedingHitSets));
83  return;
84  }
85  seedingHitSets->reserve(regionDoublets.regionSize(), localRA_.upper());
86  generator_.initEvent(iEvent, iSetup);
87 
88  LogDebug("CAHitNtupletEDProducer") << "Creating ntuplets for " << regionDoublets.regionSize() << " regions, and " << regionDoublets.layerPairsSize() << " layer pairs";
89 
90  typename T_Generator::ResultType ntuplets;
91  ntuplets.reserve(localRA_.upper());
92 
93  for(const auto& regionLayerPairs: regionDoublets) {
94  const TrackingRegion& region = regionLayerPairs.region();
95  auto seedingHitSetsFiller = seedingHitSets->beginRegion(&region);
96 
97  LogTrace("CAHitNtupletEDProducer") << " starting region";
98 
99  generator_.hitNtuplets(regionLayerPairs, ntuplets, iSetup, seedingLayerHits);
100  LogTrace("CAHitNtupletEDProducer") << " created " << ntuplets.size() << " ntuplets";
101  fillNtuplets(seedingHitSetsFiller, ntuplets);
102 
103  ntuplets.clear();
104  }
105  localRA_.update(seedingHitSets->size());
106 
107  iEvent.put(std::move(seedingHitSets));
108 }
109 
115 
116 #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:457
#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
int iEvent
Definition: GenABIO.cc:230
def move
Definition: eostools.py:510
ParameterDescriptionBase * add(U const &iLabel, T const &value)
#define LogTrace(id)
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)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
volatile std::atomic< bool > shutdown_flag false