CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
PFCandCommonVertexFitterBase Class Referenceabstract

#include <PFCandCommonVertexFitter.h>

Inheritance diagram for PFCandCommonVertexFitterBase:
PFCandCommonVertexFitter< Fitter >

Public Types

typedef reco::Vertex::CovarianceMatrix CovarianceMatrix
 

Public Member Functions

 PFCandCommonVertexFitterBase (const edm::ParameterSet &)
 
void set (const MagneticField *bField)
 
void set (reco::VertexCompositeCandidate &) const
 
virtual ~PFCandCommonVertexFitterBase ()
 

Protected Member Functions

void fill (std::vector< reco::TransientTrack > &, std::vector< reco::Candidate * > &, std::vector< reco::RecoCandidate::TrackType > &, reco::Candidate &) const
 
virtual bool fit (TransientVertex &, const std::vector< reco::TransientTrack > &) const =0
 

Protected Attributes

const MagneticFieldbField_
 

Detailed Description

Definition at line 23 of file PFCandCommonVertexFitter.h.

Member Typedef Documentation

Definition at line 25 of file PFCandCommonVertexFitter.h.

Constructor & Destructor Documentation

PFCandCommonVertexFitterBase::PFCandCommonVertexFitterBase ( const edm::ParameterSet )
inline

Definition at line 26 of file PFCandCommonVertexFitter.h.

26 : bField_(nullptr) { }
virtual PFCandCommonVertexFitterBase::~PFCandCommonVertexFitterBase ( )
inlinevirtual

Definition at line 27 of file PFCandCommonVertexFitter.h.

27 { }

Member Function Documentation

void PFCandCommonVertexFitterBase::fill ( std::vector< reco::TransientTrack > &  tracks,
std::vector< reco::Candidate * > &  daughters,
std::vector< reco::RecoCandidate::TrackType > &  trackTypes,
reco::Candidate c 
) const
protected

Definition at line 57 of file PFCandCommonVertexFitter.cc.

References MessageLogger_cfi::cerr, edmIntegrityCheck::d, reco::Candidate::daughter(), Exception, lumiContext::fill, edm::RefToBase< T >::get(), edm::Ref< C, T, F >::get(), reco::Candidate::hasMasterClone(), edm::errors::InvalidReference, reco::Candidate::masterClone(), reco::Candidate::numberOfDaughters(), reco::Candidate::pdgId(), reco::RecoCandidate::recoTrackType, and reco::PFCandidate::trackRef().

60  {
61  size_t nDau = c.numberOfDaughters();
62  for(unsigned int j = 0; j < nDau ; ++j) {
63  Candidate * d = c.daughter(j);
64  if(d == nullptr) {
65  ostringstream message;
66  message << "Can't access in write mode candidate daughters. "
67  << "pdgId = " << c.pdgId() << ".\n";
68  const Candidate * d1 = c.daughter(j);
69  if(d1 == nullptr)
70  message << "Null daughter also found in read-only mode\n";
71  else
72  message << "Daughter found in read-only mode with id: " << d1->pdgId() << "\n";
73  throw edm::Exception(edm::errors::InvalidReference) << message.str();
74  }
75  if(d->numberOfDaughters() > 0)
76  fill(tracks, daughters, trackTypes, * d);
77  else {
78  const Track * trk = nullptr;
79  RecoCandidate::TrackType type = RecoCandidate::recoTrackType;
80  if (d->hasMasterClone())
81  {
82  //get the PFCandidate
83  const PFCandidate* myPFCand = dynamic_cast<const PFCandidate*>(d->masterClone().get());
84  trk = myPFCand->trackRef().get();
85  }
86  if(trk != nullptr) {
87  tracks.push_back(TransientTrack(* trk, bField_));
88  daughters.push_back(d);
89  trackTypes.push_back(type);
90  } else {
91  cerr << ">>> warning: candidate of type " << d->pdgId()
92  << " has no track reference." << endl;
93  }
94  }
95  }
96 }
type
Definition: HCALResponse.h:21
value_type const * get() const
Definition: RefToBase.h:234
TrackType
track type
Definition: RecoCandidate.h:57
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:442
virtual int pdgId() const =0
PDG identifier.
void fill(std::vector< reco::TransientTrack > &, std::vector< reco::Candidate * > &, std::vector< reco::RecoCandidate::TrackType > &, reco::Candidate &) const
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:243
virtual const CandidateBaseRef & masterClone() const =0
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
virtual size_type numberOfDaughters() const =0
number of daughters
virtual bool hasMasterClone() const =0
virtual bool PFCandCommonVertexFitterBase::fit ( TransientVertex ,
const std::vector< reco::TransientTrack > &   
) const
protectedpure virtual
void PFCandCommonVertexFitterBase::set ( const MagneticField bField)
inline
void PFCandCommonVertexFitterBase::set ( reco::VertexCompositeCandidate c) const

