Skip to content

Instantly share code, notes, and snippets.

@raggleton
Created February 18, 2016 13:12
Show Gist options
  • Save raggleton/c6ed0267d0ce98721d6a to your computer and use it in GitHub Desktop.
Save raggleton/c6ed0267d0ce98721d6a to your computer and use it in GitHub Desktop.
Joe's sums scripts
#include "TFile.h"
#include "TTree.h"
#include "TH1F.h"
#include "TH2F.h"
#include <iostream>
#include <math.h>
#include <vector>
#include <string>
//#include "L1AnalysisEventDataFormat.h"
//#include "L1AnalysisSimulationDataFormat.h"
//#include "L1AnalysisGCTDataFormat.h"
//#include "L1AnalysisGTDataFormat.h"
//#include "L1AnalysisGMTDataFormat.h"
//#include "L1AnalysisGTDataFormat.h"
//#include "L1AnalysisRCTDataFormat.h"
//#include "L1AnalysisDTTFDataFormat.h"
//#include "L1AnalysisCSCTFDataFormat.h"
#include "L1AnalysisRecoMetDataFormat.h"
#include "L1AnalysisRecoJetDataFormat.h"
//#include "L1AnalysisRecoClusterDataFormat.h"
#include "L1AnalysisRecoMuon2DataFormat.h" //added the '2'
//#include "L1AnalysisRecoRpcHitDataFormat.h"
//#include "L1AnalysisL1ExtraDataFormat.h"
//#include "L1AnalysisRecoVertexDataFormat.h"
//#include "L1AnalysisRecoTrackDataFormat.h"
//#include "L1AnalysisL1MenuDataFormat.h"
#include "L1AnalysisL1UpgradeDataFormat.h"
//#include "L1AnalysisL1CaloTowerDataFormat.h"
//#include "L1AnalysisCaloTPDataFormat.h"
#include "L1AnalysisRecoMetFilterDataFormat.h" //added this one
//function: add two pt vectors together in the (2d) transverse plane
//output: first element is magnitude, second element is phi
vector<float> addTwoVectors(float pt1, float phi1, float pt2, float phi2){
vector<float> output;
float xpt = pt1*cos(phi1) + pt2*cos(phi2);
float ypt = pt1*sin(phi1) + pt2*sin(phi2);
output.push_back(sqrt(pow(xpt,2)+pow(ypt,2)));
float phiOut = atan(ypt/xpt);
if ( xpt < 0 && ypt > 0 ){phiOut = phiOut + M_PI;}
if ( xpt < 0 && ypt < 0 ){phiOut = phiOut - M_PI;}
output.push_back(phiOut);
return output;
}
//function:input iEta and output physical Eta value
//NB: in reality the index will not be greater than 36*2
// as the Jets are 9x9 towers and the centres are indexed
vector<float> getEtaVec(vector<short> iEta){
vector<float> eta;
const float towerIndex2phys[40] = {0.0435, 0.1305, 0.2175, 0.3045, 0.3915, 0.4785, 0.5655,
0.6525, 0.7395, 0.8265, 0.9135, 1.0005, 1.0875, 1.1745,
1.2615, 1.3485,
1.4355, 1.5225, 1.6095, 1.6965, 1.7850,
1.8800, 1.9865, 2.1075, 2.2470, 2.4110, 2.5750, 2.8250,
2.9960, 3.2265, 3.4015, 3.5765, 3.7515, 3.9260,
4.1020, 4.2770, 4.4505, 4.6270, 4.8025, 5.0400};
for (UInt_t j=0; j<iEta.size(); j++){
iEta[j] = iEta[j]/2;
if(iEta[j]>0){eta.push_back(towerIndex2phys[iEta[j]-1]);}
else{eta.push_back(-towerIndex2phys[-iEta[j]-1]);}
}
return eta;
}
// //function:calculate dPhi for two phi inputs
// //NB:this is phi1-phi2
// double calc_dPHI(double phi1, double phi2){
// double dPhi = phi1 - phi2;
// if (dPhi>M_PI){dPhi=dPhi-2*M_PI;}
// if (dPhi<-M_PI){dPhi=dPhi+2*M_PI;}
// return dPhi;
// }
//Jet structure (use for trigger and reco)
struct Jet{
vector<float> et;
vector<float> eta;
vector<float> phi;
UInt_t n;
vector<short> bx; //'bx'==bunch crossing
//the following are for reco cleaning cuts
vector<float> nhef; //neutral hadron energy fraction
vector<float> pef; //neutral EM (photon) energy fraction
vector<float> mef; //muon energy fraction
vector<float> chef; //charged hadron energy fraction
vector<float> eef; //charged EM (electron) energy fraction
vector<short> chMult; //charged hadron multiplicity
vector<short> nhMult; //neutral hadron multiplicity
vector<short> phMult; //photon multiplicity
vector<short> elMult; //electron multiplicity
vector<short> muMult; //muon multiplicity
};
struct Particle{
vector<float> et;
vector<float> eta;
vector<float> phi;
UInt_t n;
vector<bool> looseID;
};
struct energySums{
float ett;
float ettBx;
float met;
float metBx;
float metPhi;
float htt;
float httBx;
float mht;
float mhtBx;
float mhtPhi;
};
/////////////////
/////////////////
//MAIN FUNCTION//
/////////////////
/////////////////
void esums_stage2_reco_comparison(){
//create a ROOT file to save all the histograms to (actually at end of script)
//first check the file doesn't exist already so we don't overwrite
string outputFilename = "comparisons_eSums_stage2_04.root";
TFile *kk = TFile::Open( outputFilename.c_str() );
if (kk!=0){
cout << "TERMINATE:not going to overwrite file" << endl;
return;
}
//load the ROOT file we will work on
TFile * f = new TFile("/storage/jt15104/L1Trigger_upgrade_ntuples/run260627_SingleMuReReco_HF_L1JEC_001.root");
//load the TTrees from said ROOT file
TTree * recoTree = (TTree*)f->Get("l1JetRecoTree/JetRecoTree");
TTree * upgradeTree = (TTree*)f->Get("l1UpgradeEmuTree/L1UpgradeTree");
TTree * muonTree = (TTree*)f->Get("l1MuonRecoTree/Muon2RecoTree");
TTree * metFilterTree = (TTree*)f->Get("l1MetFilterRecoTree/MetFilterRecoTree");
//load the number of event entries
Int_t neventRECO = (Int_t)recoTree->GetEntries();
double testRecoJetEnergy = 30; //above this energy we require all reco jets be 'clean'
/////////////////////////////
//Structures used in script//
/////////////////////////////
struct Jet l1jet;
struct Jet recojet;
struct Particle muon;
struct energySums l1Sums;
struct energySums myL1sums;
struct energySums recoSums;
// reference of branch class types
// L1Analysis::L1AnalysisEventDataFormat *event_ = new L1Analysis::L1AnalysisEventDataFormat();
// L1Analysis::L1AnalysisSimulationDataFormat *simulation_;
// L1Analysis::L1AnalysisGCTDataFormat *gct_;
// L1Analysis::L1AnalysisGMTDataFormat *gmt_;
// L1Analysis::L1AnalysisGTDataFormat *gt_;
// L1Analysis::L1AnalysisRCTDataFormat *rct_;
// L1Analysis::L1AnalysisDTTFDataFormat *dttf_;
// L1Analysis::L1AnalysisCSCTFDataFormat *csctf_;
// L1Analysis::L1AnalysisRecoMetDataFormat *recoMet_;
// L1Analysis::L1AnalysisRecoMuonDataFormat *recoMuon_; //THIS IS OUT OF DATE
// L1Analysis::L1AnalysisRecoRpcHitDataFormat *recoRpcHit_;
// L1Analysis::L1AnalysisRecoJetDataFormat *recoJet_ = new L1Analysis::L1AnalysisRecoJetDataFormat();
// L1Analysis::L1AnalysisRecoClusterDataFormat *recoBasicCluster_;
// L1Analysis::L1AnalysisRecoClusterDataFormat *recoSuperCluster_;
// L1Analysis::L1AnalysisL1ExtraDataFormat *l1extra_;
// L1Analysis::L1AnalysisL1ExtraDataFormat *l1emuextra_;
// L1Analysis::L1AnalysisRecoVertexDataFormat *recoVertex_;
// L1Analysis::L1AnalysisRecoTrackDataFormat *recoTrack_;
// L1Analysis::L1AnalysisL1MenuDataFormat *l1menu_;
// L1Analysis::L1AnalysisL1UpgradeDataFormat *upgrade_ = new L1Analysis::L1AnalysisL1UpgradeDataFormat();
// L1Analysis::L1AnalysisCaloTPDataFormat *caloTP_ = new L1Analysis::L1AnalysisCaloTPDataFormat();
// L1Analysis::L1AnalysisL1CaloTowerDataFormat *l1Tower_ = new L1Analysis::L1AnalysisL1CaloTowerDataFormat();
//set the branch addresses
L1Analysis::L1AnalysisRecoJetDataFormat *recoJet_ = new L1Analysis::L1AnalysisRecoJetDataFormat();
recoTree->SetBranchAddress("Jet", &recoJet_);
L1Analysis::L1AnalysisRecoMetDataFormat *recoMet_ = new L1Analysis::L1AnalysisRecoMetDataFormat();
recoTree->SetBranchAddress("Sums", &recoMet_);
L1Analysis::L1AnalysisL1UpgradeDataFormat *upgrade_ = new L1Analysis::L1AnalysisL1UpgradeDataFormat();
upgradeTree->SetBranchAddress("L1Upgrade", &upgrade_);
L1Analysis::L1AnalysisRecoMuon2DataFormat *recoMuon_ = new L1Analysis::L1AnalysisRecoMuon2DataFormat();
muonTree->SetBranchAddress("Muon", &recoMuon_);
L1Analysis::L1AnalysisRecoMetFilterDataFormat *recoMetFilter_ = new L1Analysis::L1AnalysisRecoMetFilterDataFormat();
metFilterTree->SetBranchAddress("MetFilters", &recoMetFilter_);
///////////////////////////////////////////
//create the framework for the histograms//
///////////////////////////////////////////
//distributions
TH1F * hMETphi_l1 = new TH1F("hMETphi_l1", ";#phi_{L1}^{MET}", 40, -M_PI, M_PI);
TH1F * hMHTphi_l1 = new TH1F("hMHTphi_l1", ";#phi_{L1}^{MHT}", 40, -M_PI, M_PI);
TH1F * hETT_l1 = new TH1F("hETT_l1", ";ETT_{L1} (GeV)", 40, 0, 400);
TH1F * hMET_l1 = new TH1F("hMET_l1", ";MET_{L1} (GeV)", 40, 0, 150);
TH1F * hHTT_l1 = new TH1F("hHTT_l1", ";HTT_{L1} (GeV)", 40, 0, 400);
TH1F * hHTT_l1_ZOOM = new TH1F("hHTT_l1_ZOOM", ";HTT_{L1} (GeV)", 50, 0, 50);
TH1F * hMHT_l1 = new TH1F("hMHT_l1", ";MHT_{L1} (GeV)", 40, 0, 150);
TH1F * h_LeadingL1jetPtForL1HTTis0 = new TH1F("h_LeadingL1jetPtForL1HTTis0", ";LeadingL1jetPt (GeV)", 40, 0, 100);
TH1F * h_LeadingL1jetPtForL1HTTnot0 = new TH1F("h_LeadingL1jetPtForL1HTTnot0", ";LeadingL1jetPt (GeV)", 40, 0, 100);
TH2F * h_LeadingL1jetEtaPhiForL1HTTis0 = new TH2F("h_LeadingL1jetEtaPhiForL1HTTis0", ";eta;phi", 50, -5, 5, 50, -M_PI, M_PI);
TH2F * h_LeadingL1jetEtaPhiForL1HTTnot0 = new TH2F("h_LeadingL1jetEtaPhiForL1HTTnot0", ";eta;phi", 50, -5, 5, 50, -M_PI, M_PI);
TH1F * hMETphi_reco = new TH1F("hMETphi_reco", ";#phi_{RECO}^{MET}", 40, -M_PI, M_PI);
TH1F * hMHTphi_reco = new TH1F("hMHTphi_reco", ";#phi_{RECO}^{MHT}", 40, 0, 2*M_PI);
TH1F * hETT_reco = new TH1F("hETT_reco", ";ETT_{RECO} (GeV)", 40, 0, 2000);
TH1F * hMET_reco = new TH1F("hMET_reco", ";MET_{RECO} (GeV)", 40, 0, 150);
TH1F * hHTT_reco = new TH1F("hHTT_reco", ";HTT_{RECO} (GeV)", 40, 0, 400);
TH1F * hMHT_reco = new TH1F("hMHT_reco", ";MHT_{RECO} (GeV)", 40, 0, 150);
//resolutions
TH1F * hdET_ETT = new TH1F("hdET_ETT", ";(ETT_{L1} - ETT_{RECO})/ETT_{RECO}", 100, -1.0, 1.0);
TH1F * hdET_MET = new TH1F("hdET_MET", ";(MET_{L1} - MET_{RECO})/MET_{RECO}", 100, -1.0, 3.5);
TH1F * hdET_HTT = new TH1F("hdET_HTT", ";(HTT_{L1} - HTT_{RECO})/HTT_{RECO}", 100, -1.0, 3.0);
TH1F * hdET_MHT = new TH1F("hdET_MHT", ";(MHT_{L1} - MHT_{RECO})/MHT_{RECO}", 100, -1.0, 2.0);
// TH1F * hdPhi_MET = new TH1F("hdPhi_MET", ";#phi_{RECO}^{MET} - #phi_{L1}^{MET}", 50, -M_PI, M_PI);
// TH1F * hdPhi_MHT = new TH1F("hdPhi_MHT", ";#phi_{RECO}^{MHT} - #phi_{L1}^{MHT}", 50, -M_PI, M_PI);
TH2F * hETS_ETT = new TH2F("hETS_ETT", "", 200, 0, 2000, 200, 0, 800);
hETS_ETT->GetXaxis()->SetTitle("RECO ETT (GeV)");
hETS_ETT->GetYaxis()->SetTitle("L1 upgrade ETT (GeV)");
TH2F * hETS_MET = new TH2F("hETS_MET", "", 200, 0, 300, 200, 0, 300);
hETS_MET->GetXaxis()->SetTitle("RECO MET (GeV)");
hETS_MET->GetYaxis()->SetTitle("L1 upgrade MET (GeV)");
TH2F * hETS_HTT = new TH2F("hETS_HTT", "", 200, 0, 1200, 200, 0, 1200);
hETS_HTT->GetXaxis()->SetTitle("RECO HTT (GeV)");
hETS_HTT->GetYaxis()->SetTitle("L1 upgrade HTT (GeV)");
TH2F * hETS_MHT = new TH2F("hETS_MHT", "", 200, 0, 300, 200, 0, 300);
hETS_MHT->GetXaxis()->SetTitle("RECO MHT (GeV)");
hETS_MHT->GetYaxis()->SetTitle("L1 upgrade MHT (GeV)");
//distributions and resolutions for *my* htt
TH1F * h_myl1_HTT_l1 = new TH1F("h_myl1_HTT_l1", ";*my* HTT_{L1} (GeV)", 40, 0, 400);
TH1F * h_myl1_LeadingL1jetPtForL1HTTis0 = new TH1F("h_myl1_LeadingL1jetPtForL1HTTis0", ";LeadingL1jetPt (GeV)", 40, 0, 100);
TH1F * h_myl1_LeadingL1jetPtForL1HTTnot0 = new TH1F("h_myl1_LeadingL1jetPtForL1HTTnot0", ";LeadingL1jetPt (GeV)", 40, 0, 100);
TH2F * h_myl1_LeadingL1jetEtaPhiForL1HTTis0 = new TH2F("h_myl1_LeadingL1jetEtaPhiForL1HTTis0", ";eta;phi", 50, -5, 5, 50, -M_PI, M_PI);
TH2F * h_myl1_LeadingL1jetEtaPhiForL1HTTnot0 = new TH2F("h_myl1_LeadingL1jetEtaPhiForL1HTTnot0", ";eta;phi", 50, -5, 5, 50, -M_PI, M_PI);
TH1F * h_myl1_dET_HTT = new TH1F("h_myl1_dET_HTT", ";(*my*HTT_{L1} - HTT_{RECO})/HTT_{RECO}", 100, -1.0, 3.0);
TH2F * h_myl1_ETS_HTT = new TH2F("h_myl1_ETS_HTT", "", 200, 0, 1200, 200, 0, 1200);
h_myl1_ETS_HTT->GetXaxis()->SetTitle("RECO HTT (GeV)");
h_myl1_ETS_HTT->GetYaxis()->SetTitle("*my*L1 upgrade HTT (GeV)");
TH2F * h_myl1_origl1_ETS_HTT = new TH2F("h_myl1_origl1_ETS_HTT", "", 200, 0, 1200, 200, 0, 1200);
h_myl1_origl1_ETS_HTT->GetXaxis()->SetTitle("*my*L1 upgrade HTT (GeV)");
h_myl1_origl1_ETS_HTT->GetYaxis()->SetTitle("L1 upgrade HTT (GeV)");
//turnOns//
TH1F * hden_ETT = new TH1F("hden_ETT", "", 40, 0, 3000);
TH1F * hden_MET = new TH1F("hden_MET", "", 40, 0, 500);
TH1F * hden_HTT = new TH1F("hden_HTT", "", 40, 0, 300);
TH1F * hden_MHT = new TH1F("hden_MHT", "", 40, 0, 500);
TH1F * hnum_ETT_100 = new TH1F("hnum_ETT_100", "", 40, 0, 3000);
TH1F * hnum_ETT_125 = new TH1F("hnum_ETT_125", "", 40, 0, 3000);
TH1F * hnum_ETT_150 = new TH1F("hnum_ETT_150", "", 40, 0, 3000);
TH1F * hnum_ETT_175 = new TH1F("hnum_ETT_175", "", 40, 0, 3000);
TH1F * hnum_ETT_200 = new TH1F("hnum_ETT_200", "", 40, 0, 3000);
TH1F * hnum_ETT_250 = new TH1F("hnum_ETT_250", "", 40, 0, 3000);
TH1F * hnum_MET_40 = new TH1F("hnum_MET_40", "", 40, 0, 500);
TH1F * hnum_MET_60 = new TH1F("hnum_MET_60", "", 40, 0, 500);
TH1F * hnum_MET_80 = new TH1F("hnum_MET_80", "", 40, 0, 500);
TH1F * hnum_MET_100 = new TH1F("hnum_MET_100", "", 40, 0, 500);
TH1F * hnum_HTT_100 = new TH1F("hnum_HTT_100", "", 40, 0, 300);
TH1F * hnum_HTT_125 = new TH1F("hnum_HTT_125", "", 40, 0, 300);
TH1F * hnum_HTT_150 = new TH1F("hnum_HTT_150", "", 40, 0, 300);
TH1F * hnum_HTT_175 = new TH1F("hnum_HTT_175", "", 40, 0, 300);
TH1F * hnum_HTT_200 = new TH1F("hnum_HTT_200", "", 40, 0, 300);
TH1F * hnum_HTT_250 = new TH1F("hnum_HTT_250", "", 40, 0, 300);
TH1F * hnum_MHT_40 = new TH1F("hnum_MHT_40", "", 40, 0, 500);
TH1F * hnum_MHT_60 = new TH1F("hnum_MHT_60", "", 40, 0, 500);
TH1F * hnum_MHT_80 = new TH1F("hnum_MHT_80", "", 40, 0, 500);
TH1F * hnum_MHT_100 = new TH1F("hnum_MHT_100", "", 40, 0, 500);
TH1F * hEff_ETT_100 = new TH1F("hEff_ETT_100", ";reco ETT (GeV);efficiency", 40, 0, 3000);
TH1F * hEff_ETT_125 = new TH1F("hEff_ETT_125", ";reco ETT (GeV);efficiency", 40, 0, 3000);
TH1F * hEff_ETT_150 = new TH1F("hEff_ETT_150", ";reco ETT (GeV);efficiency", 40, 0, 3000);
TH1F * hEff_ETT_175 = new TH1F("hEff_ETT_175", ";reco ETT (GeV);efficiency", 40, 0, 3000);
TH1F * hEff_ETT_200 = new TH1F("hEff_ETT_200", ";reco ETT (GeV);efficiency", 40, 0, 3000);
TH1F * hEff_ETT_250 = new TH1F("hEff_ETT_250", ";reco ETT (GeV);efficiency", 40, 0, 3000);
TH1F * hEff_MET_40 = new TH1F("hEff_MET_40", ";reco MET (GeV);efficiency", 40, 0, 500);
TH1F * hEff_MET_60 = new TH1F("hEff_MET_60", ";reco MET (GeV);efficiency", 40, 0, 500);
TH1F * hEff_MET_80 = new TH1F("hEff_MET_80", ";reco MET (GeV);efficiency", 40, 0, 500);
TH1F * hEff_MET_100 = new TH1F("hEff_MET_100", ";reco MET (GeV);efficiency", 40, 0, 500);
TH1F * hEff_HTT_100 = new TH1F("hEff_HTT_100", ";reco HTT (GeV);efficiency", 40, 0, 300);
TH1F * hEff_HTT_125 = new TH1F("hEff_HTT_125", ";reco HTT (GeV);efficiency", 40, 0, 300);
TH1F * hEff_HTT_150 = new TH1F("hEff_HTT_150", ";reco HTT (GeV);efficiency", 40, 0, 300);
TH1F * hEff_HTT_175 = new TH1F("hEff_HTT_175", ";reco HTT (GeV);efficiency", 40, 0, 300);
TH1F * hEff_HTT_200 = new TH1F("hEff_HTT_200", ";reco HTT (GeV);efficiency", 40, 0, 300);
TH1F * hEff_HTT_250 = new TH1F("hEff_HTT_250", ";reco HTT (GeV);efficiency", 40, 0, 300);
TH1F * hEff_MHT_40 = new TH1F("hEff_MHT_40", ";reco MHT (GeV);efficiency", 40, 0, 500);
TH1F * hEff_MHT_60 = new TH1F("hEff_MHT_60", ";reco MHT (GeV);efficiency", 40, 0, 500);
TH1F * hEff_MHT_80 = new TH1F("hEff_MHT_80", ";reco MHT (GeV);efficiency", 40, 0, 500);
TH1F * hEff_MHT_100 = new TH1F("hEff_MHT_100", ";reco MHT (GeV);efficiency", 40, 0, 500);
///////////////////////////////
///////////////////////////////
//loop through all the events//
///////////////////////////////
///////////////////////////////
for (Int_t i=0; i<neventRECO; i++){
//load the Tree info for the event
int nb = recoTree->GetEntry(i);
if (nb==0){
cout << "did not load JetRecoTree for entry " << i << endl;
return;}
nb = upgradeTree->GetEntry(i);
if (nb==0) {
cout << "did not load L1UpgradeTree for entry " << i << endl;
return;}
nb = muonTree->GetEntry(i);
if (nb==0) {
cout << "did not load Muon2RecoTree for entry " << i << endl;
return;}
nb = metFilterTree->GetEntry(i);
if (nb==0) {
cout << "did not load MetFilterRecoTree for entry " << i << endl;
return;}
////////////////////////
//ENERGY_SUMS_ANALYSIS//
////////////////////////
///create the objects///
l1jet.et = upgrade_->jetEt;
l1jet.eta = getEtaVec(upgrade_->jetIEta);
l1jet.phi = upgrade_->jetPhi;
l1jet.n = upgrade_->nJets;
l1jet.bx = upgrade_->jetBx;
//first element is not always leadingJet...think that is fixed
//find the leadingJet |eta|<3 index
float l1ptMAX = -0.0001;
int l1ptMAXindex = 9999;
for (UInt_t kk=0; kk<l1jet.n; kk++){
if(l1jet.et[kk]>l1ptMAX && abs(l1jet.eta[kk])<3.00){
l1ptMAX = l1jet.et[kk];
l1ptMAXindex = kk;
}
}
recojet.et = recoJet_->et;
recojet.eta = recoJet_->eta;
//recojet.phi = recoJet_->phi;
recojet.n = recoJet_->nJets;
recojet.nhef = recoJet_->nhef;
recojet.pef = recoJet_->pef;
recojet.mef = recoJet_->mef;
recojet.chef = recoJet_->chef;
recojet.eef = recoJet_->eef;
recojet.chMult = recoJet_->chMult;
recojet.nhMult = recoJet_->nhMult;
recojet.phMult = recoJet_->phMult;
recojet.elMult = recoJet_->elMult;
recojet.muMult = recoJet_->muMult;
muon.et = recoMuon_->et;
muon.phi = recoMuon_->phi;
muon.n = recoMuon_->nMuons;
muon.looseID = recoMuon_->isLooseMuon;
for (UInt_t index=0; index<4; index++){
//this could seg fault! (weird data structuring)
if (upgrade_->sumType[index]==0){//~index==0
l1Sums.ett = upgrade_->sumEt[index];
l1Sums.ettBx = upgrade_->sumBx[index];
}
if (upgrade_->sumType[index]==2){//~index==1
l1Sums.met = upgrade_->sumEt[index];
l1Sums.metBx = upgrade_->sumBx[index];
l1Sums.metPhi = upgrade_->sumPhi[index];
}
if (upgrade_->sumType[index]==1){//~index==2
l1Sums.htt = upgrade_->sumEt[index];
l1Sums.httBx = upgrade_->sumBx[index];
}
if (upgrade_->sumType[index]==3){//~index==3
l1Sums.mht = upgrade_->sumEt[index];
l1Sums.mhtBx = upgrade_->sumBx[index];
l1Sums.mhtPhi = upgrade_->sumPhi[index];
}
}
//create my own l1 sums quantities using l1 jets (NB: it only includes central l1 jets)
myL1sums.htt = 0;
for (Int_t k=0; k<l1jet.n; k++){
if(l1jet.et[k]>30 && abs(l1jet.eta[k])<3.00 && l1jet.bx[k]==0){myL1sums.htt = myL1sums.htt + l1jet.et[k];}
}
//WITH NO MUON CLEANING
// recoSums.ett = recoMet_->sumEt;
// recoSums.met = recoMet_->met;
// recoSums.metPhi = recoMet_->metPhi;
recoSums.htt = recoMet_->Ht;
recoSums.mht = recoMet_->mHt;
recoSums.mhtPhi = recoMet_->mHtPhi;
//END OF WITHOUT MUON CLEANING SECTION
//WITH MUON CLEANING
// recoSums.htt = recoMet_->Ht;
recoSums.ett = recoMet_->sumEt;
// vector<float> recoMhtVec;
// recoMhtVec.push_back(recoMet_->mHt);
// recoMhtVec.push_back(recoMet_->mHtPhi);
vector<float> recoMetVec;
recoMetVec.push_back(recoMet_->met);
recoMetVec.push_back(recoMet_->metPhi);
for(UInt_t k=0; k<muon.n; k++){
if(muon.looseID[k]){
// recoSums.htt = recoSums.htt - muon.et[k];
recoSums.ett = recoSums.ett - muon.et[k];
// recoMhtVec = addTwoVectors(recoMhtVec[0], recoMhtVec[1], muon.et[k], muon.phi[k]);
recoMetVec = addTwoVectors(recoMetVec[0], recoMetVec[1], muon.et[k], muon.phi[k]);
}
}
// if(recoSums.htt<0){recoSums.htt=0;}
if(recoSums.ett<0){recoSums.ett=0;}
// recoSums.mht = recoMhtVec[0];
// recoSums.mhtPhi = recoMhtVec[1];
recoSums.met = recoMetVec[0];
recoSums.metPhi = recoMetVec[1];
//END OF WITH MUON CLEANING SECTION
//////////////////////////////////////////////////////////
//check whether all leading and above <testRecoJetEnergy> GeV
//recojets are clean before making plots for this event
//(if eventPass becomes zero do not make plots)
bool eventPass=1;
for (UInt_t j=0; j<recojet.n; j++){
if( (j==0 || recojet.et[j]>testRecoJetEnergy) && abs(recojet.eta[j])<=3.0){
//Tight jet ID for central jets (note not the tightLepVeto)
if (
(recojet.nhef[j]<0.90
&& recojet.pef[j]<0.90
&& (recojet.chMult[j] + recojet.nhMult[j] + recojet.phMult[j] + recojet.elMult[j] + recojet.muMult[j])>1)
&&
(abs(recojet.eta[j])>2.4 ||
(abs(recojet.eta[j])<=2.4
&& recojet.chef[j]>0
&& (recojet.chMult[j] + recojet.elMult[j] + recojet.muMult[j])>0
&& recojet.eef[j]<0.99 ))
){continue;}
else{eventPass = 0; break;}//this is a fail
}
if( (j==0 || recojet.et[j]>testRecoJetEnergy) && abs(recojet.eta[j])>3.0){
//Tight jet ID for forward jets
if (recojet.pef[j]<0.90 && (recojet.nhMult[j]+recojet.phMult[j])>10){continue;}
else{eventPass = 0; break;}//this is a fail
}
}//closes the loop through recojets
///////////////////////////////////
////////////////////////////////////////////////////////////
//check the MET filters are ok before making plots for event
//(if eventPass becomes zero do not make plots)
if(recoMetFilter_->hbheNoiseFilter==0 ||
recoMetFilter_->hbheNoiseIsoFilter==0 ||
recoMetFilter_->cscTightHalo2015Filter==0 ||
recoMetFilter_->ecalDeadCellTPFilter==0 ||
recoMetFilter_->goodVerticesFilter==0 ||
recoMetFilter_->eeBadScFilter==0 ||
recoMetFilter_->chHadTrackResFilter==0 ||
recoMetFilter_->muonBadTrackFilter==0){
eventPass=0;
}
if(eventPass){
///////////////////////
//fill the histograms//
///////////////////////
h_myl1_HTT_l1->Fill(myL1sums.htt);
if(myL1sums.htt<1 && l1jet.n>0){
h_myl1_LeadingL1jetPtForL1HTTis0->Fill(l1jet.et[l1ptMAXindex]);
h_myl1_LeadingL1jetEtaPhiForL1HTTis0->Fill(l1jet.eta[l1ptMAXindex], l1jet.phi[l1ptMAXindex]);
}
if(myL1sums.htt>1 && l1jet.n>0){
h_myl1_LeadingL1jetPtForL1HTTnot0->Fill(l1jet.et[l1ptMAXindex]);
h_myl1_LeadingL1jetEtaPhiForL1HTTnot0->Fill(l1jet.eta[l1ptMAXindex], l1jet.phi[l1ptMAXindex]);
}
h_myl1_dET_HTT->Fill((myL1sums.htt-recoSums.htt)/recoSums.htt);
h_myl1_ETS_HTT->Fill(recoSums.htt,myL1sums.htt);
hMETphi_reco->Fill(recoSums.metPhi);
hMHTphi_reco->Fill(recoSums.mhtPhi);
hETT_reco->Fill(recoSums.ett);
hMET_reco->Fill(recoSums.met);
hHTT_reco->Fill(recoSums.htt);
hMHT_reco->Fill(recoSums.mht);
//require that l1quantities have bx==0
if(l1Sums.ettBx==0){
hETT_l1->Fill(l1Sums.ett);
hdET_ETT->Fill((l1Sums.ett-recoSums.ett)/recoSums.ett);
hETS_ETT->Fill(recoSums.ett,l1Sums.ett);
}
if(l1Sums.metBx==0){
hMET_l1->Fill(l1Sums.met);
hMETphi_l1->Fill(l1Sums.metPhi);
hdET_MET->Fill((l1Sums.met-recoSums.met)/recoSums.met);
hETS_MET->Fill(recoSums.met,l1Sums.met);
//hdPhi_MET->Fill(calc_dPHI(recoSums.metPhi,l1Sums.metPhi));
}
if(l1Sums.httBx==0){
hHTT_l1->Fill(l1Sums.htt);
hHTT_l1_ZOOM->Fill(l1Sums.htt);
hdET_HTT->Fill((l1Sums.htt-recoSums.htt)/recoSums.htt);
hETS_HTT->Fill(recoSums.htt,l1Sums.htt);
if(l1Sums.htt<1 && l1jet.n>0){
h_LeadingL1jetPtForL1HTTis0->Fill(l1jet.et[l1ptMAXindex]);
h_LeadingL1jetEtaPhiForL1HTTis0->Fill(l1jet.eta[l1ptMAXindex], l1jet.phi[l1ptMAXindex]);
}
if(l1Sums.htt>1 && l1jet.n>0){
h_LeadingL1jetPtForL1HTTnot0->Fill(l1jet.et[l1ptMAXindex]);
h_LeadingL1jetEtaPhiForL1HTTnot0->Fill(l1jet.eta[l1ptMAXindex], l1jet.phi[l1ptMAXindex]);
}
h_myl1_origl1_ETS_HTT->Fill(myL1sums.htt,l1Sums.htt);
}
if(l1Sums.mhtBx==0){
hMHT_l1->Fill(l1Sums.mht);
hMHTphi_l1->Fill(l1Sums.mhtPhi);
hdET_MHT->Fill((l1Sums.mht-recoSums.mht)/recoSums.mht);
hETS_MHT->Fill(recoSums.mht,l1Sums.mht);
// hdPhi_MHT->Fill(calc_dPHI(recoSums.mhtPhi,l1Sums.mhtPhi));
}
//trigger turnOns
hden_ETT->Fill(recoSums.ett);
hden_MET->Fill(recoSums.met);
hden_HTT->Fill(recoSums.htt);
hden_MHT->Fill(recoSums.mht);
if(l1Sums.ett>100 && l1Sums.ettBx==0){hnum_ETT_100->Fill(recoSums.ett);}
if(l1Sums.ett>125 && l1Sums.ettBx==0){hnum_ETT_125->Fill(recoSums.ett);}
if(l1Sums.ett>150 && l1Sums.ettBx==0){hnum_ETT_150->Fill(recoSums.ett);}
if(l1Sums.ett>175 && l1Sums.ettBx==0){hnum_ETT_175->Fill(recoSums.ett);}
if(l1Sums.ett>200 && l1Sums.ettBx==0){hnum_ETT_200->Fill(recoSums.ett);}
if(l1Sums.ett>250 && l1Sums.ettBx==0){hnum_ETT_250->Fill(recoSums.ett);}
if(l1Sums.met>40 && l1Sums.metBx==0){hnum_MET_40->Fill(recoSums.met);}
if(l1Sums.met>60 && l1Sums.metBx==0){hnum_MET_60->Fill(recoSums.met);}
if(l1Sums.met>80 && l1Sums.metBx==0){hnum_MET_80->Fill(recoSums.met);}
if(l1Sums.met>100 && l1Sums.metBx==0){hnum_MET_100->Fill(recoSums.met);}
if(l1Sums.htt>100 && l1Sums.httBx==0){hnum_HTT_100->Fill(recoSums.htt);}
if(l1Sums.htt>125 && l1Sums.httBx==0){hnum_HTT_125->Fill(recoSums.htt);}
if(l1Sums.htt>150 && l1Sums.httBx==0){hnum_HTT_150->Fill(recoSums.htt);}
if(l1Sums.htt>175 && l1Sums.httBx==0){hnum_HTT_175->Fill(recoSums.htt);}
if(l1Sums.htt>200 && l1Sums.httBx==0){hnum_HTT_200->Fill(recoSums.htt);}
if(l1Sums.htt>250 && l1Sums.httBx==0){hnum_HTT_250->Fill(recoSums.htt);}
if(l1Sums.mht>40 && l1Sums.mhtBx==0){hnum_MHT_40->Fill(recoSums.mht);}
if(l1Sums.mht>60 && l1Sums.mhtBx==0){hnum_MHT_60->Fill(recoSums.mht);}
if(l1Sums.mht>80 && l1Sums.mhtBx==0){hnum_MHT_80->Fill(recoSums.mht);}
if(l1Sums.mht>100 && l1Sums.mhtBx==0){hnum_MHT_100->Fill(recoSums.mht);}
}//closes 'if' event passes recoJet cuts (eventPass==1)
if (i % 10000 == 0){
cout << i << " out of " << neventRECO << endl;}
///////////////////////////////////
}//closes loop through the events//
///////////////////////////////////
//save the output ROOT file
//write the histograms
TFile g( outputFilename.c_str() , "new");
//distributions
hMETphi_l1->Write();
hMHTphi_l1->Write();
hETT_l1->Write();
hMET_l1->Write();
hHTT_l1->Write();
hHTT_l1_ZOOM->Write();
hMHT_l1->Write();
hMETphi_reco->Write();
hMHTphi_reco->Write();
hETT_reco->Write();
hMET_reco->Write();
hHTT_reco->Write();
hMHT_reco->Write();
h_LeadingL1jetPtForL1HTTis0->Write();
h_LeadingL1jetPtForL1HTTnot0->Write();
h_LeadingL1jetEtaPhiForL1HTTis0->Write();
h_LeadingL1jetEtaPhiForL1HTTnot0->Write();
//resolutions
hdET_ETT->Write();
hdET_MET->Write();
hdET_HTT->Write();
hdET_MHT->Write();
//hdPhi_MET->Write();
//hdPhi_MHT->Write();
hETS_ETT->Write();
hETS_MET->Write();
hETS_HTT->Write();
hETS_MHT->Write();
//*my* l1 distribution and resolutions
h_myl1_HTT_l1->Write();
h_myl1_LeadingL1jetPtForL1HTTis0->Write();
h_myl1_LeadingL1jetPtForL1HTTnot0->Write();
h_myl1_dET_HTT->Write();
h_myl1_ETS_HTT->Write();
h_myl1_origl1_ETS_HTT->Write();
h_myl1_LeadingL1jetEtaPhiForL1HTTis0->Write();
h_myl1_LeadingL1jetEtaPhiForL1HTTnot0->Write();
//turnOns
hEff_ETT_100->Divide(hnum_ETT_100, hden_ETT);
hEff_ETT_125->Divide(hnum_ETT_125, hden_ETT);
hEff_ETT_150->Divide(hnum_ETT_150, hden_ETT);
hEff_ETT_175->Divide(hnum_ETT_175, hden_ETT);
hEff_ETT_200->Divide(hnum_ETT_200, hden_ETT);
hEff_ETT_250->Divide(hnum_ETT_250, hden_ETT);
hEff_ETT_100->Write();
hEff_ETT_125->Write();
hEff_ETT_150->Write();
hEff_ETT_175->Write();
hEff_ETT_200->Write();
hEff_ETT_250->Write();
hnum_ETT_100->Write();
hnum_ETT_125->Write();
hnum_ETT_150->Write();
hnum_ETT_175->Write();
hnum_ETT_200->Write();
hnum_ETT_250->Write();
hden_ETT->Write();
hEff_MET_40->Divide(hnum_MET_40, hden_MET);
hEff_MET_60->Divide(hnum_MET_60, hden_MET);
hEff_MET_80->Divide(hnum_MET_80, hden_MET);
hEff_MET_100->Divide(hnum_MET_100, hden_MET);
hEff_MET_40->Write();
hEff_MET_60->Write();
hEff_MET_80->Write();
hEff_MET_100->Write();
hnum_MET_40->Write();
hnum_MET_60->Write();
hnum_MET_80->Write();
hnum_MET_100->Write();
hden_MET->Write();
hEff_HTT_100->Divide(hnum_HTT_100, hden_HTT);
hEff_HTT_125->Divide(hnum_HTT_125, hden_HTT);
hEff_HTT_150->Divide(hnum_HTT_150, hden_HTT);
hEff_HTT_175->Divide(hnum_HTT_175, hden_HTT);
hEff_HTT_200->Divide(hnum_HTT_200, hden_HTT);
hEff_HTT_250->Divide(hnum_HTT_250, hden_HTT);
hEff_HTT_100->Write();
hEff_HTT_125->Write();
hEff_HTT_150->Write();
hEff_HTT_175->Write();
hEff_HTT_200->Write();
hEff_HTT_250->Write();
hnum_HTT_100->Write();
hnum_HTT_125->Write();
hnum_HTT_150->Write();
hnum_HTT_175->Write();
hnum_HTT_200->Write();
hnum_HTT_250->Write();
hden_HTT->Write();
hEff_MHT_40->Divide(hnum_MHT_40, hden_MHT);
hEff_MHT_60->Divide(hnum_MHT_60, hden_MHT);
hEff_MHT_80->Divide(hnum_MHT_80, hden_MHT);
hEff_MHT_100->Divide(hnum_MHT_100, hden_MHT);
hEff_MHT_40->Write();
hEff_MHT_60->Write();
hEff_MHT_80->Write();
hEff_MHT_100->Write();
hnum_MHT_40->Write();
hnum_MHT_60->Write();
hnum_MHT_80->Write();
hnum_MHT_100->Write();
hden_MHT->Write();
}//closes the 'main' function
#include "TFile.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TLegend.h"
#include "TStyle.h"
#include "TEfficiency.h"
#include <string>
#include <TLatex.h>
#include <TCanvas.h>
#include <iostream>
void plot_L1vRECO(string rootFileName, string histoName, int dimNum, string logOnOff);
void plot_turnOn(string rootFileName, string histoType);
void plot_all_loop(string rootFileName){
plot_L1vRECO(rootFileName, "hMETphi_l1", 1, "linear");
plot_L1vRECO(rootFileName, "hMHTphi_l1", 1, "linear");
plot_L1vRECO(rootFileName, "hMHTphi_l1", 1, "log");
plot_L1vRECO(rootFileName, "hETT_l1", 1, "linear");
plot_L1vRECO(rootFileName, "hMET_l1", 1, "linear");
plot_L1vRECO(rootFileName, "hHTT_l1", 1, "linear");
plot_L1vRECO(rootFileName, "hHTT_l1_ZOOM", 1, "linear");
plot_L1vRECO(rootFileName, "hHTT_l1", 1, "log");
plot_L1vRECO(rootFileName, "hMHT_l1", 1, "linear");
plot_L1vRECO(rootFileName, "hMHT_l1", 1, "log");
plot_L1vRECO(rootFileName, "hMETphi_reco", 1, "linear");
plot_L1vRECO(rootFileName, "hMHTphi_reco", 1, "linear");
plot_L1vRECO(rootFileName, "hMHTphi_reco", 1, "log");
plot_L1vRECO(rootFileName, "hETT_reco", 1, "linear");
plot_L1vRECO(rootFileName, "hMET_reco", 1, "linear");
plot_L1vRECO(rootFileName, "hHTT_reco", 1, "linear");
plot_L1vRECO(rootFileName, "hHTT_reco", 1, "log");
plot_L1vRECO(rootFileName, "hMHT_reco", 1, "linear");
plot_L1vRECO(rootFileName, "hMHT_reco", 1, "log");
plot_L1vRECO(rootFileName, "h_LeadingL1jetPtForL1HTTis0", 1, "linear");
plot_L1vRECO(rootFileName, "h_LeadingL1jetPtForL1HTTnot0", 1, "linear");
plot_L1vRECO(rootFileName, "h_LeadingL1jetEtaPhiForL1HTTis0", 2, "linear");
plot_L1vRECO(rootFileName, "h_LeadingL1jetEtaPhiForL1HTTnot0", 2, "linear");
plot_L1vRECO(rootFileName, "hdET_ETT", 1, "linear");
plot_L1vRECO(rootFileName, "hdET_MET", 1, "linear");
plot_L1vRECO(rootFileName, "hdET_HTT", 1, "linear");
plot_L1vRECO(rootFileName, "hdET_HTT", 1, "log");
plot_L1vRECO(rootFileName, "hdET_MHT", 1, "linear");
plot_L1vRECO(rootFileName, "hdET_MHT", 1, "log");
//plot_L1vRECO(rootFileName, "hdPhi_MET", 1, "linear");
//plot_L1vRECO(rootFileName, "hdPhi_MHT", 1, "linear");
plot_L1vRECO(rootFileName, "hETS_ETT", 2, "linear");
plot_L1vRECO(rootFileName, "hETS_MET", 2, "linear");
plot_L1vRECO(rootFileName, "hETS_HTT", 2, "linear");
plot_L1vRECO(rootFileName, "hETS_MHT", 2, "linear");
plot_L1vRECO(rootFileName, "hETS_ETT", 2, "log");
plot_L1vRECO(rootFileName, "hETS_MET", 2, "log");
plot_L1vRECO(rootFileName, "hETS_HTT", 2, "log");
plot_L1vRECO(rootFileName, "hETS_MHT", 2, "log");
plot_L1vRECO(rootFileName, "h_myl1_HTT_l1", 1, "linear");
plot_L1vRECO(rootFileName, "h_myl1_LeadingL1jetPtForL1HTTis0", 1, "linear");
plot_L1vRECO(rootFileName, "h_myl1_LeadingL1jetPtForL1HTTnot0", 1, "linear");
plot_L1vRECO(rootFileName, "h_myl1_dET_HTT", 1, "linear");
plot_L1vRECO(rootFileName, "h_myl1_ETS_HTT", 2, "linear");
plot_L1vRECO(rootFileName, "h_myl1_ETS_HTT", 2, "log");
plot_L1vRECO(rootFileName, "h_myl1_origl1_ETS_HTT", 2, "linear");
plot_L1vRECO(rootFileName, "h_myl1_origl1_ETS_HTT", 2, "log");
plot_L1vRECO(rootFileName, "h_myl1_LeadingL1jetEtaPhiForL1HTTis0", 2, "linear");
plot_L1vRECO(rootFileName, "h_myl1_LeadingL1jetEtaPhiForL1HTTnot0", 2, "linear");
plot_turnOn(rootFileName, "ETT");
plot_turnOn(rootFileName, "MET");
plot_turnOn(rootFileName, "HTT");
plot_turnOn(rootFileName, "MHT");
return;
}
//nb: the string names provided must be inbetween quotation marks eg "hETS_ETT"
void plot_L1vRECO(string rootFileName, string histoName, int dimNum, string logOnOff){
//select the root file containing the plot
TFile * f = new TFile( rootFileName.c_str() );
if (f==0){
cout << "You have not provided a valid fileName" << endl;
cout << "The correct format is:" << endl;
cout << "rootFileName, histogramName, histogramDimension (1or2), log Or linear (typed exactly)" << endl;
return;}
if (logOnOff!="log" && logOnOff!="linear"){
cout << "You have not provided a valid log/linear setting" << endl;
cout << "The correct format is:" << endl;
cout << "rootFileName, histogramName, histogramDimension (1or2), log Or linear (typed exactly)" << endl;
return;
}
//1d plots
if (dimNum == 1){
TH1F * h = (TH1F*)f->Get( histoName.c_str() );
if (h==0){
cout << "You have not provided a valid histoName" << endl;
cout << "The correct format is:" << endl;
cout << "rootFileName, histogramName, histogramDimension (1or2), log Or linear (typed exactly)" << endl;
return;}
//h->GetXaxis()->SetTitle("");
h->GetXaxis()->SetTitleOffset(1.0);
//h->GetXaxis()->SetTitleSize(0.040);
//h->GetXaxis()->SetRangeUser(0, 1000);
//h->GetYaxis()->SetTitle("Num Entries");
h->GetYaxis()->SetTitleOffset(2.0);
//h->GetYaxis()->SetTitleSize(0.040);
//h->GetYaxis()->SetRangeUser(0, 1000);
TCanvas* c=new TCanvas("c","c",650,600);
c->SetLeftMargin(0.15);
if(logOnOff=="log"){gPad->SetLogy();}
h->SetLineWidth(2);
h->SetLineColor(2);
//h->SetMarkerStyle(21);
//h->SetMarkerSize(0.7);
//h->SetMarkerColor(2);
h->Draw("same");
gStyle->SetOptStat(0);
int nbins = h->GetNbinsX();
double x = h->GetBinLowEdge(nbins/2);
double y = h->GetMaximum();
TLatex *texl = new TLatex(x,1.08*y,"CMS Preliminary, #sqrt{s}=13 TeV");
texl->SetTextSize(0.035);
texl->Draw("same");
string saveName = histoName + "_" + logOnOff + ".pdf";
c->SaveAs( saveName.c_str() );
c->Close();
}
//2d plots
if (dimNum == 2){
TH2F * h = (TH2F*)f->Get( histoName.c_str() );
if (h==0){
cout << "You have not provided a valid histoName" << endl;
cout << "The correct format is:" << endl;
cout << "rootFileName, histogramName, histogramDimension (1or2)" << endl;
return;}
//h->GetXaxis()->SetTitle("");
h->GetXaxis()->SetTitleOffset(1.0);
//h->GetXaxis()->SetTitleSize(0.040);
//h->GetXaxis()->SetRangeUser(0, 1000);
//h->GetYaxis()->SetTitle("Num Entries");
h->GetYaxis()->SetTitleOffset(2.0);
//h->GetYaxis()->SetTitleSize(0.040);
//h->GetYaxis()->SetRangeUser(0, 1000);
TCanvas* c=new TCanvas("c","c",650,600);
c->SetLeftMargin(0.15);
if(logOnOff=="log"){gPad->SetLogz();}
h->Draw("same, cols");
gStyle->SetOptStat(0);
int nbinsX = h->GetNbinsX();
int nbinsY = h->GetNbinsY();
double x = h->GetXaxis()->GetBinCenter(nbinsX/2);
double y = h->GetYaxis()->GetBinUpEdge(nbinsY);
TLatex *texl = new TLatex(x,1.05*y,"CMS Preliminary, #sqrt{s}=13 TeV");
texl->SetTextSize(0.035);
texl->Draw("same");
string saveName = histoName + "_" + logOnOff + ".pdf";
c->SaveAs( saveName.c_str() );
c->Close();
}
//incorrect dimNum entry
if (dimNum != 1 && dimNum !=2){
cout << "You have not put in a plot dimension of 1 or 2" << endl;
cout << "The correct format is:" << endl;
cout << "rootFileName, histogramName, histogramDimension (1or2), log Or linear (typed exactly)" << endl;
return;
}
}//closes the 'plot_L1vsRECO' function
void plot_turnOn(string rootFileName, string histoType){
if(histoType!="ETT" && histoType!="MET" && histoType!="HTT" && histoType!="MHT"){
cout << "You have not provided a valid histoType" << endl;
cout << "The correct format is:" << endl;
cout << "rootFileName, histoType (ETT, MET, HTT or MHT)" << endl;
return;
}
TFile * f = new TFile( rootFileName.c_str() );
if(histoType=="ETT"){
TH1F * hT100 = (TH1F*)f->Get("hEff_ETT_100");
TH1F * hT125 = (TH1F*)f->Get("hEff_ETT_125");
TH1F * hT150 = (TH1F*)f->Get("hEff_ETT_150");
TH1F * hT175 = (TH1F*)f->Get("hEff_ETT_175");
TH1F * hT200 = (TH1F*)f->Get("hEff_ETT_200");
TH1F * hnum100 = (TH1F*)f->Get("hnum_ETT_100");
TH1F * hnum125 = (TH1F*)f->Get("hnum_ETT_125");
TH1F * hnum150 = (TH1F*)f->Get("hnum_ETT_150");
TH1F * hnum175 = (TH1F*)f->Get("hnum_ETT_175");
TH1F * hnum200 = (TH1F*)f->Get("hnum_ETT_200");
TH1F * hdenALL = (TH1F*)f->Get("hden_ETT");
//-------------------------------------------------------------------------------
//The 100, 125, 150, 175, 200 setup----------------------------------------------
//-------------------------------------------------------------------------------
//hT100_central->SetTitle("");
hT100->GetXaxis()->SetTitle("reco ETT (GeV)");
hT100->GetYaxis()->SetTitle("efficiency");
TEfficiency * hT100e = new TEfficiency(*hnum100,*hdenALL);
TEfficiency * hT125e = new TEfficiency(*hnum125,*hdenALL);
TEfficiency * hT150e = new TEfficiency(*hnum150,*hdenALL);
TEfficiency * hT175e = new TEfficiency(*hnum175,*hdenALL);
TEfficiency * hT200e = new TEfficiency(*hnum200,*hdenALL);
hT100->SetLineColor(1); //black
hT125->SetLineColor(2); //red
hT150->SetLineColor(4); //blue
hT175->SetLineColor(8);
hT200->SetLineColor(6);
hT100->SetLineWidth(2);
hT125->SetLineWidth(2);
hT150->SetLineWidth(2);
hT175->SetLineWidth(2);
hT200->SetLineWidth(2);
hT100e->SetLineColor(1); //black
hT125e->SetLineColor(2); //red
hT150e->SetLineColor(4); //blue
hT175e->SetLineColor(8); //darkgreen
hT200e->SetLineColor(6); //pink
hT100e->SetLineWidth(2);
hT125e->SetLineWidth(2);
hT150e->SetLineWidth(2);
hT175e->SetLineWidth(2);
hT200e->SetLineWidth(2);
hT100e->SetMarkerColor(1); //black
hT125e->SetMarkerColor(2); //red
hT150e->SetMarkerColor(4); //blue
hT175e->SetMarkerColor(8);
hT200e->SetMarkerColor(6);
hT100e->SetMarkerStyle(20);
hT125e->SetMarkerStyle(20);
hT150e->SetMarkerStyle(20);
hT175e->SetMarkerStyle(20);
hT200e->SetMarkerStyle(20);
hT100e->SetMarkerSize(1);
hT125e->SetMarkerSize(1);
hT150e->SetMarkerSize(1);
hT175e->SetMarkerSize(1);
hT200e->SetMarkerSize(1);
TCanvas* c=new TCanvas("c","c",650,600);
c->SetLeftMargin(0.15);
c->SetGrid();
//hT100->GetXaxis()->SetRangeUser(0,1000);
hT100->GetYaxis()->SetRangeUser(0,1);
hT100->GetYaxis()->SetTitleOffset(1.5);
hT100->GetXaxis()->SetTitleOffset(1.0);
hT100->Draw("C, same");
hT125->Draw("C, same");
hT150->Draw("C, same");
hT175->Draw("C, same");
hT200->Draw("C, same");
hT100e->Draw("same");
hT125e->Draw("same");
hT150e->Draw("same");
hT175e->Draw("same");
hT200e->Draw("same");
gStyle->SetOptStat(0);
TLegend * leg = new TLegend(0.7, 0.15, 0.9, 0.48); //(xmin, ymin, xmax, ymax)
leg->SetLineColor(0);
leg->AddEntry(hT100, "L1>100GeV", "L");
leg->AddEntry(hT125, "L1>125GeV", "L");
leg->AddEntry(hT150, "L1>150GeV", "L");
leg->AddEntry(hT175, "L1>175GeV", "L");
leg->AddEntry(hT200, "L1>200GeV", "L");
leg->Draw();
TLatex *texl = new TLatex(0.1,1.05,"CMS Preliminary, #sqrt{s}=13 TeV");
texl->SetTextSize(0.035);
texl->Draw("same");
string saveName = "turnOn_ETT.pdf";
c->SaveAs( saveName.c_str() );
c->Close();
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
}//close 'if' ETT
if(histoType=="HTT"){
TH1F * hT100 = (TH1F*)f->Get("hEff_HTT_100");
TH1F * hT125 = (TH1F*)f->Get("hEff_HTT_125");
TH1F * hT150 = (TH1F*)f->Get("hEff_HTT_150");
TH1F * hT175 = (TH1F*)f->Get("hEff_HTT_175");
TH1F * hT200 = (TH1F*)f->Get("hEff_HTT_200");
TH1F * hnum100 = (TH1F*)f->Get("hnum_HTT_100");
TH1F * hnum125 = (TH1F*)f->Get("hnum_HTT_125");
TH1F * hnum150 = (TH1F*)f->Get("hnum_HTT_150");
TH1F * hnum175 = (TH1F*)f->Get("hnum_HTT_175");
TH1F * hnum200 = (TH1F*)f->Get("hnum_HTT_200");
TH1F * hdenALL = (TH1F*)f->Get("hden_HTT");
//-------------------------------------------------------------------------------
//The 100, 125, 150, 175, 200 setup----------------------------------------------
//-------------------------------------------------------------------------------
//hT100_central->SetTitle("");
hT100->GetXaxis()->SetTitle("reco HTT (GeV)");
hT100->GetYaxis()->SetTitle("efficiency");
TEfficiency * hT100e = new TEfficiency(*hnum100,*hdenALL);
TEfficiency * hT125e = new TEfficiency(*hnum125,*hdenALL);
TEfficiency * hT150e = new TEfficiency(*hnum150,*hdenALL);
TEfficiency * hT175e = new TEfficiency(*hnum175,*hdenALL);
TEfficiency * hT200e = new TEfficiency(*hnum200,*hdenALL);
hT100->SetLineColor(1); //black
hT125->SetLineColor(2); //red
hT150->SetLineColor(4); //blue
hT175->SetLineColor(8);
hT200->SetLineColor(6);
hT100->SetLineWidth(2);
hT125->SetLineWidth(2);
hT150->SetLineWidth(2);
hT175->SetLineWidth(2);
hT200->SetLineWidth(2);
hT100e->SetLineColor(1); //black
hT125e->SetLineColor(2); //red
hT150e->SetLineColor(4); //blue
hT175e->SetLineColor(8); //darkgreen
hT200e->SetLineColor(6); //pink
hT100e->SetLineWidth(2);
hT125e->SetLineWidth(2);
hT150e->SetLineWidth(2);
hT175e->SetLineWidth(2);
hT200e->SetLineWidth(2);
hT100e->SetMarkerColor(1); //black
hT125e->SetMarkerColor(2); //red
hT150e->SetMarkerColor(4); //blue
hT175e->SetMarkerColor(8);
hT200e->SetMarkerColor(6);
hT100e->SetMarkerStyle(20);
hT125e->SetMarkerStyle(20);
hT150e->SetMarkerStyle(20);
hT175e->SetMarkerStyle(20);
hT200e->SetMarkerStyle(20);
hT100e->SetMarkerSize(1);
hT125e->SetMarkerSize(1);
hT150e->SetMarkerSize(1);
hT175e->SetMarkerSize(1);
hT200e->SetMarkerSize(1);
TCanvas* c=new TCanvas("c","c",650,600);
c->SetLeftMargin(0.15);
c->SetGrid();
//hT100->GetXaxis()->SetRangeUser(0,1000);
hT100->GetYaxis()->SetRangeUser(0,1);
hT100->GetYaxis()->SetTitleOffset(1.5);
hT100->GetXaxis()->SetTitleOffset(1.0);
hT100->Draw("C, same");
hT125->Draw("C, same");
hT150->Draw("C, same");
hT175->Draw("C, same");
hT200->Draw("C, same");
hT100e->Draw("same");
hT125e->Draw("same");
hT150e->Draw("same");
hT175e->Draw("same");
hT200e->Draw("same");
gStyle->SetOptStat(0);
TLegend * leg = new TLegend(0.7, 0.15, 0.9, 0.48); //(xmin, ymin, xmax, ymax)
leg->SetLineColor(0);
leg->AddEntry(hT100, "L1>100GeV", "L");
leg->AddEntry(hT125, "L1>125GeV", "L");
leg->AddEntry(hT150, "L1>150GeV", "L");
leg->AddEntry(hT175, "L1>175GeV", "L");
leg->AddEntry(hT200, "L1>200GeV", "L");
leg->Draw();
TLatex *texl = new TLatex(0.1,1.05,"CMS Preliminary, #sqrt{s}=13 TeV");
texl->SetTextSize(0.035);
texl->Draw("same");
string saveName = "turnOn_HTT.pdf";
c->SaveAs( saveName.c_str() );
c->Close();
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
}//close 'if' HTT
if(histoType=="MHT"){
TH1F * hT40 = (TH1F*)f->Get("hEff_MHT_40");
TH1F * hT60 = (TH1F*)f->Get("hEff_MHT_60");
TH1F * hT80 = (TH1F*)f->Get("hEff_MHT_80");
TH1F * hT100 = (TH1F*)f->Get("hEff_MHT_100");
TH1F * hnum40 = (TH1F*)f->Get("hnum_MHT_40");
TH1F * hnum60 = (TH1F*)f->Get("hnum_MHT_60");
TH1F * hnum80 = (TH1F*)f->Get("hnum_MHT_80");
TH1F * hnum100 = (TH1F*)f->Get("hnum_MHT_100");
TH1F * hdenALL = (TH1F*)f->Get("hden_MHT");
//-------------------------------------------------------------------------------
//The 40, 60, 80, 100 setup------------------------------------------------------
//-------------------------------------------------------------------------------
//hT40_central->SetTitle("");
hT40->GetXaxis()->SetTitle("reco MHT (GeV)");
hT40->GetYaxis()->SetTitle("efficiency");
TEfficiency * hT40e = new TEfficiency(*hnum40,*hdenALL);
TEfficiency * hT60e = new TEfficiency(*hnum60,*hdenALL);
TEfficiency * hT80e = new TEfficiency(*hnum80,*hdenALL);
TEfficiency * hT100e = new TEfficiency(*hnum100,*hdenALL);
hT40->SetLineColor(1); //black
hT60->SetLineColor(2); //red
hT80->SetLineColor(4); //blue
hT100->SetLineColor(8);
hT40->SetLineWidth(2);
hT60->SetLineWidth(2);
hT80->SetLineWidth(2);
hT100->SetLineWidth(2);
hT40e->SetLineColor(1); //black
hT60e->SetLineColor(2); //red
hT80e->SetLineColor(4); //blue
hT100e->SetLineColor(8); //darkgreen
hT40e->SetLineWidth(2);
hT60e->SetLineWidth(2);
hT80e->SetLineWidth(2);
hT100e->SetLineWidth(2);
hT40e->SetMarkerColor(1); //black
hT60e->SetMarkerColor(2); //red
hT80e->SetMarkerColor(4); //blue
hT100e->SetMarkerColor(8);
hT40e->SetMarkerStyle(20);
hT60e->SetMarkerStyle(20);
hT80e->SetMarkerStyle(20);
hT100e->SetMarkerStyle(20);
hT40e->SetMarkerSize(1);
hT60e->SetMarkerSize(1);
hT80e->SetMarkerSize(1);
hT100e->SetMarkerSize(1);
TCanvas* c=new TCanvas("c","c",650,600);
c->SetLeftMargin(0.15);
c->SetGrid();
//hT40->GetXaxis()->SetRangeUser(0,400);
hT40->GetYaxis()->SetRangeUser(0,1);
hT40->GetYaxis()->SetTitleOffset(1.5);
hT40->GetXaxis()->SetTitleOffset(1.0);
hT40->Draw("C, same");
hT60->Draw("C, same");
hT80->Draw("C, same");
hT100->Draw("C, same");
//hT200->Draw("C, same");
hT40e->Draw("same");
hT60e->Draw("same");
hT80e->Draw("same");
hT100e->Draw("same");
//hT200e->Draw("same");
gStyle->SetOptStat(0);
TLegend * leg = new TLegend(0.7, 0.15, 0.9, 0.48); //(xmin, ymin, xmax, ymax)
leg->SetLineColor(0);
leg->AddEntry(hT40, "L1>40GeV", "L");
leg->AddEntry(hT60, "L1>60GeV", "L");
leg->AddEntry(hT80, "L1>80GeV", "L");
leg->AddEntry(hT100, "L1>100GeV", "L");
//leg->AddEntry(hT200, "L1>200GeV", "L");
leg->Draw();
TLatex *texl = new TLatex(0.1,1.05,"CMS Preliminary, #sqrt{s}=13 TeV");
texl->SetTextSize(0.035);
texl->Draw("same");
string saveName = "turnOn_MHT.pdf";
c->SaveAs( saveName.c_str() );
c->Close();
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
}//close 'if' MHT
if(histoType=="MET"){
TH1F * hT40 = (TH1F*)f->Get("hEff_MET_40");
TH1F * hT60 = (TH1F*)f->Get("hEff_MET_60");
TH1F * hT80 = (TH1F*)f->Get("hEff_MET_80");
TH1F * hT100 = (TH1F*)f->Get("hEff_MET_100");
TH1F * hnum40 = (TH1F*)f->Get("hnum_MET_40");
TH1F * hnum60 = (TH1F*)f->Get("hnum_MET_60");
TH1F * hnum80 = (TH1F*)f->Get("hnum_MET_80");
TH1F * hnum100 = (TH1F*)f->Get("hnum_MET_100");
TH1F * hdenALL = (TH1F*)f->Get("hden_MET");
//-------------------------------------------------------------------------------
//The 40, 60, 80, 100 setup------------------------------------------------------
//-------------------------------------------------------------------------------
//hT40_central->SetTitle("");
hT40->GetXaxis()->SetTitle("reco MET (GeV)");
hT40->GetYaxis()->SetTitle("efficiency");
TEfficiency * hT40e = new TEfficiency(*hnum40,*hdenALL);
TEfficiency * hT60e = new TEfficiency(*hnum60,*hdenALL);
TEfficiency * hT80e = new TEfficiency(*hnum80,*hdenALL);
TEfficiency * hT100e = new TEfficiency(*hnum100,*hdenALL);
hT40->SetLineColor(1); //black
hT60->SetLineColor(2); //red
hT80->SetLineColor(4); //blue
hT100->SetLineColor(8);
hT40->SetLineWidth(2);
hT60->SetLineWidth(2);
hT80->SetLineWidth(2);
hT100->SetLineWidth(2);
hT40e->SetLineColor(1); //black
hT60e->SetLineColor(2); //red
hT80e->SetLineColor(4); //blue
hT100e->SetLineColor(8); //darkgreen
hT40e->SetLineWidth(2);
hT60e->SetLineWidth(2);
hT80e->SetLineWidth(2);
hT100e->SetLineWidth(2);
hT40e->SetMarkerColor(1); //black
hT60e->SetMarkerColor(2); //red
hT80e->SetMarkerColor(4); //blue
hT100e->SetMarkerColor(8);
hT40e->SetMarkerStyle(20);
hT60e->SetMarkerStyle(20);
hT80e->SetMarkerStyle(20);
hT100e->SetMarkerStyle(20);
hT40e->SetMarkerSize(1);
hT60e->SetMarkerSize(1);
hT80e->SetMarkerSize(1);
hT100e->SetMarkerSize(1);
TCanvas* c=new TCanvas("c","c",650,600);
c->SetLeftMargin(0.15);
c->SetGrid();
//hT40->GetXaxis()->SetRangeUser(0,400);
hT40->GetYaxis()->SetRangeUser(0,1);
hT40->GetYaxis()->SetTitleOffset(1.5);
hT40->GetXaxis()->SetTitleOffset(1.0);
hT40->Draw("C, same");
hT60->Draw("C, same");
hT80->Draw("C, same");
hT100->Draw("C, same");
//hT200->Draw("C, same");
hT40e->Draw("same");
hT60e->Draw("same");
hT80e->Draw("same");
hT100e->Draw("same");
//hT200e->Draw("same");
gStyle->SetOptStat(0);
TLegend * leg = new TLegend(0.7, 0.15, 0.9, 0.48); //(xmin, ymin, xmax, ymax)
leg->SetLineColor(0);
leg->AddEntry(hT40, "L1>40GeV", "L");
leg->AddEntry(hT60, "L1>60GeV", "L");
leg->AddEntry(hT80, "L1>80GeV", "L");
leg->AddEntry(hT100, "L1>100GeV", "L");
//leg->AddEntry(hT200, "L1>200GeV", "L");
leg->Draw();
TLatex *texl = new TLatex(0.1,1.05,"CMS Preliminary, #sqrt{s}=13 TeV");
texl->SetTextSize(0.035);
texl->Draw("same");
string saveName = "turnOn_MET.pdf";
c->SaveAs( saveName.c_str() );
c->Close();
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
}//close 'if' MET
}//closes the 'plot_turnOn' function
{
gSystem->Load("libFWCoreFWLite.so");
FWLiteEnabler::enable();
std::string cmssw_base=gSystem->Getenv("CMSSW_BASE");
std::string tmp = std::string(" -I")+cmssw_base+std::string("/src/L1Trigger/L1TNtuples/interface");
std::cout << tmp << std::endl;
gSystem->AddIncludePath(tmp.c_str());
tmp = std::string(".include ")+cmssw_base+std::string("/src/L1Trigger/L1TNtuples/interface");
std::cout << tmp << std::endl;
gROOT->ProcessLine(tmp.c_str());
/////////////////////
//job specific part//
/////////////////////
gROOT->ProcessLine(".L esums_stage2_reco_comparison.cxx+");
gROOT->ProcessLine("esums_stage2_reco_comparison()");
// gROOT->ProcessLine(".L stage2_turnOnCreator.cxx+");
// gROOT->ProcessLine("stage2_turnOnCreator()");
//gROOT->ProcessLine(".L bitCheck.cxx+");
//gROOT->ProcessLine("bitCheck()");
// gROOT->ProcessLine(".L eventInfo.cxx+");
// gROOT->ProcessLine("eventInfo()");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment