Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:55

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