Skip to content

Commit

Permalink
Merge pull request #410 from amarini/submission_10X
Browse files Browse the repository at this point in the history
Developments 102x
  • Loading branch information
amarini authored Sep 9, 2019
2 parents 12ae05e + bea5416 commit aed8cbf
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Core/interface/BareLeptons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ class BareLeptons : virtual public BareP4
vector<float> *kinfitPtErr{0};

TClonesArray *fsrP4{0}; // at most 1.
vector<float> *dxy{0};
vector<float> *dz{0};

vector<float> *dxybs{0};
vector<float> *dzbs{0};

};

Expand Down
24 changes: 24 additions & 0 deletions Core/src/BareLeptons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ BareLeptons::~BareLeptons(){
BareFunctions::Delete(kinfitP4);
BareFunctions::Delete(kinfitPtErr);
BareFunctions::Delete(fsrP4);
BareFunctions::Delete(dxy);
BareFunctions::Delete(dz);
BareFunctions::Delete(dxybs);
BareFunctions::Delete(dzbs);
}

void BareLeptons::init(){
Expand Down Expand Up @@ -53,6 +57,11 @@ void BareLeptons::init(){
BareFunctions::New(kinfitP4);
BareFunctions::New(kinfitPtErr);
BareFunctions::New(fsrP4);
BareFunctions::New(dxy);
BareFunctions::New(dz);

BareFunctions::New(dxybs);
BareFunctions::New(dzbs);
}

void BareLeptons::clear(){
Expand Down Expand Up @@ -84,6 +93,11 @@ void BareLeptons::clear(){
kinfitPtErr->clear();
fsrP4->Clear();

dxy->clear();
dz->clear();
dxybs->clear();
dzbs->clear();

}

void BareLeptons::defineBranches(TTree*t){
Expand Down Expand Up @@ -123,6 +137,10 @@ void BareLeptons::defineBranches(TTree*t){
t->Branch( "lepKinfitP4","TClonesArray", &kinfitP4, 128000, 0);
t->Branch( "lepFsrP4","TClonesArray", &fsrP4, 128000, 0);

t->Branch("lepDxy","vector<float>",&dxy);
t->Branch("lepDz","vector<float>",&dz);
t->Branch("lepDxyBS","vector<float>",&dxybs);
t->Branch("lepDzBS","vector<float>",&dzbs);

}

Expand Down Expand Up @@ -155,6 +173,12 @@ void BareLeptons::setBranchAddresses(TTree*t){
BareFunctions::SetBranchAddress(t,"lepKinfitPtErr",&kinfitPtErr);
BareFunctions::SetBranchAddress(t,"lepKinfitP4",&kinfitP4);
BareFunctions::SetBranchAddress(t,"lepFsrP4",&fsrP4);

BareFunctions::SetBranchAddress(t,"lepDxy",&dxy);
BareFunctions::SetBranchAddress(t,"lepDz",&dz);

BareFunctions::SetBranchAddress(t,"lepDxyBS",&dxybs);
BareFunctions::SetBranchAddress(t,"lepDzBS",&dzbs);
}

BAREREGISTER(BareLeptons);
Expand Down
10 changes: 9 additions & 1 deletion Nero/interface/NeroLeptons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// Electron corrector
#include "EgammaAnalysis/ElectronTools/interface/EnergyScaleCorrection_class.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"

class NeroLeptons : virtual public NeroCollection,
virtual public BareLeptons
Expand All @@ -26,7 +27,7 @@ class NeroLeptons : virtual public NeroCollection,
public:
myLepton(){ chiso=-999; nhiso=-999; phoiso=-999; puiso=-999;mva = -999; miniiso=-999;
etasc=0; sieie=0; sipip=0; sieip=0; r9=0; ecorr=1;
resolution =-999; nlayers=-999;
resolution =-999; nlayers=-999;
kinfitP4.SetPxPyPzE(0,0,0,0);
kinfitPtErr=-999;
fsrP4.SetPxPyPzE(0,0,0,0);
Expand Down Expand Up @@ -57,6 +58,11 @@ class NeroLeptons : virtual public NeroCollection,

float resolution;
int nlayers;

float dxy{-999};
float dz{-999};
float dxy2{-999};
float dz2{-999};

};

Expand All @@ -68,6 +74,7 @@ class NeroLeptons : virtual public NeroCollection,
// --- Token
edm::EDGetTokenT<reco::VertexCollection> vtx_token;
edm::EDGetTokenT<pat::PackedCandidateCollection> token_pf;
edm::EDGetTokenT<reco::BeamSpot> beamspot_token;

// Token
edm::EDGetTokenT<pat::MuonCollection> mu_token;
Expand Down Expand Up @@ -106,6 +113,7 @@ class NeroLeptons : virtual public NeroCollection,

edm::Handle<reco::VertexCollection> vtx_handle;
edm::Handle<pat::PackedCandidateCollection> handle_pf;
edm::Handle<reco::BeamSpot> beamspot_handle;

// for miniiso
edm::Handle<double> rho_handle;
Expand Down
27 changes: 27 additions & 0 deletions Nero/src/NeroLeptons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ NeroLeptons::NeroLeptons(edm::ConsumesCollector & cc,edm::ParameterSet iConfig):
#endif

vtx_token = cc.consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertices"));
beamspot_token = cc.consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"));
token_pf = cc.consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("pfCands"));
ea_ . reset (new EffectiveAreas( edm::FileInPath(iConfig.getParameter<std::string>("eleEA")).fullPath () ) );
mu_token = cc.consumes<pat::MuonCollection>(iConfig.getParameter<edm::InputTag>("muons"));
Expand Down Expand Up @@ -121,6 +122,9 @@ int NeroLeptons::analyze(const edm::Event & iEvent)
const reco::Vertex *pv = &vtx_handle->front();
iEvent.getByToken(token_pf, handle_pf);

iEvent.getByToken(beamspot_token, beamspot_handle);
const reco::BeamSpot *bs = &(*beamspot_handle); // recast

iEvent.getByToken(mu_token,mu_handle);
iEvent.getByToken(el_token,el_handle);

Expand Down Expand Up @@ -234,6 +238,16 @@ int NeroLeptons::analyze(const edm::Event & iEvent)
l.selBits |= unsigned(LepHighPt * myid::isHighPtMuon(mu,*pv)) ;

l.pfPt = mu.pfP4().pt();

//
if (not mu.innerTrack().isNull())
{
l.dz = mu.innerTrack()->dz(pv->position());
l.dxy = mu.innerTrack()->dxy(pv->position());
//offlineBeamSpot
l.dz2 = mu.innerTrack()->dz(bs->position());
l.dxy2 = mu.innerTrack()->dxy(bs->position());
}

if (mu.hasUserCand("cutBasedFsrPhoton"))
{
Expand Down Expand Up @@ -379,6 +393,14 @@ int NeroLeptons::analyze(const edm::Event & iEvent)
l.sieip = el.full5x5_sigmaIetaIphi();
l.r9 = el.r9();

if ( not el.gsfTrack().isNull()){
l.dz = el.gsfTrack()->dz(pv->position());
l.dxy = el.gsfTrack()->dxy(pv->position());
//offlineBeamSpot
l.dz2 = el.gsfTrack()->dz(bs->position());
l.dxy2 = el.gsfTrack()->dxy(bs->position());
}

// float chIso = el.chargedHadronIso();
// float nhIso = el.neutralHadronIso();
// float phoIso = el.photonIso();
Expand Down Expand Up @@ -533,6 +555,11 @@ int NeroLeptons::analyze(const edm::Event & iEvent)
resolution -> push_back(l.resolution);
nLayers -> push_back(l.nlayers);

dxy -> push_back(l.dxy);
dz -> push_back(l.dz);
dxybs -> push_back(l.dxy2);
dzbs -> push_back(l.dz2);

//kinfit
new ( (*kinfitP4)[kinfitP4->GetEntriesFast()]) TLorentzVector(l.kinfitP4);
kinfitPtErr -> push_back(l.kinfitPtErr);
Expand Down
2 changes: 2 additions & 0 deletions Nero/test/testNero.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@
PhotonMVA="FSRPhotonRecovery/FSRPhotons/data/PhotonMVAv5_BDTG1000TreesDY.weights.xml"
PhotonMVA="FSRPhotonRecovery/FSRPhotons/data/PhotonMVAv9_BDTG800TreesDY.weights.xml"
addFSRphotonSequence(process, process.nero.NeroLeptons.muons.value(), PhotonMVA)
#electrons = cms.InputTag("slimmedElectrons","","nero"),
process.FSRRecovery.patphotons= cms.InputTag("slimmedPhotons","","nero")


###############################################################
Expand Down

0 comments on commit aed8cbf

Please sign in to comment.