Skip to content

Commit

Permalink
Merge pull request #2 from akalinow/Artur_CP_variables
Browse files Browse the repository at this point in the history
CP variables
  • Loading branch information
mbluj authored Aug 23, 2016
2 parents 9c295f0 + 8e658e3 commit dcfa471
Show file tree
Hide file tree
Showing 9 changed files with 612 additions and 24 deletions.
15 changes: 14 additions & 1 deletion NtupleProducer/interface/GenHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#ifndef GenHelper_h
#define GenHelper_h

#include "TVector3.h"
#include "TLorentzVector.h"

#include <DataFormats/HepMCCandidate/interface/GenParticle.h>
#include <vector>

Expand Down Expand Up @@ -50,8 +53,18 @@ namespace genhelper {
WDecay GetTopDecay (const reco::Candidate* part); // return final state for top (= final state for W) -> see enum for code

reco::GenParticle GetTauHad (const reco::Candidate* part); // build had tau by summing sons without nu
reco::GenParticle GetTauHadNeutrals (const reco::Candidate* part); // build neutral component of had tau by summing sons without nu

const reco::Candidate* IsFromID (const reco::Candidate* part, int targetPDGId); // find if is son of a certain particle (select by targetPDGId); if not found, return NULL, else return its pointer
int GetIndexInOutput (const reco::Candidate* part, std::vector<const reco::Candidate *> cands);
}

typedef reco::GenParticleCollection::const_iterator IG;
typedef reco::GenParticleRefVector::const_iterator IGR;
TVector3 ImpactParameter(const TVector3& pv, const TVector3& sv, const TLorentzVector& p4);//Calculate generator level impact parameter
void GetTausDaughters(const reco::GenParticle& tau, reco::GenParticleRefVector& products, bool ignoreNus, bool direct);
void FindDescendents(const reco::GenParticle& base, reco::GenParticleRefVector& descendents, int status, int pdgId=0, bool skipPhotonsPi0AndFSR=false);
const reco::GenParticleRef GetLeadChParticle(const reco::GenParticleRefVector& products);
int getDetailedTauDecayMode(const reco::GenParticleRefVector& products);

}
#endif
1 change: 1 addition & 0 deletions NtupleProducer/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<use name="RecoEgamma/EgammaTools" />
<use name="RecoEgamma/ElectronIdentification" />
<use name="HTT-utilities/RecoilCorrections" />
<use name="RecoVertex/AdaptiveVertexFit"/>

<library file="*.cc" name="LLRHiggsTauTauPlugins">
<Flags CPPDEFINES="CMSSW_VERSION=$(shell echo ${CMSSW_VERSION}|sed -e s/CMSSW_// -e s/_//g -e s/patch\.//)"/>
Expand Down
68 changes: 59 additions & 9 deletions NtupleProducer/plugins/GenFiller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,29 @@ void GenFiller::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
if (DEBUG) cout << " --> fromTau: 1, indexTau: " << genhelper::GetIndexInOutput(MothPtr, cands_) << endl;
}


if(filtGenP.hasUserInt("tauGenDecayMode") &&
(filtGenP.hasUserInt("ZMothIndex") || filtGenP.hasUserInt("HMothIndex") || filtGenP.hasUserInt("MSSMHMothIndex"))){

TVector3 aPVGenPoint = TVector3(genPClone->vx(), genPClone->vy(), genPClone->vz());
reco::GenParticleRefVector tauDaughters;
genhelper::GetTausDaughters(*genPClone,tauDaughters,true,false);
int detailedDecayMode = genhelper::getDetailedTauDecayMode(tauDaughters);
filtGenP.addUserInt("tauGenDetailedDecayMode", detailedDecayMode);

reco::GenParticleRef leadChParticleRef = genhelper::GetLeadChParticle(tauDaughters);

TLorentzVector p4LeadingChParticle(leadChParticleRef->px(),
leadChParticleRef->py(),
leadChParticleRef->pz(),
leadChParticleRef->energy());
TVector3 tauDecayVertex(leadChParticleRef->vx(), leadChParticleRef->vy(), leadChParticleRef->vz());
TVector3 pca = genhelper::ImpactParameter(aPVGenPoint, tauDecayVertex, p4LeadingChParticle);
filtGenP.addUserFloat("pca_x",pca.X());
filtGenP.addUserFloat("pca_y",pca.Y());
filtGenP.addUserFloat("pca_z",pca.Z());
}

result->push_back (filtGenP);
}

