ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/csander/HEPTutorial/MyAnalysis.h
Revision: 1.20
Committed: Fri Jun 29 13:44:57 2012 UTC (12 years, 10 months ago) by csander
Content type: text/plain
Branch: MAIN
Changes since 1.19: +322 -313 lines
Log Message:
Switched to v7, added MT

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 csander 1.20 public:
35     TTree *fChain; //!pointer to the analyzed TTree or TChain
36 csander 1.2
37 csander 1.20 // Declaration of leaf types
38     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[40]; //[NParton]
96     Float_t Parton_Py[40]; //[NParton]
97     Float_t Parton_Pz[40]; //[NParton]
98     Float_t Parton_E[40]; //[NParton]
99     Int_t Parton_Pid[40]; //[NParton]
100     Int_t Parton_No[40]; //[NParton]
101     Float_t MET_px;
102     Float_t MET_py;
103     Float_t MET_px_gen;
104     Float_t MET_py_gen;
105     Int_t NPrimaryVertices;
106     Bool_t trigger;
107     Float_t EventWeight;
108     Long_t EventNumber;
109     Int_t LumiNumber;
110     Int_t RunNumber;
111    
112     // List of branches
113     TBranch *b_NJet; //!
114     TBranch *b_Jet_Px; //!
115     TBranch *b_Jet_Py; //!
116     TBranch *b_Jet_Pz; //!
117     TBranch *b_Jet_E; //!
118     TBranch *b_Jet_btag; //!
119     TBranch *b_Jet_ID; //!
120     TBranch *b_Jet_Px_gen; //!
121     TBranch *b_Jet_Py_gen; //!
122     TBranch *b_Jet_Pz_gen; //!
123     TBranch *b_Jet_E_gen; //!
124     TBranch *b_Jet_Flavor_gen; //!
125     TBranch *b_NMuon; //!
126     TBranch *b_Muon_Px; //!
127     TBranch *b_Muon_Py; //!
128     TBranch *b_Muon_Pz; //!
129     TBranch *b_Muon_E; //!
130     TBranch *b_Muon_Charge; //!
131     TBranch *b_Muon_Iso; //!
132     TBranch *b_Muon_Px_gen; //!
133     TBranch *b_Muon_Py_gen; //!
134     TBranch *b_Muon_Pz_gen; //!
135     TBranch *b_Muon_E_gen; //!
136     TBranch *b_Muon_Charge_gen; //!
137     TBranch *b_NElectron; //!
138     TBranch *b_Electron_Px; //!
139     TBranch *b_Electron_Py; //!
140     TBranch *b_Electron_Pz; //!
141     TBranch *b_Electron_E; //!
142     TBranch *b_Electron_Charge; //!
143     TBranch *b_Electron_Iso; //!
144     TBranch *b_Electron_Px_gen; //!
145     TBranch *b_Electron_Py_gen; //!
146     TBranch *b_Electron_Pz_gen; //!
147     TBranch *b_Electron_E_gen; //!
148     TBranch *b_Electron_Charge_gen; //!
149     TBranch *b_NPhoton; //!
150     TBranch *b_Photon_Px; //!
151     TBranch *b_Photon_Py; //!
152     TBranch *b_Photon_Pz; //!
153     TBranch *b_Photon_E; //!
154     TBranch *b_Photon_Iso; //!
155     TBranch *b_Photon_Px_gen; //!
156     TBranch *b_Photon_Py_gen; //!
157     TBranch *b_Photon_Pz_gen; //!
158     TBranch *b_Photon_E_gen; //!
159     TBranch *b_NTau; //!
160     TBranch *b_Tau_Px; //!
161     TBranch *b_Tau_Py; //!
162     TBranch *b_Tau_Pz; //!
163     TBranch *b_Tau_E; //!
164     TBranch *b_Tau_ID; //!
165     TBranch *b_Tau_Px_gen; //!
166     TBranch *b_Tau_Py_gen; //!
167     TBranch *b_Tau_Pz_gen; //!
168     TBranch *b_Tau_E_gen; //!
169     TBranch *b_NParton; //!
170     TBranch *b_Parton_Px; //!
171     TBranch *b_Parton_Py; //!
172     TBranch *b_Parton_Pz; //!
173     TBranch *b_Parton_E; //!
174     TBranch *b_Parton_Pid; //!
175     TBranch *b_Parton_No; //!
176     TBranch *b_MET_px; //!
177     TBranch *b_MET_py; //!
178     TBranch *b_MET_px_gen; //!
179     TBranch *b_MET_py_gen; //!
180     TBranch *b_NPrimaryVertices; //!
181     TBranch *b_trigger; //!
182     TBranch *b_EventWeight; //!
183     TBranch *b_EventNumber; //!
184     TBranch *b_LumiNumber; //!
185     TBranch *b_RunNumber; //!
186    
187     MyAnalysis(bool is = false, float wf = 1., EventSelectorByList * el = 0, TTree * /*tree*/= 0) :
188     fChain(0) {
189     weight_factor = wf;
190     EventList = el;
191     isSUSY = is;
192     }
193     virtual ~MyAnalysis() {
194     }
195     virtual Int_t Version() const {
196     return 2;
197     }
198     virtual void Begin(TTree *tree);
199     virtual void SlaveBegin(TTree *tree);
200     virtual void Init(TTree *tree);
201     virtual Bool_t Notify();
202     virtual Bool_t Process(Long64_t entry);
203     virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0) {
204     return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0;
205     }
206     virtual void SetOption(const char *option) {
207     fOption = option;
208     }
209     virtual void SetObject(TObject *obj) {
210     fObject = obj;
211     }
212     virtual void SetInputList(TList *input) {
213     fInput = input;
214     }
215     virtual TList *GetOutputList() const {
216     return fOutput;
217     }
218     virtual void SlaveTerminate();
219     virtual void Terminate();
220    
221     void BuildEvent();
222    
223     int TotalEvents;
224     int TauEvents, TauEventsWithLeptons;
225     vector<MyJet> Jets;
226     vector<MyMuon> Muons;
227     vector<MyElectron> Electrons;
228     vector<MyPhoton> Photons;
229     vector<MyTau> Taus;
230     vector<MyParton> Partons;
231    
232     TLorentzVector met, genmet, MHT;
233     double HT;
234     int Jet_Mult;
235     int BJet_Mult;
236     int IsoEle_Mult;
237     int IsoMu_Mult;
238     double DeltaPhiJet1MHT, DeltaPhiJet2MHT, DeltaPhiJet3MHT;
239     bool hasBadJet, deltaPhiCut;
240    
241     double weight_factor;
242     bool isSUSY;
243    
244     TH1F *h_Mmumu;
245    
246     TH1F *h_NJet;
247     TH1F *h_NBJet;
248    
249     TH1F *h_Jet1_Pt, *h_Jet1_Eta;
250     TH1F *h_Jet2_Pt, *h_Jet2_Eta;
251     TH1F *h_Jet3_Pt, *h_Jet3_Eta;
252     TH1F *h_BJet1_Pt, *h_BJet1_Eta;
253     TH1F *h_BJet2_Pt, *h_BJet2_Eta;
254     TH1F *h_MET, *h_MHT, *h_HT;
255     TH1F *h_DeltaPhiJet1Jet2;
256     TH1F *h_DeltaPhiJet1MHT, *h_DeltaPhiJet2MHT, *h_DeltaPhiJet3MHT;
257     TH1F *h_Jet1OverHT, *h_Jet2OverHT, *h_Jet12OverHT;
258     TH1F *h_MHTOverHT;
259     TH1F *h_Muon1_Pt, *h_Electron1_Pt;
260     TH1F *h_Muon1_Iso, *h_Electron1_Iso;
261 csander 1.9
262 csander 1.20 vector<TH1F*> histograms;
263 csander 1.19
264 csander 1.20 EventSelectorByList* EventList;
265 csander 1.9
266 csander 1.1 };
267    
268     #endif
269    
270     #ifdef MyAnalysis_cxx
271     void MyAnalysis::Init(TTree *tree)
272     {
273 csander 1.20 // The Init() function is called when the selector needs to initialize
274     // a new tree or chain. Typically here the branch addresses and branch
275     // pointers of the tree will be set.
276     // It is normally not necessary to make changes to the generated
277     // code, but the routine can be extended by the user if needed.
278     // Init() will be called many times when running on PROOF
279     // (once per file to be processed).
280    
281     // Set branch addresses and branch pointers
282     if (!tree) return;
283     fChain = tree;
284     fChain->SetMakeClass(1);
285    
286     fChain->SetBranchAddress("NJet", &NJet, &b_NJet);
287     fChain->SetBranchAddress("Jet_Px", Jet_Px, &b_Jet_Px);
288     fChain->SetBranchAddress("Jet_Py", Jet_Py, &b_Jet_Py);
289     fChain->SetBranchAddress("Jet_Pz", Jet_Pz, &b_Jet_Pz);
290     fChain->SetBranchAddress("Jet_E", Jet_E, &b_Jet_E);
291     fChain->SetBranchAddress("Jet_btag", Jet_btag, &b_Jet_btag);
292     fChain->SetBranchAddress("Jet_ID", Jet_ID, &b_Jet_ID);
293     fChain->SetBranchAddress("Jet_Px_gen", Jet_Px_gen, &b_Jet_Px_gen);
294     fChain->SetBranchAddress("Jet_Py_gen", Jet_Py_gen, &b_Jet_Py_gen);
295     fChain->SetBranchAddress("Jet_Pz_gen", Jet_Pz_gen, &b_Jet_Pz_gen);
296     fChain->SetBranchAddress("Jet_E_gen", Jet_E_gen, &b_Jet_E_gen);
297     fChain->SetBranchAddress("Jet_Flavor_gen", Jet_Flavor_gen, &b_Jet_Flavor_gen);
298     fChain->SetBranchAddress("NMuon", &NMuon, &b_NMuon);
299     fChain->SetBranchAddress("Muon_Px", &Muon_Px, &b_Muon_Px);
300     fChain->SetBranchAddress("Muon_Py", &Muon_Py, &b_Muon_Py);
301     fChain->SetBranchAddress("Muon_Pz", &Muon_Pz, &b_Muon_Pz);
302     fChain->SetBranchAddress("Muon_E", &Muon_E, &b_Muon_E);
303     fChain->SetBranchAddress("Muon_Charge", &Muon_Charge, &b_Muon_Charge);
304     fChain->SetBranchAddress("Muon_Iso", &Muon_Iso, &b_Muon_Iso);
305     fChain->SetBranchAddress("Muon_Px_gen", &Muon_Px_gen, &b_Muon_Px_gen);
306     fChain->SetBranchAddress("Muon_Py_gen", &Muon_Py_gen, &b_Muon_Py_gen);
307     fChain->SetBranchAddress("Muon_Pz_gen", &Muon_Pz_gen, &b_Muon_Pz_gen);
308     fChain->SetBranchAddress("Muon_E_gen", &Muon_E_gen, &b_Muon_E_gen);
309     fChain->SetBranchAddress("Muon_Charge_gen", &Muon_Charge_gen, &b_Muon_Charge_gen);
310     fChain->SetBranchAddress("NElectron", &NElectron, &b_NElectron);
311     fChain->SetBranchAddress("Electron_Px", &Electron_Px, &b_Electron_Px);
312     fChain->SetBranchAddress("Electron_Py", &Electron_Py, &b_Electron_Py);
313     fChain->SetBranchAddress("Electron_Pz", &Electron_Pz, &b_Electron_Pz);
314     fChain->SetBranchAddress("Electron_E", &Electron_E, &b_Electron_E);
315     fChain->SetBranchAddress("Electron_Charge", &Electron_Charge, &b_Electron_Charge);
316     fChain->SetBranchAddress("Electron_Iso", &Electron_Iso, &b_Electron_Iso);
317     fChain->SetBranchAddress("Electron_Px_gen", &Electron_Px_gen, &b_Electron_Px_gen);
318     fChain->SetBranchAddress("Electron_Py_gen", &Electron_Py_gen, &b_Electron_Py_gen);
319     fChain->SetBranchAddress("Electron_Pz_gen", &Electron_Pz_gen, &b_Electron_Pz_gen);
320     fChain->SetBranchAddress("Electron_E_gen", &Electron_E_gen, &b_Electron_E_gen);
321     fChain->SetBranchAddress("Electron_Charge_gen", &Electron_Charge_gen, &b_Electron_Charge_gen);
322     fChain->SetBranchAddress("NPhoton", &NPhoton, &b_NPhoton);
323     fChain->SetBranchAddress("Photon_Px", &Photon_Px, &b_Photon_Px);
324     fChain->SetBranchAddress("Photon_Py", &Photon_Py, &b_Photon_Py);
325     fChain->SetBranchAddress("Photon_Pz", &Photon_Pz, &b_Photon_Pz);
326     fChain->SetBranchAddress("Photon_E", &Photon_E, &b_Photon_E);
327     fChain->SetBranchAddress("Photon_Iso", &Photon_Iso, &b_Photon_Iso);
328     fChain->SetBranchAddress("Photon_Px_gen", &Photon_Px_gen, &b_Photon_Px_gen);
329     fChain->SetBranchAddress("Photon_Py_gen", &Photon_Py_gen, &b_Photon_Py_gen);
330     fChain->SetBranchAddress("Photon_Pz_gen", &Photon_Pz_gen, &b_Photon_Pz_gen);
331     fChain->SetBranchAddress("Photon_E_gen", &Photon_E_gen, &b_Photon_E_gen);
332     fChain->SetBranchAddress("NTau", &NTau, &b_NTau);
333     fChain->SetBranchAddress("Tau_Px", Tau_Px, &b_Tau_Px);
334     fChain->SetBranchAddress("Tau_Py", Tau_Py, &b_Tau_Py);
335     fChain->SetBranchAddress("Tau_Pz", Tau_Pz, &b_Tau_Pz);
336     fChain->SetBranchAddress("Tau_E", Tau_E, &b_Tau_E);
337     fChain->SetBranchAddress("Tau_ID", Tau_ID, &b_Tau_ID);
338     fChain->SetBranchAddress("Tau_Px_gen", Tau_Px_gen, &b_Tau_Px_gen);
339     fChain->SetBranchAddress("Tau_Py_gen", Tau_Py_gen, &b_Tau_Py_gen);
340     fChain->SetBranchAddress("Tau_Pz_gen", Tau_Pz_gen, &b_Tau_Pz_gen);
341     fChain->SetBranchAddress("Tau_E_gen", Tau_E_gen, &b_Tau_E_gen);
342     fChain->SetBranchAddress("NParton", &NParton, &b_NParton);
343     fChain->SetBranchAddress("Parton_Px", Parton_Px, &b_Parton_Px);
344     fChain->SetBranchAddress("Parton_Py", Parton_Py, &b_Parton_Py);
345     fChain->SetBranchAddress("Parton_Pz", Parton_Pz, &b_Parton_Pz);
346     fChain->SetBranchAddress("Parton_E", Parton_E, &b_Parton_E);
347     fChain->SetBranchAddress("Parton_Pid", Parton_Pid, &b_Parton_Pid);
348     if (isSUSY)
349     fChain->SetBranchAddress("Parton_No", Parton_No, &b_Parton_No);
350     fChain->SetBranchAddress("MET_px", &MET_px, &b_MET_px);
351     fChain->SetBranchAddress("MET_py", &MET_py, &b_MET_py);
352     fChain->SetBranchAddress("MET_px_gen", &MET_px_gen, &b_MET_px_gen);
353     fChain->SetBranchAddress("MET_py_gen", &MET_py_gen, &b_MET_py_gen);
354     fChain->SetBranchAddress("NPrimaryVertices", &NPrimaryVertices, &b_NPrimaryVertices);
355     fChain->SetBranchAddress("trigger", &trigger, &b_trigger);
356     fChain->SetBranchAddress("EventWeight", &EventWeight, &b_EventWeight);
357     fChain->SetBranchAddress("EventNumber", &EventNumber, &b_EventNumber);
358     fChain->SetBranchAddress("LumiNumber", &LumiNumber, &b_LumiNumber);
359     fChain->SetBranchAddress("RunNumber", &RunNumber, &b_RunNumber);
360 csander 1.3
361 csander 1.20 TotalEvents = 0;
362 csander 1.1 }
363    
364     Bool_t MyAnalysis::Notify()
365     {
366 csander 1.20 // The Notify() function is called when a new file is opened. This
367     // can be either for a new TTree in a TChain or when when a new TTree
368     // is started when using PROOF. It is normally not necessary to make changes
369     // to the generated code, but the routine can be extended by the
370     // user if needed. The return value is currently not used.
371 csander 1.1
372 csander 1.20 return kTRUE;
373 csander 1.1 }
374    
375     #endif // #ifdef MyAnalysis_cxx