1 #ifndef RecoPixelVertexing_PixelTriplets_HitTripletEDProducerT_H
2 #define RecoPixelVertexing_PixelTriplets_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.";