Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "NtupleTools3.h"
- #include <fstream>
- #include <iostream>
- #include <vector>
- #include <cmath>
- #include <TLorentzVector.h>
- #include <TCanvas.h>
- #include <TH1D.h>
- #include <TFile.h>
- #include <TLatex.h>
- #include <TMath.h>
- using namespace std;
- void readerSummerStd(TString list, TString outname,bool useW=true){
- TObjArray* arr = list.Tokenize(" ");
- int size=arr->GetEntries();
- if(size%2!=0) {
- cout<<"unbalance file/weight list: "<<list<<endl;
- exit(0);
- }
- vector<TString> files;
- vector<double> weights;
- for(int i=0;i<size;i+=2){
- files.push_back( arr->At(i)->GetName() );
- weights.push_back( atof( arr->At(i+1)->GetName() ) );
- }
- // here is the place for histograms --- learn how to determine ranges >> Learned
- TH1D * hNel = new TH1D("hNel","Number of electrons",5,0.5,5.5);
- TH1D * hNel2 = new TH1D("hNel2","Number of electrons",5,0.5,5.5);
- TH1D * hNel3 = new TH1D("hNel3","Number of electrons",5,0.5,5.5);
- TH1D * hNel4 = new TH1D("CuthNel","Number of electrons",5,0.5,5.5);
- TH1D * hNmu = new TH1D("hNmu","Number of muons",5,0.5,5.5);
- TH1D * hNmu2 = new TH1D("hNmu2","Number of muons",5,0.5,5.5);
- TH1D * hNmu3 = new TH1D("hNmu3","Number of muons",5,0.5,5.5);
- TH1D * hNmu4 = new TH1D("CuthNmu","Number of muons",5,0.5,5.5);
- TH1D * hNlep = new TH1D("hNlep","Number of leptons",5,0.5,5.5);
- TH1D * hNlep2 = new TH1D("hNlep2","Number of leptons",5,0.5,5.5);
- TH1D * hNlep3 = new TH1D("hNlep3","Number of leptons",5,0.5,5.5);
- TH1D * hNlep4 = new TH1D("CuthNlep","Number of leptons",5,0.5,5.5);
- TH1D * hNj = new TH1D("hNj","Number of jets",20,0.5,20.5);
- TH1D * hNj2 = new TH1D("hNj2","Number of jets",20,0.5,20.5);
- TH1D * hNj3 = new TH1D("hNj3","Number of jets",20,0.5,20.5);
- TH1D * hNj4 = new TH1D("CuthNj","Number of jets",20,0.5,20.5);
- TH1D * hNbj = new TH1D("hNbj", "Number of bJets", 10, 0.5, 10.5);
- TH1D * hNbj2 = new TH1D("hNbj2", "Number of bJets", 10, 0.5, 10.5);
- TH1D * hNbj3 = new TH1D("hNbj3", "Number of bJets", 10, 0.5, 10.5);
- TH1D * hNbj4 = new TH1D("CuthNbj", "Number of bJets", 10, 0.5, 10.5);
- TH1D * hj1Pt = new TH1D("Jet1Pt", "Jet1 Pt", 50, 0, 1000);
- TH1D * hj1Pt2 = new TH1D("Jet1Pt2", "Jet1 Pt", 50, 0, 1000);
- TH1D * hj1Pt3 = new TH1D("Jet1Pt3", "Jet1 Pt", 50, 0, 1000);
- TH1D * hj1Pt4 = new TH1D("CutJet1Pt", "Jet1 Pt", 50, 0, 1000);
- TH1D * hj2Pt = new TH1D("Jet2Pt", "Jet2 Pt", 50, 0, 1000);
- TH1D * hj2Pt2 = new TH1D("Jet2Pt2", "Jet2 Pt", 50, 0, 1000);
- TH1D * hj2Pt3 = new TH1D("Jet2Pt3", "Jet2 Pt", 50, 0, 1000);
- TH1D * hj2Pt4 = new TH1D("CutJet2Pt", "Jet2 Pt", 50, 0, 1000);
- TH1D * hj3Pt = new TH1D("Jet3Pt", "Jet3 Pt", 50, 0, 1000);
- TH1D * hj3Pt2 = new TH1D("Jet3Pt2", "Jet3 Pt", 50, 0, 1000);
- TH1D * hj3Pt3 = new TH1D("Jet3Pt3", "Jet3 Pt", 50, 0, 1000);
- TH1D * hj3Pt4 = new TH1D("CutJet3Pt", "Jet3 Pt", 50, 0, 1000);
- TH1D * hj4Pt = new TH1D("Jet4Pt", "Jet4 Pt", 50, 0, 1000);
- TH1D * hj4Pt2 = new TH1D("Jet4Pt2", "Jet4 Pt", 50, 0, 1000);
- TH1D * hj4Pt3 = new TH1D("Jet4Pt3", "Jet4 Pt", 50, 0, 1000);
- TH1D * hj4Pt4 = new TH1D("CutJet4Pt", "Jet4 Pt", 50, 0, 1000);
- TH1D * hj1Eta = new TH1D("Jet1Eta", "Jet 1 Eta", 20, -5, 5);
- TH1D * hj1Eta2 = new TH1D("Jet1Eta2", "Jet 1 Eta", 20, -5, 5);
- TH1D * hj1Eta3 = new TH1D("Jet1Eta3", "Jet 1 Eta", 20, -5, 5);
- TH1D * hj1Eta4 = new TH1D("CutJet1Eta", "Jet 1 Eta", 20, -5, 5);
- TH1D * hj2Eta = new TH1D("Jet2Eta", "Jet 2 Eta", 20, -5, 5);
- TH1D * hj2Eta2 = new TH1D("Jet2Eta2", "Jet 2 Eta", 20, -5, 5);
- TH1D * hj2Eta3 = new TH1D("Jet2Eta3", "Jet 2 Eta", 20, -5, 5);
- TH1D * hj2Eta4 = new TH1D("CutJet2Eta", "Jet 2 Eta", 20, -5, 5);
- TH1D * hj3Eta = new TH1D("Jet3Eta", "Jet 3 Eta", 20, -5, 5);
- TH1D * hj3Eta2 = new TH1D("Jet3Eta2", "Jet 3 Eta", 20, -5, 5);
- TH1D * hj3Eta3 = new TH1D("Jet3Eta3", "Jet 3 Eta", 20, -5, 5);
- TH1D * hj3Eta4 = new TH1D("CutJet3Eta", "Jet 3 Eta", 20, -5, 5);
- TH1D * hj4Eta = new TH1D("Jet4Eta", "Jet 4 Eta", 20, -5, 5);
- TH1D * hj4Eta2 = new TH1D("Jet4Eta2", "Jet 4 Eta", 20, -5, 5);
- TH1D * hj4Eta3 = new TH1D("Jet4Eta3", "Jet 4 Eta", 20, -5, 5);
- TH1D * hj4Eta4 = new TH1D("CutJet4Eta", "Jet 4 Eta", 20, -5, 5);
- TH1D * hHT = new TH1D("hHT","HT",100,0,5000);
- TH1D * hHT2 = new TH1D("hHT2","HT",100,0,5000);
- TH1D * hHT3 = new TH1D("hHT3","HT",100,0,5000);
- TH1D * hHT4 = new TH1D("CuthHT", "HT", 100, 0, 5000);
- TH1D * hMET = new TH1D("hMET","MET",40,0,2000);
- TH1D * hMET2 = new TH1D("hMET2","MET",40,0,2000);
- TH1D * hMET3 = new TH1D("hMET3","MET",40,0,2000);
- TH1D * hMET4 = new TH1D("CuthMET","MET",40,0,2000);
- TH1D * hST = new TH1D("hST", "ST", 20, 0, 4000);
- TH1D * hST2 = new TH1D("hST2", "ST", 20, 0, 4000);
- TH1D * hST3 = new TH1D("hST3", "ST", 20, 0, 4000);
- TH1D * hST4 = new TH1D("CuthST", "ST", 20, 0, 4000);
- TH1D * hdPhi1 = new TH1D("hdPhi1", "#Delta#phi", 40,0,4);
- TH1D * hdPhi12 = new TH1D("hdPhi12", "#Delta#phi", 40,0,4);
- TH1D * hdPhi13 = new TH1D("hdPhi13", "#Delta#phi", 40,0,4);
- TH1D * hdPhi14 = new TH1D("CuthdPhi1", "#Delta#phi",40,0,4);
- TH1D * hdPhi2 = new TH1D("hdPhi2", "#Delta#phi ",40,0,4);
- TH1D * hdPhi22 = new TH1D("hdPhi22", "#Delta#phi ",40,0,4);
- TH1D * hdPhi23 = new TH1D("hdPhi23", "#Delta#phi ",40,0,4);
- TH1D * hdPhi24 = new TH1D("CuthdPhi2", "#Delta#phi ",40,0,4);
- TH1D * hMeff = new TH1D("hMeff","Meff",20,0,5000);
- TH1D * hMeff2 = new TH1D("hMeff2","Meff",20,0,5000);
- TH1D * hMeff3 = new TH1D("hMeff3","Meff",20,0,5000);
- TH1D * hMeff4 = new TH1D("CuthMeff","Cut Meff",20,0,5000);
- TH1D * hDiLMassOS = new TH1D("hDiLMassOS","OS DiLepton mass",30,0,450);
- TH1D * hDiLMassOS2 = new TH1D("hDiLMassOS2","OS DiLepton mass",30,0,450);
- TH1D * hDiLMassOS3 = new TH1D("hDiLMassOS3","OS DiLepton mass",30,0,450);
- TH1D * hDiLMassOS4 = new TH1D("CuthDiLMassOS","OS DiLepton mass",30,0,450);
- TH1D * hDiLMassSS = new TH1D("hDiLMassSS","SS DiLepton mass",30,0,450);
- TH1D * hDiLMassSS2 = new TH1D("hDiLMassSS2","SS DiLepton mass",30,0,450);
- TH1D * hDiLMassSS3 = new TH1D("hDiLMassSS3","SS DiLepton mass",30,0,450);
- TH1D * hDiLMassSS4 = new TH1D("CuthDiLMassSS","SS DiLepton mass after cuts",30,0,450);
- TH1D * hMETMeff = new TH1D("hMETMeff", "MET / Meff", 100, 0, 1);
- TH1D * hMETMeff2 = new TH1D("hMETMeff2", "MET / Meff", 100, 0, 1);
- TH1D * hMETMeff3 = new TH1D("hMETMeff3", "MET / Meff", 100, 0, 1);
- TH1D * hMETMeff4 = new TH1D("CuthMETMeff", "MET / Meff", 100, 0, 1);
- TH1D * hLeadLepPt = new TH1D("hLeadLepPt","1 Leading Lepton Pt ",60,0,600);
- TH1D * hLeadLepPt2 = new TH1D("hLeadLepPt2","1 Leading Lepton Pt ",60,0,600);
- TH1D * hLeadLepPt3 = new TH1D("hLeadLepPt3","1 Leading Lepton Pt ",60,0,600);
- TH1D * hLeadLepPt4 = new TH1D("CuthLeadLepPt","1 Leading Lepton Pt",60,0,600);
- TH1D * hLeadLep2Pt = new TH1D("hLeadLep2Pt","2 Leading Lepton Pt",60,0,600);
- TH1D * hLeadLep2Pt2= new TH1D("hLeadLep2Pt2","2 Leading Lepton Pt",60,0,600);
- TH1D * hLeadLep2Pt3= new TH1D("hLeadLep2Pt3","2 Leading Lepton Pt",60,0,600);
- TH1D * hLeadLep2Pt4= new TH1D("CuthLeadLep2Pt","2 Leading Lepton Pt",60,0,600);
- TH1D * hLeadLep3Pt = new TH1D("hLeadLep3Pt","3 Leading Lepton Pt",60,0,600);
- TH1D * hLeadLep3Pt2= new TH1D("hLeadLep3Pt2","3 Leading Lepton Pt",60,0,600);
- TH1D * hLeadLep3Pt3= new TH1D("hLeadLep3Pt3","3 Leading Lepton Pt",60,0,600);
- TH1D * hLeadLep3Pt4= new TH1D("CuthLeadLep3Pt","3 Leading Lepton Pt",60,0,600);
- TH1D * hLeadLepEta = new TH1D("hLeadLepEta","1 Leading Lepton Eta ",20, -5, 5);
- TH1D * hLeadLepEta2 = new TH1D("hLeadLepEta2","1 Leading Lepton Eta ",20, -5, 5);
- TH1D * hLeadLepEta3 = new TH1D("hLeadLepEta3","1 Leading Lepton Eta ",20, -5, 5);
- TH1D * hLeadLepEta4 = new TH1D("CuthLeadLepEta","1 Leading Lepton Eta",20, -5, 5);
- TH1D * hLeadLep2Eta = new TH1D("hLeadLep2Eta","2 Leading Lepton Eta",20, -5, 5);
- TH1D * hLeadLep2Eta2= new TH1D("hLeadLep2Eta2","2 Leading Lepton Eta",20, -5, 5);
- TH1D * hLeadLep2Eta3= new TH1D("hLeadLep2Eta3","2 Leading Lepton Eta",20, -5, 5);
- TH1D * hLeadLep2Eta4= new TH1D("CuthLeadLep2Eta","2 Leading Lepton Eta",20, -5, 5);
- TH1D * hLeadLep3Eta = new TH1D("hLeadLep3Eta","3 Leading Lepton Eta",20, -5, 5);
- TH1D * hLeadLep3Eta2= new TH1D("hLeadLep3Eta2","3 Leading Lepton Eta",20, -5, 5);
- TH1D * hLeadLep3Eta3= new TH1D("hLeadLep3Eta3","3 Leading Lepton Eta",20, -5, 5);
- TH1D * hLeadLep3Eta4= new TH1D("CuthLeadLep3Eta","3 Leading Lepton Eta",20, -5, 5);
- TH1D * hLeadLepIso = new TH1D("hLeadLepIso","1 Leading Lepton Iso ",20, 0, 1);
- TH1D * hLeadLepIso2 = new TH1D("hLeadLepIso2","1 Leading Lepton Iso ",20, 0, 1);
- TH1D * hLeadLepIso3 = new TH1D("hLeadLepIso3","1 Leading Lepton Iso ",20, 0, 1);
- TH1D * hLeadLepIso4 = new TH1D("CuthLeadLepIso","1 Leading Lepton Iso",20, 0, 1);
- TH1D * hLeadLep2Iso = new TH1D("hLeadLep2Iso","2 Leading Lepton Iso",20, 0, 1);
- TH1D * hLeadLep2Iso2= new TH1D("hLeadLep2Iso2","2 Leading Lepton Iso",20, 0, 1);
- TH1D * hLeadLep2Iso3= new TH1D("hLeadLep2Iso3","2 Leading Lepton Iso",20, 0, 1);
- TH1D * hLeadLep2Iso4= new TH1D("CuthLeadLep2Iso","2 Leading Lepton Iso",20, 0, 1);
- TH1D * hLeadLep3Iso = new TH1D("hLeadLep3Iso","3 Leading Lepton Iso",20, 0, 1);
- TH1D * hLeadLep3Iso2= new TH1D("hLeadLep3Iso2","3 Leading Lepton Iso",20, 0, 1);
- TH1D * hLeadLep3Iso3= new TH1D("hLeadLep3Iso3","3 Leading Lepton Iso",20, 0, 1);
- TH1D * hLeadLep3Iso4= new TH1D("CuthLeadLep3Iso","3 Leading Lepton Iso",20, 0, 1);
- TH1D * hHasZ = new TH1D("hHasZ", "ZZ count", 5, -0.5, 4.5);
- TH1D * hHasZ2 = new TH1D("hHasZ2", "ZZ count", 5, -0.5, 4.5);
- TH1D * hHasZ3 = new TH1D("hHasZ3", "ZZ count", 5, -0.5, 4.5);
- TH1D * hHasZ4 = new TH1D("CuthHasZ", "ZZ count", 5, -0.5, 4.5);
- //TH1D * hMT = new TH1D("hMT", "Transverse Mass", 50, 0, 500);
- //TH1D * hMT2 = new TH1D("hMT2", "Transverse Mass", 50, 0, 500);
- //TH1D * hMT3 = new TH1D("hMT3", "Transverse Mass", 50, 0, 500);
- //TH1D * hMT4 = new TH1D("CuthMT", "Transverse Mass", 50, 0, 500);
- EasyChain* tree = new EasyChain("delphTree");
- for(unsigned i=0;i<files.size();i++){
- tree->AddSmartW(files[i],weights[i]);
- cout<<"add: "<<files[i]<<" "<<weights[i]<<endl;
- }
- int Nevents=tree->GetEntries();
- cout<<">>>>>>>>>>>>>>>>>>>>>>> total number of events:\t" << Nevents <<endl;
- // CutFlow variables:
- const int CutNumb = 13;
- const char * CutList[CutNumb] = {"PreSel","Elec", "Jets$\\geq$4", "Bjets$\\geq$3", "MET$>$100", "MET$>$150", "MET$>$200", "MET$>$250", "MET$>$300", "MET$>$350", "MET$>$400", "MET$>$450", "MET$>$500"};
- //const char * CutList[CutNumb] = {"Before","Electrons","SMZ", "Jets>4", "Bjets=0", "Iso<0.20", "Iso<0.15", "Iso<0.10", "dPhi", "MET>1000", "HT>1000\\_MET>250", "HT>1000\\_MET>500", "MET/Meff>0.2"};
- const int CutFlow = 5;
- const char * Cutter[CutFlow] = {"Bef. sel.", "3 Elec. req.", "Jets > 4", "Bjets > 3", "MET>250"};
- //const char * Cutter[CutFlow] = {"Bef. sel.", "3 Elec. req.", "No Z", "4 Jets", "0 Bjets", "Iso > 0.15", "dPhi > 0.3", "MET>500", "HT>1000", "MET/Meff>0.2"};
- // Counter start here:
- double CFCounter[CutNumb];
- int iCFCounter[CutNumb];
- int iCFC[CutFlow];
- double CFC[CutFlow];
- for (int i=0;i < CutNumb ;i++){
- CFCounter[i] = 0;
- iCFCounter[i] = 0;
- }
- for (int i=0;i < CutFlow ;i++){
- CFC[i] = 0;
- iCFC[i] = 0;
- }
- TH1D* CF = new TH1D("CF","Cut Flow",CutFlow,0.5,CutFlow+0.5);
- // Label bins in CF histogram
- for(int cj = 0; cj < CutFlow; cj++)
- CF->GetXaxis()->SetBinLabel(cj+1,Cutter[cj]);
- ////////////////////////////////////////////
- //LOOP STARTS HERE
- ////////////////////////////////////////////
- for(int entry=0; entry < Nevents; entry+=1){
- ////////////////////////////////////////////
- ////////////////////////////////////////////
- progressT();
- double fw = tree->GetEntryW(entry); // the applied with AddSmartW for the current file/dir
- double EvWeight = 1;
- if(useW) EvWeight = tree->Get(EvWeight,"EventWeight");
- EvWeight *= fw * 1000; // 1000 for pb->fb
- // New Vector
- vector<TLorentzVector> Test;// = new vector<TLorentzVector>;
- vector<TLorentzVector> Lepton;// = new vector<TLorentzVector>;
- vector<TLorentzVector> GoodJets;
- vector<TLorentzVector> CleanJets;
- vector<TLorentzVector> GoodElectrons;
- vector<TLorentzVector> GoodMuons;
- vector<TLorentzVector> GoodLepton;
- // From ntupler
- vector<TLorentzVector> &Electrons = tree->Get(&Electrons,"Electrons");
- vector<TLorentzVector> &Muons = tree->Get(&Muons,"Muons");
- vector<TLorentzVector> &Jets = tree->Get(&Jets,"Jets");
- TLorentzVector lv_sum;
- vector<int> &ElCh = tree->Get(&ElCh,"ElectronCh");
- vector<int> &MuCh = tree->Get(&MuCh,"MuonCh");
- vector<int> &JetB = tree->Get(&JetB,"JetB");
- vector<int> LepFlavour;
- vector<int> CleanJetsInd;
- vector<int> GoodJetsInd;
- vector<int> GoodElectronsInd;
- vector<int> GoodMuonsInd;
- vector<double> &ElIso = tree->Get(&ElIso,"ElectronIso");
- vector<double> &MuIso = tree->Get(&MuIso,"MuonIso");
- vector<double> &JetMETdPhi = tree->Get(&JetMETdPhi,"JetMETdPhi");
- vector<double> LeptonIso;
- vector<double> GoodLeptonIso;
- int Nel = tree->Get(Nel, "Nel"); // Get number of electrons from root file
- int Nmu = tree->Get(Nmu, "Nmu"); // Get number of muons fromm root file
- double MET = tree->Get(MET,"DelphMET");
- double HT40 = tree->Get(HT40,"HT40");
- double HT = 0;
- int hasSS = 0; // has di-leptons
- int hasZ = 0; // has Z like pair
- int hasOS = 0;
- // The derived variables are defined below
- int Nlept = Nel + Nmu;
- bool vetoE[100];for(int ie=0;ie<Nel;ie++)vetoE[ie]=0;
- bool vetoM[100];for(int im=0;im<Nmu;im++)vetoM[im]=0;
- // EWKino leptons
- for(int ie=0;ie<Nel;ie++) {
- // Previous line vetoE[ie]|=(Electrons[ie].Pt()<20)||(fabs(Electrons[ie].Eta())>2.4);
- vetoE[ie]|=(Electrons[ie].Pt()<10.)||(fabs(Electrons[ie].Eta())>2.4) || (ElIso[ie] > 0.15); // Edited in accordance with p.3 on article
- if(!vetoE[ie])
- {
- GoodElectrons.push_back(Electrons[ie]);
- GoodElectronsInd.push_back(ie);
- GoodLepton.push_back(Electrons[ie]);
- GoodLeptonIso.push_back(ElIso[ie]);
- }
- }
- for(int im=0;im<Nmu;im++) {
- // Previous line vetoM[im]|=(Muons[im].Pt()<20)||(fabs(Muons[im].Eta())>2.4);
- vetoM[im]|=(Muons[im].Pt()<10.)||(fabs(Muons[im].Eta())>2.4) || (MuIso[im] > 0.15); // Edited in accordance with p.3 on article iso
- if(!vetoM[im])
- {
- GoodMuons.push_back(Muons[im]);
- GoodMuonsInd.push_back(im);
- GoodLepton.push_back(Muons[im]);
- GoodLeptonIso.push_back(MuIso[im]);
- }
- }
- int NGel, NGmu, NGlept;
- NGel = GoodElectrons.size();
- NGmu = GoodMuons.size();
- NGlept = NGel + NGmu;
- vector<bool> veto;
- // Look at the particle handbook for numbers 11, 13
- for(int elid = 0; elid < Nel; elid++)
- {
- veto.push_back(vetoE[elid]);
- Lepton.push_back(Electrons[elid]);
- LepFlavour.push_back(11*ElCh[elid]);
- LeptonIso.push_back(ElIso[elid]);
- }
- for(int muid = 0; muid < Nmu; muid++)
- {
- veto.push_back(vetoM[muid]);
- Lepton.push_back(Muons[muid]);
- LepFlavour.push_back(13*MuCh[muid]);
- LeptonIso.push_back(MuIso[muid]);
- }
- ////////////////////////////////////
- ////////////// VETO ////////////////
- ////////////////////////////////////
- bool abort = false;
- for(int lid = 0; lid < Nlept; lid++)
- {
- if(veto[lid])
- abort = true;
- }
- //cout << " \v NEW SETS" << endl;
- //cout << "Lepton.size(): " << Lepton.size() << "\n" << "GoodLepton.size(): " << GoodLepton.size() << endl;
- if(abort)
- {
- //cout << "ABORTED!!!" << endl;
- continue;
- }
- // 0. CF presel
- CFCounter[0]+= EvWeight;
- iCFCounter[0]++;
- CFC[0]+= EvWeight;
- iCFC[0]++;
- //cout << "Lepton.size(): " << Lepton.size() << "\n" << "GoodLepton.size(): " << GoodLepton.size() << endl;
- ////
- ////
- for(int lid = 0; lid < Nlept; lid++)
- {
- if(veto[lid]) continue;
- for(int sid = 0; (sid < Nlept) && (lid != sid); sid++)
- {
- if(veto[sid]) continue;
- int sumflvr = LepFlavour[lid] + LepFlavour[sid]; // sum of lepton flavour, possible comb: SS: 22,24,26 OS: 0,2
- if(abs(sumflvr) > 0)
- {
- hasSS++;
- double m=lv_sum.M();
- if(m>0)hDiLMassSS->Fill(m,EvWeight);
- }
- if(sumflvr == 0) // may be Z decay
- {
- lv_sum = Lepton[lid] + Lepton[sid];//lv_lep1 + lv_lep2;
- hasOS++; // NEW ADDITION AS OF 24.8.2014
- if(abs(lv_sum.M()-90.) < 15.) hasZ++; // For book keeping purposes
- if(lv_sum.M() > 0) hDiLMassOS->Fill(lv_sum.M(),EvWeight);
- }
- }
- }
- // These need to be defined after preselection in order to fill our histograms before the cuts are applied
- /////////////////////////
- // GOOD JETS SELECTION //
- /////////////////////////
- int Nbjet = 0;
- bool checkCLEAN = true;
- for(int ij = 0; ij < (int)Jets.size(); ij++)
- {
- if(Jets[ij].Pt() > 40. && fabs(Jets[ij].Eta()) < 2.4)
- {
- GoodJets.push_back(Jets[ij]);
- GoodJetsInd.push_back(ij);
- }
- }
- //////////////////////////
- // CLEAN JETS SELECTION //
- //////////////////////////
- for(int gj = 0; gj < (int)GoodJets.size(); gj++)
- {
- checkCLEAN = true;
- for(int l = 0; l < NGlept; l++)
- if(GoodJets[gj].DeltaR(GoodLepton[l]) <= 0.4) checkCLEAN = false;
- if(checkCLEAN)
- {
- CleanJets.push_back(GoodJets[gj]);
- CleanJetsInd.push_back(GoodJetsInd[gj]);
- }
- }
- ////////////////////////
- //////// NEW HT ////////
- ///////////////////////
- for(int cj = 0; cj < (int)CleanJets.size(); cj++)
- HT += CleanJets[cj].Pt();
- //cout << "New HT: " << HT << "\n Old HT: " << HT40 << endl;
- //////////////////
- // BJET TAGGING //
- //////////////////
- for(int i=0; i < (int)CleanJets.size();i++) // Two lines of for loop
- if((JetB[CleanJetsInd[i]] & 2) && (CleanJets[i].Pt() > 50.) && (fabs(CleanJets[i].Eta()) < 1.8)) Nbjet++; // Batool
- //////////////////
- double LepPtAll = 0;
- for(int lid = 0; lid < NGlept; lid++)
- LepPtAll += GoodLepton[lid].Pt();
- double ST = MET + LepPtAll;
- double MET_Phi = tree->Get(MET_Phi,"DelphMET_Phi");
- double Meff = MET + HT;
- //double MT = 0;
- //if(Nlept > 2) MT = sqrt(2*MET*Lepton[2].Pt()*(1-cos(fabs(MET_Phi - Lepton[2].Phi()))));
- //////////////////////////////////////////////////////
- //HISTOGRAMS BEFORE THE CUTS
- //////////////////////////////////////////////////////
- //cout << (MET / Meff) << endl;
- hNel->Fill(NGel,EvWeight);
- hNmu->Fill(NGmu,EvWeight);
- hNlep->Fill(NGlept, EvWeight);
- hHT->Fill(HT, EvWeight);
- hMET->Fill(MET, EvWeight);
- hNj->Fill(CleanJets.size(), EvWeight);
- hMETMeff->Fill((MET / Meff), EvWeight);
- // The following checks are necessary to avoid segmentation faults
- if(CleanJets.size() > 0) hdPhi1->Fill(JetMETdPhi[CleanJetsInd[0]], EvWeight);
- if(CleanJets.size() > 1) hdPhi2->Fill(JetMETdPhi[CleanJetsInd[1]], EvWeight);
- if(CleanJets.size() > 0) hj1Pt->Fill(CleanJets[0].Pt(), EvWeight);
- if(CleanJets.size() > 1) hj2Pt->Fill(CleanJets[1].Pt(), EvWeight);
- if(CleanJets.size() > 2) hj3Pt->Fill(CleanJets[2].Pt(), EvWeight);
- if(CleanJets.size() > 3) hj4Pt->Fill(CleanJets[3].Pt(), EvWeight);
- hNbj->Fill(Nbjet, EvWeight);
- hHasZ->Fill(hasZ);
- if(GoodLepton.size() > 0 && GoodLepton[0].Pt() > 0) hLeadLepPt->Fill(GoodLepton[0].Pt(), EvWeight);
- if(GoodLepton.size() > 1 && GoodLepton[1].Pt() > 0) hLeadLep2Pt->Fill(GoodLepton[1].Pt(), EvWeight);
- if(GoodLepton.size() > 2 && GoodLepton[2].Pt() > 0) hLeadLep3Pt->Fill(GoodLepton[2].Pt(), EvWeight);
- hMeff->Fill(Meff, EvWeight);
- if(CleanJets.size() > 0) hj1Eta->Fill(CleanJets[0].Eta(), EvWeight);
- if(CleanJets.size() > 1) hj2Eta->Fill(CleanJets[1].Eta(), EvWeight);
- if(CleanJets.size() > 2) hj3Eta->Fill(CleanJets[2].Eta(), EvWeight);
- if(CleanJets.size() > 3) hj4Eta->Fill(CleanJets[3].Eta(), EvWeight);
- if(GoodLepton.size() > 0) hLeadLepEta->Fill(GoodLepton[0].Eta(), EvWeight);
- if(GoodLepton.size() > 1) hLeadLep2Eta->Fill(GoodLepton[1].Eta(), EvWeight);
- if(GoodLepton.size() > 2) hLeadLep3Eta->Fill(GoodLepton[2].Eta(), EvWeight);
- if(GoodLepton.size() > 0) hLeadLepIso->Fill(GoodLeptonIso[0], EvWeight);
- if(GoodLepton.size() > 1) hLeadLep2Iso->Fill(GoodLeptonIso[1], EvWeight);
- if(GoodLepton.size() > 2) hLeadLep3Iso->Fill(GoodLeptonIso[2], EvWeight);
- hST->Fill(ST, EvWeight);
- //if(MT > 0) hMT->Fill(MT, EvWeight);
- //////////////////////////////////////////////////////
- //////////////////////
- // Start of CF //
- //////////////////////--------->>>>>>> here is the place, which needs to be filled by the students, Jack or Ongun, or both ---
- // 1. nElectrons
- if((NGel != 3) || (NGmu != 0))continue; // Select three electrons only
- if((GoodLepton[0].Pt() < 25.) || (GoodLepton[1].Pt() < 15.) || (GoodLepton[2].Pt() < 10.)) continue;
- CFCounter[1]+= EvWeight;
- iCFCounter[1]++;
- CFC[1]+= EvWeight;
- iCFC[1]++;
- // 2. Z-WINDOW and 15 GeV
- //if(lv_sum.M() < 15) continue;
- //if(hasZ > 0) continue; // For OS lepton pair
- //CFCounter[2]+= EvWeight;
- //iCFCounter[2]++;
- //CFC[2]+= EvWeight;
- //iCFC[2]++;
- // 3. nJets >= 4
- //The construct is as follows for putting cuts on leading jets IMO(Ongun)
- if(CleanJets.size() < 4) continue;
- CFCounter[2]+= EvWeight;
- iCFCounter[2]++;
- CFC[2]+= EvWeight;
- iCFC[2]++;
- // 4. NBjets => 3
- if(Nbjet < 3) continue;
- CFCounter[3]+= EvWeight;
- iCFCounter[3]++;
- CFC[3]+= EvWeight;
- iCFC[3]++;
- //////////////////////////////////////////////////////
- //////////////////////////////////////////////////////
- //////// HISTOGRAMS IN THE MIDDLE OF CUTS SET 2 //////
- hNlep2->Fill(NGlept, EvWeight);
- hNel2->Fill(NGel,EvWeight);
- hNmu2->Fill(NGmu,EvWeight);
- hHT2->Fill(HT,EvWeight);
- hMET2->Fill(MET,EvWeight);
- hNj2->Fill(CleanJets.size(), EvWeight);
- hdPhi12->Fill(JetMETdPhi[CleanJetsInd[0]], EvWeight);
- hdPhi22->Fill(JetMETdPhi[CleanJetsInd[1]], EvWeight);
- hNbj2->Fill(Nbjet, EvWeight);
- hMETMeff2->Fill((MET / Meff), EvWeight);
- hj1Pt2->Fill(CleanJets[0].Pt(), EvWeight);
- hj2Pt2->Fill(CleanJets[1].Pt(), EvWeight);
- hj3Pt2->Fill(CleanJets[2].Pt(), EvWeight);
- hj4Pt2->Fill(CleanJets[3].Pt(), EvWeight);
- if((hasSS > 0) && (lv_sum.M() > 0)) hDiLMassSS2->Fill(lv_sum.M(),EvWeight);
- if(lv_sum.M() > 0) hDiLMassOS2->Fill(lv_sum.M(),EvWeight);
- hHasZ2->Fill(hasZ);
- if(GoodLepton.size() > 0 && GoodLepton[0].Pt() > 0) hLeadLepPt2->Fill(GoodLepton[0].Pt(), EvWeight);
- if(GoodLepton.size() > 1 && GoodLepton[1].Pt() > 0) hLeadLep2Pt2->Fill(GoodLepton[1].Pt(), EvWeight);
- if(GoodLepton.size() > 2 && GoodLepton[2].Pt() > 0) hLeadLep3Pt2->Fill(GoodLepton[2].Pt(), EvWeight);
- hMeff2->Fill(Meff, EvWeight);
- if(CleanJets.size() > 0) hj1Eta2->Fill(CleanJets[0].Eta(), EvWeight);
- if(CleanJets.size() > 1) hj2Eta2->Fill(CleanJets[1].Eta(), EvWeight);
- if(CleanJets.size() > 2) hj3Eta2->Fill(CleanJets[2].Eta(), EvWeight);
- if(CleanJets.size() > 3) hj4Eta2->Fill(CleanJets[3].Eta(), EvWeight);
- if(GoodLepton.size() > 0) hLeadLepEta2->Fill(GoodLepton[0].Eta(), EvWeight);
- if(GoodLepton.size() > 1) hLeadLep2Eta2->Fill(GoodLepton[1].Eta(), EvWeight);
- if(GoodLepton.size() > 2) hLeadLep3Eta2->Fill(GoodLepton[2].Eta(), EvWeight);
- if(GoodLepton.size() > 0) hLeadLepIso2->Fill(GoodLeptonIso[0], EvWeight);
- if(GoodLepton.size() > 1) hLeadLep2Iso2->Fill(GoodLeptonIso[1], EvWeight);
- if(GoodLepton.size() > 2) hLeadLep3Iso2->Fill(GoodLeptonIso[2], EvWeight);
- hST2->Fill(ST, EvWeight);
- //if(MT > 0) hMT2->Fill(MT, EvWeight);
- //////////////////////////////////////////////////////
- //////////////////////////////////////////////////////
- //5. dPhi > 0.3
- //double dPhi1 = TMath::Min(JetMETdPhi[CleanJetsInd[0]],JetMETdPhi[CleanJetsInd[1]]);
- //double dPhi2 = TMath::Min(JetMETdPhi[CleanJetsInd[2]],JetMETdPhi[CleanJetsInd[3]]);
- //double dPhi = TMath::Min(dPhi1, dPhi2);
- //if(dPhi < 0.3) continue;
- //CFCounter[5]+= EvWeight;
- //iCFCounter[5]++;
- //CFC[5]+= EvWeight;
- //iCFC[5]++;
- //////////////////////////////////////////////////////
- //////// HISTOGRAMS IN THE MIDDLE OF CUTS SET 3 //////
- //////////////////////////////////////////////////////
- hNlep3->Fill(NGlept, EvWeight);
- hNel3->Fill(NGel,EvWeight);
- hNmu3->Fill(NGmu,EvWeight);
- hHT3->Fill(HT,EvWeight);
- hMET3->Fill(MET,EvWeight);
- hNj3->Fill(CleanJets.size(), EvWeight);
- hdPhi13->Fill(JetMETdPhi[CleanJetsInd[0]], EvWeight);
- hdPhi23->Fill(JetMETdPhi[CleanJetsInd[1]], EvWeight);
- hNbj3->Fill(Nbjet, EvWeight);
- hMETMeff3->Fill((MET / Meff), EvWeight);
- hj1Pt3->Fill(CleanJets[0].Pt(), EvWeight);
- hj2Pt3->Fill(CleanJets[1].Pt(), EvWeight);
- hj3Pt3->Fill(CleanJets[2].Pt(), EvWeight);
- hj4Pt3->Fill(CleanJets[3].Pt(), EvWeight);
- if((hasSS > 0) && (lv_sum.M() > 0)) hDiLMassSS3->Fill(lv_sum.M(),EvWeight);
- if(lv_sum.M() > 0) hDiLMassOS3->Fill(lv_sum.M(),EvWeight);
- hHasZ3->Fill(hasZ);
- if(GoodLepton.size() > 0 && GoodLepton[0].Pt() > 0) hLeadLepPt3->Fill(GoodLepton[0].Pt(), EvWeight);
- if(GoodLepton.size() > 1 && GoodLepton[1].Pt() > 0) hLeadLep2Pt3->Fill(GoodLepton[1].Pt(), EvWeight);
- if(GoodLepton.size() > 2 && GoodLepton[2].Pt() > 0) hLeadLep3Pt3->Fill(GoodLepton[2].Pt(), EvWeight);
- hMeff3->Fill(Meff, EvWeight);
- if(CleanJets.size() > 0) hj1Eta3->Fill(CleanJets[0].Eta(), EvWeight);
- if(CleanJets.size() > 1) hj2Eta3->Fill(CleanJets[1].Eta(), EvWeight);
- if(CleanJets.size() > 2) hj3Eta3->Fill(CleanJets[2].Eta(), EvWeight);
- if(CleanJets.size() > 3) hj4Eta3->Fill(CleanJets[3].Eta(), EvWeight);
- if(GoodLepton.size() > 0) hLeadLepEta3->Fill(GoodLepton[0].Eta(), EvWeight);
- if(GoodLepton.size() > 1) hLeadLep2Eta3->Fill(GoodLepton[1].Eta(), EvWeight);
- if(GoodLepton.size() > 2) hLeadLep3Eta3->Fill(GoodLepton[2].Eta(), EvWeight);
- if(GoodLepton.size() > 0) hLeadLepIso3->Fill(GoodLeptonIso[0], EvWeight);
- if(GoodLepton.size() > 1) hLeadLep2Iso3->Fill(GoodLeptonIso[1], EvWeight);
- if(GoodLepton.size() > 2) hLeadLep3Iso3->Fill(GoodLeptonIso[2], EvWeight);
- hST3->Fill(ST, EvWeight);
- //if(MT > 0) hMT3->Fill(MT, EvWeight);
- // 6. HT > 1000
- //if(HT < 500) continue;
- ////if( MET < 500) continue;
- //CFCounter[6]+= EvWeight;
- //iCFCounter[6]++;
- //CFC[6]+= EvWeight;
- //iCFC[6]++;
- if(MET > 100)
- {
- CFCounter[4] += EvWeight;
- iCFCounter[4]++;
- }
- if(MET > 150)
- {
- CFCounter[5] += EvWeight;
- iCFCounter[5]++;
- }
- if(MET > 200)
- {
- CFCounter[6] += EvWeight;
- iCFCounter[6]++;
- }
- // 7. MET > 500 HT
- if( MET < 250) continue;
- //if(HT < 1000) continue;
- CFCounter[7]+= EvWeight;
- iCFCounter[7]++;
- CFC[4]+= EvWeight;
- iCFC[4]++;
- if(MET > 300)
- {
- CFCounter[8] += EvWeight;
- iCFCounter[8]++;
- }
- if(MET > 350)
- {
- CFCounter[9] += EvWeight;
- iCFCounter[9]++;
- }
- if(MET > 400)
- {
- CFCounter[10] += EvWeight;
- iCFCounter[10]++;
- }
- if(MET > 450)
- {
- CFCounter[11] += EvWeight;
- iCFCounter[11]++;
- }
- if(MET > 500)
- {
- CFCounter[12] += EvWeight;
- iCFCounter[12]++;
- }
- //////////////////////////////////////////////////////
- //////////////////////////////////////////////////////
- ///////////////////////
- // END of Selection //
- ///////////////////////
- ///////////////////////////
- // HISTOGRAMS AFTER CUTS //
- ///////////////////////////
- hNlep4->Fill(NGlept, EvWeight);
- hNel4->Fill(NGel,EvWeight);
- hNmu4->Fill(NGmu,EvWeight);
- hHT4->Fill(HT,EvWeight);
- hMET4->Fill(MET,EvWeight);
- hNj4->Fill(CleanJets.size(), EvWeight);
- hdPhi14->Fill(JetMETdPhi[CleanJetsInd[0]], EvWeight);
- hdPhi24->Fill(JetMETdPhi[CleanJetsInd[1]], EvWeight);
- hNbj4->Fill(Nbjet, EvWeight);
- hMETMeff4->Fill((MET / Meff), EvWeight);
- hj1Pt4->Fill(CleanJets[0].Pt(), EvWeight);
- hj2Pt4->Fill(CleanJets[1].Pt(), EvWeight);
- hj3Pt4->Fill(CleanJets[2].Pt(), EvWeight);
- hj4Pt4->Fill(CleanJets[3].Pt(), EvWeight);
- if((hasSS > 0) && (lv_sum.M() > 0)) hDiLMassSS4->Fill(lv_sum.M(),EvWeight);
- if(lv_sum.M() > 0) hDiLMassOS4->Fill(lv_sum.M(),EvWeight);
- hHasZ4->Fill(hasZ);
- if(GoodLepton.size() > 0 && GoodLepton[0].Pt() > 0) hLeadLepPt4->Fill(GoodLepton[0].Pt(), EvWeight);
- if(GoodLepton.size() > 1 && GoodLepton[1].Pt() > 0) hLeadLep2Pt4->Fill(GoodLepton[1].Pt(), EvWeight);
- if(GoodLepton.size() > 2 && GoodLepton[2].Pt() > 0) hLeadLep3Pt4->Fill(GoodLepton[2].Pt(), EvWeight);
- hMeff4->Fill(Meff, EvWeight);
- if(CleanJets.size() > 0) hj1Eta4->Fill(CleanJets[0].Eta(), EvWeight);
- if(CleanJets.size() > 1) hj2Eta4->Fill(CleanJets[1].Eta(), EvWeight);
- if(CleanJets.size() > 2) hj3Eta4->Fill(CleanJets[2].Eta(), EvWeight);
- if(CleanJets.size() > 3) hj4Eta4->Fill(CleanJets[3].Eta(), EvWeight);
- if(GoodLepton.size() > 0) hLeadLepEta4->Fill(GoodLepton[0].Eta(), EvWeight);
- if(GoodLepton.size() > 1) hLeadLep2Eta4->Fill(GoodLepton[1].Eta(), EvWeight);
- if(GoodLepton.size() > 2) hLeadLep3Eta4->Fill(GoodLepton[2].Eta(), EvWeight);
- if(GoodLepton.size() > 0) hLeadLepIso4->Fill(GoodLeptonIso[0], EvWeight);
- if(GoodLepton.size() > 1) hLeadLep2Iso4->Fill(GoodLeptonIso[1], EvWeight);
- if(GoodLepton.size() > 2) hLeadLep3Iso4->Fill(GoodLeptonIso[2], EvWeight);
- hST4->Fill(ST, EvWeight);
- //if(MT > 0) hMT4->Fill(MT, EvWeight);
- }
- /////////////////////////////
- //LOOP ENDS HERE
- /////////////////////////////
- ofstream tfile;
- tfile.open("SummerStd_"+outname+".txt");
- tfile << "########################################" << endl;
- tfile << "Cut efficiency numbers:" << endl;
- for(int ci = 0; ci < CutNumb; ci++)
- {
- tfile << "After cut " << CutList[ci] << "\t\t\t"
- << CFCounter[ci] << "\t events left\t"<< iCFCounter[ci] <<" cnt\t"<< endl;
- //CF->SetBinContent(1+ci,CFCounter[ci]);
- }
- // Extreme care needed here
- for(int cf = 0; cf < CutFlow; cf++)
- {
- CF->SetBinContent(1+cf, CFC[cf]);
- }
- TFile * outf = new TFile("SummerStd_"+outname+"_his.root","RECREATE"); // The root file is generated
- hNmu->Write();
- hNmu2->Write();
- hNmu3->Write();
- hNmu4->Write();
- hNel->Write();
- hNel2->Write();
- hNel3->Write();
- hNel4->Write();
- hNlep->Write();
- hNlep2->Write();
- hNlep3->Write();
- hNlep4->Write();
- hHT->Write();
- hHT2->Write();
- hHT3->Write();
- hHT4->Write();
- hMET->Write();
- hMET2->Write();
- hMET3->Write();
- hMET4->Write();
- hNj->Write();
- hNj2->Write();
- hNj3->Write();
- hNj4->Write();
- hdPhi1->Write();
- hdPhi12->Write();
- hdPhi13->Write();
- hdPhi14->Write();
- hdPhi2->Write();
- hdPhi22->Write();
- hdPhi23->Write();
- hdPhi24->Write();
- hNbj->Write();
- hNbj2->Write();
- hNbj3->Write();
- hNbj4->Write();
- //hMETMeff->Write();
- //hMETMeff2->Write();
- //hMETMeff3->Write();
- //hMETMeff4->Write();
- hDiLMassOS->Write();
- hDiLMassOS2->Write();
- hDiLMassOS3->Write();
- hDiLMassOS4->Write();
- hDiLMassSS->Write();
- hDiLMassSS2->Write();
- hDiLMassSS3->Write();
- hDiLMassSS4->Write();
- hj1Pt->Write();
- hj1Pt2->Write();
- hj1Pt3->Write();
- hj1Pt4->Write();
- hj2Pt->Write();
- hj2Pt2->Write();
- hj2Pt3->Write();
- hj2Pt4->Write();
- hj3Pt->Write();
- hj3Pt2->Write();
- hj3Pt3->Write();
- hj3Pt4->Write();
- hj4Pt->Write();
- hj4Pt2->Write();
- hj4Pt3->Write();
- hj4Pt4->Write();
- hj1Eta->Write();
- hj1Eta2->Write();
- hj1Eta3->Write();
- hj1Eta4->Write();
- hj2Eta->Write();
- hj2Eta2->Write();
- hj2Eta3->Write();
- hj2Eta4->Write();
- hj3Eta->Write();
- hj3Eta2->Write();
- hj3Eta3->Write();
- hj3Eta4->Write();
- hj4Eta->Write();
- hj4Eta2->Write();
- hj4Eta3->Write();
- hj4Eta4->Write();
- hHasZ->Write();
- hHasZ2->Write();
- hHasZ3->Write();
- hHasZ4->Write();
- hMeff->Write();
- hMeff2->Write();
- hMeff3->Write();
- hMeff4->Write();
- hLeadLepPt->Write();
- hLeadLepPt2->Write();
- hLeadLepPt3->Write();
- hLeadLepPt4->Write();
- hLeadLep2Pt->Write();
- hLeadLep2Pt2->Write();
- hLeadLep2Pt3->Write();
- hLeadLep2Pt4->Write();
- hLeadLep3Pt->Write();
- hLeadLep3Pt2->Write();
- hLeadLep3Pt3->Write();
- hLeadLep3Pt4->Write();
- hLeadLepEta->Write();
- hLeadLepEta2->Write();
- hLeadLepEta3->Write();
- hLeadLepEta4->Write();
- hLeadLep2Eta->Write();
- hLeadLep2Eta2->Write();
- hLeadLep2Eta3->Write();
- hLeadLep2Eta4->Write();
- hLeadLep3Eta->Write();
- hLeadLep3Eta2->Write();
- hLeadLep3Eta3->Write();
- hLeadLep3Eta4->Write();
- hLeadLepIso->Write();
- hLeadLepIso2->Write();
- hLeadLepIso3->Write();
- hLeadLepIso4->Write();
- hLeadLep2Iso->Write();
- hLeadLep2Iso2->Write();
- hLeadLep2Iso3->Write();
- hLeadLep2Iso4->Write();
- hLeadLep3Iso->Write();
- hLeadLep3Iso2->Write();
- hLeadLep3Iso3->Write();
- hLeadLep3Iso4->Write();
- hST->Write();
- hST2->Write();
- hST3->Write();
- hST4->Write();
- //hMT->Write();
- //hMT2->Write();
- //hMT3->Write();
- //hMT4->Write();
- CF->Write(); // This allows us to visualize the cuts
- outf->Close();
- }
Advertisement
Add Comment
Please, Sign In to add comment