Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:26:30

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/PFBlockElementGsfTrack.h"
0005 #include "RecoParticleFlow/PFClusterTools/interface/LinkByRecHit.h"
0006 
0007 class GSFAndHGCalLinker : public BlockElementLinkerBase {
0008 public:
0009   GSFAndHGCalLinker(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, GSFAndHGCalLinker, "GSFAndHGCalLinker");
0021 
0022 double GSFAndHGCalLinker::testLink(const reco::PFBlockElement* elem1, const reco::PFBlockElement* elem2) const {
0023   constexpr reco::PFTrajectoryPoint::LayerType ECALShowerMax = reco::PFTrajectoryPoint::ECALShowerMax;
0024   const reco::PFBlockElementCluster* hgcalelem(nullptr);
0025   const reco::PFBlockElementGsfTrack* gsfelem(nullptr);
0026   double dist(-1.0);
0027   if (elem1->type() > elem2->type()) {
0028     hgcalelem = static_cast<const reco::PFBlockElementCluster*>(elem1);
0029     gsfelem = static_cast<const reco::PFBlockElementGsfTrack*>(elem2);
0030   } else {
0031     hgcalelem = static_cast<const reco::PFBlockElementCluster*>(elem2);
0032     gsfelem = static_cast<const reco::PFBlockElementGsfTrack*>(elem1);
0033   }
0034   const reco::PFRecTrack& track = gsfelem->GsftrackPF();
0035   const reco::PFClusterRef& clusterref = hgcalelem->clusterRef();
0036   const reco::PFTrajectoryPoint& tkAtECAL = track.extrapolatedPoint(ECALShowerMax);
0037   if (tkAtECAL.isValid()) {
0038     dist = LinkByRecHit::computeDist(tkAtECAL.positionREP().eta(),
0039                                      tkAtECAL.positionREP().phi(),
0040                                      clusterref->positionREP().Eta(),
0041                                      clusterref->positionREP().Phi());
0042     if (dist > 0.3)
0043       dist = -1.0;
0044   }
0045   if (debug_) {
0046     if (dist > 0.) {
0047       std::cout << " Here a link has been established"
0048                 << " between a GSF track an HGCal with dist  " << dist << std::endl;
0049     } else {
0050       if (debug_)
0051         std::cout << " No link found " << std::endl;
0052     }
0053   }
0054 
0055   return dist;
0056 }