1 |
|
---|
2 | Using ExRootAnalysis package for PGS data analysis
|
---|
3 | ==================================================
|
---|
4 |
|
---|
5 |
|
---|
6 | Author: Pavel Demin
|
---|
7 |
|
---|
8 |
|
---|
9 |
|
---|
10 |
|
---|
11 | Introductory remarks
|
---|
12 | ====================
|
---|
13 |
|
---|
14 |
|
---|
15 | The ExRootAnalysis is a package designed to simplify ROOT tree production and
|
---|
16 | analysis. The purpose of this tutorial is to present current functionality of
|
---|
17 | this software.
|
---|
18 |
|
---|
19 |
|
---|
20 |
|
---|
21 |
|
---|
22 | Quick start with ExRootAnalysis
|
---|
23 | ===============================
|
---|
24 |
|
---|
25 | Make sure that ROOT is installed and ROOTSYS, PATH, LD_LIBRARY_PATH,
|
---|
26 | DYLD_LIBRARY_PATH are configured correctly.
|
---|
27 |
|
---|
28 | Command to unpack the source code:
|
---|
29 |
|
---|
30 | tar -zxf ExRootAnalysis.tar.gz
|
---|
31 |
|
---|
32 | Commands to create shared library for interactive ROOT session:
|
---|
33 |
|
---|
34 | cd ExRootAnalysis
|
---|
35 |
|
---|
36 | make
|
---|
37 |
|
---|
38 | Commands to create static library for linking with PGS:
|
---|
39 |
|
---|
40 | cd ExRootAnalysis
|
---|
41 |
|
---|
42 | make static
|
---|
43 |
|
---|
44 |
|
---|
45 |
|
---|
46 |
|
---|
47 | Simple analysis using TTree::Draw
|
---|
48 | =================================
|
---|
49 |
|
---|
50 |
|
---|
51 | Now we can start ROOT and look at the data stored in the ROOT tree.
|
---|
52 |
|
---|
53 | Start ROOT and load shared library:
|
---|
54 |
|
---|
55 | root
|
---|
56 | gSystem->Load("lib/libExRootAnalysis.so");
|
---|
57 |
|
---|
58 | Open ROOT tree file and do some basic analysis using Draw or TBrowser:
|
---|
59 |
|
---|
60 | TFile::Open("pgs_events.root");
|
---|
61 | LHCO->Draw("Electron.PT");
|
---|
62 | TBrowser browser;
|
---|
63 |
|
---|
64 | Note 1: LHCO - tree name, it can be learnt e.g. from TBrowser
|
---|
65 |
|
---|
66 | Note 2: Electron - branch name; PT - variable (leaf) of this branch
|
---|
67 |
|
---|
68 | Complete description of all branches can be found in
|
---|
69 |
|
---|
70 | ExRootAnalysis/doc/RootTreeDescription.html
|
---|
71 |
|
---|
72 |
|
---|
73 |
|
---|
74 |
|
---|
75 | Macro-based analysis
|
---|
76 | ====================
|
---|
77 |
|
---|
78 |
|
---|
79 | Analysis macro consists of histogram booking, event loop (histogram filling),
|
---|
80 | histogram display
|
---|
81 |
|
---|
82 | Basic analysis macro:
|
---|
83 |
|
---|
84 | {
|
---|
85 | // Load shared library
|
---|
86 | gSystem->Load("lib/libExRootAnalysis.so");
|
---|
87 | gSystem->Load("libPhysics");
|
---|
88 |
|
---|
89 | // Create chain of root trees
|
---|
90 | TChain chain("LHCO");
|
---|
91 | chain.Add("pgs_events.root");
|
---|
92 |
|
---|
93 | // Create object of class ExRootTreeReader
|
---|
94 | ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
|
---|
95 | Long64_t numberOfEntries = treeReader->GetEntries();
|
---|
96 |
|
---|
97 | // Get pointers to branches used in this analysis
|
---|
98 | TClonesArray *branchJet = treeReader->UseBranch("Jet");
|
---|
99 | TClonesArray *branchElectron = treeReader->UseBranch("Electron");
|
---|
100 |
|
---|
101 | // Book histograms
|
---|
102 | TH1 *histJetPT = new TH1F("jet_pt", "jet P_{T}", 100, 0.0, 100.0);
|
---|
103 | TH1 *histMass = new TH1F("mass", "M_{inv}(e_{1}, e_{2})", 100, 40.0, 140.0);
|
---|
104 |
|
---|
105 | // Loop over all events
|
---|
106 | for(Int_t entry = 0; entry < numberOfEntries; ++entry) {
|
---|
107 |
|
---|
108 | // Load selected branches with data from specified event
|
---|
109 | treeReader->ReadEntry(entry);
|
---|
110 |
|
---|
111 | // If event contains at least 1 jet
|
---|
112 | if(branchJet->GetEntries() > 0) {
|
---|
113 |
|
---|
114 | // Take first jet
|
---|
115 | TRootJet *jet = (TRootJet*) branchJet->At(0);
|
---|
116 |
|
---|
117 | // Plot jet transverse momentum
|
---|
118 | histJetPT->Fill(jet->PT);
|
---|
119 |
|
---|
120 | // Print jet transverse momentum
|
---|
121 | cout << jet->PT << endl;
|
---|
122 | }
|
---|
123 |
|
---|
124 | TRootElectron *elec1, *elec2;
|
---|
125 | TLorentzVector vec1, vec2;
|
---|
126 |
|
---|
127 | // If event contains at least 2 electrons
|
---|
128 | if(branchElectron->GetEntries() > 1) {
|
---|
129 |
|
---|
130 | // Take first two electrons
|
---|
131 | elec1 = (TRootElectron *) branchElectron->At(0);
|
---|
132 | elec2 = (TRootElectron *) branchElectron->At(1);
|
---|
133 |
|
---|
134 | // Create two 4-vectors for the electrons
|
---|
135 | vec1.SetPtEtaPhiM(elec1->PT, elec1->Eta, elec1->Phi, 0.0);
|
---|
136 | vec2.SetPtEtaPhiM(elec2->PT, elec2->Eta, elec2->Phi, 0.0);
|
---|
137 |
|
---|
138 | // Plot their invariant mass
|
---|
139 | histMass->Fill((vec1 + vec2).M());
|
---|
140 | }
|
---|
141 | }
|
---|
142 |
|
---|
143 | // Show resulting histograms
|
---|
144 | histJetPT->Draw();
|
---|
145 | histMass->Draw();
|
---|
146 | }
|
---|
147 |
|
---|
148 |
|
---|
149 |
|
---|
150 |
|
---|
151 | More advanced macro-based analysis
|
---|
152 | ==================================
|
---|
153 |
|
---|
154 |
|
---|
155 | ExRootAnalysis/test contains macro Example.C using class ExRootTreeReader to
|
---|
156 | access data and class ExRootResult to manage histograms booking and output
|
---|
157 |
|
---|
158 | Here are commands to run this macro:
|
---|
159 |
|
---|
160 | cd ExRootAnalysis/test
|
---|
161 | $EDITOR test.list
|
---|
162 | root
|
---|
163 | gSystem->Load("../lib/libExRootAnalysis.so");
|
---|
164 | .X Example.C("test.list");
|
---|
165 |
|
---|
166 | Note: file test.list should contain list of root files that you would like to
|
---|
167 | analyse (one root file per line)
|
---|
168 |
|
---|
169 |
|
---|