CMS 3D CMS Logo

TrackAndECALLinker.cc
Go to the documentation of this file.
6 
8 public:
10  : BlockElementLinkerBase(conf),
11  useKDTree_(conf.getParameter<bool>("useKDTree")),
12  debug_(conf.getUntrackedParameter<bool>("debug", false)) {}
13 
14  bool linkPrefilter(const reco::PFBlockElement*, const reco::PFBlockElement*) const override;
15 
16  double testLink(const reco::PFBlockElement*, const reco::PFBlockElement*) const override;
17 
18 private:
19  const bool useKDTree_, debug_;
20 };
21 
23 
25  bool result = false;
26  switch (elem1->type()) {
28  result = (elem1->isMultilinksValide() && !elem1->getMultilinks().empty());
29  break;
31  result = (elem2->isMultilinksValide() && !elem2->getMultilinks().empty());
32  default:
33  break;
34  }
35  return (useKDTree_ ? result : true);
36 }
37 
40  const reco::PFBlockElementCluster* ecalelem(nullptr);
41  const reco::PFBlockElementTrack* tkelem(nullptr);
42  double dist(-1.0);
43  if (elem1->type() < elem2->type()) {
44  tkelem = static_cast<const reco::PFBlockElementTrack*>(elem1);
45  ecalelem = static_cast<const reco::PFBlockElementCluster*>(elem2);
46  } else {
47  tkelem = static_cast<const reco::PFBlockElementTrack*>(elem2);
48  ecalelem = static_cast<const reco::PFBlockElementCluster*>(elem1);
49  }
50  const reco::PFRecTrackRef& trackref = tkelem->trackRefPF();
51  const reco::PFClusterRef& clusterref = ecalelem->clusterRef();
52  const reco::PFCluster::REPPoint& ecalreppos = clusterref->positionREP();
53  const reco::PFTrajectoryPoint& tkAtECAL = trackref->extrapolatedPoint(ECALShowerMax);
54  const reco::PFCluster::REPPoint& tkreppos = tkAtECAL.positionREP();
55 
56  // Check if the linking has been done using the KDTree algo
57  // Glowinski & Gouzevitch
58  if (useKDTree_ && tkelem->isMultilinksValide()) { //KDTree Algo
59  const reco::PFMultilinksType& multilinks = tkelem->getMultilinks();
60  const double ecalphi = ecalreppos.Phi();
61  const double ecaleta = ecalreppos.Eta();
62 
63  // Check if the link Track/Ecal exist
64  reco::PFMultilinksType::const_iterator mlit = multilinks.begin();
65  for (; mlit != multilinks.end(); ++mlit)
66  if ((mlit->first == ecalphi) && (mlit->second == ecaleta))
67  break;
68 
69  // If the link exist, we fill dist and linktest.
70  if (mlit != multilinks.end()) {
71  dist = LinkByRecHit::computeDist(ecaleta, ecalphi, tkreppos.Eta(), tkreppos.Phi());
72  }
73 
74  } else { // Old algorithm
75  if (tkAtECAL.isValid())
76  dist = LinkByRecHit::testTrackAndClusterByRecHit(*trackref, *clusterref, false, debug_);
77  }
78 
79  if (debug_) {
80  if (dist > 0.) {
81  std::cout << " Here a link has been established"
82  << " between a track an Ecal with dist " << dist << std::endl;
83  } else
84  std::cout << " No link found " << std::endl;
85  }
86  return dist;
87 }
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
std::vector< std::pair< double, double > > PFMultilinksType
Abstract This class is used by the KDTree Track / Ecal Cluster linker to store all found links...
Abstract base class for a PFBlock element (track, cluster...)
static double computeDist(double eta1, double phi1, double eta2, double phi2, bool etaPhi=true)
computes a chisquare
const PFClusterRef & clusterRef() const override
Type type() const
double testLink(const reco::PFBlockElement *, const reco::PFBlockElement *) const override
bool linkPrefilter(const reco::PFBlockElement *, const reco::PFBlockElement *) const override
bool isValid() const
is this point valid ?
bool isMultilinksValide() const
const PFRecTrackRef & trackRefPF() const override
ROOT::Math::PositionVector3D< ROOT::Math::CylindricalEta3D< double > > REPPoint
Definition: PFCluster.h:52
#define DEFINE_EDM_PLUGIN(factory, type, name)
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
LayerType
Define the different layers where the track can be propagated.
static double testTrackAndClusterByRecHit(const reco::PFRecTrack &track, const reco::PFCluster &cluster, bool isBrem=false, bool debug=false)
Definition: LinkByRecHit.cc:16
TrackAndECALLinker(const edm::ParameterSet &conf)
#define constexpr
const PFMultilinksType & getMultilinks() const