ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/MVAMetMod.cc
Revision: 1.7
Committed: Sat Apr 7 20:12:20 2012 UTC (13 years, 1 month ago) by ceballos
Content type: text/plain
Branch: MAIN
Changes since 1.6: +11 -2 lines
Log Message:
final fix

File Contents

# User Rev Content
1 ceballos 1.7 // $Id: MVAMetMod.cc,v 1.6 2012/04/07 17:37:27 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     fJets(0),
24     fCands(0),
25     fVertices(0),
26 ceballos 1.2 fPFMet(0)
27 pharris 1.1 {
28 ceballos 1.2 }
29 pharris 1.1
30     //-------------------------------------------------------------------------------------------------
31     void MVAMetMod::Process()
32     {
33     // Process entries of the tree.
34    
35 ceballos 1.4 fJets = GetObjThisEvt<JetCol> (fJetsName); //corrected Jets
36 ceballos 1.5 //LoadBranch(fJetsName);
37 ceballos 1.4 LoadBranch(fPFCandName);
38     fVertices = GetObjThisEvt<VertexOArr>(fVertexName);
39     LoadBranch(fPFMetName);
40 ceballos 1.2
41     if (!fJets || !fCands || !fVertices || !fPFMet) {
42 pharris 1.1 SendError(kAbortModule, "Process",
43     "Pointer to input jet collection %s is null.",
44     fJetsName.Data());
45     return;
46     }
47 ceballos 1.7 // lepton selection
48 pharris 1.1 Float_t lPt0 = 0; Float_t lEta0 = 0; Float_t lPhi0 = 0;
49     Float_t lPt1 = 0; Float_t lEta1 = 0; Float_t lPhi1 = 0;
50    
51 ceballos 1.7 ParticleOArr *leptons = GetObjThisEvt<ParticleOArr>(ModNames::gkMergedLeptonsName);
52     if(leptons->GetEntries() >= 1){
53     lPt0 = leptons->At(0)->Pt(); lEta0 = leptons->At(0)->Eta(); lPhi0 = leptons->At(0)->Phi();
54     }
55     if(leptons->GetEntries() >= 2){
56     lPt1 = leptons->At(1)->Pt(); lEta1 = leptons->At(1)->Eta(); lPhi1 = leptons->At(1)->Phi();
57     }
58    
59 pharris 1.1 MetOArr *MVAMet = new MetOArr;
60     MVAMet->SetName(fMVAMetName);
61 ceballos 1.5
62     PFJetOArr *thePFJets = new PFJetOArr;
63     for(UInt_t i=0; i<fJets->GetEntries(); i++) {
64     const PFJet *ptJet = dynamic_cast<const PFJet*>(fJets->At(i));
65     thePFJets->Add(ptJet);
66     }
67    
68 pharris 1.1 Met lMVAMet = fMVAMet->GetMet( false,
69     lPt0,lPhi0,lEta0,
70     lPt1,lPhi1,lEta1,
71     fPFMet->At(0),
72     fCands,fVertices->At(0),fVertices,
73 ceballos 1.5 thePFJets,
74 pharris 1.1 int(fVertices->GetEntries()));
75    
76     MVAMet->Add(&lMVAMet);
77 ceballos 1.2
78 pharris 1.1 // sort according to pt
79     MVAMet->Sort();
80 ceballos 1.6
81 pharris 1.1 // add to event for other modules to use
82 ceballos 1.5 AddObjThisEvt(MVAMet);
83 ceballos 1.6
84     // delete temporal PFJet
85     delete thePFJets;
86    
87 pharris 1.1 }
88    
89 ceballos 1.2 //--------------------------------------------------------------------------------------------------
90     void MVAMetMod::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    
96 ceballos 1.5 //ReqBranch(fJetsName, fJets);
97 ceballos 1.4 ReqBranch(fPFCandName, fCands);
98     ReqBranch(fPFMetName, fPFMet);
99    
100 ceballos 1.2 fMVAMet = new MVAMet();
101     fMVAMet->Initialize(TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/mva_JetID_lowpt.weights.xml"))),
102     TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/mva_JetID_highpt.weights.xml"))),
103     TString(getenv("CMSSW_BASE")+string("/src/MitPhysics/Utils/python/JetIdParams_cfi.py")),
104     TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmet.root"))),
105     TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmetphi.root")))
106     );
107     }
108    
109     //--------------------------------------------------------------------------------------------------
110     void MVAMetMod::SlaveTerminate()
111     {
112     delete fMVAMet;
113     }