Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "RecoParticleFlow/PFProducer/interface/BlockElementLinkerBase.h"
0002 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
0003 #include "DataFormats/ParticleFlowReco/interface/PFBlockElementCluster.h"
0004 #include "DataFormats/ParticleFlowReco/interface/PFBlockElementTrack.h"
0005 #include "RecoParticleFlow/PFClusterTools/interface/LinkByRecHit.h"
0006 
0007 class TrackAndHOLinker : public BlockElementLinkerBase {
0008 public:
0009   TrackAndHOLinker(const edm::ParameterSet& conf)
0010       : BlockElementLinkerBase(conf),
0011         useKDTree_(conf.getParameter<bool>("useKDTree")),
0012         debug_(conf.getUntrackedParameter<bool>("debug", false)) {}
0013 
0014   double testLink(const reco::PFBlockElement*, const reco::PFBlockElement*) const override;
0015 
0016 private:
0017   bool useKDTree_, debug_;
0018 };
0019 
0020 DEFINE_EDM_PLUGIN(BlockElementLinkerFactory, TrackAndHOLinker, "TrackAndHOLinker");
0021 
0022 double TrackAndHOLinker::testLink(const reco::PFBlockElement* elem1, const reco::PFBlockElement* elem2) const {
0023   constexpr reco::PFTrajectoryPoint::LayerType HOLayer = reco::PFTrajectoryPoint::HOLayer;
0024   const reco::PFBlockElementTrack* tkelem(nullptr);
0025   const reco::PFBlockElementCluster* hoelem(nullptr);
0026   double dist(-1.0);
0027   if (elem1->type() < elem2->type()) {
0028     tkelem = static_cast<const reco::PFBlockElementTrack*>(elem1);
0029     hoelem = static_cast<const reco::PFBlockElementCluster*>(elem2);
0030   } else {
0031     tkelem = static_cast<const reco::PFBlockElementTrack*>(elem2);
0032     hoelem = static_cast<const reco::PFBlockElementCluster*>(elem1);
0033   }
0034   const reco::PFClusterRef& horef = hoelem->clusterRef();
0035   const reco::PFRecTrackRef& tkref = tkelem->trackRefPF();
0036   if (horef.isNull() || tkref.isNull()) {
0037     throw cms::Exception("BadClusterRefs") << "PFBlockElementCluster's refs are null!";
0038   }
0039   if (tkelem->trackRef()->pt() > 3.00001 && tkref->extrapolatedPoint(HOLayer).isValid()) {
0040     dist = LinkByRecHit::testTrackAndClusterByRecHit(*tkref, *horef, false, debug_);
0041   } else {
0042     dist = -1.;
0043   }
0044   return dist;
0045 }