CMS 3D CMS Logo

List of all members | Public Types | Static Public Member Functions
BPHTrackReference Class Reference

#include <BPHTrackReference.h>

Public Types

typedef pat::PackedCandidate candidate
 

Static Public Member Functions

static const reco::TrackgetElecPF (const reco::Candidate &rc)
 
static const reco::TrackgetElecPF (const pat::Electron *el)
 
static const reco::TrackgetElecTC (const reco::Candidate &rc)
 
static const reco::TrackgetElecTC (const pat::Electron *el)
 
static const reco::TrackgetFromBT (const reco::Candidate &rc)
 
static const reco::TrackgetFromGP (const reco::Candidate &rc)
 
static const reco::TrackgetFromPC (const reco::Candidate &rc)
 
static const reco::TrackgetFromPF (const reco::Candidate &rc)
 
static const reco::TrackgetFromRC (const reco::Candidate &rc)
 
static const reco::TrackgetMuonBT (const reco::Candidate &rc)
 
static const reco::TrackgetMuonBT (const reco::Muon *mu)
 
static const reco::TrackgetMuonGT (const reco::Candidate &rc)
 
static const reco::TrackgetMuonGT (const pat::Muon *mu)
 
static const reco::TrackgetMuonIT (const reco::Candidate &rc)
 
static const reco::TrackgetMuonIT (const pat::Muon *mu)
 
static const reco::TrackgetMuonPF (const reco::Candidate &rc)
 
static const reco::TrackgetMuonPF (const pat::Muon *mu)
 
static const reco::TrackgetMuonSA (const reco::Candidate &rc)
 
static const reco::TrackgetMuonSA (const pat::Muon *mu)
 
static const reco::TrackgetTrack (const reco::Candidate &rc, const char *modeList="cfhbpmnigset", char *modeFlag=nullptr)
 

Detailed Description

Description: class to have uniform access to reco::Track for different particle objects

Author
Paolo Ronchese INFN Padova

Definition at line 36 of file BPHTrackReference.h.

Member Typedef Documentation

◆ candidate

Definition at line 38 of file BPHTrackReference.h.

Member Function Documentation

◆ getElecPF() [1/2]

static const reco::Track* BPHTrackReference::getElecPF ( const reco::Candidate rc)
inlinestatic

Definition at line 262 of file BPHTrackReference.h.

262  {
263  const pat::Electron* el = dynamic_cast<const pat::Electron*>(&rc);
264  if (el == nullptr)
265  return nullptr;
266  return getElecPF(el);
267  }
Analysis-level electron class.
Definition: Electron.h:51
static const reco::Track * getElecPF(const reco::Candidate &rc)

◆ getElecPF() [2/2]

static const reco::Track* BPHTrackReference::getElecPF ( const pat::Electron el)
inlinestatic

Definition at line 268 of file BPHTrackReference.h.

References edm::Ref< C, T, F >::get(), edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), and pat::Electron::pfCandidateRef().

