ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/MVAMetMod.cc
Revision: 1.5
Committed: Sat Apr 7 16:45:04 2012 UTC (13 years, 1 month ago) by ceballos
Content type: text/plain
Branch: MAIN
Changes since 1.4: +15 -4 lines
Log Message:
fixing a mess with pfjets and jets

File Contents

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