CMS 3D CMS Logo

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

#include <CandCommonVertexFitter.h>

Inheritance diagram for CandCommonVertexFitterBase:
CandCommonVertexFitter< Fitter >

Public Types

typedef reco::Vertex::CovarianceMatrix CovarianceMatrix
 

Public Member Functions

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

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_
 
double chi2_
 chi-sqared More...
 
CovarianceMatrix cov_
 covariance matrix (3x3) More...
 
double ndof_
 number of degrees of freedom More...
 

Detailed Description

Definition at line 19 of file CandCommonVertexFitter.h.

Member Typedef Documentation

Definition at line 21 of file CandCommonVertexFitter.h.

Constructor & Destructor Documentation

CandCommonVertexFitterBase::CandCommonVertexFitterBase ( const edm::ParameterSet )
inline

Definition at line 22 of file CandCommonVertexFitter.h.

22 : bField_(nullptr) {}
virtual CandCommonVertexFitterBase::~CandCommonVertexFitterBase ( )
inlinevirtual

Definition at line 23 of file CandCommonVertexFitter.h.

23 {}

Member Function Documentation

void CandCommonVertexFitterBase::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 60 of file CandCommonVertexFitter.cc.

References beam_dqm_sourceclient-live_cfg::cerr, ztail::d, reco::Candidate::daughter(), Exception, ntuplemaker::fill, reco::Candidate::get(), edm::errors::InvalidReference, dqmiolumiharvest::j, reco::Candidate::numberOfDaughters(), and reco::Candidate::pdgId().

63  {
64  size_t nDau = c.numberOfDaughters();
65  for (unsigned int j = 0; j < nDau; ++j) {
66  Candidate *d = c.daughter(j);
67  if (d == nullptr) {
68  ostringstream message;
69  message << "Can't access in write mode candidate daughters. "
70  << "pdgId = " << c.pdgId() << ".\n";
71  const Candidate *d1 = c.daughter(j);
72  if (d1 == nullptr)
73  message << "Null daughter also found in read-only mode\n";
74  else
75  message << "Daughter found in read-only mode with id: " << d1->pdgId() << "\n";
76  throw edm::Exception(edm::errors::InvalidReference) << message.str();
77  }
78  if (d->numberOfDaughters() > 0)
79  fill(tracks, daughters, trackTypes, *d);
80  else {
81  const Track *trk = d->get<const Track *>();
83  if (trk != nullptr) {
84  tracks.push_back(TransientTrack(*trk, bField_));
85  daughters.push_back(d);
86  trackTypes.push_back(type);
87  } else {
88  cerr << ">>> warning: candidate of type " << d->pdgId() << " has no track reference." << endl;
89  }
90  }
91  }
92 }
type
Definition: HCALResponse.h:21
TrackType
track type
Definition: RecoCandidate.h:56
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
virtual int pdgId() const =0
PDG identifier.
d
Definition: ztail.py:151
void fill(std::vector< reco::TransientTrack > &, std::vector< reco::Candidate * > &, std::vector< reco::RecoCandidate::TrackType > &, reco::Candidate &) const
T get() const
get a component
Definition: Candidate.h:222
virtual size_type numberOfDaughters() const =0
number of daughters
virtual bool CandCommonVertexFitterBase::fit ( TransientVertex ,
const std::vector< reco::TransientTrack > &   
) const
protectedpure virtual
void CandCommonVertexFitterBase::set ( const MagneticField bField)
inline
void CandCommonVertexFitterBase::set ( reco::VertexCompositeCandidate c) const

Definition at line 9 of file CandCommonVertexFitter.cc.

