ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/SelMods/interface/GenericSelMod.h
Revision: 1.2
Committed: Fri Dec 12 16:04:44 2008 UTC (16 years, 4 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.1: +10 -7 lines
Log Message:
Added minmaxpt cut.

File Contents

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