ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/PhysicsMod/interface/PlotKineMod.h
Revision: 1.11
Committed: Mon Jun 15 15:00:16 2009 UTC (15 years, 10 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_009b
Changes since 1.10: +2 -2 lines
Log Message:
Added proper fwd defs plus split up complilation of MitAna/DataTree LinkDefs.

File Contents

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2 loizides 1.11 // $Id: PlotKineMod.h,v 1.10 2009/05/19 10:27:21 loizides Exp $
3 loizides 1.1 //
4     // PlotKineMod
5     //
6 loizides 1.3 // This module allows one to quickly plot eta and pt distribution of a given particle.
7 loizides 1.1 //
8     // Authors: C.Loizides
9     //--------------------------------------------------------------------------------------------------
10    
11     #ifndef MITANA_PHYSICSMOD_PLOTKINEMOD_H
12     #define MITANA_PHYSICSMOD_PLOTKINEMOD_H
13    
14 loizides 1.11 #include "MitAna/DataCont/interface/Collection.h"
15 loizides 1.1 #include "MitAna/TreeMod/interface/BaseMod.h"
16     #include <TH1D.h>
17    
18     namespace mithep
19     {
20     template<class T>
21     class PlotKineMod : public BaseMod
22     {
23     public:
24     PlotKineMod(const char *name="PlotKineMod",
25     const char *title="Plot kinematics module");
26    
27 loizides 1.5 const char *GetColName() const { return fColName; }
28     Double_t GetEtaMin() const { return fEtaMin; }
29     Double_t GetEtaMax() const { return fEtaMax; }
30     const char *GetInputName() const { return GetColName(); }
31     Double_t GetPtMin() const { return fPtMin; }
32     Double_t GetPtMax() const { return fPtMax; }
33     void SetColName(const char *n) { fColName=n; }
34 loizides 1.9 void SetEntriesMax(Int_t e) { fEntriesMax = e; }
35 loizides 1.5 void SetEtaMin(Double_t e) { fEtaMin = e; }
36     void SetEtaMax(Double_t e) { fEtaMax = e; }
37     void SetInputName(const char *n) { SetColName(n); }
38     void SetPtMin(Double_t pt) { fPtMin = pt; }
39     void SetPtMax(Double_t pt) { fPtMax = pt; }
40 loizides 1.1
41     protected:
42 loizides 1.3 Bool_t Load();
43     void Process();
44     void SlaveBegin();
45    
46 loizides 1.1 TString fColName; //name of collection
47     Double_t fPtMin; //minimum pt
48     Double_t fPtMax; //maximum pt
49     Double_t fEtaMin; //minimum eta
50     Double_t fEtaMax; //maximum eta
51 loizides 1.9 Int_t fEntriesMax; //maximum number of entries
52 loizides 1.2 const Collection<T> *fCol; //!pointer to collection
53 loizides 1.1 TH1D *fPtHist; //!pt histogram
54     TH1D *fEtaHist; //!eta histogram
55 loizides 1.9 TH1D *fEntHist; //!entries histogram
56 loizides 1.1
57 loizides 1.6 ClassDefT(PlotKineMod, 1) // Plot kinematics module
58 loizides 1.1 };
59     }
60    
61     //--------------------------------------------------------------------------------------------------
62     template<class T>
63     mithep::PlotKineMod<T>::PlotKineMod(const char *name, const char *title) :
64     BaseMod(name,title),
65     fColName("SetMe"),
66     fPtMin(1),
67     fPtMax(5000),
68     fEtaMin(-10),
69     fEtaMax(10),
70 loizides 1.9 fEntriesMax(250),
71 loizides 1.1 fCol(0),
72     fPtHist(0),
73 loizides 1.9 fEtaHist(0),
74     fEntHist(0)
75 loizides 1.1 {
76     // Constructor.
77 loizides 1.3
78 loizides 1.9 SetFillHist(kTRUE);
79 loizides 1.3 }
80    
81     //--------------------------------------------------------------------------------------------------
82     template<class T>
83 loizides 1.1 void mithep::PlotKineMod<T>::Process()
84     {
85     // Process entries of the tree: Just load the branch and fill the histograms.
86    
87 loizides 1.10 if (!LoadEventObject(GetColName(), fCol)) {
88 loizides 1.4 SendError(kAbortModule, "Process", "Could not load data!");
89 loizides 1.3 return;
90     }
91    
92     if (!GetFillHist())
93     return;
94 loizides 1.2
95 loizides 1.3 UInt_t ents=fCol->GetEntries();
96 loizides 1.9 fEntHist->Fill(ents);
97 loizides 1.3 for(UInt_t i=0;i<ents;++i) {
98 loizides 1.2 const T *p = fCol->At(i);
99 loizides 1.1 Double_t pt = p->Pt();
100     if (pt<fPtMin)
101     continue;
102     if (pt>fPtMax)
103     continue;
104     Double_t eta = p->Eta();
105     if (eta<fEtaMin)
106     continue;
107     if (eta>fEtaMax)
108     continue;
109     fPtHist->Fill(pt);
110     fEtaHist->Fill(eta);
111     }
112     }
113    
114     //--------------------------------------------------------------------------------------------------
115     template<class T>
116     void mithep::PlotKineMod<T>::SlaveBegin()
117     {
118     // Request a branch and create the histograms.
119 loizides 1.6
120 loizides 1.10 ReqEventObject(GetColName(), fCol);
121 loizides 1.1
122 loizides 1.3 if (GetFillHist()) {
123 loizides 1.7 Int_t ptbins = (Int_t)((fPtMax-fPtMin)/2.5);
124     AddTH1(fPtHist,"hPtHist",";p_{t} [GeV];#",ptbins,fPtMin,fPtMax);
125     Int_t etabins = (Int_t)((fEtaMax-fEtaMin)/0.1);
126     AddTH1(fEtaHist,"hEtaHist",";#eta;#",etabins,fEtaMin,fEtaMax);
127 loizides 1.9 AddTH1(fEntHist,"hEntriesHist",";#entries;#",fEntriesMax,-0.5,fEntriesMax-0.5);
128 loizides 1.3 }
129 loizides 1.1 }
130     #endif