Skip to content

Commit

Permalink
Merge pull request cms-sw#164 from amarini/taunu_and_hmm
Browse files Browse the repository at this point in the history
Taunu and hmm
  • Loading branch information
amarini authored Jul 24, 2017
2 parents 7836990 + 54c8ca2 commit 2f632bf
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 140 deletions.
Binary file added aux/hotjets-runBCDEFGH.root
Binary file not shown.
8 changes: 3 additions & 5 deletions dat/configHmumu.dat
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ include=dat/catalog/2017.moriond/hmm.dat
addfiles=/store/group/phys_higgs/ceballos/Data//Nero/v2.2.1/SingleMuon
#include=catalog/2017.moriond/singleMuon.dat
#
Files=
include=dat/catalog/2017.moriond/dy_private.dat

Smear=NONE
#Smear=NONE,JES,PU,@SmearSF("muTRG_runGH"!"muTRG_runGH"),@SmearSF("muID_runGH"!"muID_runGH"),@SmearSF("muISO_runGH"!"muISOloose_runGH")
#Smear=NONE
Smear=NONE,JES,PU,@SmearSF("muTRG_runGH"!"muTRG_runGH"),@SmearSF("muID_runGH"!"muID_runGH"),@SmearSF("muISO_runGH"!"muISOloose_runGH")
#Smear=NONE,JES,@SmearBjets(1!0!"btag"),@SmearBjets(0!1!"btag")
#Smear=NONE,*[-133!0]SmearKaMuCa(%%d),*[1!135]SmearKaMuCa(%%d)
#Smear=NONE,@SmearScales("ScaleR"!1!0),@SmearScales("ScaleF"!0!1),@SmearScales("ScaleRF"!1!1),*[0!50]SmearPdfs(%%d)
Expand All @@ -38,7 +36,7 @@ include=dat/hmumu.dat
MCDB=aux/mcdb.TauNu.2017.dat
pileup=aux/pileup.TauNu.moriond.root
#Correct=ScaleAndSmear
Correct=ScaleAndSmear,KaMuCa
Correct=ScaleAndSmear,KaMuCa,JetFilter2016
#Correct=ScaleAndSmear,RochesterCorrections

Analysis=JsonAnalysis,MetFiltersAnalysis,HmumuAnalysis
9 changes: 5 additions & 4 deletions dat/configHmumuSyst.dat
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ include=dat/catalog/2017.moriond/hmm.dat
#Smear=NONE,JES,@SmearBjets(1!0!"btag"),@SmearBjets(0!1!"btag"),JER,@SmearPu

#Smear=NONE,*[-133!0]SmearKaMuCa(%%d),*[1!135]SmearKaMuCa(%%d)
Smear=NONE,*[1!8]SmearWG1(%%d)
#Smear=NONE,*[1!8]SmearWG1(%%d)

#Smear=NONE,@SmearScales("ScaleR"!1!0),@SmearScales("ScaleF"!0!1),@SmearScales("ScaleRF"!1!1),*[0!50]SmearPdfs(%%d)
##
#Smear = NONE,*[1!8]SmearWG1(%%d),JER,@SmearBjets(1!0!"btag"),@SmearBjets(0!1!"btag")

Smear=NONE,@SmearScales("ScaleR"!1!0),@SmearScales("ScaleF"!0!1),@SmearScales("ScaleRF"!1!1),*[0!50]SmearPdfs(%%d)
#Smear=NONE,@SmearSF("muTRG"!"muTRG_v2"),@SmearSF("muID_runBCDEF"!"muID_runBCDEF"),@SmearSF("muID_runGH"!"muID_runGH"),@SmearSF("muISO_runBCDEF"!"muISOloose_runBCDEF"),@SmearSF("muISO_runGH"!"muISOloose_runGH")