References reco::Vertex::chi2(), BPhysicsValidation_cfi::daughters, HCALHighEnergyHPDFilter_cfi::energy, reco::Candidate::energy(), Exception, reco::Vertex::fill(), ntuplemaker::fill, trackingPlots::fit, edm::errors::InvalidReference, EgHLTOffHistBins_cfi::mass, reco::Candidate::mass(), reco::Vertex::ndof(), AlCaHLTBitMon_ParallelJobs::p, reco::TrackBase::p(), multPhiCorr_741_25nsDY_cfi::px, reco::TrackBase::px(), multPhiCorr_741_25nsDY_cfi::py, reco::TrackBase::py(), reco::TrackBase::pz(), reco::RecoCandidate::recoTrackType, Scenarios_cff::scale, reco::VertexCompositeCandidate::setChi2AndNdof(), reco::VertexCompositeCandidate::setCovariance(), reco::Candidate::setP4(), reco::LeafCandidate::setP4(), reco::Candidate::setVertex(), reco::LeafCandidate::setVertex(), mathSSE::sqrt(), HLT_2018_cff::track, PDWG_EXOHSCP_cff::tracks, findQualityFiles::v, bphysicsOniaDQM_cfi::vertex, and badGlobalMuonTaggersAOD_cff::vtx.

9  {
10  if (bField_ == nullptr)
12  << "B-Field was not set up CandCommonVertexFitter.\n"
13  << "the following method must be called before fitting a candidate:\n"
14  << " CandCommonVertexFitter:.set( const MagneticField * )" << endl;
15  vector<TransientTrack> tracks;
16  vector<Candidate *> daughters;
17  vector<RecoCandidate::TrackType> trackTypes;
18  fill(tracks, daughters, trackTypes, c);
19  assert(tracks.size() == daughters.size());
21  if (fit(vertex, tracks)) {
22  tracks = vertex.refittedTracks();
23  Candidate::Point vtx(vertex.position());
24  c.setVertex(vtx);
25  vector<TransientTrack>::const_iterator trackIt = tracks.begin(), tracksEnd = tracks.end();
26  vector<Candidate *>::const_iterator daughterIt = daughters.begin();
27  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;
42  py *= scale;
43  pz *= scale;
44  }
45  Candidate::LorentzVector dp4(px, py, pz, energy);
46  daughter.setP4(dp4);
47  mp4 += dp4;
48  }
49  c.setP4(mp4);
50  Vertex v = vertex;
51  c.setChi2AndNdof(chi2_ = v.chi2(), ndof_ = v.ndof());
52  v.fill(cov_);
54  } else {
55  c.setChi2AndNdof(chi2_ = -1, ndof_ = 0);
56  c.setCovariance(cov_ = CovarianceMatrix(ROOT::Math::SMatrixIdentity()));
57  }
58 }
double p() const
momentum vector magnitude
Definition: TrackBase.h:599
void fill(CovarianceMatrix &v) const
fill SMatrix
virtual void setP4(const LorentzVector &p4)=0
set 4-momentum
reco::Vertex::CovarianceMatrix CovarianceMatrix
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:605
void setVertex(const Point &vertex) override
set vertex
CovarianceMatrix cov_
covariance matrix (3x3)
void setChi2AndNdof(double chi2, double ndof)
set chi2 and ndof
virtual double energy() const =0
energy
T sqrt(T t)
Definition: SSEVec.h:19
virtual void setVertex(const Point &vertex)=0
set vertex
void setCovariance(const CovarianceMatrix &m)
set covariance matrix
double chi2() const
chi-squares
Definition: Vertex.h:102
void fill(std::vector< reco::TransientTrack > &, std::vector< reco::Candidate * > &, std::vector< reco::RecoCandidate::TrackType > &, reco::Candidate &) const
double ndof() const
Definition: Vertex.h:109
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:611
virtual double mass() const =0
mass
double ndof_
number of degrees of freedom
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
math::XYZPoint Point
point in the space
Definition: Candidate.h:41
virtual bool fit(TransientVertex &, const std::vector< reco::TransientTrack > &) const =0
void setP4(const LorentzVector &p4) final
set 4-momentum
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:608

Member Data Documentation

const MagneticField* CandCommonVertexFitterBase::bField_
protected

Definition at line 28 of file CandCommonVertexFitter.h.

double CandCommonVertexFitterBase::chi2_
mutableprotected

chi-sqared

Definition at line 35 of file CandCommonVertexFitter.h.

CovarianceMatrix CandCommonVertexFitterBase::cov_
mutableprotected

covariance matrix (3x3)

Definition at line 39 of file CandCommonVertexFitter.h.

double CandCommonVertexFitterBase::ndof_
mutableprotected

number of degrees of freedom

Definition at line 37 of file CandCommonVertexFitter.h.