1 |
//--------------------------------------------------------------------------------------------------
|
2 |
// $Id: GenericSelMod.h,v 1.2 2008/12/12 16:04:44 loizides Exp $
|
3 |
//
|
4 |
// GenericSelMod
|
5 |
//
|
6 |
// This module allows trivial event selection based on counting the number of
|
7 |
// particles found in the given kinematic range.
|
8 |
//
|
9 |
// Authors: C.Loizides
|
10 |
//--------------------------------------------------------------------------------------------------
|
11 |
|
12 |
#ifndef MITPHYSICS_SELMODS_GENERICSELMOD_H
|
13 |
#define MITPHYSICS_SELMODS_GENERICSELMOD_H
|
14 |
|
15 |
#include "MitAna/TreeMod/interface/BaseSelMod.h"
|
16 |
#include <TH1D.h>
|
17 |
|
18 |
namespace mithep
|
19 |
{
|
20 |
template<class T>
|
21 |
class GenericSelMod : public BaseSelMod
|
22 |
{
|
23 |
public:
|
24 |
GenericSelMod(const char *name="GenericSelMod",
|
25 |
const char *title="Generic selection module");
|
26 |
~GenericSelMod() {}
|
27 |
|
28 |
const char *GetColName() const { return fColName; }
|
29 |
Double_t GetEtaMin() const { return fEtaMin; }
|
30 |
Double_t GetEtaMax() const { return fEtaMax; }
|
31 |
const char *GetInputName() const { return GetColName(); }
|
32 |
UInt_t GetMinCounts() const { return fMinCounts; }
|
33 |
Double_t GetMinPtMax() const { return fMinMaxPt; }
|
34 |
Double_t GetPtMin() const { return fPtMin; }
|
35 |
Double_t GetPtMax() const { return fPtMax; }
|
36 |
void SetColName(const char *n) { fColName=n; }
|
37 |
void SetEtaMin(Double_t e) { fEtaMin = e; }
|
38 |
void SetEtaMax(Double_t e) { fEtaMax = e; }
|
39 |
void SetInputName(const char *n) { SetColName(n); }
|
40 |
void SetMinMaxPt(Double_t pt) { fMinMaxPt= pt; }
|
41 |
void SetMinCounts(UInt_t c) { fMinCounts = c; }
|
42 |
void SetPtMin(Double_t pt) { fPtMin = pt; }
|
43 |
void SetPtMax(Double_t pt) { fPtMax = pt; }
|
44 |
|
45 |
protected:
|
46 |
void Process();
|
47 |
void SlaveBegin();
|
48 |
|
49 |
TString fColName; //name of input collection
|
50 |
Double_t fPtMin; //minimum pt required (def = 0 GeV)
|
51 |
Double_t fPtMax; //maximum pt required (def = 5000 GeV)
|
52 |
Double_t fEtaMin; //minimum eta required (def = -10)
|
53 |
Double_t fEtaMax; //maximum eta required (def = +10)
|
54 |
Double_t fMinMaxPt; //min pt required for max pt (def = 0GeV)
|
55 |
UInt_t fMinCounts; //min number of particles required (def = 1)
|
56 |
const Collection<T> *fCol; //!pointer to collection
|
57 |
TH1D *fNAccCounters; //!acceptance histogram
|
58 |
|
59 |
ClassDefT(GenericSelMod,1) // Generic selection module
|
60 |
};
|
61 |
}
|
62 |
|
63 |
//--------------------------------------------------------------------------------------------------
|
64 |
template<class T>
|
65 |
mithep::GenericSelMod<T>::GenericSelMod(const char *name, const char *title) :
|
66 |
BaseSelMod(name,title),
|
67 |
fColName("SetMe"),
|
68 |
fPtMin(0),
|
69 |
fPtMax(5000),
|
70 |
fEtaMin(-10),
|
71 |
fEtaMax(10),
|
72 |
fMinMaxPt(0),
|
73 |
fMinCounts(1),
|
74 |
fCol(0)
|
75 |
{
|
76 |
// Constructor.
|
77 |
}
|
78 |
|
79 |
//--------------------------------------------------------------------------------------------------
|
80 |
template<class T>
|
81 |
void mithep::GenericSelMod<T>::Process()
|
82 |
{
|
83 |
// Process entries of the tree.
|
84 |
|
85 |
fNAccCounters->Fill(0);
|
86 |
|
87 |
fCol = GetObjThisEvt<Collection<T> >(GetColName());
|
88 |
if (!fCol) {
|
89 |
this->SendError(kAbortModule, "Process",
|
90 |
"Could not obtain collection with name %s!", GetColName());
|
91 |
return;
|
92 |
}
|
93 |
|
94 |
fNAccCounters->Fill(1);
|
95 |
|
96 |
UInt_t counter = 0;
|
97 |
UInt_t ents=this->fCol->GetEntries();
|
98 |
for(UInt_t i=0;i<ents;++i) {
|
99 |
const T *p = this->fCol->At(i);
|
100 |
Double_t pt = p->Pt();
|
101 |
if (pt<this->fPtMin)
|
102 |
continue;
|
103 |
if (pt>this->fPtMax)
|
104 |
continue;
|
105 |
Double_t eta = p->Eta();
|
106 |
if (eta<this->fEtaMin)
|
107 |
continue;
|
108 |
if (eta>this->fEtaMax)
|
109 |
continue;
|
110 |
|
111 |
if (i==0) { // check particle with largest pt
|
112 |
if (pt<fMinMaxPt) {
|
113 |
this->SkipEvent();
|
114 |
return;
|
115 |
}
|
116 |
}
|
117 |
++counter;
|
118 |
}
|
119 |
|
120 |
fNAccCounters->Fill(2);
|
121 |
|
122 |
// skip event if not enough particles are found in kinematic region
|
123 |
if (counter<GetMinCounts()) {
|
124 |
this->SkipEvent();
|
125 |
return;
|
126 |
}
|
127 |
|
128 |
fNAccCounters->Fill(3);
|
129 |
}
|
130 |
|
131 |
//--------------------------------------------------------------------------------------------------
|
132 |
template<class T>
|
133 |
void mithep::GenericSelMod<T>::SlaveBegin()
|
134 |
{
|
135 |
// Setup acceptence histogram.
|
136 |
|
137 |
AddTH1(fNAccCounters,"hNAccCounters",";cut;#",25,-0.5,24.5);
|
138 |
if (1) {
|
139 |
TAxis *xa = fNAccCounters->GetXaxis();
|
140 |
for(Int_t i=1;i<=fNAccCounters->GetNbinsX();++i)
|
141 |
xa->SetBinLabel(i,"unused");
|
142 |
xa->SetBinLabel(1,"Enter");
|
143 |
xa->SetBinLabel(2,"Objs");
|
144 |
xa->SetBinLabel(3,"MinMax");
|
145 |
xa->SetBinLabel(4,"Counts");
|
146 |
xa->SetRangeUser(0,3);
|
147 |
}
|
148 |
}
|
149 |
#endif
|