1 |
//--------------------------------------------------------------------------------------------------
|
2 |
// $Id: PlotKineMod.h,v 1.1 2008/11/28 20:27:23 loizides Exp $
|
3 |
//
|
4 |
// PlotKineMod
|
5 |
//
|
6 |
// This module
|
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 GSetEtaMax() const { return fEtaMax; }
|
31 |
Double_t GetPtMin() const { return fPtMin; }
|
32 |
Double_t GetPtMax() const { return fPtMax; }
|
33 |
void SetColName(const char *n) { fColName=n; }
|
34 |
void SetEtaMin(Double_t e) { fEtaMin = e; }
|
35 |
void SetEtaMax(Double_t e) { fEtaMax = e; }
|
36 |
void SetPtMin(Double_t pt) { fPtMin = pt; }
|
37 |
void SetPtMax(Double_t pt) { fPtMax = pt; }
|
38 |
|
39 |
protected:
|
40 |
TString fColName; //name of collection
|
41 |
Double_t fPtMin; //minimum pt
|
42 |
Double_t fPtMax; //maximum pt
|
43 |
Double_t fEtaMin; //minimum eta
|
44 |
Double_t fEtaMax; //maximum eta
|
45 |
Bool_t fLoadBr; //=true then load branch (def=1)
|
46 |
const Collection<T> *fCol; //!pointer to collection
|
47 |
TH1D *fPtHist; //!pt histogram
|
48 |
TH1D *fEtaHist; //!eta histogram
|
49 |
TH1D *fMassHist; //!mass histogram
|
50 |
TH1D *fMtHist; //!mt histogram
|
51 |
|
52 |
void Process();
|
53 |
void SlaveBegin();
|
54 |
|
55 |
ClassDefT(PlotKineMod,1) // Plot kinematics module
|
56 |
};
|
57 |
}
|
58 |
|
59 |
//--------------------------------------------------------------------------------------------------
|
60 |
template<class T>
|
61 |
mithep::PlotKineMod<T>::PlotKineMod(const char *name, const char *title) :
|
62 |
BaseMod(name,title),
|
63 |
fColName("SetMe"),
|
64 |
fPtMin(1),
|
65 |
fPtMax(5000),
|
66 |
fEtaMin(-10),
|
67 |
fEtaMax(10),
|
68 |
fLoadBr(kTRUE),
|
69 |
fCol(0),
|
70 |
fPtHist(0),
|
71 |
fEtaHist(0)
|
72 |
{
|
73 |
// Constructor.
|
74 |
}
|
75 |
|
76 |
//--------------------------------------------------------------------------------------------------
|
77 |
template<class T>
|
78 |
void mithep::PlotKineMod<T>::Process()
|
79 |
{
|
80 |
// Process entries of the tree: Just load the branch and fill the histograms.
|
81 |
|
82 |
if (fLoadBr)
|
83 |
LoadBranch(GetColName());
|
84 |
else
|
85 |
fCol = GetObjThisEvt<Collection<T> >(GetColName());
|
86 |
|
87 |
Int_t ents=fCol->GetEntries();
|
88 |
for(Int_t i=0;i<ents;++i) {
|
89 |
const T *p = fCol->At(i);
|
90 |
Double_t pt = p->Pt();
|
91 |
if (pt<fPtMin)
|
92 |
continue;
|
93 |
if (pt>fPtMax)
|
94 |
continue;
|
95 |
Double_t eta = p->Eta();
|
96 |
if (eta<fEtaMin)
|
97 |
continue;
|
98 |
if (eta>fEtaMax)
|
99 |
continue;
|
100 |
fPtHist->Fill(pt);
|
101 |
fEtaHist->Fill(eta);
|
102 |
}
|
103 |
}
|
104 |
|
105 |
//--------------------------------------------------------------------------------------------------
|
106 |
template<class T>
|
107 |
void mithep::PlotKineMod<T>::SlaveBegin()
|
108 |
{
|
109 |
// Request a branch and create the histograms.
|
110 |
|
111 |
if (fLoadBr)
|
112 |
ReqBranch(GetColName(), fCol);
|
113 |
|
114 |
fPtHist = new TH1D("hPtHist",";p_{t} [GeV];#",100,0.,250.);
|
115 |
AddOutput(fPtHist);
|
116 |
fEtaHist = new TH1D("hEtaHist",";#eta;#",160,-8.,8.);
|
117 |
AddOutput(fEtaHist);
|
118 |
}
|
119 |
#endif
|