Expand All @@ -222,24 +245,51 @@ void GenFiller::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
for (unsigned int iTauH = 0; iTauH < tauHadcandsMothers_.size(); iTauH++)
{
int tauMothInd = tauHadcandsMothers_.at(iTauH);
pat::GenericParticle tauH (genhelper::GetTauHad(cands_.at(tauMothInd)));
pat::GenericParticle tauH (genhelper::GetTauHad(cands_.at(tauMothInd)));
pat::GenericParticle tauH_neutral (genhelper::GetTauHadNeutrals(cands_.at(tauMothInd)));
tauH.addUserInt ("TauMothIndex", tauMothInd);
tauH_neutral.addUserInt ("TauMothIndex", tauMothInd);

// copy all the other flags from original tau
pat::GenericParticle& tauMothGenP = result->at(tauMothInd);
if (tauMothGenP.hasUserInt("HMothIndex") ) tauH.addUserInt ("HMothIndex", tauMothGenP.userInt ("HMothIndex"));
if (tauMothGenP.hasUserInt("MSSMHMothIndex") ) tauH.addUserInt ("MSSMHMothIndex", tauMothGenP.userInt ("MSSMHMothIndex"));
if (tauMothGenP.hasUserInt("TopMothIndex") ) tauH.addUserInt ("TopMothIndex", tauMothGenP.userInt ("TopMothIndex"));
if (tauMothGenP.hasUserInt("bMothIndex") ) tauH.addUserInt ("bMothIndex", tauMothGenP.userInt ("bMothIndex"));
if (tauMothGenP.hasUserInt("WMothIndex") ) tauH.addUserInt ("WMothIndex", tauMothGenP.userInt ("WMothIndex"));
if (tauMothGenP.hasUserInt("ZMothIndex") ) tauH.addUserInt ("ZMothIndex", tauMothGenP.userInt ("ZMothIndex"));
if (tauMothGenP.hasUserInt("HMothIndex") ){
tauH.addUserInt ("HMothIndex", tauMothGenP.userInt ("HMothIndex"));
tauH_neutral.addUserInt ("HMothIndex", tauMothGenP.userInt ("HMothIndex"));
}
if (tauMothGenP.hasUserInt("MSSMHMothIndex") ){
tauH.addUserInt ("MSSMHMothIndex", tauMothGenP.userInt ("MSSMHMothIndex"));
tauH_neutral.addUserInt ("MSSMHMothIndex", tauMothGenP.userInt ("MSSMHMothIndex"));
}
if (tauMothGenP.hasUserInt("TopMothIndex") ){
tauH.addUserInt ("TopMothIndex", tauMothGenP.userInt ("TopMothIndex"));
tauH_neutral.addUserInt ("TopMothIndex", tauMothGenP.userInt ("TopMothIndex"));
}
if (tauMothGenP.hasUserInt("bMothIndex") ){
tauH.addUserInt ("bMothIndex", tauMothGenP.userInt ("bMothIndex"));
tauH_neutral.addUserInt ("bMothIndex", tauMothGenP.userInt ("bMothIndex"));
}
if (tauMothGenP.hasUserInt("WMothIndex") ){
tauH.addUserInt ("WMothIndex", tauMothGenP.userInt ("WMothIndex"));
tauH_neutral.addUserInt ("WMothIndex", tauMothGenP.userInt ("WMothIndex"));
}
if (tauMothGenP.hasUserInt("ZMothIndex") ){
tauH.addUserInt ("ZMothIndex", tauMothGenP.userInt ("ZMothIndex"));
tauH_neutral.addUserInt ("ZMothIndex", tauMothGenP.userInt ("ZMothIndex"));
}



// many flags change of meaning w.r.t. mother tau, put everything to 0 (can be changed in future)
int tauhFlags = 0;
tauH.addUserInt ("generalGenFlags", tauhFlags); // remember! TauH inherits ALL the flags from
tauH.addUserInt ("generalGenFlags", tauhFlags); // remember! TauH inherits ALL the flags from
tauH_neutral.addUserInt ("generalGenFlags", tauhFlags); // remember! TauH inherits ALL the flags from

if (DEBUG) cout << " ++ " << iTauH << " id: " << tauH.pdgId() << " | pt: " << tauH.pt() << " | eta: " << tauH.eta() << endl;
if (DEBUG){
cout << " ++ " << iTauH << " id: " << tauH.pdgId() << " | pt: " << tauH.pt() << " | eta: " << tauH.eta() << endl;
cout << " ++ " << iTauH << " id: " << tauH_neutral.pdgId() << " | pt: " << tauH_neutral.pt() << " | eta: " << tauH_neutral.eta() << endl;
}
result->push_back (tauH);
result->push_back (tauH_neutral);
}
iEvent.put(result);
}
Expand Down
Loading

0 comments on commit dcfa471

Please sign in to comment.