ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TreeMod/src/FullExample.cc
Revision: 1.1
Committed: Mon Jun 9 00:06:36 2008 UTC (16 years, 11 months ago) by bendavid
Content type: text/plain
Branch: MAIN
Log Message:
adherance to coding conventions, reverted ParticleExample, new full chain example

File Contents

# User Rev Content
1 bendavid 1.1 // $Id: ParticleExample.cc,v 1.5 2008/06/05 16:03:35 bendavid Exp $
2    
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     // Run startup code on the client machine. For this module, we dont
38     // do anything here.
39     }
40    
41     //__________________________________________________________________________________________________
42     void FullExampleMod::Process()
43     {
44     // Process entries of the tree. For this module, we just load
45     // the branch and fill the histograms.
46    
47     LoadBranch(fGenPartName);
48     for(Int_t i=0;i<fParticles->GetEntries();++i) {
49     GenParticle* p = fParticles->At(i);
50     fGenPtHist->Fill(p->Pt());
51     fGenEtaHist->Fill(p->Eta());
52     }
53    
54     LoadBranch(fTrackName);
55     for(Int_t i=0;i<fTracks->GetEntries();++i) {
56     Track* p = fTracks->At(i);
57     fTrackPtHist->Fill(p->Pt());
58     }
59    
60     LoadBranch(fMuonName);
61     for(Int_t i=0;i<fMuons->GetEntries();++i) {
62     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     }
68    
69    
70     LoadBranch(fElectronName);
71     for(Int_t i=0;i<fElectrons->GetEntries();++i) {
72     Electron *p = fElectrons->At(i);
73     fElectronPtHist->Fill(p->Pt());
74     }
75    
76     }
77    
78     //__________________________________________________________________________________________________
79     void FullExampleMod::SlaveBegin()
80     {
81     // Run startup code on the computer (slave) doing the actual
82     // analysis. Here, we typically initialize histograms and
83     // other analysis objects and request branches. For this module,
84     // we request a branch of the MitTree.
85    
86     ReqBranch(fGenPartName, fParticles);
87     ReqBranch(fTrackName, fTracks);
88     ReqBranch(fMuonName, fMuons);
89     ReqBranch(fElectronName, fElectrons);
90    
91     fGenPtHist = new TH1D("hGenPtHist",";p_{t};#",100,0.,25.);
92     AddOutput(fGenPtHist);
93     fGenEtaHist = new TH1D("hGenEtaHist",";#eta;#",160,-8.,8.);
94     AddOutput(fGenEtaHist);
95    
96     fTrackPtHist = new TH1D("hTrackPtHist",";p_{t};#",100,0.,25.);
97     AddOutput(fTrackPtHist);
98    
99     fMuonPtHist = new TH1D("hMuonPtHist",";p_{t};#",100,0.,25.);
100     AddOutput(fMuonPtHist);
101     fMuonEtaHist = new TH1D("hMuonEtaHist",";#eta;#",160,-8.,8.);
102     AddOutput(fMuonEtaHist);
103    
104     fMuonTrackPtHist = new TH1D("hMuonTrackPtHist",";p_{t};#",100,0.,25.);
105     AddOutput(fMuonTrackPtHist);
106     fMuonTrackPtErrHist = new TH1D("hMuonTrackPtErrHist",";p_{t};#",100,0.,25.);
107     AddOutput(fMuonTrackPtErrHist);
108    
109     fElectronPtHist = new TH1D("hElectronPtHist",";p_{t};#",100,0.,25.);
110     AddOutput(fElectronPtHist);
111     }
112    
113     //__________________________________________________________________________________________________
114     void FullExampleMod::SlaveTerminate()
115     {
116     // Run finishing code on the computer (slave) that did the
117     // analysis. For this module, we dont do anything here.
118     }
119    
120     //__________________________________________________________________________________________________
121     void FullExampleMod::Terminate()
122     {
123     // Run finishing code on the client computer.
124     // For this module, we dont do anything here.
125     }