CMS 3D CMS Logo

TrackAndHCALLinker.cc
Go to the documentation of this file.
9 
11 public:
13  : BlockElementLinkerBase(conf),
14  useKDTree_(conf.getParameter<bool>("useKDTree")),
15  trajectoryLayerEntranceString_(conf.getParameter<std::string>("trajectoryLayerEntrance")),
16  trajectoryLayerExitString_(conf.getParameter<std::string>("trajectoryLayerExit")),
17  debug_(conf.getUntrackedParameter<bool>("debug", false)) {
18  // convert TrajectoryLayers info from string to enum
21  // make sure the requested setting is supported
28  // flag if exit layer should be checked or not
30  }
31 
32  bool linkPrefilter(const reco::PFBlockElement*, const reco::PFBlockElement*) const override;
33 
34  double testLink(const reco::PFBlockElement*, const reco::PFBlockElement*) const override;
35 
36 private:
37  bool useKDTree_;
42  bool debug_;
43  bool checkExit_;
44 };
45 
47 
49  bool result = false;
50  // Track-HCAL KDTree multilinks are stored to HCAL's elem
51  switch (elem1->type()) {
53  result = (elem2->isMultilinksValide() && !elem2->getMultilinks().empty());
54  break;
56  result = (elem1->isMultilinksValide() && !elem1->getMultilinks().empty());
57  default:
58  break;
59  }
60  return (useKDTree_ ? result : true);
61 }
62 
64  const reco::PFBlockElementCluster* hcalelem(nullptr);
65  const reco::PFBlockElementTrack* tkelem(nullptr);
66  double dist(-1.0);
67  if (elem1->type() < elem2->type()) {
68  tkelem = static_cast<const reco::PFBlockElementTrack*>(elem1);
69  hcalelem = static_cast<const reco::PFBlockElementCluster*>(elem2);
70  } else {
71  tkelem = static_cast<const reco::PFBlockElementTrack*>(elem2);
72  hcalelem = static_cast<const reco::PFBlockElementCluster*>(elem1);
73  }
74  const reco::PFRecTrackRef& trackref = tkelem->trackRefPF();
75  const reco::PFClusterRef& clusterref = hcalelem->clusterRef();
76  const reco::PFCluster::REPPoint& hcalreppos = clusterref->positionREP();
77  const reco::PFTrajectoryPoint& tkAtHCALEnt = trackref->extrapolatedPoint(trajectoryLayerEntrance_);
78  // Check exit point
79  double dHEta = 0.;
80  double dHPhi = 0.;
81  double dRHCALEx = 0.;
82  if (checkExit_) {
83  const reco::PFTrajectoryPoint& tkAtHCALEx = trackref->extrapolatedPoint(trajectoryLayerExit_);
84  dHEta = (tkAtHCALEx.positionREP().Eta() - tkAtHCALEnt.positionREP().Eta());
85  dHPhi = reco::deltaPhi(tkAtHCALEx.positionREP().Phi(), tkAtHCALEnt.positionREP().Phi());
86  dRHCALEx = tkAtHCALEx.position().R();
87  }
88  if (useKDTree_ && hcalelem->isMultilinksValide()) { //KDTree Algo
89  const reco::PFMultilinksType& multilinks = hcalelem->getMultilinks();
90  const double tracketa = tkAtHCALEnt.positionREP().Eta();
91  const double trackphi = tkAtHCALEnt.positionREP().Phi();
92 
93  // Check if the link Track/Hcal exist
94  reco::PFMultilinksType::const_iterator mlit = multilinks.begin();
95  for (; mlit != multilinks.end(); ++mlit)
96  if ((mlit->first == trackphi) && (mlit->second == tracketa))
97  break;
98 
99  // If the link exist, we fill dist and linktest.
100 
101  if (mlit != multilinks.end()) {
102  // when checkExit_ is false
103  if (!checkExit_) {
104  dist = LinkByRecHit::computeDist(hcalreppos.Eta(), hcalreppos.Phi(), tracketa, trackphi);
105  }
106  // when checkExit_ is true
107  else {
108  //special case ! A looper can exit the barrel inwards and hit the endcap
109  //In this case calculate the distance based on the first crossing since
110  //the looper will probably never make it to the endcap
111  if (dRHCALEx < tkAtHCALEnt.position().R()) {
112  dist = LinkByRecHit::computeDist(hcalreppos.Eta(), hcalreppos.Phi(), tracketa, trackphi);
113  edm::LogWarning("TrackHCALLinker ")
114  << "Special case of linking with track hitting HCAL and looping back in the tracker ";
115  } else {
117  hcalreppos.Eta(), hcalreppos.Phi(), tracketa + 0.1 * dHEta, trackphi + 0.1 * dHPhi);
118  }
119  } // checkExit_
120  } // multilinks
121 
122  } else { // Old algorithm
123  if (tkAtHCALEnt.isValid())
124  dist = LinkByRecHit::testTrackAndClusterByRecHit(*trackref, *clusterref, false, debug_);
125  }
126  return dist;
127 }
electrons_cff.bool
bool
Definition: electrons_cff.py:372
MessageLogger.h
funct::false
false
Definition: Factorize.h:34
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
TrackAndHCALLinker::trajectoryLayerEntranceString_
std::string trajectoryLayerEntranceString_
Definition: TrackAndHCALLinker.cc:38
PFBlockElementCluster.h
reco::deltaPhi
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
reco::PFTrajectoryPoint::HCALExit
HCAL exit.
Definition: PFTrajectoryPoint.h:50
LinkByRecHit::testTrackAndClusterByRecHit
static double testTrackAndClusterByRecHit(const reco::PFRecTrack &track, const reco::PFCluster &cluster, bool isBrem=false, bool debug=false)
Definition: LinkByRecHit.cc:16
cms::cuda::assert
assert(be >=bs)
reco::PFBlockElement::HCAL
Definition: PFBlockElement.h:36
reco::PFBlockElement::getMultilinks
const PFMultilinksType & getMultilinks() const
Definition: PFBlockElement.h:119
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
TrackAndHCALLinker::checkExit_
bool checkExit_
Definition: TrackAndHCALLinker.cc:43
TrackAndHCALLinker
Definition: TrackAndHCALLinker.cc:10
reco::PFBlockElementTrack::trackRefPF
const PFRecTrackRef & trackRefPF() const override
Definition: PFBlockElementTrack.h:46
reco::PFBlockElement::TRACK
Definition: PFBlockElement.h:32
TrackAndHCALLinker::trajectoryLayerExit_
reco::PFTrajectoryPoint::LayerType trajectoryLayerExit_
Definition: TrackAndHCALLinker.cc:41
PFCluster.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
edm::ParameterSet
Definition: ParameterSet.h:36
reco::PFTrajectoryPoint::position
const math::XYZPoint & position() const
cartesian position (x, y, z)
Definition: PFTrajectoryPoint.h:100
edmplugin::PluginFactory
Definition: PluginFactory.h:34
LinkByRecHit.h
reco::PFTrajectoryPoint::HCALEntrance
HCAL front face.
Definition: PFTrajectoryPoint.h:48
reco::PFTrajectoryPoint::LayerType
LayerType
Define the different layers where the track can be propagated.
Definition: PFTrajectoryPoint.h:34
reco::PFTrajectoryPoint::layerTypeByName
static LayerType layerTypeByName(const std::string &name)
Definition: PFTrajectoryPoint.cc:42
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::VFcalEntrance
VFcal(HF) front face.
Definition: PFTrajectoryPoint.h:54
TrackAndHCALLinker::debug_
bool debug_
Definition: TrackAndHCALLinker.cc:42
std
Definition: JetResolutionObject.h:76
reco::PFTrajectoryPoint::Unknown
Definition: PFTrajectoryPoint.h:58
reco::PFTrajectoryPoint
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
Definition: PFTrajectoryPoint.h:26
reco::PFBlockElementCluster
Cluster Element.
Definition: PFBlockElementCluster.h:16
TrackAndHCALLinker::linkPrefilter
bool linkPrefilter(const reco::PFBlockElement *, const reco::PFBlockElement *) const override
Definition: TrackAndHCALLinker.cc:48
reco::PFBlockElementTrack
Track Element.
Definition: PFBlockElementTrack.h:17
TrackAndHCALLinker::trajectoryLayerEntrance_
reco::PFTrajectoryPoint::LayerType trajectoryLayerEntrance_
Definition: TrackAndHCALLinker.cc:40
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:303
TrackAndHCALLinker::testLink
double testLink(const reco::PFBlockElement *, const reco::PFBlockElement *) const override
Definition: TrackAndHCALLinker.cc:63
TrackAndHCALLinker::trajectoryLayerExitString_
std::string trajectoryLayerExitString_
Definition: TrackAndHCALLinker.cc:39
reco::PFCluster::REPPoint
ROOT::Math::PositionVector3D< ROOT::Math::CylindricalEta3D< double > > REPPoint
Definition: PFCluster.h:52
TrackAndHCALLinker::useKDTree_
bool useKDTree_
Definition: TrackAndHCALLinker.cc:37
LinkByRecHit::computeDist
static double computeDist(double eta1, double phi1, double eta2, double phi2, bool etaPhi=true)
computes a chisquare
Definition: LinkByRecHit.cc:517
PFBlockElementTrack.h
TrackAndHCALLinker::TrackAndHCALLinker
TrackAndHCALLinker(const edm::ParameterSet &conf)
Definition: TrackAndHCALLinker.cc:12
deltaPhi.h
PFTrajectoryPoint.h
reco::PFBlockElement::isMultilinksValide
bool isMultilinksValide() const
Definition: PFBlockElement.h:118