ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TreeMod/src/FullExample.cc
Revision: 1.3
Committed: Wed Jun 11 23:37:20 2008 UTC (16 years, 11 months ago) by paus
Content type: text/plain
Branch: MAIN
Changes since 1.2: +5 -5 lines
Log Message:
Minor cleanup.

File Contents

# User Rev Content
1 paus 1.3 // $Id: FullExample.cc,v 1.2 2008/06/09 11:47:03 paus Exp $
2 bendavid 1.1
3     #include "MitAna/TreeMod/interface/FullExampleMod.h"
4     #include <TH1D.h>
5     #include "MitAna/DataTree/interface/Names.h"
6    
7     using namespace mithep;
8    
9     ClassImp(mithep::FullExampleMod)
10    
11     //__________________________________________________________________________________________________
12     FullExampleMod::FullExampleMod(const char *name, const char *title)
13     : TAModule(name,title),
14     fParticles(0),
15     fTracks(0),
16     fMuons(0),
17     fElectrons(0),
18     fGenPartName(Names::gkGenPartBrn),
19     fTrackName(Names::gkTrackBrn),
20     fMuonName(Names::gkMuonBrn),
21     fElectronName(Names::gkElectronBrn),
22     fGenPtHist(0),
23     fGenEtaHist(0),
24     fTrackPtHist(0),
25     fMuonPtHist(0),
26     fMuonEtaHist(0),
27     fMuonTrackPtHist(0),
28     fMuonTrackPtErrHist(0),
29     fElectronPtHist(0)
30     {
31     // Constructor.
32     }
33    
34     //__________________________________________________________________________________________________
35     void FullExampleMod::Begin()
36     {
37 paus 1.2 // Run startup code on the client machine. For this module, we dont do
38     // anything here.
39 bendavid 1.1 }
40    
41     //__________________________________________________________________________________________________
42     void FullExampleMod::Process()
43     {
44 paus 1.2 // Process entries of the tree. For this module, we just load the branch and
45     // fill the histograms.
46 bendavid 1.1
47     LoadBranch(fGenPartName);
48 paus 1.3 for (UInt_t i=0; i<fParticles->GetEntries(); ++i) {
49 paus 1.2 GenParticle* p = fParticles->At(i);
50     fGenPtHist->Fill(p->Pt());
51     fGenEtaHist->Fill(p->Eta());
52 bendavid 1.1 }
53    
54     LoadBranch(fTrackName);
55 paus 1.3 for (UInt_t i=0; i<fTracks->GetEntries(); ++i) {
56 paus 1.2 Track* p = fTracks->At(i);
57     fTrackPtHist->Fill(p->Pt());
58 bendavid 1.1 }
59    
60     LoadBranch(fMuonName);
61 paus 1.3 for (UInt_t i=0; i<fMuons->GetEntries(); ++i) {
62 paus 1.2 Muon *p = fMuons->At(i);
63     fMuonPtHist->Fill(p->Pt());
64     fMuonEtaHist->Fill(p->Eta());
65     fMuonTrackPtHist->Fill(p->GetTrack()->Pt());
66     fMuonTrackPtErrHist->Fill(p->GetTrack()->PtErr());
67 bendavid 1.1 }
68    
69    
70     LoadBranch(fElectronName);
71 paus 1.3 for (UInt_t i=0; i<fElectrons->GetEntries(); ++i) {
72 paus 1.2 Electron *p = fElectrons->At(i);
73     fElectronPtHist->Fill(p->Pt());
74 bendavid 1.1 }
75    
76     }
77    
78     //__________________________________________________________________________________________________
79     void FullExampleMod::SlaveBegin()
80     {
81 paus 1.2 // Run startup code on the computer (slave) doing the actual analysis. Here,
82     // we typically initialize histograms and other analysis objects and request
83     // branches. For this module, we request a branch of the MitTree.
84    
85     ReqBranch(fGenPartName, fParticles);
86     ReqBranch(fTrackName, fTracks);
87     ReqBranch(fMuonName, fMuons);
88 bendavid 1.1 ReqBranch(fElectronName, fElectrons);
89    
90 paus 1.2 fGenPtHist = new TH1D("hGenPtHist",";p_{t};#",100,0.,25.);
91 bendavid 1.1 AddOutput(fGenPtHist);
92 paus 1.2 fGenEtaHist = new TH1D("hGenEtaHist",";#eta;#",160,-8.,8.);
93 bendavid 1.1 AddOutput(fGenEtaHist);
94    
95 paus 1.2 fTrackPtHist = new TH1D("hTrackPtHist",";p_{t};#",100,0.,25.);
96 bendavid 1.1 AddOutput(fTrackPtHist);
97    
98 paus 1.2 fMuonPtHist = new TH1D("hMuonPtHist",";p_{t};#",100,0.,25.);
99 bendavid 1.1 AddOutput(fMuonPtHist);
100 paus 1.2 fMuonEtaHist = new TH1D("hMuonEtaHist",";#eta;#",160,-8.,8.);
101 bendavid 1.1 AddOutput(fMuonEtaHist);
102    
103 paus 1.2 fMuonTrackPtHist = new TH1D("hMuonTrackPtHist",";p_{t};#",100,0.,25.);
104 bendavid 1.1 AddOutput(fMuonTrackPtHist);
105     fMuonTrackPtErrHist = new TH1D("hMuonTrackPtErrHist",";p_{t};#",100,0.,25.);
106     AddOutput(fMuonTrackPtErrHist);
107    
108 paus 1.2 fElectronPtHist = new TH1D("hElectronPtHist",";p_{t};#",100,0.,25.);
109 bendavid 1.1 AddOutput(fElectronPtHist);
110     }
111    
112     //__________________________________________________________________________________________________
113     void FullExampleMod::SlaveTerminate()
114     {
115 paus 1.2 // Run finishing code on the computer (slave) that did the analysis. For this
116     // module, we dont do anything here.
117 bendavid 1.1 }
118    
119     //__________________________________________________________________________________________________
120     void FullExampleMod::Terminate()
121     {
122 paus 1.2 // Run finishing code on the client computer. For this module, we dont do
123     // anything here.
124 bendavid 1.1 }