24 |
|
#include "DataFormats/JetReco/interface/CaloJetCollection.h" |
25 |
|
#include "SimDataFormats/HiGenData/interface/GenHIEvent.h" |
26 |
|
#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h" |
27 |
+ |
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" |
28 |
|
#include "DataFormats/JetReco/interface/GenJetCollection.h" |
29 |
|
#include "DataFormats/VertexReco/interface/Vertex.h" |
30 |
|
#include "DataFormats/Math/interface/deltaPhi.h" |
43 |
|
using namespace reco; |
44 |
|
|
45 |
|
HiInclusiveJetAnalyzer::HiInclusiveJetAnalyzer(const edm::ParameterSet& iConfig) { |
45 |
– |
|
46 |
|
|
47 |
|
jetTag_ = iConfig.getParameter<InputTag>("jetTag"); |
48 |
+ |
matchTag_ = iConfig.getUntrackedParameter<InputTag>("matchTag",jetTag_); |
49 |
+ |
|
50 |
|
vtxTag_ = iConfig.getUntrackedParameter<edm::InputTag>("vtxTag",edm::InputTag("hiSelectedVertex")); |
51 |
+ |
trackTag_ = iConfig.getParameter<InputTag>("trackTag"); |
52 |
+ |
useQuality_ = iConfig.getUntrackedParameter<bool>("useQuality",1); |
53 |
+ |
trackQuality_ = iConfig.getUntrackedParameter<string>("trackQuality","highPurity"); |
54 |
|
|
55 |
|
isMC_ = iConfig.getUntrackedParameter<bool>("isMC",false); |
56 |
< |
|
56 |
> |
fillGenJets_ = iConfig.getUntrackedParameter<bool>("fillGenJets",false); |
57 |
> |
|
58 |
> |
doTrigger_ = iConfig.getUntrackedParameter<bool>("doTrigger",false); |
59 |
> |
|
60 |
> |
rParam = iConfig.getParameter<double>("rParam"); |
61 |
> |
hardPtMin_ = iConfig.getUntrackedParameter<double>("hardPtMin",4); |
62 |
> |
|
63 |
|
if(isMC_){ |
64 |
|
genjetTag_ = iConfig.getParameter<InputTag>("genjetTag"); |
65 |
|
eventInfoTag_ = iConfig.getParameter<InputTag>("eventInfoTag"); |
72 |
|
usePat_ = iConfig.getUntrackedParameter<bool>("usePAT",true); |
73 |
|
|
74 |
|
doLifeTimeTagging_ = iConfig.getUntrackedParameter<bool>("doLifeTimeTagging",false); |
75 |
+ |
doLifeTimeTaggingExtras_ = iConfig.getUntrackedParameter<bool>("doLifeTimeTaggingExtras",true); |
76 |
+ |
saveBfragments_ = iConfig.getUntrackedParameter<bool>("saveBfragments",false); |
77 |
+ |
|
78 |
|
pfCandidateLabel_ = iConfig.getUntrackedParameter<edm::InputTag>("pfCandidateLabel",edm::InputTag("particleFlowTmp")); |
79 |
|
|
80 |
< |
if(!isMC_){ |
80 |
> |
if(doTrigger_){ |
81 |
|
L1gtReadout_ = iConfig.getParameter<edm::InputTag>("L1gtReadout"); |
82 |
|
hltResName_ = iConfig.getUntrackedParameter<string>("hltTrgResults","TriggerResults::HLT"); |
83 |
|
|
94 |
|
} |
95 |
|
|
96 |
|
cout<<" jet collection : "<<jetTag_<<endl; |
97 |
+ |
doSubEvent_ = 0; |
98 |
+ |
|
99 |
|
if(isMC_){ |
100 |
|
cout<<" genjet collection : "<<genjetTag_<<endl; |
101 |
|
genPtMin_ = iConfig.getUntrackedParameter<double>("genPtMin",0); |
102 |
+ |
doSubEvent_ = iConfig.getUntrackedParameter<bool>("doSubEvent",1); |
103 |
|
} |
104 |
|
|
105 |
|
|
146 |
|
t->Branch("jty",jets_.jty,"jty[nref]/F"); |
147 |
|
t->Branch("jtphi",jets_.jtphi,"jtphi[nref]/F"); |
148 |
|
t->Branch("jtpu",jets_.jtpu,"jtpu[nref]/F"); |
149 |
+ |
t->Branch("jtm",jets_.jtm,"jtm[nref]/F"); |
150 |
+ |
|
151 |
+ |
// jet ID information, jet composition |
152 |
+ |
t->Branch("discr_fr01", jets_.discr_fr01,"discr_fr01[nref]/F"); |
153 |
+ |
|
154 |
+ |
t->Branch("trackMax", jets_.trackMax,"trackMax[nref]/F"); |
155 |
+ |
t->Branch("trackSum", jets_.trackSum,"trackSum[nref]/F"); |
156 |
+ |
t->Branch("trackN", jets_.trackN,"trackN[nref]/I"); |
157 |
+ |
t->Branch("trackHardSum", jets_.trackHardSum,"trackHardSum[nref]/F"); |
158 |
+ |
t->Branch("trackHardN", jets_.trackHardN,"trackHardN[nref]/I"); |
159 |
+ |
|
160 |
+ |
t->Branch("chargedMax", jets_.chargedMax,"chargedMax[nref]/F"); |
161 |
+ |
t->Branch("chargedSum", jets_.chargedSum,"chargedSum[nref]/F"); |
162 |
+ |
t->Branch("chargedN", jets_.chargedN,"chargedN[nref]/I"); |
163 |
+ |
t->Branch("chargedHardSum", jets_.chargedHardSum,"chargedHardSum[nref]/F"); |
164 |
+ |
t->Branch("chargedHardN", jets_.chargedHardN,"chargedHardN[nref]/I"); |
165 |
+ |
|
166 |
+ |
t->Branch("photonMax", jets_.photonMax,"photonMax[nref]/F"); |
167 |
+ |
t->Branch("photonSum", jets_.photonSum,"photonSum[nref]/F"); |
168 |
+ |
t->Branch("photonN", jets_.photonN,"photonN[nref]/I"); |
169 |
+ |
t->Branch("photonHardSum", jets_.photonHardSum,"photonHardSum[nref]/F"); |
170 |
+ |
t->Branch("photonHardN", jets_.photonHardN,"photonHardN[nref]/I"); |
171 |
+ |
|
172 |
+ |
t->Branch("neutralMax", jets_.neutralMax,"neutralMax[nref]/F"); |
173 |
+ |
t->Branch("neutralSum", jets_.neutralSum,"neutralSum[nref]/F"); |
174 |
+ |
t->Branch("neutralN", jets_.neutralN,"neutralN[nref]/I"); |
175 |
+ |
|
176 |
+ |
t->Branch("eMax", jets_.eMax,"eMax[nref]/F"); |
177 |
+ |
t->Branch("eSum", jets_.eSum,"eSum[nref]/F"); |
178 |
+ |
t->Branch("eN", jets_.eN,"eN[nref]/I"); |
179 |
+ |
|
180 |
+ |
t->Branch("muMax", jets_.muMax,"muMax[nref]/F"); |
181 |
+ |
t->Branch("muSum", jets_.muSum,"muSum[nref]/F"); |
182 |
+ |
t->Branch("muN", jets_.muN,"muN[nref]/I"); |
183 |
+ |
|
184 |
+ |
t->Branch("matchedPt", jets_.matchedPt,"matchedPt[nref]/F"); |
185 |
+ |
t->Branch("matchedR", jets_.matchedR,"matchedR[nref]/F"); |
186 |
|
|
187 |
|
// b-jet discriminators |
188 |
|
if (doLifeTimeTagging_) { |
196 |
|
t->Branch("discr_tcHighEff",jets_.discr_tcHighEff,"discr_tcHighEff[nref]/F"); |
197 |
|
t->Branch("discr_tcHighPur",jets_.discr_tcHighPur,"discr_tcHighPur[nref]/F"); |
198 |
|
|
199 |
< |
t->Branch("nsvtx", jets_.nsvtx, "nsvtx[nref]/b"); |
200 |
< |
t->Branch("svtxntrk", jets_.svtxntrk, "svtxntrk[nref]/b"); |
199 |
> |
t->Branch("nsvtx", jets_.nsvtx, "nsvtx[nref]/I"); |
200 |
> |
t->Branch("svtxntrk", jets_.svtxntrk, "svtxntrk[nref]/I"); |
201 |
|
t->Branch("svtxdl", jets_.svtxdl, "svtxdl[nref]/F"); |
202 |
|
t->Branch("svtxdls", jets_.svtxdls, "svtxdls[nref]/F"); |
203 |
|
t->Branch("svtxm", jets_.svtxm, "svtxm[nref]/F"); |
204 |
|
t->Branch("svtxpt", jets_.svtxpt, "svtxpt[nref]/F"); |
205 |
|
|
206 |
< |
t->Branch("nIPtracks",jets_.nIPtracks,"nIPTracks[nref]/b"); |
207 |
< |
t->Branch("nselIPtracks",jets_.nselIPtracks,"nselIPTracks[nref]/b"); |
206 |
> |
t->Branch("nIPtrk",jets_.nIPtrk,"nIPtrk[nref]/I"); |
207 |
> |
t->Branch("nselIPtrk",jets_.nselIPtrk,"nselIPtrk[nref]/I"); |
208 |
> |
|
209 |
> |
if (doLifeTimeTaggingExtras_) { |
210 |
> |
t->Branch("nIP",&jets_.nIP,"nIP/I"); |
211 |
> |
t->Branch("ipJetIndex",jets_.ipJetIndex,"ipJetIndex[nIP]/I"); |
212 |
> |
t->Branch("ipPt",jets_.ipPt,"ipPt[nIP]/F"); |
213 |
> |
t->Branch("ipProb0",jets_.ipProb0,"ipProb0[nIP]/F"); |
214 |
> |
t->Branch("ipProb1",jets_.ipProb1,"ipProb1[nIP]/F"); |
215 |
> |
t->Branch("ip2d",jets_.ip2d,"ip2d[nIP]/F"); |
216 |
> |
t->Branch("ip2dSig",jets_.ip2dSig,"ip2dSig[nIP]/F"); |
217 |
> |
t->Branch("ip3d",jets_.ip3d,"ip3d[nIP]/F"); |
218 |
> |
t->Branch("ip3dSig",jets_.ip3dSig,"ip3dSig[nIP]/F"); |
219 |
> |
t->Branch("ipDist2Jet",jets_.ipDist2Jet,"ipDist2Jet[nIP]/F"); |
220 |
> |
t->Branch("ipDist2JetSig",jets_.ipDist2JetSig,"ipDist2JetSig[nIP]/F"); |
221 |
> |
t->Branch("ipClosest2Jet",jets_.ipClosest2Jet,"ipClosest2Jet[nIP]/F"); |
222 |
> |
|
223 |
> |
} |
224 |
|
|
225 |
|
t->Branch("mue", jets_.mue, "mue[nref]/F"); |
226 |
|
t->Branch("mupt", jets_.mupt, "mupt[nref]/F"); |
230 |
|
t->Branch("muptrel", jets_.muptrel, "muptrel[nref]/F"); |
231 |
|
t->Branch("muchg", jets_.muchg, "muchg[nref]/I"); |
232 |
|
} |
233 |
+ |
|
234 |
|
|
235 |
|
if(isMC_){ |
236 |
+ |
t->Branch("beamId1",&jets_.beamId1,"beamId1/I"); |
237 |
+ |
t->Branch("beamId2",&jets_.beamId2,"beamId2/I"); |
238 |
+ |
|
239 |
|
t->Branch("pthat",&jets_.pthat,"pthat/F"); |
240 |
|
|
241 |
|
// Only matched gen jets |
250 |
|
t->Branch("refparton_flavor",jets_.refparton_flavor,"refparton_flavor[nref]/I"); |
251 |
|
t->Branch("refparton_flavorForB",jets_.refparton_flavorForB,"refparton_flavorForB[nref]/I"); |
252 |
|
|
253 |
< |
// For all gen jets, matched or unmatched |
254 |
< |
t->Branch("ngen",&jets_.ngen,"ngen/I"); |
255 |
< |
t->Branch("genmatchindex",jets_.genmatchindex,"genmatchindex[ngen]/I"); |
256 |
< |
t->Branch("genpt",jets_.genpt,"genpt[ngen]/F"); |
257 |
< |
t->Branch("geneta",jets_.geneta,"geneta[ngen]/F"); |
258 |
< |
t->Branch("geny",jets_.geny,"geny[ngen]/F"); |
259 |
< |
t->Branch("genphi",jets_.genphi,"genphi[ngen]/F"); |
260 |
< |
t->Branch("gendphijt",jets_.gendphijt,"gendphijt[ngen]/F"); |
261 |
< |
t->Branch("gendrjt",jets_.gendrjt,"gendrjt[ngen]/F"); |
253 |
> |
if(fillGenJets_){ |
254 |
> |
// For all gen jets, matched or unmatched |
255 |
> |
t->Branch("ngen",&jets_.ngen,"ngen/I"); |
256 |
> |
t->Branch("genmatchindex",jets_.genmatchindex,"genmatchindex[ngen]/I"); |
257 |
> |
t->Branch("genpt",jets_.genpt,"genpt[ngen]/F"); |
258 |
> |
t->Branch("geneta",jets_.geneta,"geneta[ngen]/F"); |
259 |
> |
t->Branch("geny",jets_.geny,"geny[ngen]/F"); |
260 |
> |
t->Branch("genphi",jets_.genphi,"genphi[ngen]/F"); |
261 |
> |
t->Branch("gendphijt",jets_.gendphijt,"gendphijt[ngen]/F"); |
262 |
> |
t->Branch("gendrjt",jets_.gendrjt,"gendrjt[ngen]/F"); |
263 |
> |
|
264 |
> |
if(doSubEvent_){ |
265 |
> |
t->Branch("gensubid",jets_.gensubid,"gensubid[ngen]/I"); |
266 |
> |
} |
267 |
> |
} |
268 |
> |
|
269 |
> |
if(saveBfragments_ ) { |
270 |
> |
t->Branch("bMult",&jets_.bMult,"bMult/I"); |
271 |
> |
t->Branch("bJetIndex",jets_.bJetIndex,"bJetIndex[bMult]/I"); |
272 |
> |
t->Branch("bStatus",jets_.bStatus,"bStatus[bMult]/I"); |
273 |
> |
t->Branch("bVx",jets_.bVx,"bVx[bMult]/F"); |
274 |
> |
t->Branch("bVy",jets_.bVy,"bVy[bMult]/F"); |
275 |
> |
t->Branch("bVz",jets_.bVz,"bVz[bMult]/F"); |
276 |
> |
t->Branch("bPt",jets_.bPt,"bPt[bMult]/F"); |
277 |
> |
t->Branch("bEta",jets_.bEta,"bEta[bMult]/F"); |
278 |
> |
t->Branch("bPhi",jets_.bPhi,"bPhi[bMult]/F"); |
279 |
> |
t->Branch("bPdg",jets_.bPdg,"bPdg[bMult]/I"); |
280 |
> |
t->Branch("bChg",jets_.bChg,"bChg[bMult]/I"); |
281 |
> |
} |
282 |
> |
|
283 |
|
} |
284 |
|
/* |
285 |
|
if(!isMC_){ |
333 |
|
|
334 |
|
|
335 |
|
|
241 |
– |
//double jetPtMin = 35.; |
242 |
– |
|
336 |
|
|
337 |
|
// loop the events |
338 |
|
|
353 |
|
|
354 |
|
edm::Handle<pat::JetCollection> patjets; |
355 |
|
if(usePat_)iEvent.getByLabel(jetTag_, patjets); |
356 |
+ |
|
357 |
+ |
edm::Handle<pat::JetCollection> matchedjets; |
358 |
+ |
iEvent.getByLabel(matchTag_, matchedjets); |
359 |
|
|
360 |
|
edm::Handle<reco::JetView> jets; |
361 |
|
iEvent.getByLabel(jetTag_, jets); |
362 |
|
|
363 |
|
edm::Handle<reco::PFCandidateCollection> pfCandidates; |
364 |
< |
if(doLifeTimeTagging_){ |
365 |
< |
iEvent.getByLabel(pfCandidateLabel_,pfCandidates); |
366 |
< |
} |
364 |
> |
iEvent.getByLabel(pfCandidateLabel_,pfCandidates); |
365 |
> |
|
366 |
> |
edm::Handle<reco::TrackCollection> tracks; |
367 |
> |
iEvent.getByLabel(trackTag_,tracks); |
368 |
> |
|
369 |
|
// FILL JRA TREE |
370 |
|
|
371 |
|
jets_.b = b; |
372 |
|
jets_.nref = 0; |
373 |
|
|
374 |
< |
if(!isMC_){ |
374 |
> |
if(doTrigger_){ |
375 |
|
fillL1Bits(iEvent); |
376 |
|
fillHLTBits(iEvent); |
377 |
|
} |
379 |
|
for(unsigned int j = 0 ; j < jets->size(); ++j){ |
380 |
|
const reco::Jet& jet = (*jets)[j]; |
381 |
|
|
382 |
< |
//cout<<" jet pt "<<jet.pt()<<endl; |
285 |
< |
//if(jet.pt() < jetPtMin) continue; |
382 |
> |
|
383 |
|
if (useJEC_ && usePat_){ |
384 |
|
jets_.rawpt[jets_.nref]=(*patjets)[j].correctedJet("Uncorrected").pt(); |
385 |
|
} |
407 |
|
jets_.discr_tcHighPur[jets_.nref] = (*patjets)[j].bDiscriminator("akPu3PFTrackCountingHighPurBJetTags"); |
408 |
|
} |
409 |
|
else{ |
410 |
< |
cout<<" you fail at btagging "<<endl; |
410 |
> |
cout<<" b-tagging variables not filled for this collection, turn of doLifeTimeTagging "<<endl; |
411 |
|
} |
412 |
< |
|
412 |
> |
|
413 |
|
const reco::SecondaryVertexTagInfo& tagInfoSV=*(*patjets)[j].tagInfoSecondaryVertex(); |
414 |
+ |
|
415 |
+ |
jets_.nsvtx[jets_.nref] = tagInfoSV.nVertices(); |
416 |
+ |
|
417 |
|
if (tagInfoSV.nVertices()>0) { |
318 |
– |
Measurement1D m1D = tagInfoSV.flightDistance(0); |
319 |
– |
jets_.nsvtx[jets_.nref] = tagInfoSV.nVertices(); |
418 |
|
jets_.svtxntrk[jets_.nref] = tagInfoSV.nVertexTracks(0); |
419 |
+ |
// this is the 3d flight distance, for 2-D use (0,true) |
420 |
+ |
Measurement1D m1D = tagInfoSV.flightDistance(0); |
421 |
|
jets_.svtxdl[jets_.nref] = m1D.value(); |
422 |
|
jets_.svtxdls[jets_.nref] = m1D.significance(); |
423 |
|
|
424 |
< |
const reco::Vertex& svtx = tagInfoSV.secondaryVertex(0); |
425 |
< |
|
424 |
> |
const reco::Vertex& svtx = tagInfoSV.secondaryVertex(0); |
425 |
> |
//cout<<" SV: vx: "<<svtx.x()<<" vy "<<svtx.y()<<" vz "<<svtx.z()<<endl; |
426 |
> |
//cout<<" PV: vx: "<<jet.vx()<<" vy "<<jet.vy()<<" vz "<<jet.vz()<<endl; |
427 |
|
jets_.svtxm[jets_.nref] = svtx.p4().mass(); |
428 |
< |
jets_.svtxpt[jets_.nref] = svtx.p4().pt(); |
429 |
< |
|
329 |
< |
} |
330 |
< |
else { |
331 |
< |
jets_.nsvtx[jets_.nref] = 0; |
332 |
< |
jets_.svtxntrk[jets_.nref] = 0; |
333 |
< |
jets_.svtxdl[jets_.nref] = 0.0; |
334 |
< |
jets_.svtxdls[jets_.nref] = 0.0; |
335 |
< |
jets_.svtxm[jets_.nref] = 0.0; |
336 |
< |
jets_.svtxpt[jets_.nref] = 0.0; |
428 |
> |
jets_.svtxpt[jets_.nref] = svtx.p4().pt(); |
429 |
> |
//cout<<" chi2 "<<svtx.chi2()<<" ndof "<<svtx.ndof()<<endl; |
430 |
|
} |
431 |
+ |
|
432 |
|
const reco::TrackIPTagInfo& tagInfoIP=*(*patjets)[j].tagInfoTrackIP(); |
433 |
+ |
|
434 |
+ |
jets_.nIPtrk[jets_.nref] = tagInfoIP.tracks().size(); |
435 |
+ |
jets_.nselIPtrk[jets_.nref] = tagInfoIP.selectedTracks().size(); |
436 |
|
|
437 |
< |
jets_.nIPtracks[jets_.nref] = tagInfoIP.tracks().size(); |
341 |
< |
jets_.nselIPtracks[jets_.nref] = tagInfoIP.selectedTracks().size(); |
437 |
> |
if (doLifeTimeTaggingExtras_) { |
438 |
|
|
439 |
< |
// would be nice to save the info for the tracks, but requires a more sophisticated tree |
440 |
< |
/* |
441 |
< |
//cout << "Jet pt: " << tagInfoIP.jet()->pt() << endl; |
442 |
< |
cout << "Tot tracks: " << tagInfoIP.tracks().size() << endl; |
443 |
< |
TrackRefVector selTracks=tagInfoIP.selectedTracks(); |
444 |
< |
int n=selTracks.size(); |
445 |
< |
cout << "Sel tracks: " << n << endl; |
446 |
< |
// false cout << " Pt \t d len \t jet dist \t p3d \t p2d\t ip3d \t ip2d " << endl; |
447 |
< |
GlobalPoint pv(tagInfoIP.primaryVertex()->position().x(),tagInfoIP.primaryVertex()->position().y(),tagInfoIP.primaryVertex()->position().z()); |
448 |
< |
cout << pv << " vs " << tagInfoIP.primaryVertex()->position() << endl; |
449 |
< |
for(int j=0;j< n;j++) |
450 |
< |
{ |
451 |
< |
TrackIPTagInfo::TrackIPData data = tagInfoIP.impactParameterData()[j]; |
452 |
< |
cout << selTracks[j]->pt() << "\t"; |
453 |
< |
cout << tagInfoIP.probabilities(0)[j] << "\t"; |
454 |
< |
cout << tagInfoIP.probabilities(1)[j] << "\t"; |
455 |
< |
cout << data.ip3d.value() << "\t"; |
456 |
< |
cout << data.ip3d.significance() << "\t"; |
457 |
< |
cout << data.distanceToJetAxis.value() << "\t"; |
458 |
< |
cout << data.distanceToJetAxis.significance() << "\t"; |
459 |
< |
cout << data.distanceToGhostTrack.value() << "\t"; |
364 |
< |
cout << data.distanceToGhostTrack.significance() << "\t"; |
365 |
< |
cout << data.closestToJetAxis << "\t"; |
366 |
< |
cout << (data.closestToJetAxis - pv).mag() << "\t"; |
367 |
< |
cout << data.closestToGhostTrack << "\t"; |
368 |
< |
cout << (data.closestToGhostTrack - pv).mag() << "\t"; |
369 |
< |
cout << data.ip2d.value() << "\t"; |
370 |
< |
cout << data.ip2d.significance() << endl; |
371 |
< |
} |
372 |
< |
*/ |
439 |
> |
TrackRefVector selTracks=tagInfoIP.selectedTracks(); |
440 |
> |
|
441 |
> |
GlobalPoint pv(tagInfoIP.primaryVertex()->position().x(),tagInfoIP.primaryVertex()->position().y(),tagInfoIP.primaryVertex()->position().z()); |
442 |
> |
|
443 |
> |
for(int it=0;it<jets_.nselIPtrk[jets_.nref] ;it++) |
444 |
> |
{ |
445 |
> |
jets_.ipJetIndex[jets_.nIP + it]= jets_.nref; |
446 |
> |
TrackIPTagInfo::TrackIPData data = tagInfoIP.impactParameterData()[it]; |
447 |
> |
jets_.ipPt[jets_.nIP + it] = selTracks[it]->pt(); |
448 |
> |
jets_.ipProb0[jets_.nIP + it] = tagInfoIP.probabilities(0)[it]; |
449 |
> |
jets_.ipProb1[jets_.nIP + it] = tagInfoIP.probabilities(1)[it]; |
450 |
> |
jets_.ip2d[jets_.nIP + it] = data.ip2d.value(); |
451 |
> |
jets_.ip2dSig[jets_.nIP + it] = data.ip2d.significance(); |
452 |
> |
jets_.ip3d[jets_.nIP + it] = data.ip3d.value(); |
453 |
> |
jets_.ip3dSig[jets_.nIP + it] = data.ip3d.significance(); |
454 |
> |
jets_.ipDist2Jet[jets_.nIP + it] = data.distanceToJetAxis.value(); |
455 |
> |
jets_.ipDist2JetSig[jets_.nIP + it] = data.distanceToJetAxis.significance(); |
456 |
> |
jets_.ipClosest2Jet[jets_.nIP + it] = (data.closestToJetAxis - pv).mag(); //decay length |
457 |
> |
} |
458 |
> |
|
459 |
> |
jets_.nIP += jets_.nselIPtrk[jets_.nref]; |
460 |
|
|
461 |
+ |
} |
462 |
+ |
|
463 |
|
const reco::PFCandidateCollection *pfCandidateColl = &(*pfCandidates); |
464 |
|
int pfMuonIndex = getPFJetMuon(jet, pfCandidateColl); |
465 |
|
if(pfMuonIndex >=0){ |
471 |
|
jets_.mudr[jets_.nref] = reco::deltaR(jet,muon); |
472 |
|
jets_.muptrel[jets_.nref] = getPtRel(muon, jet); |
473 |
|
jets_.muchg[jets_.nref] = muon.charge(); |
474 |
< |
} |
386 |
< |
else{ |
474 |
> |
}else{ |
475 |
|
jets_.mupt[jets_.nref] = 0.0; |
476 |
|
jets_.mueta[jets_.nref] = 0.0; |
477 |
|
jets_.muphi[jets_.nref] = 0.0; |
480 |
|
jets_.muptrel[jets_.nref] = 0.0; |
481 |
|
jets_.muchg[jets_.nref] = 0; |
482 |
|
} |
483 |
+ |
|
484 |
+ |
} |
485 |
+ |
|
486 |
+ |
|
487 |
+ |
|
488 |
+ |
// Jet ID variables |
489 |
+ |
|
490 |
+ |
jets_.muMax[jets_.nref] = 0; |
491 |
+ |
jets_.muSum[jets_.nref] = 0; |
492 |
+ |
jets_.muN[jets_.nref] = 0; |
493 |
+ |
|
494 |
+ |
jets_.eMax[jets_.nref] = 0; |
495 |
+ |
jets_.eSum[jets_.nref] = 0; |
496 |
+ |
jets_.eN[jets_.nref] = 0; |
497 |
+ |
|
498 |
+ |
jets_.neutralMax[jets_.nref] = 0; |
499 |
+ |
jets_.neutralSum[jets_.nref] = 0; |
500 |
+ |
jets_.neutralN[jets_.nref] = 0; |
501 |
+ |
|
502 |
+ |
jets_.photonMax[jets_.nref] = 0; |
503 |
+ |
jets_.photonSum[jets_.nref] = 0; |
504 |
+ |
jets_.photonN[jets_.nref] = 0; |
505 |
+ |
jets_.photonHardSum[jets_.nref] = 0; |
506 |
+ |
jets_.photonHardN[jets_.nref] = 0; |
507 |
+ |
|
508 |
+ |
jets_.chargedMax[jets_.nref] = 0; |
509 |
+ |
jets_.chargedSum[jets_.nref] = 0; |
510 |
+ |
jets_.chargedN[jets_.nref] = 0; |
511 |
+ |
jets_.chargedHardSum[jets_.nref] = 0; |
512 |
+ |
jets_.chargedHardN[jets_.nref] = 0; |
513 |
+ |
|
514 |
+ |
jets_.trackMax[jets_.nref] = 0; |
515 |
+ |
jets_.trackSum[jets_.nref] = 0; |
516 |
+ |
jets_.trackN[jets_.nref] = 0; |
517 |
+ |
jets_.trackHardSum[jets_.nref] = 0; |
518 |
+ |
jets_.trackHardN[jets_.nref] = 0; |
519 |
+ |
|
520 |
+ |
|
521 |
+ |
for(unsigned int icand = 0; icand < tracks->size(); ++icand){ |
522 |
+ |
const reco::Track& track = (*tracks)[icand]; |
523 |
+ |
if(useQuality_ ){ |
524 |
+ |
bool goodtrack = track.quality(reco::TrackBase::qualityByName(trackQuality_)); |
525 |
+ |
if(!goodtrack) continue; |
526 |
+ |
} |
527 |
+ |
|
528 |
+ |
double dr = deltaR(jet,track); |
529 |
+ |
if(dr < rParam){ |
530 |
+ |
double ptcand = track.pt(); |
531 |
+ |
jets_.trackSum[jets_.nref] += ptcand; |
532 |
+ |
jets_.trackN[jets_.nref] += 1; |
533 |
+ |
|
534 |
+ |
if(ptcand > hardPtMin_){ |
535 |
+ |
jets_.trackHardSum[jets_.nref] += ptcand; |
536 |
+ |
jets_.trackHardN[jets_.nref] += 1; |
537 |
+ |
|
538 |
+ |
} |
539 |
+ |
if(ptcand > jets_.trackMax[jets_.nref]) jets_.trackMax[jets_.nref] = ptcand; |
540 |
+ |
|
541 |
+ |
} |
542 |
+ |
} |
543 |
+ |
|
544 |
+ |
for(unsigned int icand = 0; icand < pfCandidates->size(); ++icand){ |
545 |
+ |
const reco::PFCandidate& track = (*pfCandidates)[icand]; |
546 |
+ |
double dr = deltaR(jet,track); |
547 |
+ |
if(dr < rParam){ |
548 |
+ |
double ptcand = track.pt(); |
549 |
+ |
int pfid = track.particleId(); |
550 |
+ |
|
551 |
+ |
switch(pfid){ |
552 |
+ |
|
553 |
+ |
case 1: |
554 |
+ |
jets_.chargedSum[jets_.nref] += ptcand; |
555 |
+ |
jets_.chargedN[jets_.nref] += 1; |
556 |
+ |
if(ptcand > hardPtMin_){ |
557 |
+ |
jets_.chargedHardSum[jets_.nref] += ptcand; |
558 |
+ |
jets_.chargedHardN[jets_.nref] += 1; |
559 |
+ |
} |
560 |
+ |
if(ptcand > jets_.chargedMax[jets_.nref]) jets_.chargedMax[jets_.nref] = ptcand; |
561 |
+ |
break; |
562 |
+ |
|
563 |
+ |
case 2: |
564 |
+ |
jets_.eSum[jets_.nref] += ptcand; |
565 |
+ |
jets_.eN[jets_.nref] += 1; |
566 |
+ |
if(ptcand > jets_.eMax[jets_.nref]) jets_.eMax[jets_.nref] = ptcand; |
567 |
+ |
break; |
568 |
+ |
|
569 |
+ |
case 3: |
570 |
+ |
jets_.muSum[jets_.nref] += ptcand; |
571 |
+ |
jets_.muN[jets_.nref] += 1; |
572 |
+ |
if(ptcand > jets_.muMax[jets_.nref]) jets_.muMax[jets_.nref] = ptcand; |
573 |
+ |
break; |
574 |
+ |
|
575 |
+ |
case 4: |
576 |
+ |
jets_.photonSum[jets_.nref] += ptcand; |
577 |
+ |
jets_.photonN[jets_.nref] += 1; |
578 |
+ |
if(ptcand > hardPtMin_){ |
579 |
+ |
jets_.photonHardSum[jets_.nref] += ptcand; |
580 |
+ |
jets_.photonHardN[jets_.nref] += 1; |
581 |
+ |
} |
582 |
+ |
if(ptcand > jets_.photonMax[jets_.nref]) jets_.photonMax[jets_.nref] = ptcand; |
583 |
+ |
break; |
584 |
+ |
|
585 |
+ |
case 5: |
586 |
+ |
jets_.neutralSum[jets_.nref] += ptcand; |
587 |
+ |
jets_.neutralN[jets_.nref] += 1; |
588 |
+ |
if(ptcand > jets_.neutralMax[jets_.nref]) jets_.neutralMax[jets_.nref] = ptcand; |
589 |
+ |
break; |
590 |
+ |
|
591 |
+ |
default: |
592 |
+ |
break; |
593 |
+ |
|
594 |
+ |
} |
595 |
+ |
} |
596 |
+ |
} |
597 |
+ |
|
598 |
+ |
double drMin = 100; |
599 |
+ |
for(unsigned int imatch = 0 ; imatch < matchedjets->size(); ++imatch){ |
600 |
+ |
const reco::Jet& mjet = (*matchedjets)[imatch]; |
601 |
+ |
|
602 |
+ |
double dr = deltaR(jet,mjet); |
603 |
+ |
if(dr < drMin){ |
604 |
+ |
jets_.matchedPt[jets_.nref] = mjet.pt(); |
605 |
+ |
jets_.matchedR[jets_.nref] = dr; |
606 |
+ |
drMin = dr; |
607 |
+ |
} |
608 |
|
} |
609 |
+ |
|
610 |
+ |
|
611 |
+ |
|
612 |
+ |
|
613 |
+ |
// if(etrk.quality(reco::TrackBase::qualityByName(qualityString_))) pev_.trkQual[pev_.nTrk]=1; |
614 |
+ |
|
615 |
+ |
///////////////////////////////////////////////////////////////// |
616 |
+ |
// Jet core pt^2 discriminant for fake jets |
617 |
+ |
// Edited by Yue Shi Lai <ylai@mit.edu> |
618 |
+ |
|
619 |
+ |
// Initial value is 0 |
620 |
+ |
jets_.discr_fr01[jets_.nref] = 0; |
621 |
+ |
// Start with no directional adaption, i.e. the fake rejection |
622 |
+ |
// axis is the jet axis |
623 |
+ |
float pseudorapidity_adapt = jets_.jteta[jets_.nref]; |
624 |
+ |
float azimuth_adapt = jets_.jtphi[jets_.nref]; |
625 |
+ |
|
626 |
+ |
// Unadapted discriminant with adaption search |
627 |
+ |
for (size_t iteration = 0; iteration < 2; iteration++) { |
628 |
+ |
float pseudorapidity_adapt_new = pseudorapidity_adapt; |
629 |
+ |
float azimuth_adapt_new = azimuth_adapt; |
630 |
+ |
float max_weighted_perp = 0; |
631 |
+ |
float perp_square_sum = 0; |
632 |
+ |
|
633 |
+ |
for (size_t index_pf_candidate = 0; |
634 |
+ |
index_pf_candidate < pfCandidates->size(); |
635 |
+ |
index_pf_candidate++) { |
636 |
+ |
const reco::PFCandidate &p = |
637 |
+ |
(*pfCandidates)[index_pf_candidate]; |
638 |
+ |
|
639 |
+ |
switch (p.particleId()) { |
640 |
+ |
//case 1: // Charged hadron |
641 |
+ |
//case 3: // Muon |
642 |
+ |
case 4: // Photon |
643 |
+ |
{ |
644 |
+ |
const float dpseudorapidity = |
645 |
+ |
p.eta() - pseudorapidity_adapt; |
646 |
+ |
const float dazimuth = |
647 |
+ |
reco::deltaPhi(p.phi(), azimuth_adapt); |
648 |
+ |
// The Gaussian scale factor is 0.5 / (0.1 * 0.1) |
649 |
+ |
// = 50 |
650 |
+ |
const float angular_weight = |
651 |
+ |
exp(-50.0F * (dpseudorapidity * dpseudorapidity + |
652 |
+ |
dazimuth * dazimuth)); |
653 |
+ |
const float weighted_perp = |
654 |
+ |
angular_weight * p.pt() * p.pt(); |
655 |
+ |
const float weighted_perp_square = |
656 |
+ |
weighted_perp * p.pt(); |
657 |
+ |
|
658 |
+ |
perp_square_sum += weighted_perp_square; |
659 |
+ |
if (weighted_perp >= max_weighted_perp) { |
660 |
+ |
pseudorapidity_adapt_new = p.eta(); |
661 |
+ |
azimuth_adapt_new = p.phi(); |
662 |
+ |
max_weighted_perp = weighted_perp; |
663 |
+ |
} |
664 |
+ |
} |
665 |
+ |
default: |
666 |
+ |
break; |
667 |
+ |
} |
668 |
+ |
} |
669 |
+ |
// Update the fake rejection value |
670 |
+ |
jets_.discr_fr01[jets_.nref] = std::max( |
671 |
+ |
jets_.discr_fr01[jets_.nref], perp_square_sum); |
672 |
+ |
// Update the directional adaption |
673 |
+ |
pseudorapidity_adapt = pseudorapidity_adapt_new; |
674 |
+ |
azimuth_adapt = azimuth_adapt_new; |
675 |
+ |
} |
676 |
+ |
|
677 |
|
|
678 |
|
jets_.jtpt[jets_.nref] = jet.pt(); |
679 |
|
jets_.jteta[jets_.nref] = jet.eta(); |
680 |
|
jets_.jtphi[jets_.nref] = jet.phi(); |
681 |
|
jets_.jty[jets_.nref] = jet.eta(); |
682 |
|
jets_.jtpu[jets_.nref] = jet.pileup(); |
683 |
+ |
jets_.jtm[jets_.nref] = jet.mass(); |
684 |
|
|
685 |
|
if(isMC_ && usePat_){ |
686 |
< |
jets_.refparton_flavorForB[jets_.nref] = (*patjets)[j].partonFlavour(); |
687 |
< |
const reco::GenJet* genjet = (*patjets)[j].genJet(); |
686 |
> |
|
687 |
> |
const reco::GenJet * genjet = (*patjets)[j].genJet(); |
688 |
|
|
689 |
|
if(genjet){ |
690 |
|
jets_.refpt[jets_.nref] = genjet->pt(); |
702 |
|
jets_.refdrjt[jets_.nref] = -999.; |
703 |
|
} |
704 |
|
|
705 |
< |
// matched partons |
706 |
< |
const reco::GenParticle * parton = (*patjets)[j].genParton(); |
707 |
< |
if(parton){ |
708 |
< |
jets_.refparton_pt[jets_.nref] = parton->pt(); |
709 |
< |
jets_.refparton_flavor[jets_.nref] = parton->pdgId(); |
705 |
> |
jets_.refparton_flavorForB[jets_.nref] = (*patjets)[j].partonFlavour(); |
706 |
> |
|
707 |
> |
// matched partons |
708 |
> |
const reco::GenParticle & parton = *(*patjets)[j].genParton(); |
709 |
> |
|
710 |
> |
if((*patjets)[j].genParton()){ |
711 |
> |
jets_.refparton_pt[jets_.nref] = parton.pt(); |
712 |
> |
jets_.refparton_flavor[jets_.nref] = parton.pdgId(); |
713 |
> |
|
714 |
> |
if(saveBfragments_ && abs(jets_.refparton_flavorForB[jets_.nref])==5){ |
715 |
> |
|
716 |
> |
usedStringPts.clear(); |
717 |
> |
|
718 |
> |
// uncomment this if you want to know the ugly truth about parton matching -matt |
719 |
> |
//if(jet.pt() > 50 &&abs(parton.pdgId())!=5 && parton.pdgId()!=21) |
720 |
> |
// cout<<" Identified as a b, but doesn't match b or gluon, id = "<<parton.pdgId()<<endl; |
721 |
> |
|
722 |
> |
jets_.bJetIndex[jets_.bMult] = jets_.nref; |
723 |
> |
jets_.bStatus[jets_.bMult] = parton.status(); |
724 |
> |
jets_.bVx[jets_.bMult] = parton.vx(); |
725 |
> |
jets_.bVy[jets_.bMult] = parton.vy(); |
726 |
> |
jets_.bVz[jets_.bMult] = parton.vz(); |
727 |
> |
jets_.bPt[jets_.bMult] = parton.pt(); |
728 |
> |
jets_.bEta[jets_.bMult] = parton.eta(); |
729 |
> |
jets_.bPhi[jets_.bMult] = parton.phi(); |
730 |
> |
jets_.bPdg[jets_.bMult] = parton.pdgId(); |
731 |
> |
jets_.bChg[jets_.bMult] = parton.charge(); |
732 |
> |
jets_.bMult++; |
733 |
> |
saveDaughters(parton); |
734 |
> |
} |
735 |
> |
|
736 |
> |
|
737 |
|
} else { |
738 |
< |
jets_.refparton_pt[jets_.nref] = -999; |
739 |
< |
jets_.refparton_flavor[jets_.nref] = -999; |
738 |
> |
jets_.refparton_pt[jets_.nref] = -999; |
739 |
> |
jets_.refparton_flavor[jets_.nref] = -999; |
740 |
|
} |
741 |
+ |
|
742 |
+ |
|
743 |
|
} |
744 |
|
|
745 |
|
jets_.nref++; |
750 |
|
|
751 |
|
if(isMC_){ |
752 |
|
|
753 |
+ |
edm::Handle<HepMCProduct> hepMCProduct; |
754 |
+ |
iEvent.getByLabel(eventInfoTag_,hepMCProduct); |
755 |
+ |
const HepMC::GenEvent* MCEvt = hepMCProduct->GetEvent(); |
756 |
+ |
std::pair<HepMC::GenParticle*,HepMC::GenParticle*> beamParticles = MCEvt->beam_particles(); |
757 |
+ |
jets_.beamId1 = beamParticles.first->pdg_id(); |
758 |
+ |
jets_.beamId2 = beamParticles.second->pdg_id(); |
759 |
+ |
|
760 |
|
edm::Handle<GenEventInfoProduct> hEventInfo; |
761 |
|
iEvent.getByLabel(eventInfoTag_,hEventInfo); |
762 |
|
//jets_.pthat = hEventInfo->binningValues()[0]; |
781 |
|
jets_.genphi[jets_.ngen] = genjet.phi(); |
782 |
|
jets_.geny[jets_.ngen] = genjet.eta(); |
783 |
|
|
784 |
+ |
if(doSubEvent_){ |
785 |
+ |
const GenParticle* gencon = genjet.getGenConstituent(0); |
786 |
+ |
jets_.gensubid[jets_.ngen] = gencon->collisionId(); |
787 |
+ |
} |
788 |
|
|
789 |
|
// find matching patJet if there is one |
790 |
|
|
815 |
|
|
816 |
|
} |
817 |
|
t->Fill(); |
818 |
+ |
memset(&jets_,0,sizeof jets_); |
819 |
|
} |
820 |
|
|
821 |
|
|
966 |
|
|
967 |
|
return (pTrel2 > 0) ? std::sqrt(pTrel2) : 0.0; |
968 |
|
} |
969 |
+ |
|
970 |
+ |
// Recursive function, but this version gets called only the first time |
971 |
+ |
void |
972 |
+ |
HiInclusiveJetAnalyzer::saveDaughters(const reco::GenParticle &gen){ |
973 |
+ |
|
974 |
+ |
for(unsigned i=0;i<gen.numberOfDaughters();i++){ |
975 |
+ |
const reco::Candidate & daughter = *gen.daughter(i); |
976 |
+ |
double daughterPt = daughter.pt(); |
977 |
+ |
if(daughterPt<1.) continue; |
978 |
+ |
double daughterEta = daughter.eta(); |
979 |
+ |
if(fabs(daughterEta)>3.) continue; |
980 |
+ |
int daughterPdgId = daughter.pdgId(); |
981 |
+ |
int daughterStatus = daughter.status(); |
982 |
+ |
// Special case when b->b+string, both b and string contain all daughters, so only take the string |
983 |
+ |
if(gen.pdgId()==daughterPdgId && gen.status()==3 && daughterStatus==2) continue; |
984 |
+ |
|
985 |
+ |
// cheesy way of finding strings which were already used |
986 |
+ |
if(daughter.pdgId()==92){ |
987 |
+ |
for(unsigned ist=0;ist<usedStringPts.size();ist++){ |
988 |
+ |
if(fabs(daughter.pt() - usedStringPts[ist]) < 0.0001) return; |
989 |
+ |
} |
990 |
+ |
usedStringPts.push_back(daughter.pt()); |
991 |
+ |
} |
992 |
+ |
jets_.bJetIndex[jets_.bMult] = jets_.nref; |
993 |
+ |
jets_.bStatus[jets_.bMult] = daughterStatus; |
994 |
+ |
jets_.bVx[jets_.bMult] = daughter.vx(); |
995 |
+ |
jets_.bVy[jets_.bMult] = daughter.vy(); |
996 |
+ |
jets_.bVz[jets_.bMult] = daughter.vz(); |
997 |
+ |
jets_.bPt[jets_.bMult] = daughterPt; |
998 |
+ |
jets_.bEta[jets_.bMult] = daughterEta; |
999 |
+ |
jets_.bPhi[jets_.bMult] = daughter.phi(); |
1000 |
+ |
jets_.bPdg[jets_.bMult] = daughterPdgId; |
1001 |
+ |
jets_.bChg[jets_.bMult] = daughter.charge(); |
1002 |
+ |
jets_.bMult++; |
1003 |
+ |
saveDaughters(daughter); |
1004 |
+ |
} |
1005 |
+ |
} |
1006 |
+ |
|
1007 |
+ |
// This version called for all subsequent calls |
1008 |
+ |
void |
1009 |
+ |
HiInclusiveJetAnalyzer::saveDaughters(const reco::Candidate &gen){ |
1010 |
+ |
|
1011 |
+ |
for(unsigned i=0;i<gen.numberOfDaughters();i++){ |
1012 |
+ |
const reco::Candidate & daughter = *gen.daughter(i); |
1013 |
+ |
double daughterPt = daughter.pt(); |
1014 |
+ |
if(daughterPt<1.) continue; |
1015 |
+ |
double daughterEta = daughter.eta(); |
1016 |
+ |
if(fabs(daughterEta)>3.) continue; |
1017 |
+ |
int daughterPdgId = daughter.pdgId(); |
1018 |
+ |
int daughterStatus = daughter.status(); |
1019 |
+ |
// Special case when b->b+string, both b and string contain all daughters, so only take the string |
1020 |
+ |
if(gen.pdgId()==daughterPdgId && gen.status()==3 && daughterStatus==2) continue; |
1021 |
+ |
|
1022 |
+ |
// cheesy way of finding strings which were already used |
1023 |
+ |
if(daughter.pdgId()==92){ |
1024 |
+ |
for(unsigned ist=0;ist<usedStringPts.size();ist++){ |
1025 |
+ |
if(fabs(daughter.pt() - usedStringPts[ist]) < 0.0001) return; |
1026 |
+ |
} |
1027 |
+ |
usedStringPts.push_back(daughter.pt()); |
1028 |
+ |
} |
1029 |
+ |
|
1030 |
+ |
jets_.bJetIndex[jets_.bMult] = jets_.nref; |
1031 |
+ |
jets_.bStatus[jets_.bMult] = daughterStatus; |
1032 |
+ |
jets_.bVx[jets_.bMult] = daughter.vx(); |
1033 |
+ |
jets_.bVy[jets_.bMult] = daughter.vy(); |
1034 |
+ |
jets_.bVz[jets_.bMult] = daughter.vz(); |
1035 |
+ |
jets_.bPt[jets_.bMult] = daughterPt; |
1036 |
+ |
jets_.bEta[jets_.bMult] = daughterEta; |
1037 |
+ |
jets_.bPhi[jets_.bMult] = daughter.phi(); |
1038 |
+ |
jets_.bPdg[jets_.bMult] = daughterPdgId; |
1039 |
+ |
jets_.bChg[jets_.bMult] = daughter.charge(); |
1040 |
+ |
jets_.bMult++; |
1041 |
+ |
saveDaughters(daughter); |
1042 |
+ |
} |
1043 |
+ |
} |
1044 |
|
|
1045 |
|
DEFINE_FWK_MODULE(HiInclusiveJetAnalyzer); |