1 |
pharris |
1.8 |
// $Id: MVAMetMod.cc,v 1.7 2012/04/07 20:12:20 ceballos Exp $
|
2 |
pharris |
1.1 |
|
3 |
|
|
#include "MitPhysics/Mods/interface/MVAMetMod.h"
|
4 |
|
|
#include "MitCommon/MathTools/interface/MathUtils.h"
|
5 |
|
|
#include "MitAna/DataTree/interface/MetCol.h"
|
6 |
ceballos |
1.7 |
#include "MitAna/DataTree/interface/ParticleCol.h"
|
7 |
pharris |
1.1 |
#include "MitAna/DataTree/interface/Names.h"
|
8 |
|
|
#include "MitPhysics/Init/interface/ModNames.h"
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
using namespace mithep;
|
12 |
|
|
|
13 |
|
|
ClassImp(mithep::MVAMetMod)
|
14 |
|
|
|
15 |
|
|
//--------------------------------------------------------------------------------------------------
|
16 |
|
|
MVAMetMod::MVAMetMod(const char *name, const char *title) :
|
17 |
|
|
BaseMod(name,title),
|
18 |
ceballos |
1.3 |
fMVAMetName("MetMVA"),
|
19 |
ceballos |
1.5 |
fJetsName ("correctPFJets"),
|
20 |
pharris |
1.1 |
fPFCandName(Names::gkPFCandidatesBrn),
|
21 |
|
|
fVertexName(ModNames::gkGoodVertexesName),
|
22 |
|
|
fPFMetName ("PFMet"),
|
23 |
pharris |
1.8 |
fRhoName ("Rho"),
|
24 |
pharris |
1.1 |
fJets(0),
|
25 |
|
|
fCands(0),
|
26 |
|
|
fVertices(0),
|
27 |
pharris |
1.8 |
fPFMet(0),
|
28 |
|
|
fRhoCol(0)
|
29 |
pharris |
1.1 |
{
|
30 |
ceballos |
1.2 |
}
|
31 |
pharris |
1.1 |
|
32 |
|
|
//-------------------------------------------------------------------------------------------------
|
33 |
|
|
void MVAMetMod::Process()
|
34 |
|
|
{
|
35 |
|
|
// Process entries of the tree.
|
36 |
|
|
|
37 |
ceballos |
1.4 |
fJets = GetObjThisEvt<JetCol> (fJetsName); //corrected Jets
|
38 |
ceballos |
1.5 |
//LoadBranch(fJetsName);
|
39 |
ceballos |
1.4 |
LoadBranch(fPFCandName);
|
40 |
|
|
fVertices = GetObjThisEvt<VertexOArr>(fVertexName);
|
41 |
|
|
LoadBranch(fPFMetName);
|
42 |
pharris |
1.8 |
LoadBranch(fRhoName);
|
43 |
ceballos |
1.2 |
|
44 |
|
|
if (!fJets || !fCands || !fVertices || !fPFMet) {
|
45 |
pharris |
1.1 |
SendError(kAbortModule, "Process",
|
46 |
|
|
"Pointer to input jet collection %s is null.",
|
47 |
|
|
fJetsName.Data());
|
48 |
|
|
return;
|
49 |
|
|
}
|
50 |
ceballos |
1.7 |
// lepton selection
|
51 |
pharris |
1.1 |
Float_t lPt0 = 0; Float_t lEta0 = 0; Float_t lPhi0 = 0;
|
52 |
|
|
Float_t lPt1 = 0; Float_t lEta1 = 0; Float_t lPhi1 = 0;
|
53 |
|
|
|
54 |
ceballos |
1.7 |
ParticleOArr *leptons = GetObjThisEvt<ParticleOArr>(ModNames::gkMergedLeptonsName);
|
55 |
|
|
if(leptons->GetEntries() >= 1){
|
56 |
|
|
lPt0 = leptons->At(0)->Pt(); lEta0 = leptons->At(0)->Eta(); lPhi0 = leptons->At(0)->Phi();
|
57 |
|
|
}
|
58 |
|
|
if(leptons->GetEntries() >= 2){
|
59 |
|
|
lPt1 = leptons->At(1)->Pt(); lEta1 = leptons->At(1)->Eta(); lPhi1 = leptons->At(1)->Phi();
|
60 |
|
|
}
|
61 |
|
|
|
62 |
pharris |
1.1 |
MetOArr *MVAMet = new MetOArr;
|
63 |
|
|
MVAMet->SetName(fMVAMetName);
|
64 |
ceballos |
1.5 |
|
65 |
|
|
PFJetOArr *thePFJets = new PFJetOArr;
|
66 |
|
|
for(UInt_t i=0; i<fJets->GetEntries(); i++) {
|
67 |
|
|
const PFJet *ptJet = dynamic_cast<const PFJet*>(fJets->At(i));
|
68 |
|
|
thePFJets->Add(ptJet);
|
69 |
|
|
}
|
70 |
|
|
|
71 |
pharris |
1.1 |
Met lMVAMet = fMVAMet->GetMet( false,
|
72 |
|
|
lPt0,lPhi0,lEta0,
|
73 |
|
|
lPt1,lPhi1,lEta1,
|
74 |
|
|
fPFMet->At(0),
|
75 |
pharris |
1.8 |
fCands,fVertices->At(0),fVertices,fRhoCol->At(0)->Rho(),
|
76 |
ceballos |
1.5 |
thePFJets,
|
77 |
pharris |
1.1 |
int(fVertices->GetEntries()));
|
78 |
|
|
|
79 |
|
|
MVAMet->Add(&lMVAMet);
|
80 |
ceballos |
1.2 |
|
81 |
pharris |
1.1 |
// sort according to pt
|
82 |
|
|
MVAMet->Sort();
|
83 |
ceballos |
1.6 |
|
84 |
pharris |
1.1 |
// add to event for other modules to use
|
85 |
ceballos |
1.5 |
AddObjThisEvt(MVAMet);
|
86 |
ceballos |
1.6 |
|
87 |
|
|
// delete temporal PFJet
|
88 |
|
|
delete thePFJets;
|
89 |
|
|
|
90 |
pharris |
1.1 |
}
|
91 |
|
|
|
92 |
ceballos |
1.2 |
//--------------------------------------------------------------------------------------------------
|
93 |
|
|
void MVAMetMod::SlaveBegin()
|
94 |
|
|
{
|
95 |
|
|
// Run startup code on the computer (slave) doing the actual analysis. Here,
|
96 |
|
|
// we typically initialize histograms and other analysis objects and request
|
97 |
|
|
// branches. For this module, we request a branch of the MitTree.
|
98 |
|
|
|
99 |
ceballos |
1.5 |
//ReqBranch(fJetsName, fJets);
|
100 |
ceballos |
1.4 |
ReqBranch(fPFCandName, fCands);
|
101 |
|
|
ReqBranch(fPFMetName, fPFMet);
|
102 |
pharris |
1.8 |
ReqBranch(fRhoName, fRhoCol);
|
103 |
ceballos |
1.4 |
|
104 |
ceballos |
1.2 |
fMVAMet = new MVAMet();
|
105 |
|
|
fMVAMet->Initialize(TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/mva_JetID_lowpt.weights.xml"))),
|
106 |
|
|
TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/mva_JetID_highpt.weights.xml"))),
|
107 |
|
|
TString(getenv("CMSSW_BASE")+string("/src/MitPhysics/Utils/python/JetIdParams_cfi.py")),
|
108 |
pharris |
1.8 |
TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmet_52.root"))),
|
109 |
|
|
TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmetphi_52.root"))),
|
110 |
|
|
TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmetu1cov_52.root"))),
|
111 |
|
|
TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmetphiu1cov_52.root")))
|
112 |
ceballos |
1.2 |
);
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
//--------------------------------------------------------------------------------------------------
|
116 |
|
|
void MVAMetMod::SlaveTerminate()
|
117 |
|
|
{
|
118 |
|
|
delete fMVAMet;
|
119 |
|
|
}
|