1 |
// $Id: HwwEvtPreSelMod.cc,v 1.1 2008/10/06 15:40:14 sixie Exp $
|
2 |
|
3 |
#include "MitPhysics/SelMods/interface/HwwEvtPreSelMod.h"
|
4 |
#include <TH1D.h>
|
5 |
#include <TH2D.h>
|
6 |
#include "MitAna/DataTree/interface/Names.h"
|
7 |
#include "MitAna/DataCont/interface/ObjArray.h"
|
8 |
#include "MitCommon/MathTools/interface/MathUtils.h"
|
9 |
|
10 |
using namespace mithep;
|
11 |
ClassImp(mithep::HwwEvtPreSelMod)
|
12 |
|
13 |
//--------------------------------------------------------------------------------------------------
|
14 |
HwwEvtPreSelMod::HwwEvtPreSelMod(const char *name, const char *title) :
|
15 |
BaseMod(name,title),
|
16 |
fPrintDebug(false),
|
17 |
fMuonName(Names::gkMuonBrn),
|
18 |
fElectronName(Names::gkElectronBrn),
|
19 |
fMuons(0),
|
20 |
fElectrons(0),
|
21 |
fNEventsProcessed(0),
|
22 |
fNEventsPassed(0)
|
23 |
{
|
24 |
// Constructor.
|
25 |
}
|
26 |
|
27 |
//--------------------------------------------------------------------------------------------------
|
28 |
void HwwEvtPreSelMod::Begin()
|
29 |
{
|
30 |
// Run startup code on the client machine. For this module, we dont do
|
31 |
// anything here.
|
32 |
}
|
33 |
|
34 |
//--------------------------------------------------------------------------------------------------
|
35 |
void HwwEvtPreSelMod::Process()
|
36 |
{
|
37 |
// Process entries of the tree. For this module, we just load the branches an
|
38 |
|
39 |
fNEventsProcessed++;
|
40 |
|
41 |
if (fNEventsProcessed % 1000 == 0 || fPrintDebug) {
|
42 |
time_t systime;
|
43 |
systime = time(NULL);
|
44 |
cerr << endl << "HwwEvtPreSelMod : Process Event " << fNEventsProcessed << " Time: " << ctime(&systime) << endl;
|
45 |
}
|
46 |
|
47 |
int nLeptons = 0;
|
48 |
|
49 |
LoadBranch(fMuonName);
|
50 |
double maxLeptonPt = 0;
|
51 |
for (UInt_t i=0; i<fMuons->GetEntries(); ++i) {
|
52 |
if (fPrintDebug) cerr << "mu " << i << " " << fMuons->At(i)->Pt() << endl;
|
53 |
|
54 |
if (fMuons->At(i)->Pt() > 5)
|
55 |
nLeptons++;
|
56 |
if (fMuons->At(i)->Pt() > maxLeptonPt)
|
57 |
maxLeptonPt = fMuons->At(i)->Pt();
|
58 |
}
|
59 |
|
60 |
if (maxLeptonPt > 20 && nLeptons >= 2) {
|
61 |
fNEventsPassed++;
|
62 |
return;
|
63 |
}
|
64 |
|
65 |
LoadBranch(fElectronName);
|
66 |
for (UInt_t i=0; i<fElectrons->GetEntries(); ++i) {
|
67 |
if (fPrintDebug) cerr << "ele " << i << " " << fElectrons->At(i)->Pt() << endl;
|
68 |
if (fElectrons->At(i)->Pt() > 5)
|
69 |
nLeptons++;
|
70 |
if (fElectrons->At(i)->Pt() > maxLeptonPt)
|
71 |
maxLeptonPt = fElectrons->At(i)->Pt();
|
72 |
}
|
73 |
|
74 |
if (maxLeptonPt > 20 && nLeptons >= 2) {
|
75 |
fNEventsPassed++;
|
76 |
return;
|
77 |
}
|
78 |
|
79 |
//By now the event fails preselection. If nLeptons < 2 or if maxLeptonPt
|
80 |
//is less than 20
|
81 |
if (fPrintDebug) cerr << nLeptons << " " << maxLeptonPt << endl;
|
82 |
if (fPrintDebug) cerr << "fail preselection - skip event" << endl;
|
83 |
SkipEvent();
|
84 |
return;
|
85 |
|
86 |
|
87 |
|
88 |
}
|
89 |
//--------------------------------------------------------------------------------------------------
|
90 |
void HwwEvtPreSelMod::SlaveBegin()
|
91 |
{
|
92 |
// Run startup code on the computer (slave) doing the actual analysis. Here,
|
93 |
// we typically initialize histograms and other analysis objects and request
|
94 |
// branches. For this module, we request a branch of the MitTree.
|
95 |
ReqBranch(fMuonName, fMuons);
|
96 |
ReqBranch(fElectronName, fElectrons);
|
97 |
|
98 |
fHWWPreSelection = new TH1D("hHWWPreSelection", ";Cut Number;#", 9, -1.5, 7.5);
|
99 |
AddOutput(fHWWPreSelection);
|
100 |
|
101 |
}
|
102 |
|
103 |
//--------------------------------------------------------------------------------------------------
|
104 |
void HwwEvtPreSelMod::SlaveTerminate()
|
105 |
{
|
106 |
// Run finishing code on the computer (slave) that did the analysis. For this
|
107 |
// module, we dont do anything here.
|
108 |
|
109 |
cerr << "Events Processed: " << fNEventsProcessed << endl;
|
110 |
cerr << "Events Passed PreSelection: " << fNEventsPassed << endl;
|
111 |
|
112 |
}
|
113 |
|
114 |
//--------------------------------------------------------------------------------------------------
|
115 |
void HwwEvtPreSelMod::Terminate()
|
116 |
{
|
117 |
// Run finishing code on the client computer. For this module, we dont do
|
118 |
// anything here.
|
119 |
}
|