CMS 3D CMS Logo

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

#include <BPHTrackReference.h>

Public Types

typedef pat::PackedCandidate candidate
 

Public Member Functions

 BPHTrackReference ()
 
 ~BPHTrackReference ()
 

Static Public Member Functions

static const reco::TrackgetElecPF (const reco::Candidate &rc)
 
static const reco::TrackgetElecPF (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="cfhbpmnigse", char *modeFlag=0)
 

Private Member Functions

 BPHTrackReference (const BPHTrackReference &x)
 
BPHTrackReferenceoperator= (const BPHTrackReference &x)
 

Detailed Description

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

Author
Paolo Ronchese INFN Padova

Definition at line 37 of file BPHTrackReference.h.

Member Typedef Documentation

Definition at line 39 of file BPHTrackReference.h.

Constructor & Destructor Documentation

BPHTrackReference::BPHTrackReference ( )

Constructor

Referenced by getElecPF().

BPHTrackReference::~BPHTrackReference ( )

Destructor

BPHTrackReference::BPHTrackReference ( const BPHTrackReference x)
private

Member Function Documentation

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

Definition at line 273 of file BPHTrackReference.h.

273  {
274  // std::cout << "getElecPF" << std::endl;
275  const pat::Electron* el = dynamic_cast<const pat::Electron*>(&rc);
276  if (el == nullptr)
277  return nullptr;
278  return getElecPF(el);
279  }
Analysis-level electron class.
Definition: Electron.h:51
static const reco::Track * getElecPF(const reco::Candidate &rc)
static const reco::Track* BPHTrackReference::getElecPF ( const pat::Electron el)
inlinestatic

Definition at line 280 of file BPHTrackReference.h.

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

