ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TreeMod/src/ParticleExample.cc
Revision: 1.1
Committed: Tue May 27 19:50:16 2008 UTC (16 years, 11 months ago) by loizides
Content type: text/plain
Branch: MAIN
Log Message:
First import of TreeModules.

File Contents

# User Rev Content
1 loizides 1.1 // $Id: THIExampleAnaMod.h 4354 2007-08-17 20:24:57Z loizides $
2    
3     #include "MitAna/TreeMod/interface/ParticleExampleMod.h"
4     #include <TH1D.h>
5    
6     using namespace mithep;
7    
8     ClassImp(mithep::ParticleExampleMod)
9    
10     //__________________________________________________________________________________________________
11     ParticleExampleMod::ParticleExampleMod(const char *name, const char *title)
12     : TAModule(name,title),
13     fParticles(0),
14     fPartName("Particles"),
15     fPtHist(0),
16     fEtaHist(0)
17     {
18     // Constructor.
19     }
20    
21     //__________________________________________________________________________________________________
22     void ParticleExampleMod::Begin()
23     {
24     // Run startup code on the client machine. For this module, we dont
25     // do anything here.
26     }
27    
28     //__________________________________________________________________________________________________
29     void ParticleExampleMod::Process()
30     {
31     // Process entries of the tree. For this module, we just load
32     // the branch and fill the histograms.
33    
34     LoadBranch(GetPartName());
35    
36     Int_t ents=fParticles->GetEntries();
37     for(Int_t i=0;i<ents;++i) {
38     Particle &p = fParticles->At(i);
39     fPtHist->Fill(p.Pt());
40     fEtaHist->Fill(p.Eta());
41     }
42    
43     }
44    
45     //__________________________________________________________________________________________________
46     void ParticleExampleMod::SlaveBegin()
47     {
48     // Run startup code on the computer (slave) doing the actual
49     // analysis. Here, we typically initialize histograms and
50     // other analysis objects and request branches. For this module,
51     // we request a branch of the MitTree.
52    
53     ReqBranch(GetPartName(), fParticles);
54    
55     fPtHist = new TH1D("hPtHist",";p_{t};#",100,0.,25.);
56     AddOutput(fPtHist);
57     fEtaHist = new TH1D("hEtaHist",";#eta;#",160,-8.,8.);
58     AddOutput(fEtaHist);
59     }
60    
61     //__________________________________________________________________________________________________
62     void ParticleExampleMod::SlaveTerminate()
63     {
64     // Run finishing code on the computer (slave) that did the
65     // analysis. For this module, we dont do anything here.
66     }
67    
68     //__________________________________________________________________________________________________
69     void ParticleExampleMod::Terminate()
70     {
71     // Run finishing code on the client computer.
72     // For this module, we dont do anything here.
73     }