diff --git a/bin/BuildFile.xml b/bin/BuildFile.xml
index fc12ecf..d319f81 100644
--- a/bin/BuildFile.xml
+++ b/bin/BuildFile.xml
@@ -15,6 +15,19 @@
-->
+
+
+
+
+
+
+
+
+
diff --git a/bin/JetTriggerAnalysis.cc b/bin/JetTriggerAnalysis.cc
new file mode 100644
index 0000000..4e06285
--- /dev/null
+++ b/bin/JetTriggerAnalysis.cc
@@ -0,0 +1,28 @@
+#include "Analysis/Trigger/interface/JetTriggerAnalyser.h"
+
+using namespace analysis;
+using namespace analysis::tools;
+using namespace analysis::trigger;
+
+int main(int argc, char ** argv)
+{
+ TH1::SetDefaultSumw2(); // proper treatment of errors when scaling histograms
+
+ JetTriggerAnalyser trigger(argc,argv);
+ trigger.jetHistograms("Probes");
+ trigger.jetHistograms("Probes with matching");
+
+ for ( int i = 0 ; i < trigger.nEvents() ; ++i )
+ {
+ if ( ! trigger.event(i) ) continue; // read event, run selection/json
+ if ( ! trigger.selectionTrigger() ) continue; // trigger
+ if ( ! trigger.preselection() ) continue; // preselection
+ if ( ! trigger.jetCorrections() ) continue; // jet corrections
+ if ( ! trigger.jetKTEfirstSelection() ) continue; // jet corrections
+ trigger.jetKTEtagandprobeSelection();
+ }
+} // end main
+
+
+
+
diff --git a/bin/MuonTriggerAnalysis.cc b/bin/MuonTriggerAnalysis.cc
new file mode 100644
index 0000000..1acda41
--- /dev/null
+++ b/bin/MuonTriggerAnalysis.cc
@@ -0,0 +1,28 @@
+#include "Analysis/Trigger/interface/MuonTriggerAnalyser.h"
+#include "Analysis/Tools/interface/Analysis.h"
+#include
+#include
+
+using namespace analysis;
+using namespace analysis::tools;
+using namespace analysis::muontrigger;
+
+int main(int argc, char ** argv)
+{
+ TH1::SetDefaultSumw2(); // proper treatment of errors when scaling histogram
+
+ MuonTriggerAnalyser muontrigger(argc,argv);
+
+ for ( int i = 0 ; i < muontrigger.nEvents() ; ++i )
+ {
+
+ if ( ! muontrigger.event(i) ) continue; // read event, run selection/json
+ if ( ! muontrigger.selectionTrigger() ) continue; // trigger
+ if ( ! muontrigger.muonsSelection() ) continue; // muon first selection
+ if ( ! muontrigger.muonTagsSelection() ) continue; // muon tag selection
+ muontrigger.reconstructJPsi();
+
+ }
+} // end main
+
+
diff --git a/interface/JetTriggerAnalyser.h b/interface/JetTriggerAnalyser.h
index dd814e2..f1158d5 100644
--- a/interface/JetTriggerAnalyser.h
+++ b/interface/JetTriggerAnalyser.h
@@ -1,24 +1,14 @@
#ifndef Analysis_Trigger_JetTriggerAnalyser_h
#define Analysis_Trigger_JetTriggerAnalyser_h 1
-// -*- C++ -*-
//
-// Package: Analysis/MssmHbb
-// Class: Analysis
-//
-/**\class Analysis MssmHbbAnalyser.cc Analysis/MssmHbb/src/MssmHbbAnalyser.cc
-
- Description: [one line class summary]
-
- Implementation:
- [Notes on implementation]
-*/
-//
-// Original Author: Roberval Walsh Bastos Rangel
-// Created: Mon, 20 Oct 2014 14:24:08 GMT
+// Author: Daina Leyva
+// Created: Aug. 2021
+// Reviwed: Feb. 2024
//
//
+
// system include files
#include
#include
diff --git a/interface/MuonTriggerAnalyser.h b/interface/MuonTriggerAnalyser.h
index 811e8e0..79d3356 100644
--- a/interface/MuonTriggerAnalyser.h
+++ b/interface/MuonTriggerAnalyser.h
@@ -1,24 +1,14 @@
#ifndef Analysis_MuonTriggerAnalyser_h
#define Analysis_MuonTriggerAnalyser_h 1
-// -*- C++ -*-
//
-// Package: Analysis/MssmHbb
-// Class: Analysis
-//
-/**\class Analysis MssmHbbAnalyser.cc Analysis/MssmHbb/src/MssmHbbAnalyser.cc
-
- Description: [one line class summary]
-
- Implementation:
- [Notes on implementation]
-*/
-//
-// Original Author: Roberval Walsh Bastos Rangel
-// Created: Mon, 20 Oct 2014 14:24:08 GMT
+// Author: Daina Leyva
+// Created: Aug. 2021
+// Reviwed: Feb. 2024
//
//
+
// system include files
#include
#include
@@ -47,16 +37,22 @@ namespace analysis {
virtual bool event(const int &i);
bool muonsSelection();
+ //bool muonsSelection_upsilon();
bool muonTagsSelection();
- void muonPassandFail_MatchingProbesSelection();
+ void reconstructJPsi();
+ //void reconstruct_upsilon();
TH1D* TagsPt = new TH1D("Tags_Pt","TagsPt" , 300, 0, 30);
TH1D* PassedProbesPt = new TH1D("Matched_Probes_Pt","MatchedProbesPt" , 300, 0, 30);
TH1D* FailedProbesPt = new TH1D("Failed_Probes_Pt","FailedProbesPt" ,300, 0, 30);
- TH1D* DiMuonMass_afterTagSelection = new TH1D("DiMuonMass","DiMuonMass" , 50, 2.85, 3.35);
+ //TH1D* DiMuonMass_afterTagSelection = new TH1D("DiMuonMass","DiMuonMass" , 50, 2.85, 3.35);
+ //TH1D* DiMuonMass_afterTagSelection = new TH1D("DiMuonMass","DiMuonMass" , 80, 2.70, 3.50);
+ TH1D* DiMuonMass_afterTagSelection = new TH1D("DiMuonMass","DiMuonMass" , 80, 2.80, 3.60);
- TH2D* PassedDiMuonMass_vs_probespT = new TH2D("DiMuonMass of passing muons 2D","Passing Probes 2D" , 50, 2.85, 3.35, 300, 0, 30);
- TH2D* FailedDiMuonMass_vs_probespT = new TH2D("DiMuonMass of failing muons 2D","Failing Probes 2D" , 50, 2.85, 3.35, 300, 0, 30);
+ //TH2D* PassedDiMuonMass_vs_probespT = new TH2D("DiMuonMass of passing muons 2D","Passing Probes 2D" , 50, 2.85, 3.35, 300, 0, 30);
+ //TH2D* FailedDiMuonMass_vs_probespT = new TH2D("DiMuonMass of failing muons 2D","Failing Probes 2D" , 50, 2.85, 3.35, 300, 0, 30);
+ TH2D* PassedDiMuonMass_vs_probespT = new TH2D("DiMuonMass of passing muons 2D","Passing Probes 2D" , 80, 2.80, 3.60, 300, 0, 30);
+ TH2D* FailedDiMuonMass_vs_probespT = new TH2D("DiMuonMass of failing muons 2D","Failing Probes 2D" , 80, 2.80, 3.60, 300, 0, 30);
// ----------member data ---------------------------
protected:
diff --git a/src/JetTriggerAnalyser.cc b/src/JetTriggerAnalyser.cc
index 7c1a6e3..8677271 100644
--- a/src/JetTriggerAnalyser.cc
+++ b/src/JetTriggerAnalyser.cc
@@ -1,16 +1,11 @@
-/**\class MssmHbb MssmHbbAnalyser.cc Analysis/Tools/src/MssmHbbAnalyser.cc
-
- Description: [one line class summary]
-
- Implementation:
- [Notes on implementation]
-*/
//
-// Original Author: Roberval Walsh
-// Created: Mon, 20 Oct 2014 14:24:08 GMT
+// Author: Daina Leyva
+// Created: Aug. 2021
+// Reviwed: Feb. 2024
//
//
+
// system include files
#include
//
@@ -75,8 +70,8 @@ bool JetTriggerAnalyser::jetKTEfirstSelection()
}
if ( selectedJets_[0]->deltaPhi(*selectedJets_[1]) < 2.4 ) return false;
- if ( selectedJets_[0]->eta() > 2.3 ) return false;
- if ( selectedJets_[1]->eta() > 2.3 ) return false;
+ if ( fabs(selectedJets_[0]->eta()) > 2.3 ) return false;
+ if ( fabs(selectedJets_[1]->eta()) > 2.3 ) return false;
if ( selectedJets_[2])
if ( selectedJets_[2]->pt() > (0.3*(selectedJets_[0]->pt()+selectedJets_[1]->pt())*0.5) ) return false;
diff --git a/src/MuonTriggerAnalyser.cc b/src/MuonTriggerAnalyser.cc
index bdd827d..a0802d9 100644
--- a/src/MuonTriggerAnalyser.cc
+++ b/src/MuonTriggerAnalyser.cc
@@ -1,13 +1,8 @@
-/**\class MssmHbb MssmHbbAnalyser.cc Analysis/Tools/src/MssmHbbAnalyser.cc
- Description: [one line class summary]
-
- Implementation:
- [Notes on implementation]
-*/
//
-// Original Author: Roberval Walsh
-// Created: Mon, 20 Oct 2014 14:24:08 GMT
+// Author: Daina Leyva
+// Created: Aug. 2021
+// Reviwed: Feb. 2024
//
//
@@ -76,8 +71,8 @@ bool MuonTriggerAnalyser::muonsSelection()
int q1, q2;
if ( ! this -> selectionMuonId() ) return false; // check if event has muons
- if ( ! this -> selectionMuons() ) return false; // selection of the two leading muons according to nminMuons, ptmax, ptmin and etamax from config file
- if (selectedMuons_[0] -> deltaR(*selectedMuons_[1]) < 0.1 ) return false; // check deltaR between leading muons
+ if ( ! this -> selectionMuons() ) return false; // selection of the 2 leading muons according to nminMuons, ptmax, ptmin and etamax from config file
+ if (selectedMuons_[0] -> deltaR(*selectedMuons_[1]) < 0.1 ) return false; // check deltaR between 2 leading muons
//Discriminate two muons with same charge and that their sum is outside J/Psi mass window
for ( int i = 0; i < config_ -> nMuonsMin(); i++ )
@@ -105,9 +100,10 @@ bool MuonTriggerAnalyser::muonsSelection()
bool MuonTriggerAnalyser::muonTagsSelection()
{
- TLorentzVector m1_afterTagSelection, m2_afterTagSelection, m_afterTagSelection;
+ TLorentzVector m1_afterTagSelection, m2_afterTagSelection, m_afterTagSelection; //reconstructed mass after tag selection
double MassObtained;
+ //matching of tag muon to online object and kinematic selection
if ( ! onlineL1MuonMatching(1) ) return false; //check tags L1 online matching
if ( ! onlineL3MuonMatching(1) ) return false; //check tags L3 online matching
if ( selectedMuons_[0] -> pt() < 10 ) return false; //pt condition for tags
@@ -130,10 +126,10 @@ bool MuonTriggerAnalyser::muonTagsSelection()
return true;
}
-void MuonTriggerAnalyser::muonPassandFail_MatchingProbesSelection()
+void MuonTriggerAnalyser::reconstructJPsi()
{
- TLorentzVector m1matched, m2matched, mmatched;
- TLorentzVector m1failedmatched,m2failedmatched,mfailedmatched;
+ TLorentzVector m1matched, m2matched, mmatched; //reconstructed mass after probes selection, from passing probes
+ TLorentzVector m1failedmatched,m2failedmatched,mfailedmatched; //reconstructed mass after probes selection, from failing probes
double matchedDiMuonMassObtained;
double failedmatchedDiMuonMassObtained;
diff --git a/test/ProcessingTools/JKTE_setp3_FitUncertaintyVariations.C b/test/ProcessingTools/JKTE_setp3_FitUncertaintyVariations.C
new file mode 100644
index 0000000..a246b26
--- /dev/null
+++ b/test/ProcessingTools/JKTE_setp3_FitUncertaintyVariations.C
@@ -0,0 +1,89 @@
+void JKTE_setp3_FitUncertaintyVariations()
+{
+ TH1::SetDefaultSumw2(); // proper treatment of errors when scaling histograms
+ TCanvas * c1 = new TCanvas("c1","",820,820);
+
+ int etabin = -1, sigma = 0, sign_var = 0;
+ double etamin, etamax;
+
+ cout<<"\nIntroduce the absolute values of the pseudorapidity limits for which the efficiency will be calculated\n";
+ cout<<"\n|eta| lower limit:\n";
+ cin >> etamin;
+ cout<<"\n|eta| upper limit:\n";
+ cin >> etamax;
+
+ cout<<"\nIntroduce the module of the variation in amounts of sigma\n";
+ cin >> sigma;
+
+ cout<<"\nIntroduce the sign of the variation\n";
+ cin >> sign_var;
+
+ if (etamin == 0)
+ etabin = 1;
+ else if (etamin == 1)
+ etabin = 2;
+ else if (etamin == 1.4)
+ etabin = 3;
+
+
+
+ TFile * f = new TFile(Form("TGraph_up_nominal_down/TGraph_scale_factor_2017_SL_%dsigma.root",sigma));
+
+ auto sf_up = (TGraphAsymmErrors*) f -> Get(Form("jetOnlineTriggerScaleFactor_eta_%g_to_%g_up",etamin,etamax));
+ auto sf_down = (TGraphAsymmErrors*) f -> Get(Form("jetOnlineTriggerScaleFactor_eta_%g_to_%g_down",etamin,etamax));
+ TFitResultPtr r1;
+
+ //fitting function
+ TF1 *fa1 = new TF1("fa1","[0]*erf([1]*x-[2])",40, 300);
+ fa1 -> SetParameters(1,0.05,1);
+
+ //Fit and plot the SF, EX0 to ignore x axis uncert.
+ if (sign_var == 1)
+ {
+ r1 = sf_up->Fit(fa1,"RS EX0");
+ sf_up->Draw("ap");
+ }
+
+ if (sign_var == -1)
+ {
+ r1 = sf_down->Fit(fa1,"RS EX0");
+ sf_down->Draw("ap");
+ }
+
+
+//---------------------------------------------
+ // print matrices
+ cout << endl;
+ cout << "chi2/ndf = " << r1->Chi2() << "/" << r1->Ndf() << " = " << r1->Chi2()/r1->Ndf() << ", prob = " << r1->Prob() << endl;
+ cout << endl;
+ cout << "*** Correlation Matrix ***" << endl;
+ r1 -> GetCorrelationMatrix().Print();
+ cout << endl;
+ cout << "*** Covariance Matrix ***" << endl;
+ r1 -> GetCovarianceMatrix().Print();
+//---------------------------------------------
+
+// Fit results
+
+ TFile fout(Form("results_fit_up_down/Funct_sf_%dsigma.root",sigma),"UPDATE");
+ if(sign_var == 1)
+ {
+ if(etabin == 1)
+ fa1->Write(Form("jetOnlineTriggerScaleFactor_etabin_0p0_to_1p0_%ds_up",sigma));
+ if(etabin == 2)
+ fa1->Write(Form("jetOnlineTriggerScaleFactor_etabin_1p0_to_1p4_%ds_up",sigma));
+ if(etabin == 3)
+ fa1->Write(Form("jetOnlineTriggerScaleFactor_etabin_1p4_to_2p2_%ds_up",sigma));
+ }
+
+ if(sign_var == -1)
+ {
+ if(etabin == 1)
+ fa1->Write(Form("jetOnlineTriggerScaleFactor_etabin_0p0_to_1p0_%ds_down",sigma));
+ if(etabin == 2)
+ fa1->Write(Form("jetOnlineTriggerScaleFactor_etabin_1p0_to_1p4_%ds_down",sigma));
+ if(etabin == 3)
+ fa1->Write(Form("jetOnlineTriggerScaleFactor_etabin_1p4_to_2p2_%ds_down",sigma));
+ }
+
+}
diff --git a/test/ProcessingTools/JKTE_step1_plot.C b/test/ProcessingTools/JKTE_step1_plot.C
new file mode 100644
index 0000000..2f629f9
--- /dev/null
+++ b/test/ProcessingTools/JKTE_step1_plot.C
@@ -0,0 +1,548 @@
+TH1D* ProjectHistogram(TH2F* h, double etamin, double etamax, char name[]);
+TGraphAsymmErrors* DivideTGraphsErrors(TGraphAsymmErrors* A, TGraphAsymmErrors* B);
+double ErrorDivision(double ea, double eb, double ValueA, double ValueB);
+void FillHistogramfromHistogram(TH1D* h1, TH1D* h2,int BinMin,int BinMax);
+void FillHistogramfromHistogram_newbinning(TH1D* h1, TH1D* h2,int BinMin,int BinMax);
+void Change_binning(TH1D* h1, TH1D* h2,int Number_of_bins_h1,int Number_of_bins_h2, Double_t *bineo);
+
+
+// MACRO TO PLOT THE JET KINEMATIC TRIGGER EFFICIENCY AS FUNCTION OF PT AMONG TWO USER DEFINED PSEUDORAPIDITY VALUES
+
+int JKE_step1_plot()
+{
+
+ TH1::SetDefaultSumw2(); // proper treatment of errors when scaling histograms
+
+ //For Scale Factors Data
+ //info from https://twiki.cern.ch/twiki/bin/viewauth/CMS/MSSMHiggs2BBbarRunIILegacy2017#Triggers_Luminosity
+ Double_t Luminosity_C = 9581; //Luminosity of the physics trigger in 2017 in pb=^-1
+ Double_t Luminosity_D = 4224;
+ Double_t Luminosity_E = 9261;
+ Double_t Luminosity_F = 13462;
+ Double_t Luminosity_Total_CDE = Luminosity_C + Luminosity_D + Luminosity_E; //Run2 Luminosity of the physics trigger in 2017 eras CDE in pb=^-1
+ Double_t Total_Physics_Trigger_Lumi = Luminosity_C + Luminosity_D + Luminosity_E + Luminosity_F; //Run2 Luminosity of the physics trigger in 2017 eras CDEF in pb=^-1
+
+ Double_t Luminosity_PFJet40_C = 0.05725; //Luminosity of the control trigger in pb=^-1
+ Double_t Luminosity_PFJet40_D = 0.01902;
+ Double_t Luminosity_PFJet40_E = 0.06548;
+ Double_t Luminosity_PFJet40_F = 0.07229;
+ Double_t Luminosity_Total_PFJet40_CDE = Luminosity_PFJet40_C + Luminosity_PFJet40_D + Luminosity_PFJet40_E; //Run2 Luminosity of the control trigger in 2017 eras CDE in pb=^-1
+ Double_t Total_PFJet40_Trigger_Lumi = Luminosity_PFJet40_C + Luminosity_PFJet40_D + Luminosity_PFJet40_E + Luminosity_PFJet40_F; //Run2 Luminosity of the physics control in 2017 eras CDEF in pb=^-1
+
+ Double_t Luminosity_PFJet60_C = 0.2286; //Luminosity of the control trigger in pb=^-1
+ Double_t Luminosity_PFJet60_D = 0.3515;
+ Double_t Luminosity_PFJet60_E = 0.2739;
+ Double_t Luminosity_PFJet60_F = 0.2582;
+ Double_t Luminosity_Total_PFJet60_CDE = Luminosity_PFJet60_C+Luminosity_PFJet60_D+Luminosity_PFJet60_E; //Run2 Luminosity of the control trigger in 2017 eras CDE in pb=^-1
+ Double_t Total_PFJet60_Trigger_Lumi = Luminosity_PFJet60_C + Luminosity_PFJet60_D + Luminosity_PFJet60_E + Luminosity_PFJet60_F; //Run2 Luminosity of the physics control in 2017 eras CDEF in pb=^-1
+
+ //The SF to scale to the physics trigger Lumi
+ Double_t ScaleFactor_F_PFJet40, ScaleFactor_F_PFJet60;
+ Double_t ScaleFactor_CDE_PFJet40, ScaleFactor_CDE_PFJet60;
+ ScaleFactor_CDE_PFJet40 = (Luminosity_Total_CDE/Total_Physics_Trigger_Lumi) * (Total_PFJet40_Trigger_Lumi/Luminosity_Total_PFJet40_CDE);
+ ScaleFactor_CDE_PFJet60 = (Luminosity_Total_CDE/Total_Physics_Trigger_Lumi) * (Total_PFJet60_Trigger_Lumi/Luminosity_Total_PFJet60_CDE);
+ ScaleFactor_F_PFJet40 = (Luminosity_F/Total_Physics_Trigger_Lumi) * (Total_PFJet40_Trigger_Lumi/Luminosity_PFJet40_F);
+ ScaleFactor_F_PFJet60 = (Luminosity_F/Total_Physics_Trigger_Lumi) * (Total_PFJet60_Trigger_Lumi/Luminosity_PFJet60_F);
+
+
+
+ // declare Tfiles
+ //For MC
+ TFile * f1 = new TFile("rootfiles_SL/my_MC_SL_JKTE_QCD_HT100to200_HLT_PFJet40.root");
+ TFile * f2 = new TFile("rootfiles_SL/my_MC_SL_JKTE_QCD_HT200to300_HLT_PFJet40.root");
+ TFile * f3 = new TFile("rootfiles_SL/my_MC_SL_JKTE_QCD_HT300to500_HLT_PFJet40.root");
+ TFile * f4 = new TFile("rootfiles_SL/my_MC_SL_JKTE_QCD_HT500to700_HLT_PFJet40.root");
+ TFile * f5 = new TFile("rootfiles_SL/my_MC_SL_JKTE_QCD_HT700to1000_HLT_PFJet40.root");
+ TFile * f6 = new TFile("rootfiles_SL/my_MC_SL_JKTE_QCD_HT1000to1500_HLT_PFJet40.root");
+ TFile * f7 = new TFile("rootfiles_SL/my_MC_SL_JKTE_QCD_HT1500to2000_HLT_PFJet40.root");
+ TFile * f8 = new TFile("rootfiles_SL/my_MC_SL_JKTE_QCD_HT2000toInf_HLT_PFJet40.root");
+
+ //For data
+ TFile * fDATA_PFJet40_1 = new TFile("rootfiles_SL/my_Data_SL_JKTE_JetHT_Run2017C_HLT_PFJet40.root");
+ TFile * fDATA_PFJet40_2 = new TFile("rootfiles_SL/my_Data_SL_JKTE_JetHT_Run2017D_HLT_PFJet40.root");
+ TFile * fDATA_PFJet40_3 = new TFile("rootfiles_SL/my_Data_SL_JKTE_JetHT_Run2017E_HLT_PFJet40.root");
+ TFile * fDATA_PFJet40_4 = new TFile("rootfiles_SL/my_Data_SL_JKTE_JetHT_Run2017F_HLT_PFJet40.root");
+
+ TFile * fDATA_PFJet60_1 = new TFile("rootfiles_SL/my_Data_SL_JKTE_JetHT_Run2017C_HLT_PFJet60.root");
+ TFile * fDATA_PFJet60_2 = new TFile("rootfiles_SL/my_Data_SL_JKTE_JetHT_Run2017D_HLT_PFJet60.root");
+ TFile * fDATA_PFJet60_3 = new TFile("rootfiles_SL/my_Data_SL_JKTE_JetHT_Run2017E_HLT_PFJet60.root");
+ TFile * fDATA_PFJet60_4 = new TFile("rootfiles_SL/my_Data_SL_JKTE_JetHT_Run2017F_HLT_PFJet60.root");
+
+
+ // get two pseudorapidity values among whose the efficiency is going to be calculted
+ double etamin, etamax;
+ cout<<"\nIntroduce the absolute values of the pseudorapidity limits for which the efficiency will be calculated\n";
+ cout<<"\n|eta| lower limit:\n";
+ cin >> etamin;
+ cout<<"\n|eta| upper limit:\n";
+ cin >> etamax;
+
+ //intervals
+ // 0 - 1 barrel
+ // 1 - 1.4 overlap
+ // 1.4 - 2.2 endcap
+
+ // get DATA denominator histograms
+ TH2F * h_denominatorDATA_PFJet40_1 = (TH2F*) fDATA_PFJet40_1 -> Get("Probes/pt_eta_jet2");
+ TH2F * h_denominatorDATA_PFJet40_2 = (TH2F*) fDATA_PFJet40_2 -> Get("Probes/pt_eta_jet2");
+ TH2F * h_denominatorDATA_PFJet40_3 = (TH2F*) fDATA_PFJet40_3 -> Get("Probes/pt_eta_jet2");
+ TH2F * h_denominatorDATA_PFJet40_4 = (TH2F*) fDATA_PFJet40_4 -> Get("Probes/pt_eta_jet2");
+ TH2F * h_denominatorDATA_PFJet60_1 = (TH2F*) fDATA_PFJet60_1 -> Get("Probes/pt_eta_jet2");
+ TH2F * h_denominatorDATA_PFJet60_2 = (TH2F*) fDATA_PFJet60_2 -> Get("Probes/pt_eta_jet2");
+ TH2F * h_denominatorDATA_PFJet60_3 = (TH2F*) fDATA_PFJet60_3 -> Get("Probes/pt_eta_jet2");
+ TH2F * h_denominatorDATA_PFJet60_4 = (TH2F*) fDATA_PFJet60_4 -> Get("Probes/pt_eta_jet2");
+ // get MC denominator histograms
+ TH2F * h_denominator1_2D = (TH2F*) f1 -> Get("Probes/pt_eta_jet2");
+ TH2F * h_denominator2_2D = (TH2F*) f2 -> Get("Probes/pt_eta_jet2");
+ TH2F * h_denominator3_2D = (TH2F*) f3 -> Get("Probes/pt_eta_jet2");
+ TH2F * h_denominator4_2D = (TH2F*) f4 -> Get("Probes/pt_eta_jet2");
+ TH2F * h_denominator5_2D = (TH2F*) f5 -> Get("Probes/pt_eta_jet2");
+ TH2F * h_denominator6_2D = (TH2F*) f6 -> Get("Probes/pt_eta_jet2");
+ TH2F * h_denominator7_2D = (TH2F*) f7 -> Get("Probes/pt_eta_jet2");
+ TH2F * h_denominator8_2D = (TH2F*) f8 -> Get("Probes/pt_eta_jet2");
+
+
+ // get DATA numerator histograms
+ TH2F * h_numeratorDATA_PFJet40_1 = (TH2F*) fDATA_PFJet40_1 -> Get("Probes with matching/pt_eta_jet2");
+ TH2F * h_numeratorDATA_PFJet40_2 = (TH2F*) fDATA_PFJet40_2 -> Get("Probes with matching/pt_eta_jet2");
+ TH2F * h_numeratorDATA_PFJet40_3 = (TH2F*) fDATA_PFJet40_3 -> Get("Probes with matching/pt_eta_jet2");
+ TH2F * h_numeratorDATA_PFJet40_4 = (TH2F*) fDATA_PFJet40_4 -> Get("Probes with matching/pt_eta_jet2");
+ TH2F * h_numeratorDATA_PFJet60_1 = (TH2F*) fDATA_PFJet60_1 -> Get("Probes with matching/pt_eta_jet2");
+ TH2F * h_numeratorDATA_PFJet60_2 = (TH2F*) fDATA_PFJet60_2 -> Get("Probes with matching/pt_eta_jet2");
+ TH2F * h_numeratorDATA_PFJet60_3 = (TH2F*) fDATA_PFJet60_3 -> Get("Probes with matching/pt_eta_jet2");
+ TH2F * h_numeratorDATA_PFJet60_4 = (TH2F*) fDATA_PFJet60_4 -> Get("Probes with matching/pt_eta_jet2");
+ // get MC numerator histograms
+ TH2F * h_numerator1_2D = (TH2F*) f1 -> Get("Probes with matching/pt_eta_jet2");
+ TH2F * h_numerator2_2D = (TH2F*) f2 -> Get("Probes with matching/pt_eta_jet2");
+ TH2F * h_numerator3_2D = (TH2F*) f3 -> Get("Probes with matching/pt_eta_jet2");
+ TH2F * h_numerator4_2D = (TH2F*) f4 -> Get("Probes with matching/pt_eta_jet2");
+ TH2F * h_numerator5_2D = (TH2F*) f5 -> Get("Probes with matching/pt_eta_jet2");
+ TH2F * h_numerator6_2D = (TH2F*) f6 -> Get("Probes with matching/pt_eta_jet2");
+ TH2F * h_numerator7_2D = (TH2F*) f7 -> Get("Probes with matching/pt_eta_jet2");
+ TH2F * h_numerator8_2D = (TH2F*) f8 -> Get("Probes with matching/pt_eta_jet2");
+
+
+
+ // Adding the Data era CDE samples
+ TH2F * h_numeratorDATA_CDE_PFJet40 = (TH2F*) h_numeratorDATA_PFJet40_1 -> Clone("h_numeratorDATA_CDEF_PFJet40");
+ TH2F * h_denominatorDATA_CDE_PFJet40 = (TH2F*) h_denominatorDATA_PFJet40_1 -> Clone("h_denominatorDATA_CDEF_PFJet40");
+ h_numeratorDATA_CDE_PFJet40 -> Add(h_numeratorDATA_PFJet40_2);
+ h_numeratorDATA_CDE_PFJet40 -> Add(h_numeratorDATA_PFJet40_3);
+ h_denominatorDATA_CDE_PFJet40 -> Add(h_denominatorDATA_PFJet40_2);
+ h_denominatorDATA_CDE_PFJet40 -> Add(h_denominatorDATA_PFJet40_3);
+
+
+ TH2F * h_numeratorDATA_CDE_PFJet60 = (TH2F*) h_numeratorDATA_PFJet60_1 ->Clone("h_numeratorDATA_CDEF_PFJet60");
+ TH2F * h_denominatorDATA_CDE_PFJet60 = (TH2F*) h_denominatorDATA_PFJet60_1->Clone("h_denominatorDATA_CDEF_PFJet60");
+ h_numeratorDATA_CDE_PFJet60 -> Add(h_numeratorDATA_PFJet60_2);
+ h_numeratorDATA_CDE_PFJet60 -> Add(h_numeratorDATA_PFJet60_3);
+ h_denominatorDATA_CDE_PFJet60 -> Add(h_denominatorDATA_PFJet60_2);
+ h_denominatorDATA_CDE_PFJet60 -> Add(h_denominatorDATA_PFJet60_3);
+
+
+ // Scale Data samples before adding CDE and F
+ h_numeratorDATA_PFJet40_4 -> Scale (ScaleFactor_F_PFJet40);
+ h_denominatorDATA_PFJet40_4 -> Scale (ScaleFactor_F_PFJet40);
+ h_numeratorDATA_CDE_PFJet40 -> Scale (ScaleFactor_CDE_PFJet40);
+ h_denominatorDATA_CDE_PFJet40 -> Scale (ScaleFactor_CDE_PFJet40);
+
+ h_numeratorDATA_PFJet60_4 -> Scale (ScaleFactor_F_PFJet60);
+ h_denominatorDATA_PFJet60_4 -> Scale (ScaleFactor_F_PFJet60);
+ h_numeratorDATA_CDE_PFJet60 -> Scale (ScaleFactor_CDE_PFJet60);
+ h_denominatorDATA_CDE_PFJet60 -> Scale (ScaleFactor_CDE_PFJet60);
+
+ // Adding Data samples
+ TH2F * h_numeratorDATA_PFJet40_2D = (TH2F*) h_numeratorDATA_CDE_PFJet40->Clone("h_numeratorDATA_PFJet40_2D");
+ TH2F * h_denominatorDATA_PFJet40_2D = (TH2F*) h_denominatorDATA_CDE_PFJet40->Clone("h_denominatorDATA_PFJet40_2D");
+
+ h_numeratorDATA_PFJet40_2D -> Add(h_numeratorDATA_PFJet40_4);
+ h_denominatorDATA_PFJet40_2D -> Add(h_denominatorDATA_PFJet40_4);
+
+ TH2F * h_numeratorDATA_PFJet60_2D = (TH2F*) h_numeratorDATA_CDE_PFJet60->Clone("h_numeratorDATA_PFJet60_2D");
+ TH2F * h_denominatorDATA_PFJet60_2D = (TH2F*) h_denominatorDATA_CDE_PFJet60->Clone("h_denominatorDATA_PFJet60_2D");
+
+ h_numeratorDATA_PFJet60_2D -> Add(h_numeratorDATA_PFJet60_4);
+ h_denominatorDATA_PFJet60_2D -> Add(h_denominatorDATA_PFJet60_4);
+
+ //Projecting Data Samples
+ TH1D* h_numeratorDATA_PFJet40 = ProjectHistogram(h_numeratorDATA_PFJet40_2D, etamin, etamax, "h_numeratorDATA_PFJet40");
+ TH1D* h_denominatorDATA_PFJet40 = ProjectHistogram(h_denominatorDATA_PFJet40_2D, etamin, etamax, "h_denominatorDATA_PFJet40");
+ TH1D* h_numeratorDATA_PFJet60 = ProjectHistogram(h_numeratorDATA_PFJet60_2D, etamin, etamax, "h_numeratorDATA_PFJet60");
+ TH1D* h_denominatorDATA_PFJet60 = ProjectHistogram(h_denominatorDATA_PFJet60_2D, etamin, etamax, "h_denominatorDATA_PFJet60");
+
+
+ // projection of each MC histogram
+
+ TH1D* h_denominator1 = ProjectHistogram(h_denominator1_2D, etamin, etamax, "h_denominator1_projected");
+ TH1D* h_denominator2 = ProjectHistogram(h_denominator2_2D, etamin, etamax, "h_denominator2_projected");
+ TH1D* h_denominator3 = ProjectHistogram(h_denominator3_2D, etamin, etamax, "h_denominator3_projected");
+ TH1D* h_denominator4 = ProjectHistogram(h_denominator4_2D, etamin, etamax, "h_denominator4_projected");
+ TH1D* h_denominator5 = ProjectHistogram(h_denominator5_2D, etamin, etamax, "h_denominator5_projected");
+ TH1D* h_denominator6 = ProjectHistogram(h_denominator6_2D, etamin, etamax, "h_denominator6_projected");
+ TH1D* h_denominator7 = ProjectHistogram(h_denominator7_2D, etamin, etamax, "h_denominator7_projected");
+ TH1D* h_denominator8 = ProjectHistogram(h_denominator8_2D, etamin, etamax, "h_denominator8_projected");
+
+ TH1D* h_numerator1 = ProjectHistogram(h_numerator1_2D, etamin, etamax, "h_numerator1_projected");
+ TH1D* h_numerator2 = ProjectHistogram(h_numerator2_2D, etamin, etamax, "h_numerator2_projected");
+ TH1D* h_numerator3 = ProjectHistogram(h_numerator3_2D, etamin, etamax, "h_numerator3_projected");
+ TH1D* h_numerator4 = ProjectHistogram(h_numerator4_2D, etamin, etamax, "h_numerator4_projected");
+ TH1D* h_numerator5 = ProjectHistogram(h_numerator5_2D, etamin, etamax, "h_numerator5_projected");
+ TH1D* h_numerator6 = ProjectHistogram(h_numerator6_2D, etamin, etamax, "h_numerator6_projected");
+ TH1D* h_numerator7 = ProjectHistogram(h_numerator7_2D, etamin, etamax, "h_numerator7_projected");
+ TH1D* h_numerator8 = ProjectHistogram(h_numerator8_2D, etamin, etamax, "h_numerator8_projected");
+
+ //--------------------------------------------------------------------------------------------------------
+ //This section is to combine the MC HT bins and the two data samples (with PFJet40 and PFJe60)
+
+ int SamplesSizeMC = 8; //How many MC HT bins
+ int SamplesSizeData = 2; //PFJet40 and PFJet60
+
+ TH1D* NumeratorHistogramsMC[8] = {h_numerator1,h_numerator2,h_numerator3,h_numerator4,h_numerator5,h_numerator6,h_numerator7,h_numerator8};
+ TH1D* DenominatorHistogramsMC[8] = {h_denominator1,h_denominator2,h_denominator3,h_denominator4,h_denominator5,h_denominator6,h_denominator7,h_denominator8};
+
+ TH1D* NumeratorHistogramsData[2] = {h_numeratorDATA_PFJet40,h_numeratorDATA_PFJet60};
+ TH1D* DenominatorHistogramsData[2] = {h_denominatorDATA_PFJet40,h_denominatorDATA_PFJet60};
+
+ // adding the MC histograms to only one
+ int LowerLimitBinMC = 1;
+ int UpperLimitBinMC = h_denominator1 -> GetNbinsX();
+ int SamplesLimitsMC[9] = {LowerLimitBinMC,65,108,175,269,425,587,866,UpperLimitBinMC+1}; //array to introduce the limits in which the samples will be read and the efficiency calculated. Limits selected to optimize statistics.
+
+ TH1D *h_numeratorMC_no_rebin = new TH1D("h_numeratorMC_no_rebin", "h_numeratorMC_no_rebin", UpperLimitBinMC, 0, UpperLimitBinMC);
+ TH1D *h_denominatorMC_no_rebin = new TH1D("h_denominatorMC_no_rebin", "h_denominatorMC_no_rebin", UpperLimitBinMC, 0, UpperLimitBinMC);
+
+ for(int i = 0; i < SamplesSizeMC; i++)
+ {
+ FillHistogramfromHistogram(h_numeratorMC_no_rebin,NumeratorHistogramsMC[i],SamplesLimitsMC[i],SamplesLimitsMC[i+1]);
+ FillHistogramfromHistogram(h_denominatorMC_no_rebin,DenominatorHistogramsMC[i],SamplesLimitsMC[i],SamplesLimitsMC[i+1]);
+ }
+
+
+ // adding the Data histograms to only one
+ int LowerLimitBinData = 1;
+ int UpperLimitBinData = h_numeratorDATA_PFJet60 -> GetNbinsX();
+ int SamplesLimitsData[3] = {LowerLimitBinData,140,UpperLimitBinData+1}; //array to introduce the limits in which the samples will be read and the efficiency calculated
+
+ TH1D *h_numeratorData_no_rebin = new TH1D("h_numeratorData_no_rebin", "h_numeratorData_no_rebin", UpperLimitBinData, 0, UpperLimitBinData);
+ TH1D *h_denominatorData_no_rebin = new TH1D("h_denominatorData_no_rebin", "h_denominatorData_no_rebin", UpperLimitBinData, 0, UpperLimitBinData);
+
+ for(int i = 0; i < SamplesSizeData; i++)
+ {
+ FillHistogramfromHistogram(h_numeratorData_no_rebin, NumeratorHistogramsData[i], SamplesLimitsData[i], SamplesLimitsData[i+1]);
+ FillHistogramfromHistogram(h_denominatorData_no_rebin, DenominatorHistogramsData[i], SamplesLimitsData[i], SamplesLimitsData[i+1]);
+ }
+
+
+ //--------------------------------------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------------------------------------
+ //This section is to change binning of numerator and denominator plots
+
+ Int_t Number_of_bins = 20;
+ Double_t *bineo;
+ Double_t bineo_array [21] = {30,35,40,45,50,55,60,65,70,75,80,85,90,95,110,125,140,160,180,200,300}; // should contain (Number_of_bins) + 1 numbers
+ bineo = bineo_array;
+
+ TH1D *h_numeratorMC = new TH1D("h_numeratorMC", "h_numeratorMC", Number_of_bins, bineo);
+ TH1D *h_denominatorMC = new TH1D("h_denominatorMC", "h_denominatorMC", Number_of_bins, bineo);
+ TH1D *h_numeratorData = new TH1D("h_numeratorData", "h_numeratorData", Number_of_bins, bineo);
+ TH1D *h_denominatorData = new TH1D("h_denominatorData", "h_denominatorData", Number_of_bins, bineo);
+
+
+ for(int i = 0; i < Number_of_bins; i++)
+ {
+ Change_binning(h_numeratorMC, h_numeratorMC_no_rebin, Number_of_bins, UpperLimitBinMC, bineo); //UpperLimitBinMC should be 1500 check
+ Change_binning(h_denominatorMC, h_denominatorMC_no_rebin, Number_of_bins, UpperLimitBinMC, bineo);
+ Change_binning(h_numeratorData, h_numeratorData_no_rebin, Number_of_bins, UpperLimitBinMC, bineo); //UpperLimitBinMC should be 1500 check
+ Change_binning(h_denominatorData, h_denominatorData_no_rebin, Number_of_bins, UpperLimitBinMC, bineo);
+ }
+
+ h_numeratorData_no_rebin -> Rebin(5);
+ h_denominatorData_no_rebin -> Rebin(5);
+ h_numeratorMC_no_rebin -> Rebin(5);
+ h_denominatorMC_no_rebin -> Rebin(5);
+
+
+ auto C = new TCanvas("C","Canvas",1000,1500);
+ C -> Divide (1,2);
+ //--------------------------------------------------------------------------------------------------------
+
+ //Efficiency computation and plot
+
+ // calculate the efficiency of MC
+ TGraphAsymmErrors* g_effMC = new TGraphAsymmErrors(h_numeratorMC, h_denominatorMC,"cl=0.683 b(1,1) mode");
+ g_effMC -> SetMarkerStyle(20);
+ g_effMC -> SetTitle("QCD");
+ g_effMC -> GetXaxis()->SetRangeUser(0, 300);
+
+ // calculate the efficiency of Data
+ TGraphAsymmErrors* g_effData = new TGraphAsymmErrors(h_numeratorData, h_denominatorData,"cl=0.683 b(1,1) mode");
+ g_effData -> SetMarkerStyle(20);
+ g_effData -> SetMarkerColor(kRed);
+ g_effData -> SetLineColor(kRed);
+ g_effData -> SetTitle("Data CDEF");
+ g_effData -> GetXaxis()->SetRangeUser(0, 300);
+
+
+ C -> cd(1);
+ TMultiGraph *mg = new TMultiGraph();
+ mg->Add(g_effData);
+ mg->Add(g_effMC);
+ mg->GetHistogram()->GetYaxis()->SetRangeUser(0,1.1);
+ mg->GetHistogram()->GetXaxis()->SetRangeUser(30, 300);
+ mg->GetHistogram()->GetXaxis()->SetTitle("p_{T}^{probe} [GeV]");
+ mg->GetHistogram()->GetYaxis()->SetTitle("Jet Kinematic Trigger Efficiency");
+ mg->GetXaxis()->SetTitleSize(0.045);
+ mg->GetYaxis()->SetTitleSize(0.045);
+ mg->Draw("AP");
+ gPad->SetGrid(1,1);
+ //gPad->BuildLegend();
+
+
+ TLatex latex;
+ latex.SetTextFont(43);
+ latex.SetTextSize(20);
+ latex.SetTextAlign(11);
+ latex.DrawLatexNDC(gPad->GetLeftMargin(), 1.02-C->GetTopMargin(),
+ (std::string("CMS Work in progress #sqrt{s} = 13 TeV, L = 36.67 fb^{-1}")).c_str());
+
+ TLatex latex1;
+ latex1.SetTextFont(43);
+ latex1.SetTextSize(20);
+ latex1.SetTextAlign(11);
+ latex1.DrawLatexNDC(0.8-gPad->GetLeftMargin(), 1.02-C->GetTopMargin(),
+ (std::string("HLT_PFJet40_er2p3").c_str()));
+
+ auto legend = new TLegend(0.6,0.25,0.8,0.45);
+ legend->SetHeader(Form("%g<|#eta|<%g",etamin,etamax),"C"); // option "C" allows to center the header
+ legend->AddEntry(g_effData,"Data CDEF","lep");
+ legend->AddEntry(g_effMC, "QCD","lep");
+ legend->Draw();
+
+
+ C -> cd(2);
+ C -> SetGrid();
+ TGraphAsymmErrors *ratioeff = DivideTGraphsErrors(g_effData, g_effMC);
+ ratioeff -> GetXaxis() -> SetRangeUser(30,300);
+ ratioeff -> GetYaxis() -> SetRangeUser(0.1,1.1);
+ ratioeff -> SetMarkerStyle(20);
+ ratioeff -> SetTitle ("");
+ ratioeff -> GetXaxis() -> SetTitle ("p_{T}^{probe} [GeV]");
+ ratioeff -> GetYaxis() -> SetTitle ("scale factor");
+ ratioeff -> GetXaxis() -> SetTitleSize(0.045);
+ ratioeff -> GetYaxis() -> SetTitleSize(0.045);
+ ratioeff -> Draw("AP");
+
+ //--------------------------------------------------------------------------------------------------------
+ // Fit parameters & check a goodness of fit chisquare test
+
+ TF1 *fa1 = new TF1("fa1","[0]*erf([1]*x-[2])",50, 300);
+ fa1 -> SetParameters(1,0.05,1);
+ //ratioeff -> Fit(fa1,"QNR");
+ TFitResultPtr r1 = ratioeff->Fit(fa1,"RS");
+ cout << "function: p0*erf(p1*x-p2)" << endl;
+ cout << "chi2/ndf = " << r1->Chi2() << "/" << r1->Ndf() << " = " << r1->Chi2()/r1->Ndf() << ", prob = " << r1->Prob() << endl;
+
+ fa1 -> Draw("same");
+ gPad->SetGrid(1,1);
+
+
+
+ //--------------------------------------------------------------------------------------------------------
+ //OUTPUTS
+ //--------------------------------------------------------------------------------------------------------
+
+ C -> SaveAs(Form("JKTE_2017_SL_eta_%g_to_%g.png",etamin,etamax));
+ C -> SaveAs(Form("JKTE_2017_SL_eta_%g_to_%g.pdf",etamin,etamax));
+
+
+ //save SF in a file for next step (get confidence intervals)
+ TFile f("TGraphs_scale_factor_2017_SL.root","UPDATE");
+ ratioeff->Write(Form("scale_factor_2017_SL_eta_%g_to_%g",etamin,etamax));
+
+ return 0;
+
+}
+
+//function for projectiong each MC sample numerator and denominator //ARREGLAR
+TH1D* ProjectHistogram(TH2F* h, double etamin, double etamax, char name[])
+{
+ //declare histograms and variables
+ TH1D *hprojected;
+ char name1[1000];
+ char name2[1000];
+ strcpy (name1, name);
+ strcpy (name2, name);
+ strcat(name1, "1");
+ strcat(name2, "2");
+ double Lowedgeup, Lowedgedown;
+ double half_bin_width = 0.5 * (h -> GetYaxis() -> GetBinWidth(1));
+
+ if (etamin == 0)
+ {
+ if (etamax == -1)
+ {
+ int LowerBin = 1;
+ int UpperBin = h -> GetNbinsY();
+
+ hprojected = h -> ProjectionX(name, LowerBin, UpperBin, "e");
+
+ }
+
+ else
+ {
+ int NbinX = h -> GetNbinsX();
+ int LowerBin = int(h -> FindBin(0,-1*etamax + half_bin_width)/NbinX);
+ int UpperBin = int(h -> FindBin(0,etamax - half_bin_width)/NbinX);
+
+ //Lowedgeup = h -> GetYaxis() -> GetBinLowEdge(UpperBin);
+ //Lowedgedown = h -> GetYaxis() -> GetBinLowEdge(LowerBin);
+
+ hprojected = h -> ProjectionX(name, LowerBin, UpperBin, "e");
+
+ //cout<< name << " Low_Edge_up "<< Lowedgeup << " Low_Edge_down "<< Lowedgedown< GetNbinsX();
+ int LowerBin1 = h -> FindBin(0,etamin + half_bin_width)/NbinX;
+ int UpperBin1 = h -> GetNbinsY();
+ int UpperBin2 = h -> FindBin(0,-1*etamin - half_bin_width)/NbinX;
+ int LowerBin2 = 1;
+
+ TH1D *hprojected1 = h -> ProjectionX(name1, LowerBin1, UpperBin1, "e");
+ TH1D *hprojected2 = h -> ProjectionX(name2, LowerBin2, UpperBin2, "e");
+
+ hprojected = hprojected1;
+ hprojected -> Add(hprojected2);
+ }
+
+ else
+ {
+ int NbinX = h -> GetNbinsX();
+ int LowerBin1 = int(h -> FindBin(0,etamin+half_bin_width)/NbinX);
+ int UpperBin1 = int(h -> FindBin(0,etamax-half_bin_width)/NbinX);
+ int UpperBin2 = int(h -> FindBin(0,-1*etamin-half_bin_width)/NbinX);
+ int LowerBin2 = int(h -> FindBin(0,-1*etamax+half_bin_width)/NbinX);
+
+ TH1D *hprojected1 = h -> ProjectionX(name1, LowerBin1, UpperBin1, "e");
+ TH1D *hprojected2 = h -> ProjectionX(name2, LowerBin2, UpperBin2, "e");
+
+ hprojected = hprojected1;
+ hprojected -> Add(hprojected2);
+
+ }
+ }
+
+ //hprojected -> Rebin(5);
+ return hprojected;
+
+}
+
+
+//function for proper treatment of errors in division of TGraphs
+double ErrorDivision(double ea, double eb, double ValueA, double ValueB)
+{
+ double err = sqrt((1/(ValueB*ValueB))*(ea*ea+eb*eb*((ValueA*ValueA)/(ValueB*ValueB))));
+ return err;
+}
+
+
+//This function divides two TGraphAsymmErrors that have the same number of points A/B
+TGraphAsymmErrors* DivideTGraphsErrors(TGraphAsymmErrors* A, TGraphAsymmErrors* B)
+{
+ int nPoints = A -> GetN(); // number of points in the TGraphs
+
+ double xA [nPoints], yA [nPoints];
+ double xB [nPoints], yB [nPoints];
+ double X [nPoints], Y[nPoints];
+ double xerrlower[nPoints], xerrupper[nPoints], yerrlower[nPoints], yerrupper[nPoints];
+ double x1a, x2a, y1a, y2a, x1b, x2b, y1b, y2b; //temporal variables to store the errors
+
+ for(int i=1; i <= nPoints; ++i)
+ {
+ A -> GetPoint(i-1, xA[i-1], yA[i-1]);
+ B -> GetPoint(i-1, xB[i-1], yB[i-1]);
+
+ X[i-1] = xA[i-1];
+
+ if (yB[i-1] != 0)
+ Y[i-1] = yA[i-1]/yB[i-1];
+ if (yB[i-1] == 0)
+ Y[i-1] = 0;
+
+ y1a = A -> GetErrorYlow(i-1);
+ y2a = A -> GetErrorYhigh(i-1);
+
+ y1b = B -> GetErrorYlow(i-1);
+ y2b = B -> GetErrorYhigh(i-1);
+
+ xerrlower[i-1] = A -> GetErrorXlow(i-1);
+ xerrupper[i-1] = A -> GetErrorXhigh(i-1);
+ yerrlower[i-1] = ErrorDivision(y1a, y1b, yA[i-1], yB[i-1]);
+ yerrupper[i-1] = ErrorDivision(y2a, y2b, yA[i-1], yB[i-1]);
+
+ //cout<<"Point number: "< GetBinContent(i);
+ BinError = h2 -> GetBinError(i);
+
+ h1 -> SetBinContent(i, BinContent);
+ h1 -> SetBinError(i, BinError);
+ }
+
+ return;
+}
+
+void Change_binning(TH1D* h1, TH1D* h2,int Number_of_bins_h1,int Number_of_bins_h2, Double_t *bineo) //h1 is the one to be filled and h2 is the one with content. BinMin included, BinMax not included.
+{
+ const int N = Number_of_bins_h1;
+ Double_t content = 0;
+ Double_t newcontent = 0;
+ Double_t error;
+ Double_t BinContent [20] = {0};
+ Double_t BinError [20] = {0};
+
+ for (int i=0; i < Number_of_bins_h2; i++) //loop over number of histograms to be read
+ {
+ content = h2 -> GetBinContent(i);
+
+ for(int j=0; j= bineo[j] && i < bineo[j+1] )//this was wrong!
+ if (i > bineo[j] && i <= bineo[j+1] )
+ BinContent[j] += content;
+ }
+
+ }
+
+ for (int k=0; k SetBinContent(k+1, BinContent[k]);
+ h1 -> SetBinError(k+1, error);
+ }
+
+ return;
+}
+
diff --git a/test/ProcessingTools/JKTE_step2_GetConfidenceIntervals.C b/test/ProcessingTools/JKTE_step2_GetConfidenceIntervals.C
new file mode 100644
index 0000000..c875b08
--- /dev/null
+++ b/test/ProcessingTools/JKTE_step2_GetConfidenceIntervals.C
@@ -0,0 +1,249 @@
+void JKTE_step2_GetConfidenceIntervals()
+{
+ //USE THIS FUNCTION TO GET GRAPHS WITH CONFIDENCE INTERVALS FROM THE FIT PERFORMED TO THE NOMINAL JET KINEMATIC SCALE FACTOR
+ //USER PROVIDES ETA RANGE AND SIGMA
+
+ TH1::SetDefaultSumw2(); // proper treatment of errors when scaling histograms
+ TFile * f = new TFile("TGraph_up_nominal_down/TGraphs_scale_factor_2017_SL.root");
+ TCanvas * c1 = new TCanvas("c1","",820,820);
+
+ int etabin = -1, sigma = 0;
+ double etamin, etamax;
+
+ cout<<"\nIntroduce the absolute values of the pseudorapidity limits for which the efficiency will be calculated\n";
+ cout<<"\n|eta| lower limit:\n";
+ cin >> etamin;
+ cout<<"\n|eta| upper limit:\n";
+ cin >> etamax;
+
+ cout<<"\nIntroduce the variation in amounts of sigma\n";
+ cin >> sigma;
+
+ if (etamin == 0)
+ etabin = 1;
+ else if (etamin == 1)
+ etabin = 2;
+ else if (etamin == 1.4)
+ etabin = 3;
+
+ auto sf = (TGraphAsymmErrors*) f -> Get(Form("scale_factor_2017_SL_eta_%g_to_%g",etamin,etamax));
+
+
+ //fitting function
+ TF1 *fa1 = new TF1("fa1","[0]*erf([1]*x-[2])",40, 300);
+ fa1 -> SetParameters(1,0.05,1);
+
+ // Fix correlated parameters
+ double param_1fix[3] = {4.09284e-02,3.61857e-02,3.28926e-02};
+ double param_2fix[3] = {1.07469e+00,9.54743e-01,8.94030e-01};
+ fa1 -> FixParameter(1,param_1fix[etabin - 1]);
+ //fa1 -> FixParameter(2,param_2fix[etabin - 1]);
+
+ //Fit and plot the SF, EX0 to ignore x axis uncert.
+ TFitResultPtr r1 = sf->Fit(fa1,"RS EX0");
+ sf -> GetFunction("fa1") -> SetLineColor(kBlack);
+ sf -> Draw("ap");
+ //fa1 -> Draw("same");
+
+
+//---------------------------------------------
+ // print matrices
+ cout << endl;
+ cout << "*** Correlation Matrix ***" << endl;
+ r1 -> GetCorrelationMatrix().Print();
+ cout << endl;
+ cout << "*** Covariance Matrix ***" << endl;
+ r1 -> GetCovarianceMatrix().Print();
+//---------------------------------------------
+
+ int bineo = 2600;
+ sf -> GetYaxis() -> SetRangeUser(0.6,1.01);
+ sf -> GetXaxis() -> SetRangeUser(120,300);
+
+ TH1D *h_CI ;
+
+
+ if (sigma != 0)
+ {
+ if(sigma == 1)
+ {
+ // histogram to hold the confidence intervals
+ h_CI = new TH1D("h_CI",
+ "Fit with .68 conf.band", bineo, 40, 300);
+
+ //Compute the confidence intervals and save in the histogram, 68% CL by default
+ (TVirtualFitter::GetFitter())->GetConfidenceIntervals(h_CI, 0.68);
+
+ }
+ if(sigma == 2)
+ {
+ // histogram to hold the confidence intervals
+ h_CI = new TH1D("h_CI",
+ "Fit with .95 conf.band", bineo, 40, 300);
+
+ //Compute the confidence intervals and save in the histogram, 95% CL by default
+ (TVirtualFitter::GetFitter())->GetConfidenceIntervals(h_CI, 0.95);
+
+ }
+ h_CI->SetStats(kFALSE);
+ h_CI->SetFillColor(2);
+ h_CI->SetLineColor(2);
+ //Draw the CI, e3 option draws the band
+ //h_CI->Draw("e same");
+ }
+//---------------------------------------------
+//Plot - use this section to plot the interval
+//---------------------------------------------
+ /*
+ sf -> GetYaxis() -> SetTitle ("");
+
+ TLatex latex;
+ latex.SetTextFont(43);
+ latex.SetTextSize(20);
+ latex.SetTextAlign(11);
+ latex.DrawLatexNDC(gPad->GetLeftMargin(), 1.02-c1->GetTopMargin(),
+ (std::string("CMS Work in progress #sqrt{s} = 13 TeV, L = 54.54 fb^{-1}")).c_str());
+
+ TLatex latex1;
+ latex1.SetTextFont(43);
+ latex1.SetTextSize(20);
+ latex1.SetTextAlign(11);
+ latex1.DrawLatexNDC(0.8-gPad->GetLeftMargin(), 1.02-c1->GetTopMargin(),
+ (std::string("HLT_PFJet116_er2p3").c_str()));
+
+ auto legend = new TLegend(0.6,0.25,0.8,0.35);
+ legend->SetHeader("0 <|#eta|< 1","c1"); // option "C" allows to center the header
+ legend->AddEntry(sf,"Scale Factor","lep");
+ legend->Draw();
+
+ c1 -> SaveAs("Barrel_SF_1sigma_CI_2.png");
+ c1 -> SaveAs("Barrel_SF_1sigma_CI_2.pdf");*/
+
+ //sf -> GetYaxis() -> SetRangeUser (0.55,1.05);
+
+ //c1 -> SaveAs("Barrel_SF_1sigma_CI_zoom_v2.png");
+ //c1 -> SaveAs("Barrel_SF_1sigma_CI_zoom_v2.pdf");
+//---------------------------------------------
+
+
+//--------------------------------------------
+//Section to save in graphs nominal and up and down variations
+//--------------------------------------------
+
+ Double_t p[3] = {(TVirtualFitter::GetFitter())->GetParameter(0), (TVirtualFitter::GetFitter())->GetParameter(1), (TVirtualFitter::GetFitter())->GetParameter(2)};
+ Double_t x[bineo], y_nominal[bineo], y_sigma_up[bineo], y_sigma_down[bineo], CL;
+
+ for (int i=0; i < bineo; i++)
+ {
+ //x[i] = h_CI -> GetBinCenter(i+1);
+ x[i] = 40.05 + 0.1*i;
+ y_nominal[i] = p[0]*erf(p[1]*x[i]-p[2]);
+
+ if(sigma != 0)
+ {
+ CL = h_CI -> GetBinError(i+1);
+ y_sigma_up[i] = p[0]*erf(p[1]*x[i]-p[2]) + CL;
+ y_sigma_down[i] = p[0]*erf(p[1]*x[i]-p[2]) - CL;
+ }
+ //cout < SetLineWidth(2);
+ gr_SF_barrel_nominal -> SetLineColor(kBlack);
+ gr_SF_barrel_nominal -> Draw("same");
+
+ if(sigma != 0)
+ {
+ gr_SF_barrel_sigma_up -> SetLineColor(kRed);
+ gr_SF_barrel_sigma_up -> Draw("same");
+ gr_SF_barrel_sigma_down -> SetLineColor(kBlue);
+ gr_SF_barrel_sigma_down -> Draw("same");
+ }
+//---------------------------------------------
+//Plot - use this section to plot the nominal and up and down variations of the SF
+//---------------------------------------------
+
+ sf -> GetYaxis() -> SetTitle ("");
+ gr_SF_barrel_nominal -> SetTitle ("");
+
+ auto legend = new TLegend(0.6,0.25,0.8,0.35);
+ legend->SetHeader("0 <|#eta|< 1","c1"); // option "C" allows to center the header
+ legend->AddEntry(sf,"Scale Factor","lep");
+ legend->AddEntry(gr_SF_barrel_nominal,"Scale Factor Fit","lp");
+ //legend->AddEntry(gr_SF_barrel_sigma_up,Form("Scale Factor %d#sigma up",sigma),"lp");
+ //legend->AddEntry(gr_SF_barrel_sigma_down,Form("Scale Factor %d#sigma down",sigma),"lp");
+ legend->Draw();
+
+
+ TLatex latex;
+ latex.SetTextFont(43);
+ latex.SetTextSize(20);
+ latex.SetTextAlign(11);
+ latex.DrawLatexNDC(gPad->GetLeftMargin(), 1.02-c1->GetTopMargin(),
+ (std::string("CMS Work in progress #sqrt{s} = 13 TeV, L = 54.54 fb^{-1}")).c_str());
+
+ TLatex latex1;
+ latex1.SetTextFont(43);
+ latex1.SetTextSize(20);
+ latex1.SetTextAlign(11);
+ latex1.DrawLatexNDC(0.8-gPad->GetLeftMargin(), 1.02-c1->GetTopMargin(),
+ (std::string("HLT_PFJet116_er2p3").c_str()));
+
+ sf -> GetXaxis() -> SetRangeUser (40,300);
+ sf -> GetYaxis() -> SetRangeUser (0.6,1.05);
+
+ if(sigma == 0)
+ {
+ c1 -> SaveAs(Form("results_fit_nominal/SF_%dsigma_CI_up_nominal_down_eta_%g_to_%g.png",sigma,etamin,etamax));
+ c1 -> SaveAs(Form("results_fit_nominal/SF_%dsigma_CI_up_nominal_down_eta_%g_to_%g.pdf",sigma,etamin,etamax));
+ }
+
+ if(sigma != 0)
+ {
+ c1 -> SaveAs(Form("TGraph_up_nominal_down/SF_%dsigma_CI_up_nominal_down_eta_%g_to_%g.png",sigma,etamin,etamax));
+ c1 -> SaveAs(Form("TGraph_up_nominal_down/SF_%dsigma_CI_up_nominal_down_eta_%g_to_%g.pdf",sigma,etamin,etamax));
+ }
+//---------------------------------------------
+
+
+ //save SF in a file for next step (get confidence intervals graphs parametrized)
+
+
+ if(sigma == 0)
+ {
+ TFile fout("results_fit_nominal/Funct_sf_barrel_nominal.root","UPDATE");
+ if(etabin == 1)
+ fa1->Write("jetOnlineTriggerScaleFactor_etabin_0p0_to_1p0_nominal");
+ if(etabin == 2)
+ fa1->Write("jetOnlineTriggerScaleFactor_etabin_1p0_to_1p4_nominal");
+ if(etabin == 3)
+ fa1->Write("jetOnlineTriggerScaleFactor_etabin_1p4_to_2p2_nominal");
+ }
+
+ if(sigma == 1)
+ {
+ TFile fout("TGraph_up_nominal_down/TGraph_scale_factor_2017_SL_1sigma.root","UPDATE");
+ gr_SF_barrel_sigma_up -> Write(Form("jetOnlineTriggerScaleFactor_eta_%g_to_%g_up",etamin,etamax));
+ gr_SF_barrel_sigma_down -> Write(Form("jetOnlineTriggerScaleFactor_eta_%g_to_%g_down",etamin,etamax));
+ }
+
+ if(sigma == 2)
+ {
+ TFile fout("TGraph_up_nominal_down/TGraph_scale_factor_2017_SL_2sigma.root","UPDATE");
+ gr_SF_barrel_sigma_up -> Write(Form("jetOnlineTriggerScaleFactor_eta_%g_to_%g_up",etamin,etamax));
+ gr_SF_barrel_sigma_down -> Write(Form("jetOnlineTriggerScaleFactor_eta_%g_to_%g_down",etamin,etamax));
+ }
+
+}
diff --git a/test/ProcessingTools/MKTE_MultiFit_Data_JPsiCurve_CDEF_cuadraticBkg.C b/test/ProcessingTools/MKTE_MultiFit_Data_JPsiCurve_CDEF_cuadraticBkg.C
new file mode 100644
index 0000000..45f9442
--- /dev/null
+++ b/test/ProcessingTools/MKTE_MultiFit_Data_JPsiCurve_CDEF_cuadraticBkg.C
@@ -0,0 +1,253 @@
+#include "Fit/Fitter.h"
+#include "Fit/BinData.h"
+#include "Fit/Chi2FCN.h"
+#include "TH1.h"
+#include "TList.h"
+#include "TMath.h"
+#include "Math/WrappedMultiTF1.h"
+#include "HFitInterface.h"
+#include "TCanvas.h"
+#include "TStyle.h"
+
+Double_t fitting_function_passed (Double_t *val, Double_t *par);
+Double_t fitting_function_failed (Double_t *val, Double_t *par);
+TH1D* ProjectHistogram(TH2D* h, double ptmin, double ptmax, char name[]);
+
+// Passed function parameters
+int iparPassed[7] = { 0,
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6
+};
+// Failed function parameters
+int iparFailed[7] = { 0,
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6
+};
+
+// Create the GlobalCHi2 structure
+struct GlobalChi2 {
+ GlobalChi2( ROOT::Math::IMultiGenFunction & f1,
+ ROOT::Math::IMultiGenFunction & f2) :
+ fChi2_1(&f1), fChi2_2(&f2) {}
+
+ double operator() (const double *par) const {
+ double p1[7];
+ for (int i = 0; i < 7; ++i) p1[i] = par[iparPassed[i] ];
+
+ double p2[7];
+ for (int i = 0; i < 7; ++i) p2[i] = par[iparFailed[i] ];
+
+ return (*fChi2_1)(p1) + (*fChi2_2)(p2);
+ }
+
+ const ROOT::Math::IMultiGenFunction * fChi2_1;
+ const ROOT::Math::IMultiGenFunction * fChi2_2;
+};
+
+
+//USE THIS MACRO FOR SIMULTANEOUS FIT OF JPSI CURVE FROM PASSING AND FAILING MUONS
+void MKTE_MultiFit_Data_JPsiCurve_CDEF_cuadraticBkg() {
+
+
+ TH1::SetDefaultSumw2(); // proper treatment of errors when scaling histograms
+
+ TFile * f = new TFile("my_Data_SL_MKTE_Run2017CDEF.root");
+
+ //Lower and upper limits of pTbins
+ Double_t Limits[5] = {11.5, 12.5, 13.5, 18.5, 30};
+ int pTbin = 3;//select the pT bin [1,2,3,4]
+ bool save_in_rootfile = false; //save histograms in rootfiles
+
+ // Histograms
+ TH2D * DiMuonMass_passedmatching = (TH2D*) f -> Get("DiMuonMass of passing muons 2D");
+ TH2D * DiMuonMass_failedmatching = (TH2D*) f -> Get("DiMuonMass of failing muons 2D");
+
+ double min = 2.92, max = 3.28;
+ // Declaring fitting functions and set parameters names
+ TF1* fittingfunction_passed = new TF1 ("fittingfunction_passed", fitting_function_passed, min, max, 7);
+ fittingfunction_passed -> SetParNames ("A","m_{0}","#sigma","k_{2}","k_{1}","k_{0}","#epsilon");
+ TF1* fittingfunction_failed = new TF1 ("fittingfunction_failed", fitting_function_failed, min, max, 7);
+ fittingfunction_failed -> SetParNames ("A","m_{0}","#sigma","k_{2}","k_{1}","k_{0}","#epsilon");
+
+
+ //Projecting the 2D histograms
+ TH1D* DiMuonMass_passed = ProjectHistogram(DiMuonMass_passedmatching, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_passed_pTbin_%d", pTbin));
+ TH1D* DiMuonMass_failed = ProjectHistogram(DiMuonMass_failedmatching, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_failed_pTbin_%d", pTbin));
+
+ int bineo = 4;
+
+ DiMuonMass_passed -> Rebin(bineo);
+ DiMuonMass_failed -> Rebin(bineo);
+
+ if (save_in_rootfile)
+ {
+ TFile j(Form("DiMuonMass_Data_pTbin_%d.root", pTbin),"recreate");
+ DiMuonMass_passed->Write();
+ DiMuonMass_failed->Write();
+ j.Close();
+ }
+
+ // perform now global fit
+
+ //wrap a function in a IParamMultiFunction interface
+ ROOT::Math::WrappedMultiTF1 wfittingfunction_passed(*fittingfunction_passed,1);
+ ROOT::Math::WrappedMultiTF1 wfittingfunction_failed(*fittingfunction_failed,1);
+
+ //fit properties
+
+ ROOT::Fit::DataOptions opt;
+
+ ROOT::Fit::DataRange rangePassed;
+ rangePassed.SetRange(2.92,3.28);
+ ROOT::Fit::BinData dataPassed(opt,rangePassed);
+ ROOT::Fit::FillData(dataPassed, DiMuonMass_passed);
+
+ ROOT::Fit::DataRange rangeFailed;
+ rangeFailed.SetRange(2.92,3.28);
+ ROOT::Fit::BinData dataFailed(opt,rangeFailed);
+ ROOT::Fit::FillData(dataFailed, DiMuonMass_failed);
+
+ //individual chi2 functions
+ ROOT::Fit::Chi2Function chi2_Passed(dataPassed, wfittingfunction_passed);
+ ROOT::Fit::Chi2Function chi2_Failed(dataFailed, wfittingfunction_failed);
+
+ //Pass the individual chi2 to globalChi2
+ GlobalChi2 globalChi2(chi2_Passed, chi2_Failed);
+
+ //declare the fitter
+ ROOT::Fit::Fitter fitter;
+
+ const int Npar = 7;
+ //double par0[Npar] = { 2, 3.0969, 0.0296, -3.16, 10, -20, 0.4}; //use for bin1,2 bineo 0p4
+ double par0[Npar] = { 100, 3.0969, 0.009, -3.16, 10, -20, 0.9}; //use for bin3 bineo 0p4
+
+ // fix or set range on the parameters
+ fitter.Config().SetParamsSettings(7,par0);
+ fitter.Config().ParSettings(1).Fix();
+ fitter.Config().MinimizerOptions().SetPrintLevel(0);
+ fitter.Config().SetMinimizer("Minuit2","Migrad");
+
+ //Perform the fit
+ fitter.FitFCN(7,globalChi2,0,dataPassed.Size()+dataFailed.Size(),true);
+ ROOT::Fit::FitResult result = fitter.Result();
+ result.Print(std::cout);
+
+ TCanvas * C1 = new TCanvas("C","Canvas",1500,750);
+ C1 -> Divide(2,1);
+ C1 -> cd(1);
+ gStyle->SetOptFit(1111);
+
+
+ fittingfunction_passed -> SetFitResult( result, iparPassed);
+ fittingfunction_passed -> SetRange(rangePassed().first, rangePassed().second);
+ fittingfunction_passed -> SetLineColor(kBlue);
+ DiMuonMass_passed -> GetListOfFunctions() -> Add(fittingfunction_passed);
+ DiMuonMass_passed -> SetMarkerStyle(20);
+ DiMuonMass_passed -> SetTitle("");
+ DiMuonMass_passed -> GetXaxis() -> SetTitle("m_{#mu#mu}");
+ DiMuonMass_passed -> GetXaxis() -> SetRangeUser(2.85,3.35);
+ DiMuonMass_passed -> GetYaxis() -> SetRangeUser(0,fittingfunction_passed->GetMaximum()+20.7);
+ DiMuonMass_passed -> GetYaxis() -> SetTitle(Form("Entries/(0.0%d GeV)", bineo));
+ DiMuonMass_passed -> Draw();
+
+ TLatex latex;
+ latex.SetTextFont(43);
+ latex.SetTextSize(20);
+ latex.SetTextAlign(11);
+ latex.DrawLatexNDC(C1 -> cd(1) ->GetLeftMargin(), 1.02-C1 -> cd(1) ->GetTopMargin(),
+ (std::string("CMS Work in progress")).c_str());
+
+ auto legend_passed = new TLegend(0.11,0.7,0.45,0.85);
+ legend_passed->SetBorderSize(0);
+ legend_passed->SetHeader(Form("%.1f < p_{T}^{probes} < %.1f GeV", Limits[pTbin-1], Limits[pTbin]),"C"); // option "C" allows to center the header
+ legend_passed->AddEntry(DiMuonMass_passed,"Data CDEF","lep");
+ TLegendEntry* l_passed_funct = legend_passed->AddEntry(fittingfunction_passed,"passing probe","l");
+ l_passed_funct->SetTextColor(kBlue);
+ legend_passed->Draw();
+
+ C1 -> cd(2);
+ fittingfunction_failed -> SetFitResult( result, iparFailed);
+ fittingfunction_failed -> SetRange(rangeFailed().first, rangeFailed().second);
+ fittingfunction_failed -> SetLineColor(kRed);
+ DiMuonMass_failed -> GetListOfFunctions() -> Add(fittingfunction_failed);
+ DiMuonMass_failed -> SetMarkerStyle(20);
+ DiMuonMass_failed -> SetTitle("");
+ DiMuonMass_failed -> GetXaxis() -> SetTitle("m_{#mu#mu}");
+ DiMuonMass_failed -> GetXaxis() -> SetRangeUser(2.85,3.35);
+ DiMuonMass_failed -> GetYaxis() -> SetRangeUser(0,fittingfunction_failed->GetMaximum()+15.7);
+ DiMuonMass_failed -> GetYaxis() -> SetTitle(Form("Entries/(0.0%d GeV)", bineo));
+ DiMuonMass_failed -> Draw();
+
+
+ auto legend_failed = new TLegend(0.11,0.7,0.45,0.85);
+ legend_failed->SetBorderSize(0);
+ legend_failed->SetHeader(Form("%.1f < p_{T}^{probes} < %.1f GeV", Limits[pTbin-1], Limits[pTbin]),"C"); // option "C" allows to center the header
+ legend_failed->AddEntry(DiMuonMass_failed,"Data CDEF","lep");
+ TLegendEntry* l_failed_funct = legend_failed->AddEntry(fittingfunction_failed,"failing probe","l");
+ l_failed_funct->SetTextColor(kRed);
+ legend_failed->Draw();
+
+ latex.DrawLatexNDC(C1 -> cd(2) ->GetLeftMargin(), 1.02-C1 -> cd(2) ->GetTopMargin(),
+ (std::string("CMS Work in progress")).c_str());
+
+ C1 -> SaveAs(Form("plots_data_cuadraticBkg/JPsi_pTbin%d_bineo0p0%dGeV.png",pTbin,bineo));
+ C1 -> SaveAs(Form("plots_data_cuadraticBkg/JPsi_pTbin%d_bineo0p0%dGeV.pdf",pTbin,bineo));
+ C1 -> SaveAs(Form("plots_data_cuadraticBkg/JPsi_pTbin%d_bineo0p0%dGeV.root",pTbin,bineo));
+}
+
+
+// Fitting function definition for Passed sample
+Double_t fitting_function_passed (Double_t *val, Double_t *par)
+{
+ Double_t exponential = exp(-1*((val[0]-par[1])*(val[0]-par[1])/(2*par[2]*par[2])));
+ Double_t f_passed = (par[0] * exponential + par[3]*val[0]*val[0] + par[4]*val[0] + par[5])*par[6];
+ return f_passed;
+}
+
+// Fitting function definition for Failed sample
+Double_t fitting_function_failed (Double_t *val, Double_t *par)
+{
+ Double_t exponential = exp(-1*((val[0]-par[1])*(val[0]-par[1])/(2*par[2]*par[2])));
+ Double_t f_failed = (par[0] * exponential + par[3]*val[0]*val[0] + par[4]*val[0] + par[5])*(1-par[6]);
+ return f_failed;
+}
+
+
+TH1D* ProjectHistogram(TH2D* h, double ptmin, double ptmax, char name[])
+{
+ //declare histograms and variables
+ TH1D *hprojected;
+ double half_bin_width = 0.5 * (h -> GetYaxis() -> GetBinWidth(1));
+ double Lowedgeup, Lowedgedown;
+
+ if (ptmax == -1)
+ {
+ int LowerBin = 1;
+ int UpperBin = h -> GetNbinsY();
+
+ hprojected = h -> ProjectionX(name, LowerBin, UpperBin, "e");
+
+ }
+
+ else
+ {
+ int LowerBin = int(h -> GetYaxis() -> FindBin(ptmin + half_bin_width));
+ int UpperBin = int(h -> GetYaxis() -> FindBin(ptmax - half_bin_width));
+
+ Lowedgeup = h -> GetYaxis() -> GetBinLowEdge(UpperBin);
+ Lowedgedown = h -> GetYaxis() -> GetBinLowEdge(LowerBin);
+
+ hprojected = h -> ProjectionX(name, LowerBin, UpperBin, "e");
+ }
+
+ return hprojected;
+
+}
diff --git a/test/ProcessingTools/MKTE_MultiFit_MC_JPsiCurve_cuadraticBkg.C b/test/ProcessingTools/MKTE_MultiFit_MC_JPsiCurve_cuadraticBkg.C
new file mode 100644
index 0000000..b45e333
--- /dev/null
+++ b/test/ProcessingTools/MKTE_MultiFit_MC_JPsiCurve_cuadraticBkg.C
@@ -0,0 +1,488 @@
+#include "Fit/Fitter.h"
+#include "Fit/BinData.h"
+#include "Fit/Chi2FCN.h"
+#include "TH1.h"
+#include "TList.h"
+#include "TMath.h"
+#include "Math/WrappedMultiTF1.h"
+#include "HFitInterface.h"
+#include "TCanvas.h"
+#include "TStyle.h"
+
+Double_t fitting_function_passed (Double_t *val, Double_t *par);
+Double_t fitting_function_failed (Double_t *val, Double_t *par);
+TH1D* ProjectHistogram(TH2D* h, double ptmin, double ptmax, char name[]);
+
+// Passed function parameters
+int iparPassed[7] = { 0,
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6
+};
+// Failed function parameters
+int iparFailed[7] = { 0,
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6
+};
+
+// Create the GlobalCHi2 structure
+struct GlobalChi2 {
+ GlobalChi2( ROOT::Math::IMultiGenFunction & f1,
+ ROOT::Math::IMultiGenFunction & f2) :
+ fChi2_1(&f1), fChi2_2(&f2) {}
+
+ double operator() (const double *par) const {
+ double p1[7];
+ for (int i = 0; i < 7; ++i) p1[i] = par[iparPassed[i] ];
+
+ double p2[7];
+ for (int i = 0; i < 7; ++i) p2[i] = par[iparFailed[i] ];
+
+ return (*fChi2_1)(p1) + (*fChi2_2)(p2);
+ }
+
+ const ROOT::Math::IMultiGenFunction * fChi2_1;
+ const ROOT::Math::IMultiGenFunction * fChi2_2;
+};
+
+
+
+void MKTE_MultiFit_MC_JPsiCurve_cuadraticBkg() {
+
+
+ TH1::SetDefaultSumw2(); // proper treatment of errors when scaling histograms
+
+ Double_t Luminosity_Total =0.002493*1000; //mult by 1000 to take from /fb to /pb -> lumi of control trigger
+ //Double_t Luminosity_Total = 36.67*1000; //mult by 1000 to take from /fb to /pb -> lumi of physics trigger
+
+ TFile * f1 = new TFile("mkte_less-stats_50perc/my_MC_SL_MKTE_QCD_Pt-50To80.root");
+ TFile * f2 = new TFile("mkte_less-stats_50perc/my_MC_SL_MKTE_QCD_Pt-80To120.root");
+ TFile * f3 = new TFile("mkte_less-stats_50perc/my_MC_SL_MKTE_QCD_Pt-120To170.root");
+ TFile * f4 = new TFile("mkte_less-stats_50perc/my_MC_SL_MKTE_QCD_Pt-170To300.root");
+ TFile * f5 = new TFile("mkte_less-stats_50perc/my_MC_SL_MKTE_QCD_Pt-300To470.root");
+ TFile * f6 = new TFile("mkte_less-stats_50perc/my_MC_SL_MKTE_QCD_Pt-470To600.root");
+ TFile * f7 = new TFile("mkte_less-stats_50perc/my_MC_SL_MKTE_QCD_Pt-600To800.root");
+ TFile * f8 = new TFile("mkte_less-stats_50perc/my_MC_SL_MKTE_QCD_Pt-800to1000.root");
+ TFile * f9 = new TFile("mkte_less-stats_50perc/my_MC_SL_MKTE_QCD_Pt-1000toInf.root");
+
+ //Individual Histograms - DiMuon mass
+ TH2D * DiMuonMass_passed_2D_1 = (TH2D*) f1 -> Get("DiMuonMass of passing muons 2D");
+ TH2D * DiMuonMass_failed_2D_1 = (TH2D*) f1 -> Get("DiMuonMass of failing muons 2D");
+
+ TH2D * DiMuonMass_passed_2D_2 = (TH2D*) f2 -> Get("DiMuonMass of passing muons 2D");
+ TH2D * DiMuonMass_failed_2D_2 = (TH2D*) f2 -> Get("DiMuonMass of failing muons 2D");
+
+ TH2D * DiMuonMass_passed_2D_3 = (TH2D*) f3 -> Get("DiMuonMass of passing muons 2D");
+ TH2D * DiMuonMass_failed_2D_3 = (TH2D*) f3 -> Get("DiMuonMass of failing muons 2D");
+
+ TH2D * DiMuonMass_passed_2D_4 = (TH2D*) f4 -> Get("DiMuonMass of passing muons 2D");
+ TH2D * DiMuonMass_failed_2D_4 = (TH2D*) f4 -> Get("DiMuonMass of failing muons 2D");
+
+ TH2D * DiMuonMass_passed_2D_5 = (TH2D*) f5 -> Get("DiMuonMass of passing muons 2D");
+ TH2D * DiMuonMass_failed_2D_5 = (TH2D*) f5 -> Get("DiMuonMass of failing muons 2D");
+
+ TH2D * DiMuonMass_passed_2D_6 = (TH2D*) f6 -> Get("DiMuonMass of passing muons 2D");
+ TH2D * DiMuonMass_failed_2D_6 = (TH2D*) f6 -> Get("DiMuonMass of failing muons 2D");
+
+ TH2D * DiMuonMass_passed_2D_7 = (TH2D*) f7 -> Get("DiMuonMass of passing muons 2D");
+ TH2D * DiMuonMass_failed_2D_7 = (TH2D*) f7 -> Get("DiMuonMass of failing muons 2D");
+
+ TH2D * DiMuonMass_passed_2D_8 = (TH2D*) f8 -> Get("DiMuonMass of passing muons 2D");
+ TH2D * DiMuonMass_failed_2D_8 = (TH2D*) f8 -> Get("DiMuonMass of failing muons 2D");
+
+ TH2D * DiMuonMass_passed_2D_9 = (TH2D*) f9 -> Get("DiMuonMass of passing muons 2D");
+ TH2D * DiMuonMass_failed_2D_9 = (TH2D*) f9 -> Get("DiMuonMass of failing muons 2D");
+
+ //Individual Histograms - pT
+ TH1D * pT_passed_1 = (TH1D*) f1 -> Get("Matched_Probes_Pt");
+ TH1D * pT_failed_1 = (TH1D*) f1 -> Get("Failed_Probes_Pt");
+ TH1D * pT_passed_2 = (TH1D*) f2 -> Get("Matched_Probes_Pt");
+ TH1D * pT_failed_2 = (TH1D*) f2 -> Get("Failed_Probes_Pt");
+ TH1D * pT_passed_3 = (TH1D*) f3 -> Get("Matched_Probes_Pt");
+ TH1D * pT_failed_3 = (TH1D*) f3 -> Get("Failed_Probes_Pt");
+ TH1D * pT_passed_4 = (TH1D*) f4 -> Get("Matched_Probes_Pt");
+ TH1D * pT_failed_4 = (TH1D*) f4 -> Get("Failed_Probes_Pt");
+ TH1D * pT_passed_5 = (TH1D*) f5 -> Get("Matched_Probes_Pt");
+ TH1D * pT_failed_5 = (TH1D*) f5 -> Get("Failed_Probes_Pt");
+ TH1D * pT_passed_6 = (TH1D*) f6 -> Get("Matched_Probes_Pt");
+ TH1D * pT_failed_6 = (TH1D*) f6 -> Get("Failed_Probes_Pt");
+ TH1D * pT_passed_7 = (TH1D*) f7 -> Get("Matched_Probes_Pt");
+ TH1D * pT_failed_7 = (TH1D*) f7 -> Get("Failed_Probes_Pt");
+ TH1D * pT_passed_8 = (TH1D*) f8 -> Get("Matched_Probes_Pt");
+ TH1D * pT_failed_8 = (TH1D*) f8 -> Get("Failed_Probes_Pt");
+ TH1D * pT_passed_9 = (TH1D*) f9 -> Get("Matched_Probes_Pt");
+ TH1D * pT_failed_9 = (TH1D*) f9 -> Get("Failed_Probes_Pt");
+
+
+ //Lower and upper limits of pTbins
+ Double_t Limits[5] = {11.5, 12.5, 13.5, 18.5, 30};
+ int pTbin = 4;//select the pT bin [1,2,3,4]
+ bool save_in_rootfile = false; //save histograms in rootfiles
+
+ //Projecting the 2D histograms
+ TH1D* DiMuonMass_passed_1 = ProjectHistogram(DiMuonMass_passed_2D_1, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_passed_pTbin_%d_1", pTbin));
+ TH1D* DiMuonMass_failed_1 = ProjectHistogram(DiMuonMass_failed_2D_1, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_failed_pTbin_%d_1", pTbin));
+
+ TH1D* DiMuonMass_passed_2 = ProjectHistogram(DiMuonMass_passed_2D_2, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_passed_pTbin_%d_2", pTbin));
+ TH1D* DiMuonMass_failed_2 = ProjectHistogram(DiMuonMass_failed_2D_2, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_failed_pTbin_%d_2", pTbin));
+
+ TH1D* DiMuonMass_passed_3 = ProjectHistogram(DiMuonMass_passed_2D_3, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_passed_pTbin_%d_3", pTbin));
+ TH1D* DiMuonMass_failed_3 = ProjectHistogram(DiMuonMass_failed_2D_3, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_failed_pTbin_%d_3", pTbin));
+
+ TH1D* DiMuonMass_passed_4 = ProjectHistogram(DiMuonMass_passed_2D_4, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_passed_pTbin_%d_4", pTbin));
+ TH1D* DiMuonMass_failed_4 = ProjectHistogram(DiMuonMass_failed_2D_4, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_failed_pTbin_%d_4", pTbin));
+
+ TH1D* DiMuonMass_passed_5 = ProjectHistogram(DiMuonMass_passed_2D_5, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_passed_pTbin_%d_5", pTbin));
+ TH1D* DiMuonMass_failed_5 = ProjectHistogram(DiMuonMass_failed_2D_5, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_failed_pTbin_%d_5", pTbin));
+
+ TH1D* DiMuonMass_passed_6 = ProjectHistogram(DiMuonMass_passed_2D_6, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_passed_pTbin_%d_6", pTbin));
+ TH1D* DiMuonMass_failed_6 = ProjectHistogram(DiMuonMass_failed_2D_6, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_failed_pTbin_%d_6", pTbin));
+
+ TH1D* DiMuonMass_passed_7 = ProjectHistogram(DiMuonMass_passed_2D_7, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_passed_pTbin_%d_7", pTbin));
+ TH1D* DiMuonMass_failed_7 = ProjectHistogram(DiMuonMass_failed_2D_7, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_failed_pTbin_%d_7", pTbin));
+
+ TH1D* DiMuonMass_passed_8 = ProjectHistogram(DiMuonMass_passed_2D_8, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_passed_pTbin_%d_8", pTbin));
+ TH1D* DiMuonMass_failed_8 = ProjectHistogram(DiMuonMass_failed_2D_8, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_failed_pTbin_%d_8", pTbin));
+
+ TH1D* DiMuonMass_passed_9 = ProjectHistogram(DiMuonMass_passed_2D_9, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_passed_pTbin_%d_9", pTbin));
+ TH1D* DiMuonMass_failed_9 = ProjectHistogram(DiMuonMass_failed_2D_9, Limits[pTbin-1], Limits[pTbin], Form("DiMuonMass_failed_pTbin_%d_9", pTbin));
+
+ //get parameters of MC samples (pb)
+ //Double_t Cross_section_0= 1362000;
+ Double_t Cross_section_1= 376600;
+ Double_t Cross_section_2= 88930;
+ Double_t Cross_section_3= 21230;
+ Double_t Cross_section_4= 7055;
+ Double_t Cross_section_5= 619.30;
+ Double_t Cross_section_6= 59.24;
+ Double_t Cross_section_7= 18.21;
+ Double_t Cross_section_8= 3.275;
+ Double_t Cross_section_9= 1.078;
+
+ TH1F * Workflow1 = (TH1F*) f1 -> Get("workflow;1/Workflow #1");
+ TH1F * Workflow2 = (TH1F*) f2 -> Get("workflow;1/Workflow #1");
+ TH1F * Workflow3 = (TH1F*) f3 -> Get("workflow;1/Workflow #1");
+ TH1F * Workflow4 = (TH1F*) f4 -> Get("workflow;1/Workflow #1");
+ TH1F * Workflow5 = (TH1F*) f5 -> Get("workflow;1/Workflow #1");
+ TH1F * Workflow6 = (TH1F*) f6 -> Get("workflow;1/Workflow #1");
+ TH1F * Workflow7 = (TH1F*) f7 -> Get("workflow;1/Workflow #1");
+ TH1F * Workflow8 = (TH1F*) f8 -> Get("workflow;1/Workflow #1");
+ TH1F * Workflow9 = (TH1F*) f9 -> Get("workflow;1/Workflow #1");
+
+ Double_t Nevents1 = Workflow1->GetBinContent(2);
+ Double_t Nevents2 = Workflow2->GetBinContent(2);
+ Double_t Nevents3 = Workflow3->GetBinContent(2);
+ Double_t Nevents4 = Workflow4->GetBinContent(2);
+ Double_t Nevents5 = Workflow5->GetBinContent(2);
+ Double_t Nevents6 = Workflow6->GetBinContent(2);
+ Double_t Nevents7 = Workflow7->GetBinContent(2);
+ Double_t Nevents8 = Workflow8->GetBinContent(2);
+ Double_t Nevents9 = Workflow9->GetBinContent(2);
+
+ // calculate Scale Factors for each MC sample
+ Double_t ScaleFactor1, ScaleFactor2, ScaleFactor3, ScaleFactor4, ScaleFactor5, ScaleFactor6, ScaleFactor7, ScaleFactor8, ScaleFactor9 ;
+
+ //Double_t Luminosity_Total = Nevents1/Cross_section_1 + Nevents2/Cross_section_2 + Nevents3/Cross_section_3 + Nevents4/Cross_section_4 + Nevents5/Cross_section_5 + Nevents6/Cross_section_6 + Nevents7/Cross_section_7 + Nevents8/Cross_section_8 + Nevents9/Cross_section_9;
+
+ cout<<"Luminosity_Total "< Scale(ScaleFactor1);
+ DiMuonMass_failed_1 -> Scale(ScaleFactor1);
+
+ DiMuonMass_passed_2 -> Scale(ScaleFactor2);
+ DiMuonMass_failed_2 -> Scale(ScaleFactor2);
+
+ DiMuonMass_passed_3 -> Scale(ScaleFactor3);
+ DiMuonMass_failed_3 -> Scale(ScaleFactor3);
+
+ DiMuonMass_passed_4 -> Scale(ScaleFactor4);
+ DiMuonMass_failed_4 -> Scale(ScaleFactor4);
+
+ DiMuonMass_passed_5 -> Scale(ScaleFactor5);
+ DiMuonMass_failed_5 -> Scale(ScaleFactor5);
+
+ DiMuonMass_passed_6 -> Scale(ScaleFactor6);
+ DiMuonMass_failed_6 -> Scale(ScaleFactor6);
+
+ DiMuonMass_passed_7 -> Scale(ScaleFactor7);
+ DiMuonMass_failed_7 -> Scale(ScaleFactor7);
+
+ DiMuonMass_passed_8 -> Scale(ScaleFactor8);
+ DiMuonMass_failed_8 -> Scale(ScaleFactor8);
+
+ DiMuonMass_passed_9 -> Scale(ScaleFactor9);
+ DiMuonMass_failed_9 -> Scale(ScaleFactor9);
+
+ pT_passed_1 -> Scale(ScaleFactor1);
+ pT_failed_1 -> Scale(ScaleFactor1);
+ pT_passed_2 -> Scale(ScaleFactor2);
+ pT_failed_2 -> Scale(ScaleFactor2);
+ pT_passed_3 -> Scale(ScaleFactor3);
+ pT_failed_3 -> Scale(ScaleFactor3);
+ pT_passed_4 -> Scale(ScaleFactor4);
+ pT_failed_4 -> Scale(ScaleFactor4);
+ pT_passed_5 -> Scale(ScaleFactor5);
+ pT_failed_5 -> Scale(ScaleFactor5);
+ pT_passed_6 -> Scale(ScaleFactor6);
+ pT_failed_6 -> Scale(ScaleFactor6);
+ pT_passed_7 -> Scale(ScaleFactor7);
+ pT_failed_7 -> Scale(ScaleFactor7);
+ pT_passed_8 -> Scale(ScaleFactor8);
+ pT_failed_8 -> Scale(ScaleFactor8);
+ pT_passed_9 -> Scale(ScaleFactor9);
+ pT_failed_9 -> Scale(ScaleFactor9);
+
+
+ // adding the MC histograms
+ TH1F * DiMuonMass_passed = (TH1F*) DiMuonMass_passed_1->Clone("DiMuonMass_passed");
+ TH1F * DiMuonMass_failed = (TH1F*) DiMuonMass_failed_1->Clone("DiMuonMass_failed");
+
+ DiMuonMass_passed -> Add(DiMuonMass_passed_2);
+ DiMuonMass_passed -> Add(DiMuonMass_passed_3);
+ DiMuonMass_passed -> Add(DiMuonMass_passed_4);
+ DiMuonMass_passed -> Add(DiMuonMass_passed_5);
+ DiMuonMass_passed -> Add(DiMuonMass_passed_6);
+ DiMuonMass_passed -> Add(DiMuonMass_passed_7);
+ DiMuonMass_passed -> Add(DiMuonMass_passed_8);
+ DiMuonMass_passed -> Add(DiMuonMass_passed_9);
+
+ DiMuonMass_failed -> Add(DiMuonMass_failed_2);
+ DiMuonMass_failed -> Add(DiMuonMass_failed_3);
+ DiMuonMass_failed -> Add(DiMuonMass_failed_4);
+ DiMuonMass_failed -> Add(DiMuonMass_failed_5);
+ DiMuonMass_failed -> Add(DiMuonMass_failed_6);
+ DiMuonMass_failed -> Add(DiMuonMass_failed_7);
+ DiMuonMass_failed -> Add(DiMuonMass_failed_8);
+ DiMuonMass_failed -> Add(DiMuonMass_failed_9);
+
+ TH1D * pT_passed = (TH1D*) pT_passed_1->Clone("pT_passed");
+ TH1D * pT_failed = (TH1D*) pT_failed_1->Clone("pT_failed");
+ pT_passed -> Add(pT_passed_2);
+ pT_passed -> Add(pT_passed_3);
+ pT_passed -> Add(pT_passed_4);
+ pT_passed -> Add(pT_passed_5);
+ pT_passed -> Add(pT_passed_6);
+ pT_passed -> Add(pT_passed_7);
+ pT_passed -> Add(pT_passed_8);
+ pT_passed -> Add(pT_passed_9);
+
+ pT_failed -> Add(pT_failed_2);
+ pT_failed -> Add(pT_failed_3);
+ pT_failed -> Add(pT_failed_4);
+ pT_failed -> Add(pT_failed_5);
+ pT_failed -> Add(pT_failed_6);
+ pT_failed -> Add(pT_failed_7);
+ pT_failed -> Add(pT_failed_8);
+ pT_failed -> Add(pT_failed_9);
+
+//-----------
+
+ int bineo = 4; // in 10^-2 GeV
+
+ DiMuonMass_passed -> Rebin(bineo);
+ DiMuonMass_failed -> Rebin(bineo);
+
+ double min = 2.92, max = 3.28;
+ //double min = 2.92, max = 3.28;
+ //double min = 2.92, max = 3.32;
+
+ // Declaring fitting functions and set parameters names
+ TF1* fittingfunction_passed = new TF1 ("fittingfunction_passed", fitting_function_passed, min, max, 7);
+ fittingfunction_passed -> SetParNames ("A","m_{0}","#sigma","k_{2}","k_{1}","k_{0}","#epsilon");
+ TF1* fittingfunction_failed = new TF1 ("fittingfunction_failed", fitting_function_failed, min, max, 7);
+ fittingfunction_failed -> SetParNames ("A","m_{0}","#sigma","k_{2}","k_{1}","k_{0}","#epsilon");
+
+
+ // perform now global fit
+
+ //wrap a function in a IParamMultiFunction interface
+ ROOT::Math::WrappedMultiTF1 wfittingfunction_passed(*fittingfunction_passed,1);
+ ROOT::Math::WrappedMultiTF1 wfittingfunction_failed(*fittingfunction_failed,1);
+
+ //fit properties
+
+ ROOT::Fit::DataOptions opt;
+
+ ROOT::Fit::DataRange rangePassed;
+ rangePassed.SetRange(min,max);
+ ROOT::Fit::BinData dataPassed(opt,rangePassed);
+ ROOT::Fit::FillData(dataPassed, DiMuonMass_passed);
+
+ ROOT::Fit::DataRange rangeFailed;
+ rangeFailed.SetRange(min,max);
+ //rangeFailed.SetRange(3.097-0.12,3.097+0.12);
+ ROOT::Fit::BinData dataFailed(opt,rangeFailed);
+ ROOT::Fit::FillData(dataFailed, DiMuonMass_failed);
+
+ //individual chi2 functions
+ ROOT::Fit::Chi2Function chi2_Passed(dataPassed, wfittingfunction_passed);
+ ROOT::Fit::Chi2Function chi2_Failed(dataFailed, wfittingfunction_failed);
+
+ //Pass the individual chi2 to globalChi2
+ GlobalChi2 globalChi2(chi2_Passed, chi2_Failed);
+
+ //declare the fitter
+ ROOT::Fit::Fitter fitter;
+
+ const int Npar = 7;
+ //double par0[Npar] = { 6, 3.0969, 0.0296, -3.16, 19, -28.56, 0.9}; //use for bin2 bineo 0p2
+// double par0[Npar] = { 2, 3.0969, 0.0296, -3.16, 10, -20, 0.9}; //use for bin2 bineo 0p4
+// double par0[Npar] = { 2, 3.0969, 0.0296, -3.16, 10, -20, 0.4}; //use for bin1 bineo 0p4
+// double par0[Npar] = { 20, 3.0969, 0.031, -5, 1, -5, 0.91}; //use for bin3 bineo 0p4
+ double par0[Npar] = { 5, 3.0969, 0.031, -5, 33, -50, 0.91}; //use for bin4 bineo 0p4
+
+ // fix or set range on the parameters
+ fitter.Config().SetParamsSettings(7,par0);
+ fitter.Config().ParSettings(1).Fix();
+ //fitter.Config().ParSettings(3).Fix();
+ //fitter.Config().ParSettings(5).SetLimits(0,1000);
+ //fitter.Config().ParSettings(3).SetLimits(-100,0);
+ fitter.Config().MinimizerOptions().SetPrintLevel(0);
+ fitter.Config().SetMinimizer("Minuit2","Migrad");
+
+ //Perform the fit
+ fitter.FitFCN(7,globalChi2,0,dataPassed.Size()+dataFailed.Size(),true);
+ ROOT::Fit::FitResult result = fitter.Result();
+ result.Print(std::cout);
+
+ TCanvas * C1 = new TCanvas("C1","Canvas",1500,750);
+ gStyle->SetOptFit(1111);
+
+ //pT_passed -> Draw();
+ //pT_failed -> Draw();
+
+
+ C1 -> Divide(2,1);
+ C1 -> cd(1);
+ fittingfunction_passed -> SetFitResult( result, iparPassed);
+ fittingfunction_passed -> SetRange(rangePassed().first, rangePassed().second);
+ fittingfunction_passed -> SetLineColor(kBlue);
+ DiMuonMass_passed -> GetListOfFunctions() -> Add(fittingfunction_passed);
+ DiMuonMass_passed -> SetMarkerStyle(20);
+ //DiMuonMass_passed -> SetTitle(Form("Passing Probes %.1f SetTitle("");
+ DiMuonMass_passed -> GetXaxis() -> SetTitle("m_{#mu#mu}");
+ DiMuonMass_passed -> GetXaxis() -> SetRangeUser(2.85,3.35);
+ DiMuonMass_passed -> GetYaxis() -> SetRangeUser(0,fittingfunction_passed->GetMaximum()+0.7);
+ DiMuonMass_passed -> GetYaxis() -> SetTitle(Form("Entries/(0.0%d GeV)", bineo));
+ DiMuonMass_passed -> Draw();
+
+ TLatex latex;
+ latex.SetTextFont(43);
+ latex.SetTextSize(20);
+ latex.SetTextAlign(11);
+ latex.DrawLatexNDC(C1 -> cd(1) ->GetLeftMargin(), 1.02-C1 -> cd(1) ->GetTopMargin(),
+ (std::string("CMS Simulation Work in progress")).c_str());
+
+
+ auto legend_passed = new TLegend(0.11,0.7,0.45,0.85);
+ legend_passed->SetBorderSize(0);
+ legend_passed->SetHeader(Form("%.1f < p_{T}^{probes} < %.1f GeV", Limits[pTbin-1], Limits[pTbin]),"C"); // option "C" allows to center the header
+ legend_passed->AddEntry(DiMuonMass_passed,"QCD #mu-enriched","lep");
+ TLegendEntry* l_passed_funct = legend_passed->AddEntry(fittingfunction_passed,"passing probe","l");
+ l_passed_funct->SetTextColor(kBlue);
+ legend_passed->Draw();
+
+ C1 -> cd(2);
+
+ fittingfunction_failed -> SetFitResult( result, iparFailed);
+ fittingfunction_failed -> SetRange(rangeFailed().first, rangeFailed().second);
+ fittingfunction_failed -> SetLineColor(kRed);
+ DiMuonMass_failed -> GetListOfFunctions() -> Add(fittingfunction_failed);
+ DiMuonMass_failed -> SetMarkerStyle(20);
+ DiMuonMass_failed -> SetTitle("");
+ //DiMuonMass_failed -> SetTitle(Form("Failing Probes %.1f GetXaxis() -> SetTitle("m_{#mu#mu}");
+ DiMuonMass_failed -> GetXaxis() -> SetRangeUser(2.85,3.35);
+ DiMuonMass_failed -> GetYaxis() -> SetRangeUser(0,fittingfunction_failed->GetMaximum()+0.2);
+ DiMuonMass_failed -> GetYaxis() -> SetTitle(Form("Entries/(0.0%d GeV)",bineo));
+ DiMuonMass_failed -> Draw();
+
+ auto legend_failed = new TLegend(0.11,0.7,0.45,0.85);
+ legend_failed->SetBorderSize(0);
+ legend_failed->SetHeader(Form("%.1f < p_{T}^{probes} < %.1f GeV", Limits[pTbin-1], Limits[pTbin]),"C"); // option "C" allows to center the header
+ legend_failed->AddEntry(DiMuonMass_failed,"QCD #mu-enriched","lep");
+ TLegendEntry* l_failed_funct = legend_failed->AddEntry(fittingfunction_failed,"failing probe","l");
+ l_failed_funct->SetTextColor(kRed);
+ legend_failed->Draw();
+
+ latex.DrawLatexNDC(C1 -> cd(2) ->GetLeftMargin(), 1.02-C1 -> cd(2) ->GetTopMargin(),
+ (std::string("CMS Simulation Work in progress")).c_str());
+
+
+ C1 -> SaveAs(Form("plots_MC_cuadraticBkg_less-stats_50p/JPsi_pTbin%d_bineo0p0%dGeV.png",pTbin,bineo));
+ C1 -> SaveAs(Form("plots_MC_cuadraticBkg_less-stats_50p/JPsi_pTbin%d_bineo0p0%dGeV.pdf",pTbin,bineo));
+ C1 -> SaveAs(Form("plots_MC_cuadraticBkg_less-stats_50p/JPsi_pTbin%d_bineo0p0%dGeV.root",pTbin,bineo));
+
+
+
+
+}
+
+
+// Fitting function definition for Passed sample
+Double_t fitting_function_passed (Double_t *val, Double_t *par)
+{
+ Double_t exponential = exp(-1*((val[0]-par[1])*(val[0]-par[1])/(2*par[2]*par[2])));
+ Double_t f_passed = (par[0] * exponential + par[3]*val[0]*val[0] + par[4]*val[0] + par[5])*par[6];
+ return f_passed;
+}
+
+// Fitting function definition for Failed sample
+Double_t fitting_function_failed (Double_t *val, Double_t *par)
+{
+ Double_t exponential = exp(-1*((val[0]-par[1])*(val[0]-par[1])/(2*par[2]*par[2])));
+ Double_t f_failed = (par[0] * exponential + par[3]*val[0]*val[0] + par[4]*val[0] + par[5])*(1-par[6]);
+ return f_failed;
+}
+
+
+
+TH1D* ProjectHistogram(TH2D* h, double ptmin, double ptmax, char name[])
+{
+ //declare histograms and variables
+ TH1D *hprojected;
+ double half_bin_width = 0.5 * (h -> GetYaxis() -> GetBinWidth(1));
+ double Lowedgeup, Lowedgedown;
+
+ if (ptmax == -1)
+ {
+ int LowerBin = 1;
+ int UpperBin = h -> GetNbinsY();
+
+ hprojected = h -> ProjectionX(name, LowerBin, UpperBin, "e");
+
+ }
+
+ else
+ {
+ int LowerBin = int(h -> GetYaxis() -> FindBin(ptmin + half_bin_width));
+ int UpperBin = int(h -> GetYaxis() -> FindBin(ptmax - half_bin_width));
+
+ Lowedgeup = h -> GetYaxis() -> GetBinLowEdge(UpperBin);
+ Lowedgedown = h -> GetYaxis() -> GetBinLowEdge(LowerBin);
+
+ hprojected = h -> ProjectionX(name, LowerBin, UpperBin, "e");
+ }
+
+ return hprojected;
+
+}
diff --git a/test/jetTrigger_semilep_2017_C_HLT_PFJet40_v.cfg b/test/jetTrigger_SL_2017_HLT_PFJet40_Data.cfg
similarity index 65%
rename from test/jetTrigger_semilep_2017_C_HLT_PFJet40_v.cfg
rename to test/jetTrigger_SL_2017_HLT_PFJet40_Data.cfg
index fc1e88a..0ab151b 100644
--- a/test/jetTrigger_semilep_2017_C_HLT_PFJet40_v.cfg
+++ b/test/jetTrigger_SL_2017_HLT_PFJet40_Data.cfg
@@ -2,19 +2,12 @@
process = MssmHbb
eventsMax = -1
-# # == Monte Carlo ==
-# ntuplesList = tools:mssmhbb-2017-v4/mc/SUSYGluGluToBBHToBB_M-200_rootFileList.txt
-# isMC = true
-# output = histograms_semilep_MH-200_2017-v4_test.root
-# nloMC = true
-# signalRegion = true
-
# == Data ==
-ntuplesList = tools:mssmhbb-2017-v4/data/JetHT_Run2017C_rootFileList.txt
+ntuplesList = /afs/desy.de/user/l/leyvaped/Analyses/MSSM/Run2017/CMSSW_10_6_20/src/Analysis/Tools/data/ntuples/2017/v6/data/JetHT_Run2017C_rootFileList.txt
isMC = false
-output = histograms_JKTE_semilep_BTagCSV_2017-v4_exttree_20200520.root
+output = histograms_JKTE_semilep_2017-v6_Legacy_JetHT_Run2017C.root
signalRegion = false
-json = tools:2017/certified/Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON.txt
+json = /afs/desy.de/user/l/leyvaped/Analyses/MSSM/Run2017/Cert_294927-306462_13TeV_UL2017_Collisions17_GoldenJSON.txt
[Trigger]
@@ -48,6 +41,9 @@ nMin = 1
ptMin = 40
etaMax = 2.3
+
+#
+#
### User-defined
[User]
dRMin = 1.0
@@ -56,7 +52,7 @@ doTree = true
[Jets]
-jets = updatedPatJets
+jets = updatedJets
nMin = 2
id = tight
puId = loose
diff --git a/test/jetTrigger_SL_2017_MC_UL.cfg b/test/jetTrigger_SL_2017_MC_UL.cfg
new file mode 100644
index 0000000..cd30aca
--- /dev/null
+++ b/test/jetTrigger_SL_2017_MC_UL.cfg
@@ -0,0 +1,74 @@
+[Info]
+process = MssmHbb
+eventsMax = 100000
+
+# == Monte Carlo ==
+ntuplesList = /afs/desy.de/user/l/leyvaped/Analyses/MSSM/Run2017/CMSSW_10_6_20/src/Analysis/Tools/data/ntuples/2017/v6/mc/QCD_HT100to200_rootFileList.txt
+isMC = true
+output = histograms_semilep_JKTE_2017_v6_Legacy.root
+nloMC = true
+signalRegion = false
+
+[Trigger]
+results = TriggerResults
+hltPath = HLT_PFJet40_v
+L1T.Jets = l1tJets
+
+[Trigger.Objects.Jets]
+L1 = l1tJets
+Calo = hltSingleCaloJet10
+PF = hltSinglePFJet40
+L1.MatchDeltaR = 0.5
+Calo.MatchDeltaR = 0.5
+PF.MatchDeltaR = 0.5
+
+[Trigger.Emulate.Jets.L1]
+seed = L1_SingleJet40Eta2p3
+nMin = 1
+ptMin = 40
+etaMax = 2.3
+
+[Trigger.Emulate.Jets.Calo]
+path = HLT_CaloJet30Eta2p3
+nMin = 1
+ptMin = 30
+etaMax = 2.3
+
+[Trigger.Emulate.Jets.PF]
+path = HLT_PFJet40Eta2p3
+nMin = 1
+ptMin = 40
+etaMax = 2.3
+
+
+#
+#
+### User-defined
+[User]
+dRMin = 1.0
+dEtaMax = 1.5
+doTree = true
+
+
+[Jets]
+jets = updatedJets
+nMin = 2
+id = tight
+puId = loose
+ptMin = 30
+ptMin = 30
+ptMin = -1
+etaMax = 2.3
+etaMax = 2.3
+etaMax = -1
+extendedFlavour = true
+
+[Generator]
+genParticles = prunedGenParticles
+genJets = slimmedGenJets
+
+
+[Corrections]
+Jets.jerPtRes = /afs/desy.de/user/l/leyvaped/Analyses/MSSM/Run2017/CMSSW_10_6_20/src/Analysis/Tools/data/calibrations/2017/jer/Summer19UL17_JRV2_MC_PtResolution_AK4PFchs.txt
+Jets.jerSF = /afs/desy.de/user/l/leyvaped/Analyses/MSSM/Run2017/CMSSW_10_6_20/src/Analysis/Tools/data/calibrations/2017/jer/Summer19UL17_JRV2_MC_SF_AK4PFchs.txt
+Pileup.reweight = /afs/desy.de/user/l/leyvaped/Analyses/MSSM/Run2017/CMSSW_10_6_20/src/Analysis/Tools/data/calibrations/2017/pileup/run2_legacy/PileupWeight_MSSMHbb_mix_2017_UltraLegacy.root
diff --git a/test/jetTrigger_semilep_2017.cfg b/test/jetTrigger_semilep_2017.cfg
deleted file mode 100644
index a3f6d6f..0000000
--- a/test/jetTrigger_semilep_2017.cfg
+++ /dev/null
@@ -1,59 +0,0 @@
-[Info]
-process = MssmHbb
-eventsMax = -1
-
-# # == Monte Carlo ==
-# ntuplesList = tools:mssmhbb-2017-v4/mc/SUSYGluGluToBBHToBB_M-200_rootFileList.txt
-# isMC = true
-# output = histograms_semilep_MH-200_2017-v4_test.root
-# nloMC = true
-# signalRegion = true
-
-# == Data ==
-ntuplesList = tools:mssmhbb-2017-v4/data/JetHT_Run2017C_rootFileList.txt
-isMC = false
-output = histograms_JKTE_semilep_BTagCSV_2017-v4_exttree_20200520.root
-signalRegion = false
-json = tools:2017/certified/Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON.txt
-
-
-[Trigger]
-results = TriggerResults
-hltPath = HLT_PFJet60_v
-
-
-[Trigger.Objects]
-directory = slimmedPatTrigger
-Jets.L1 = hltL1sSingleJet35
-Jets.Calo = hltSingleCaloJet40
-Jets.PF = hltSinglePFJet60
-Muons.L1 = hltL1Mu12er2p3Jet40er2p3dRMax0p4DoubleJet40er2p3dEtaMax1p6_l1muon
-Muons.L3 = hltL3fL1sMu12Dijet40L1f0L2f8L3Filtered12
-BTag.Calo = hltBTagCalo30x8CSVp0p92DoubleWithMatching
-#
-#
-### User-defined
-[User]
-dRMin = 1.0
-dEtaMax = 1.5
-doTree = true
-
-
-[Jets]
-jets = updatedPatJets
-nMin = 2
-id = tight
-puId = loose
-ptMin = 30
-ptMin = 30
-ptMin = -1
-etaMax = 2.3
-etaMax = 2.3
-etaMax = -1
-extendedFlavour = true
-
-[Generator]
-genParticles = prunedGenParticles
-genJets = slimmedGenJets
-
-
diff --git a/test/jetTrigger_semilep_2017_HT1000to1500.cfg b/test/jetTrigger_semilep_2017_HT1000to1500.cfg
deleted file mode 100644
index da11093..0000000
--- a/test/jetTrigger_semilep_2017_HT1000to1500.cfg
+++ /dev/null
@@ -1,59 +0,0 @@
-[Info]
-process = MssmHbb
-eventsMax = -1
-
-# == Monte Carlo ==
-ntuplesList = tools:mssmhbb-2017-v4/mc/QCD_HT1000to1500_rootFileList.txt
-isMC = true
-output = histograms_semilep_JKTE_2017_mcQCD_HT1000to1500.root
-nloMC = true
-signalRegion = false
-
-# == Data ==
-#ntuplesList = tools:mssmhbb-2017-v4/data/JetHT_Run2017C_rootFileList.txt
-#isMC = false
-#output = histograms_JKTE_semilep_BTagCSV_2017-v4_exttree_20200520.root
-#signalRegion = false
-#json = tools:2017/certified/Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON.txt
-
-
-[Trigger]
-results = TriggerResults
-hltPath = HLT_PFJet60_v
-
-
-[Trigger.Objects]
-directory = slimmedPatTrigger
-Jets.L1 = hltL1sSingleJet35
-Jets.Calo = hltSingleCaloJet40
-Jets.PF = hltSinglePFJet60
-Muons.L1 = hltL1Mu12er2p3Jet40er2p3dRMax0p4DoubleJet40er2p3dEtaMax1p6_l1muon
-Muons.L3 = hltL3fL1sMu12Dijet40L1f0L2f8L3Filtered12
-BTag.Calo = hltBTagCalo30x8CSVp0p92DoubleWithMatching
-#
-#
-### User-defined
-[User]
-dRMin = 1.0
-dEtaMax = 1.5
-doTree = true
-
-
-[Jets]
-jets = updatedPatJets
-nMin = 2
-id = tight
-puId = loose
-ptMin = 30
-ptMin = 30
-ptMin = -1
-etaMax = 2.3
-etaMax = 2.3
-etaMax =-1
-extendedFlavour = true
-
-[Generator]
-genParticles = prunedGenParticles
-genJets = slimmedGenJets
-
-
diff --git a/test/jetTrigger_semilep_2017_HT100to200.cfg b/test/jetTrigger_semilep_2017_HT100to200.cfg
deleted file mode 100644
index 33fc5b9..0000000
--- a/test/jetTrigger_semilep_2017_HT100to200.cfg
+++ /dev/null
@@ -1,59 +0,0 @@
-[Info]
-process = MssmHbb
-eventsMax = -1
-
-# == Monte Carlo ==
-ntuplesList = tools:mssmhbb-2017-v4/mc/QCD_HT100to200_rootFileList.txt
-isMC = true
-output = histograms_semilep_JKTE_2017_mcQCD_HT100to200.root
-nloMC = true
-signalRegion = false
-
-# == Data ==
-#ntuplesList = tools:mssmhbb-2017-v4/data/JetHT_Run2017C_rootFileList.txt
-#isMC = false
-#output = histograms_JKTE_semilep_BTagCSV_2017-v4_exttree_20200520.root
-#signalRegion = false
-#json = tools:2017/certified/Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON.txt
-
-
-[Trigger]
-results = TriggerResults
-hltPath = HLT_PFJet60_v
-
-
-[Trigger.Objects]
-directory = slimmedPatTrigger
-Jets.L1 = hltL1sSingleJet35
-Jets.Calo = hltSingleCaloJet40
-Jets.PF = hltSinglePFJet60
-Muons.L1 = hltL1Mu12er2p3Jet40er2p3dRMax0p4DoubleJet40er2p3dEtaMax1p6_l1muon
-Muons.L3 = hltL3fL1sMu12Dijet40L1f0L2f8L3Filtered12
-BTag.Calo = hltBTagCalo30x8CSVp0p92DoubleWithMatching
-#
-#
-### User-defined
-[User]
-dRMin = 1.0
-dEtaMax = 1.5
-doTree = true
-
-
-[Jets]
-jets = updatedPatJets
-nMin = 2
-id = tight
-puId = loose
-ptMin = 30
-ptMin = 30
-ptMin = -1
-etaMax = 2.3
-etaMax = 2.3
-etaMax =-1
-extendedFlavour = true
-
-[Generator]
-genParticles = prunedGenParticles
-genJets = slimmedGenJets
-
-
diff --git a/test/jetTrigger_semilep_2017_HT100to200_ext1.cfg b/test/jetTrigger_semilep_2017_HT100to200_ext1.cfg
deleted file mode 100644
index 77dc775..0000000
--- a/test/jetTrigger_semilep_2017_HT100to200_ext1.cfg
+++ /dev/null
@@ -1,59 +0,0 @@
-[Info]
-process = MssmHbb
-eventsMax = -1
-
-# == Monte Carlo ==
-ntuplesList = tools:mssmhbb-2017-v4/mc/QCD_HT100to200_ext1_rootFileList.txt
-isMC = true
-output = histograms_semilep_JKTE_2017_mcQCD_HT100to200_ext1.root
-nloMC = true
-signalRegion = false
-
-# == Data ==
-#ntuplesList = tools:mssmhbb-2017-v4/data/JetHT_Run2017C_rootFileList.txt
-#isMC = false
-#output = histograms_JKTE_semilep_BTagCSV_2017-v4_exttree_20200520.root
-#signalRegion = false
-#json = tools:2017/certified/Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON.txt
-
-
-[Trigger]
-results = TriggerResults
-hltPath = HLT_PFJet60_v
-
-
-[Trigger.Objects]
-directory = slimmedPatTrigger
-Jets.L1 = hltL1sSingleJet35
-Jets.Calo = hltSingleCaloJet40
-Jets.PF = hltSinglePFJet60
-Muons.L1 = hltL1Mu12er2p3Jet40er2p3dRMax0p4DoubleJet40er2p3dEtaMax1p6_l1muon
-Muons.L3 = hltL3fL1sMu12Dijet40L1f0L2f8L3Filtered12
-BTag.Calo = hltBTagCalo30x8CSVp0p92DoubleWithMatching
-#
-#
-### User-defined
-[User]
-dRMin = 1.0
-dEtaMax = 1.5
-doTree = true
-
-
-[Jets]
-jets = updatedPatJets
-nMin = 2
-id = tight
-puId = loose
-ptMin = 30
-ptMin = 30
-ptMin = -1
-etaMax = 2.3
-etaMax = 2.3
-etaMax =-1
-extendedFlavour = true
-
-[Generator]
-genParticles = prunedGenParticles
-genJets = slimmedGenJets
-
-
diff --git a/test/jetTrigger_semilep_2017_HT1500to2000.cfg b/test/jetTrigger_semilep_2017_HT1500to2000.cfg
deleted file mode 100644
index 398c8d1..0000000
--- a/test/jetTrigger_semilep_2017_HT1500to2000.cfg
+++ /dev/null
@@ -1,59 +0,0 @@
-[Info]
-process = MssmHbb
-eventsMax = -1
-
-# == Monte Carlo ==
-ntuplesList = tools:mssmhbb-2017-v4/mc/QCD_HT1500to2000_rootFileList.txt
-isMC = true
-output = histograms_semilep_JKTE_2017_mcQCD_HT1500to2000.root
-nloMC = true
-signalRegion = false
-
-# == Data ==
-#ntuplesList = tools:mssmhbb-2017-v4/data/JetHT_Run2017C_rootFileList.txt
-#isMC = false
-#output = histograms_JKTE_semilep_BTagCSV_2017-v4_exttree_20200520.root
-#signalRegion = false
-#json = tools:2017/certified/Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON.txt
-
-
-[Trigger]
-results = TriggerResults
-hltPath = HLT_PFJet60_v
-
-
-[Trigger.Objects]
-directory = slimmedPatTrigger
-Jets.L1 = hltL1sSingleJet35
-Jets.Calo = hltSingleCaloJet40
-Jets.PF = hltSinglePFJet60
-Muons.L1 = hltL1Mu12er2p3Jet40er2p3dRMax0p4DoubleJet40er2p3dEtaMax1p6_l1muon
-Muons.L3 = hltL3fL1sMu12Dijet40L1f0L2f8L3Filtered12
-BTag.Calo = hltBTagCalo30x8CSVp0p92DoubleWithMatching
-#
-#
-### User-defined
-[User]
-dRMin = 1.0
-dEtaMax = 1.5
-doTree = true
-
-
-[Jets]
-jets = updatedPatJets
-nMin = 2
-id = tight
-puId = loose
-ptMin = 30
-ptMin = 30
-ptMin = -1
-etaMax = 2.3
-etaMax = 2.3
-etaMax =-1
-extendedFlavour = true
-
-[Generator]
-genParticles = prunedGenParticles
-genJets = slimmedGenJets
-
-
diff --git a/test/jetTrigger_semilep_2017_HT2000toInf.cfg b/test/jetTrigger_semilep_2017_HT2000toInf.cfg
deleted file mode 100644
index e124d55..0000000
--- a/test/jetTrigger_semilep_2017_HT2000toInf.cfg
+++ /dev/null
@@ -1,59 +0,0 @@
-[Info]
-process = MssmHbb
-eventsMax = -1
-
-# == Monte Carlo ==
-ntuplesList = tools:mssmhbb-2017-v4/mc/QCD_HT2000toInf_rootFileList.txt
-isMC = true
-output = histograms_semilep_JKTE_2017_mcQCD_HT2000toInf.root
-nloMC = true
-signalRegion = false
-
-# == Data ==
-#ntuplesList = tools:mssmhbb-2017-v4/data/JetHT_Run2017C_rootFileList.txt
-#isMC = false
-#output = histograms_JKTE_semilep_BTagCSV_2017-v4_exttree_20200520.root
-#signalRegion = false
-#json = tools:2017/certified/Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON.txt
-
-
-[Trigger]
-results = TriggerResults
-hltPath = HLT_PFJet60_v
-
-
-[Trigger.Objects]
-directory = slimmedPatTrigger
-Jets.L1 = hltL1sSingleJet35
-Jets.Calo = hltSingleCaloJet40
-Jets.PF = hltSinglePFJet60
-Muons.L1 = hltL1Mu12er2p3Jet40er2p3dRMax0p4DoubleJet40er2p3dEtaMax1p6_l1muon
-Muons.L3 = hltL3fL1sMu12Dijet40L1f0L2f8L3Filtered12
-BTag.Calo = hltBTagCalo30x8CSVp0p92DoubleWithMatching
-#
-#
-### User-defined
-[User]
-dRMin = 1.0
-dEtaMax = 1.5
-doTree = true
-
-
-[Jets]
-jets = updatedPatJets
-nMin = 2
-id = tight
-puId = loose
-ptMin = 30
-ptMin = 30
-ptMin = -1
-etaMax = 2.3
-etaMax = 2.3
-etaMax =-1
-extendedFlavour = true
-
-[Generator]
-genParticles = prunedGenParticles
-genJets = slimmedGenJets
-
-
diff --git a/test/jetTrigger_semilep_2017_HT200to300.cfg b/test/jetTrigger_semilep_2017_HT200to300.cfg
deleted file mode 100644
index 76368d2..0000000
--- a/test/jetTrigger_semilep_2017_HT200to300.cfg
+++ /dev/null
@@ -1,59 +0,0 @@
-[Info]
-process = MssmHbb
-eventsMax = -1
-
-# == Monte Carlo ==
-ntuplesList = tools:mssmhbb-2017-v4/mc/QCD_HT200to300_rootFileList.txt
-isMC = true
-output = histograms_semilep_JKTE_2017_mcQCD_HT200to300.root
-nloMC = true
-signalRegion = false
-
-# == Data ==
-#ntuplesList = tools:mssmhbb-2017-v4/data/JetHT_Run2017C_rootFileList.txt
-#isMC = false
-#output = histograms_JKTE_semilep_BTagCSV_2017-v4_exttree_20200520.root
-#signalRegion = false
-#json = tools:2017/certified/Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON.txt
-
-
-[Trigger]
-results = TriggerResults
-hltPath = HLT_PFJet60_v
-
-
-[Trigger.Objects]
-directory = slimmedPatTrigger
-Jets.L1 = hltL1sSingleJet35
-Jets.Calo = hltSingleCaloJet40
-Jets.PF = hltSinglePFJet60
-Muons.L1 = hltL1Mu12er2p3Jet40er2p3dRMax0p4DoubleJet40er2p3dEtaMax1p6_l1muon
-Muons.L3 = hltL3fL1sMu12Dijet40L1f0L2f8L3Filtered12
-BTag.Calo = hltBTagCalo30x8CSVp0p92DoubleWithMatching
-#
-#
-### User-defined
-[User]
-dRMin = 1.0
-dEtaMax = 1.5
-doTree = true
-
-
-[Jets]
-jets = updatedPatJets
-nMin = 2
-id = tight
-puId = loose
-ptMin = 30
-ptMin = 30
-ptMin = -1
-etaMax = 2.3
-etaMax = 2.3
-etaMax =-1
-extendedFlavour = true
-
-[Generator]
-genParticles = prunedGenParticles
-genJets = slimmedGenJets
-
-
diff --git a/test/jetTrigger_semilep_2017_HT300to500.cfg b/test/jetTrigger_semilep_2017_HT300to500.cfg
deleted file mode 100644
index 2bb2cfd..0000000
--- a/test/jetTrigger_semilep_2017_HT300to500.cfg
+++ /dev/null
@@ -1,59 +0,0 @@
-[Info]
-process = MssmHbb
-eventsMax = -1
-
-# == Monte Carlo ==
-ntuplesList = tools:mssmhbb-2017-v4/mc/QCD_HT300to500_rootFileList.txt
-isMC = true
-output = histograms_semilep_JKTE_2017_mcQCD_HT300to500.root
-nloMC = true
-signalRegion = false
-
-# == Data ==
-#ntuplesList = tools:mssmhbb-2017-v4/data/JetHT_Run2017C_rootFileList.txt
-#isMC = false
-#output = histograms_JKTE_semilep_BTagCSV_2017-v4_exttree_20200520.root
-#signalRegion = false
-#json = tools:2017/certified/Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON.txt
-
-
-[Trigger]
-results = TriggerResults
-hltPath = HLT_PFJet60_v
-
-
-[Trigger.Objects]
-directory = slimmedPatTrigger
-Jets.L1 = hltL1sSingleJet35
-Jets.Calo = hltSingleCaloJet40
-Jets.PF = hltSinglePFJet60
-Muons.L1 = hltL1Mu12er2p3Jet40er2p3dRMax0p4DoubleJet40er2p3dEtaMax1p6_l1muon
-Muons.L3 = hltL3fL1sMu12Dijet40L1f0L2f8L3Filtered12
-BTag.Calo = hltBTagCalo30x8CSVp0p92DoubleWithMatching
-#
-#
-### User-defined
-[User]
-dRMin = 1.0
-dEtaMax = 1.5
-doTree = true
-
-
-[Jets]
-jets = updatedPatJets
-nMin = 2
-id = tight
-puId = loose
-ptMin = 30
-ptMin = 30
-ptMin = -1
-etaMax = 2.3
-etaMax = 2.3
-etaMax =-1
-extendedFlavour = true
-
-[Generator]
-genParticles = prunedGenParticles
-genJets = slimmedGenJets
-
-
diff --git a/test/jetTrigger_semilep_2017_HT500to700.cfg b/test/jetTrigger_semilep_2017_HT500to700.cfg
deleted file mode 100644
index 988041e..0000000
--- a/test/jetTrigger_semilep_2017_HT500to700.cfg
+++ /dev/null
@@ -1,59 +0,0 @@
-[Info]
-process = MssmHbb
-eventsMax = -1
-
-# == Monte Carlo ==
-ntuplesList = tools:mssmhbb-2017-v4/mc/QCD_HT500to700_rootFileList.txt
-isMC = true
-output = histograms_semilep_JKTE_2017_mcQCD_HT500to700.root
-nloMC = true
-signalRegion = false
-
-# == Data ==
-#ntuplesList = tools:mssmhbb-2017-v4/data/JetHT_Run2017C_rootFileList.txt
-#isMC = false
-#output = histograms_JKTE_semilep_BTagCSV_2017-v4_exttree_20200520.root
-#signalRegion = false
-#json = tools:2017/certified/Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON.txt
-
-
-[Trigger]
-results = TriggerResults
-hltPath = HLT_PFJet60_v
-
-
-[Trigger.Objects]
-directory = slimmedPatTrigger
-Jets.L1 = hltL1sSingleJet35
-Jets.Calo = hltSingleCaloJet40
-Jets.PF = hltSinglePFJet60
-Muons.L1 = hltL1Mu12er2p3Jet40er2p3dRMax0p4DoubleJet40er2p3dEtaMax1p6_l1muon
-Muons.L3 = hltL3fL1sMu12Dijet40L1f0L2f8L3Filtered12
-BTag.Calo = hltBTagCalo30x8CSVp0p92DoubleWithMatching
-#
-#
-### User-defined
-[User]
-dRMin = 1.0
-dEtaMax = 1.5
-doTree = true
-
-
-[Jets]
-jets = updatedPatJets
-nMin = 2
-id = tight
-puId = loose
-ptMin = 30
-ptMin = 30
-ptMin = -1
-etaMax = 2.3
-etaMax = 2.3
-etaMax =-1
-extendedFlavour = true
-
-[Generator]
-genParticles = prunedGenParticles
-genJets = slimmedGenJets
-
-
diff --git a/test/jetTrigger_semilep_2017_HT700to1000.cfg b/test/jetTrigger_semilep_2017_HT700to1000.cfg
deleted file mode 100644
index c6dc6a7..0000000
--- a/test/jetTrigger_semilep_2017_HT700to1000.cfg
+++ /dev/null
@@ -1,59 +0,0 @@
-[Info]
-process = MssmHbb
-eventsMax = -1
-
-# == Monte Carlo ==
-ntuplesList = tools:mssmhbb-2017-v4/mc/QCD_HT700to1000_rootFileList.txt
-isMC = true
-output = histograms_semilep_JKTE_2017_mcQCD_HT700to1000.root
-nloMC = true
-signalRegion = false
-
-# == Data ==
-#ntuplesList = tools:mssmhbb-2017-v4/data/JetHT_Run2017C_rootFileList.txt
-#isMC = false
-#output = histograms_JKTE_semilep_BTagCSV_2017-v4_exttree_20200520.root
-#signalRegion = false
-#json = tools:2017/certified/Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON.txt
-
-
-[Trigger]
-results = TriggerResults
-hltPath = HLT_PFJet60_v
-
-
-[Trigger.Objects]
-directory = slimmedPatTrigger
-Jets.L1 = hltL1sSingleJet35
-Jets.Calo = hltSingleCaloJet40
-Jets.PF = hltSinglePFJet60
-Muons.L1 = hltL1Mu12er2p3Jet40er2p3dRMax0p4DoubleJet40er2p3dEtaMax1p6_l1muon
-Muons.L3 = hltL3fL1sMu12Dijet40L1f0L2f8L3Filtered12
-BTag.Calo = hltBTagCalo30x8CSVp0p92DoubleWithMatching
-#
-#
-### User-defined
-[User]
-dRMin = 1.0
-dEtaMax = 1.5
-doTree = true
-
-
-[Jets]
-jets = updatedPatJets
-nMin = 2
-id = tight
-puId = loose
-ptMin = 30
-ptMin = 30
-ptMin = -1
-etaMax = 2.3
-etaMax = 2.3
-etaMax =-1
-extendedFlavour = true
-
-[Generator]
-genParticles = prunedGenParticles
-genJets = slimmedGenJets
-
-
diff --git a/test/muonTrigger_semilep_2017.cfg b/test/muonTrigger_semilep_2017.cfg
deleted file mode 100644
index b4d0534..0000000
--- a/test/muonTrigger_semilep_2017.cfg
+++ /dev/null
@@ -1,58 +0,0 @@
-[Info]
-process = MssmHbb
-eventsMax = 500000
-
-# # == Monte Carlo ==
-# ntuplesList = tools:mssmhbb-2017-v4/mc/SUSYGluGluToBBHToBB_M-200_rootFileList.txt
-# isMC = true
-# output = histograms_MuonKTE_semilep_MH-200_2017-v4_test.root
-# nloMC = true
-# signalRegion = true
-
-# == Data ==
-ntuplesList = tools:mssmhbb-2017-v4/data/DoubleMuon_Run2017C_rootFileList.txt
-isMC = false
-output = histograms_MuonKTE_semilep_HLT_Mu8.root
-signalRegion = false
-json = /afs/desy.de/user/l/leyvaped/CMSSW_10_6_20/src/Analysis/Tools/data/calibrations/2017/certified/Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON.txt
-
-[Trigger]
-results = TriggerResults
-#hltPath = HLT_Mu8
-hltPath = HLT_Mu8_v
-#l1Seed = L1_Mu12er2p3_Jet40er2p3_dR_Max0p4_DoubleJet40er2p3_dEta_Max1p6
-
-
-[Trigger.Objects]
-directory = slimmedPatTrigger
-#Jets.L1 = hltL1sSingleJet35
-#Jets.Calo = hltSingleCaloJet40
-#Jets.PF = hltSinglePFJet60
-Muons.L1 = hltL1sSingleMu3IorSingleMu5IorSingleMu7
-Muons.L3 = hltL3fL1sMu5L1f0L2f5L3Filtered8
-#Muons.L1 = hltL1fL1sMu5L1Filtered0
-#Muons.L3 = hltL3fL1sMu5L1f0L2f5L3Filtered8
-BTag.Calo = hltBTagCalo30x8CSVp0p92DoubleWithMatching
-
-
-#
-#
-### User-defined
-[User]
-dRMin = 1.0
-dEtaMax = 1.5
-doTree = true
-
-[Muons]
-muons = slimmedMuons
-nMin = 2
-id = tight
-ptMin = 5.
-ptMax = 30.
-etaMax = 2.3
-
-[Generator]
-genParticles = prunedGenParticles
-genJets = slimmedGenJets
-
-
diff --git a/test/muonTrigger_semilep_2017_C.cfg b/test/muonTrigger_semilep_2017_Data.cfg
similarity index 60%
rename from test/muonTrigger_semilep_2017_C.cfg
rename to test/muonTrigger_semilep_2017_Data.cfg
index 09ce35a..8a52d98 100644
--- a/test/muonTrigger_semilep_2017_C.cfg
+++ b/test/muonTrigger_semilep_2017_Data.cfg
@@ -1,26 +1,20 @@
[Info]
process = MssmHbb
-eventsMax = -1
-
-
-# # == Monte Carlo ==
-# ntuplesList = tools:mssmhbb-2017-v4/mc/SUSYGluGluToBBHToBB_M-200_rootFileList.txt
-# isMC = true
-# output = histograms_MuonKTE_semilep_MH-200_2017-v4_test.root
-# nloMC = true
-# signalRegion = true
+eventsMax = 100000
# == Data ==
-ntuplesList = tools:mssmhbb-2017-v4/data/DoubleMuon_Run2017C_rootFileList.txt
+ntuplesList = /afs/desy.de/user/l/leyvaped/Analyses/MSSM/Run2017/CMSSW_10_6_20/src/Analysis/Tools/data/ntuples/2017/v6/data/DoubleMuon_Run2017C_rootFileList.txt
isMC = false
-output = histograms_MuonKTE_semilep_HLT_Mu8.root
-signalRegion = true
-json = tools:2017/certified/Cert_294927-306462_13TeV_EOY2017ReReco_Collisions17_JSON.txt
+output = histograms_MKTE_semilep_2017-v6_Legacy_HLT_Mu8_DoubleMuon_Run2017C.root
+signalRegion = false
+json = /afs/desy.de/user/l/leyvaped/Analyses/MSSM/Run2017/Cert_294927-306462_13TeV_UL2017_Collisions17_GoldenJSON.txt
+
[Trigger]
results = TriggerResults
hltPath = HLT_Mu8_v
+
[Trigger.Objects]
directory = slimmedPatTrigger
@@ -42,7 +36,7 @@ nMin = 1
ptMin = 12
etaMax = 2.3
-
+
### User-defined
[User]
dRMin = 0.1
diff --git a/test/muonTrigger_semilep_2017_MC.cfg b/test/muonTrigger_semilep_2017_MC.cfg
new file mode 100644
index 0000000..23e5708
--- /dev/null
+++ b/test/muonTrigger_semilep_2017_MC.cfg
@@ -0,0 +1,63 @@
+[Info]
+process = MssmHbb
+eventsMax = 100000
+
+
+# == Monte Carlo ==
+ntuplesList = /afs/desy.de/user/l/leyvaped/Analyses/MSSM/Run2017/CMSSW_10_6_20/src/Analysis/Trigger/test/muonEnriched_filelist/QCD_Pt-50To80_MuEnrichedPt5_rootFileList_good.txt
+isMC = true
+output = histograms_MKTE_semilep_2017-v6_Legacy_HLT_Mu8_MuEnriched_QCD_Pt-50To80.root
+nloMC = true
+signalRegion = false
+
+
+[Trigger]
+results = TriggerResults
+#hltPath = HLT_Mu8
+hltPath = HLT_Mu8_v
+#l1Seed = L1_Mu12er2p3_Jet40er2p3_dR_Max0p4_DoubleJet40er2p3_dEta_Max1p6
+
+
+[Trigger.Objects]
+directory = slimmedPatTrigger
+
+[Trigger.Objects.Muons]
+L1 = hltL1sSingleMu3IorSingleMu5IorSingleMu7
+L3 = hltL3fL1sMu5L1f0L2f5L3Filtered8
+L1.MatchDeltaR = 0.4
+L3.MatchDeltaR = 0.005
+
+[Trigger.Emulate.Muons.L1]
+seed = L1_SingleMu12Eta2p3
+nMin = 1
+ptMin = 12
+etaMax = 2.3
+
+[Trigger.Emulate.Muons.L3]
+path = HLT_L3SingleMu12Eta2p3
+nMin = 1
+ptMin = 12
+etaMax = 2.3
+
+
+#
+#
+### User-defined
+[User]
+dRMin = 0.1
+dEtaMax = 1.5
+doTree = true
+
+[Muons]
+muons = slimmedMuons
+nMin = 2
+id = tight
+ptMin = 5.
+ptMax = 30.
+etaMax = 2.3
+
+[Generator]
+genParticles = prunedGenParticles
+genJets = slimmedGenJets
+
+