1 |
loizides |
1.1 |
//--------------------------------------------------------------------------------------------------
|
2 |
|
|
// $Id: PlotKineMod.h,v 1.1 2008/11/25 14:30:53 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 |
|
|
T *fCol; //!pointer to collection
|
46 |
|
|
TH1D *fPtHist; //!pt histogram
|
47 |
|
|
TH1D *fEtaHist; //!eta histogram
|
48 |
|
|
|
49 |
|
|
void Process();
|
50 |
|
|
void SlaveBegin();
|
51 |
|
|
|
52 |
|
|
ClassDefT(PlotKineMod,1) // Plot kinematics module
|
53 |
|
|
};
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
//--------------------------------------------------------------------------------------------------
|
57 |
|
|
template<class T>
|
58 |
|
|
mithep::PlotKineMod<T>::PlotKineMod(const char *name, const char *title) :
|
59 |
|
|
BaseMod(name,title),
|
60 |
|
|
fColName("SetMe"),
|
61 |
|
|
fPtMin(1),
|
62 |
|
|
fPtMax(5000),
|
63 |
|
|
fEtaMin(-10),
|
64 |
|
|
fEtaMax(10),
|
65 |
|
|
fCol(0),
|
66 |
|
|
fPtHist(0),
|
67 |
|
|
fEtaHist(0)
|
68 |
|
|
{
|
69 |
|
|
// Constructor.
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
//--------------------------------------------------------------------------------------------------
|
73 |
|
|
template<class T>
|
74 |
|
|
void mithep::PlotKineMod<T>::Process()
|
75 |
|
|
{
|
76 |
|
|
// Process entries of the tree: Just load the branch and fill the histograms.
|
77 |
|
|
|
78 |
|
|
LoadBranch(GetColName());
|
79 |
|
|
|
80 |
|
|
Int_t ents=fCol->GetEntries();
|
81 |
|
|
for(Int_t i=0;i<ents;++i) {
|
82 |
|
|
const Particle *p = fCol->At(i);
|
83 |
|
|
Double_t pt = p->Pt();
|
84 |
|
|
if (pt<fPtMin)
|
85 |
|
|
continue;
|
86 |
|
|
if (pt>fPtMax)
|
87 |
|
|
continue;
|
88 |
|
|
Double_t eta = p->Eta();
|
89 |
|
|
if (eta<fEtaMin)
|
90 |
|
|
continue;
|
91 |
|
|
if (eta>fEtaMax)
|
92 |
|
|
continue;
|
93 |
|
|
fPtHist->Fill(pt);
|
94 |
|
|
fEtaHist->Fill(eta);
|
95 |
|
|
}
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
//--------------------------------------------------------------------------------------------------
|
99 |
|
|
template<class T>
|
100 |
|
|
void mithep::PlotKineMod<T>::SlaveBegin()
|
101 |
|
|
{
|
102 |
|
|
// Request a branch and create the histograms.
|
103 |
|
|
|
104 |
|
|
ReqBranch(GetColName(), fCol);
|
105 |
|
|
|
106 |
|
|
fPtHist = new TH1D("hPtHist",";p_{t};#",100,0.,25.);
|
107 |
|
|
AddOutput(fPtHist);
|
108 |
|
|
fEtaHist = new TH1D("hEtaHist",";#eta;#",160,-8.,8.);
|
109 |
|
|
AddOutput(fEtaHist);
|
110 |
|
|
}
|
111 |
|
|
#endif
|