diff --git a/LJAnalysis/.gitignore b/LJAnalysis/.gitignore new file mode 100644 index 0000000..4172cfd --- /dev/null +++ b/LJAnalysis/.gitignore @@ -0,0 +1,5 @@ +hists +*.so +*.d +*.pcm +*.root diff --git a/LJAnalysis/LJAnalyzer.C b/LJAnalysis/LJAnalyzer.C new file mode 100644 index 0000000..f39c42f --- /dev/null +++ b/LJAnalysis/LJAnalyzer.C @@ -0,0 +1,255 @@ +#define LJAnalyzer_cxx +// The class definition in LJAnalyzer.h has been generated automatically +// by the ROOT utility TTree::MakeSelector(). This class is derived +// from the ROOT class TSelector. For more information on the TSelector +// framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual. + +// The following methods are defined in this file: +// Begin(): called every time a loop on the tree starts, +// a convenient place to create your histograms. +// SlaveBegin(): called after Begin(), when on PROOF called only on the +// slave servers. +// Process(): called for each event, in this function you decide what +// to read and fill your histograms. +// SlaveTerminate: called at the end of the loop on the tree, when on PROOF +// called only on the slave servers. +// Terminate(): called at the end of the loop on the tree, +// a convenient place to draw/fit your histograms. +// +// To use this file, try the following session on your Tree T: +// +// root> T->Process("LJAnalyzer.C") +// root> T->Process("LJAnalyzer.C","some options") +// root> T->Process("LJAnalyzer.C+") +// + +#include "LJAnalyzer.h" + +#include +#include +#include +#include +#include + +#include +#include + +void LJAnalyzer::book(const char* name, const char* title, + const int nbinx, const double xmin, const double xmax, + const int nbiny=0, const double ymin=0, const double ymax=0) +{ + if ( nbiny == 0 ) h_[name] = new TH1F(name, title, nbinx, xmin, xmax); + else new TH2F(name, title, nbinx, xmin, xmax, nbiny, ymin, ymax); +} + +void LJAnalyzer::Begin(TTree * /*tree*/) +{ +} + +void LJAnalyzer::SlaveBegin(TTree * /*tree*/) +{ + auto options = fOption.Tokenize(","); + if ( options->GetEntries() == 0 ) sampleName_ = "NONE"; + else sampleName_ = ((TObjString*)options->At(0))->String(); + for ( int i=1; iGetEntries(); ++i ) { + const auto str = ((TObjString*)options->At(i))->String(); + if ( str == "SIGNAL" ) mode_ = SIGNAL; + else if ( str == "OTHERS" ) mode_ = OTHERS; + else mode_ = NONE; + } + + book("allmuons_n", "All muon;Muon multiplicity", 10, 0, 10); + book("allmuons_pt", "All muon;p_{T} (GeV)", 100, 0, 100); + book("muons_n", "Selected muon;Muon multiplicity", 10, 0, 10); + book("muons_pt", "Selected muon;p_{T} (GeV)", 100, 0, 100); + book("vetomuons_n", "Veto muon;Muon multiplicity", 10, 0, 10); + book("allelectrons_n", "All electrons;Muon multiplicity", 10, 0, 10); + book("allelectrons_pt", "All electrons;p_{T} (GeV)", 100, 0, 100); + book("vetoelectrons_n", "Veto electrons;Muon multiplicity", 10, 0, 10); + + book("alljets_n", "All jets;Jet multiplicity", 10, 0, 10); + + book("jets_n", "jets;Jet multiplicity", 10, 0, 10); + book("jets_pt", "jets;p_{T} (GeV)", 100, 0, 100); + book("jets_eta", "jets;#eta", 100, -2.5, 2.5); + book("jets_m", "jets;Mass (GeV)", 100, 0, 100); + book("jets_btag", "jets;b tag", 100, 0, 1); + + book("jets_allm12", "any dijets;M(jet1, jet2);Candidates per 10GeV", 50, 0, 500); + book("jets_allm123", "any trijets;M(jet1, jet2, jet3);Candidates per 10GeV", 50, 0, 500); + + book("jets_leadm12", "leading dijets;M(jet1, jet2);Events per 10GeV", 50, 0, 500); + book("jets_leadm123", "leading trijets;M(jet1, jet2, jet3);Events per 10GeV", 50, 0, 500); + + book("jets_btagm12", "leading dijets with 3rd jet b tag;M(jet1, jet2);Events per 20GeV", 25, 0, 500); + book("jets_btagm123", "leading trijets with 3rd jet b tag;M(jet1, jet2, jet3);Events per 20GeV", 25, 0, 500); + + book("jets_btagmwm12", "leading dijets with 3rd jet b tag and MW cut;M(jet1, jet2);Events per 20GeV", 25, 0, 500); + book("jets_btagmwm123", "leading trijets with 3rd jet b tag and MW cut;M(jet1, jet2, jet3);Events per 20GeV", 25, 0, 500); +} + +Bool_t LJAnalyzer::Process(Long64_t entry) +{ + GetEntry(entry); + + if ( mode_ != NONE ) { + const bool isSignal = [&](){ + if ( std::abs(MCleptonPDGid) != 13 ) return false; + + if ( MCleptonicBottom_px == 0 and MCleptonicBottom_py == 0 and + MCleptonicBottom_pz == 0 ) return false; + if ( MChadronicWDecayQuark_px == 0 and MChadronicWDecayQuark_py == 0 and + MChadronicWDecayQuark_pz == 0 ) return false; + if ( MChadronicWDecayQuarkBar_px == 0 and MChadronicWDecayQuarkBar_py == 0 and + MChadronicWDecayQuarkBar_pz == 0 ) return false; + return true; + }(); + + if ( mode_ == SIGNAL and !isSignal ) return false; + if ( mode_ == OTHERS and isSignal ) return false; + } + + std::vector muons, vetomuons; + for ( int i=0; iFill(pt, EventWeight); + + if ( Muon_Iso[i]/pt > 0.2 ) continue; + if ( std::abs(eta) > 2.4 ) continue; + + if ( pt > 10 ) vetomuons.push_back(mu); + if ( std::abs(eta) < 2.1 and pt > 26 ) muons.push_back(mu); + } + h_["allmuons_n"]->Fill(NMuon, EventWeight); + h_["muons_n"]->Fill(muons.size(), EventWeight); + + std::vector vetoelectrons; + for ( int i=0; iFill(pt, EventWeight); + + if ( Electron_Iso[i]/pt > 0.2 ) continue; + if ( std::abs(eta) > 2.4 ) continue; + + if ( pt > 10 ) vetoelectrons.push_back(el); + } + h_["allelectrons_n"]->Fill(NElectron, EventWeight); + h_["vetoelectrons_n"]->Fill(vetoelectrons.size(), EventWeight); + + if ( muons.size() != 1 ) return false; + if ( !vetoelectrons.empty() or vetomuons.size() > 1 ) return false; + + const auto muon0 = muons[0]; + + std::vector jets; + std::vector jetsBtag; + for ( int i=0; i 2.4 ) continue; + if ( muon0.DeltaR(jet) < 0.3 ) continue; + + jets.push_back(jet); + jetsBtag.push_back(Jet_btag[i]); + + h_["jets_pt"]->Fill(pt, EventWeight); + h_["jets_eta"]->Fill(eta, EventWeight); + h_["jets_m"]->Fill(jet.M(), EventWeight); + h_["jets_btag"]->Fill(Jet_btag[i], EventWeight); + } + h_["alljets_n"]->Fill(NJet, EventWeight); + h_["jets_n"]->Fill(jets.size(), EventWeight); + if ( jets.size() < 4 ) return false; + + std::vector jetIdxsByPt; + for ( int i=0, n=jets.size(); i jets[j].Pt();}); + + // Find a jet nearest to the lepton + TLorentzVector jet0; + for ( int i=0, n=jets.size(); i TMath::Pi()/2 ) continue; + if ( jet0.Pt() == 0 or dRLep < muon0.DeltaR(jet0) ) jet0 = jet; + } + + // Continue to the other jets to form top + TLorentzVector wCand, tCand; + TLorentzVector wCandWithBtag, tCandWithBtag; + TLorentzVector wCandWithBtagMW, tCandWithBtagMW; + for ( int i=0, n=jetIdxsByPt.size(); iFill((jet1+jet2).M(), EventWeight); + for ( int k=j+1; kFill((jet1+jet2+jet3).M(), EventWeight); + + if ( wCand.Pt() == 0 ) { + wCand = jet1+jet2; + tCand = wCand+jet3; + } + if ( jetsBtag[jetIdxsByPt[k]] > 0.1 and wCandWithBtag.Pt() == 0 ) { + wCandWithBtag = jet1+jet2; + tCandWithBtag = wCandWithBtag+jet3; + if ( wCandWithBtag.M() < 150 ) { + wCandWithBtagMW = wCandWithBtag; + tCandWithBtagMW = tCandWithBtag; + } + } + } + } + } + if ( wCand.M() > 0 ) { + h_["jets_leadm12"]->Fill(wCand.M(), EventWeight); + h_["jets_leadm123"]->Fill(tCand.M(), EventWeight); + } + if ( wCandWithBtag.M() > 0 ) { + h_["jets_btagm12"]->Fill(wCandWithBtag.M(), EventWeight); + h_["jets_btagm123"]->Fill(tCandWithBtag.M(), EventWeight); + } + if ( wCandWithBtagMW.M() > 0 ) { + h_["jets_btagmwm12"]->Fill(wCandWithBtagMW.M(), EventWeight); + h_["jets_btagmwm123"]->Fill(tCandWithBtagMW.M(), EventWeight); + } + + return kTRUE; +} + +void LJAnalyzer::SlaveTerminate() +{ + for ( auto x = h_.begin(); x != h_.end(); ++x ) { + fOutput->Add(x->second); + } +} + +void LJAnalyzer::Terminate() +{ + TFile* f = TFile::Open(("hists/"+sampleName_+".root").c_str(), "recreate"); + + for ( int i=0; iGetEntries(); ++i ) { + TH1* h = dynamic_cast(fOutput->At(i)); + if ( !h ) h = dynamic_cast(fOutput->At(i)); + if ( !h ) continue; + + h->Write(); + } + f->Close(); +} diff --git a/LJAnalysis/LJAnalyzer.h b/LJAnalysis/LJAnalyzer.h new file mode 100644 index 0000000..87f26aa --- /dev/null +++ b/LJAnalysis/LJAnalyzer.h @@ -0,0 +1,246 @@ +////////////////////////////////////////////////////////// +// This class has been automatically generated on +// Tue Nov 8 16:29:47 2016 by ROOT version 6.04/12 +// from TTree events/ +// found on file: files/ww.root +////////////////////////////////////////////////////////// + +#ifndef LJAnalyzer_h +#define LJAnalyzer_h + +#include +#include +#include +#include + +#include +#include +#include +#include + +#define NMAX 100 + +// Header file for the classes stored in the TTree if any. + +class LJAnalyzer : public TSelector { +public : + std::map h_; + void book(const char* name, const char* title, + const int nbinx, const double xmin, const double xmax, + const int nbiny, const double ymin, const double ymax); + + TTree *fChain; //!pointer to the analyzed TTree or TChain + + // Fixed size dimensions of array or collections stored in the TTree if any. + + // Declaration of leaf types + Int_t NJet; + Float_t Jet_Px[NMAX]; //[NJet] + Float_t Jet_Py[NMAX]; //[NJet] + Float_t Jet_Pz[NMAX]; //[NJet] + Float_t Jet_E[NMAX]; //[NJet] + Float_t Jet_btag[NMAX]; //[NJet] + Bool_t Jet_ID[NMAX]; //[NJet] + Int_t NMuon; + Float_t Muon_Px[NMAX]; //[NMuon] + Float_t Muon_Py[NMAX]; //[NMuon] + Float_t Muon_Pz[NMAX]; //[NMuon] + Float_t Muon_E[NMAX]; //[NMuon] + Int_t Muon_Charge[NMAX]; //[NMuon] + Float_t Muon_Iso[NMAX]; //[NMuon] + Int_t NElectron; + Float_t Electron_Px[NMAX]; //[NElectron] + Float_t Electron_Py[NMAX]; //[NElectron] + Float_t Electron_Pz[NMAX]; //[NElectron] + Float_t Electron_E[NMAX]; //[NElectron] + Int_t Electron_Charge[NMAX]; //[NElectron] + Float_t Electron_Iso[NMAX]; //[NElectron] + Int_t NPhoton; + Float_t Photon_Px[NMAX]; //[NPhoton] + Float_t Photon_Py[NMAX]; //[NPhoton] + Float_t Photon_Pz[NMAX]; //[NPhoton] + Float_t Photon_E[NMAX]; //[NPhoton] + Float_t Photon_Iso[NMAX]; //[NPhoton] + Float_t MET_px; + Float_t MET_py; + Float_t MChadronicBottom_px; + Float_t MChadronicBottom_py; + Float_t MChadronicBottom_pz; + Float_t MCleptonicBottom_px; + Float_t MCleptonicBottom_py; + Float_t MCleptonicBottom_pz; + Float_t MChadronicWDecayQuark_px; + Float_t MChadronicWDecayQuark_py; + Float_t MChadronicWDecayQuark_pz; + Float_t MChadronicWDecayQuarkBar_px; + Float_t MChadronicWDecayQuarkBar_py; + Float_t MChadronicWDecayQuarkBar_pz; + Float_t MClepton_px; + Float_t MClepton_py; + Float_t MClepton_pz; + Int_t MCleptonPDGid; + Float_t MCneutrino_px; + Float_t MCneutrino_py; + Float_t MCneutrino_pz; + Int_t NPrimaryVertices; + Bool_t triggerIsoMu24; + Float_t EventWeight; + + // List of branches + TBranch *b_NJet; //! + TBranch *b_Jet_Px; //! + TBranch *b_Jet_Py; //! + TBranch *b_Jet_Pz; //! + TBranch *b_Jet_E; //! + TBranch *b_Jet_btag; //! + TBranch *b_Jet_ID; //! + TBranch *b_NMuon; //! + TBranch *b_Muon_Px; //! + TBranch *b_Muon_Py; //! + TBranch *b_Muon_Pz; //! + TBranch *b_Muon_E; //! + TBranch *b_Muon_Charge; //! + TBranch *b_Muon_Iso; //! + TBranch *b_NElectron; //! + TBranch *b_Electron_Px; //! + TBranch *b_Electron_Py; //! + TBranch *b_Electron_Pz; //! + TBranch *b_Electron_E; //! + TBranch *b_Electron_Charge; //! + TBranch *b_Electron_Iso; //! + TBranch *b_NPhoton; //! + TBranch *b_Photon_Px; //! + TBranch *b_Photon_Py; //! + TBranch *b_Photon_Pz; //! + TBranch *b_Photon_E; //! + TBranch *b_Photon_Iso; //! + TBranch *b_MET_px; //! + TBranch *b_MET_py; //! + TBranch *b_MChadronicBottom_px; //! + TBranch *b_MChadronicBottom_py; //! + TBranch *b_MChadronicBottom_pz; //! + TBranch *b_MCleptonicBottom_px; //! + TBranch *b_MCleptonicBottom_py; //! + TBranch *b_MCleptonicBottom_pz; //! + TBranch *b_MChadronicWDecayQuark_px; //! + TBranch *b_MChadronicWDecayQuark_py; //! + TBranch *b_MChadronicWDecayQuark_pz; //! + TBranch *b_MChadronicWDecayQuarkBar_px; //! + TBranch *b_MChadronicWDecayQuarkBar_py; //! + TBranch *b_MChadronicWDecayQuarkBar_pz; //! + TBranch *b_MClepton_px; //! + TBranch *b_MClepton_py; //! + TBranch *b_MClepton_pz; //! + TBranch *b_MCleptonPDGid; //! + TBranch *b_MCneutrino_px; //! + TBranch *b_MCneutrino_py; //! + TBranch *b_MCneutrino_pz; //! + TBranch *b_NPrimaryVertices; //! + TBranch *b_triggerIsoMu24; //! + TBranch *b_EventWeight; //! + + LJAnalyzer(TTree * /*tree*/ =0) : fChain(0) { } + virtual ~LJAnalyzer() { } + virtual Int_t Version() const { return 2; } + virtual void Begin(TTree *tree); + virtual void SlaveBegin(TTree *tree); + virtual void Init(TTree *tree); + virtual Bool_t Notify(); + virtual Bool_t Process(Long64_t entry); + virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0) { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; } + virtual void SetOption(const char *option) { fOption = option; } + virtual void SetObject(TObject *obj) { fObject = obj; } + virtual void SetInputList(TList *input) { fInput = input; } + virtual TList *GetOutputList() const { return fOutput; } + virtual void SlaveTerminate(); + virtual void Terminate(); + + enum MODE { NONE, SIGNAL, OTHERS } mode_; + std::string sampleName_; + + ClassDef(LJAnalyzer,0); +}; + +#endif + +#ifdef LJAnalyzer_cxx +void LJAnalyzer::Init(TTree *tree) +{ + // The Init() function is called when the selector needs to initialize + // a new tree or chain. Typically here the branch addresses and branch + // pointers of the tree will be set. + // It is normally not necessary to make changes to the generated + // code, but the routine can be extended by the user if needed. + // Init() will be called many times when running on PROOF + // (once per file to be processed). + + // Set branch addresses and branch pointers + if (!tree) return; + fChain = tree; + fChain->SetMakeClass(1); + + fChain->SetBranchAddress("NJet", &NJet, &b_NJet); + fChain->SetBranchAddress("Jet_Px", Jet_Px, &b_Jet_Px); + fChain->SetBranchAddress("Jet_Py", Jet_Py, &b_Jet_Py); + fChain->SetBranchAddress("Jet_Pz", Jet_Pz, &b_Jet_Pz); + fChain->SetBranchAddress("Jet_E", Jet_E, &b_Jet_E); + fChain->SetBranchAddress("Jet_btag", Jet_btag, &b_Jet_btag); + fChain->SetBranchAddress("Jet_ID", Jet_ID, &b_Jet_ID); + fChain->SetBranchAddress("NMuon", &NMuon, &b_NMuon); + fChain->SetBranchAddress("Muon_Px", Muon_Px, &b_Muon_Px); + fChain->SetBranchAddress("Muon_Py", Muon_Py, &b_Muon_Py); + fChain->SetBranchAddress("Muon_Pz", Muon_Pz, &b_Muon_Pz); + fChain->SetBranchAddress("Muon_E", Muon_E, &b_Muon_E); + fChain->SetBranchAddress("Muon_Charge", Muon_Charge, &b_Muon_Charge); + fChain->SetBranchAddress("Muon_Iso", Muon_Iso, &b_Muon_Iso); + fChain->SetBranchAddress("NElectron", &NElectron, &b_NElectron); + fChain->SetBranchAddress("Electron_Px", Electron_Px, &b_Electron_Px); + fChain->SetBranchAddress("Electron_Py", Electron_Py, &b_Electron_Py); + fChain->SetBranchAddress("Electron_Pz", Electron_Pz, &b_Electron_Pz); + fChain->SetBranchAddress("Electron_E", Electron_E, &b_Electron_E); + fChain->SetBranchAddress("Electron_Charge", Electron_Charge, &b_Electron_Charge); + fChain->SetBranchAddress("Electron_Iso", Electron_Iso, &b_Electron_Iso); + fChain->SetBranchAddress("NPhoton", &NPhoton, &b_NPhoton); + fChain->SetBranchAddress("Photon_Px", Photon_Px, &b_Photon_Px); + fChain->SetBranchAddress("Photon_Py", Photon_Py, &b_Photon_Py); + fChain->SetBranchAddress("Photon_Pz", Photon_Pz, &b_Photon_Pz); + fChain->SetBranchAddress("Photon_E", Photon_E, &b_Photon_E); + fChain->SetBranchAddress("Photon_Iso", Photon_Iso, &b_Photon_Iso); + fChain->SetBranchAddress("MET_px", &MET_px, &b_MET_px); + fChain->SetBranchAddress("MET_py", &MET_py, &b_MET_py); + fChain->SetBranchAddress("MChadronicBottom_px", &MChadronicBottom_px, &b_MChadronicBottom_px); + fChain->SetBranchAddress("MChadronicBottom_py", &MChadronicBottom_py, &b_MChadronicBottom_py); + fChain->SetBranchAddress("MChadronicBottom_pz", &MChadronicBottom_pz, &b_MChadronicBottom_pz); + fChain->SetBranchAddress("MCleptonicBottom_px", &MCleptonicBottom_px, &b_MCleptonicBottom_px); + fChain->SetBranchAddress("MCleptonicBottom_py", &MCleptonicBottom_py, &b_MCleptonicBottom_py); + fChain->SetBranchAddress("MCleptonicBottom_pz", &MCleptonicBottom_pz, &b_MCleptonicBottom_pz); + fChain->SetBranchAddress("MChadronicWDecayQuark_px", &MChadronicWDecayQuark_px, &b_MChadronicWDecayQuark_px); + fChain->SetBranchAddress("MChadronicWDecayQuark_py", &MChadronicWDecayQuark_py, &b_MChadronicWDecayQuark_py); + fChain->SetBranchAddress("MChadronicWDecayQuark_pz", &MChadronicWDecayQuark_pz, &b_MChadronicWDecayQuark_pz); + fChain->SetBranchAddress("MChadronicWDecayQuarkBar_px", &MChadronicWDecayQuarkBar_px, &b_MChadronicWDecayQuarkBar_px); + fChain->SetBranchAddress("MChadronicWDecayQuarkBar_py", &MChadronicWDecayQuarkBar_py, &b_MChadronicWDecayQuarkBar_py); + fChain->SetBranchAddress("MChadronicWDecayQuarkBar_pz", &MChadronicWDecayQuarkBar_pz, &b_MChadronicWDecayQuarkBar_pz); + fChain->SetBranchAddress("MClepton_px", &MClepton_px, &b_MClepton_px); + fChain->SetBranchAddress("MClepton_py", &MClepton_py, &b_MClepton_py); + fChain->SetBranchAddress("MClepton_pz", &MClepton_pz, &b_MClepton_pz); + fChain->SetBranchAddress("MCleptonPDGid", &MCleptonPDGid, &b_MCleptonPDGid); + fChain->SetBranchAddress("MCneutrino_px", &MCneutrino_px, &b_MCneutrino_px); + fChain->SetBranchAddress("MCneutrino_py", &MCneutrino_py, &b_MCneutrino_py); + fChain->SetBranchAddress("MCneutrino_pz", &MCneutrino_pz, &b_MCneutrino_pz); + fChain->SetBranchAddress("NPrimaryVertices", &NPrimaryVertices, &b_NPrimaryVertices); + fChain->SetBranchAddress("triggerIsoMu24", &triggerIsoMu24, &b_triggerIsoMu24); + fChain->SetBranchAddress("EventWeight", &EventWeight, &b_EventWeight); +} + +Bool_t LJAnalyzer::Notify() +{ + // The Notify() function is called when a new file is opened. This + // can be either for a new TTree in a TChain or when when a new TTree + // is started when using PROOF. It is normally not necessary to make changes + // to the generated code, but the routine can be extended by the + // user if needed. The return value is currently not used. + + return kTRUE; +} + +#endif // #ifdef LJAnalyzer_cxx diff --git a/LJAnalysis/files b/LJAnalysis/files new file mode 120000 index 0000000..68b44c4 --- /dev/null +++ b/LJAnalysis/files @@ -0,0 +1 @@ +../files/ \ No newline at end of file diff --git a/LJAnalysis/run.py b/LJAnalysis/run.py new file mode 100755 index 0000000..81fc489 --- /dev/null +++ b/LJAnalysis/run.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python + +import sys, os +from ROOT import * + +sampleNames = [ + "ttbar", "ttbarOthers", "WW", "WZ", "ZZ", "SingleTop", "WJets", "ZJets", "QCD", +] +samples = { + "Data":{"title":"Data", "files":["data.root"], "color":kWhite}, + "ZJets":{"title":"Z#rightarrowl^{+}l^{-}+jets", "files":["dy.root"], "color":kAzure+2}, + "QCD":{"title":"QCD", "files":["qcd.root"], "color":kYellow}, + "SingleTop":{"title":"Single top", "files":["single_top.root"], "color":kCyan+1}, + "WJets":{"title":"W+jets", "files":["wjets.root"], "color":kGreen+1}, + "WW":{"title":"Dibosons", "files":["ww.root"], "color":kMagenta}, + "WZ":{"title":"Dibosons", "files":["wz.root"], "color":kMagenta}, + "ZZ":{"title":"Dibosons", "files":["zz.root"], "color":kMagenta}, + "ttbar":{"title":"t#bar{t}#rightarrowl^{#pm}+jets", "files":["ttbar.root"], "color":kRed+1}, + "ttbarOthers":{"title":"t#bar{t} others", "files":["ttbar.root"], "color":kRed+3}, +} + +if not os.path.exists("hists"): + #proof = TProof.Open("") + os.mkdir("hists") + for sample in samples: + chain = TChain("events") + for f in samples[sample]["files"]: chain.Add("files/"+f) + + opt = sample + if sample == 'ttbarOthers': opt += ',OTHERS' + elif sample == 'ttbar': opt += ',SIGNAL' + + #chain.SetProof() + chain.Process('LJAnalyzer.C+', opt) + +for sample in samples: + samples[sample]["hfile"] = TFile("hists/"+sample+".root") +hists = [x.GetName() for x in samples["Data"]["hfile"].GetListOfKeys()] + +gStyle.SetOptTitle(0) +gStyle.SetOptStat(0) +objs = [] +for hName in hists: + #if "m12" not in hName: continue + + c = TCanvas("c"+hName, hName, 500, 500) + c.SetGridx() + c.SetGridy() + + leg = TLegend(0.60, 0.60, 1-c.GetTopMargin()-0.02, 1.-c.GetRightMargin()-0.02) + hs = THStack() + hRD = samples["Data"]["hfile"].Get(hName) + hMC = None + for sample in sampleNames: + h = samples[sample]["hfile"].Get(hName) + + if hMC == None: + hMC = h.Clone() + hMC.SetName("hSumMC"+hName) + hMC.Reset() + + h.SetFillColor(samples[sample]["color"]) + h.SetLineColor(samples[sample]["color"]) + h.SetOption("hist") + hs.Add(h) + hMC.Add(h) + + titles = [] + for sample in reversed(sampleNames): + title = samples[sample]['title'] + if title in titles: continue + titles.append(title) + leg.AddEntry(samples[sample]["hfile"].Get(hName), title, 'f') + leg.AddEntry(hRD, "Data", "lp") + leg.SetFillStyle(0) + leg.SetBorderSize(0) + + hMC.SetLineColor(kBlack) + hMC.SetFillStyle(0) + + hRD.SetMaximum(1.2*max(hMC.GetMaximum(), hRD.GetMaximum())) + hRD.SetMarkerSize(1) + hRD.SetMarkerStyle(kFullCircle) + + hMC.Draw("hist") + hs.Draw("samehist") + hMC.Draw("samehist") + hRD.Draw("sameE") + leg.Draw() + + label1 = TLatex().DrawLatexNDC(c.GetLeftMargin()+0.01, 1-c.GetTopMargin()+0.01, "CMS Open Data 2010") + label2 = TLatex().DrawLatexNDC(1-c.GetRightMargin()-0.01, 1-c.GetTopMargin()+0.01, "#sqrt{s}=7TeV L=50pb^{-1}") + label1.SetTextAlign(11) + label2.SetTextAlign(31) + label1.SetTextSize(0.05) + label2.SetTextSize(0.04) + label2.SetTextFont(62) + + hRD.Draw("sameaxis") + + objs.extend([c, hs, hRD, hMC, leg, label1, label2]) diff --git a/LJAnalysis/setup.sh b/LJAnalysis/setup.sh new file mode 100644 index 0000000..cfc6947 --- /dev/null +++ b/LJAnalysis/setup.sh @@ -0,0 +1,3 @@ +#!/bin/bash +source /cvmfs/sft.cern.ch/lcg/external/gcc/4.9.1/x86_64-slc6-gcc48-opt/setup.sh +source /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.04.12/x86_64-slc6-gcc49-opt/root/bin/thisroot.sh