268  {
269  try {
270  const reco::PFCandidateRef& pcr = el->pfCandidateRef();
271  if (pcr.isNonnull() && pcr.isAvailable()) {
272  const reco::TrackRef& tkr = pcr->trackRef();
273  if (tkr.isNonnull() && tkr.isAvailable())
274  return tkr.get();
275  }
276  } catch (edm::Exception const&) {
277  }
278  return nullptr;
279  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
reco::PFCandidateRef pfCandidateRef() const
reference to the source PFCandidates; null if this has been built from a standard electron ...
bool isAvailable() const
Definition: Ref.h:537
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232

◆ getElecTC() [1/2]

static const reco::Track* BPHTrackReference::getElecTC ( const reco::Candidate rc)
inlinestatic

Definition at line 280 of file BPHTrackReference.h.

280  {
281  const pat::Electron* el = dynamic_cast<const pat::Electron*>(&rc);
282  if (el == nullptr)
283  return nullptr;
284  return getElecTC(el);
285  }
static const reco::Track * getElecTC(const reco::Candidate &rc)
Analysis-level electron class.
Definition: Electron.h:51

◆ getElecTC() [2/2]

static const reco::Track* BPHTrackReference::getElecTC ( const pat::Electron el)
inlinestatic

Definition at line 286 of file BPHTrackReference.h.

References pat::Electron::closestCtfTrackRef(), edm::Ref< C, T, F >::get(), edm::Ref< C, T, F >::isAvailable(), and edm::Ref< C, T, F >::isNonnull().

286  {
287  try {
288  // Return the ctftrack closest to the electron
289  const reco::TrackRef& tkr = el->closestCtfTrackRef();
290  if (tkr.isNonnull() && tkr.isAvailable())
291  return tkr.get();
292  } catch (edm::Exception const&) {
293  }
294  return nullptr;
295  }
reco::TrackRef closestCtfTrackRef() const override
override the reco::GsfElectron::closestCtfTrackRef method, to access the internal storage of the trac...
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isAvailable() const
Definition: Ref.h:537
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232

◆ getFromBT()

static const reco::Track* BPHTrackReference::getFromBT ( const reco::Candidate rc)
inlinestatic

Definition at line 159 of file BPHTrackReference.h.

References reco::Candidate::bestTrack().

159  {
160  try {
161  const reco::Track* trk = rc.bestTrack();
162  return trk;
163  } catch (edm::Exception const&) {
164  }
165  return nullptr;
166  }
virtual const Track * bestTrack() const
Definition: Candidate.h:268

◆ getFromGP()

static const reco::Track* BPHTrackReference::getFromGP ( const reco::Candidate rc)
inlinestatic

Definition at line 147 of file BPHTrackReference.h.

References edm::Ref< C, T, F >::get(), runTauDisplay::gp, edm::Ref< C, T, F >::isAvailable(), and edm::Ref< C, T, F >::isNonnull().

147  {
148  const pat::GenericParticle* gp = dynamic_cast<const pat::GenericParticle*>(&rc);
149  if (gp == nullptr)
150  return nullptr;
151  try {
152  const reco::TrackRef& tkr = gp->track();
153  if (tkr.isNonnull() && tkr.isAvailable())
154  return tkr.get();
155  } catch (edm::Exception const&) {
156  }
157  return nullptr;
158  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed) ...
bool isAvailable() const
Definition: Ref.h:537
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232

◆ getFromPC()

static const reco::Track* BPHTrackReference::getFromPC ( const reco::Candidate rc)
inlinestatic

Definition at line 167 of file BPHTrackReference.h.

References createTree::pp.

167  {
168  const pat::PackedCandidate* pp = dynamic_cast<const pat::PackedCandidate*>(&rc);
169  if (pp == nullptr)
170  return nullptr;
171  try {
172  const reco::Track* trk = &pp->pseudoTrack();
173  return trk;
174  } catch (edm::Exception const&) {
175  }
176  return nullptr;
177  }

◆ getFromPF()

static const reco::Track* BPHTrackReference::getFromPF ( const reco::Candidate rc)
inlinestatic

Definition at line 135 of file BPHTrackReference.h.

References edm::Ref< C, T, F >::get(), edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), and packedPFCandidateRefMixer_cfi::pf.

Referenced by BPHRecoBuilder::sameTrack().

135  {
136  const reco::PFCandidate* pf = dynamic_cast<const reco::PFCandidate*>(&rc);
137  if (pf == nullptr)
138  return nullptr;
139  try {
140  const reco::TrackRef& tkr = pf->trackRef();
141  if (tkr.isNonnull() && tkr.isAvailable())
142  return tkr.get();
143  } catch (edm::Exception const&) {
144  }
145  return nullptr;
146  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isAvailable() const
Definition: Ref.h:537
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232

◆ getFromRC()

static const reco::Track* BPHTrackReference::getFromRC ( const reco::Candidate rc)
inlinestatic

Definition at line 126 of file BPHTrackReference.h.

References reco::Candidate::get(), edm::Ref< C, T, F >::get(), edm::Ref< C, T, F >::isAvailable(), and edm::Ref< C, T, F >::isNonnull().

Referenced by BPHRecoBuilder::sameTrack().

126  {
127  try {
128  const reco::TrackRef& tkr = rc.get<reco::TrackRef>();
129  if (tkr.isNonnull() && tkr.isAvailable())
130  return tkr.get();
131  } catch (edm::Exception const&) {
132  }
133  return nullptr;
134  }
T get() const
get a component
Definition: Candidate.h:221
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isAvailable() const
Definition: Ref.h:537
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232

◆ getMuonBT() [1/2]

static const reco::Track* BPHTrackReference::getMuonBT ( const reco::Candidate rc)
inlinestatic

Definition at line 196 of file BPHTrackReference.h.

References amptDefaultParameters_cff::mu.

196  {
197  const reco::Muon* mu = dynamic_cast<const reco::Muon*>(&rc);
198  if (mu == nullptr)
199  return nullptr;
200  return getMuonBT(mu);
201  }
static const reco::Track * getMuonBT(const reco::Candidate &rc)

◆ getMuonBT() [2/2]

static const reco::Track* BPHTrackReference::getMuonBT ( const reco::Muon mu)
inlinestatic

Definition at line 202 of file BPHTrackReference.h.

References edm::Ref< C, T, F >::get(), edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), and amptDefaultParameters_cff::mu.

