File indexing completed on 2024-04-06 12:28:57
0001 #include "FWCore/Framework/interface/stream/EDProducer.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Framework/interface/MakerMacros.h"
0004 #include "FWCore/Framework/interface/ConsumesCollector.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006
0007 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
0008 #include "DataFormats/Common/interface/OwnVector.h"
0009
0010 #include "TrackingTools/TransientTrackingRecHit/interface/SeedingLayerSetsHits.h"
0011 #include "RecoTracker/TkSeedingLayers/interface/SeedingLayerSetsBuilder.h"
0012
0013 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionsSeedingLayerSets.h"
0014
0015 #include "VertexBeamspotOrigins.h"
0016 #include "AreaSeededTrackingRegionsBuilder.h"
0017 #include "PixelInactiveAreaFinder.h"
0018
0019 #include <vector>
0020 #include <utility>
0021 #include <memory>
0022
0023 class PixelInactiveAreaTrackingRegionsSeedingLayersProducer : public edm::stream::EDProducer<> {
0024 public:
0025 PixelInactiveAreaTrackingRegionsSeedingLayersProducer(const edm::ParameterSet& iConfig);
0026 ~PixelInactiveAreaTrackingRegionsSeedingLayersProducer() override = default;
0027
0028 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0029
0030 void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
0031
0032 private:
0033 SeedingLayerSetsBuilder seedingLayerSetsBuilder_;
0034 VertexBeamspotOrigins origins_;
0035 PixelInactiveAreaFinder inactiveAreaFinder_;
0036 AreaSeededTrackingRegionsBuilder trackingRegionsBuilder_;
0037 };
0038
0039 PixelInactiveAreaTrackingRegionsSeedingLayersProducer::PixelInactiveAreaTrackingRegionsSeedingLayersProducer(
0040 const edm::ParameterSet& iConfig)
0041 : seedingLayerSetsBuilder_(iConfig, consumesCollector()),
0042 origins_(iConfig.getParameter<edm::ParameterSet>("RegionPSet"), consumesCollector()),
0043 inactiveAreaFinder_(iConfig,
0044 seedingLayerSetsBuilder_.layers(),
0045 seedingLayerSetsBuilder_.seedingLayerSetsLooper(),
0046 consumesCollector()),
0047 trackingRegionsBuilder_(iConfig.getParameter<edm::ParameterSet>("RegionPSet"), consumesCollector()) {
0048 produces<SeedingLayerSetsHits>();
0049 produces<TrackingRegionsSeedingLayerSets>();
0050 }
0051
0052 void PixelInactiveAreaTrackingRegionsSeedingLayersProducer::fillDescriptions(
0053 edm::ConfigurationDescriptions& descriptions) {
0054 edm::ParameterSetDescription desc;
0055
0056 edm::ParameterSetDescription descRegion;
0057 VertexBeamspotOrigins::fillDescriptions(descRegion);
0058 AreaSeededTrackingRegionsBuilder::fillDescriptions(descRegion);
0059 desc.add<edm::ParameterSetDescription>("RegionPSet", descRegion);
0060
0061 PixelInactiveAreaFinder::fillDescriptions(desc);
0062 SeedingLayerSetsBuilder::fillDescriptions(desc);
0063
0064 descriptions.add("pixelInactiveAreaTrackingRegionsAndSeedingLayers", desc);
0065 }
0066
0067 void PixelInactiveAreaTrackingRegionsSeedingLayersProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0068 auto orphanHandle = iEvent.put(seedingLayerSetsBuilder_.hits(iEvent, iSetup));
0069 const SeedingLayerSetsHits* seedingLayers = orphanHandle.product();
0070
0071 auto regions = std::make_unique<TrackingRegionsSeedingLayerSets>(seedingLayers);
0072
0073 const auto origins = origins_.origins(iEvent);
0074 const auto builder = trackingRegionsBuilder_.beginEvent(iEvent, iSetup);
0075
0076 const auto allAreas = inactiveAreaFinder_.inactiveAreas(iEvent, iSetup);
0077 for (const auto& origin : origins) {
0078 auto areasLayerSets = allAreas.areasAndLayerSets(origin.first, origin.second);
0079 LogTrace("PixelInactiveAreaTrackingRegionsSeedingLayersProducer")
0080 << "Origin " << origin.first.x() << "," << origin.first.y() << "," << origin.first.z() << " z half lengh "
0081 << origin.second;
0082 for (auto& areasLayerSet : areasLayerSets) {
0083 auto region = builder.region(origin, areasLayerSet.first);
0084 if (!region)
0085 continue;
0086 #ifdef EDM_ML_DEBUG
0087 auto etaPhiRegion = dynamic_cast<const RectangularEtaPhiTrackingRegion*>(region.get());
0088 std::stringstream ss;
0089 for (const auto& ind : areasLayerSet.second) {
0090 ss << ind << ",";
0091 }
0092 LogTrace("PixelInactiveAreaTrackingRegionsSeedingLayersProducer")
0093 << " region eta,phi " << region->direction().eta() << "," << region->direction().phi() << " eta range "
0094 << etaPhiRegion->etaRange().min() << "," << etaPhiRegion->etaRange().max() << " phi range "
0095 << (region->direction().phi() - etaPhiRegion->phiMargin().left()) << ","
0096 << (region->direction().phi() + etaPhiRegion->phiMargin().right()) << " layer sets " << ss.str();
0097 #endif
0098
0099 regions->emplace_back(std::move(region), std::move(areasLayerSet.second));
0100 }
0101 }
0102
0103 iEvent.put(std::move(regions));
0104 }
0105
0106 DEFINE_FWK_MODULE(PixelInactiveAreaTrackingRegionsSeedingLayersProducer);