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 38 of file BPHTrackReference.h.

Member Typedef Documentation

Definition at line 42 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 235 of file BPHTrackReference.h.

235  {
236 // std::cout << "getElecPF" << std::endl;
237  const pat::Electron* el = dynamic_cast<const pat::Electron*>( &rc );
238  if ( el == nullptr ) return nullptr;
239  return getElecPF( el );
240  }
Analysis-level electron class.
Definition: Electron.h:52
static const reco::Track * getElecPF(const reco::Candidate &rc)
static const reco::Track* BPHTrackReference::getElecPF ( const pat::Electron el)
inlinestatic

Definition at line 241 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.

241  {
242  try {
243  const reco::PFCandidateRef& pcr = el->pfCandidateRef();
244  if ( pcr.isNonnull() && pcr.isAvailable() ) {
245  const reco::TrackRef& tkr = pcr->trackRef();
246  if ( tkr.isNonnull() && tkr.isAvailable() ) return tkr.get();
247  }
248  }
249  catch ( edm::Exception const& ) {
250  }
251  return nullptr;
252  }
bool isAvailable() const
Definition: Ref.h:577
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
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:245
static const reco::Track* BPHTrackReference::getFromBT ( const reco::Candidate rc)
inlinestatic

Definition at line 131 of file BPHTrackReference.h.

References reco::Candidate::bestTrack().

131  {
132 // std::cout << "getFromBT" << std::endl;
133  try {
134  const reco::Track* trk = rc.bestTrack();
135  return trk;
136  }
137  catch ( edm::Exception const& ) {
138  }
139  return nullptr;
140  }
virtual const Track * bestTrack() const
Definition: Candidate.h:247
static const reco::Track* BPHTrackReference::getFromGP ( const reco::Candidate rc)
inlinestatic

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

118  {
119 // std::cout << "getFromGC" << std::endl;
120  const pat::GenericParticle* gp =
121  dynamic_cast<const pat::GenericParticle*>( &rc );
122  if ( gp == nullptr ) return nullptr;
123  try {
124  const reco::TrackRef& tkr = gp->track();
125  if ( tkr.isNonnull() && tkr.isAvailable() ) return tkr.get();
126  }
127  catch ( edm::Exception const& ) {
128  }
129  return nullptr;
130  }
bool isAvailable() const
Definition: Ref.h:577
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
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:245
reco::TrackRef track() const override
static const reco::Track* BPHTrackReference::getFromPC ( const reco::Candidate rc)
inlinestatic

Definition at line 141 of file BPHTrackReference.h.

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

141  {
142 // std::cout << "getFromPC" << std::endl;
143  const pat::PackedCandidate* pp =
144  dynamic_cast<const pat::PackedCandidate*>( &rc );
145  if ( pp == nullptr ) return nullptr;
146  try {
147  const reco::Track* trk = &pp->pseudoTrack();
148  return trk;
149  }
150  catch ( edm::Exception const& ) {
151  }
152  return nullptr;
153  }
virtual const reco::Track & pseudoTrack() const
Return reference to a pseudo track made with candidate kinematics, parameterized error for eta...
static const reco::Track* BPHTrackReference::getFromPF ( const reco::Candidate rc)
inlinestatic

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

105  {
106 // std::cout << "getFromPF" << std::endl;
107  const reco::PFCandidate* pf =
108  dynamic_cast<const reco::PFCandidate*>( &rc );
109  if ( pf == nullptr ) return nullptr;
110  try {
111  const reco::TrackRef& tkr = pf->trackRef();
112  if ( tkr.isNonnull() && tkr.isAvailable() ) return tkr.get();
113  }
114  catch ( edm::Exception const& ) {
115  }
116  return nullptr;
117  }
bool isAvailable() const
Definition: Ref.h:577
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:442
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:245
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 95 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().