Definition at line 9 of file PFCandCommonVertexFitter.cc.

References reco::Vertex::chi2(), reco::Vertex::covariance(), BPhysicsValidation_cfi::daughters, reco::Candidate::energy(), Exception, lumiContext::fill, trackingPlots::fit, edm::errors::InvalidReference, ResonanceBuilder::mass, reco::Candidate::mass(), reco::Vertex::ndof(), AlCaHLTBitMon_ParallelJobs::p, reco::TrackBase::p(), reco::TrackBase::px(), reco::TrackBase::py(), reco::TrackBase::pz(), reco::RecoCandidate::recoTrackType, TransientVertex::refittedTracks(), Scenarios_cff::scale, reco::VertexCompositeCandidate::setChi2AndNdof(), reco::VertexCompositeCandidate::setCovariance(), reco::Candidate::setP4(), reco::LeafCandidate::setP4(), reco::Candidate::setVertex(), reco::LeafCandidate::setVertex(), mathSSE::sqrt(), HiIsolationCommonParameters_cff::track, l1t::tracks, findQualityFiles::v, and badGlobalMuonTaggersAOD_cff::vtx.

9  {
10  if(bField_ == nullptr)
12  << "B-Field was not set up PFCandCommonVertexFitter.\n"
13  << "the following method must be called before fitting a candidate:\n"
14  << " PFCandCommonVertexFitter:.set( const MagneticField * )" << endl;
15  std::vector<TransientTrack> tracks;
16  std::vector<Candidate *> daughters;
17  std::vector<RecoCandidate::TrackType> trackTypes;
18  fill(tracks, daughters, trackTypes, c);
19  assert(tracks.size() == daughters.size());
20  TransientVertex vertex;
21  if(fit(vertex, tracks)) {
22  tracks = vertex.refittedTracks();
23  Candidate::Point vtx(vertex.position());
24  c.setVertex(vtx);
25  std::vector<TransientTrack>::const_iterator trackIt = tracks.begin(), tracksEnd = tracks.end();
26  std::vector<Candidate *>::const_iterator daughterIt = daughters.begin();
27  std::vector<RecoCandidate::TrackType>::const_iterator trackTypeIt = trackTypes.begin();
28  Candidate::LorentzVector mp4(0, 0, 0, 0);
29  for(; trackIt != tracksEnd; ++ trackIt, ++ daughterIt, ++trackTypeIt) {
30  const Track & track = trackIt->track();
31  Candidate & daughter = * * daughterIt;
32  double px = track.px(), py = track.py(), pz = track.pz(), p = track.p();
33  double energy;
34  daughter.setVertex( vtx );
35  if(*trackTypeIt == RecoCandidate::recoTrackType) {
36  double mass = daughter.mass();
37  energy = sqrt(p*p + mass*mass);
38  } else {
39  energy = daughter.energy();
40  double scale = energy / p;
41  px *= scale; py *= scale; pz *= scale;
42  }
43  Candidate::LorentzVector dp4(px, py, pz, energy);
44  daughter.setP4(dp4);
45  mp4 += dp4;
46  }
47  c.setP4(mp4);
48  Vertex v = vertex;
49  c.setChi2AndNdof(v.chi2(), v.ndof());
51  } else {
52  c.setChi2AndNdof(-1, 0);
53  c.setCovariance(CovarianceMatrix(ROOT::Math::SMatrixIdentity()));
54  }
55 }
double p() const
momentum vector magnitude
Definition: TrackBase.h:648
virtual void setP4(const LorentzVector &p4)=0
set 4-momentum
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
Definition: Vertex.h:130
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:660
void setVertex(const Point &vertex) override
set vertex
virtual bool fit(TransientVertex &, const std::vector< reco::TransientTrack > &) const =0
void setChi2AndNdof(double chi2, double ndof)
set chi2 and ndof
virtual double energy() const =0
energy
T sqrt(T t)
Definition: SSEVec.h:18
virtual void setVertex(const Point &vertex)=0
set vertex
void setCovariance(const CovarianceMatrix &m)
set covariance matrix
void fill(std::vector< reco::TransientTrack > &, std::vector< reco::Candidate * > &, std::vector< reco::RecoCandidate::TrackType > &, reco::Candidate &) const
double chi2() const
chi-squares
Definition: Vertex.h:98
double ndof() const
Definition: Vertex.h:105
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:672
virtual double mass() const =0
mass
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
reco::Vertex::CovarianceMatrix CovarianceMatrix
math::XYZPoint Point
point in the space
Definition: Candidate.h:41
std::vector< reco::TransientTrack > const & refittedTracks() const
void setP4(const LorentzVector &p4) final
set 4-momentum
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:666

Member Data Documentation

const MagneticField* PFCandCommonVertexFitterBase::bField_
protected

Definition at line 32 of file PFCandCommonVertexFitter.h.