Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions HelperFunction/interface/HelperFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,20 @@ class HelperFunction
void setdebug(int d){debug_= d;};

//ForZ
double pterr(reco::Candidate *c, bool isData);
double pterr(const reco::Candidate *c, bool isData) const;

//double pterr(pat::Electron electron, bool isData);
//double pterr(pat::Muon muon, bool isData);
double pterr(TLorentzVector fsrPhoton);
double pterr(const TLorentzVector& fsrPhoton) const;

double pterr(reco::GsfElectron* electron, bool isData);
double pterr(reco::Muon* muon, bool isData);
double pterr(const reco::GsfElectron* electron, bool isData) const;
double pterr(const reco::Muon* muon, bool isData) const;

double masserror(std::vector<TLorentzVector> p4s, std::vector<double> pTErrs);
double masserror(const std::vector<TLorentzVector>& p4s,
const std::vector<double>& pTErrs) const;

double masserrorFullCov(std::vector<TLorentzVector> p4s, TMatrixDSym covMatrix);
double masserrorFullCov(const std::vector<TLorentzVector>& p4s,
TMatrixDSym& covMatrix) const;

//double masserror(std::vector<TLorentzVector> p4s, )

Expand Down
33 changes: 20 additions & 13 deletions HelperFunction/src/HelperFunction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ HelperFunction::~HelperFunction()
// member functions
//

