Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-01 22:41:00

0001 #include "CombinedHitPairGeneratorForPhotonConversion.h"
0002 
0003 #include <memory>
0004 
0005 #include "DataFormats/Common/interface/Handle.h"
0006 #include "FWCore/Framework/interface/ConsumesCollector.h"
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "HitPairGeneratorFromLayerPairForPhotonConversion.h"
0009 
0010 #include "FWCore/Utilities/interface/RunningAverage.h"
0011 namespace {
0012   edm::RunningAverage localRA;
0013 }
0014 
0015 CombinedHitPairGeneratorForPhotonConversion::CombinedHitPairGeneratorForPhotonConversion(const edm::ParameterSet& cfg,
0016                                                                                          edm::ConsumesCollector& iC)
0017     : theSeedingLayerToken(iC.consumes<SeedingLayerSetsHits>(cfg.getParameter<edm::InputTag>("SeedingLayers"))) {
0018   theMaxElement = cfg.getParameter<unsigned int>("maxElement");
0019   maxHitPairsPerTrackAndGenerator = cfg.getParameter<unsigned int>("maxHitPairsPerTrackAndGenerator");
0020   theGenerator = std::make_unique<HitPairGeneratorFromLayerPairForPhotonConversion>(
0021       iC, 0, 1, &theLayerCache, 0, maxHitPairsPerTrackAndGenerator);
0022 }
0023 
0024 const OrderedHitPairs& CombinedHitPairGeneratorForPhotonConversion::run(const ConversionRegion& convRegion,
0025                                                                         const TrackingRegion& region,
0026                                                                         const edm::Event& ev,
0027                                                                         const edm::EventSetup& es) {
0028   if (thePairs.capacity() == 0)
0029     thePairs.reserve(localRA.upper());
0030   thePairs.clear();
0031   hitPairs(convRegion, region, thePairs, ev, es);
0032   return thePairs;
0033 }
0034 
0035 void CombinedHitPairGeneratorForPhotonConversion::hitPairs(const ConversionRegion& convRegion,
0036                                                            const TrackingRegion& region,
0037                                                            OrderedHitPairs& result,
0038                                                            const edm::Event& ev,
0039                                                            const edm::EventSetup& es) {
0040   edm::Handle<SeedingLayerSetsHits> hlayers;
0041   ev.getByToken(theSeedingLayerToken, hlayers);
0042   const SeedingLayerSetsHits& layers = *hlayers;
0043   assert(layers.numberOfLayersInSet() == 2);
0044 
0045   for (SeedingLayerSetsHits::LayerSetIndex i = 0; i < layers.size(); ++i) {
0046     theGenerator->hitPairs(convRegion, region, result, layers[i], ev, es);
0047   }
0048 }
0049 
0050 void CombinedHitPairGeneratorForPhotonConversion::clearCache() {
0051   theLayerCache.clear();
0052   localRA.update(thePairs.size());
0053   thePairs.clear();
0054   thePairs.shrink_to_fit();
0055 }