1 |
// $Id: MVAMetMod.cc,v 1.9 2012/04/25 10:12:00 pharris Exp $
|
2 |
|
3 |
#include "MitPhysics/Mods/interface/MVAMetMod.h"
|
4 |
#include "MitCommon/MathTools/interface/MathUtils.h"
|
5 |
#include "MitAna/DataTree/interface/MetCol.h"
|
6 |
#include "MitAna/DataTree/interface/ParticleCol.h"
|
7 |
#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 |
fMVAMetName("MetMVA"),
|
19 |
fJetsName ("correctPFJets"),
|
20 |
fPFCandName(Names::gkPFCandidatesBrn),
|
21 |
fVertexName(ModNames::gkGoodVertexesName),
|
22 |
fPFMetName ("PFMet"),
|
23 |
fRhoName ("Rho"),
|
24 |
fJets(0),
|
25 |
fCands(0),
|
26 |
fVertices(0),
|
27 |
fPFMet(0),
|
28 |
fRhoCol(0)
|
29 |
{
|
30 |
}
|
31 |
|
32 |
//-------------------------------------------------------------------------------------------------
|
33 |
void MVAMetMod::Process()
|
34 |
{
|
35 |
// Process entries of the tree.
|
36 |
|
37 |
fJets = GetObjThisEvt<JetCol> (fJetsName); //corrected Jets
|
38 |
//LoadBranch(fJetsName);
|
39 |
LoadBranch(fPFCandName);
|
40 |
fVertices = GetObjThisEvt<VertexOArr>(fVertexName);
|
41 |
LoadBranch(fPFMetName);
|
42 |
LoadBranch(fRhoName);
|
43 |
|
44 |
if (!fJets || !fCands || !fVertices || !fPFMet) {
|
45 |
SendError(kAbortModule, "Process",
|
46 |
"Pointer to input jet collection %s is null.",
|
47 |
fJetsName.Data());
|
48 |
return;
|
49 |
}
|
50 |
// lepton selection
|
51 |
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 |
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 |
MetOArr *MVAMet = new MetOArr;
|
63 |
MVAMet->SetName(fMVAMetName);
|
64 |
|
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 |
Met lMVAMet = fMVAMet->GetMet( false,
|
72 |
lPt0,lPhi0,lEta0,
|
73 |
lPt1,lPhi1,lEta1,
|
74 |
fPFMet->At(0),
|
75 |
fCands,fVertices->At(0),fVertices,fRhoCol->At(0)->Rho(),
|
76 |
thePFJets,
|
77 |
int(fVertices->GetEntries()));
|
78 |
|
79 |
MVAMet->Add(&lMVAMet);
|
80 |
|
81 |
// sort according to pt
|
82 |
MVAMet->Sort();
|
83 |
|
84 |
// add to event for other modules to use
|
85 |
AddObjThisEvt(MVAMet);
|
86 |
|
87 |
// delete temporal PFJet
|
88 |
delete thePFJets;
|
89 |
|
90 |
}
|
91 |
|
92 |
//--------------------------------------------------------------------------------------------------
|
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 |
//ReqBranch(fJetsName, fJets);
|
100 |
ReqBranch(fPFCandName, fCands);
|
101 |
ReqBranch(fPFMetName, fPFMet);
|
102 |
ReqBranch(fRhoName, fRhoCol);
|
103 |
|
104 |
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 |
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/gbrmetu2cov_52.root")))
|
112 |
);
|
113 |
}
|
114 |
|
115 |
//--------------------------------------------------------------------------------------------------
|
116 |
void MVAMetMod::SlaveTerminate()
|
117 |
{
|
118 |
delete fMVAMet;
|
119 |
}
|