Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-18 09:15:20

0001 #ifndef RecoParticleFlow_PFClusterProducer_PFRecHitNavigatorBase_h
0002 #define RecoParticleFlow_PFClusterProducer_PFRecHitNavigatorBase_h
0003 
0004 #include "FWCore/Framework/interface/Frameworkfwd.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/Framework/interface/EventSetup.h"
0008 #include "FWCore/Framework/interface/ESHandle.h"
0009 #include "FWCore/Framework/interface/ConsumesCollector.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include "DataFormats/ParticleFlowReco/interface/PFRecHit.h"
0012 #include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h"
0013 
0014 #include "DataFormats/ParticleFlowReco/interface/PFRecHit.h"
0015 #include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h"
0016 
0017 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0018 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0019 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0020 #include "Geometry/CaloGeometry/interface/TruncatedPyramid.h"
0021 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0022 
0023 #include <unordered_map>
0024 
0025 class PFRecHitNavigatorBase {
0026 public:
0027   typedef std::unordered_map<unsigned, unsigned> DetIdToHitIdx;
0028 
0029   PFRecHitNavigatorBase() = default;
0030   PFRecHitNavigatorBase(const edm::ParameterSet& iConfig, edm::ConsumesCollector& cc) {}
0031 
0032   virtual ~PFRecHitNavigatorBase() = default;
0033 
0034   virtual void init(const edm::EventSetup&) = 0;
0035   virtual void associateNeighbours(reco::PFRecHit&,
0036                                    std::unique_ptr<reco::PFRecHitCollection>&,
0037                                    edm::RefProd<reco::PFRecHitCollection>&) = 0;
0038 
0039 protected:
0040   void associateNeighbour(const DetId& id,
0041                           reco::PFRecHit& hit,
0042                           std::unique_ptr<reco::PFRecHitCollection>& hits,
0043                           edm::RefProd<reco::PFRecHitCollection>& refProd,
0044                           short eta,
0045                           short phi,
0046                           short depth) {
0047     auto found_hit = std::lower_bound(
0048         hits->begin(), hits->end(), id, [](const reco::PFRecHit& a, const DetId& id) { return a.detId() < id; });
0049     if (found_hit != hits->end() && found_hit->detId() == id.rawId()) {
0050       hit.addNeighbour(eta, phi, depth, found_hit - hits->begin());
0051     }
0052   }
0053 };
0054 
0055 #include "FWCore/PluginManager/interface/PluginFactory.h"
0056 typedef edmplugin::PluginFactory<PFRecHitNavigatorBase*(const edm::ParameterSet&, edm::ConsumesCollector&)>
0057     PFRecHitNavigationFactory;
0058 
0059 #endif