From d211690e138cdf544f20b58aec5cec277e1a224e Mon Sep 17 00:00:00 2001 From: Abideh Jafari <nadjieh@users.noreply.github.com> Date: Thu, 14 Mar 2019 16:38:46 +0100 Subject: [PATCH 1/8] Update readme for MVA training --- TopAnalysis/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/TopAnalysis/README.md b/TopAnalysis/README.md index 5a6693bb..b5126866 100644 --- a/TopAnalysis/README.md +++ b/TopAnalysis/README.md @@ -172,6 +172,13 @@ To plot the output of the local analysis you can run the following: ``` python scripts/plotter.py -i analysis/ -j data/era2017/samples.json -l 12870 ``` +# BDT training +This part currently works only for the VBF analysis. The signal and background trees must have been produced in the previous session by enabling "--mvatree" with "SEL" option. +The training is done per category with the following command: +``` +python scripts/trainVbfBDT --vbf nt=50:mns=5:md=3:abb=0.6:nc=1 --ext LowVPtHighMJJ --sig signal.root --bkg backgrounds.root --cat A:VBF --card LowVPtHighMJJCard +``` +The example above is for "LowVPtHighMJJ" category. # Preparation of the data cards and workspaces @@ -180,3 +187,5 @@ This part currently works only for the VBF analysis. It assumes that there are r python scripts/makeWorkspace.py --Chan LowVPtHighMJJ --Hist vbfmva --nBin 20 --year 2016 --shapeOnly --doSignalPH ``` The input histogram will be rebinned to have five bins. If you remove "--doSignalPH", the signal process in the signal and control region will NOT be connected via the transfer function (TF). Note that the TF part is not developed fully since it is statistics limited. "--shapeOnly" is to disentangle the shape and rate systematics for non-TF version. + + -- GitLab From 6c4ec64d367dcd1f76b90e71db442527c121c3dd Mon Sep 17 00:00:00 2001 From: nadjieh <ajafari@cern.ch> Date: Thu, 14 Mar 2019 16:39:25 +0100 Subject: [PATCH 2/8] python script for BDT training --- TopAnalysis/scripts/trainVbfBDT.py | 62 ++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 TopAnalysis/scripts/trainVbfBDT.py diff --git a/TopAnalysis/scripts/trainVbfBDT.py b/TopAnalysis/scripts/trainVbfBDT.py new file mode 100755 index 00000000..854764ff --- /dev/null +++ b/TopAnalysis/scripts/trainVbfBDT.py @@ -0,0 +1,62 @@ + +import os +import sys +import optparse +import ROOT +import pickle +from collections import OrderedDict +import json +import re +import commands +from TopLJets2015.TopAnalysis.storeTools import * +from TopLJets2015.TopAnalysis.batchTools import * + +""" +Wrapper to be used when run in parallel +""" +def RunMethodPacked(args): + + options,extention,signal,background,category,card=args + print args + print 'Running with options ',options,' in ',category, ' category' + print 'The extention is ', extention, ' and the card is ', card + print 'Signal input is ',signal, ' and background input is ', background + try: + cmd='runTMVAClassification --vbf %s --ext %s --sig %s --bkg %s --cat %s --card %s' %(options,extention,signal,background,category,card) + print '>>>>>>' + print(cmd) + os.system(cmd) + except : + print 50*'<' + print " Something is wrong! " + print 50*'<' + return False + return True + +""" +""" +def main(): + + #configuration + usage = 'usage: %prog [options]' + parser = optparse.OptionParser(usage) + parser.add_option('' , '--vbf', dest='options', help='options for BDT training [%default]', default='nt=50:mns=5:md=3:abb=0.6:nc=1', type='string') + parser.add_option('' , '--ext', dest='extention', help='extention for the weight file [%default]', default='LowVPtHighMJJ', type='string') + parser.add_option('' , '--sig', dest='signal', help='signal file name [%default]', default='signal.root', type='string') + parser.add_option('' , '--bkg', dest='background', help='background file name [%default]', default='backgrounds.root', type='string') + parser.add_option('' , '--cat', dest='category', help='selection category [%default]', default='A:VBF', type='string') + parser.add_option('' , '--card', dest='card', help='card name including input variables [%default]', default='LowVPtHighMJJCard', type='string') + + + (opt, args) = parser.parse_args() + print opt + print args + + args = [opt.options,opt.extention,opt.signal,opt.background,opt.category,opt.card] + RunMethodPacked(args) + +""" +for execution from another script +""" +if __name__ == "__main__": + sys.exit(main()) -- GitLab From 51b5d634b25f812b52a2e5d17bec4add75295325 Mon Sep 17 00:00:00 2001 From: Abideh Jafari <nadjieh@users.noreply.github.com> Date: Fri, 15 Mar 2019 08:57:22 +0100 Subject: [PATCH 3/8] Update README.md --- TopAnalysis/README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/TopAnalysis/README.md b/TopAnalysis/README.md index b5126866..c21ae3ab 100644 --- a/TopAnalysis/README.md +++ b/TopAnalysis/README.md @@ -178,7 +178,20 @@ The training is done per category with the following command: ``` python scripts/trainVbfBDT --vbf nt=50:mns=5:md=3:abb=0.6:nc=1 --ext LowVPtHighMJJ --sig signal.root --bkg backgrounds.root --cat A:VBF --card LowVPtHighMJJCard ``` -The example above is for "LowVPtHighMJJ" category. +The example above is for "LowVPtHighMJJ" category. Once happy with the training, +``` +cp vbf/weights/LowVPtHighMJJ_BDT_VBF0LowVPtHighMJJ* test/analysis/VBF_weights +``` +Update src/VBFVectorBoson.cc accordingly and compile. + +## Transformed BDT +To make the background BDT distribution flat, following steps must be followed: + * Produce plots with the compiled version of the code including new BDT weights (see Local analysis) and + ``` + cd test/analysis/VBF_weights + python getInverseCDFFromPlotter.py PATH_TO_plotter.root + ``` + * Reproduce the plots to have the proper flat BDT distribution of background # Preparation of the data cards and workspaces -- GitLab From 71ee07f6a8d280763b783b4895a7cd6e8c58aa4f Mon Sep 17 00:00:00 2001 From: nadjieh <ajafari@cern.ch> Date: Fri, 15 Mar 2019 09:25:48 +0100 Subject: [PATCH 4/8] update --- TopAnalysis/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 TopAnalysis/.gitignore diff --git a/TopAnalysis/.gitignore b/TopAnalysis/.gitignore new file mode 100644 index 00000000..c5960522 --- /dev/null +++ b/TopAnalysis/.gitignore @@ -0,0 +1 @@ +**/macro -- GitLab From c0006dd15dc8ad3bc7ec27fcd42e98122b9b1e31 Mon Sep 17 00:00:00 2001 From: nadjieh <ajafari@cern.ch> Date: Fri, 15 Mar 2019 09:27:09 +0100 Subject: [PATCH 5/8] update --- TopAnalysis/.gitignore | 4 ++++ TopAnalysis/test/analysis/steerVBFVectorBoson.sh | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/TopAnalysis/.gitignore b/TopAnalysis/.gitignore index c5960522..6c983e14 100644 --- a/TopAnalysis/.gitignore +++ b/TopAnalysis/.gitignore @@ -1 +1,5 @@ **/macro +**/test/analysis/VBFVectorBoson/ +**/grid +ajafari.cc +**/../CTPPSAnalysisTools diff --git a/TopAnalysis/test/analysis/steerVBFVectorBoson.sh b/TopAnalysis/test/analysis/steerVBFVectorBoson.sh index 25d73b56..c25f8da4 100644 --- a/TopAnalysis/test/analysis/steerVBFVectorBoson.sh +++ b/TopAnalysis/test/analysis/steerVBFVectorBoson.sh @@ -94,8 +94,8 @@ case $WHAT in ### --CR : gives a control region to evaluate fake rates in the photon data samples ### --SRfake : gives the distributions of fakes, normalised based on fake rates - #json=data/era${ERA}/vbf_samples.json,data/era${ERA}/vbf_syst_samples.json - json=data/era${ERA}/vbf_syst_samples.json + json=data/era${ERA}/vbf_samples.json,data/era${ERA}/vbf_syst_samples.json + #json=data/era${ERA}/vbf_syst_samples.json if [[ -z ${EXTRA} ]]; then echo "Making trees ... " @@ -105,7 +105,7 @@ case $WHAT in fi echo ${json} python scripts/runLocalAnalysis.py \ - -i ${eosdir} --only EWKAJJ \ #${json} \ + -i ${eosdir} --only ${json} \ -o ${outdir}/${githash}/${EXTRA} \ --farmappendix ${githash} \ -q ${queue} --genWeights genweights_${githash}.root \ -- GitLab From b3b20982eae88fbe94bec4f873daa231eb89d5b5 Mon Sep 17 00:00:00 2001 From: nadjieh <ajafari@cern.ch> Date: Mon, 25 Mar 2019 12:40:39 +0100 Subject: [PATCH 6/8] FR update: bug fixes, etc. --- TopAnalysis/bin/runFRcalculation.cc | 37 ++++++-- TopAnalysis/bin/runWorkspaceProvider.cc | 2 +- TopAnalysis/data/era2017/fakeRatios.root | Bin 4582 -> 5470 bytes TopAnalysis/interface/FRcalculationVBF.h | 86 ++++++++++++++---- TopAnalysis/scripts/createFakeRatio.py | 21 +++-- TopAnalysis/src/SelectionTools.cc | 22 ++--- TopAnalysis/src/VBFVectorBoson.cc | 37 ++++---- .../test/analysis/steerVBFVectorBoson.sh | 6 +- 8 files changed, 139 insertions(+), 72 deletions(-) mode change 100644 => 100755 TopAnalysis/scripts/createFakeRatio.py diff --git a/TopAnalysis/bin/runFRcalculation.cc b/TopAnalysis/bin/runFRcalculation.cc index d6ccd481..97400ecf 100644 --- a/TopAnalysis/bin/runFRcalculation.cc +++ b/TopAnalysis/bin/runFRcalculation.cc @@ -1,7 +1,22 @@ #include "TopLJets2015/TopAnalysis/interface/FRcalculationVBF.h" +#include "TChain.h" +#include "TFile.h" +#include "TTree.h" +#include "TString.h" +#include "TObjString.h" +#include "TSystem.h" +#include "TROOT.h" +#include "TMVA/Tools.h" +#include "TMVA/Factory.h" +#include "TMVA/DataLoader.h" +#include "TMVA/TMVARegGui.h" + +using namespace std; +using namespace TMVA; int main( int argc, char** argv ) { TString fGammaData("Data13TeV_SinglePhoton_2017.root"), fJetData("Data13TeV_JetHT_2017.root"), fJetQCD("Data13TeV_JetHTQCD_2017.root"), fGammaMC("MC13TeV_GJets.root"); + std::string categories; for (int i=1; i<argc; i++) { TString input(argv[i]); if ( input=="--fGdata"){ @@ -20,15 +35,23 @@ int main( int argc, char** argv ) i++; fGammaMC = TString(argv[i]); continue; - } + } else if( input == "--cats"){ + i++; + categories = std::string(argv[i]); + } + } + std::vector<TString> cats = TMVA::gTools().SplitString( categories, ':' ); + for(unsigned int icat = 0; icat < cats.size(); icat++){ + cout << cats[icat]<<endl; + //HighMJJ: bias from VBF trigger --> use jet data + if(cats[icat].Contains("LowVPtHighMJJ")){ + promptEstimator(fJetData,cats[icat], "EB", fGammaMC, fJetQCD); + continue; + } + promptEstimator(fGammaData,cats[icat], "EB", fGammaMC, fJetQCD); + promptEstimator(fGammaData,cats[icat], "EE", fGammaMC, fJetQCD); } - //HighMJJ: bias from VBF trigger --> use jet data - promptEstimator(fJetData,"HighMJJA", "EB", fGammaMC, fJetQCD); - //LowMJJ: barrel - promptEstimator(fGammaData,"LowMJJA", "EB", fGammaMC, fJetQCD); - //LowMJJ: endcap - promptEstimator(fGammaData,"LowMJJA", "EE", fGammaMC, fJetQCD); makeFile(); return 0; diff --git a/TopAnalysis/bin/runWorkspaceProvider.cc b/TopAnalysis/bin/runWorkspaceProvider.cc index c7ab7931..04844734 100644 --- a/TopAnalysis/bin/runWorkspaceProvider.cc +++ b/TopAnalysis/bin/runWorkspaceProvider.cc @@ -64,6 +64,6 @@ int main( int argc, char** argv ) // wsp.makeCard(YE, TString("A"), doSignalPH, sigEff, bkgEff); // wsp.makeCard(YE, TString("MM"), doSignalPH, sigEff, bkgEff); wsp.makeCardNLO(YE, TString("A")); - wsp.plotSystSig(); + //wsp.plotSystSig(); return 0; } diff --git a/TopAnalysis/data/era2017/fakeRatios.root b/TopAnalysis/data/era2017/fakeRatios.root index bcc9eb977c7ee5a63dfaebd544e64335f7bffc2a..f54c9e86e19a7e48ca48d06290a63cffd1a4b9eb 100644 GIT binary patch literal 5470 zcmdT|cUV(fwm+1F5~NB99TiYPTIfybO;ALncL+5gB}nfGNUstQF(OSw5Gla|gd$B4 z2-1s4Xi`NGPy}9J=G`~%zB}K{oBP*2`Sy2qvd>z3=l5G@HSgQEQ2?-h0{{RA0ARKv zj&sDhJaLc^hYI=MCX`M908s)+{4VZ>U;D!FrFdc9tp07|266S@x<Y|tMS3>h>XCrh ziDu$%001)7a6uyI9BthY2DT`d+djhH$LIM!KLDU($rEXSB$z0uLL4U=0D!6FUmc62 z@OXDp^ohLk$?mhq^5lkEVruldxBZOtQCcoe&U!jJ*6J$sj^4KRC#SL2LwGwO9L#hn z%}4+=Dd11yV`G!sf}6wPGTU(LI2@(}*Gc>kuO1xk%uI$g7gT>XEhqo;$~^PNGH<F; zCYmGDBt3_F<AGUbe(o&s!Dd|BX%K#%IBUnX;c&n35fKpy5mda6p8$A5#85=U<Lrp{ z5fRF;u3+$Rd|P~v9hd?PW(GsS;Px;ZZK0KSBd?G@>?PbAxt1wd0XuO~xU;eaNGi42 zwt+0V8NgF9KZ}i%-BxvpW<xW|tl@B}3GbA%$T`X3BwflgFG%l=g@r#z%8F=h5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W>O_0R2llFUnjLW^44 zjpy>0D6jZwu*>DSdZ7q%?dk-=@-kMYUp+%6O1d+RVIXkGiDpxKOA-Z1iNnMlt#JB9 zX;4A`Y%M$VEFpN9BKfWKOus~L9IB&}l5jSr)q{I{+L>Ecm7Go2BMFoS70Zb~WaRE& z{i;aF6Q$`vmVIy`ySYQ4(Vu)*CMLK3hCJf{>c;InR8x7mHraAsi*b~%E_rTFIH0F^ z_=6~dt-PkIxT@)?>Cm02G}EUx#?n^4<F<u~81vbp$7_L>#if?SOW}`HII3g(1`I5C z1(A%YokW>)MaBv8j+3kwk3sMJN|0mWY%zK4-GejxYNk!xVzQf31=jYf)U|C540^QL z5~1Giv?qJ*d-OVSzrGc;pVSO-M=dEOtW2f7^)0C=Z5u9AmXh_i*D|$efKDBM97iqW zk)FY~*6(om`t7<~(@e}C>rhHxLgp$SFK(?Iw4N6LpMp!DH3pEp<dL(SL++XHe3o+{ zWeU!G=fBN4kfz8<;m?1VD)`T%*?&LeB55ddb|l(=9qBAtLkb7}{z#;FfnhN~G6nbt Dz@!Kd diff --git a/TopAnalysis/interface/FRcalculationVBF.h b/TopAnalysis/interface/FRcalculationVBF.h index 9d12a2a4..fdb25212 100644 --- a/TopAnalysis/interface/FRcalculationVBF.h +++ b/TopAnalysis/interface/FRcalculationVBF.h @@ -15,13 +15,22 @@ #include <vector> #include <iostream> #include <sstream> - - +#include <string> using namespace RooFit; using namespace std; + +TString corrCat(TString dataset, TString cat){ + if(dataset.Contains("JetHT") && cat.Contains("HighVPt")){ + cat = "HighVPtHighMJJA"; + } + return cat; +} + void fixZeroBins(TH1D * h){ + cout<<h->GetName()<<endl; for(int i = 0; i < h->GetXaxis()->GetNbins(); i++){ + cout<<h->GetBinContent(i+1) <<endl; if(h->GetBinContent(i+1) == 0) h->SetBinContent(i+1, 0.1); } } @@ -41,8 +50,17 @@ TH1D* mergeBin(TH1D * h){ TH1D* rawFRMaker(TH1D& Num1, TH1D& Den1, TString fname = "Data13TeV_SinglePhoton_2017.root", TString catName = "LowMJJA", TString det = "EB"){ TFile * f = TFile::Open(fname); - TH2D * Num = (TH2D*)f->Get(catName+"_tightMjj"+det); - TH2D * Den = (TH2D*)f->Get(catName+"_looseMjj"+det); + TString tmpCat = corrCat(fname,catName); + TH2D * Num = (TH2D*)f->Get(tmpCat+"_tightMjj"+det); + TH2D * Den = (TH2D*)f->Get(tmpCat+"_looseMjj"+det); + if(tmpCat == catName && catName == "HighVPtA"){ + Num = (TH2D*)f->Get("HighVPtHighMJJA_tightMjj"+det); + Den = (TH2D*)f->Get("HighVPtHighMJJA_looseMjj"+det); + TH2D * tmpNum = (TH2D*)f->Get("HighVPtLowMJJA_tightMjj"+det); + TH2D * tmpDen = (TH2D*)f->Get("HighVPtLowMJJA_looseMjj"+det); + Num->Add(tmpNum); + Den->Add(tmpDen); + } Num1 = *((TH1D*)Num->ProjectionY("rawNum")); Den1 = *((TH1D*)Den->ProjectionY("Den")); @@ -52,20 +70,25 @@ TH1D* rawFRMaker(TH1D& Num1, TH1D& Den1, TString fname = "Data13TeV_SinglePhoto } void makeFile(){ - TFile * f1 = TFile::Open("LowMJJA_FR_EE.root"); - TFile * f2 = TFile::Open("LowMJJA_FR_EB.root"); - TFile * f3 = TFile::Open("HighMJJA_FR_EB.root"); - TH1D * h1 = (TH1D*)f1->Get("fracRatio_Merged"); - h1->SetName("LowMJJ_EE"); - TH1D * h2 = (TH1D*)f2->Get("fracRatio_Merged"); - h2->SetName("LowMJJ_EB"); - TH1D * h3 = (TH1D*)f3->Get("fracRatio"); - h3->SetName("HigMJJ_EB"); + const int nCat = 4; + TString cats[nCat] = {"LowVPtHighMJJ","HighVPtHighMJJ","HighVPtLowMJJ","HighVPt"}; + TString det[2] = {"EB","EE"}; + std::vector<TH1D*> hists; + for(int iCat = 0; iCat < nCat; iCat++){ + for(int iDet = 0; iDet < 2; iDet++){ + TFile * f = TFile::Open(cats[iCat]+"A_FR_"+det[iDet]+".root"); + if(f){ + TH1D * h = (TH1D*) f->Get("fracRatio_Merged"); + h->SetName(cats[iCat]+"_"+det[iDet]); + hists.push_back(h); + } + } + } + TFile * f = new TFile("fakeRatios.root","recreate"); f->cd(); - h1->Write(); - h2->Write(); - h3->Write(); + for(unsigned int iHist = 0; iHist < hists.size(); iHist++) + hists[iHist]->Write(); f->Close(); } @@ -74,7 +97,21 @@ void promptEstimator(TString dataname = "Data13TeV_SinglePhoton_2017.root", TStr if (det == "EE") pHigh = 0.0271; TFile * fD = TFile::Open(dataname); - TH2D * data = (TH2D*)fD->Get(catName+"_relaxedTightMjj"+det); + TString tmpCat = corrCat(dataname,catName); + TH2D * data = 0; + TString gDataHist("relaxedTightMjj"),qcdDataHist("tmpQCDMjj"),gMCHist("tightMjj"); + //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + // tmpQCD <--> relaxedTight + //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + if(tmpCat == catName && catName == "HighVPtA"){ + data = (TH2D*)fD->Get("HighVPtHighMJJA_"+gDataHist+det); + TH2D * tmpdata = (TH2D*)fD->Get("HighVPtLowMJJA_"+gDataHist+det); + data->Add(tmpdata); + } else data = (TH2D*)fD->Get(tmpCat+"_"+gDataHist+det); + if(!data) { + cout << "Wrong category name "<< catName<<endl; + return; + } std::vector<TH1D*> dataSihih; std::vector<double> trueNData; for(int i = 0; i<4; i++){ @@ -86,7 +123,12 @@ void promptEstimator(TString dataname = "Data13TeV_SinglePhoton_2017.root", TStr TH1D * tmpMJJ = (TH1D*)data->ProjectionY("DataMJJ"); RooRealVar sihih("sihih","sihih",0,0.1); TFile * fP = TFile::Open(pname); - TH2D * prompt2 = (TH2D*)fP->Get(catName+"_tightMjj"+det); + TH2D * prompt2 = (TH2D*)fP->Get(catName+"_"+gMCHist+det); + if(catName == "HighVPtA"){ + prompt2 = (TH2D*)fP->Get("HighVPtHighMJJA_"+gMCHist+det); + TH2D * tmpPrompt2 = (TH2D*)fP->Get("HighVPtLowMJJA_"+gMCHist+det); + prompt2->Add(tmpPrompt2); + } TH1D * prompt = (TH1D*)prompt2->ProjectionX("Prompt"); prompt->Scale(1/prompt->Integral()); double pFrac = prompt->Integral(1,prompt->GetXaxis()->FindBin(pHigh)); @@ -95,8 +137,11 @@ void promptEstimator(TString dataname = "Data13TeV_SinglePhoton_2017.root", TStr RooDataHist dP("dP","dP",sihih,Import(*prompt)); RooHistPdf promptPdf("promptPdf","promptPdf",sihih,dP,0) ; TFile * fQ = TFile::Open(qcd); - TH2D * QCD2 = (TH2D*)fQ->Get(catName+"_allMjj"+det); - //TH2D * QCD2 = (TH2D*)fD->Get(catName+"_tmpQCDMjj"+det); + tmpCat = corrCat(qcd,catName); + TH2D * QCD2 = (TH2D*)fQ->Get(tmpCat+"_"+qcdDataHist+det); + + // TH2D * QCD2 = (TH2D*)fD->Get(tmpCat+"_tmpQCDMjj"+det); + TH1D * QCD = (TH1D*)QCD2->ProjectionX("QCD"); QCD->Scale(1/QCD->Integral()); double fFrac = QCD->Integral(1,QCD->GetXaxis()->FindBin(pHigh)); @@ -109,6 +154,7 @@ void promptEstimator(TString dataname = "Data13TeV_SinglePhoton_2017.root", TStr TH1D* nPrompt = (TH1D*)tmpMJJ->Clone("nPrompt"); TH1D* nFake = (TH1D*)tmpMJJ->Clone("nFake"); TH1D* fakeFraction = (TH1D*)tmpMJJ->Clone("fakeFraction"); + for(unsigned int i =0; i<dataSihih.size();i++){ cout <<"Number of entries: "<<dataSihih[i]->GetEntries()<<endl; dataSihih[i]->Rebin(4); diff --git a/TopAnalysis/scripts/createFakeRatio.py b/TopAnalysis/scripts/createFakeRatio.py old mode 100644 new mode 100755 index e0f2e942..a199ea32 --- a/TopAnalysis/scripts/createFakeRatio.py +++ b/TopAnalysis/scripts/createFakeRatio.py @@ -15,12 +15,14 @@ Wrapper to be used when run in parallel """ def RunMethodPacked(args): - - fGammaData, fJetData, fJetQCD, fGammaMC=args + gData,jData,jQCD,gMC,cats=args print args - + print 'Running with photon data ',gData,' and photon MC ',gMC + print 'The JetData is ', jData, ' and ', jQCD, ' has teh QCD template' + print 'Fake rates will be provided for these categories', cats try: - cmd='runFRcalculation --fGdata %s --fJdata %s --fJQCD %s --fGMC %s' %(fGammaData,fJetData,fJetQCD,fGammaMC) + cmd='runFRcalculation --fGdata %s --fJdata %s --fJQCD %s --fGMC %s --cats %s' %(gData,jData,jQCD,gMC,cats) + print '>>>>>>' print(cmd) os.system(cmd) except : @@ -37,10 +39,11 @@ def main(): #configuration usage = 'usage: %prog [options]' parser = optparse.OptionParser(usage) - parser.add_option('', '--fGdata', dest='fGammaData', help='Photon data from CR [%default]', default='Data13TeV_SinglePhoton_2017.root', type='string') - parser.add_option('', '--fJdata', dest='fJetData', help='Jet data from CR [%default]', default='Data13TeV_JetHT_2017.root', type='string') - parser.add_option('', '--fJQCD', dest='fJetQCD', help='Data for QCD photon template [%default]', default='Data13TeV_JetHTQCD_2017.root', type='string') - parser.add_option('', '--fGMC', dest='fGammaMC', help='MC for prompt photon template [%default]', default='MC13TeV_GJets.root', type='string') + parser.add_option('' , '--fGdata', dest='gData', help='Photon data in signal region [%default]', default='Data13TeV_SinglePhoton_2017.root', type='string') + parser.add_option('' , '--fJdata', dest='jData', help='Jet data from control region [%default]', default='Data13TeV_JetHT_2017.root', type='string') + parser.add_option('' , '--fJQCD', dest='jQCD', help='Jet data for QCD templates [%default]', default='Data13TeV_JetHTQCD_2017.root', type='string') + parser.add_option('' , '--fGMC', dest='gMC', help='Photon MC in signal region [%default]', default='MC13TeV_GJets.root', type='string') + parser.add_option('' , '--cats', dest='cats', help='selection categories [%default]', default='HighVPtA', type='string') @@ -48,7 +51,7 @@ def main(): print opt print args - args = [opt.fGammaData,opt.fJetData,opt.fJetQCD,opt.fGammaMC] + args = [opt.gData,opt.jData,opt.jQCD,opt.gMC,opt.cats] RunMethodPacked(args) """ diff --git a/TopAnalysis/src/SelectionTools.cc b/TopAnalysis/src/SelectionTools.cc index 47a8c94c..ee6ba382 100644 --- a/TopAnalysis/src/SelectionTools.cc +++ b/TopAnalysis/src/SelectionTools.cc @@ -99,26 +99,20 @@ TString SelectionTool::flagFinalState(MiniEvent_t &ev, std::vector<Particle> pre if( ch==13*13 && fabs(mll-91)<15 && (tightLeptons[0].pt()>30 || tightLeptons[1].pt()>30)) chTag="MM"; leptons_=tightLeptons; } else { - if (!isSRfake) { - if( tightPhotons.size()>=1){ - chTag="A"; - leptons_ =tightLeptons; - photons_ =tightPhotons; - } - } else { - if(fakePhotons.size()>=1){ - chTag="A"; - leptons_ =tightLeptons; - photons_ =tightPhotons; - } + bool passPhoton = (!isSRfake && tightPhotons.size()>=1) || (isSRfake && fakePhotons.size()>=1); + if(passPhoton){ + chTag="A"; + leptons_ =tightLeptons; } + if(isSRfake) photons_ = fakePhotons; + else photons_ = tightPhotons; } } else { if(isSRfake) return ""; - bool passPhoton = (!isSRfake && !isQCDTemp && inclusivePhotons.size()>=1) || (!isSRfake && isQCDTemp && tmpPhotons.size()>=1); + bool passPhoton = (!isQCDTemp && inclusivePhotons.size()>=1) || (isQCDTemp && tmpPhotons.size()>=1); if(passPhoton) { chTag="A"; - if(!isQCDTemp) photons_ =inclusivePhotons; + if(!isQCDTemp) photons_ =inclusivePhotons; else photons_ =tmpPhotons; //cout<< "Number of very loose photons: "<<photons_.size()<<endl; leptons_ =tightLeptons; diff --git a/TopAnalysis/src/VBFVectorBoson.cc b/TopAnalysis/src/VBFVectorBoson.cc index dac4dc39..991050e9 100644 --- a/TopAnalysis/src/VBFVectorBoson.cc +++ b/TopAnalysis/src/VBFVectorBoson.cc @@ -259,8 +259,8 @@ void VBFVectorBoson::runAnalysis() //select photons photons_ = selector_->selPhotons(allPhotons, SelectionTool::TIGHT, leptons); - relaxedTightPhotons_ = selector_->selPhotons(allPhotons,SelectionTool::QCDTEMP, leptons); - tmpPhotons_ = selector_->selPhotons(allPhotons,SelectionTool::RELAXEDTIGHT, leptons); + relaxedTightPhotons_ = selector_->selPhotons(allPhotons,SelectionTool::RELAXEDTIGHT, leptons); + tmpPhotons_ = selector_->selPhotons(allPhotons,SelectionTool::QCDTEMP, leptons); inclusivePhotons_ = selector_->selPhotons(allPhotons,SelectionTool::CONTROL, leptons); for(auto a : inclusivePhotons_) { int idx = a.originalReference(); @@ -280,7 +280,7 @@ void VBFVectorBoson::runAnalysis() if(fakePhotons_.size()>=1){ chTag="A"; photons_.clear(); - photons_ =fakePhotons_; + photons_ = fakePhotons_; } } } else { @@ -290,7 +290,7 @@ void VBFVectorBoson::runAnalysis() chTag="A"; photons_.clear(); if(!QCDTemp_) photons_ =inclusivePhotons_; - else photons_ =tmpPhotons_; + else photons_ =tmpPhotons_; } } @@ -315,18 +315,17 @@ void VBFVectorBoson::runAnalysis() } //MC truth for the selected photons - for(auto a : photons_) { - int idx=a.originalReference(); - bool isPrompt(ev_.gamma_isPromptFinalState[idx]); - if (selector_->isFakePhoton(ev_,idx)) { - fakeACR.push_back(a); - mults[isPrompt ? "looseprompt" : "loosefake"]++; - } else if (a.hasQualityFlag(SelectionTool::TIGHT)){ - tightACR.push_back(a); - mults[isPrompt ? "tightprompt" : "tightfake"]++; - } - } - + for(auto a : photons_) { + int idx=a.originalReference(); + bool isPrompt(ev_.gamma_isPromptFinalState[idx]); + if (selector_->isFakePhoton(ev_,idx)){ + fakeACR.push_back(a); + mults[isPrompt ? "looseprompt" : "loosefake"]++; + } else if (selector_->isTight(ev_,idx)){ + tightACR.push_back(a); + mults[isPrompt ? "tightprompt" : "tightfake"]++; + } + } } //no interesting channel has been found @@ -463,9 +462,11 @@ void VBFVectorBoson::runAnalysis() } //fake rate - if(ev_.isData && chTag=="A" && SRfake_ && (cat[4]||cat[5])) { + bool FRmeasured((cat[3] && cat[6]) || cat[4]); + if(ev_.isData && chTag=="A" && SRfake_ && FRmeasured) { + TString FRcat( baseCategory); + FRcat.Remove(FRcat.First(chTag),1); cout << "Fake Rate will be applied! " <<endl; - TString FRcat(cat[5] ? "LowMJJ" : "HighMJJ"); plotwgts[0]*=fr_->getWeight(FRcat, vbfVars_.mjj, photons_[0].Eta()); } diff --git a/TopAnalysis/test/analysis/steerVBFVectorBoson.sh b/TopAnalysis/test/analysis/steerVBFVectorBoson.sh index c25f8da4..e63fad9f 100644 --- a/TopAnalysis/test/analysis/steerVBFVectorBoson.sh +++ b/TopAnalysis/test/analysis/steerVBFVectorBoson.sh @@ -105,11 +105,11 @@ case $WHAT in fi echo ${json} python scripts/runLocalAnalysis.py \ - -i ${eosdir} --only ${json} \ + -i ${eosdir} --only SinglePhoton \ #${json} \ -o ${outdir}/${githash}/${EXTRA} \ --farmappendix ${githash} \ -q ${queue} --genWeights genweights_${githash}.root \ - --era era${ERA} -m VBFVectorBoson::RunVBFVectorBoson --ch 0 --runSysts --skipexisting ${extraOpts}; + --era era${ERA} -m VBFVectorBoson::RunVBFVectorBoson --ch 0 --runSysts --CR --skipexisting ${extraOpts}; ;; SELTRIGEFF ) @@ -144,7 +144,7 @@ case $WHAT in MERGE ) - ./scripts/mergeOutputs.py ${outdir}/${githash}/${EXTRA}; + ./scripts/mergeOutputs.py ${outdir}/${githash}/${EXTRA}${QCD}; ;; MERGETRIGEFF ) -- GitLab From a07e468698a775e0bc38808f72f56b90e49676dd Mon Sep 17 00:00:00 2001 From: nadjieh <ajafari@cern.ch> Date: Mon, 25 Mar 2019 13:20:18 +0100 Subject: [PATCH 7/8] FR distributions --- TopAnalysis/src/VBFVectorBoson.cc | 4 ++-- TopAnalysis/test/analysis/steerVBFVectorBoson.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TopAnalysis/src/VBFVectorBoson.cc b/TopAnalysis/src/VBFVectorBoson.cc index 991050e9..62c2fdbb 100644 --- a/TopAnalysis/src/VBFVectorBoson.cc +++ b/TopAnalysis/src/VBFVectorBoson.cc @@ -462,11 +462,11 @@ void VBFVectorBoson::runAnalysis() } //fake rate - bool FRmeasured((cat[3] && cat[6]) || cat[4]); + bool FRmeasured(chTags.size() > 1); if(ev_.isData && chTag=="A" && SRfake_ && FRmeasured) { TString FRcat( baseCategory); FRcat.Remove(FRcat.First(chTag),1); - cout << "Fake Rate will be applied! " <<endl; + cout << "Fake Rate will be applied in "<<baseCategory<<" with FRcat of "<<FRcat <<endl; plotwgts[0]*=fr_->getWeight(FRcat, vbfVars_.mjj, photons_[0].Eta()); } diff --git a/TopAnalysis/test/analysis/steerVBFVectorBoson.sh b/TopAnalysis/test/analysis/steerVBFVectorBoson.sh index e63fad9f..9596781c 100644 --- a/TopAnalysis/test/analysis/steerVBFVectorBoson.sh +++ b/TopAnalysis/test/analysis/steerVBFVectorBoson.sh @@ -55,7 +55,7 @@ case $WHAT in TESTSEL ) json=data/era${ERA}/vbf_samples.json - tag=MC13TeV_2017_EWKAJJ + tag=Data13TeV_2017F_SinglePhoton if [[ ${ERA} == "2016" ]]; then tag=MC13TeV_2016_TTJets fi @@ -67,7 +67,7 @@ case $WHAT in python scripts/runLocalAnalysis.py \ -i ${input} -o ${output} --tag ${tag} --only ${tag} --mvatree\ --njobs 8 -q local --genWeights genweights_${githash}.root \ - --era era${ERA} -m VBFVectorBoson::RunVBFVectorBoson --ch 0 --runSysts --debug; + --era era${ERA} -m VBFVectorBoson::RunVBFVectorBoson --ch 0 --runSysts --debug --SRfake ; #--debug --mvatree \ ./scripts/mergeOutputs.py ${output}; -- GitLab From ba3161a754066aded9d76b9acb013ba5ac17d384 Mon Sep 17 00:00:00 2001 From: nadjieh <ajafari@cern.ch> Date: Mon, 25 Mar 2019 14:24:22 +0100 Subject: [PATCH 8/8] FR instruction --- TopAnalysis/README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/TopAnalysis/README.md b/TopAnalysis/README.md index c21ae3ab..7768d3ae 100644 --- a/TopAnalysis/README.md +++ b/TopAnalysis/README.md @@ -200,5 +200,20 @@ This part currently works only for the VBF analysis. It assumes that there are r python scripts/makeWorkspace.py --Chan LowVPtHighMJJ --Hist vbfmva --nBin 20 --year 2016 --shapeOnly --doSignalPH ``` The input histogram will be rebinned to have five bins. If you remove "--doSignalPH", the signal process in the signal and control region will NOT be connected via the transfer function (TF). Note that the TF part is not developed fully since it is statistics limited. "--shapeOnly" is to disentangle the shape and rate systematics for non-TF version. - +# Photon fake rate estimation and distributions +The method is explained in AN-18-046. The FR is measured in bins of mjj separately for photons in the barrel and endcap. It is measured in a control region (CR) which has the same selection as the signal region except the 2nd jet that is required to ```fail``` the loose pileup identification. +## Input data for FR measurement + * Photon data (HighVPt categories): add ```--CR``` to the SEL option in steerVBFVectorBoson.sh + * Jet data (LowVPt category): run steerVBFVectorBoson.sh with SELJETHT in which ```--CR``` is a default input +## Input templates for FR measurement + * Tight template: the output of running default SEL option in steerVBFVectorBoson.sh on GJet samples + * Fake template: the output of running SELJETHT option with ```-q QCDTemp``` argument in steerVBFVectorBoson.sh +## Fake rate estimation + * Run the command below on the output of the aforementioned steps: +``` +python scripts/createFakeRatio.py --fGdata PHOTON-DATA --fJdata JETHT-DATA --fJQCD JETHT-DATA-QCDTEMP --fGMC GJET-MC --cats HighVPtHighMJJA:HighVPtLowMJJA:LowVPtHighMJJA +``` + * Copy the output ```fakeRatios.root``` to data/eraYEAR +## Fake rate application +Here the distributions of not-tight photons are scaled by the estimated FR. The distributions can be used then in plotting. Need to activate ```--SRfake``` for the SEL option in steerVBFVectorBoson.sh and run on SinglePhoton data -- GitLab