double HelperFunction:: masserrorFullCov(std::vector<TLorentzVector> p4s, TMatrixDSym covMatrix){
double HelperFunction:: masserrorFullCov(const std::vector<TLorentzVector>& p4s,
TMatrixDSym& covMatrix) const {

int ndim = 3*p4s.size();
if(debug_) cout<<""<<endl;
Expand Down Expand Up @@ -117,7 +118,8 @@ double HelperFunction:: masserrorFullCov(std::vector<TLorentzVector> p4s, TMatri
}


double HelperFunction::masserror( std::vector<TLorentzVector> Lep, std::vector<double> pterr){
double HelperFunction::masserror( const std::vector<TLorentzVector>& Lep,
const std::vector<double>& pterr) const {
// if(Lep.size()!= pterr.size()!=4) {std::cout<<" Lepsize="<<Lep.size()<<", "<<pterr.size()<<std::endl;}
TLorentzVector compositeParticle ;
for(unsigned int i=0; i<Lep.size(); i++){
Expand All @@ -144,25 +146,25 @@ double HelperFunction::masserror( std::vector<TLorentzVector> Lep, std::vector<d
}


double HelperFunction::pterr( reco::Candidate *c, bool isData){
double HelperFunction::pterr( const reco::Candidate *c, bool isData) const {

reco::GsfElectron *gsf; reco::Muon *mu;
reco::PFCandidate *pf;
const reco::GsfElectron *gsf; const reco::Muon *mu;
const reco::PFCandidate *pf;

pat::Muon *patmu;
const pat::Muon *patmu;

double pterrLep = 0.0;

if ((gsf = dynamic_cast<reco::GsfElectron *> (&(*c)) ) != 0)
if ((gsf = dynamic_cast<const reco::GsfElectron *> (&(*c)) ) != 0)
{
pterrLep=pterr(gsf, isData);
}
else if ((mu = dynamic_cast<reco::Muon *> (&(*c)) ) != 0)
else if ((mu = dynamic_cast<const reco::Muon *> (&(*c)) ) != 0)
{
pterrLep=pterr(mu, isData);
if(debug_)cout<<"reco pt err is "<<pterrLep<<endl;

if( (patmu = dynamic_cast<pat::Muon *> (&(*c)) )!=0){
if( (patmu = dynamic_cast<const pat::Muon *> (&(*c)) )!=0){

if ( patmu->hasUserFloat("correctedPtError") == true ) {
if(debug_) cout<<"use userFloat for muon pt err"<<endl;
Expand All @@ -172,24 +174,29 @@ double HelperFunction::pterr( reco::Candidate *c, bool isData){

}
}
else if ((pf = dynamic_cast<reco::PFCandidate *> (&(*c)) ) != 0)
else if ((pf = dynamic_cast<const reco::PFCandidate *> (&(*c)) ) != 0)
{
pterrLep=pterr(c, isData);
}
else
throw cms::Exception("InvalidCast") << "KinZFitter only takes particles "
<< "whose pointers can be cast to "
<< "electrons, muons, or PFCandidates"
<< std::endl;


return pterrLep;

}

double HelperFunction::pterr( reco::Muon* mu, bool isData){
double HelperFunction::pterr( const reco::Muon* mu, bool isData) const {

double pterr = mu->muonBestTrack()->ptError();

return pterr;
}

double HelperFunction::pterr( reco::GsfElectron * elec, bool isData ){
double HelperFunction::pterr( const reco::GsfElectron * elec, bool isData ) const {

if(debug_) cout<<"reco:gsfelectron pt err"<<endl;

Expand Down Expand Up @@ -224,7 +231,7 @@ double HelperFunction::pterr( reco::GsfElectron * elec, bool isData ){
}


double HelperFunction::pterr(TLorentzVector ph){
double HelperFunction::pterr(const TLorentzVector& ph) const {

if(debug_) cout<<"perr for pf photon"<<endl;

Expand Down
42 changes: 24 additions & 18 deletions KinZfitter/interface/KinZfitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,15 @@ class KinZfitter {
public:

KinZfitter(bool isData);
~KinZfitter();

/// Kinematic fit of lepton momenta
/// HelperFunction class to calcluate per lepton(+photon) pT error
void Setup(std::vector< reco::Candidate* > selectedLeptons, std::map<unsigned int, TLorentzVector> selectedFsrPhotons);
void Setup(const std::vector< const reco::Candidate* >& selectedLeptons,
const std::map<unsigned int, TLorentzVector>& selectedFsrPhotons);
/// For backwards compatibility
void Setup(const std::vector< reco::Candidate* >& selectedLeptons,
const std::map<unsigned int, TLorentzVector>& selectedFsrPhotons);

///
void KinRefitZ();
Expand All @@ -70,17 +75,17 @@ class KinZfitter {
double l3, double l4, double lph3, double lph4);

// result wrappers
double GetRefitM4l();
double GetM4l();
double GetRefitMZ1();
double GetRefitMZ2();
double GetMZ1();
double GetMZ2();

double GetMZ1Err();
double GetRefitM4lErr();
double GetM4lErr();
double GetRefitM4lErrFullCov();
double GetRefitM4l() const;
double GetM4l() const;
double GetRefitMZ1() const;
double GetRefitMZ2() const;
double GetMZ1() const;
double GetMZ2() const;

double GetMZ1Err() const;
double GetRefitM4lErr() const;
double GetM4lErr() const;
double GetRefitM4lErrFullCov() const;

// cov matrix change for spherical coordinate to Cartisean coordinates

Expand All @@ -99,8 +104,8 @@ class KinZfitter {
TMatrixDSym GetRefitZZOFBigCov();
*/

std::vector<TLorentzVector> GetRefitP4s();
std::vector<TLorentzVector> GetP4s();
std::vector<TLorentzVector> GetRefitP4s() const;
std::vector<TLorentzVector> GetP4s() const;

////////////////

Expand Down Expand Up @@ -147,11 +152,12 @@ class KinZfitter {
/// HelperFunction class to calcluate per lepton(+photon) pT error
HelperFunction * helperFunc_;

void initZs(std::vector< reco::Candidate* > selectedLeptons, std::map<unsigned int, TLorentzVector> selectedFsrPhoton);
void initZs(const std::vector< const reco::Candidate* >& selectedLeptons,
const std::map<unsigned int, TLorentzVector>& selectedFsrPhoton);

void SetFitInput(FitInput &input,
vector<TLorentzVector> ZLep, vector<double> ZLepErr,
vector<TLorentzVector> ZGamma, vector<double> ZGammaErr);
const vector<TLorentzVector>& ZLep, const vector<double>& ZLepErr,
const vector<TLorentzVector>& ZGamma, const vector<double>& ZGammaErr);

void SetFitOutput(FitInput &input, FitOutput &output,
double &l1, double &l2, double &lph1, double &lph2,
Expand All @@ -170,7 +176,7 @@ class KinZfitter {
vector<TLorentzVector> &Z2Gamma, vector<double> &Z2GammaErr,
vector<int> &Z1id, vector<int> &Z2id);

bool IsFourEFourMu(vector<int> &Z1id, vector<int> &Z2id);
bool IsFourEFourMu(const vector<int> &Z1id, const vector<int> &Z2id) const;
/// lepton ids for Z1 Z2
std::vector<int> idsZ1_, idsZ2_;
/// lepton ids that fsr photon associated to
Expand Down
Loading