CMS 3D CMS Logo

PreshowerAndECALLinker.cc
Go to the documentation of this file.
5 
7 public:
10  useKDTree_(conf.getParameter<bool>("useKDTree")),
11  debug_(conf.getUntrackedParameter<bool>("debug", false)) {}
12 
13  bool linkPrefilter(const reco::PFBlockElement*, const reco::PFBlockElement*) const override;
14 
15  double testLink(const reco::PFBlockElement*, const reco::PFBlockElement*) const override;
16 
17 private:
19 };
20 
22 
24  bool result = false;
25  // PS-ECAL KDTree multilinks are stored to PS's elem
26  switch (elem1->type()) {
29  result = (elem1->isMultilinksValide(elem2->type()) && !elem1->getMultilinks(elem2->type()).empty() &&
30  elem2->isMultilinksValide(elem1->type()));
31  break;
33  result = (elem2->isMultilinksValide(elem1->type()) && !elem2->getMultilinks(elem1->type()).empty() &&
34  elem1->isMultilinksValide(elem2->type()));
35  break;
36  default:
37  break;
38  }
39  return (useKDTree_ ? result : true);
40 }
41 
43  const reco::PFBlockElementCluster *pselem(nullptr), *ecalelem(nullptr);
44  double dist(-1.0);
45  if (elem1->type() < elem2->type()) {
46  pselem = static_cast<const reco::PFBlockElementCluster*>(elem1);
47  ecalelem = static_cast<const reco::PFBlockElementCluster*>(elem2);
48  } else {
49  pselem = static_cast<const reco::PFBlockElementCluster*>(elem2);
50  ecalelem = static_cast<const reco::PFBlockElementCluster*>(elem1);
51  }
52  const reco::PFClusterRef& psref = pselem->clusterRef();
53  const reco::PFClusterRef& ecalref = ecalelem->clusterRef();
54  if (psref.isNull() || ecalref.isNull()) {
55  throw cms::Exception("BadClusterRefs") << "PFBlockElementCluster's refs are null!";
56  }
57  // Check if the linking has been done using the KDTree algo
58  // Glowinski & Gouzevitch
59  if (useKDTree_ && pselem->isMultilinksValide(ecalelem->type())) { // KDTree algo
60  const reco::PFMultilinksType& multilinks = pselem->getMultilinks(ecalelem->type());
61  const reco::PFCluster::REPPoint& ecalreppos = ecalref->positionREP();
62  const math::XYZPoint& ecalxyzpos = ecalref->position();
63  const math::XYZPoint& psxyzpos = psref->position();
64  const double ecalPhi = ecalreppos.Phi();
65  const double ecalEta = ecalreppos.Eta();
66 
67  // Check if the link PS/Ecal exist
68  reco::PFMultilinksType::const_iterator mlit = multilinks.begin();
69  for (; mlit != multilinks.end(); ++mlit)
70  if ((mlit->first == ecalPhi) && (mlit->second == ecalEta))
71  break;
72 
73  // If the link exist, we fill dist and linktest.
74  if (mlit != multilinks.end()) {
76  ecalxyzpos.X() / 1000., ecalxyzpos.Y() / 1000., psxyzpos.X() / 1000., psxyzpos.Y() / 1000., false);
77  }
78  } else { //Old algorithm
79  dist = LinkByRecHit::testECALAndPSByRecHit(*ecalref, *psref, debug_);
80  }
81  return dist;
82 }
electrons_cff.bool
bool
Definition: electrons_cff.py:393
egammaTools::ecalEta
double ecalEta(const math::XYZVector &momentum, const math::XYZPoint &vertex)
Definition: ECALPositionCalculator.cc:71
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
edm::Ref::isNull
bool isNull() const
Checks for null.
Definition: Ref.h:235
PreshowerAndECALLinker::useKDTree_
bool useKDTree_
Definition: PreshowerAndECALLinker.cc:18
reco::PFBlockElement::isMultilinksValide
bool isMultilinksValide(Type type) const
Definition: PFBlockElement.h:117
LinkByRecHit::testECALAndPSByRecHit
static double testECALAndPSByRecHit(const reco::PFCluster &clusterECAL, const reco::PFCluster &clusterPS, bool debug=false)
Definition: LinkByRecHit.cc:363
egammaTools::ecalPhi
double ecalPhi(const MagneticField &magField, const math::XYZVector &momentum, const math::XYZPoint &vertex, const int charge)
Definition: ECALPositionCalculator.cc:16
BlockElementLinkerBase
Definition: BlockElementLinkerBase.h:10
edm::Ref< PFClusterCollection >
PFCluster.h
PreshowerAndECALLinker::testLink
double testLink(const reco::PFBlockElement *, const reco::PFBlockElement *) const override
Definition: PreshowerAndECALLinker.cc:42
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
edm::ParameterSet
Definition: ParameterSet.h:47
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edmplugin::PluginFactory
Definition: PluginFactory.h:34
PreshowerAndECALLinker::PreshowerAndECALLinker
PreshowerAndECALLinker(const edm::ParameterSet &conf)
Definition: PreshowerAndECALLinker.cc:8
LinkByRecHit.h
reco::PFBlockElement::ECAL
Definition: PFBlockElement.h:35
PreshowerAndECALLinker
Definition: PreshowerAndECALLinker.cc:6
reco::PFBlockElement
Abstract base class for a PFBlock element (track, cluster...)
Definition: PFBlockElement.h:26
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
reco::PFBlockElementCluster
Cluster Element.
Definition: PFBlockElementCluster.h:16
Exception
Definition: hltDiff.cc:246
PreshowerAndECALLinker::debug_
bool debug_
Definition: PreshowerAndECALLinker.cc:18
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::PFBlockElement::PS1
Definition: PFBlockElement.h:33
reco::PFCluster::REPPoint
ROOT::Math::PositionVector3D< ROOT::Math::CylindricalEta3D< double > > REPPoint
Definition: PFCluster.h:48
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
PreshowerAndECALLinker::linkPrefilter
bool linkPrefilter(const reco::PFBlockElement *, const reco::PFBlockElement *) const override
Definition: PreshowerAndECALLinker.cc:23
reco::PFBlockElement::PS2
Definition: PFBlockElement.h:34