ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/SelMods/interface/GenericSelMod.h
Revision: 1.1
Committed: Wed Dec 10 17:27:28 2008 UTC (16 years, 4 months ago) by loizides
Content type: text/plain
Branch: MAIN
Log Message:
Added generic selection module.

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: GenericSelMod.h,v 1.1 2008/12/09 10:18:19 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
17 namespace mithep
18 {
19 template<class T>
20 class GenericSelMod : public BaseSelMod
21 {
22 public:
23 GenericSelMod(const char *name="GenericSelMod",
24 const char *title="Generic selection module");
25 ~GenericSelMod() {}
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 UInt_t GetMinCounts() const { return fMinCounts; }
32 Double_t GetPtMin() const { return fPtMin; }
33 Double_t GetPtMax() const { return fPtMax; }
34 void SetColName(const char *n) { fColName=n; }
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 void SetMinCounts(UInt_t c) { fMinCounts = c; }
41
42 protected:
43 void Process();
44
45 TString fColName; //name of input collection
46 Double_t fPtMin; //minimum pt required (def=0 GeV)
47 Double_t fPtMax; //maximum pt required (def=5000 GeV)
48 Double_t fEtaMin; //minimum eta required (def=-10)
49 Double_t fEtaMax; //maximum eta required (def=+10)
50 UInt_t fMinCounts; //minimum number of particles required to accept event
51 const Collection<T> *fCol; //!pointer to collection
52
53 ClassDefT(GenericSelMod,1) // Generic selection module
54 };
55 }
56
57 //--------------------------------------------------------------------------------------------------
58 template<class T>
59 mithep::GenericSelMod<T>::GenericSelMod(const char *name, const char *title) :
60 BaseSelMod(name,title),
61 fColName("SetMe"),
62 fPtMin(0),
63 fPtMax(5000),
64 fEtaMin(-10),
65 fEtaMax(10),
66 fMinCounts(1),
67 fCol(0)
68 {
69 // Constructor.
70 }
71
72 //--------------------------------------------------------------------------------------------------
73 template<class T>
74 void mithep::GenericSelMod<T>::Process()
75 {
76 // Process entries of the tree: Just load the branch and fill the histograms.
77
78 fCol = GetObjThisEvt<Collection<T> >(GetColName());
79 if (!fCol) {
80 this->SendError(kAbortModule, "Process",
81 "Could not obtain collection with name %s!", GetColName());
82 return;
83 }
84
85 UInt_t counter = 0;
86 UInt_t ents=this->fCol->GetEntries();
87 for(UInt_t i=0;i<ents;++i) {
88 const T *p = this->fCol->At(i);
89 Double_t pt = p->Pt();
90 if (pt<this->fPtMin)
91 continue;
92 if (pt>this->fPtMax)
93 continue;
94 Double_t eta = p->Eta();
95 if (eta<this->fEtaMin)
96 continue;
97 if (eta>this->fEtaMax)
98 continue;
99
100 ++counter;
101 }
102
103 // skip event if not enough particles are found in kinematic region
104 if (counter<GetMinCounts())
105 this->SkipEvent();
106 }
107 #endif