280  {
281  try {
282  const reco::PFCandidateRef& pcr = el->pfCandidateRef();
283  if (pcr.isNonnull() && pcr.isAvailable()) {
284  const reco::TrackRef& tkr = pcr->trackRef();
285  if (tkr.isNonnull() && tkr.isAvailable())
286  return tkr.get();
287  }
288  } catch (edm::Exception const&) {
289  }
290  return nullptr;
291  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isAvailable() const
Definition: Ref.h:537
reco::PFCandidateRef pfCandidateRef() const
reference to the source PFCandidates; null if this has been built from a standard electron ...
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
static const reco::Track* BPHTrackReference::getFromBT ( const reco::Candidate rc)
inlinestatic

Definition at line 163 of file BPHTrackReference.h.

References reco::Candidate::bestTrack().

163  {
164  // std::cout << "getFromBT" << std::endl;
165  try {
166  const reco::Track* trk = rc.bestTrack();
167  return trk;
168  } catch (edm::Exception const&) {
169  }
170  return nullptr;
171  }
virtual const Track * bestTrack() const
Definition: Candidate.h:269
static const reco::Track* BPHTrackReference::getFromGP ( const reco::Candidate rc)
inlinestatic

Definition at line 150 of file BPHTrackReference.h.

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

150  {
151  // std::cout << "getFromGC" << std::endl;
152  const pat::GenericParticle* gp = dynamic_cast<const pat::GenericParticle*>(&rc);
153  if (gp == nullptr)
154  return nullptr;
155  try {
156  const reco::TrackRef& tkr = gp->track();
157  if (tkr.isNonnull() && tkr.isAvailable())
158  return tkr.get();
159  } catch (edm::Exception const&) {
160  }
161  return nullptr;
162  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isAvailable() const
Definition: Ref.h:537
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed) ...
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
reco::TrackRef track() const override
static const reco::Track* BPHTrackReference::getFromPC ( const reco::Candidate rc)
inlinestatic

Definition at line 172 of file BPHTrackReference.h.

References createTree::pp, and pat::PackedCandidate::pseudoTrack().

172  {
173  // std::cout << "getFromPC" << std::endl;
174  const pat::PackedCandidate* pp = dynamic_cast<const pat::PackedCandidate*>(&rc);
175  if (pp == nullptr)
176  return nullptr;
177  try {
178  const reco::Track* trk = &pp->pseudoTrack();
179  return trk;
180  } catch (edm::Exception const&) {
181  }
182  return nullptr;
183  }
virtual const reco::Track & pseudoTrack() const
static const reco::Track* BPHTrackReference::getFromPF ( const reco::Candidate rc)
inlinestatic

Definition at line 137 of file BPHTrackReference.h.

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

Referenced by BPHRecoBuilder::sameTrack().

137  {
138  // std::cout << "getFromPF" << std::endl;
139  const reco::PFCandidate* pf = dynamic_cast<const reco::PFCandidate*>(&rc);
140  if (pf == nullptr)
141  return nullptr;
142  try {
143  const reco::TrackRef& tkr = pf->trackRef();
144  if (tkr.isNonnull() && tkr.isAvailable())
145  return tkr.get();
146  } catch (edm::Exception const&) {
147  }
148  return nullptr;
149  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isAvailable() const
Definition: Ref.h:537
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:408
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
static const reco::Track* BPHTrackReference::getFromRC ( const reco::Candidate rc)
inlinestatic

Definition at line 127 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().

127  {
128  // std::cout << "getFromRC" << std::endl;
129  try {
130  const reco::TrackRef& tkr = rc.get<reco::TrackRef>();
131  if (tkr.isNonnull() && tkr.isAvailable())
132  return tkr.get();
133  } catch (edm::Exception const&) {
134  }
135  return nullptr;
136  }
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
T get() const
get a component
Definition: Candidate.h:222
static const reco::Track* BPHTrackReference::getMuonBT ( const reco::Candidate rc)
inlinestatic

Definition at line 203 of file BPHTrackReference.h.

References amptDefaultParameters_cff::mu.

203  {
204  // std::cout << "getMuonBT" << std::endl;
205  const reco::Muon* mu = dynamic_cast<const reco::Muon*>(&rc);
206  if (mu == nullptr)
207  return nullptr;
208  return getMuonBT(mu);
209  }
static const reco::Track * getMuonBT(const reco::Candidate &rc)
static const reco::Track* BPHTrackReference::getMuonBT ( const reco::Muon mu)
inlinestatic

Definition at line 210 of file BPHTrackReference.h.

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

210  {
211  try {
212  const reco::TrackRef& tkr = mu->muonBestTrack();
213  if (tkr.isNonnull() && tkr.isAvailable())
214  return tkr.get();
215  } catch (edm::Exception const&) {
216  }
217  return nullptr;
218  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isAvailable() const
Definition: Ref.h:537
virtual TrackRef muonBestTrack() const
Definition: Muon.h:60
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
static const reco::Track* BPHTrackReference::getMuonGT ( const reco::Candidate rc)
inlinestatic

Definition at line 237 of file BPHTrackReference.h.

References amptDefaultParameters_cff::mu.

237  {
238  // std::cout << "getMuonGT" << std::endl;
239  const pat::Muon* mu = dynamic_cast<const pat::Muon*>(&rc);
240  if (mu == nullptr)
241  return nullptr;
242  return getMuonGT(mu);
243  }
static const reco::Track * getMuonGT(const reco::Candidate &rc)
Analysis-level muon class.
Definition: Muon.h:51
static const reco::Track* BPHTrackReference::getMuonGT ( const pat::Muon mu)
inlinestatic

Definition at line 244 of file BPHTrackReference.h.

References edm::Ref< C, T, F >::get(), pat::Muon::globalTrack(), edm::Ref< C, T, F >::isAvailable(), reco::Muon::isGlobalMuon(), and edm::Ref< C, T, F >::isNonnull().

244  {
245  if (!mu->isGlobalMuon())
246  return nullptr;
247  try {
248  const reco::TrackRef& mgt = mu->globalTrack();
249  if (mgt.isNonnull() && mgt.isAvailable())
250  return mgt.get();
251  } catch (edm::Exception const&) {
252  }
253  return nullptr;
254  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isAvailable() const
Definition: Ref.h:537
bool isGlobalMuon() const override
Definition: Muon.h:298
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
reco::TrackRef globalTrack() const override
reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon) ...
Definition: Muon.h:80
static const reco::Track* BPHTrackReference::getMuonIT ( const reco::Candidate rc)
inlinestatic

Definition at line 219 of file BPHTrackReference.h.

References amptDefaultParameters_cff::mu.

219  {
220  // std::cout << "getMuonIT" << std::endl;
221  const pat::Muon* mu = dynamic_cast<const pat::Muon*>(&rc);
222  if (mu == nullptr)
223  return nullptr;
224  return getMuonIT(mu);
225  }
static const reco::Track * getMuonIT(const reco::Candidate &rc)
Analysis-level muon class.
Definition: Muon.h:51
static const reco::Track* BPHTrackReference::getMuonIT ( const pat::Muon mu)
inlinestatic

Definition at line 226 of file BPHTrackReference.h.

References edm::Ref< C, T, F >::get(), pat::Muon::innerTrack(), edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), and reco::Muon::isTrackerMuon().

226  {
227  if (!mu->isTrackerMuon())
228  return nullptr;
229  try {
230  const reco::TrackRef& mit = mu->innerTrack();
231  if (mit.isNonnull() && mit.isAvailable())
232  return mit.get();
233  } catch (edm::Exception const&) {
234  }
235  return nullptr;
236  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isAvailable() const
Definition: Ref.h:537
bool isTrackerMuon() const override
Definition: Muon.h:299
reco::TrackRef innerTrack() const override
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.h:72
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
static const reco::Track* BPHTrackReference::getMuonPF ( const reco::Candidate rc)
inlinestatic

Definition at line 184 of file BPHTrackReference.h.

References amptDefaultParameters_cff::mu.

184  {
185  // std::cout << "getMuonPF" << std::endl;
186  const pat::Muon* mu = dynamic_cast<const pat::Muon*>(&rc);
187  if (mu == nullptr)
188  return nullptr;
189  return getMuonPF(mu);
190  }
static const reco::Track * getMuonPF(const reco::Candidate &rc)
Analysis-level muon class.
Definition: Muon.h:51
static const reco::Track* BPHTrackReference::getMuonPF ( const pat::Muon mu)
inlinestatic

Definition at line 191 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::Muon::pfCandidateRef().

191  {
192  try {
193  const reco::PFCandidateRef& pcr = mu->pfCandidateRef();
194  if (pcr.isNonnull() && pcr.isAvailable()) {
195  const reco::TrackRef& tkr = pcr->trackRef();
196  if (tkr.isNonnull() && tkr.isAvailable())
197  return tkr.get();
198  }
199  } catch (edm::Exception const&) {
200  }
201  return nullptr;
202  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isAvailable() const
Definition: Ref.h:537
reco::PFCandidateRef pfCandidateRef() const
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
static const reco::Track* BPHTrackReference::getMuonSA ( const reco::Candidate rc)
inlinestatic

Definition at line 255 of file BPHTrackReference.h.

References amptDefaultParameters_cff::mu.

255  {
256  // std::cout << "getMuonGT" << std::endl;
257  const pat::Muon* mu = dynamic_cast<const pat::Muon*>(&rc);
258  if (mu == nullptr)
259  return nullptr;
260  return getMuonSA(mu);
261  }
static const reco::Track * getMuonSA(const reco::Candidate &rc)
Analysis-level muon class.
Definition: Muon.h:51
static const reco::Track* BPHTrackReference::getMuonSA ( const pat::Muon mu)
inlinestatic

Definition at line 262 of file BPHTrackReference.h.

References edm::Ref< C, T, F >::get(), edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), reco::Muon::isStandAloneMuon(), and pat::Muon::standAloneMuon().

262  {
263  if (!mu->isStandAloneMuon())
264  return nullptr;
265  try {
266  const reco::TrackRef& msa = mu->standAloneMuon();
267  if (msa.isNonnull() && msa.isAvailable())
268  return msa.get();
269  } catch (edm::Exception const&) {
270  }
271  return nullptr;
272  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool isStandAloneMuon() const override
Definition: Muon.h:300
bool isAvailable() const
Definition: Ref.h:537
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
reco::TrackRef standAloneMuon() const override
reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon) ...
static const reco::Track* BPHTrackReference::getTrack ( const reco::Candidate rc,
const char *  modeList = "cfhbpmnigse",
char *  modeFlag = 0 
)
inlinestatic

Operationsget 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 () n : pat :: Muon :: muonBestTrack () i : pat :: Muon :: innerTrack () g : pat :: Muon :: globalTrack () s : pat :: Muon :: standAloneMuon () e : pat :: Electron :: pfCandidateRef ()

Definition at line 65 of file BPHTrackReference.h.

Referenced by BPHDecayVertex::tTracks().

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

Referenced by getElecPF().