1 |
bendavid |
1.2 |
// $Id: FillerJPTJets.cc,v 1.1 2010/05/04 11:56:43 bendavid Exp $
|
2 |
bendavid |
1.1 |
|
3 |
|
|
#include "MitProd/TreeFiller/interface/FillerJPTJets.h"
|
4 |
|
|
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
|
5 |
|
|
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
|
6 |
|
|
#include "DataFormats/JetReco/interface/JPTJet.h"
|
7 |
|
|
#include "DataFormats/BTauReco/interface/JetTag.h"
|
8 |
|
|
#include "SimDataFormats/JetMatching/interface/JetFlavour.h"
|
9 |
|
|
#include "SimDataFormats/JetMatching/interface/JetFlavourMatching.h"
|
10 |
|
|
#include "SimDataFormats/JetMatching/interface/MatchedPartons.h"
|
11 |
|
|
#include "SimDataFormats/JetMatching/interface/JetMatchedPartons.h"
|
12 |
|
|
#include "JetMETCorrections/Objects/interface/JetCorrector.h"
|
13 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
14 |
|
|
#include "MitAna/DataTree/interface/CaloJetCol.h"
|
15 |
|
|
#include "MitAna/DataTree/interface/JPTJetCol.h"
|
16 |
|
|
#include "MitEdm/DataFormats/interface/RefToBaseToPtr.h"
|
17 |
|
|
#include "MitProd/ObjectService/interface/ObjectService.h"
|
18 |
|
|
|
19 |
|
|
using namespace std;
|
20 |
|
|
using namespace edm;
|
21 |
|
|
using namespace mithep;
|
22 |
|
|
|
23 |
|
|
//--------------------------------------------------------------------------------------------------
|
24 |
|
|
FillerJPTJets::FillerJPTJets(const ParameterSet &cfg, const char *name, bool active) :
|
25 |
|
|
BaseFiller(cfg,name,active),
|
26 |
|
|
flavorMatchingActive_(Conf().getUntrackedParameter<bool>("flavorMatchingActive",true)),
|
27 |
|
|
bTaggingActive_(Conf().getUntrackedParameter<bool>("bTaggingActive",true)),
|
28 |
|
|
jetToVertexActive_(Conf().getUntrackedParameter<bool>("jetToVertexActive",true)),
|
29 |
|
|
jetCorrectionsActive_(Conf().getUntrackedParameter<bool>("jetCorrectionsActive",true)),
|
30 |
|
|
edmName_(Conf().getUntrackedParameter<string>("edmName","recoJPTJets:iterativeCone5JPTJets")),
|
31 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName","ItrCone5JPTJets")),
|
32 |
|
|
jetToVertexAlphaName_(Conf().getUntrackedParameter<string>
|
33 |
|
|
("jetToVertexAlphaName","jetToVertexAlpha")),
|
34 |
|
|
jetToVertexBetaName_(Conf().getUntrackedParameter<string>
|
35 |
|
|
("jetToVertexBetaName","jetToVertexBetaName")),
|
36 |
|
|
L2JetCorrectorName_(Conf().getUntrackedParameter<string>
|
37 |
|
|
("L2JetCorrectorName","L2JetCorrectorName")),
|
38 |
|
|
L3JetCorrectorName_(Conf().getUntrackedParameter<string>
|
39 |
|
|
("L3JetCorrectorName","L3JetCorrectorName")),
|
40 |
|
|
flavorMatchingByReferenceName_(Conf().getUntrackedParameter<string>
|
41 |
|
|
("flavorMatchingByReferenceName","srcByReference")),
|
42 |
|
|
flavorMatchingDefinition_(Conf().getUntrackedParameter<string>
|
43 |
|
|
("flavorMatchingDefinition","Algorithmic")),
|
44 |
|
|
jetProbabilityBJetTagsName_(Conf().getUntrackedParameter<string>
|
45 |
|
|
("JetProbabilityBJetTagsName","jetProbabilityBJetTags")),
|
46 |
|
|
jetBProbabilityBJetTagsName_(Conf().getUntrackedParameter<string>
|
47 |
|
|
("JetBProbabilityBJetTagsName","jetBProbabilityBJetTags")),
|
48 |
|
|
simpleSecondaryVertexBJetTagsName_(Conf().getUntrackedParameter<string>
|
49 |
|
|
("SimpleSecondaryVertexBJetTagsName","simpleSecondaryVertexBJetTags")),
|
50 |
|
|
combinedSecondaryVertexBJetTagsName_(Conf().getUntrackedParameter<string>
|
51 |
|
|
("CombinedSecondaryVertexBJetTagsName","combinedSecondaryVertexBJetTags")),
|
52 |
|
|
combinedSecondaryVertexMVABJetTagsName_(Conf().getUntrackedParameter<string>
|
53 |
|
|
("CombinedSecondaryVertexMVABJetTagsName","combinedSecondaryVertexMVABJetTags")),
|
54 |
|
|
trackCountingHighEffBJetTagsName_(Conf().getUntrackedParameter<string>
|
55 |
|
|
("TrackCountingHighEffBJetTagsName","trackCountingHighEffBJetTags")),
|
56 |
|
|
trackCountingHighPurBJetTagsName_(Conf().getUntrackedParameter<string>
|
57 |
|
|
("TrackCountingHighPurBJetTagsName","trackCountingHighPurBJetTags")),
|
58 |
|
|
softMuonBJetTagsName_(Conf().getUntrackedParameter<string>
|
59 |
|
|
("SoftMuonBJetTagsName","softMuonBJetTags")),
|
60 |
|
|
softMuonByIP3dBJetTagsName_(Conf().getUntrackedParameter<string>
|
61 |
|
|
("SoftMuonByIP3dBJetTagsName","softMuonByIP3dBJetTags")),
|
62 |
|
|
softMuonByPtBJetTagsName_(Conf().getUntrackedParameter<string>
|
63 |
|
|
("SoftMuonByPtBJetTagsName","softMuonByPtBJetTags")),
|
64 |
|
|
softElectronByIP3dBJetTagsName_(Conf().getUntrackedParameter<string>
|
65 |
|
|
("SoftElectronByIP3dBJetTagsName","softElectronByIP3dBJetTags")),
|
66 |
|
|
softElectronByPtBJetTagsName_(Conf().getUntrackedParameter<string>
|
67 |
|
|
("SoftElectronByPtBJetTagsName","softElectronByPtBJetTags")),
|
68 |
|
|
caloJetMapName_(Conf().getUntrackedParameter<string>("caloJetCandMapName","caloJetMapName")),
|
69 |
|
|
jetMapName_(Conf().getUntrackedParameter<string>("jetMapName","JPTJetMap")),
|
70 |
|
|
caloJetMap_(0),
|
71 |
|
|
jetMap_(new mithep::JPTJetMap),
|
72 |
|
|
jets_(new mithep::JPTJetArr(16))
|
73 |
|
|
{
|
74 |
|
|
// Constructor.
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
//--------------------------------------------------------------------------------------------------
|
78 |
|
|
FillerJPTJets::~FillerJPTJets()
|
79 |
|
|
{
|
80 |
|
|
// Destructor.
|
81 |
|
|
|
82 |
|
|
delete jets_;
|
83 |
|
|
delete jetMap_;
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
//--------------------------------------------------------------------------------------------------
|
87 |
|
|
void FillerJPTJets::BookDataBlock(TreeWriter &tws)
|
88 |
|
|
{
|
89 |
|
|
// Add jets branch to tree.
|
90 |
|
|
|
91 |
|
|
tws.AddBranch(mitName_,&jets_);
|
92 |
|
|
OS()->add<mithep::JPTJetArr>(jets_,mitName_);
|
93 |
|
|
|
94 |
|
|
if (!caloJetMapName_.empty()) {
|
95 |
|
|
caloJetMap_ = OS()->get<CaloJetMap>(caloJetMapName_);
|
96 |
|
|
if (caloJetMap_)
|
97 |
|
|
AddBranchDep(mitName_,caloJetMap_->GetBrName());
|
98 |
|
|
}
|
99 |
|
|
if (!jetMapName_.empty()) {
|
100 |
|
|
jetMap_->SetBrName(mitName_);
|
101 |
|
|
OS()->add<JPTJetMap>(jetMap_,jetMapName_);
|
102 |
|
|
}
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
//--------------------------------------------------------------------------------------------------
|
106 |
|
|
void FillerJPTJets::FillDataBlock(const edm::Event &event,
|
107 |
|
|
const edm::EventSetup &setup)
|
108 |
|
|
{
|
109 |
|
|
// Fill jets from edm collection into our collection.
|
110 |
|
|
|
111 |
|
|
jets_->Delete();
|
112 |
|
|
jetMap_->Reset();
|
113 |
|
|
|
114 |
|
|
// handle for the Jet Collection
|
115 |
|
|
Handle<reco::JPTJetCollection> hJetProduct;
|
116 |
|
|
GetProduct(edmName_, hJetProduct, event);
|
117 |
|
|
|
118 |
|
|
// handles for jet flavour matching
|
119 |
|
|
Handle<reco::JetMatchedPartonsCollection> hPartonMatchingProduct;
|
120 |
|
|
if (flavorMatchingActive_)
|
121 |
|
|
GetProduct(flavorMatchingByReferenceName_, hPartonMatchingProduct, event);
|
122 |
|
|
|
123 |
|
|
Handle<reco::JetTagCollection> hJetProbabilityBJetTags;
|
124 |
|
|
Handle<reco::JetTagCollection> hJetBProbabilityBJetTags;
|
125 |
|
|
Handle<reco::JetTagCollection> hSimpleSecondaryVertexBJetTags;
|
126 |
|
|
Handle<reco::JetTagCollection> hCombinedSecondaryVertexBJetTags;
|
127 |
|
|
Handle<reco::JetTagCollection> hCombinedSecondaryVertexMVABJetTags;
|
128 |
|
|
Handle<reco::JetTagCollection> hTrackCountingHighEffBJetTags;
|
129 |
|
|
Handle<reco::JetTagCollection> hTrackCountingHighPurBJetTags;
|
130 |
|
|
Handle<reco::JetTagCollection> hSoftMuonBJetTags;
|
131 |
|
|
Handle<reco::JetTagCollection> hSoftMuonByIP3dBJetTags;
|
132 |
|
|
Handle<reco::JetTagCollection> hSoftMuonByPtBJetTags;
|
133 |
|
|
Handle<reco::JetTagCollection> hSoftElectronByIP3dBJetTags;
|
134 |
|
|
Handle<reco::JetTagCollection> hSoftElectronByPtBJetTags;
|
135 |
|
|
|
136 |
|
|
if (bTaggingActive_) {
|
137 |
|
|
GetProduct(jetProbabilityBJetTagsName_, hJetProbabilityBJetTags, event);
|
138 |
|
|
GetProduct(jetBProbabilityBJetTagsName_, hJetBProbabilityBJetTags, event);
|
139 |
|
|
GetProduct(simpleSecondaryVertexBJetTagsName_, hSimpleSecondaryVertexBJetTags, event);
|
140 |
|
|
GetProduct(combinedSecondaryVertexBJetTagsName_, hCombinedSecondaryVertexBJetTags, event);
|
141 |
|
|
GetProduct(combinedSecondaryVertexMVABJetTagsName_, hCombinedSecondaryVertexMVABJetTags, event);
|
142 |
|
|
GetProduct(trackCountingHighEffBJetTagsName_, hTrackCountingHighEffBJetTags, event);
|
143 |
|
|
GetProduct(trackCountingHighPurBJetTagsName_, hTrackCountingHighPurBJetTags, event);
|
144 |
|
|
GetProduct(softMuonBJetTagsName_, hSoftMuonBJetTags, event);
|
145 |
|
|
GetProduct(softMuonByIP3dBJetTagsName_, hSoftMuonByIP3dBJetTags, event);
|
146 |
|
|
GetProduct(softMuonByPtBJetTagsName_, hSoftMuonByPtBJetTags, event);
|
147 |
|
|
GetProduct(softElectronByIP3dBJetTagsName_, hSoftElectronByIP3dBJetTags, event);
|
148 |
|
|
GetProduct(softElectronByPtBJetTagsName_, hSoftElectronByPtBJetTags, event);
|
149 |
|
|
}
|
150 |
|
|
|
151 |
|
|
const reco::JPTJetCollection inJets = *(hJetProduct.product());
|
152 |
|
|
|
153 |
|
|
//Handles to Jet to Vertex Association
|
154 |
|
|
Handle<std::vector<double> > JV_alpha;
|
155 |
|
|
Handle<std::vector<double> > JV_beta;
|
156 |
|
|
std::vector<double>::const_iterator it_jv_alpha;
|
157 |
|
|
std::vector<double>::const_iterator it_jv_beta;
|
158 |
|
|
|
159 |
|
|
if (jetToVertexActive_) {
|
160 |
|
|
GetProduct(jetToVertexAlphaName_, JV_alpha, event);
|
161 |
|
|
GetProduct(jetToVertexBetaName_, JV_beta, event);
|
162 |
|
|
it_jv_alpha = JV_alpha->begin();
|
163 |
|
|
it_jv_beta = JV_beta->begin();
|
164 |
|
|
}
|
165 |
|
|
|
166 |
|
|
//Define Jet Correction Services
|
167 |
|
|
const JetCorrector* correctorL2 = 0;
|
168 |
|
|
const JetCorrector* correctorL3 = 0;
|
169 |
|
|
if (jetCorrectionsActive_) {
|
170 |
|
|
correctorL2 = JetCorrector::getJetCorrector (L2JetCorrectorName_,setup);
|
171 |
|
|
correctorL3 = JetCorrector::getJetCorrector (L3JetCorrectorName_,setup);
|
172 |
|
|
}
|
173 |
|
|
|
174 |
|
|
// loop through all jets
|
175 |
|
|
for (reco::JPTJetCollection::const_iterator inJet = inJets.begin();
|
176 |
|
|
inJet != inJets.end(); ++inJet) {
|
177 |
|
|
|
178 |
|
|
reco::JPTJetRef jetRef(hJetProduct, inJet - inJets.begin());
|
179 |
|
|
reco::JetBaseRef jetBaseRef(jetRef);
|
180 |
|
|
|
181 |
|
|
mithep::JPTJet *jet = jets_->Allocate();
|
182 |
|
|
new (jet) mithep::JPTJet(inJet->p4().x(),
|
183 |
|
|
inJet->p4().y(),
|
184 |
|
|
inJet->p4().z(),
|
185 |
|
|
inJet->p4().e());
|
186 |
|
|
|
187 |
|
|
//add to map
|
188 |
|
|
edm::Ptr<reco::JPTJet> thePtr(hJetProduct, inJet - inJets.begin());
|
189 |
|
|
jetMap_->Add(thePtr, jet);
|
190 |
|
|
|
191 |
|
|
//fill jet moments
|
192 |
|
|
jet->SetSigmaEta(TMath::Sqrt(inJet->etaetaMoment()));
|
193 |
|
|
jet->SetSigmaPhi(TMath::Sqrt(inJet->phiphiMoment()));
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
//fill jptjet-specific quantities
|
197 |
|
|
jet->SetZSPCor(inJet->getZSPCor());
|
198 |
|
|
jet->SetChargedHadronEnergy(inJet->chargedHadronEnergy());
|
199 |
|
|
jet->SetNeutralHadronEnergy(inJet->neutralHadronEnergy());
|
200 |
|
|
jet->SetChargedEmEnergy(inJet->chargedHadronEnergy());
|
201 |
|
|
jet->SetNeutralEmEnergy(inJet->neutralEmEnergy());
|
202 |
|
|
jet->SetResponseOfChargedWithEff(inJet->getSpecific().mResponseOfChargedWithEff);
|
203 |
|
|
jet->SetResponseOfChargedWithoutEff(inJet->getSpecific().mResponseOfChargedWithoutEff);
|
204 |
|
|
jet->SetSumPtOfChargedWithEff(inJet->getSpecific().mSumPtOfChargedWithEff);
|
205 |
|
|
jet->SetSumPtOfChargedWithoutEff(inJet->getSpecific().mSumPtOfChargedWithoutEff);
|
206 |
|
|
jet->SetSumEnergyOfChargedWithEff(inJet->getSpecific().mSumEnergyOfChargedWithEff);
|
207 |
|
|
jet->SetSumEnergyOfChargedWithoutEff(inJet->getSpecific().mSumEnergyOfChargedWithoutEff);
|
208 |
|
|
jet->SetR2momtr(inJet->getSpecific().R2momtr);
|
209 |
|
|
jet->SetEta2momtr(inJet->getSpecific().Eta2momtr);
|
210 |
|
|
jet->SetPhi2momtr(inJet->getSpecific().Phi2momtr);
|
211 |
|
|
jet->SetPout(inJet->getSpecific().Pout);
|
212 |
|
|
jet->SetZch(inJet->getSpecific().Zch);
|
213 |
|
|
jet->SetChargedMultiplicity(inJet->chargedMultiplicity());
|
214 |
|
|
jet->SetMuonMultiplicity(inJet->muonMultiplicity());
|
215 |
|
|
jet->SetElectronMultiplicity(inJet->elecMultiplicity());
|
216 |
|
|
|
217 |
|
|
if (jetToVertexActive_) {
|
218 |
|
|
//compute alpha and beta parameter for jets
|
219 |
|
|
jet->SetAlpha((*it_jv_alpha));
|
220 |
|
|
jet->SetBeta((*it_jv_beta));
|
221 |
|
|
}
|
222 |
|
|
|
223 |
|
|
//Jet Corrections
|
224 |
|
|
if (jetCorrectionsActive_) {
|
225 |
|
|
double L2Scale = correctorL2->correction(inJet->p4());
|
226 |
|
|
double L3Scale = correctorL3->correction(inJet->p4()*L2Scale);
|
227 |
|
|
jet->SetL2RelativeCorrectionScale(L2Scale);
|
228 |
|
|
jet->SetL3AbsoluteCorrectionScale(L3Scale);
|
229 |
|
|
jet->EnableCorrection(mithep::JPTJet::L2);
|
230 |
|
|
jet->EnableCorrection(mithep::JPTJet::L3);
|
231 |
|
|
}
|
232 |
|
|
|
233 |
|
|
if (bTaggingActive_) {
|
234 |
|
|
jet->SetJetProbabilityBJetTagsDisc((*(hJetProbabilityBJetTags.product()))[jetBaseRef]);
|
235 |
|
|
jet->SetJetBProbabilityBJetTagsDisc((*(hJetBProbabilityBJetTags.product()))[jetBaseRef]);
|
236 |
|
|
jet->SetSimpleSecondaryVertexBJetTagsDisc(
|
237 |
|
|
(*(hSimpleSecondaryVertexBJetTags.product()))[jetBaseRef]);
|
238 |
|
|
jet->SetCombinedSecondaryVertexBJetTagsDisc(
|
239 |
|
|
(*(hCombinedSecondaryVertexBJetTags.product()))[jetBaseRef]);
|
240 |
|
|
jet->SetCombinedSecondaryVertexMVABJetTagsDisc(
|
241 |
|
|
(*(hCombinedSecondaryVertexMVABJetTags.product()))[jetBaseRef]);
|
242 |
|
|
jet->SetTrackCountingHighEffBJetTagsDisc(
|
243 |
|
|
(*(hTrackCountingHighEffBJetTags.product()))[jetBaseRef]);
|
244 |
|
|
jet->SetTrackCountingHighPurBJetTagsDisc(
|
245 |
|
|
(*(hTrackCountingHighPurBJetTags.product()))[jetBaseRef]);
|
246 |
|
|
jet->SetSoftMuonBJetTagsDisc((*(hSoftMuonBJetTags.product()))[jetBaseRef]);
|
247 |
|
|
jet->SetSoftMuonByIP3dBJetTagsDisc((*(hSoftMuonByIP3dBJetTags.product()))[jetBaseRef]);
|
248 |
|
|
jet->SetSoftMuonByPtBJetTagsDisc((*(hSoftMuonByPtBJetTags.product()))[jetBaseRef]);
|
249 |
|
|
jet->SetSoftElectronByIP3dBJetTagsDisc((*(hSoftElectronByIP3dBJetTags.product()))[jetBaseRef]);
|
250 |
|
|
jet->SetSoftElectronByPtBJetTagsDisc((*(hSoftElectronByPtBJetTags.product()))[jetBaseRef]);
|
251 |
|
|
}
|
252 |
|
|
|
253 |
|
|
// get the Monte Carlo flavour matching information
|
254 |
|
|
if (flavorMatchingActive_) {
|
255 |
|
|
unsigned int iJet = inJet - inJets.begin();
|
256 |
|
|
const reco::JetMatchedPartonsCollection *matchedPartons = hPartonMatchingProduct.product();
|
257 |
|
|
reco::MatchedPartons matchedParton = (*matchedPartons)[matchedPartons->key(iJet)];
|
258 |
|
|
int flavorPhysDef = (matchedParton.physicsDefinitionParton().isNonnull())?
|
259 |
|
|
matchedParton.physicsDefinitionParton()->pdgId():0;
|
260 |
|
|
int flavorAlgDef = (matchedParton.algoDefinitionParton().isNonnull())?
|
261 |
|
|
matchedParton.algoDefinitionParton()->pdgId():0;
|
262 |
|
|
|
263 |
|
|
if (flavorMatchingDefinition_ == "Algorithmic") {
|
264 |
|
|
jet->SetMatchedMCFlavor(flavorAlgDef);
|
265 |
|
|
} else if(flavorMatchingDefinition_ == "Physics") {
|
266 |
|
|
jet->SetMatchedMCFlavor(flavorPhysDef);
|
267 |
|
|
} else {
|
268 |
|
|
jet->SetMatchedMCFlavor(0);
|
269 |
|
|
}
|
270 |
|
|
}
|
271 |
|
|
|
272 |
|
|
// fill ref to original jet
|
273 |
bendavid |
1.2 |
if (caloJetMap_ && inJet->getCaloJetRef().isNonnull()) {
|
274 |
bendavid |
1.1 |
const edm::Ptr<reco::CaloJet> caloJetPtr(mitedm::refToBaseToPtr(inJet->getCaloJetRef()));
|
275 |
|
|
const mithep::Jet *originalJet = caloJetMap_->GetMit(caloJetPtr);
|
276 |
|
|
jet->SetOriginalJet(originalJet);
|
277 |
|
|
}
|
278 |
|
|
if (jetToVertexActive_) {
|
279 |
|
|
it_jv_alpha++;
|
280 |
|
|
it_jv_beta++;
|
281 |
|
|
}
|
282 |
|
|
}
|
283 |
|
|
jets_->Trim();
|
284 |
|
|
}
|