CMS 3D CMS Logo

TrackAndHCALLinker.cc
Go to the documentation of this file.
8 
10 public:
13  _useKDTree(conf.getParameter<bool>("useKDTree")),
14  _debug(conf.getUntrackedParameter<bool>("debug",false)) {}
15 
16  double testLink
17  ( const reco::PFBlockElement*,
18  const reco::PFBlockElement* ) const override;
19 
20 private:
22 };
23 
26  "TrackAndHCALLinker");
27 
29  ( const reco::PFBlockElement* elem1,
30  const reco::PFBlockElement* elem2) const {
35  const reco::PFBlockElementCluster *hcalelem(nullptr);
36  const reco::PFBlockElementTrack *tkelem(nullptr);
37  double dist(-1.0);
38  if( elem1->type() < elem2->type() ) {
39  tkelem = static_cast<const reco::PFBlockElementTrack*>(elem1);
40  hcalelem = static_cast<const reco::PFBlockElementCluster*>(elem2);
41  } else {
42  tkelem = static_cast<const reco::PFBlockElementTrack*>(elem2);
43  hcalelem = static_cast<const reco::PFBlockElementCluster*>(elem1);
44  }
45  const reco::PFRecTrackRef& trackref = tkelem->trackRefPF();
46  const reco::PFClusterRef& clusterref = hcalelem->clusterRef();
47  const reco::PFCluster::REPPoint& hcalreppos = clusterref->positionREP();
48  const reco::PFTrajectoryPoint& tkAtHCALEnt =
49  trackref->extrapolatedPoint( HCALEntrance );
50  const reco::PFTrajectoryPoint& tkAtHCALEx =
51  trackref->extrapolatedPoint( HCALExit );
52  const double dHEta = ( tkAtHCALEx.positionREP().Eta() -
53  tkAtHCALEnt.positionREP().Eta() );
54  const double dHPhi = reco::deltaPhi( tkAtHCALEx.positionREP().Phi(),
55  tkAtHCALEnt.positionREP().Phi() );
56  if ( _useKDTree && hcalelem->isMultilinksValide() ) { //KDTree Algo
57  const reco::PFMultilinksType& multilinks = hcalelem->getMultilinks();
58  const double tracketa = tkAtHCALEnt.positionREP().Eta();
59  const double trackphi = tkAtHCALEnt.positionREP().Phi();
60 
61  // Check if the link Track/Hcal exist
62  reco::PFMultilinksType::const_iterator mlit = multilinks.begin();
63  for (; mlit != multilinks.end(); ++mlit)
64  if ((mlit->first == trackphi) && (mlit->second == tracketa))
65  break;
66 
67  // If the link exist, we fill dist and linktest.
68 
69 
70 
71  if (mlit != multilinks.end()){
72 
73 
74  //special case ! A looper can exit the barrel inwards and hit the endcap
75  //In this case calculate the distance based on the first crossing since
76  //the looper will probably never make it to the endcap
77  if (tkAtHCALEx.position().R()<tkAtHCALEnt.position().R()) {
78  dist = LinkByRecHit::computeDist(hcalreppos.Eta(),
79  hcalreppos.Phi(),
80  tracketa,
81  trackphi);
82 
83  edm::LogWarning("TrackHCALLinker ") <<"Special case of linking with track hitting HCAL and looping back in the tracker ";
84  }
85  else {
86  dist = LinkByRecHit::computeDist(hcalreppos.Eta(),
87  hcalreppos.Phi(),
88  tracketa + 0.1 * dHEta,
89  trackphi + 0.1 * dHPhi);
90  }
91 
92  }
93 
94  } else {// Old algorithm
95  if ( tkAtHCALEnt.isValid() )
97  *clusterref,
98  false, _debug );
99  }
100  return dist;
101 }
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
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...)
double testLink(const reco::PFBlockElement *, const reco::PFBlockElement *) const override
static double computeDist(double eta1, double phi1, double eta2, double phi2, bool etaPhi=true)
computes a chisquare
const PFClusterRef & clusterRef() const override
const math::XYZPoint & position() const
cartesian position (x, y, z)
Type type() const
#define constexpr
bool isValid() const
is this point valid ?
TrackAndHCALLinker(const edm::ParameterSet &conf)
bool isMultilinksValide() const
const PFRecTrackRef & trackRefPF() const override
ROOT::Math::PositionVector3D< ROOT::Math::CylindricalEta3D< double > > REPPoint
Definition: PFCluster.h:54
#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:18
const PFMultilinksType & getMultilinks() const