-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate CAHiTripletGenerator and generalize
- Loading branch information
Showing
10 changed files
with
338 additions
and
163 deletions.
There are no files selected for viewing
118 changes: 118 additions & 0 deletions
118
RecoPixelVertexing/PixelTriplets/plugins/CAHitNtupletEDProducerT.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
#include "FWCore/Framework/interface/stream/EDProducer.h" | ||
#include "FWCore/Framework/interface/ConsumesCollector.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
#include "FWCore/Utilities/interface/EDGetToken.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "DataFormats/Common/interface/Handle.h" | ||
#include "FWCore/Utilities/interface/RunningAverage.h" | ||
|
||
#include "RecoTracker/TkHitPairs/interface/RegionsSeedingHitSets.h" | ||
#include "RecoPixelVertexing/PixelTriplets/interface/OrderedHitTriplets.h" | ||
#include "RecoPixelVertexing/PixelTriplets/interface/OrderedHitSeeds.h" | ||
#include "RecoTracker/TkHitPairs/interface/IntermediateHitDoublets.h" | ||
|
||
namespace { | ||
void fillNtuplets(RegionsSeedingHitSets::RegionFiller& seedingHitSetsFiller, | ||
const OrderedHitTriplets& triplets) { | ||
for(const auto& triplet: triplets) { | ||
seedingHitSetsFiller.emplace_back(triplet[0], triplet[1], triplet[2]); | ||
} | ||
} | ||
|
||
void fillNtuplets(RegionsSeedingHitSets::RegionFiller& seedingHitSetsFiller, | ||
const OrderedHitSeeds& quadruplets) { | ||
for(const auto& quad: quadruplets) { | ||
seedingHitSetsFiller.emplace_back(quad[0], quad[1], quad[2], quad[3]); | ||
} | ||
} | ||
} | ||
|
||
template <typename T_Generator> | ||
class CAHitNtupletEDProducerT: public edm::stream::EDProducer<> { | ||
public: | ||
CAHitNtupletEDProducerT(const edm::ParameterSet& iConfig); | ||
~CAHitNtupletEDProducerT() = default; | ||
|
||
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); | ||
|
||
virtual void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override; | ||
|
||
private: | ||
edm::EDGetTokenT<IntermediateHitDoublets> doubletToken_; | ||
|
||
edm::RunningAverage localRA_; | ||
|
||
T_Generator generator_; | ||
}; | ||
|
||
template <typename T_Generator> | ||
CAHitNtupletEDProducerT<T_Generator>::CAHitNtupletEDProducerT(const edm::ParameterSet& iConfig): | ||
doubletToken_(consumes<IntermediateHitDoublets>(iConfig.getParameter<edm::InputTag>("doublets"))), | ||
generator_(iConfig, consumesCollector(), false) | ||
{ | ||
produces<RegionsSeedingHitSets>(); | ||
} | ||
|
||
template <typename T_Generator> | ||
void CAHitNtupletEDProducerT<T_Generator>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
edm::ParameterSetDescription desc; | ||
|
||
desc.add<edm::InputTag>("doublets", edm::InputTag("hitPairEDProducer")); | ||
T_Generator::fillDescriptions(desc); | ||
|
||
auto label = T_Generator::fillDescriptionsLabel() + std::string("EDProducer"); | ||
descriptions.add(label, desc); | ||
} | ||
|
||
template <typename T_Generator> | ||
void CAHitNtupletEDProducerT<T_Generator>::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { | ||
edm::Handle<IntermediateHitDoublets> hdoublets; | ||
iEvent.getByToken(doubletToken_, hdoublets); | ||
const auto& regionDoublets = *hdoublets; | ||
|
||
const SeedingLayerSetsHits& seedingLayerHits = regionDoublets.seedingLayerHits(); | ||
if(seedingLayerHits.numberOfLayersInSet() < T_Generator::minLayers) { | ||
throw cms::Exception("Configuration") << "CAHitNtupletEDProducer expects SeedingLayerSetsHits::numberOfLayersInSet() to be >= " << T_Generator::minLayers << ", got " << seedingLayerHits.numberOfLayersInSet(); | ||
} | ||
|
||
auto seedingHitSets = std::make_unique<RegionsSeedingHitSets>(); | ||
if(regionDoublets.empty()) { | ||
iEvent.put(std::move(seedingHitSets)); | ||
return; | ||
} | ||
seedingHitSets->reserve(regionDoublets.regionSize(), localRA_.upper()); | ||
generator_.initEvent(iEvent, iSetup); | ||
|
||
LogDebug("CAHitNtupletEDProducer") << "Creating ntuplets for " << regionDoublets.regionSize() << " regions, and " << regionDoublets.layerPairsSize() << " layer pairs"; | ||
|
||
typename T_Generator::ResultType ntuplets; | ||
ntuplets.reserve(localRA_.upper()); | ||
|
||
for(const auto& regionLayerPairs: regionDoublets) { | ||
const TrackingRegion& region = regionLayerPairs.region(); | ||
auto seedingHitSetsFiller = seedingHitSets->beginRegion(®ion); | ||
|
||
LogTrace("CAHitNtupletEDProducer") << " starting region"; | ||
|
||
generator_.hitNtuplets(regionLayerPairs, ntuplets, iSetup, seedingLayerHits); | ||
LogTrace("CAHitNtupletEDProducer") << " created " << ntuplets.size() << " ntuplets"; | ||
fillNtuplets(seedingHitSetsFiller, ntuplets); | ||
|
||
ntuplets.clear(); | ||
} | ||
localRA_.update(seedingHitSets->size()); | ||
|
||
iEvent.put(std::move(seedingHitSets)); | ||
} | ||
|
||
#include "FWCore/PluginManager/interface/ModuleDef.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
#include "CAHitQuadrupletGenerator.h" | ||
using CAHitQuadrupletEDProducer = CAHitNtupletEDProducerT<CAHitQuadrupletGenerator>; | ||
DEFINE_FWK_MODULE(CAHitQuadrupletEDProducer); | ||
|
||
#include "CAHitTripletGenerator.h" | ||
using CAHitTripletEDProducer = CAHitNtupletEDProducerT<CAHitTripletGenerator>; | ||
DEFINE_FWK_MODULE(CAHitTripletEDProducer); |
93 changes: 0 additions & 93 deletions
93
RecoPixelVertexing/PixelTriplets/plugins/CAHitQuadrupletEDProducer.cc
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.