Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-11 16:23:18

0001 #include "SeedGeneratorFromRegionHitsEDProducer.h"
0002 
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "FWCore/Framework/interface/ConsumesCollector.h"
0006 
0007 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
0008 
0009 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducerFactory.h"
0010 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducer.h"
0011 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
0012 
0013 #include "RecoTracker/TkTrackingRegions/interface/OrderedHitsGeneratorFactory.h"
0014 #include "RecoTracker/TkTrackingRegions/interface/OrderedHitsGenerator.h"
0015 
0016 #include "RecoTracker/TkSeedingLayers/interface/SeedComparitorFactory.h"
0017 #include "RecoTracker/TkSeedingLayers/interface/SeedComparitor.h"
0018 
0019 #include "RecoTracker/TkSeedGenerator/interface/SeedCreatorFactory.h"
0020 #include "RecoTracker/TkSeedGenerator/interface/SeedCreator.h"
0021 
0022 #include "RecoTracker/TkSeedGenerator/interface/SeedGeneratorFromRegionHits.h"
0023 
0024 SeedGeneratorFromRegionHitsEDProducer::SeedGeneratorFromRegionHitsEDProducer(const edm::ParameterSet& cfg)
0025     : theRegionProducer(nullptr),
0026       theClusterCheck(cfg.getParameter<edm::ParameterSet>("ClusterCheckPSet"), consumesCollector()) {
0027   theSilentOnClusterCheck =
0028       cfg.getParameter<edm::ParameterSet>("ClusterCheckPSet").getUntrackedParameter<bool>("silentClusterCheck", false);
0029 
0030   moduleName = cfg.getParameter<std::string>("@module_label");
0031 
0032   edm::ParameterSet creatorPSet = cfg.getParameter<edm::ParameterSet>("SeedCreatorPSet");
0033 
0034   edm::ParameterSet regfactoryPSet = cfg.getParameter<edm::ParameterSet>("RegionFactoryPSet");
0035   std::string regfactoryName = regfactoryPSet.getParameter<std::string>("ComponentName");
0036   theRegionProducer = TrackingRegionProducerFactory::get()->create(regfactoryName, regfactoryPSet, consumesCollector());
0037 
0038   edm::ConsumesCollector iC = consumesCollector();
0039   edm::ParameterSet hitsfactoryPSet = cfg.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet");
0040   std::string hitsfactoryName = hitsfactoryPSet.getParameter<std::string>("ComponentName");
0041 
0042   edm::ParameterSet comparitorPSet = cfg.getParameter<edm::ParameterSet>("SeedComparitorPSet");
0043   std::string comparitorName = comparitorPSet.getParameter<std::string>("ComponentName");
0044   std::unique_ptr<SeedComparitor> aComparitor;
0045   if (comparitorName != "none") {
0046     aComparitor = SeedComparitorFactory::get()->create(comparitorName, comparitorPSet, iC);
0047   }
0048 
0049   std::string creatorName = creatorPSet.getParameter<std::string>("ComponentName");
0050 
0051   theGenerator = std::make_unique<SeedGeneratorFromRegionHits>(
0052       OrderedHitsGeneratorFactory::get()->create(hitsfactoryName, hitsfactoryPSet, iC),
0053       std::move(aComparitor),
0054       SeedCreatorFactory::get()->create(creatorName, creatorPSet, consumesCollector()));
0055 
0056   produces<TrajectorySeedCollection>();
0057 }
0058 
0059 SeedGeneratorFromRegionHitsEDProducer::~SeedGeneratorFromRegionHitsEDProducer() {}
0060 
0061 void SeedGeneratorFromRegionHitsEDProducer::produce(edm::Event& ev, const edm::EventSetup& es) {
0062   auto triplets = std::make_unique<TrajectorySeedCollection>();
0063 
0064   //protection for big ass events...
0065   size_t clustsOrZero = theClusterCheck.tooManyClusters(ev);
0066   if (clustsOrZero) {
0067     if (!theSilentOnClusterCheck)
0068       edm::LogError("TooManyClusters") << "Found too many clusters (" << clustsOrZero << "), bailing out.\n";
0069     ev.put(std::move(triplets));
0070     return;
0071   }
0072 
0073   typedef std::vector<std::unique_ptr<TrackingRegion> > Regions;
0074   typedef Regions::const_iterator IR;
0075   Regions regions = theRegionProducer->regions(ev, es);
0076 
0077   for (IR ir = regions.begin(), irEnd = regions.end(); ir < irEnd; ++ir) {
0078     const TrackingRegion& region = **ir;
0079 
0080     // make job
0081     theGenerator->run(*triplets, region, ev, es);
0082     // std::cout << "created seeds for " << moduleName << " " << triplets->size() << std::endl;
0083   }
0084   triplets->shrink_to_fit();
0085 
0086   // put to event
0087   ev.put(std::move(triplets));
0088 }