ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/UHHAnalysis/SFrameTools/src/EventCalc.cxx
Revision: 1.2
Committed: Wed Jun 6 08:20:34 2012 UTC (12 years, 11 months ago) by rkogler
Content type: text/plain
Branch: MAIN
Changes since 1.1: +2 -0 lines
Log Message:
small bugfix

File Contents

# User Rev Content
1 rkogler 1.1 // Dear emacs, this is -*- c++ -*-
2    
3     #include "include/EventCalc.h"
4    
5     #include <iostream>
6    
7     EventCalc* EventCalc::m_instance = NULL;
8    
9     EventCalc* EventCalc::Instance()
10     {
11     // Get a pointer to the object handler.
12     // This is the only way to access this class,
13     // since it's a singleton. This method is accessible
14     // from everywhere.
15    
16     if (m_instance == NULL){
17     m_instance = new EventCalc();
18     }
19     return m_instance;
20     }
21    
22     EventCalc::EventCalc() : m_logger( "EventCalc" )
23     {
24     // constructor: initialise all variables
25     m_logger << DEBUG << "Constructor called." << SLogger::endmsg;
26     m_bcc = NULL;
27     m_lumi = NULL;
28     }
29    
30     EventCalc::~EventCalc()
31     {
32     // default destructor
33     }
34    
35     void EventCalc::Reset()
36     {
37     // reset: set all booleans to false
38     // this has to be done at the beginning of each event
39     // after a call to reset all quantities will be re-calculated
40     // when they are accessed
41    
42     // (re-)set the pointers using the ObjectHandler
43     ObjectHandler* objs = ObjectHandler::Instance();
44     m_bcc = objs->GetBaseCycleContainer();
45     m_lumi = objs->GetLumiHandler();
46    
47     // reset booleans
48     b_HT = false;
49 rkogler 1.2 b_HTlep = false;
50    
51 rkogler 1.1 }
52    
53     BaseCycleContainer* EventCalc::GetBaseCycleContainer()
54     {
55     // return the pointer to the container with all objects
56     if (!m_bcc){
57     m_logger << WARNING << "Pointer to BaseCycleContainer is NULL." << SLogger::endmsg;
58     }
59     return m_bcc;
60     }
61    
62     LuminosityHandler* EventCalc::GetLumiHandler()
63     {
64     // return the pointer to the container with all objects
65     if (!m_lumi){
66     m_logger << WARNING << "Pointer to LumiHandler is NULL." << SLogger::endmsg;
67     }
68     return m_lumi;
69     }
70    
71     double EventCalc::GetHT()
72     {
73     // calculate HT, which is defined as the scalar sum of all
74     // jets, leptons and missing transverse momentum in the event
75     if (!b_HT){
76    
77     b_HT = true;
78     m_HT = 0;
79    
80     // add lepton pt and MET
81     m_HT += GetHTlep();
82    
83     // sum over pt of all jets
84     if(m_bcc->jets){
85     for(unsigned int i=0; i<m_bcc->jets->size(); ++i){
86     m_HT += m_bcc->jets->at(i).pt();
87     }
88     }
89    
90     }
91     return m_HT;
92     }
93    
94     double EventCalc::GetHTlep()
95     {
96     // calculate HT_lep, which is defined as the scalar sum of all
97     // leptons and missing transverse momentum in the event
98     if (!b_HTlep){
99    
100     b_HTlep = true;
101     m_HTlep=0;
102    
103     // sum over pt of all electrons
104     if(m_bcc->electrons){
105     for(unsigned int i=0; i<m_bcc->electrons->size(); ++i){
106     m_HTlep += m_bcc->electrons->at(i).pt();
107     }
108     }
109    
110     // sum over pt of all muons
111     if(m_bcc->muons){
112     for(unsigned int i=0; i<m_bcc->muons->size(); ++i){
113     m_HTlep += m_bcc->muons->at(i).pt();
114     }
115     }
116    
117     // sum over pt of all taus
118     if(m_bcc->taus){
119     for(unsigned int i=0; i<m_bcc->taus->size(); ++i){
120     m_HTlep += m_bcc->taus->at(i).pt();
121     }
122     }
123    
124     // add MET
125     if(m_bcc->met) m_HTlep += m_bcc->met->pt();
126    
127     }
128     return m_HTlep;
129     }
130    
131