202  {
203  try {
204  const reco::TrackRef& tkr = mu->muonBestTrack();
205  if (tkr.isNonnull() && tkr.isAvailable())
206  return tkr.get();
207  } catch (edm::Exception const&) {
208  }
209  return nullptr;
210  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isAvailable() const
Definition: Ref.h:537
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232

◆ getMuonGT() [1/2]

static const reco::Track* BPHTrackReference::getMuonGT ( const reco::Candidate rc)
inlinestatic

Definition at line 228 of file BPHTrackReference.h.

References amptDefaultParameters_cff::mu.

228  {
229  const pat::Muon* mu = dynamic_cast<const pat::Muon*>(&rc);
230  if (mu == nullptr)
231  return nullptr;
232  return getMuonGT(mu);
233  }
static const reco::Track * getMuonGT(const reco::Candidate &rc)
Analysis-level muon class.
Definition: Muon.h:51

◆ getMuonGT() [2/2]

static const reco::Track* BPHTrackReference::getMuonGT ( const pat::Muon mu)
inlinestatic

Definition at line 234 of file BPHTrackReference.h.

References edm::Ref< C, T, F >::get(), edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), and amptDefaultParameters_cff::mu.

234  {
235  if (!mu->isGlobalMuon())
236  return nullptr;
237  try {
238  const reco::TrackRef& mgt = mu->globalTrack();
239  if (mgt.isNonnull() && mgt.isAvailable())
240  return mgt.get();
241  } catch (edm::Exception const&) {
242  }
243  return nullptr;
244  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isAvailable() const
Definition: Ref.h:537
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232

◆ getMuonIT() [1/2]

static const reco::Track* BPHTrackReference::getMuonIT ( const reco::Candidate rc)
inlinestatic

Definition at line 211 of file BPHTrackReference.h.

References amptDefaultParameters_cff::mu.

211  {
212  const pat::Muon* mu = dynamic_cast<const pat::Muon*>(&rc);
213  if (mu == nullptr)
214  return nullptr;
215  return getMuonIT(mu);
216  }
static const reco::Track * getMuonIT(const reco::Candidate &rc)
Analysis-level muon class.
Definition: Muon.h:51

◆ getMuonIT() [2/2]

static const reco::Track* BPHTrackReference::getMuonIT ( const pat::Muon mu)
inlinestatic

Definition at line 217 of file BPHTrackReference.h.

References edm::Ref< C, T, F >::get(), edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), and amptDefaultParameters_cff::mu.

217  {
218  if (!mu->isTrackerMuon())
219  return nullptr;
220  try {
221  const reco::TrackRef& mit = mu->innerTrack();
222  if (mit.isNonnull() && mit.isAvailable())
223  return mit.get();
224  } catch (edm::Exception const&) {
225  }
226  return nullptr;
227  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isAvailable() const
Definition: Ref.h:537
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232

◆ getMuonPF() [1/2]

static const reco::Track* BPHTrackReference::getMuonPF ( const reco::Candidate rc)
inlinestatic

Definition at line 178 of file BPHTrackReference.h.

References amptDefaultParameters_cff::mu.

178  {
179  const pat::Muon* mu = dynamic_cast<const pat::Muon*>(&rc);
180  if (mu == nullptr)
181  return nullptr;
182  return getMuonPF(mu);
183  }
static const reco::Track * getMuonPF(const reco::Candidate &rc)
Analysis-level muon class.
Definition: Muon.h:51

◆ getMuonPF() [2/2]

static const reco::Track* BPHTrackReference::getMuonPF ( const pat::Muon mu)
inlinestatic

Definition at line 184 of file BPHTrackReference.h.

References edm::Ref< C, T, F >::get(), edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), and amptDefaultParameters_cff::mu.

184  {
185  try {
186  const reco::PFCandidateRef& pcr = mu->pfCandidateRef();
187  if (pcr.isNonnull() && pcr.isAvailable()) {
188  const reco::TrackRef& tkr = pcr->trackRef();
189  if (tkr.isNonnull() && tkr.isAvailable())
190  return tkr.get();
191  }
192  } catch (edm::Exception const&) {
193  }
194  return nullptr;
195  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isAvailable() const
Definition: Ref.h:537
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232

◆ getMuonSA() [1/2]

static const reco::Track* BPHTrackReference::getMuonSA ( const reco::Candidate rc)
inlinestatic

Definition at line 245 of file BPHTrackReference.h.

References amptDefaultParameters_cff::mu.

245  {
246  const pat::Muon* mu = dynamic_cast<const pat::Muon*>(&rc);
247  if (mu == nullptr)
248  return nullptr;
249  return getMuonSA(mu);
250  }
static const reco::Track * getMuonSA(const reco::Candidate &rc)
Analysis-level muon class.
Definition: Muon.h:51

◆ getMuonSA() [2/2]

static const reco::Track* BPHTrackReference::getMuonSA ( const pat::Muon mu)
inlinestatic

Definition at line 251 of file BPHTrackReference.h.

References edm::Ref< C, T, F >::get(), edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), and amptDefaultParameters_cff::mu.

