ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/SelMods/interface/GenericSelMod.h
Revision: 1.7
Committed: Wed Jun 17 14:52:59 2009 UTC (15 years, 10 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_029c, Mit_029b, Mit_029a, Mit_028a, Mit_028, Mit_027, Mit_027a, 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_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012, Mit_011a, Mit_011, Mit_010a, Mit_010, Mit_009c, HEAD
Changes since 1.6: +7 -7 lines
Log Message:
Adjust counters

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: GenericSelMod.h,v 1.6 2009/06/17 11:50:28 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/DataCont/interface/Collection.h"
16 #include "MitAna/TreeMod/interface/BaseSelMod.h"
17 #include <TH1D.h>
18
19 namespace mithep
20 {
21 template<class T>
22 class GenericSelMod : public BaseSelMod
23 {
24 public:
25 GenericSelMod(const char *name="GenericSelMod",
26 const char *title="Generic selection module");
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 ClassDef(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;#",5,-0.5,4.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