CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PreshowerAndECALLinker Class Reference
Inheritance diagram for PreshowerAndECALLinker:
BlockElementLinkerBase

Public Member Functions

bool linkPrefilter (const reco::PFBlockElement *, const reco::PFBlockElement *) const override
 
 PreshowerAndECALLinker (const edm::ParameterSet &conf)
 
double testLink (const reco::PFBlockElement *, const reco::PFBlockElement *) const override
 
- Public Member Functions inherited from BlockElementLinkerBase
 BlockElementLinkerBase (const BlockElementLinkerBase &)=delete
 
 BlockElementLinkerBase (const edm::ParameterSet &conf)
 
const std::string & name () const
 
BlockElementLinkerBaseoperator= (const BlockElementLinkerBase &)=delete
 
virtual ~BlockElementLinkerBase ()=default
 

Private Attributes

bool debug_
 
bool useKDTree_
 

Detailed Description

Definition at line 6 of file PreshowerAndECALLinker.cc.

Constructor & Destructor Documentation

◆ PreshowerAndECALLinker()

PreshowerAndECALLinker::PreshowerAndECALLinker ( const edm::ParameterSet conf)
inline

Definition at line 8 of file PreshowerAndECALLinker.cc.

10  useKDTree_(conf.getParameter<bool>("useKDTree")),
11  debug_(conf.getUntrackedParameter<bool>("debug", false)) {}

Member Function Documentation

◆ linkPrefilter()

bool PreshowerAndECALLinker::linkPrefilter ( const reco::PFBlockElement elem1,
const reco::PFBlockElement elem2 
) const
overridevirtual

Reimplemented from BlockElementLinkerBase.

Definition at line 23 of file PreshowerAndECALLinker.cc.

23  {
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 }

References reco::PFBlockElement::ECAL, relativeConstraints::empty, reco::PFBlockElement::getMultilinks(), reco::PFBlockElement::isMultilinksValide(), reco::PFBlockElement::PS1, reco::PFBlockElement::PS2, mps_fire::result, reco::PFBlockElement::type(), and useKDTree_.

◆ testLink()

double PreshowerAndECALLinker::testLink ( const reco::PFBlockElement elem1,
const reco::PFBlockElement elem2 
) const
overridevirtual

Implements BlockElementLinkerBase.

Definition at line 42 of file PreshowerAndECALLinker.cc.

42  {
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 math::XYZPoint& ecalxyzpos = ecalref->position();
62  const math::XYZPoint& psxyzpos = psref->position();
63 
64  // Check if the link PS/Ecal exist
65  reco::PFMultilinksType::const_iterator mlit = multilinks.begin();
66  for (; mlit != multilinks.end(); ++mlit)
67  if (mlit->clusterRef == ecalref)
68  break;
69 
70  // If the link exist, we fill dist and linktest.
71  if (mlit != multilinks.end()) {
73  ecalxyzpos.X() / 1000., ecalxyzpos.Y() / 1000., psxyzpos.X() / 1000., psxyzpos.Y() / 1000., false);
74  }
75  } else { //Old algorithm
76  dist = LinkByRecHit::testECALAndPSByRecHit(*ecalref, *psref, debug_);
77  }
78  return dist;
79 }

References reco::PFBlockElementCluster::clusterRef(), LinkByRecHit::computeDist(), debug_, Exception, edm::Ref< C, T, F >::isNull(), LinkByRecHit::testECALAndPSByRecHit(), reco::PFBlockElement::type(), and useKDTree_.

Member Data Documentation

◆ debug_

bool PreshowerAndECALLinker::debug_
private

Definition at line 18 of file PreshowerAndECALLinker.cc.

Referenced by testLink().

◆ useKDTree_

bool PreshowerAndECALLinker::useKDTree_
private

Definition at line 18 of file PreshowerAndECALLinker.cc.

Referenced by linkPrefilter(), and testLink().

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
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
LinkByRecHit::testECALAndPSByRecHit
static double testECALAndPSByRecHit(const reco::PFCluster &clusterECAL, const reco::PFCluster &clusterPS, bool debug=false)
Definition: LinkByRecHit.cc:363
edm::Ref< PFClusterCollection >
BlockElementLinkerBase::BlockElementLinkerBase
BlockElementLinkerBase(const edm::ParameterSet &conf)
Definition: BlockElementLinkerBase.h:12
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
reco::PFMultilinksType
std::vector< PFMultilink > PFMultilinksType
collection of PFSuperCluster objects
Definition: PFMultilinksTC.h:22
reco::PFBlockElement::ECAL
Definition: PFBlockElement.h:35
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
reco::PFBlockElementCluster
Cluster Element.
Definition: PFBlockElementCluster.h:16
Exception
Definition: hltDiff.cc:245
PreshowerAndECALLinker::debug_
bool debug_
Definition: PreshowerAndECALLinker.cc:18
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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::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
reco::PFBlockElement::PS2
Definition: PFBlockElement.h:34