ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/JetIDMod.cc
Revision: 1.29
Committed: Thu May 24 06:03:11 2012 UTC (12 years, 11 months ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_029c, Mit_029b, Mit_029a, Mit_028a, HEAD
Changes since 1.28: +2 -2 lines
Log Message:
bug in terminate

File Contents

# Content
1 // $Id: JetIDMod.cc,v 1.28 2012/04/07 11:51:10 ceballos Exp $
2
3 #include "MitPhysics/Mods/interface/JetIDMod.h"
4 #include "MitCommon/MathTools/interface/MathUtils.h"
5 #include "MitAna/DataTree/interface/JetCol.h"
6 #include "MitPhysics/Init/interface/ModNames.h"
7 #include "MitAna/DataTree/interface/CaloJetCol.h"
8 #include "MitAna/DataTree/interface/PFJetCol.h"
9 #include "MitPhysics/Utils/interface/JetTools.h"
10
11 using namespace mithep;
12
13 ClassImp(mithep::JetIDMod)
14
15 //--------------------------------------------------------------------------------------------------
16 JetIDMod::JetIDMod(const char *name, const char *title) :
17 BaseMod(name,title),
18 fJetsName(ModNames::gkPubJetsName),
19 fGoodJetsName(ModNames::gkGoodJetsName),
20 fVertexName(ModNames::gkGoodVertexesName),
21 fUseJetCorrection(kTRUE),
22 fJetPtCut(35.0),
23 fJetEtaMaxCut(5.0),
24 fJetEEMFractionMinCut(0.01),
25 fApplyBetaCut(kFALSE),
26 fApplyMVACut(kFALSE),
27 fVertices(0)
28 {
29 }
30
31 //-------------------------------------------------------------------------------------------------
32 void JetIDMod::Process()
33 {
34 // Process entries of the tree.
35
36 const JetCol *inJets = GetObjThisEvt<JetCol>(fJetsName);
37 if (!inJets) {
38 SendError(kAbortModule, "Process",
39 "Pointer to input jet collection %s is null.",
40 fJetsName.Data());
41 return;
42 }
43
44 JetOArr *GoodJets = new JetOArr;
45 GoodJets->SetName(fGoodJetsName);
46
47 fVertices = GetObjThisEvt<VertexOArr>(fVertexName);
48
49 // loop over jets
50 for (UInt_t i=0; i<inJets->GetEntries(); ++i) {
51 const Jet *jet = inJets->At(i);
52
53 if (jet->AbsEta() > fJetEtaMaxCut)
54 continue;
55
56 Double_t jetpt;
57 if (fUseJetCorrection)
58 jetpt = jet->Pt();
59 else
60 jetpt = jet->RawMom().Pt();
61
62 if (jetpt < fJetPtCut)
63 continue;
64
65 Bool_t passEEMFractionMinCut = kTRUE;
66 if(fJetEEMFractionMinCut > 0){
67 const CaloJet *caloJet = dynamic_cast<const CaloJet*>(jet);
68 // The 2.6 value is hardcoded, no reason to change that value in CMS
69 if (caloJet && caloJet->AbsEta() < 2.6 &&
70 caloJet->EnergyFractionEm() < fJetEEMFractionMinCut)
71 passEEMFractionMinCut = kFALSE;
72 }
73 if(passEEMFractionMinCut == kFALSE)
74 continue;
75
76 // Jet to vertex association cut
77 const PFJet *pfJet = dynamic_cast<const PFJet*>(jet);
78 Bool_t passBetaCut = kTRUE;
79 if (pfJet && fApplyBetaCut == kTRUE) {
80 passBetaCut = JetTools::PassBetaVertexAssociationCut(dynamic_cast<const PFJet*>(jet), fVertices->At(0), fVertices, 0.2);
81 }
82 if(passBetaCut == kFALSE)
83 continue;
84
85 if(fApplyMVACut == kTRUE &&
86 fJetIDMVA->pass(pfJet,fVertices->At(0),fVertices) == kFALSE) continue;
87
88 // add good jet to collection
89 GoodJets->Add(jet);
90 }
91
92 // sort according to pt
93 GoodJets->Sort();
94
95 // add to event for other modules to use
96 AddObjThisEvt(GoodJets);
97 }
98
99 //--------------------------------------------------------------------------------------------------
100 void JetIDMod::SlaveBegin()
101 {
102 // Run startup code on the computer (slave) doing the actual analysis. Here,
103 // we typically initialize histograms and other analysis objects and request
104 // branches. For this module, we request a branch of the MitTree.
105
106 if(fApplyMVACut == kTRUE){
107 fJetIDMVA = new JetIDMVA();
108 fJetIDMVA->Initialize(JetIDMVA::kLoose,
109 TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/mva_JetID_lowpt.weights.xml"))),
110 TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/mva_JetID_highpt.weights.xml"))),
111 JetIDMVA::kBaseline,
112 TString(getenv("CMSSW_BASE")+string("/src/MitPhysics/Utils/python/JetIdParams_cfi.py")));
113 }
114
115 }
116
117 //--------------------------------------------------------------------------------------------------
118 void JetIDMod::SlaveTerminate()
119 {
120 if(fApplyMVACut == kTRUE) delete fJetIDMVA;
121 }