Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:28

0001 #include "RecoParticleFlow/PFProducer/interface/BlockElementLinkerBase.h"
0002 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
0003 #include "DataFormats/ParticleFlowReco/interface/PFBlockElementCluster.h"
0004 #include "RecoParticleFlow/PFClusterTools/interface/LinkByRecHit.h"
0005 
0006 class HCALAndHOLinker : public BlockElementLinkerBase {
0007 public:
0008   HCALAndHOLinker(const edm::ParameterSet& conf)
0009       : BlockElementLinkerBase(conf),
0010         useKDTree_(conf.getParameter<bool>("useKDTree")),
0011         debug_(conf.getUntrackedParameter<bool>("debug", false)) {}
0012 
0013   double testLink(const reco::PFBlockElement*, const reco::PFBlockElement*) const override;
0014 
0015 private:
0016   bool useKDTree_, debug_;
0017 };
0018 
0019 DEFINE_EDM_PLUGIN(BlockElementLinkerFactory, HCALAndHOLinker, "HCALAndHOLinker");
0020 
0021 double HCALAndHOLinker::testLink(const reco::PFBlockElement* elem1, const reco::PFBlockElement* elem2) const {
0022   const reco::PFBlockElementCluster *hcalelem(nullptr), *hoelem(nullptr);
0023   double dist(-1.0);
0024   if (elem1->type() < elem2->type()) {
0025     hcalelem = static_cast<const reco::PFBlockElementCluster*>(elem1);
0026     hoelem = static_cast<const reco::PFBlockElementCluster*>(elem2);
0027   } else {
0028     hcalelem = static_cast<const reco::PFBlockElementCluster*>(elem2);
0029     hoelem = static_cast<const reco::PFBlockElementCluster*>(elem1);
0030   }
0031   const reco::PFClusterRef& hcalref = hcalelem->clusterRef();
0032   const reco::PFClusterRef& horef = hoelem->clusterRef();
0033   const reco::PFCluster::REPPoint& hcalreppos = hcalref->positionREP();
0034   if (hcalref.isNull() || horef.isNull()) {
0035     throw cms::Exception("BadClusterRefs") << "PFBlockElementCluster's refs are null!";
0036   }
0037   dist = (std::abs(hcalreppos.Eta()) < 1.5
0038               ? LinkByRecHit::computeDist(
0039                     hcalreppos.Eta(), hcalreppos.Phi(), horef->positionREP().Eta(), horef->positionREP().Phi())
0040               : -1.0);
0041   return (dist < 0.2 ? dist : -1.0);
0042 }