#Smear=NONE,@SmearJesSource("AbsoluteStat"),@SmearJesSource("AbsoluteScale"),@SmearJesSource("AbsoluteMPFBias"),@SmearJesSource("Fragmentation"),@SmearJesSource("SinglePionECAL"),@SmearJesSource("FlavorQCD"),@SmearJesSource("TimePtEta"),@SmearJesSource("RelativeJEREC1"),@SmearJesSource("RelativeJEREC2"),@SmearJesSource("RelativeJERHF"),@SmearJesSource("RelativePtBB"),@SmearJesSource("RelativePtEC1"),@SmearJesSource("RelativePtEC2"),@SmearJesSource("RelativePtHF"),@SmearJesSource("RelativeBal"),@SmearJesSource("RelativeFSR"),@SmearJesSource("PileUpDataMC"),@SmearJesSource("PileUpPtRef"),@SmearJesSource("PileUpPtBB"),@SmearJesSource("PileUpPtEC1"),@SmearJesSource("PileUpPtEC2"),@SmearJesSource("PileUpPtHF")
Expand All @@ -21,5 +24,3 @@ Smear=NONE,*[1!8]SmearWG1(%%d)
## be less peaky, given the n. of systs
#Final=true
EntryPerSecond=10
addConfig=HmumuAnalysis|catType=2
addConfig=HmumuAnalysis|doScikit=0
2 changes: 1 addition & 1 deletion dat/hmumu.dat
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ addConfig=HmumuAnalysis|AddLabel('ttHToNonbb_M125')

