ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TreeMod/src/FullExampleMod.cc
Revision: 1.4
Committed: Fri Jul 25 11:34:46 2008 UTC (16 years, 9 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_006, Mit_005, Mit_004, MITHEP_2_0_x
Changes since 1.3: +13 -13 lines
Log Message:
Updated examples to work with merged gen-sim information

File Contents

# User Rev Content
1 bendavid 1.4 // $Id: FullExampleMod.cc,v 1.3 2008/07/03 08:22:19 loizides Exp $
2 loizides 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 loizides 1.3 //--------------------------------------------------------------------------------------------------
12 loizides 1.2 FullExampleMod::FullExampleMod(const char *name, const char *title) :
13     BaseMod(name,title),
14 bendavid 1.4 fMCPartName(Names::gkMCPartBrn),
15 loizides 1.2 fTrackName(Names::gkTrackBrn),
16     fMuonName(Names::gkMuonBrn),
17     fElectronName(Names::gkElectronBrn),
18     fParticles(0),
19     fTracks(0),
20     fMuons(0),
21     fElectrons(0),
22 bendavid 1.4 fMCPtHist(0),
23     fMCEtaHist(0),
24 loizides 1.2 fTrackPtHist(0),
25     fTrackEtaHist(0),
26     fMuonPtHist(0),
27     fMuonEtaHist(0),
28     fElectronPtHist(0),
29     fElectronEtaHist(0)
30 loizides 1.1 {
31     // Constructor.
32     }
33    
34 loizides 1.3 //--------------------------------------------------------------------------------------------------
35 loizides 1.1 void FullExampleMod::Begin()
36     {
37     // Run startup code on the client machine. For this module, we dont do
38     // anything here.
39     }
40    
41 loizides 1.3 //--------------------------------------------------------------------------------------------------
42 loizides 1.1 void FullExampleMod::Process()
43     {
44 loizides 1.2 // Process entries of the tree. For this module, we just load the branches and
45 loizides 1.1 // fill the histograms.
46    
47 bendavid 1.4 LoadBranch(fMCPartName);
48 loizides 1.1 for (UInt_t i=0; i<fParticles->GetEntries(); ++i) {
49 bendavid 1.4 MCParticle* p = fParticles->At(i);
50     fMCPtHist->Fill(p->Pt());
51     fMCEtaHist->Fill(p->Eta());
52 loizides 1.1 }
53    
54     LoadBranch(fTrackName);
55     for (UInt_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 (UInt_t i=0; i<fMuons->GetEntries(); ++i) {
62     Muon *p = fMuons->At(i);
63     fMuonPtHist->Fill(p->Pt());
64     fMuonEtaHist->Fill(p->Eta());
65     }
66    
67     LoadBranch(fElectronName);
68     for (UInt_t i=0; i<fElectrons->GetEntries(); ++i) {
69     Electron *p = fElectrons->At(i);
70     fElectronPtHist->Fill(p->Pt());
71 loizides 1.2 fElectronEtaHist->Fill(p->Eta());
72 loizides 1.1 }
73    
74     }
75    
76 loizides 1.3 //--------------------------------------------------------------------------------------------------
77 loizides 1.1 void FullExampleMod::SlaveBegin()
78     {
79     // Run startup code on the computer (slave) doing the actual analysis. Here,
80     // we typically initialize histograms and other analysis objects and request
81     // branches. For this module, we request a branch of the MitTree.
82    
83 bendavid 1.4 ReqBranch(fMCPartName, fParticles);
84 loizides 1.1 ReqBranch(fTrackName, fTracks);
85     ReqBranch(fMuonName, fMuons);
86     ReqBranch(fElectronName, fElectrons);
87    
88 bendavid 1.4 fMCPtHist = new TH1D("hMCPtHist",";p_{t};#",100,0.,25.);
89     AddOutput(fMCPtHist);
90     fMCEtaHist = new TH1D("hMCEtaHist",";#eta;#",160,-8.,8.);
91     AddOutput(fMCEtaHist);
92 loizides 1.1 fTrackPtHist = new TH1D("hTrackPtHist",";p_{t};#",100,0.,25.);
93     AddOutput(fTrackPtHist);
94 loizides 1.2 fTrackEtaHist = new TH1D("hTrakEtaHist",";#eta;#",160,-8.,8.);
95     AddOutput(fTrackEtaHist);
96 loizides 1.1 fMuonPtHist = new TH1D("hMuonPtHist",";p_{t};#",100,0.,25.);
97     AddOutput(fMuonPtHist);
98     fMuonEtaHist = new TH1D("hMuonEtaHist",";#eta;#",160,-8.,8.);
99     AddOutput(fMuonEtaHist);
100     fElectronPtHist = new TH1D("hElectronPtHist",";p_{t};#",100,0.,25.);
101     AddOutput(fElectronPtHist);
102 loizides 1.2 fElectronEtaHist = new TH1D("hElectronEtaHist",";#eta;#",160,-8.,8.);
103     AddOutput(fElectronEtaHist);
104 loizides 1.1 }
105    
106 loizides 1.3 //--------------------------------------------------------------------------------------------------
107 loizides 1.1 void FullExampleMod::SlaveTerminate()
108     {
109     // Run finishing code on the computer (slave) that did the analysis. For this
110     // module, we dont do anything here.
111     }
112    
113 loizides 1.3 //--------------------------------------------------------------------------------------------------
114 loizides 1.1 void FullExampleMod::Terminate()
115     {
116     // Run finishing code on the client computer. For this module, we dont do
117     // anything here.
118     }