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

◆ CovarianceMatrix

Definition at line 21 of file CandCommonVertexFitter.h.

Constructor & Destructor Documentation

◆ CandCommonVertexFitterBase()

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

Definition at line 22 of file CandCommonVertexFitter.h.

22 : bField_(nullptr) {}

◆ ~CandCommonVertexFitterBase()

virtual CandCommonVertexFitterBase::~CandCommonVertexFitterBase ( )
inlinevirtual

Definition at line 23 of file CandCommonVertexFitter.h.

23 {}

Member Function Documentation

◆ fill()

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 HltBtagPostValidation_cff::c, DMR_cfg::cerr, ztail::d, d1, BPhysicsValidation_cfi::daughters, Exception, ntuplemaker::fill, edm::errors::InvalidReference, dqmiolumiharvest::j, and DiMuonV_cfg::tracks.

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 }
TrackType
track type
Definition: RecoCandidate.h:56
void fill(std::vector< reco::TransientTrack > &, std::vector< reco::Candidate *> &, std::vector< reco::RecoCandidate::TrackType > &, reco::Candidate &) const
d
Definition: ztail.py:151
static constexpr float d1

◆ fit()

virtual bool CandCommonVertexFitterBase::fit ( TransientVertex ,
const std::vector< reco::TransientTrack > &   
) const
protectedpure virtual

◆ set() [1/2]

void CandCommonVertexFitterBase::set ( const MagneticField bField)
inline

◆ set() [2/2]

void CandCommonVertexFitterBase::set ( reco::VertexCompositeCandidate c) const

Definition at line 9 of file CandCommonVertexFitter.cc.

References cms::cuda::assert(), HltBtagPostValidation_cff::c, BPhysicsValidation_cfi::daughters, hcalRecHitTable_cff::energy, reco::Candidate::energy(), Exception, ntuplemaker::fill, l1tPhase2CaloJetEmulator_cfi::fit, edm::errors::InvalidReference, EgHLTOffHistBins_cfi::mass, reco::Candidate::mass(), AlCaHLTBitMon_ParallelJobs::p, multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, reco::RecoCandidate::recoTrackType, pfClustersFromCombinedCaloHF_cfi::scale, reco::Candidate::setP4(), reco::Candidate::setVertex(), mathSSE::sqrt(), HLT_2024v14_cff::track, DiMuonV_cfg::tracks, findQualityFiles::v, bphysicsOniaDQM_cfi::vertex, and L1BJetProducer_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  }
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_);
53  c.setCovariance(cov_);
54  } else {
55  c.setChi2AndNdof(chi2_ = -1, ndof_ = 0);
56  c.setCovariance(cov_ = CovarianceMatrix(ROOT::Math::SMatrixIdentity()));
57  }
58 }
virtual double energy() const =0
energy
virtual void setP4(const LorentzVector &p4)=0
set 4-momentum
virtual double mass() const =0
mass
reco::Vertex::CovarianceMatrix CovarianceMatrix
assert(be >=bs)
void fill(std::vector< reco::TransientTrack > &, std::vector< reco::Candidate *> &, std::vector< reco::RecoCandidate::TrackType > &, reco::Candidate &) const
CovarianceMatrix cov_
covariance matrix (3x3)
T sqrt(T t)
Definition: SSEVec.h:19
virtual void setVertex(const Point &vertex)=0
set vertex
double ndof_
number of degrees of freedom
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
math::XYZPoint Point
point in the space
Definition: Candidate.h:40
virtual bool fit(TransientVertex &, const std::vector< reco::TransientTrack > &) const =0

Member Data Documentation

◆ bField_

const MagneticField* CandCommonVertexFitterBase::bField_
protected

Definition at line 28 of file CandCommonVertexFitter.h.

Referenced by set().

◆ chi2_

double CandCommonVertexFitterBase::chi2_
mutableprotected

chi-sqared

Definition at line 35 of file CandCommonVertexFitter.h.

◆ cov_

CovarianceMatrix CandCommonVertexFitterBase::cov_
mutableprotected

covariance matrix (3x3)

Definition at line 39 of file CandCommonVertexFitter.h.

◆ ndof_

double CandCommonVertexFitterBase::ndof_
mutableprotected

number of degrees of freedom

Definition at line 37 of file CandCommonVertexFitter.h.