Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-01 22:40:57

0001 #include "CombinedHitTripletGenerator.h"
0002 
0003 #include "RecoTracker/TkHitPairs/interface/HitPairGeneratorFromLayerPair.h"
0004 #include "RecoPixelVertexing/PixelTriplets/interface/HitTripletGeneratorFromPairAndLayers.h"
0005 #include "RecoPixelVertexing/PixelTriplets/interface/HitTripletGeneratorFromPairAndLayersFactory.h"
0006 #include "RecoPixelVertexing/PixelTriplets/interface/LayerTriplets.h"
0007 #include "FWCore/Framework/interface/ConsumesCollector.h"
0008 #include "FWCore/Framework/interface/Event.h"
0009 #include "DataFormats/Common/interface/Handle.h"
0010 
0011 CombinedHitTripletGenerator::CombinedHitTripletGenerator(const edm::ParameterSet& cfg, edm::ConsumesCollector& iC)
0012     : theSeedingLayerToken(iC.consumes<SeedingLayerSetsHits>(cfg.getParameter<edm::InputTag>("SeedingLayers"))) {
0013   edm::ParameterSet generatorPSet = cfg.getParameter<edm::ParameterSet>("GeneratorPSet");
0014   std::string generatorName = generatorPSet.getParameter<std::string>("ComponentName");
0015   theGenerator = HitTripletGeneratorFromPairAndLayersFactory::get()->create(generatorName, generatorPSet, iC);
0016   theGenerator->init(std::make_unique<HitPairGeneratorFromLayerPair>(iC, 0, 1, &theLayerCache), &theLayerCache);
0017 }
0018 
0019 CombinedHitTripletGenerator::~CombinedHitTripletGenerator() {}
0020 
0021 void CombinedHitTripletGenerator::hitTriplets(const TrackingRegion& region,
0022                                               OrderedHitTriplets& result,
0023                                               const edm::Event& ev,
0024                                               const edm::EventSetup& es) {
0025   edm::Handle<SeedingLayerSetsHits> hlayers;
0026   ev.getByToken(theSeedingLayerToken, hlayers);
0027   const SeedingLayerSetsHits& layers = *hlayers;
0028   if (layers.numberOfLayersInSet() != 3)
0029     throw cms::Exception("Configuration")
0030         << "CombinedHitTripletGenerator expects SeedingLayerSetsHits::numberOfLayersInSet() to be 3, got "
0031         << layers.numberOfLayersInSet();
0032 
0033   std::vector<LayerTriplets::LayerSetAndLayers> trilayers = LayerTriplets::layers(layers);
0034   for (const auto& setAndLayers : trilayers) {
0035     theGenerator->hitTriplets(region, result, ev, es, setAndLayers.first, setAndLayers.second);
0036   }
0037   theLayerCache.clear();
0038 }