CMS 3D CMS Logo

TrackAndGSFLinker.cc
Go to the documentation of this file.
6 
8 public:
11  _useKDTree(conf.getParameter<bool>("useKDTree")),
12  _useConvertedBrems(conf.getParameter<bool>("useConvertedBrems")),
13  _debug(conf.getUntrackedParameter<bool>("debug",false)) {}
14 
15  double testLink
16  ( const reco::PFBlockElement*,
17  const reco::PFBlockElement* ) const override;
18 
19 private:
21 };
22 
25  "TrackAndGSFLinker");
26 
28  ( const reco::PFBlockElement* elem1,
29  const reco::PFBlockElement* elem2) const {
32  double dist = -1.0;
33  const reco::PFBlockElementGsfTrack * gsfelem(nullptr);
34  const reco::PFBlockElementTrack * tkelem(nullptr);
35  if( elem1->type() < elem2->type() ) {
36  tkelem = static_cast<const reco::PFBlockElementTrack *>(elem1);
37  gsfelem = static_cast<const reco::PFBlockElementGsfTrack *>(elem2);
38  } else {
39  tkelem = static_cast<const reco::PFBlockElementTrack *>(elem2);
40  gsfelem = static_cast<const reco::PFBlockElementGsfTrack *>(elem1);
41  }
42 
43  const reco::PFRecTrackRef& trackref = tkelem->trackRefPF();
44  const reco::GsfPFRecTrackRef& gsfref = gsfelem->GsftrackRefPF();
45  const reco::TrackRef& kftrackref= trackref->trackRef();
46  const reco::TrackBaseRef kftrackrefbase(kftrackref);
47  const reco::PFRecTrackRef& refkf = gsfref->kfPFRecTrackRef();
48  if(refkf.isNonnull()) {
49  const reco::TrackRef& gsftrackref = refkf->trackRef();
50  if ( gsftrackref.isNonnull() && kftrackref.isNonnull() &&
51  kftrackref == gsftrackref ) {
52  dist = 0.001;
53  }
54  }
55 
56  //override for converted brems
57  if(_useConvertedBrems) {
58  if(tkelem->isLinkedToDisplacedVertex()){
59  const std::vector<reco::PFRecTrackRef>& convbrems =
60  gsfref->convBremPFRecTrackRef();
61  for( const auto& convbrem : convbrems ) {
62  if( tkelem->trackType(T_FROM_GAMMACONV) &&
63  kftrackref == convbrem->trackRef() ) {
64  dist = 0.001;
65  } else { // check the base ref as well (for dedicated conversions?)
66  const reco::TrackBaseRef convbrembase(convbrem->trackRef());
67  if( convbrembase == kftrackrefbase ) {
68  dist = 0.001;
69  }
70  }
71  }
72  }
73  }
74  return dist;
75 }
Abstract base class for a PFBlock element (track, cluster...)
TrackAndGSFLinker(const edm::ParameterSet &conf)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
double testLink(const reco::PFBlockElement *, const reco::PFBlockElement *) const override
Type type() const
bool trackType(TrackType trType) const override
const GsfPFRecTrackRef & GsftrackRefPF() const
bool isLinkedToDisplacedVertex() const override
const PFRecTrackRef & trackRefPF() const override
#define DEFINE_EDM_PLUGIN(factory, type, name)
#define constexpr