ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/PhysicsMod/interface/PlotKineMod.h
Revision: 1.4
Committed: Wed Dec 10 16:29:30 2008 UTC (16 years, 4 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.3: +3 -5 lines
Log Message:
Cleanup

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: PlotKineMod.h,v 1.3 2008/12/09 10:18:33 loizides Exp $
3 //
4 // PlotKineMod
5 //
6 // This module allows one to quickly plot eta and pt distribution of a given particle.
7 //
8 // Authors: C.Loizides
9 //--------------------------------------------------------------------------------------------------
10
11 #ifndef MITANA_PHYSICSMOD_PLOTKINEMOD_H
12 #define MITANA_PHYSICSMOD_PLOTKINEMOD_H
13
14 #include "MitAna/TreeMod/interface/BaseMod.h"
15 #include "MitAna/DataTree/interface/Collections.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 ~PlotKineMod() {}
27
28 const char *GetColName() const { return fColName; }
29 Double_t GetEtaMin() const { return fEtaMin; }
30 Double_t GetEtaMax() const { return fEtaMax; }
31 Double_t GetPtMin() const { return fPtMin; }
32 Double_t GetPtMax() const { return fPtMax; }
33 Bool_t GetLoadBranch() const { return fLoadBr; }
34 void SetColName(const char *n) { fColName=n; }
35 void SetEtaMin(Double_t e) { fEtaMin = e; }
36 void SetEtaMax(Double_t e) { fEtaMax = e; }
37 void SetLoadBranch(Bool_t b) { fLoadBr = b; }
38 void SetPtMin(Double_t pt) { fPtMin = pt; }
39 void SetPtMax(Double_t pt) { fPtMax = pt; }
40
41 protected:
42 Bool_t Load();
43 void Process();
44 void SlaveBegin();
45
46 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 Bool_t fLoadBr; //=true then load branch (def=1)
52 const Collection<T> *fCol; //!pointer to collection
53 TH1D *fPtHist; //!pt histogram
54 TH1D *fEtaHist; //!eta histogram
55
56 ClassDefT(PlotKineMod,1) // Plot kinematics module
57 };
58 }
59
60 //--------------------------------------------------------------------------------------------------
61 template<class T>
62 mithep::PlotKineMod<T>::PlotKineMod(const char *name, const char *title) :
63 BaseMod(name,title),
64 fColName("SetMe"),
65 fPtMin(1),
66 fPtMax(5000),
67 fEtaMin(-10),
68 fEtaMax(10),
69 fLoadBr(kTRUE),
70 fCol(0),
71 fPtHist(0),
72 fEtaHist(0)
73 {
74 // Constructor.
75
76 SetFillHist(1);
77 }
78
79 //--------------------------------------------------------------------------------------------------
80 template<class T>
81 Bool_t mithep::PlotKineMod<T>::Load()
82 {
83 // Load data from branch or get pointer from event.
84
85 if (GetLoadBranch())
86 LoadBranch(GetColName());
87 else
88 fCol = GetObjThisEvt<Collection<T> >(GetColName());
89
90 return (fCol!=0);
91 }
92
93 //--------------------------------------------------------------------------------------------------
94 template<class T>
95 void mithep::PlotKineMod<T>::Process()
96 {
97 // Process entries of the tree: Just load the branch and fill the histograms.
98
99 if (!Load()) {
100 SendError(kAbortModule, "Process", "Could not load data!");
101 return;
102 }
103
104 if (!GetFillHist())
105 return;
106
107 UInt_t ents=fCol->GetEntries();
108 for(UInt_t i=0;i<ents;++i) {
109 const T *p = fCol->At(i);
110 Double_t pt = p->Pt();
111 if (pt<fPtMin)
112 continue;
113 if (pt>fPtMax)
114 continue;
115 Double_t eta = p->Eta();
116 if (eta<fEtaMin)
117 continue;
118 if (eta>fEtaMax)
119 continue;
120 fPtHist->Fill(pt);
121 fEtaHist->Fill(eta);
122 }
123 }
124
125 //--------------------------------------------------------------------------------------------------
126 template<class T>
127 void mithep::PlotKineMod<T>::SlaveBegin()
128 {
129 // Request a branch and create the histograms.
130
131 if (GetLoadBranch())
132 ReqBranch(GetColName(), fCol);
133
134 if (GetFillHist()) {
135 AddTH1(fPtHist,"hPtHist",";p_{t} [GeV];#",100,0.,250.);
136 AddTH1(fEtaHist,"hEtaHist",";#eta;#",160,-8.,8.);
137 }
138 }
139 #endif