Skip to content

Commit

Permalink
Merge pull request #387 from danielwinterbottom/FF_MSSM_updates
Browse files Browse the repository at this point in the history
Ff mssm updates
  • Loading branch information
danielwinterbottom authored Jan 7, 2022
2 parents 42eea1a + 77da24b commit 40c4751
Show file tree
Hide file tree
Showing 27 changed files with 1,037 additions and 175 deletions.
10 changes: 10 additions & 0 deletions Analysis/HiggsTauTauRun2/interface/HTTCategories.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class HTTCategories : public ModuleBase {
double wt_tquark_alt_;
double wt_zpt_up_;
double wt_zpt_down_;
double wt_zpt_embed_ic_;
double wt_efake_rate_up_;
double wt_efake_rate_down_;
double wt_mfake_rate_up_;
Expand Down Expand Up @@ -243,6 +244,15 @@ class HTTCategories : public ModuleBase {
unsigned n_loose_bjets_;
unsigned n_btag_;
unsigned n_loose_btag_;

double deepbpt_1_;
double deepbeta_1_;
double deep_probb_1_;
double deep_probbb_1_;
double deep_problepb_1_;
double deepcsv_probb_1_;
double deepcsv_probbb_1_;

branch_var jpt_1_; // Defined if n_jets >= 1
branch_var jpt_2_; // Defined if n_jets >= 2
branch_var jeta_1_; // Defined if n_jets >= 1
Expand Down
12 changes: 11 additions & 1 deletion Analysis/HiggsTauTauRun2/interface/HTTGenMatchSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class HTTGenMatchSelector : public ModuleBase {
CLASS_MEMBER(HTTGenMatchSelector<T>, std::string, input_vec_label)
CLASS_MEMBER(HTTGenMatchSelector<T>, std::string, output_vec_label)
CLASS_MEMBER(HTTGenMatchSelector<T>, ic::mcorigin, gen_match)
CLASS_MEMBER(HTTGenMatchSelector<T>, bool, add_gen)
public:
HTTGenMatchSelector(std::string const& name);
virtual ~HTTGenMatchSelector();
Expand All @@ -33,6 +34,7 @@ template <class T>
HTTGenMatchSelector<T>::HTTGenMatchSelector(std::string const& name) : ModuleBase(name), gen_match_(mcorigin::tauHad) {
input_vec_label_ = "taus";
output_vec_label_ = "genmatched_taus";
add_gen_ = false;
}

template <class T>
Expand All @@ -43,6 +45,7 @@ template <class T>
int HTTGenMatchSelector<T>::Execute(TreeEvent *event) {
std::vector<T*> input_vec = event->GetPtrVec<T>(input_vec_label_);
std::vector<T*> output_vec;
std::vector<ROOT::Math::PtEtaPhiEVector> output_vec_gen;

std::vector<GenJet *> gen_taus_ptr;
std::vector<GenParticle *> sel_particles;
Expand All @@ -68,17 +71,19 @@ int HTTGenMatchSelector<T>::Execute(TreeEvent *event) {
event->Add("genHadTaus", gen_taus_ptr);
event->Add("genLeps", sel_particles);
}


for(unsigned i=0; i<input_vec.size(); ++i){
std::vector<T *> lepton;
lepton.push_back(input_vec[i]);
std::vector<std::pair<T*, GenParticle*> > lepton_match = MatchByDR(lepton, sel_particles, 0.2, true, true);
std::vector<std::pair<T*, GenJet*> > tau_match = MatchByDR(lepton, gen_taus_ptr, 0.2, true, true);

mcorigin gen_match_1 = mcorigin::fake;
int leptonsize = lepton_match.size();
int tausize = tau_match.size();


if(leptonsize!=0&&tausize!=0){
DR(lepton_match.at(0).first,lepton_match.at(0).second) < DR(tau_match.at(0).first,tau_match.at(0).second) ? tausize=0 : leptonsize = 0;
}
Expand Down Expand Up @@ -110,9 +115,14 @@ int HTTGenMatchSelector<T>::Execute(TreeEvent *event) {

if(gen_match_1 == gen_match_){
output_vec.push_back(input_vec[i]);
if (add_gen_) {
if(tausize!=0) output_vec_gen.push_back(tau_match.at(0).second->vector());
else if(leptonsize!=0) output_vec_gen.push_back(lepton_match.at(0).second->vector());
}
}
}
event->Add(output_vec_label_, output_vec);
if (add_gen_) event->Add(output_vec_label_+"_gen", output_vec_gen);

return 0;
}
Expand Down
3 changes: 3 additions & 0 deletions Analysis/HiggsTauTauRun2/interface/HTTSequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class HTTSequence {
double muon_shift_barrel, muon_shift_nearendcap, muon_shift_farendcap;
unsigned e_unc_mode;
double fakeE_tau_shift_0pi, fakeE_tau_shift_1pi, fakeE_tau_shift_0pi_endcap, fakeE_tau_shift_1pi_endcap, fakeMu_tau_shift_0pi, fakeMu_tau_shift_1pi ;
double muon_res_shift = 0.;
double elec_res_shift = 0.;
double tau_res_shift = 0.;
double tau_shift_1prong0pi0, tau_shift_1prong1pi0, tau_shift_3prong0pi0, tau_shift_3prong1pi0;
std::string tau_shift_func_1prong0pi0, tau_shift_func_1prong1pi0, tau_shift_func_3prong0pi0, tau_shift_func_3prong1pi0;
bool do_qcd_scale_wts_;
Expand Down
1 change: 1 addition & 0 deletions Analysis/HiggsTauTauRun2/interface/HTTWeights.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class HTTWeights : public ModuleBase {
CLASS_MEMBER(HTTWeights, std::string, mssm_mass)
CLASS_MEMBER(HTTWeights, bool, is_embedded)
CLASS_MEMBER(HTTWeights, bool, do_nnlops_weights)
CLASS_MEMBER(HTTWeights, TH2F*, embed_pt_weights_ic_hist)

TFile *ggh_weights_;
TGraph *ggh_mg_0jet_;
Expand Down
130 changes: 81 additions & 49 deletions Analysis/HiggsTauTauRun2/interface/JetEnergyUncertainty.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class JetEnergyUncertainty : public ModuleBase {
CLASS_MEMBER(JetEnergyUncertainty, std::vector<double>, correlations)
CLASS_MEMBER(JetEnergyUncertainty, unsigned, jes_corr_mode)
CLASS_MEMBER(JetEnergyUncertainty, bool, EENoiseFix)
CLASS_MEMBER(JetEnergyUncertainty, bool, HEMFix)
CLASS_MEMBER(JetEnergyUncertainty, bool, shift_met)
CLASS_MEMBER(JetEnergyUncertainty, std::string, met_label)
JetCorrectionUncertainty *uncert_;
Expand Down Expand Up @@ -70,9 +71,12 @@ int JetEnergyUncertainty<T>::PreAnalysis() {
std::cout << boost::format(param_fmt()) % "uncert_file" % uncert_file_;
std::cout << boost::format(param_fmt()) % "uncert_set" % uncert_set_;
std::cout << boost::format(param_fmt()) % "shift_met" % shift_met_;
params_ = new JetCorrectorParameters(uncert_file_, uncert_set_);
uncert_ = new JetCorrectionUncertainty(*params_);


if(uncert_set_!=""){
params_ = new JetCorrectorParameters(uncert_file_, uncert_set_);
uncert_ = new JetCorrectionUncertainty(*params_);
}

if(sum_uncerts_){
for (unsigned j=0; j<uncert_sets_.size(); ++j){
std::cout << "uncert sets[j]: " << uncert_sets_[j] << std::endl;
Expand All @@ -87,68 +91,96 @@ int JetEnergyUncertainty<T>::PreAnalysis() {
template <class T>
int JetEnergyUncertainty<T>::Execute(TreeEvent *event) {
std::vector<T *> & vec = event->GetPtrVec<T>(input_label_);
if(!sum_uncerts_){
ROOT::Math::PxPyPzEVector before(0.,0.,0.,0.);
ROOT::Math::PxPyPzEVector after(0.,0.,0.,0.);
for (unsigned i = 0; i < vec.size(); ++i) {
double pt = vec[i]->pt() * (vec[i]->uncorrected_energy()/vec[i]->energy());
bool skipJet = (EENoiseFix_ && pt<50 && fabs(vec[i]->eta())>2.65 && fabs(vec[i]->eta())<3.139);
if(!skipJet) before+=vec[i]->vector();
uncert_->setJetPt(vec[i]->pt());
uncert_->setJetEta(vec[i]->eta());
if (jes_shift_mode_ == 1) {
double shift = uncert_->getUncertainty(false); //down
vec[i]->set_vector(vec[i]->vector() * (1.0-shift));
if(uncert_set_!="") {
if(!sum_uncerts_){
ROOT::Math::PxPyPzEVector before(0.,0.,0.,0.);
ROOT::Math::PxPyPzEVector after(0.,0.,0.,0.);
for (unsigned i = 0; i < vec.size(); ++i) {
double pt = vec[i]->pt() * (vec[i]->uncorrected_energy()/vec[i]->energy());
bool skipJet = (EENoiseFix_ && pt<50 && fabs(vec[i]->eta())>2.65 && fabs(vec[i]->eta())<3.139);
if(!skipJet) before+=vec[i]->vector();
uncert_->setJetPt(vec[i]->pt());
uncert_->setJetEta(vec[i]->eta());
if (jes_shift_mode_ == 1) {
double shift = uncert_->getUncertainty(false); //down
vec[i]->set_vector(vec[i]->vector() * (1.0-shift));
}
if (jes_shift_mode_ == 2) {
double shift = uncert_->getUncertainty(true); //up
vec[i]->set_vector(vec[i]->vector() * (1.0+shift));
}
if(!skipJet) after+=vec[i]->vector();

}
if (jes_shift_mode_ == 2) {
double shift = uncert_->getUncertainty(true); //up
vec[i]->set_vector(vec[i]->vector() * (1.0+shift));
if (shift_met_) {
Met * met = event->GetPtr<Met>(met_label_);
this->CorrectMETForShift(met, after-before);
}
if(!skipJet) after+=vec[i]->vector();

}
if (shift_met_) {
Met * met = event->GetPtr<Met>(met_label_);
this->CorrectMETForShift(met, after-before);
}
} else if (sum_uncerts_){
ROOT::Math::PxPyPzEVector before(0.,0.,0.,0.);
ROOT::Math::PxPyPzEVector after(0.,0.,0.,0.);
for (unsigned i = 0; i < vec.size(); ++i) {
double pt = vec[i]->pt() * (vec[i]->uncorrected_energy()/vec[i]->energy());
bool skipJet = (EENoiseFix_ && pt<50 && fabs(vec[i]->eta())>2.65 && fabs(vec[i]->eta())<3.139);
if(!skipJet) before+=vec[i]->vector();
double shift=0;
double factor = 1.; //for correlations
for (unsigned j=0; j<uncerts_.size(); ++j){
uncerts_[j]->setJetPt(vec[i]->pt());
uncerts_[j]->setJetEta(vec[i]->eta());
if (jes_corr_mode_ == 1) {
factor = correlations_[j];
} else if (jes_corr_mode_ == 2){
factor = 1. - correlations_[j];
} else if (sum_uncerts_){
ROOT::Math::PxPyPzEVector before(0.,0.,0.,0.);
ROOT::Math::PxPyPzEVector after(0.,0.,0.,0.);
for (unsigned i = 0; i < vec.size(); ++i) {
double pt = vec[i]->pt() * (vec[i]->uncorrected_energy()/vec[i]->energy());
bool skipJet = (EENoiseFix_ && pt<50 && fabs(vec[i]->eta())>2.65 && fabs(vec[i]->eta())<3.139);
if(!skipJet) before+=vec[i]->vector();
double shift=0;
double factor = 1.; //for correlations
for (unsigned j=0; j<uncerts_.size(); ++j){
uncerts_[j]->setJetPt(vec[i]->pt());
uncerts_[j]->setJetEta(vec[i]->eta());
if (jes_corr_mode_ == 1) {
factor = correlations_[j];
} else if (jes_corr_mode_ == 2){
factor = 1. - correlations_[j];
}

if (jes_shift_mode_ == 1) {
shift = sqrt(shift*shift + factor*pow(uncerts_[j]->getUncertainty(false),2)); //down
}
if (jes_shift_mode_ == 2) {
shift = sqrt(shift*shift + factor*pow(uncerts_[j]->getUncertainty(true),2)); //up
}
}

if (jes_shift_mode_ == 1) {
shift = sqrt(shift*shift + factor*pow(uncerts_[j]->getUncertainty(false),2)); //down
vec[i]->set_vector(vec[i]->vector() * (1.0-shift));
}
if (jes_shift_mode_ == 2) {
shift = sqrt(shift*shift + factor*pow(uncerts_[j]->getUncertainty(true),2)); //up
vec[i]->set_vector(vec[i]->vector() * (1.0+shift));
}
if(!skipJet) after+=vec[i]->vector();
}
if (jes_shift_mode_ == 1) {
vec[i]->set_vector(vec[i]->vector() * (1.0-shift));
if (shift_met_) {
Met * met = event->GetPtr<Met>(met_label_);
this->CorrectMETForShift(met, after-before);
}
if (jes_shift_mode_ == 2) {
vec[i]->set_vector(vec[i]->vector() * (1.0+shift));
}
}

// code to apply jet scaling for HEM issue in 2018
if(HEMFix_){
ROOT::Math::PxPyPzEVector before(0.,0.,0.,0.);
ROOT::Math::PxPyPzEVector after(0.,0.,0.,0.);
for (unsigned i = 0; i < vec.size(); ++i) {
double pt = vec[i]->pt() * (vec[i]->uncorrected_energy()/vec[i]->energy());
before+=vec[i]->vector();
bool region1 = pt>15 && vec[i]->phi()>-1.57 && vec[i]->phi() < -0.87 && vec[i]->eta()>-2.5 && vec[i]->eta()<-1.3;
bool region2 = pt>15 && vec[i]->phi()>-1.57 && vec[i]->phi() < -0.87 && vec[i]->eta()>-3.0 && vec[i]->eta()<-2.5;
if (region1) {
vec[i]->set_vector(vec[i]->vector() * 0.8);
}
if(!skipJet) after+=vec[i]->vector();
if (region2) {
vec[i]->set_vector(vec[i]->vector() * 0.65);
}
after+=vec[i]->vector();

}
if (shift_met_) {
Met * met = event->GetPtr<Met>(met_label_);
this->CorrectMETForShift(met, after-before);
}
}


return 0;
}

Expand Down
Loading

0 comments on commit 40c4751

Please sign in to comment.