95  {
96 // std::cout << "getFromRC" << std::endl;
97  try {
98  const reco::TrackRef& tkr = rc.get<reco::TrackRef>();
99  if ( tkr.isNonnull() && tkr.isAvailable() ) return tkr.get();
100  }
101  catch ( edm::Exception const& ) {
102  }
103  return nullptr;
104  }
bool isAvailable() const
Definition: Ref.h:577
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:245
T get() const
get a component
Definition: Candidate.h:217
static const reco::Track* BPHTrackReference::getMuonBT ( const reco::Candidate rc)
inlinestatic

Definition at line 172 of file BPHTrackReference.h.

References RPCpg::mu.

172  {
173 // std::cout << "getMuonBT" << std::endl;
174  const reco::Muon* mu = dynamic_cast<const reco::Muon*>( &rc );
175  if ( mu == nullptr ) return nullptr;
176  return getMuonBT( mu );
177  }
const int mu
Definition: Constants.h:22
static const reco::Track * getMuonBT(const reco::Candidate &rc)
static const reco::Track* BPHTrackReference::getMuonBT ( const reco::Muon mu)
inlinestatic

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

178  {
179  try {
180  const reco::TrackRef& tkr = mu->muonBestTrack();
181  if ( tkr.isNonnull() && tkr.isAvailable() ) return tkr.get();
182  }
183  catch ( edm::Exception const& ) {
184  }
185  return nullptr;
186  }
bool isAvailable() const
Definition: Ref.h:577
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
virtual TrackRef muonBestTrack() const
Definition: Muon.h:63
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:245
static const reco::Track* BPHTrackReference::getMuonGT ( const reco::Candidate rc)
inlinestatic

Definition at line 203 of file BPHTrackReference.h.

References RPCpg::mu.

203  {
204 // std::cout << "getMuonGT" << std::endl;
205  const pat::Muon* mu = dynamic_cast<const pat::Muon*>( &rc );
206  if ( mu == nullptr ) return nullptr;
207  return getMuonGT( mu );
208  }
static const reco::Track * getMuonGT(const reco::Candidate &rc)
const int mu
Definition: Constants.h:22
Analysis-level muon class.
Definition: Muon.h:50
static const reco::Track* BPHTrackReference::getMuonGT ( const pat::Muon mu)
inlinestatic

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

209  {
210  if ( !mu->isGlobalMuon() ) return nullptr;
211  try {
212  const reco::TrackRef& mgt = mu->globalTrack();
213  if ( mgt.isNonnull() && mgt.isAvailable() ) return mgt.get();
214  }
215  catch ( edm::Exception const& ) {
216  }
217  return nullptr;
218  }
bool isAvailable() const
Definition: Ref.h:577
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
bool isGlobalMuon() const override
Definition: Muon.h:276
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:245
reco::TrackRef globalTrack() const override
reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon) ...
Definition: Muon.h:81
static const reco::Track* BPHTrackReference::getMuonIT ( const reco::Candidate rc)
inlinestatic

Definition at line 187 of file BPHTrackReference.h.

References RPCpg::mu.

187  {
188 // std::cout << "getMuonIT" << std::endl;
189  const pat::Muon* mu = dynamic_cast<const pat::Muon*>( &rc );
190  if ( mu == nullptr ) return nullptr;
191  return getMuonIT( mu );
192  }
static const reco::Track * getMuonIT(const reco::Candidate &rc)
const int mu
Definition: Constants.h:22
Analysis-level muon class.
Definition: Muon.h:50
static const reco::Track* BPHTrackReference::getMuonIT ( const pat::Muon mu)
inlinestatic

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

193  {
194  if ( !mu->isTrackerMuon() ) return nullptr;
195  try {
196  const reco::TrackRef& mit = mu->innerTrack();
197  if ( mit.isNonnull() && mit.isAvailable() ) return mit.get();
198  }
199  catch ( edm::Exception const& ) {
200  }
201  return nullptr;
202  }
bool isAvailable() const
Definition: Ref.h:577
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
bool isTrackerMuon() const override
Definition: Muon.h:277
reco::TrackRef innerTrack() const override
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.h:73
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:245
static const reco::Track* BPHTrackReference::getMuonPF ( const reco::Candidate rc)
inlinestatic

