ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/csander/HEPTutorial/MyAnalysis.h
Revision: 1.14
Committed: Fri May 25 09:18:51 2012 UTC (12 years, 11 months ago) by csander
Content type: text/plain
Branch: MAIN
Changes since 1.13: +1 -0 lines
Log Message:
Added event comparison and more plots

File Contents

# User Rev Content
1 csander 1.1 //////////////////////////////////////////////////////////
2     // This class has been automatically generated on
3     // Wed Feb 1 07:53:21 2012 by ROOT version 5.32/00
4     // from TTree data/
5     // found on file: data.root
6     //////////////////////////////////////////////////////////
7    
8     #ifndef MyAnalysis_h
9     #define MyAnalysis_h
10    
11     #include <TROOT.h>
12 csander 1.2 #include <TFile.h>
13 csander 1.1 #include <TChain.h>
14     #include <TSelector.h>
15 csander 1.4 #include <TH1F.h>
16 csander 1.6 #include <TLorentzVector.h>
17 csander 1.1
18 csander 1.3 #include "MyJet.h"
19     #include "MyMuon.h"
20 csander 1.4 #include "MyElectron.h"
21     #include "MyPhoton.h"
22 csander 1.12 #include "MyTau.h"
23     #include "MyParton.h"
24 csander 1.3
25 csander 1.13 #include "EventSelectorByList.h"
26    
27 csander 1.3 using namespace std;
28    
29 csander 1.1 // Header file for the classes stored in the TTree if any.
30    
31     // Fixed size dimensions of array or collections stored in the TTree if any.
32    
33 csander 1.2 class MyAnalysis: public TSelector {
34     public:
35     TTree *fChain; //!pointer to the analyzed TTree or TChain
36    
37     // Declaration of leaf types
38 csander 1.12 Int_t NJet;
39     Float_t Jet_Px[20]; //[NJet]
40     Float_t Jet_Py[20]; //[NJet]
41     Float_t Jet_Pz[20]; //[NJet]
42     Float_t Jet_E[20]; //[NJet]
43     Float_t Jet_btag[20]; //[NJet]
44     Bool_t Jet_ID[20]; //[NJet]
45     Float_t Jet_Px_gen[20]; //[NJet]
46     Float_t Jet_Py_gen[20]; //[NJet]
47     Float_t Jet_Pz_gen[20]; //[NJet]
48     Float_t Jet_E_gen[20]; //[NJet]
49     Int_t Jet_Flavor_gen[20]; //[NJet]
50     Int_t NMuon;
51     Float_t Muon_Px[5]; //[NMuon]
52     Float_t Muon_Py[5]; //[NMuon]
53     Float_t Muon_Pz[5]; //[NMuon]
54     Float_t Muon_E[5]; //[NMuon]
55     Int_t Muon_Charge[5]; //[NMuon]
56     Float_t Muon_Iso[5]; //[NMuon]
57     Float_t Muon_Px_gen[5]; //[NMuon]
58     Float_t Muon_Py_gen[5]; //[NMuon]
59     Float_t Muon_Pz_gen[5]; //[NMuon]
60     Float_t Muon_E_gen[5]; //[NMuon]
61     Int_t Muon_Charge_gen[5]; //[NMuon]
62     Int_t NElectron;
63     Float_t Electron_Px[5]; //[NElectron]
64     Float_t Electron_Py[5]; //[NElectron]
65     Float_t Electron_Pz[5]; //[NElectron]
66     Float_t Electron_E[5]; //[NElectron]
67     Int_t Electron_Charge[5]; //[NElectron]
68     Float_t Electron_Iso[5]; //[NElectron]
69     Float_t Electron_Px_gen[5]; //[NElectron]
70     Float_t Electron_Py_gen[5]; //[NElectron]
71     Float_t Electron_Pz_gen[5]; //[NElectron]
72     Float_t Electron_E_gen[5]; //[NElectron]
73     Int_t Electron_Charge_gen[5]; //[NElectron]
74     Int_t NPhoton;
75     Float_t Photon_Px[5]; //[NPhoton]
76     Float_t Photon_Py[5]; //[NPhoton]
77     Float_t Photon_Pz[5]; //[NPhoton]
78     Float_t Photon_E[5]; //[NPhoton]
79     Float_t Photon_Iso[5]; //[NPhoton]
80     Float_t Photon_Px_gen[5]; //[NPhoton]
81     Float_t Photon_Py_gen[5]; //[NPhoton]
82     Float_t Photon_Pz_gen[5]; //[NPhoton]
83     Float_t Photon_E_gen[5]; //[NPhoton]
84     Int_t NTau;
85     Float_t Tau_Px[5]; //[NTau]
86     Float_t Tau_Py[5]; //[NTau]
87     Float_t Tau_Pz[5]; //[NTau]
88     Float_t Tau_E[5]; //[NTau]
89     Bool_t Tau_ID[5]; //[NTau]
90     Float_t Tau_Px_gen[5]; //[NTau]
91     Float_t Tau_Py_gen[5]; //[NTau]
92     Float_t Tau_Pz_gen[5]; //[NTau]
93     Float_t Tau_E_gen[5]; //[NTau]
94     Int_t NParton;
95     Float_t Parton_Px[20]; //[NParton]
96     Float_t Parton_Py[20]; //[NParton]
97     Float_t Parton_Pz[20]; //[NParton]
98     Float_t Parton_E[20]; //[NParton]
99     Int_t Parton_Pid[20]; //[NParton]
100     Float_t MET_px;
101     Float_t MET_py;
102     Float_t MET_px_gen;
103     Float_t MET_py_gen;
104     Int_t NPrimaryVertices;
105     Bool_t trigger;
106     Float_t EventWeight;
107     Int_t EventNumber;
108     Int_t LumiNumber;
109     Int_t RunNumber;
110 csander 1.2
111     // List of branches
112 csander 1.12 TBranch *b_NJet; //!
113     TBranch *b_Jet_Px; //!
114     TBranch *b_Jet_Py; //!
115     TBranch *b_Jet_Pz; //!
116     TBranch *b_Jet_E; //!
117     TBranch *b_Jet_btag; //!
118     TBranch *b_Jet_ID; //!
119     TBranch *b_Jet_Px_gen; //!
120     TBranch *b_Jet_Py_gen; //!
121     TBranch *b_Jet_Pz_gen; //!
122     TBranch *b_Jet_E_gen; //!
123     TBranch *b_Jet_Flavor_gen; //!
124     TBranch *b_NMuon; //!
125     TBranch *b_Muon_Px; //!
126     TBranch *b_Muon_Py; //!
127     TBranch *b_Muon_Pz; //!
128     TBranch *b_Muon_E; //!
129     TBranch *b_Muon_Charge; //!
130     TBranch *b_Muon_Iso; //!
131     TBranch *b_Muon_Px_gen; //!
132     TBranch *b_Muon_Py_gen; //!
133     TBranch *b_Muon_Pz_gen; //!
134     TBranch *b_Muon_E_gen; //!
135     TBranch *b_Muon_Charge_gen; //!
136     TBranch *b_NElectron; //!
137     TBranch *b_Electron_Px; //!
138     TBranch *b_Electron_Py; //!
139     TBranch *b_Electron_Pz; //!
140     TBranch *b_Electron_E; //!
141     TBranch *b_Electron_Charge; //!
142     TBranch *b_Electron_Iso; //!
143     TBranch *b_Electron_Px_gen; //!
144     TBranch *b_Electron_Py_gen; //!
145     TBranch *b_Electron_Pz_gen; //!
146     TBranch *b_Electron_E_gen; //!
147     TBranch *b_Electron_Charge_gen; //!
148     TBranch *b_NPhoton; //!
149     TBranch *b_Photon_Px; //!
150     TBranch *b_Photon_Py; //!
151     TBranch *b_Photon_Pz; //!
152     TBranch *b_Photon_E; //!
153     TBranch *b_Photon_Iso; //!
154     TBranch *b_Photon_Px_gen; //!
155     TBranch *b_Photon_Py_gen; //!
156     TBranch *b_Photon_Pz_gen; //!
157     TBranch *b_Photon_E_gen; //!
158     TBranch *b_NTau; //!
159     TBranch *b_Tau_Px; //!
160     TBranch *b_Tau_Py; //!
161     TBranch *b_Tau_Pz; //!
162     TBranch *b_Tau_E; //!
163     TBranch *b_Tau_ID; //!
164     TBranch *b_Tau_Px_gen; //!
165     TBranch *b_Tau_Py_gen; //!
166     TBranch *b_Tau_Pz_gen; //!
167     TBranch *b_Tau_E_gen; //!
168     TBranch *b_NParton; //!
169     TBranch *b_Parton_Px; //!
170     TBranch *b_Parton_Py; //!
171     TBranch *b_Parton_Pz; //!
172     TBranch *b_Parton_E; //!
173     TBranch *b_Parton_Pid; //!
174     TBranch *b_MET_px; //!
175     TBranch *b_MET_py; //!
176     TBranch *b_MET_px_gen; //!
177     TBranch *b_MET_py_gen; //!
178     TBranch *b_NPrimaryVertices; //!
179     TBranch *b_trigger; //!
180     TBranch *b_EventWeight; //!
181     TBranch *b_EventNumber; //!
182     TBranch *b_LumiNumber; //!
183     TBranch *b_RunNumber; //!
184 csander 1.2
185 csander 1.9 MyAnalysis(float wf = 1., TTree * /*tree*/= 0) :
186 csander 1.2 fChain(0) {
187 csander 1.9 weight_factor = wf;
188 csander 1.2 }
189     virtual ~MyAnalysis() {
190     }
191     virtual Int_t Version() const {
192     return 2;
193     }
194     virtual void Begin(TTree *tree);
195     virtual void SlaveBegin(TTree *tree);
196     virtual void Init(TTree *tree);
197     virtual Bool_t Notify();
198     virtual Bool_t Process(Long64_t entry);
199     virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0) {
200     return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0;
201     }
202     virtual void SetOption(const char *option) {
203     fOption = option;
204     }
205     virtual void SetObject(TObject *obj) {
206     fObject = obj;
207     }
208     virtual void SetInputList(TList *input) {
209     fInput = input;
210     }
211     virtual TList *GetOutputList() const {
212     return fOutput;
213     }
214     virtual void SlaveTerminate();
215     virtual void Terminate();
216 csander 1.1
217 csander 1.3 void BuildEvent();
218    
219     int TotalEvents;
220     vector<MyJet> Jets;
221     vector<MyMuon> Muons;
222 csander 1.4 vector<MyElectron> Electrons;
223     vector<MyPhoton> Photons;
224 csander 1.12 vector<MyTau> Taus;
225     vector<MyParton> Partons;
226 csander 1.4
227 csander 1.12 TLorentzVector met, genmet;
228     double weight_factor;
229 csander 1.9
230 csander 1.7 TH1F *h_Mmumu;
231 csander 1.3
232 csander 1.9 TH1F *h_NJet;
233     TH1F *h_NBJet;
234    
235     TH1F *h_Jet1_Pt, *h_Jet1_Eta;
236     TH1F *h_Jet2_Pt, *h_Jet2_Eta;
237     TH1F *h_Jet3_Pt, *h_Jet3_Eta;
238     TH1F *h_BJet1_Pt, *h_BJet1_Eta;
239     TH1F *h_BJet2_Pt, *h_BJet2_Eta;
240     TH1F *h_MET;
241    
242 csander 1.14 EventSelectorByList* singleTauEventList;
243 csander 1.9
244 csander 1.1 };
245    
246     #endif
247    
248     #ifdef MyAnalysis_cxx
249     void MyAnalysis::Init(TTree *tree)
250     {
251     // The Init() function is called when the selector needs to initialize
252     // a new tree or chain. Typically here the branch addresses and branch
253     // pointers of the tree will be set.
254     // It is normally not necessary to make changes to the generated
255     // code, but the routine can be extended by the user if needed.
256     // Init() will be called many times when running on PROOF
257     // (once per file to be processed).
258    
259     // Set branch addresses and branch pointers
260     if (!tree) return;
261     fChain = tree;
262     fChain->SetMakeClass(1);
263    
264     fChain->SetBranchAddress("NJet", &NJet, &b_NJet);
265     fChain->SetBranchAddress("Jet_Px", Jet_Px, &b_Jet_Px);
266     fChain->SetBranchAddress("Jet_Py", Jet_Py, &b_Jet_Py);
267     fChain->SetBranchAddress("Jet_Pz", Jet_Pz, &b_Jet_Pz);
268     fChain->SetBranchAddress("Jet_E", Jet_E, &b_Jet_E);
269     fChain->SetBranchAddress("Jet_btag", Jet_btag, &b_Jet_btag);
270 csander 1.12 fChain->SetBranchAddress("Jet_ID", Jet_ID, &b_Jet_ID);
271     fChain->SetBranchAddress("Jet_Px_gen", Jet_Px_gen, &b_Jet_Px_gen);
272     fChain->SetBranchAddress("Jet_Py_gen", Jet_Py_gen, &b_Jet_Py_gen);
273     fChain->SetBranchAddress("Jet_Pz_gen", Jet_Pz_gen, &b_Jet_Pz_gen);
274     fChain->SetBranchAddress("Jet_E_gen", Jet_E_gen, &b_Jet_E_gen);
275     fChain->SetBranchAddress("Jet_Flavor_gen", Jet_Flavor_gen, &b_Jet_Flavor_gen);
276 csander 1.1 fChain->SetBranchAddress("NMuon", &NMuon, &b_NMuon);
277 csander 1.12 fChain->SetBranchAddress("Muon_Px", &Muon_Px, &b_Muon_Px);
278     fChain->SetBranchAddress("Muon_Py", &Muon_Py, &b_Muon_Py);
279     fChain->SetBranchAddress("Muon_Pz", &Muon_Pz, &b_Muon_Pz);
280     fChain->SetBranchAddress("Muon_E", &Muon_E, &b_Muon_E);
281     fChain->SetBranchAddress("Muon_Charge", &Muon_Charge, &b_Muon_Charge);
282     fChain->SetBranchAddress("Muon_Iso", &Muon_Iso, &b_Muon_Iso);
283     fChain->SetBranchAddress("Muon_Px_gen", &Muon_Px_gen, &b_Muon_Px_gen);
284     fChain->SetBranchAddress("Muon_Py_gen", &Muon_Py_gen, &b_Muon_Py_gen);
285     fChain->SetBranchAddress("Muon_Pz_gen", &Muon_Pz_gen, &b_Muon_Pz_gen);
286     fChain->SetBranchAddress("Muon_E_gen", &Muon_E_gen, &b_Muon_E_gen);
287     fChain->SetBranchAddress("Muon_Charge_gen", &Muon_Charge_gen, &b_Muon_Charge_gen);
288 csander 1.1 fChain->SetBranchAddress("NElectron", &NElectron, &b_NElectron);
289 csander 1.12 fChain->SetBranchAddress("Electron_Px", &Electron_Px, &b_Electron_Px);
290     fChain->SetBranchAddress("Electron_Py", &Electron_Py, &b_Electron_Py);
291     fChain->SetBranchAddress("Electron_Pz", &Electron_Pz, &b_Electron_Pz);
292     fChain->SetBranchAddress("Electron_E", &Electron_E, &b_Electron_E);
293     fChain->SetBranchAddress("Electron_Charge", &Electron_Charge, &b_Electron_Charge);
294     fChain->SetBranchAddress("Electron_Iso", &Electron_Iso, &b_Electron_Iso);
295     fChain->SetBranchAddress("Electron_Px_gen", &Electron_Px_gen, &b_Electron_Px_gen);
296     fChain->SetBranchAddress("Electron_Py_gen", &Electron_Py_gen, &b_Electron_Py_gen);
297     fChain->SetBranchAddress("Electron_Pz_gen", &Electron_Pz_gen, &b_Electron_Pz_gen);
298     fChain->SetBranchAddress("Electron_E_gen", &Electron_E_gen, &b_Electron_E_gen);
299     fChain->SetBranchAddress("Electron_Charge_gen", &Electron_Charge_gen, &b_Electron_Charge_gen);
300 csander 1.1 fChain->SetBranchAddress("NPhoton", &NPhoton, &b_NPhoton);
301 csander 1.12 fChain->SetBranchAddress("Photon_Px", &Photon_Px, &b_Photon_Px);
302     fChain->SetBranchAddress("Photon_Py", &Photon_Py, &b_Photon_Py);
303     fChain->SetBranchAddress("Photon_Pz", &Photon_Pz, &b_Photon_Pz);
304     fChain->SetBranchAddress("Photon_E", &Photon_E, &b_Photon_E);
305     fChain->SetBranchAddress("Photon_Iso", &Photon_Iso, &b_Photon_Iso);
306     fChain->SetBranchAddress("Photon_Px_gen", &Photon_Px_gen, &b_Photon_Px_gen);
307     fChain->SetBranchAddress("Photon_Py_gen", &Photon_Py_gen, &b_Photon_Py_gen);
308     fChain->SetBranchAddress("Photon_Pz_gen", &Photon_Pz_gen, &b_Photon_Pz_gen);
309     fChain->SetBranchAddress("Photon_E_gen", &Photon_E_gen, &b_Photon_E_gen);
310     fChain->SetBranchAddress("NTau", &NTau, &b_NTau);
311     fChain->SetBranchAddress("Tau_Px", Tau_Px, &b_Tau_Px);
312     fChain->SetBranchAddress("Tau_Py", Tau_Py, &b_Tau_Py);
313     fChain->SetBranchAddress("Tau_Pz", Tau_Pz, &b_Tau_Pz);
314     fChain->SetBranchAddress("Tau_E", Tau_E, &b_Tau_E);
315     fChain->SetBranchAddress("Tau_ID", Tau_ID, &b_Tau_ID);
316     fChain->SetBranchAddress("Tau_Px_gen", Tau_Px_gen, &b_Tau_Px_gen);
317     fChain->SetBranchAddress("Tau_Py_gen", Tau_Py_gen, &b_Tau_Py_gen);
318     fChain->SetBranchAddress("Tau_Pz_gen", Tau_Pz_gen, &b_Tau_Pz_gen);
319     fChain->SetBranchAddress("Tau_E_gen", Tau_E_gen, &b_Tau_E_gen);
320     fChain->SetBranchAddress("NParton", &NParton, &b_NParton);
321     fChain->SetBranchAddress("Parton_Px", Parton_Px, &b_Parton_Px);
322     fChain->SetBranchAddress("Parton_Py", Parton_Py, &b_Parton_Py);
323     fChain->SetBranchAddress("Parton_Pz", Parton_Pz, &b_Parton_Pz);
324     fChain->SetBranchAddress("Parton_E", Parton_E, &b_Parton_E);
325     fChain->SetBranchAddress("Parton_Pid", Parton_Pid, &b_Parton_Pid);
326 csander 1.1 fChain->SetBranchAddress("MET_px", &MET_px, &b_MET_px);
327     fChain->SetBranchAddress("MET_py", &MET_py, &b_MET_py);
328 csander 1.12 fChain->SetBranchAddress("MET_px_gen", &MET_px_gen, &b_MET_px_gen);
329     fChain->SetBranchAddress("MET_py_gen", &MET_py_gen, &b_MET_py_gen);
330 csander 1.1 fChain->SetBranchAddress("NPrimaryVertices", &NPrimaryVertices, &b_NPrimaryVertices);
331 csander 1.12 fChain->SetBranchAddress("trigger", &trigger, &b_trigger);
332 csander 1.5 fChain->SetBranchAddress("EventWeight", &EventWeight, &b_EventWeight);
333 csander 1.12 fChain->SetBranchAddress("EventNumber", &EventNumber, &b_EventNumber);
334     fChain->SetBranchAddress("LumiNumber", &LumiNumber, &b_LumiNumber);
335     fChain->SetBranchAddress("RunNumber", &RunNumber, &b_RunNumber);
336 csander 1.3
337     TotalEvents = 0;
338 csander 1.1 }
339    
340     Bool_t MyAnalysis::Notify()
341     {
342     // The Notify() function is called when a new file is opened. This
343     // can be either for a new TTree in a TChain or when when a new TTree
344     // is started when using PROOF. It is normally not necessary to make changes
345     // to the generated code, but the routine can be extended by the
346     // user if needed. The return value is currently not used.
347    
348     return kTRUE;
349     }
350    
351     #endif // #ifdef MyAnalysis_cxx