Revision: | 1.13 |
Committed: | Fri Jun 26 16:47:18 2009 UTC (15 years, 10 months ago) by loizides |
Content type: | text/plain |
Branch: | MAIN |
CVS Tags: | Mit_032, Mit_031, Mit_025c_branch2, Mit_025c_branch1, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_025c_branch0, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013, Mit_013pre1, Mit_012i, Mit_012h, Mit_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012, Mit_011a, Mit_011, Mit_010a, Mit_010, HEAD |
Branch point for: | Mit_025c_branch |
Changes since 1.12: | +2 -2 lines |
Log Message: | Cleanup and added TrackToPartMod |
# | Content |
---|---|
1 | //-------------------------------------------------------------------------------------------------- |
2 | // $Id: PlotKineMod.h,v 1.12 2009/06/17 11:50:27 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 | const 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 |