src
PhysicsTools
RecoUtils
src
CandMassKinFitter.cc
Go to the documentation of this file.
1
#include "
PhysicsTools/RecoUtils/interface/CandMassKinFitter.h
"
2
#include "
PhysicsTools/KinFitter/interface/TKinFitter.h
"
3
#include "
DataFormats/RecoCandidate/interface/RecoCandidate.h
"
4
#include "
PhysicsTools/KinFitter/interface/TFitConstraintM.h
"
5
#include "
PhysicsTools/KinFitter/interface/TFitParticleMCCart.h
"
6
#include "TMatrixD.h"
7
#include <iostream>
8
using namespace
reco
;
9
using namespace
std
;
10
11
FitQuality
CandMassKinFitter::set
(
Candidate
&
c
)
const
{
12
TKinFitter
fitter(
"CandMassFit"
,
"CandMassFit"
);
13
TString
name
(
"dau0"
);
14
size_t
daus =
c
.numberOfDaughters();
15
vector<TMatrixD>
errors
(daus, TMatrix(3, 3));
16
vector<TVector3> momenta(daus);
17
vector<TFitParticleMCCart*>
particles
(daus,
nullptr
);
18
TFitConstraintM
constraint
(
"MassConstraint"
,
"MassConstraint"
,
nullptr
,
nullptr
, mass_);
19
for
(
size_t
i
= 0;
i
< daus; ++
i
) {
20
const
Candidate
& dau = *
c
.daughter(
i
);
21
const
Particle::LorentzVector
& p4 = dau.
p4
();
22
TMatrixD&
err
=
errors
[
i
];
23
TVector3& mom = momenta[
i
];
24
mom = TVector3(p4.px(), p4.py(), p4.pz());
25
TrackRef
trk = dau.
get
<
TrackRef
>();
26
// dummy errors for now...
27
// should play with track parametrization...
28
err
.Zero();
29
err
(0, 0) = 0.1;
30
err
(1, 1) = 0.1;
31
err
(2, 2) = 0.1;
32
fitter.
addMeasParticle
(
particles
[
i
] =
new
TFitParticleMCCart
(
name
,
name
, &mom, dau.
mass
(), &
err
));
33
name
[3]++;
34
constraint
.addParticle1(
particles
[
i
]);
35
}
36
fitter.
addConstraint
(&
constraint
);
37
fitter.
setMaxNbIter
(30);
38
fitter.
setMaxDeltaS
(1
e
-2);
39
fitter.
setMaxF
(1
e
-1);
40
fitter.
setVerbosity
(0);
41
fitter.
fit
();
42
// if ( fitter->getStatus() != 0 ) throw ...
43
TLorentzVector sum(0, 0, 0, 0);
44
for
(
size_t
i
= 0;
i
< daus; ++
i
) {
45
Candidate
& dau = *
c
.daughter(
i
);
46
TFitParticleMCCart
*
part
=
particles
[
i
];
47
const
TLorentzVector* p4 =
part
->getCurr4Vec();
48
dau.
setP4
(
Particle::LorentzVector
(p4->X(), p4->Y(), p4->Z(), p4->T()));
49
sum += *p4;
50
delete
particles
[
i
];
51
}
52
c
.setP4(
Particle::LorentzVector
(sum.X(), sum.Y(), sum.Z(), sum.T()));
53
return
FitQuality
(fitter.
getS
(), fitter.
getNDF
());
54
}
TFitConstraintM
Definition:
TFitConstraintM.h:11
TFitParticleMCCart
Definition:
TFitParticleMCCart.h:9
TKinFitter::setMaxF
void setMaxF(Double_t maxF)
Definition:
TKinFitter.h:54
mps_fire.i
i
Definition:
mps_fire.py:429
ecalTrigSettings_cff.particles
particles
Definition:
ecalTrigSettings_cff.py:11
TKinFitter::fit
Int_t fit()
Definition:
TKinFitter.cc:318
reco::Candidate::setP4
virtual void setP4(const LorentzVector &p4)=0
set 4-momentum
TKinFitter::setMaxDeltaS
void setMaxDeltaS(Double_t maxDeltaS)
Definition:
TKinFitter.h:52
edm::Ref< TrackCollection >
reco::Candidate::get
T get() const
get a component
Definition:
Candidate.h:221
reco::Candidate::mass
virtual double mass() const =0
mass
reco::Candidate
Definition:
Candidate.h:27
std
Definition:
JetResolutionObject.h:76
MillePedeFileConverter_cfg.e
e
Definition:
MillePedeFileConverter_cfg.py:37
TKinFitter.h
HltBtagPostValidation_cff.c
c
Definition:
HltBtagPostValidation_cff.py:35
TKinFitter::getS
Double_t getS()
Definition:
TKinFitter.cc:1066
submitPVResolutionJobs.err
err
Definition:
submitPVResolutionJobs.py:85
nano_mu_digi_cff.errors
errors
Definition:
nano_mu_digi_cff.py:96
TKinFitter
Definition:
TKinFitter.h:13
CandMassKinFitter.h
TKinFitter::addConstraint
void addConstraint(TAbsFitConstraint *constraint)
Definition:
TKinFitter.cc:292
TKinFitter::getNDF
Int_t getNDF()
Definition:
TKinFitter.h:45
TKinFitter::addMeasParticle
void addMeasParticle(TAbsFitParticle *particle)
Definition:
TKinFitter.cc:194
TKinFitter::setVerbosity
void setVerbosity(Int_t verbosity=1)
Definition:
TKinFitter.cc:304
CandMassKinFitter::set
reco::FitQuality set(reco::Candidate &) const
Definition:
CandMassKinFitter.cc:11
HLT_2023v12_cff.constraint
constraint
Definition:
HLT_2023v12_cff.py:38738
TFitParticleMCCart.h
part
part
Definition:
HCALResponse.h:20
TFitConstraintM.h
TKinFitter::setMaxNbIter
void setMaxNbIter(Int_t maxNbIter)
Definition:
TKinFitter.h:48
reco
fixed size matrix
Definition:
AlignmentAlgorithmBase.h:46
errors
Definition:
errors.py:1
FitQuality
FitQuality
Definition:
Fit.h:30
reco::FitQuality
Definition:
FitQuality.h:16
reco::Particle::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition:
Particle.h:21
RecoCandidate.h
Skims_PA_cff.name
name
Definition:
Skims_PA_cff.py:17
reco::Candidate::p4
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
Generated for CMSSW Reference Manual by
1.8.14