source: trunk/doc/README@ 22

Last change on this file since 22 was 4, checked in by Pavel Demin, 16 years ago

first commit

File size: 3.9 KB
Line 
1
2Using ExRootAnalysis package for PGS data analysis
3==================================================
4
5
6Author: Pavel Demin
7
8
9
10
11Introductory remarks
12====================
13
14
15The ExRootAnalysis is a package designed to simplify ROOT tree production and
16analysis. The purpose of this tutorial is to present current functionality of
17this software.
18
19
20
21
22Quick start with ExRootAnalysis
23===============================
24
25Make sure that ROOT is installed and ROOTSYS, PATH, LD_LIBRARY_PATH,
26DYLD_LIBRARY_PATH are configured correctly.
27
28Command to unpack the source code:
29
30 tar -zxf ExRootAnalysis.tar.gz
31
32Commands to create shared library for interactive ROOT session:
33
34 cd ExRootAnalysis
35
36 make
37
38Commands to create static library for linking with PGS:
39
40 cd ExRootAnalysis
41
42 make static
43
44
45
46
47Simple analysis using TTree::Draw
48=================================
49
50
51Now we can start ROOT and look at the data stored in the ROOT tree.
52
53Start ROOT and load shared library:
54
55 root
56 gSystem->Load("lib/libExRootAnalysis.so");
57
58Open 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
64Note 1: LHCO - tree name, it can be learnt e.g. from TBrowser
65
66Note 2: Electron - branch name; PT - variable (leaf) of this branch
67
68Complete description of all branches can be found in
69
70 ExRootAnalysis/doc/RootTreeDescription.html
71
72
73
74
75Macro-based analysis
76====================
77
78
79Analysis macro consists of histogram booking, event loop (histogram filling),
80histogram display
81
82Basic 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
151More advanced macro-based analysis
152==================================
153
154
155ExRootAnalysis/test contains macro Example.C using class ExRootTreeReader to
156access data and class ExRootResult to manage histograms booking and output
157
158Here 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
166Note: file test.list should contain list of root files that you would like to
167analyse (one root file per line)
168
169
Note: See TracBrowser for help on using the repository browser.