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

File Contents

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