Skip to content

Commit

Permalink
Legacy fiducial and differential xs measurement full Run2 (#1166)
Browse files Browse the repository at this point in the history
+ Factorized fiducial and differential xs workflow
+ Prompt 2016 analysis strategy
+ Full Run2 optimize categorization

Co-authored-by: Simone Pigazzi <[email protected]>
Co-authored-by: abeschi <[email protected]>
Co-authored-by: Simone Pigazzini <[email protected]>
Co-authored-by: Seth Zenz <[email protected]>
Co-authored-by: vtavolar <[email protected]>
Co-authored-by: Pasquale Musella <[email protected]>
Co-authored-by: gfasanel <[email protected]>
Co-authored-by: Shervin <[email protected]>
Co-authored-by: Nadezda <nadezda.chernyavskaya>
  • Loading branch information
9 people authored May 26, 2020
1 parent 5130d9c commit 659617b
Show file tree
Hide file tree
Showing 125 changed files with 63,467 additions and 197,717 deletions.
1 change: 0 additions & 1 deletion DataFormats/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<use name="DataFormats/VertexReco"/>
<use name="DataFormats/Common"/>
<use name="DataFormats/JetReco"/>
<use name="rootrflx"/>

<export>
<lib name="1"/>
Expand Down
2 changes: 2 additions & 0 deletions DataFormats/interface/GenDiPhoton.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ namespace flashgg {

virtual GenDiPhoton *clone() const { return ( new GenDiPhoton( *this ) ); }


const flashgg::GenPhotonExtra::cand_type* leadingPhoton() const { return &(leadingPhoton_.cand()); };
const flashgg::GenPhotonExtra::cand_type* subLeadingPhoton() const { return &(subLeadingPhoton_.cand()); }


const reco::GenJet & leadingJet() const { return *leadingJet_; };
const reco::GenJet & subLeadingJet() const { return *subLeadingJet_; }
Expand Down
50 changes: 50 additions & 0 deletions DataFormats/interface/GenJetExtra.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#ifndef FLASHgg_GenJetExtra_h
#define FLASHgg_GenJetExtra_h

//#include "flashgg/DataFormats/interface/Jet.h"
#include "DataFormats/PatCandidates/interface/PackedGenParticle.h"
#include "DataFormats/JetReco/interface/GenJet.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
#include "DataFormats/Common/interface/Ptr.h"

#include <string>

namespace flashgg {

class GenJetExtra : public reco::GenJet
{

public:
GenJetExtra(){}
GenJetExtra(const reco::GenJet &j) : reco::GenJet(j) {}

bool hasBottom() const {return hasBottom_;}
void setHasBottom( bool x ){hasBottom_ = x;}

bool hasBquark() const {return hasBquark_;}
void setHasBquark( bool x ){hasBquark_ = x;}

bool deltaRBquarkGenJet() const {return deltaRBquarkGenjet_;}
void setDeltaRBquarkGenjet( double x ){deltaRBquarkGenjet_ = x;}

bool jetPtOverBquarkPt() const {return jetPtOverBquarkPt_;}
void setJetPtOverBquarkPt( double x ){jetPtOverBquarkPt_ = x;}


private:
bool hasBottom_;
bool hasBquark_;
double deltaRBquarkGenjet_;
double jetPtOverBquarkPt_;
};
}

#endif
// Local Variables:
// mode:c++
// indent-tabs-mode:nil
// tab-width:4
// c-basic-offset:4
// End:
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4

64 changes: 64 additions & 0 deletions DataFormats/interface/GenLeptonExtra.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifndef FLASHgg_GenLeptonExtra_h
#define FLASHgg_GenLeptonExtra_h

//#include "flashgg/DataFormats/interface/Lepton.h"
#include "DataFormats/PatCandidates/interface/PackedGenParticle.h"
#include "DataFormats/Candidate/interface/ShallowCloneCandidate.h"
#include "DataFormats/Common/interface/Ptr.h"

#include <string>

namespace flashgg {

class GenLeptonExtra : public reco::ShallowCloneCandidate
{

public:
typedef edm::Ptr<pat::PackedGenParticle> ptr_type;
typedef ptr_type::value_type cand_type;
// typedef Lepton::mcMatch_t match_type; //FIXME

GenLeptonExtra() {}
GenLeptonExtra( ptr_type ptr ) : ptr_( ptr ) {}


bool operator==( const ptr_type &rhs ) const { return ptr_ == rhs; }
bool operator!=( const ptr_type &rhs ) const { return ptr_ != rhs; }

const cand_type &cand() const { return *ptr_; }
ptr_type ptr() const { return ptr_; }
void setPtr( ptr_type x ) { ptr_ = x; }

float genIso() const { return genIso_; }
void setGenIso( float x ) { genIso_ = x; }

float genIsoAfterDressing() const { return genIsoAfterDressing_; }
void setGenIsoAfterDressing( float x ) { genIsoAfterDressing_ = x; }

// reco::Particle::LorentzVector dressedP4() const { return dressedP4_; }
// void setDressedP4( reco::Particle::LorentzVector x ) { dressedP4_ = x; }
// void setP4( reco::Particle::LorentzVector x ) { p4_ = x; }

// void copyTo( flashgg::Lepton &fg, const std::string &postFix = "" ) const
// {
// fg.addUserFloat( "genIso" + postFix, genIso_ );
// }

private:
ptr_type ptr_;
float genIso_;
float genIsoAfterDressing_;
// reco::Particle::LorentzVector dressedP4_;
// reco::Particle::LorentzVector p4_;
};
}

#endif
// Local Variables:
// mode:c++
// indent-tabs-mode:nil
// tab-width:4
// c-basic-offset:4
// End:
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4

10 changes: 10 additions & 0 deletions DataFormats/interface/Jet.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace flashgg {
};

enum JetIDLevel {Loose=0, Tight=1, Tight2017=2, Tight2018=3};
enum JetPuIdLevel {none=0, loose=1, medium=2, tight=3, mixed=4, forward_loose=5, forward_medium=6, forward_tight=7};

class Jet : public pat::Jet, public WeightedObject
{
Expand All @@ -27,12 +28,15 @@ namespace flashgg {
void setPuJetId( const edm::Ptr<reco::Vertex> vtx, const PileupJetIdentifier & );
bool hasPuJetId( const edm::Ptr<reco::Vertex> vtx ) const;
bool passesPuJetId( const edm::Ptr<reco::Vertex> vtx, PileupJetIdentifier::Id level = PileupJetIdentifier::kLoose ) const;
bool passesJetPuId( JetPuIdLevel level = none ) const;
void setSimpleRMS( float theRMS ) { simpleRMS_ = theRMS; }
void setSimpleMVA( float theMVA ) { simpleMVA_ = theMVA; }
float rms() const { return simpleRMS_; }
float rms( const edm::Ptr<reco::Vertex> vtx ) const;
float betaStar( const edm::Ptr<reco::Vertex> vtx ) const;
bool passesPuJetId( const edm::Ptr<DiPhotonCandidate> dipho, PileupJetIdentifier::Id level = PileupJetIdentifier::kLoose )const;


float rms( const edm::Ptr<DiPhotonCandidate> dipho ) const;
float betaStar( const edm::Ptr<DiPhotonCandidate> dipho ) const;
float puJetIdMVA() const { return simpleMVA_; }
Expand All @@ -55,12 +59,18 @@ namespace flashgg {
void setNeEnergies(std::vector<float> val) { neEnergies_ = val; }
void setMuEnergies(std::vector<float> val) { muEnergies_ = val; }

std::vector<double> _pujid_wp_pt_bin_1;
// std::vector<double> _pujid_wp_pt_bin_2; not used since same puJetId cuts for pt = 0 ... 30 GeV
// std::vector<double> _pujid_wp_pt_bin_3;
std::vector<double> _pujid_wp_pt_bin_4;

private:
std::map<edm::Ptr<reco::Vertex>, MinimalPileupJetIdentifier> puJetId_;
float qglikelihood_;
float simpleRMS_; // simpler storage for PFCHS where this is not vertex-dependent
float simpleMVA_;
std::vector<float> chEnergies_, emEnergies_, neEnergies_, muEnergies_;
std::vector<std::pair<double,double> > eta_cuts_;
};
}

Expand Down
2 changes: 1 addition & 1 deletion DataFormats/interface/Photon.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace flashgg {
void updateEnergy( std::string key, float val );
void shiftAllMvaValuesBy( float val );
void shiftMvaValueBy( float val, edm::Ptr<reco::Vertex> vtx );
void shiftSigmaEOverEValueBy( float val );
void shiftSigmaEOverEValueBy( float val, float cutoff=0. );
void smearSigmaEOverEValueBy( float val );
// void setSigEOverE(float val) { sigEOverE_ = val; };

Expand Down
8 changes: 7 additions & 1 deletion DataFormats/interface/SigmaMpTTag.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define flashgg_SigmaMpTTag

#include "flashgg/DataFormats/interface/DiPhotonTagBase.h"
#include "DataFormats/Candidate/interface/CompositeCandidate.h"

namespace flashgg {

Expand All @@ -13,11 +14,16 @@ namespace flashgg {

SigmaMpTTag( edm::Ptr<DiPhotonCandidate>, DiPhotonMVAResult );
SigmaMpTTag( edm::Ptr<DiPhotonCandidate>, edm::Ptr<DiPhotonMVAResult> );

SigmaMpTTag( edm::Ptr<DiPhotonCandidate>, DiPhotonMVAResult, std::map<std::string, edm::Ptr<reco::CompositeCandidate> > );
SigmaMpTTag( edm::Ptr<DiPhotonCandidate>, edm::Ptr<DiPhotonMVAResult>, std::map<std::string, edm::Ptr<reco::CompositeCandidate> > );
const edm::Ptr<reco::CompositeCandidate > getCompCand(const std::string &name) const;

virtual SigmaMpTTag *clone() const override;
DiPhotonTagBase::tag_t tagEnum() const override {return DiPhotonTagBase::kUntagged; }

private:

std::map<std::string, edm::Ptr<reco::CompositeCandidate > > compObjMap_;


};
Expand Down
13 changes: 6 additions & 7 deletions DataFormats/interface/TTHLeptonicTag.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ namespace flashgg {
int subleadMomMomID() const { return sublead_motherMotherID_; }
int subleadPassFrix() const { return sublead_passFrix_; }
double subleadSmallestDr() const { return sublead_smallestDr_; }

void setJets( std::vector<edm::Ptr<Jet> > Jets ) { Jets_ = Jets; }
void setBJets( std::vector<edm::Ptr<Jet> > BJets ) { BJets_ = BJets;}
void setMuons( std::vector<edm::Ptr<Muon> > Muons ) {Muons_ = Muons;}
void setElectrons( std::vector<edm::Ptr<Electron> > Electrons ) {Electrons_ = Electrons;}
void setLepPt( std::vector<double> lepPt) { lepPt_ = lepPt; }
void setLepE( std::vector<double> lepE) { lepE_ = lepE; }
void setLepEta( std::vector<double> lepEta) { lepEta_ = lepEta; }
void setLepPhi( std::vector<double> lepPhi) { lepPhi_ = lepPhi; }
void setLepType( std::vector<int> lepType) { lepType_ = lepType; }
void setLepPt( std::vector<double> lepPt ) { lepPt_ = lepPt; }
void setLepE( std::vector<double> lepE ) { lepE_ = lepE; }
void setLepEta( std::vector<double> lepEta ) { lepEta_ = lepEta; }
void setLepPhi( std::vector<double> lepPhi ) { lepPhi_ = lepPhi; }
void setLepType( std::vector<int> lepType ) { lepType_ = lepType; }

void setLeadPrompt(int leadPrompt) { leadPrompt_ = leadPrompt; }
void setSubleadPrompt(int subleadPrompt) { subleadPrompt_ = subleadPrompt; }
Expand Down Expand Up @@ -113,7 +113,6 @@ namespace flashgg {
int sublead_motherMotherID_;
int sublead_passFrix_;
double sublead_smallestDr_;

float mvaRes_;
};
}
Expand Down
70 changes: 70 additions & 0 deletions DataFormats/src/Jet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Jet::Jet() : pat::Jet()
qglikelihood_ = -999.;
simpleMVA_ = -999.;
puJetId_.clear();
eta_cuts_.push_back( std::make_pair (0 ,2.50 ) );
eta_cuts_.push_back( std::make_pair (2.50 ,2.75 ) );
eta_cuts_.push_back( std::make_pair (2.75 ,3.00 ) );
eta_cuts_.push_back( std::make_pair (3.00 ,5.00) );
}

Jet::Jet( const pat::Jet &aJet ) : pat::Jet( aJet )
Expand Down Expand Up @@ -38,6 +42,8 @@ bool Jet::passesPuJetId( const edm::Ptr<reco::Vertex> vtx, PileupJetIdentifier::
return true;
}



float Jet::rms( const edm::Ptr<reco::Vertex> vtx ) const
{
assert( hasPuJetId( vtx ) );
Expand Down Expand Up @@ -67,6 +73,70 @@ float Jet::betaStar( const edm::Ptr<DiPhotonCandidate> dipho ) const
return betaStar( dipho->vtx() );
}


bool Jet::passesJetPuId( JetPuIdLevel level ) const
{
flashgg::Jet* ptr = const_cast<flashgg::Jet*> (this);

switch(level){
case none:
{
ptr->_pujid_wp_pt_bin_1 = {-1,-1,-1,-1};
// ptr->_pujid_wp_pt_bin_2 = {-1,-1,-1,-1}; not used since same puJetId cuts for pt = 0 ... 30 GeV
// ptr->_pujid_wp_pt_bin_3 = {-1,-1,-1,-1};
ptr->_pujid_wp_pt_bin_4 = {-1,-1,-1,-1};
}break;
case loose:
{
ptr->_pujid_wp_pt_bin_1 = {-0.97, -0.68, -0.53, -0.47};
// ptr->_pujid_wp_pt_bin_2 = {-0.97, -0.68, -0.53, -0.47};
// ptr->_pujid_wp_pt_bin_3 = {-0.97, -0.68, -0.53, -0.47};
ptr->_pujid_wp_pt_bin_4 = {-0.89, -0.52, -0.38, -0.30};
}break;

case medium:
{
ptr->_pujid_wp_pt_bin_1 = {0.18, -0.55, -0.42, -0.36};
// ptr->_pujid_wp_pt_bin_2 = {0.18, -0.55, -0.42, -0.36};
// ptr->_pujid_wp_pt_bin_3 = {0.18, -0.55, -0.42, -0.36};
ptr->_pujid_wp_pt_bin_4 = {0.61, -0.35, -0.23, -0.17};
}break;
case tight:
{
ptr->_pujid_wp_pt_bin_1 = {0.69, -0.35, -0.26, -0.21};
// ptr->_pujid_wp_pt_bin_2 = {0.69, -0.35, -0.26, -0.21};
// ptr->_pujid_wp_pt_bin_3 = {0.69, -0.35, -0.26, -0.21};
ptr->_pujid_wp_pt_bin_4 = {0.86, -0.10, -0.05, -0.01};
}break;
default:
{
std::cout << "error:: wrong level !!" << std::endl;
}
break;
}


bool pass=false;
if ( (!_pujid_wp_pt_bin_1.empty()) &&
(!_pujid_wp_pt_bin_4.empty()) ){

for (UInt_t eta_bin=0; eta_bin < _pujid_wp_pt_bin_1.size(); eta_bin++ ){
if ( fabs( this->eta() ) > eta_cuts_[eta_bin].first &&
fabs( this->eta() ) <= eta_cuts_[eta_bin].second){
if ( this->pt() >= 0 && this->pt() <= 30 && this->puJetIdMVA() > _pujid_wp_pt_bin_1[eta_bin] )
pass=true;
if ( this->pt() > 30 && this->pt() <= 50 && this->puJetIdMVA() > _pujid_wp_pt_bin_4[eta_bin] )
pass=true;
if (this->pt() > 50) pass = true;
}
}
}


return pass;

}

bool Jet::passesJetID( JetIDLevel level) const
{
float eta = this->eta();
Expand Down
4 changes: 2 additions & 2 deletions DataFormats/src/Photon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ void Photon::shiftMvaValueBy( float val, edm::Ptr<reco::Vertex> vtx ) {
}

//sigmaEOverE systematycs
void Photon::shiftSigmaEOverEValueBy( float val ) {
void Photon::shiftSigmaEOverEValueBy( float val, float cutoff ) {
const LorentzVector pho_p4 = p4(getCandidateP4type());
float energyError = getCorrectedEnergyError(getCandidateP4type());
setP4(getCandidateP4type(), pho_p4, energyError*(1.+val), false);
setP4(getCandidateP4type(), pho_p4, energyError + val*(std::max(energyError, cutoff)), false);
}


Expand Down
22 changes: 20 additions & 2 deletions DataFormats/src/SigmaMpTTag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,26 @@ SigmaMpTTag::~SigmaMpTTag() {}
SigmaMpTTag::SigmaMpTTag( edm::Ptr<flashgg::DiPhotonCandidate> diPho, edm::Ptr<DiPhotonMVAResult> mvaRes )
: SigmaMpTTag::SigmaMpTTag( diPho, *mvaRes ) {}

SigmaMpTTag::SigmaMpTTag( edm::Ptr<DiPhotonCandidate> dipho, DiPhotonMVAResult mvares ) : DiPhotonTagBase::DiPhotonTagBase( dipho,
mvares ) {}
SigmaMpTTag::SigmaMpTTag( edm::Ptr<DiPhotonCandidate> dipho, DiPhotonMVAResult mvares ) : DiPhotonTagBase::DiPhotonTagBase( dipho, mvares ) {}

SigmaMpTTag::SigmaMpTTag( edm::Ptr<flashgg::DiPhotonCandidate> diPho, edm::Ptr<DiPhotonMVAResult> mvaRes, std::map<std::string, edm::Ptr<reco::CompositeCandidate> > compObjMap )
: SigmaMpTTag::SigmaMpTTag( diPho, *mvaRes, compObjMap ) {}

SigmaMpTTag::SigmaMpTTag( edm::Ptr<DiPhotonCandidate> dipho, DiPhotonMVAResult mvares, std::map<std::string, edm::Ptr<reco::CompositeCandidate> > compObjMap ) : DiPhotonTagBase::DiPhotonTagBase( dipho,
mvares ) {

compObjMap_ = compObjMap;

}

const edm::Ptr<reco::CompositeCandidate > SigmaMpTTag::getCompCand(const std::string &name) const
{
auto itr = compObjMap_.find(name);
if(itr==compObjMap_.end()){
assert(0);
}
return itr->second;
}

SigmaMpTTag *SigmaMpTTag::clone() const
{
Expand Down
8 changes: 8 additions & 0 deletions DataFormats/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "flashgg/DataFormats/interface/Electron.h"
#include "flashgg/DataFormats/interface/Muon.h"
#include "flashgg/DataFormats/interface/GenPhotonExtra.h"
#include "flashgg/DataFormats/interface/GenLeptonExtra.h"
#include "flashgg/DataFormats/interface/GenJetExtra.h"
#include "flashgg/DataFormats/interface/Jet.h"
#include "flashgg/DataFormats/interface/Met.h"
#include "flashgg/DataFormats/interface/Photon.h"
Expand Down Expand Up @@ -162,6 +164,12 @@ namespace {
std::vector<flashgg::GenPhotonExtra> vec_fgg_pho_xtra;
edm::Wrapper<std::vector<flashgg::GenPhotonExtra> > wrp_vec_fgg_pho_xtra;

flashgg::GenLeptonExtra fgg_lep_xtra;
edm::Ptr<flashgg::GenLeptonExtra> ptr_fgg_lep_xtra;
std::vector<flashgg::GenLeptonExtra> vec_fgg_lep_xtra;
edm::Wrapper<flashgg::GenLeptonExtra> wrp_fgg_lep_xtra;
edm::Wrapper<std::vector<flashgg::GenLeptonExtra> > wrp_vec_fgg_lep_xtra;

flashgg::DiPhotonMVAResult res;
// edm::Wrapper<flashgg::DiPhotonMVAResult> wrp_res;
// std::pair<edm::Ptr<flashgg::DiPhotonCandidate>,flashgg::DiPhotonMVAResult> pair_res;
Expand Down
Loading

0 comments on commit 659617b

Please sign in to comment.