Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:24:34

0001 #ifndef __RecoLocalCalo_HGCRecProducers_HGCalMultiClusterProducer_H__
0002 #define __RecoLocalCalo_HGCRecProducers_HGCalMultiClusterProducer_H__
0003 
0004 // user include files
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 #include "FWCore/Framework/interface/stream/EDProducer.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 
0009 #include "FWCore/Framework/interface/Event.h"
0010 #include "FWCore/Framework/interface/MakerMacros.h"
0011 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0012 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0013 #include "RecoParticleFlow/PFClusterProducer/interface/RecHitTopologicalCleanerBase.h"
0014 #include "RecoParticleFlow/PFClusterProducer/interface/SeedFinderBase.h"
0015 #include "RecoParticleFlow/PFClusterProducer/interface/InitialClusteringStepBase.h"
0016 #include "RecoParticleFlow/PFClusterProducer/interface/PFClusterBuilderBase.h"
0017 #include "RecoParticleFlow/PFClusterProducer/interface/PFCPositionCalculatorBase.h"
0018 #include "RecoParticleFlow/PFClusterProducer/interface/PFClusterEnergyCorrectorBase.h"
0019 
0020 #include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalDepthPreClusterer.h"
0021 #include "RecoLocalCalo/HGCalRecAlgos/interface/HGCal3DClustering.h"
0022 #include "RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h"
0023 
0024 #include "FWCore/Framework/interface/ESHandle.h"
0025 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0026 #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
0027 
0028 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
0029 
0030 class HGCalMultiClusterProducer : public edm::stream::EDProducer<> {
0031 public:
0032   HGCalMultiClusterProducer(const edm::ParameterSet&);
0033   ~HGCalMultiClusterProducer() override {}
0034   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0035 
0036   void produce(edm::Event&, const edm::EventSetup&) override;
0037 
0038 private:
0039   edm::EDGetTokenT<HGCRecHitCollection> hits_fh_token;
0040   edm::EDGetTokenT<HGCRecHitCollection> hits_ee_token;
0041   edm::EDGetTokenT<HGCRecHitCollection> hits_bh_token;
0042   edm::EDGetTokenT<std::vector<reco::BasicCluster>> clusters_token;
0043   edm::EDGetTokenT<std::vector<reco::BasicCluster>> clusters_sharing_token;
0044   std::unique_ptr<HGCal3DClustering> multicluster_algo;
0045   bool doSharing;
0046   HGCalClusteringAlgoBase::VerbosityLevel verbosity;
0047 };
0048 
0049 DEFINE_FWK_MODULE(HGCalMultiClusterProducer);
0050 
0051 HGCalMultiClusterProducer::HGCalMultiClusterProducer(const edm::ParameterSet& ps)
0052     : doSharing(ps.getParameter<bool>("doSharing")),
0053       verbosity((HGCalClusteringAlgoBase::VerbosityLevel)ps.getUntrackedParameter<unsigned int>("verbosity", 3)) {
0054   std::vector<double> multicluster_radii = ps.getParameter<std::vector<double>>("multiclusterRadii");
0055   double minClusters = ps.getParameter<unsigned>("minClusters");
0056   clusters_token = consumes<std::vector<reco::BasicCluster>>(ps.getParameter<edm::InputTag>("HGCLayerClusters"));
0057   clusters_sharing_token =
0058       consumes<std::vector<reco::BasicCluster>>(ps.getParameter<edm::InputTag>("HGCLayerClustersSharing"));
0059   hits_ee_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCEEInput"));
0060   hits_fh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCFHInput"));
0061   hits_bh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCBHInput"));
0062   auto sumes = consumesCollector();
0063 
0064   multicluster_algo = std::make_unique<HGCal3DClustering>(ps, sumes, multicluster_radii, minClusters);
0065 
0066   produces<std::vector<reco::HGCalMultiCluster>>();
0067   produces<std::vector<reco::HGCalMultiCluster>>("sharing");
0068 }
0069 
0070 void HGCalMultiClusterProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0071   // hgcalMultiClusters
0072   edm::ParameterSetDescription desc;
0073   desc.add<edm::InputTag>("HGCLayerClusters", edm::InputTag("hgcalLayerClusters"));
0074   desc.addUntracked<unsigned int>("verbosity", 3);
0075   desc.add<bool>("doSharing", false);
0076   desc.add<edm::InputTag>("HGCEEInput", edm::InputTag("HGCalRecHit", "HGCEERecHits"));
0077   desc.add<edm::InputTag>("HGCFHInput", edm::InputTag("HGCalRecHit", "HGCHEFRecHits"));
0078   desc.add<std::vector<double>>("multiclusterRadii",
0079                                 {
0080                                     2.0,
0081                                     5.0,
0082                                     5.0,
0083                                 });
0084   desc.add<edm::InputTag>("HGCBHInput", edm::InputTag("HGCalRecHit", "HGCHEBRecHits"));
0085   desc.add<edm::InputTag>("HGCLayerClustersSharing", edm::InputTag("hgcalLayerClusters", "sharing"));
0086   desc.add<unsigned int>("minClusters", 3);
0087   descriptions.add("hgcalMultiClusters", desc);
0088 }
0089 
0090 void HGCalMultiClusterProducer::produce(edm::Event& evt, const edm::EventSetup& es) {
0091   edm::Handle<std::vector<reco::BasicCluster>> clusterHandle;
0092   edm::Handle<std::vector<reco::BasicCluster>> clusterSharingHandle;
0093 
0094   evt.getByToken(clusters_token, clusterHandle);
0095   if (doSharing)
0096     evt.getByToken(clusters_sharing_token, clusterSharingHandle);
0097 
0098   edm::PtrVector<reco::BasicCluster> clusterPtrs, clusterPtrsSharing;
0099   for (unsigned i = 0; i < clusterHandle->size(); ++i) {
0100     edm::Ptr<reco::BasicCluster> ptr(clusterHandle, i);
0101     clusterPtrs.push_back(ptr);
0102   }
0103 
0104   if (doSharing) {
0105     for (unsigned i = 0; i < clusterSharingHandle->size(); ++i) {
0106       edm::Ptr<reco::BasicCluster> ptr(clusterSharingHandle, i);
0107       clusterPtrsSharing.push_back(ptr);
0108     }
0109   }
0110 
0111   auto multiclusters = std::make_unique<std::vector<reco::HGCalMultiCluster>>();
0112   auto multiclusters_sharing = std::make_unique<std::vector<reco::HGCalMultiCluster>>();
0113 
0114   multicluster_algo->getEvent(evt);
0115   multicluster_algo->getEventSetup(es);
0116 
0117   *multiclusters = multicluster_algo->makeClusters(clusterPtrs);
0118   if (doSharing)
0119     *multiclusters_sharing = multicluster_algo->makeClusters(clusterPtrsSharing);
0120   evt.put(std::move(multiclusters));
0121   if (doSharing)
0122     evt.put(std::move(multiclusters_sharing), "sharing");
0123 }
0124 
0125 #endif