1 #ifndef RecoTracker_PixelSeeding_HitTripletEDProducerT_h 2 #define RecoTracker_PixelSeeding_HitTripletEDProducerT_h 27 template <
typename T_HitTripletGenerator>
40 std::unique_ptr<hitTripletEDProducerT::ImplBase>
impl_;
59 template <
typename T_HitTripletGenerator>
70 template <
typename T_HitTripletGenerator,
typename T_SeedingHitSets,
typename T_IntermediateHitTriplets>
75 ~Impl()
override =
default;
78 T_SeedingHitSets::produces(producesCollector);
79 T_IntermediateHitTriplets::produces(producesCollector);
87 auto seedingHitSetsProducer = T_SeedingHitSets();
88 auto intermediateHitTripletsProducer = T_IntermediateHitTriplets(&seedingLayerHits);
90 if (regionDoublets.
empty()) {
91 seedingHitSetsProducer.putEmpty(
iEvent);
92 intermediateHitTripletsProducer.putEmpty(
iEvent);
104 size_t triplets_total = 0;
106 LogDebug(
"HitTripletEDProducer") <<
"Creating triplets for " << regionDoublets.
regionSize() <<
" regions, and " 107 << trilayers.size() <<
" pair+3rd layers from " 110 for (
const auto& regionLayerPairs : regionDoublets) {
113 auto hitCachePtr_filler_shs = seedingHitSetsProducer.beginRegion(&
region,
nullptr);
114 auto hitCachePtr_filler_iht =
115 intermediateHitTripletsProducer.beginRegion(&
region, std::get<0>(hitCachePtr_filler_shs));
116 auto hitCachePtr = std::get<0>(hitCachePtr_filler_iht);
119 hitCache.
extend(regionLayerPairs.layerHitMapCache());
121 LogTrace(
"HitTripletEDProducer") <<
" starting region";
123 for (
const auto& layerPair : regionLayerPairs) {
125 <<
" starting layer pair " << layerPair.innerLayerIndex() <<
"," << layerPair.outerLayerIndex();
128 return a.first[0].index() == layerPair.innerLayerIndex() &&
129 a.first[1].index() == layerPair.outerLayerIndex();
131 if (
found == trilayers.end()) {
132 auto exp =
cms::Exception(
"LogicError") <<
"Did not find the layer pair from vector<pair+third layers>. " 133 "This is a sign of some internal inconsistency\n";
134 exp <<
"I was looking for layer pair " << layerPair.innerLayerIndex() <<
"," << layerPair.outerLayerIndex()
135 <<
". Triplets have the following pairs:\n";
136 for (
const auto&
a : trilayers) {
137 exp <<
" " <<
a.first[0].index() <<
"," <<
a.first[1].index() <<
": 3rd layers";
138 for (
const auto&
b :
a.second) {
139 exp <<
" " <<
b.index();
145 const auto& thirdLayers =
found->second;
151 layerPair.doublets(),
153 intermediateHitTripletsProducer.tripletLastLayerIndexVector(),
158 <<
" created " << triplets.
size() <<
" triplets for layer pair " << layerPair.innerLayerIndex() <<
"," 159 << layerPair.outerLayerIndex() <<
" and 3rd layers";
160 for (
const auto&
l : thirdLayers) {
161 LogTrace(
"HitTripletEDProducer") <<
" " <<
l.index();
165 triplets_total += triplets.
size();
166 seedingHitSetsProducer.fill(std::get<1>(hitCachePtr_filler_shs), triplets);
167 intermediateHitTripletsProducer.fill(
168 std::get<1>(hitCachePtr_filler_iht), layerPair.layerPair(), thirdLayers, triplets);
175 seedingHitSetsProducer.put(
iEvent);
176 intermediateHitTripletsProducer.put(
iEvent);
197 const std::vector<SeedingLayerSetsHits::SeedingLayer>&,
221 for (
const auto& trpl : triplets) {
222 filler.emplace_back(trpl.inner(), trpl.middle(), trpl.outer());
247 void reserve(
size_t regionsSize,
size_t localRAupper) {
254 return std::make_tuple(&(
filler.layerHitMapCache()),
filler);
261 const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers,
265 <<
" triplets.size() " << triplets.
size();
292 template <
typename T_HitTripletGenerator>
298 auto iC = consumesCollector();
303 impl_ = std::make_unique<Impl<T_HitTripletGenerator, ImplSeedingHitSets, ImplIntermediateHitTriplets>>(iConfig, iC);
305 impl_ = std::make_unique<Impl<T_HitTripletGenerator, ImplSeedingHitSets, DoNothing>>(iConfig, iC);
307 impl_ = std::make_unique<Impl<T_HitTripletGenerator, DoNothing, ImplIntermediateHitTriplets>>(iConfig, iC);
310 <<
"HitTripletEDProducerT requires either produceIntermediateHitTriplets or produceSeedingHitSets to be True. " 311 "If neither are needed, just remove this module from your sequence/path as it doesn't do anything useful";
313 impl_->produces(producesCollector());
316 template <
typename T_HitTripletGenerator>
321 desc.add<
bool>(
"produceSeedingHitSets",
false);
322 desc.add<
bool>(
"produceIntermediateHitTriplets",
false);
326 auto label = T_HitTripletGenerator::fillDescriptionsLabel() +
std::string(
"EDProducerDefault");
330 template <
typename T_HitTripletGenerator>
334 const auto& regionDoublets = *hdoublets;
339 <<
"HitTripletEDProducerT expects SeedingLayerSetsHits::numberOfLayersInSet() to be >= 3, got " 341 <<
". This is likely caused by a configuration error of this module, HitPairEDProducer, or " 342 "SeedingLayersEDProducer.";
void fill(int, const IntermediateHitTriplets::LayerPair &, const std::vector< SeedingLayerSetsHits::SeedingLayer > &, const OrderedHitTriplets &)
auto beginRegion(const TrackingRegion *, LayerHitMapCache *ptr)
T getParameter(std::string const &) const
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
T_HitTripletGenerator generator_
void fill(int, const OrderedHitTriplets &)
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
void putEmpty(edm::Event &iEvent)
virtual void produces(edm::ProducesCollector) const =0
unsigned short size() const
Get the number of SeedingLayerSets.
~HitTripletEDProducerT() override=default
void reserve(size_t regionsSize, size_t localRAupper)
std::unique_ptr< hitTripletEDProducerT::ImplBase > impl_
Impl(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
LayerHitMapCache hitCacheTmp_
std::unique_ptr< RegionsSeedingHitSets > seedingHitSets_
static void produces(edm::ProducesCollector producesCollector)
DoNothing(const SeedingLayerSetsHits *layers)
virtual void produce(const IntermediateHitDoublets ®ionDoublets, edm::Event &iEvent, const edm::EventSetup &iSetup)=0
static void produces(edm::ProducesCollector)
void produce(const IntermediateHitDoublets ®ionDoublets, edm::Event &iEvent, const edm::EventSetup &iSetup) override
auto beginRegion(const TrackingRegion *region, LayerHitMapCache *ptr)
unsigned short numberOfLayersInSet() const
Get number of layers in each SeedingLayerSets.
edm::RunningAverage localRA_
std::pair< LayerSet, std::vector< Layer > > LayerSetAndLayers
void put(edm::Event &iEvent)
Helper class enforcing correct way of filling the doublets of a region.
void produces(edm::ProducesCollector producesCollector) const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
produceIntermediateHitTriplets
void fill(RegionsSeedingHitSets::RegionFiller &filler, const OrderedHitTriplets &triplets)
edm::EDGetTokenT< IntermediateHitDoublets > doubletToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void putEmpty(edm::Event &iEvent)
void extend(const LayerHitMapCache &other)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
~ImplGeneratorBase() override=default
virtual ~ImplBase()=default
std::vector< int > * tripletLastLayerIndexVector()
HitTripletEDProducerT(const edm::ParameterSet &iConfig)
void put(edm::Event &iEvent)
unsigned int size() const override
void update(unsigned int q)
ImplGeneratorBase(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
void reserve(size_t, size_t)