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  // Track-ECAL KDTree multilinks are stored to ecal's elem
27  switch (elem1->type()) {
29  result = (elem2->isMultilinksValide(elem1->type()) && !elem2->getMultilinks(elem1->type()).empty() &&
30  elem1->isMultilinksValide(elem2->type()));
31  break;
33  result = (elem1->isMultilinksValide(elem2->type()) && !elem1->getMultilinks(elem2->type()).empty() &&
34  elem2->isMultilinksValide(elem1->type()));
35  default:
36  break;
37  }
38  return (useKDTree_ ? result : true);
39 }
40 
43  const reco::PFBlockElementCluster* ecalelem(nullptr);
44  const reco::PFBlockElementTrack* tkelem(nullptr);
45  double dist(-1.0);
46  if (elem1->type() < elem2->type()) {
47  tkelem = static_cast<const reco::PFBlockElementTrack*>(elem1);
48  ecalelem = static_cast<const reco::PFBlockElementCluster*>(elem2);
49  } else {
50  tkelem = static_cast<const reco::PFBlockElementTrack*>(elem2);
51  ecalelem = static_cast<const reco::PFBlockElementCluster*>(elem1);
52  }
53  const reco::PFRecTrackRef& trackref = tkelem->trackRefPF();
54  const reco::PFClusterRef& clusterref = ecalelem->clusterRef();
55  const reco::PFCluster::REPPoint& ecalreppos = clusterref->positionREP();
56  const reco::PFTrajectoryPoint& tkAtECAL = trackref->extrapolatedPoint(ECALShowerMax);
57 
58  // Check if the linking has been done using the KDTree algo
59  // Glowinski & Gouzevitch
60  if (useKDTree_ && ecalelem->isMultilinksValide(tkelem->type())) { //KDTree Algo
61  const reco::PFMultilinksType& multilinks = ecalelem->getMultilinks(tkelem->type());
62  const double tracketa = tkAtECAL.positionREP().Eta();
63  const double trackphi = tkAtECAL.positionREP().Phi();
64 
65  // Check if the link Track/Ecal exist
66  reco::PFMultilinksType::const_iterator mlit = multilinks.begin();
67  for (; mlit != multilinks.end(); ++mlit)
68  if ((mlit->first == trackphi) && (mlit->second == tracketa))
69  break;
70 
71  // If the link exist, we fill dist and linktest.
72  if (mlit != multilinks.end()) {
73  dist = LinkByRecHit::computeDist(ecalreppos.Eta(), ecalreppos.Phi(), tracketa, trackphi);
74  }
75 
76  } else { // Old algorithm
77  if (tkAtECAL.isValid())
78  dist = LinkByRecHit::testTrackAndClusterByRecHit(*trackref, *clusterref, false, debug_);
79  }
80 
81  if (debug_) {
82  if (dist > 0.) {
83  std::cout << " Here a link has been established"
84  << " between a track an Ecal with dist " << dist << std::endl;
85  } else
86  std::cout << " No link found " << std::endl;
87  }
88  return dist;
89 }
electrons_cff.bool
bool
Definition: electrons_cff.py:393
funct::false
false
Definition: Factorize.h:29
reco::PFMultilinksType
std::vector< std::pair< double, double > > PFMultilinksType
Abstract This class is used by the KDTree Track / Ecal Cluster linker to store all found links.
Definition: PFMultilinksTC.h:13
PFBlockElementCluster.h
TrackAndECALLinker::testLink
double testLink(const reco::PFBlockElement *, const reco::PFBlockElement *) const override
Definition: TrackAndECALLinker.cc:41
TrackAndECALLinker::useKDTree_
const bool useKDTree_
Definition: TrackAndECALLinker.cc:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
LinkByRecHit::testTrackAndClusterByRecHit
static double testTrackAndClusterByRecHit(const reco::PFRecTrack &track, const reco::PFCluster &cluster, bool isBrem=false, bool debug=false)
Definition: LinkByRecHit.cc:18
reco::PFBlockElement::isMultilinksValide
bool isMultilinksValide(Type type) const
Definition: PFBlockElement.h:117
BlockElementLinkerBase
Definition: BlockElementLinkerBase.h:10
edm::Ref< PFRecTrackCollection >
reco::PFTrajectoryPoint::positionREP
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
Definition: PFTrajectoryPoint.h:103
TrackAndECALLinker
Definition: TrackAndECALLinker.cc:7
reco::PFBlockElementTrack::trackRefPF
const PFRecTrackRef & trackRefPF() const override
Definition: PFBlockElementTrack.h:46
reco::PFBlockElement::TRACK
Definition: PFBlockElement.h:32
reco::PFTrajectoryPoint::ECALShowerMax
Definition: PFTrajectoryPoint.h:46
PFCluster.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
edm::ParameterSet
Definition: ParameterSet.h:47
edmplugin::PluginFactory
Definition: PluginFactory.h:34
LinkByRecHit.h
reco::PFBlockElement::ECAL
Definition: PFBlockElement.h:35
TrackAndECALLinker::TrackAndECALLinker
TrackAndECALLinker(const edm::ParameterSet &conf)
Definition: TrackAndECALLinker.cc:9
reco::PFTrajectoryPoint::LayerType
LayerType
Define the different layers where the track can be propagated.
Definition: PFTrajectoryPoint.h:34
reco::PFTrajectoryPoint::isValid
bool isValid() const
is this point valid ?
Definition: PFTrajectoryPoint.h:84
reco::PFBlockElement
Abstract base class for a PFBlock element (track, cluster...)
Definition: PFBlockElement.h:26
reco::PFTrajectoryPoint
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
Definition: PFTrajectoryPoint.h:26
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
reco::PFBlockElementCluster
Cluster Element.
Definition: PFBlockElementCluster.h:16
reco::PFBlockElementTrack
Track Element.
Definition: PFBlockElementTrack.h:17
BlockElementLinkerBase.h
reco::PFBlockElementCluster::clusterRef
const PFClusterRef & clusterRef() const override
Definition: PFBlockElementCluster.h:29
reco::PFBlockElement::type
Type type() const
Definition: PFBlockElement.h:69
mps_fire.result
result
Definition: mps_fire.py:311
reco::PFCluster::REPPoint
ROOT::Math::PositionVector3D< ROOT::Math::CylindricalEta3D< double > > REPPoint
Definition: PFCluster.h:48
TrackAndECALLinker::linkPrefilter
bool linkPrefilter(const reco::PFBlockElement *, const reco::PFBlockElement *) const override
Definition: TrackAndECALLinker.cc:24
reco::PFBlockElement::getMultilinks
const PFMultilinksType & getMultilinks(Type type) const
Definition: PFBlockElement.h:124
LinkByRecHit::computeDist
static double computeDist(double eta1, double phi1, double eta2, double phi2, bool etaPhi=true)
computes a chisquare
Definition: LinkByRecHit.cc:519
PFBlockElementTrack.h
TrackAndECALLinker::debug_
const bool debug_
Definition: TrackAndECALLinker.cc:19