ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/PhysicsMod/interface/GenericSelMod.h
Revision: 1.1
Committed: Tue Dec 9 10:18:19 2008 UTC (16 years, 5 months ago) by loizides
Content type: text/plain
Branch: MAIN
Log Message:
Added generic selection module.

File Contents

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2     // $Id: PlotKineMod.h,v 1.2 2008/12/04 13:52:27 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 MITANA_PHYSICSMOD_GENERICSELMOD_H
13     #define MITANA_PHYSICSMOD_GENERICSELMOD_H
14    
15     #include "MitAna/PhysicsMod/interface/PlotKineMod.h"
16    
17     namespace mithep
18     {
19     template<class T>
20     class GenericSelMod : public PlotKineMod<T>
21     {
22     public:
23     GenericSelMod(const char *name="GenericSelMod",
24     const char *title="Generic selection module");
25     ~GenericSelMod() {}
26    
27     UInt_t GetMinCounts() const { return fMinCounts; }
28     void SetMinCounts(UInt_t c) { fMinCounts = c; }
29    
30     protected:
31     void Process();
32    
33     UInt_t fMinCounts; //minimum number of particles required to accept event
34    
35     ClassDefT(GenericSelMod,1) // Plot kinematics module
36     };
37     }
38    
39     //--------------------------------------------------------------------------------------------------
40     template<class T>
41     mithep::GenericSelMod<T>::GenericSelMod(const char *name, const char *title) :
42     PlotKineMod<T>(name,title),
43     fMinCounts(1)
44     {
45     // Constructor.
46    
47     this->SetFillHist(0);
48     }
49    
50     //--------------------------------------------------------------------------------------------------
51     template<class T>
52     void mithep::GenericSelMod<T>::Process()
53     {
54     // Process entries of the tree: Just load the branch and fill the histograms.
55    
56     UInt_t counter = 0;
57    
58     if (!this->Load()) {
59     this->SendError(TAModule::kAbortModule, "Process", "Could not load data!");
60     return;
61     }
62    
63     UInt_t ents=this->fCol->GetEntries();
64    
65     for(UInt_t i=0;i<ents;++i) {
66     const T *p = this->fCol->At(i);
67     Double_t pt = p->Pt();
68     if (pt<this->fPtMin)
69     continue;
70     if (pt>this->fPtMax)
71     continue;
72     Double_t eta = p->Eta();
73     if (eta<this->fEtaMin)
74     continue;
75     if (eta>this->fEtaMax)
76     continue;
77    
78     ++counter;
79    
80     if (!this->GetFillHist())
81     continue;
82    
83     this->fPtHist->Fill(pt);
84     this->fEtaHist->Fill(eta);
85     }
86    
87     // skip event if not enough particles are found in kinematic region
88     if (counter<GetMinCounts())
89     this->SkipEvent();
90     }
91     #endif