ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/PhysicsMod/interface/PlotKineMod.h
Revision: 1.12
Committed: Wed Jun 17 11:50:27 2009 UTC (15 years, 10 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_009c
Changes since 1.11: +2 -2 lines
Log Message:
use templateClassImp everywhere

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: PlotKineMod.h,v 1.11 2009/06/15 15:00:16 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/DataCont/interface/Collection.h"
15 #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 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 void SetEntriesMax(Int_t e) { fEntriesMax = e; }
35 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
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 Int_t fEntriesMax; //maximum number of entries
52 const Collection<T> *fCol; //!pointer to collection
53 TH1D *fPtHist; //!pt histogram
54 TH1D *fEtaHist; //!eta histogram
55 TH1D *fEntHist; //!entries histogram
56
57 ClassDef(PlotKineMod, 1) // Plot kinematics module
58 };
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 fEntriesMax(250),
71 fCol(0),
72 fPtHist(0),
73 fEtaHist(0),
74 fEntHist(0)
75 {
76 // Constructor.
77
78 SetFillHist(kTRUE);
79 }
80
81 //--------------------------------------------------------------------------------------------------
82 template<class T>
83 void mithep::PlotKineMod<T>::Process()
84 {
85 // Process entries of the tree: Just load the branch and fill the histograms.
86
87 if (!LoadEventObject(GetColName(), fCol)) {
88 SendError(kAbortModule, "Process", "Could not load data!");
89 return;
90 }
91
92 if (!GetFillHist())
93 return;
94
95 UInt_t ents=fCol->GetEntries();
96 fEntHist->Fill(ents);
97 for(UInt_t i=0;i<ents;++i) {
98 const T *p = fCol->At(i);
99 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
120 ReqEventObject(GetColName(), fCol);
121
122 if (GetFillHist()) {
123 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 AddTH1(fEntHist,"hEntriesHist",";#entries;#",fEntriesMax,-0.5,fEntriesMax-0.5);
128 }
129 }
130 #endif