251  {
252  if (!mu->isStandAloneMuon())
253  return nullptr;
254  try {
255  const reco::TrackRef& msa = mu->standAloneMuon();
256  if (msa.isNonnull() && msa.isAvailable())
257  return msa.get();
258  } catch (edm::Exception const&) {
259  }
260  return nullptr;
261  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isAvailable() const
Definition: Ref.h:537
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232

◆ getTrack()

static const reco::Track* BPHTrackReference::getTrack ( const reco::Candidate rc,
const char *  modeList = "cfhbpmnigset",
char *  modeFlag = nullptr 
)
inlinestatic

Only static functions, no data memberOperationsget associated reco::Track calling a sequence of functions until a track is found; the list of functions to call is given as a string where each character identify a function: c : reco :: Candidate :: get<reco::TrackRef> () f : reco :: PFCandidate :: trackRef () h : pat :: GenericParticle :: track () b : reco :: Candidate :: bestTrack () p : pat :: PackedCandidate :: pseudoTrack () m : pat :: Muon ::pfCandidateRef()::trackRef () n : pat :: Muon :: muonBestTrack () i : pat :: Muon :: innerTrack () g : pat :: Muon :: globalTrack () s : pat :: Muon :: standAloneMuon () e : pat :: Electron ::pfCandidateRef()::trackRef () t : pat :: Electron :: closestCtfTrackRef ()

Definition at line 60 of file BPHTrackReference.h.

Referenced by BPHDecayToChargedXXbarBuilder::addParticle(), BPHDecayToTkpTknSymChargeBuilder::addParticle(), BPHDecayVertex::fTracks(), and HeavyFlavorDQMAnalyzer::getDaughterTrack().

62  {
63  if (rc.charge() == 0)
64  return nullptr;
65  const char* mptr = modeList;
66  char c;
67  if (modeFlag == nullptr)
68  modeFlag = &c;
69  char& mode = *modeFlag;
70  const reco::Track* tkp = nullptr;
71  while ((mode = *mptr++)) {
72  switch (mode) {
73  case 'c':
74  if ((tkp = getFromRC(rc)) != nullptr)
75  return tkp;
76  break;
77  case 'f':
78  if ((tkp = getFromPF(rc)) != nullptr)
79  return tkp;
80  break;
81  case 'h':
82  if ((tkp = getFromGP(rc)) != nullptr)
83  return tkp;
84  break;
85  case 'b':
86  if ((tkp = getFromBT(rc)) != nullptr)
87  return tkp;
88  break;
89  case 'p':
90  if ((tkp = getFromPC(rc)) != nullptr)
91  return tkp;
92  break;
93  case 'm':
94  if ((tkp = getMuonPF(rc)) != nullptr)
95  return tkp;
96  break;
97  case 'n':
98  if ((tkp = getMuonBT(rc)) != nullptr)
99  return tkp;
100  break;
101  case 'i':
102  if ((tkp = getMuonIT(rc)) != nullptr)
103  return tkp;
104  break;
105  case 'g':
106  if ((tkp = getMuonGT(rc)) != nullptr)
107  return tkp;
108  break;
109  case 's':
110  if ((tkp = getMuonSA(rc)) != nullptr)
111  return tkp;
112  break;
113  case 'e':
114  if ((tkp = getElecPF(rc)) != nullptr)
115  return tkp;
116  break;
117  case 't':
118  if ((tkp = getElecTC(rc)) != nullptr)
119  return tkp;
120  break;
121  }
122  }
123  return nullptr;
124  }
static const reco::Track * getMuonPF(const reco::Candidate &rc)
static const reco::Track * getFromPF(const reco::Candidate &rc)
static const reco::Track * getMuonSA(const reco::Candidate &rc)
static const reco::Track * getElecTC(const reco::Candidate &rc)
static const reco::Track * getFromRC(const reco::Candidate &rc)
static const reco::Track * getMuonIT(const reco::Candidate &rc)
static const reco::Track * getMuonGT(const reco::Candidate &rc)
virtual int charge() const =0
electric charge
static const reco::Track * getElecPF(const reco::Candidate &rc)
static const reco::Track * getFromPC(const reco::Candidate &rc)
static const reco::Track * getFromGP(const reco::Candidate &rc)
static const reco::Track * getMuonBT(const reco::Candidate &rc)
static const reco::Track * getFromBT(const reco::Candidate &rc)