Definition at line 154 of file BPHTrackReference.h.

References RPCpg::mu.

154  {
155 // std::cout << "getMuonPF" << std::endl;
156  const pat::Muon* mu = dynamic_cast<const pat::Muon*>( &rc );
157  if ( mu == nullptr ) return nullptr;
158  return getMuonPF( mu );
159  }
static const reco::Track * getMuonPF(const reco::Candidate &rc)
const int mu
Definition: Constants.h:22
Analysis-level muon class.
Definition: Muon.h:50
static const reco::Track* BPHTrackReference::getMuonPF ( const pat::Muon mu)
inlinestatic

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

160  {
161  try {
162  const reco::PFCandidateRef& pcr = mu->pfCandidateRef();
163  if ( pcr.isNonnull() && pcr.isAvailable() ) {
164  const reco::TrackRef& tkr = pcr->trackRef();
165  if ( tkr.isNonnull() && tkr.isAvailable() ) return tkr.get();
166  }
167  }
168  catch ( edm::Exception const& ) {
169  }
170  return nullptr;
171  }
bool isAvailable() const
Definition: Ref.h:577
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
reco::PFCandidateRef pfCandidateRef() const
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:245
static const reco::Track* BPHTrackReference::getMuonSA ( const reco::Candidate rc)
inlinestatic

Definition at line 219 of file BPHTrackReference.h.

References RPCpg::mu.

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

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

225  {
226  if ( !mu->isStandAloneMuon() ) return nullptr;
227  try {
228  const reco::TrackRef& msa = mu->standAloneMuon();
229  if ( msa.isNonnull() && msa.isAvailable() ) return msa.get();
230  }
231  catch ( edm::Exception const& ) {
232  }
233  return nullptr;
234  }
bool isAvailable() const
Definition: Ref.h:577
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
bool isStandAloneMuon() const override
Definition: Muon.h:278
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:245
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 68 of file BPHTrackReference.h.

Referenced by BPHDecayVertex::tTracks().

70  {
71  if ( rc.charge() == 0 ) return nullptr;
72  const char* mptr = modeList;
73  char c;
74  if ( modeFlag == nullptr ) modeFlag = &c;
75  char& mode = *modeFlag;
76  const reco::Track* tkp = nullptr;
77  while ( ( mode = *mptr++ ) ) {
78  switch ( mode ) {
79  case 'c': if ( ( tkp = getFromRC( rc ) ) != nullptr ) return tkp; break;
80  case 'f': if ( ( tkp = getFromPF( rc ) ) != nullptr ) return tkp; break;
81  case 'h': if ( ( tkp = getFromGP( rc ) ) != nullptr ) return tkp; break;
82  case 'b': if ( ( tkp = getFromBT( rc ) ) != nullptr ) return tkp; break;
83  case 'p': if ( ( tkp = getFromPC( rc ) ) != nullptr ) return tkp; break;
84  case 'm': if ( ( tkp = getMuonPF( rc ) ) != nullptr ) return tkp; break;
85  case 'n': if ( ( tkp = getMuonBT( rc ) ) != nullptr ) return tkp; break;
86  case 'i': if ( ( tkp = getMuonIT( rc ) ) != nullptr ) return tkp; break;
87  case 'g': if ( ( tkp = getMuonGT( rc ) ) != nullptr ) return tkp; break;
88  case 's': if ( ( tkp = getMuonSA( rc ) ) != nullptr ) return tkp; break;
89  case 'e': if ( ( tkp = getElecPF( rc ) ) != nullptr ) return tkp; break;
90  }
91  }
92  return nullptr;
93  }
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)
#define nullptr
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().