1 |
//root -l CITCommon/Examples/ReadZeeEventExample.C+'("/data/blue/sixie/LeptonScaleAndResolution/Electrons/ZeeNtuple.AllNtuple_HZZ4lNtuple_s12-zllm50-2-v9_noskim_0000.root.root")'
|
2 |
//root -l CITCommon/Examples/ReadZeeEventExample.C+'("/data/blue/sixie/LeptonScaleAndResolution/Electrons/Hgg/tree_zee_nosmear.root",2)'
|
3 |
|
4 |
//================================================================================================
|
5 |
//
|
6 |
// Example
|
7 |
//
|
8 |
//________________________________________________________________________________________________
|
9 |
|
10 |
#if !defined(__CINT__) || defined(__MAKECINT__)
|
11 |
#include <TROOT.h> // access to gROOT, entry point to ROOT system
|
12 |
#include <TSystem.h> // interface to OS
|
13 |
#include <TFile.h> // file handle class
|
14 |
#include <TTree.h> // class to access ntuples
|
15 |
#include <TH1F.h> //
|
16 |
#include <TCanvas.h> //
|
17 |
#include <TClonesArray.h> // ROOT array class
|
18 |
#include <TBenchmark.h> // class to track macro running statistics
|
19 |
#include <TLorentzVector.h> // class for 4-vector calculations
|
20 |
#include <vector> // STL vector class
|
21 |
#include <iostream> // standard I/O
|
22 |
#include <iomanip> // functions to format standard I/O
|
23 |
#include <fstream> // functions for file I/O
|
24 |
#include <string> // C++ string class
|
25 |
#include <sstream> // class for parsing strings
|
26 |
|
27 |
// structure for output ntuple
|
28 |
#include "CITCommon/CommonData/interface/ZeeEventTree.h"
|
29 |
#endif
|
30 |
|
31 |
|
32 |
//=== MAIN MACRO =================================================================================================
|
33 |
|
34 |
void ReadZeeEventExample(const string inputfile, Int_t Option = 0) {
|
35 |
|
36 |
|
37 |
//*****************************************************************************************
|
38 |
//Make a Histogram
|
39 |
//*****************************************************************************************
|
40 |
TH1F *hist = new TH1F ("mass",";Mass [GeV/c^{2}];Number of Events",80,40,200);
|
41 |
|
42 |
|
43 |
//*****************************************************************************************
|
44 |
// Input
|
45 |
//*****************************************************************************************
|
46 |
citana::ZeeEventTree zeeTree;
|
47 |
if (Option == 0) {
|
48 |
cout << zeeTree.fTreeType << endl;
|
49 |
zeeTree.LoadTree(inputfile.c_str());
|
50 |
zeeTree.InitTree();
|
51 |
cout << zeeTree.fTreeType << endl;
|
52 |
}
|
53 |
if (Option == 1) {
|
54 |
zeeTree.LoadTree(inputfile.c_str(),citana::ZeeEventTree::kHggFutyanZeeDataEvent);
|
55 |
zeeTree.InitTree(citana::ZeeEventTree::kHggFutyanZeeDataEvent);
|
56 |
}
|
57 |
if (Option == 2) {
|
58 |
zeeTree.LoadTree(inputfile.c_str(),citana::ZeeEventTree::kHggFutyanZeeMCEvent);
|
59 |
zeeTree.InitTree(citana::ZeeEventTree::kHggFutyanZeeMCEvent);
|
60 |
}
|
61 |
|
62 |
//*****************************************************************************************
|
63 |
// Read Input File
|
64 |
//*****************************************************************************************
|
65 |
for (Long64_t ievt=0; ievt<zeeTree.tree_->GetEntries();ievt++) {
|
66 |
|
67 |
if (ievt%10000 == 0) std::cout << "--- ... Processing event: " << ievt << std::endl;
|
68 |
|
69 |
zeeTree.tree_->GetEntry(ievt);
|
70 |
|
71 |
if (zeeTree.Ele1Pt() > 25 && zeeTree.Ele2Pt() > 25) {
|
72 |
|
73 |
//For supercluster energy
|
74 |
TLorentzVector ele1;
|
75 |
TLorentzVector ele2;
|
76 |
|
77 |
Bool_t useRegression = kFALSE;
|
78 |
//Note: Et = E / Cosh(eta)
|
79 |
|
80 |
if (useRegression) {
|
81 |
ele1.SetPtEtaPhiM( zeeTree.fEle1EnergyRegression / TMath::CosH(zeeTree.Ele1Eta()) , zeeTree.Ele1Eta(), zeeTree.Ele1Phi(), 0.51099892e-3);
|
82 |
ele2.SetPtEtaPhiM( zeeTree.fEle2EnergyRegression / TMath::CosH(zeeTree.Ele2Eta()) , zeeTree.Ele2Eta(), zeeTree.Ele2Phi(), 0.51099892e-3);
|
83 |
} else {
|
84 |
ele1.SetPtEtaPhiM( zeeTree.Ele1Pt() , zeeTree.Ele1Eta(), zeeTree.Ele1Phi(), 0.51099892e-3);
|
85 |
ele2.SetPtEtaPhiM( zeeTree.Ele2Pt() , zeeTree.Ele2Eta(), zeeTree.Ele2Phi(), 0.51099892e-3);
|
86 |
}
|
87 |
|
88 |
double weight = 1; //zeeTree.fWeight //if you want to use pileup reweighting
|
89 |
hist->Fill((ele1+ele2).M(), weight);
|
90 |
|
91 |
}
|
92 |
|
93 |
}
|
94 |
|
95 |
|
96 |
|
97 |
//--------------------------------------------------------------------------------------------------------------
|
98 |
// Plot
|
99 |
//==============================================================================================================
|
100 |
|
101 |
TCanvas *cv = new TCanvas("cv","cv", 800, 600);
|
102 |
hist->Draw("hist");
|
103 |
cv->SaveAs("massExample.gif");
|
104 |
|
105 |
|
106 |
}
|