addConfig=HmumuAnalysis|unblind=1
addConfig=HmumuAnalysis|weights.push_back('aux/hmm/bdt_Apr05.xml')
addConfig=HmumuAnalysis|catType=2
addConfig=HmumuAnalysis|catType=3
addConfig=HmumuAnalysis|doScikit=0
addConfig=HmumuAnalysis|doEvenOnly=1
1 change: 1 addition & 0 deletions interface/Corrector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class CorrectorBase : public Named {
vector<Tau *> & GetTauVector(Event *e) { return e->taus_;}
vector<Lepton *>& GetLepVector(Event *e) { return e->leps_;}
vector<GenParticle *>& GetGenVector(Event *e) { return e->genparticles_;}
vector<Jet *> & GetJetVector(Event *e) { return e->jets_;}

// R/W Access to Objects, private/protected members
inline void Scale( Object&o, float value) { o.Scale(value);}
Expand Down
22 changes: 22 additions & 0 deletions interface/JetFilter2016.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef JET_FILTER_2016_H
#define JET_FILTER_2016_H

#include "interface/Corrector.hpp"

#include "TH2D.h"
#include <memory>

class JetFilter2016: public CorrectorBase
{
// kill jets accordingly to JetMet Map
std::unique_ptr<TH2D> h;

public:
void Init() override;
const string name() const override { return "JetFilter2016";}
int correct(Event *e) override ;
//vector<Jet *> & GetJetVector(Event *e) { return e->jets_;}
//inline void Scale( Object&o, float value) { o.Scale(value);}
};

#endif
3 changes: 2 additions & 1 deletion python/ParseDat.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ def FindHadoop(name,mount="/mnt/hadoop/cms"):

def FindEOS(name,mount=""):
''' EOS PATH should be followed. The mount option will assume that eos is mounted in ~/eos '''
EOS = "/afs/cern.ch/project/eos/installation/0.3.84-aquamarine/bin/eos.select"
#EOS = "/afs/cern.ch/project/eos/installation/0.3.84-aquamarine/bin/eos.select"
EOS = "/afs/cern.ch/project/eos/installation/0.3.15/bin/eos.select"
# should match wildcard, that for some reason new root does not
if '/store/' not in name and '/eos/user' not in name: return [name]
if '/eos/cms/store/' in name: return [name] # likely already parsed
Expand Down
2 changes: 1 addition & 1 deletion python/hmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def __init__(self):
class HmmConfigWithTTH(HmmConfigAutoCat):
def __init__(self):
HmmConfigAutoCat.__init__(self)
self.categories=[ "cat%d"%x for x in range(0,15)]
self.categories=[ "cat%d"%x for x in range(0,16)]
self.computeVersioning()

hmmTTH =HmmConfigTTH()
Expand Down
2 changes: 1 addition & 1 deletion python/mcDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

(opts,args)=parser.parse_args()

EOS = "/afs/cern.ch/project/eos/installation/0.3.84-aquamarine/bin/eos.select"
EOS = "/afs/cern.ch/project/eos/installation/0.3.15/bin/eos.select"
if '/eos/user' in opts.eos: EOS += " root://eosuser"

if opts.rec:
Expand Down
2 changes: 1 addition & 1 deletion python/puDistributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

(opts,args)=parser.parse_args()

EOS = "/afs/cern.ch/project/eos/installation/0.3.84-aquamarine/bin/eos.select"
EOS = "/afs/cern.ch/project/eos/installation/0.3.15/bin/eos.select"
if '/eos/user' in opts.eos: EOS += " root://eosuser"

if opts.eos=="" and opts.mcdb!="":
Expand Down
2 changes: 0 additions & 2 deletions script/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ def drange(start, stop, step):

onews=0 ## for onews

EOS='/afs/cern.ch/project/eos/installation/0.3.84-aquamarine/bin/eos.select'

print "inserting in path cwd"
sys.path.insert(0,os.getcwd())
print "inserting in path cwd/python",
Expand Down
10 changes: 8 additions & 2 deletions script/dumpSystHmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
parser.add_option("","--syst",type='string',help="Syst [Default=%default]", default="PU")
parser.add_option("","--outname",type='string',help="OutSystName [Default=%default]", default="cms_pu")
parser.add_option("","--rebin",type='int',help="Rebin [Default=%default]", default=20)
parser.add_option("","--hmm",dest="hmm",type="string",help="HmmConfig instance [%default]",default="hmmWithTTH")
opts, args = parser.parse_args()

#python script/drawSyst.py -i test/Hmumu/Hmumu_2017_03_07_JES_BTAG/Hmumu_2017_03_07_JES_BTAG.root --base=HmumuAnalysis/Vars/Mmm_OneB_BB_GluGlu_HToMuMu_M125 --syst=BTAGL
Expand All @@ -21,9 +22,11 @@
print "-> Base Path is " + basepath
sys.path.insert(0,basepath)
sys.path.insert(0,basepath +"/python")
from hmm import hmm, hmmAutoCat
from hmm import *

config=hmmAutoCat
#config=hmmAutoCat
config= eval(opts.hmm)
config.Print()

fIn=ROOT.TFile.Open(opts.input)
if fIn==None:
Expand Down Expand Up @@ -72,6 +75,9 @@ def appendToLine(l,valDown,valUp):
continue
elif h == None:
print >> sys.stderr, "[ERROR] Hist", name, "doesn't exist"
if( cat =="cat15" and proc =="VBF") :
systsline .append( "-")
continue ## ok for this
raise IOError
elif opts.syst!= 'Scale' and opts.syst != 'Pdf':
hUp=fIn.Get(name+"_"+opts.syst+"Up")
Expand Down
2 changes: 1 addition & 1 deletion script/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

(opts,args)=parser.parse_args()

EOS='/afs/cern.ch/project/eos/installation/0.3.84-aquamarine/bin/eos.select'
EOS='/afs/cern.ch/project/eos/installation/0.3.15/bin/eos.select'

if 'CMSSW_BASE' not in os.environ:
print "-> Use a CMSSW environment: cmsenv"
Expand Down
17 changes: 9 additions & 8 deletions src/AnalysisHmumu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,13 @@ string HmumuAnalysis::CategoryBdt(Lepton*mu0, Lepton*mu1, const vector<Jet*>& je
if ( bdt[0] >= 0.050 and bdt[0] < 0.250 and mu_max_eta < 0.900 ) icat = 4 ;
if ( bdt[0] >= 0.250 and bdt[0] < 0.400 and mu_max_eta < 0.900 ) icat = 5 ;
if ( mu_max_eta < 1.900 and bdt[0] >= 0.250 and bdt[0] < 0.400 and mu_max_eta >= 0.900 ) icat = 6 ;
if ( bdt[0] >= 0.050 and bdt[0] < 0.250 and mu_max_eta >= 0.900 ) icat = 7 ;
if ( bdt[0] >= -0.400 and bdt[0] < 0.050 and mu_max_eta < 1.900 ) icat = 8 ;
if ( bdt[0] < 0.730 and bdt[0] >= 0.650 ) icat = 9 ;
if ( mu_max_eta < 1.900 and bdt[0] < 0.650 and bdt[0] >= 0.400 and mu_max_eta >= 0.900 ) icat = 10 ;
if ( bdt[0] < 0.650 and bdt[0] >= 0.400 and mu_max_eta < 0.900 ) icat = 11 ;
if ( bdt[0] >= 0.730 ) icat = 12 ;
if ( bdt[0] >= 0.050 and bdt[0] < 0.250 and mu_max_eta >= 0.900 and mu_max_eta < 1.9) icat = 7 ;
if ( bdt[0] >= -0.400 and bdt[0] < 0.050 and mu_max_eta < 0.9 ) icat = 8 ;
if ( bdt[0] >= -0.400 and bdt[0] < 0.050 and mu_max_eta < 1.900 and mu_max_eta >=0.9) icat = 9 ;
if ( bdt[0] < 0.730 and bdt[0] >= 0.650 ) icat = 10 ;
if ( mu_max_eta < 1.900 and bdt[0] < 0.650 and bdt[0] >= 0.400 and mu_max_eta >= 0.900 ) icat = 11 ;
if ( bdt[0] < 0.650 and bdt[0] >= 0.400 and mu_max_eta < 0.900 ) icat = 12 ;
if ( bdt[0] >= 0.730 ) icat = 13 ;
//

if (icat>=0)catStr=Form("cat%d",icat);
Expand Down Expand Up @@ -935,8 +936,8 @@ int HmumuAnalysis::analyze(Event *e, string systname)
else if (catType==2) category = CategoryBdt(mu0,mu1,selectedJets,e->GetMet().Pt());
else if (catType==3) {
category = CategoryBdt(mu0,mu1,selectedJets,e->GetMet().Pt());
if (e->Bjets()>0 and e->Njets() >4) category = "cat13"; // ttHHadr
if (e->Bjets()>0 and e->Njets() >1 and e->Nleps()>2 ) category="cat14"; // veto Njets> 4
if (e->Bjets()>0 and e->Njets() >4) category = "cat14"; // ttHHadr
if (e->Bjets()>0 and e->Njets() >1 and e->Nleps()>2 ) category="cat15"; // veto Njets> 4
}
else category = Category(mu0, mu1, selectedJets);

Expand Down
2 changes: 2 additions & 0 deletions src/BackgroundFitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ RooAbsPdf* PdfModelBuilder::getZModExp2(string prefix, int order){
string pname = prefix+suf;
string old = pname;
replace(old,"zmod2","zmod");
replace(old,Form("ord%d",order),"ord1");
if (params.find(old) != params.end()) params[pname] -> setVal( params[old]->getVal());
else cout <<"WARNING UNABLE TO FIND REPLACEMENT FROM "<<old<<" TO "<<pname<<endl;
}
Expand Down Expand Up @@ -1198,6 +1199,7 @@ void BackgroundFitter::fit(){
system(Form("mkdir -p %s/zmod2/",plotDir.c_str()));
c -> SaveAs( Form("%s/zmod2/zmod2_all_cat%d.pdf",plotDir.c_str(),cat) );
c -> SaveAs( Form("%s/zmod2/zmod2_all_cat%d.png",plotDir.c_str(),cat) );

delete p;
delete c;
}
Expand Down
53 changes: 53 additions & 0 deletions src/JetFilter2016.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include "interface/JetFilter2016.hpp"
#include "TFile.h"

//#define DEBUG 2

#ifdef DEBUG
#include <iostream>
#endif

void JetFilter2016::Init(){
TFile *f=TFile::Open("aux/hotjets-runBCDEFGH.root");
h.reset( (TH2D*)f->Get("h2jet")->Clone() ) ;
//f->Close();
}

int JetFilter2016::correct(Event *e)
{
#ifdef DEBUG
if (DEBUG>1){
std::cout <<" BEFORE CORRECTIONS:";
for(int ijet =0; ;ijet++)
{
Jet *j= e->GetJet(ijet);
if (j==NULL) break;
std::cout << "("<<j->Pt()<<","<<j->Eta()<<","<<j->Phi()<<") ";

}
std::cout << std::endl;
}
#endif

for (auto&j : GetJetVector(e) )
{
if ( h->GetBinContent(h->FindBin(j->Eta(), j->Phi())) > 0)
{
// bad
Scale(*j,0.0);
}
}
#ifdef DEBUG
if (DEBUG>1){
std::cout <<" AFTER CORRECTIONS:";
for(int ijet =0; ;ijet++)
{
Jet *j= e->GetJet(ijet);
if (j==NULL) break;
std::cout << "("<<j->Pt()<<","<<j->Eta()<<","<<j->Phi()<<") ";

}
std::cout << std::endl;
}
#endif
}
1 change: 1 addition & 0 deletions src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "interface/JSON.hpp"
#include "interface/KalmanMuonCalibrator.hpp"
#include "interface/KaMuCa.hpp"
#include "interface/JetFilter2016.hpp"
#include "interface/Lepton.hpp"
#include "interface/LinkDef.hpp"
#include "interface/Loader.hpp"
Expand Down
113 changes: 0 additions & 113 deletions test/bias/polyfewz/collect.py

This file was deleted.

0 comments on commit 2f632bf

Please sign in to comment.