218 std::cout <<
"Usage : " <<
argv[0] <<
" [parameters.py]" << std::endl;
222 cout <<
"Hello from " <<
argv[0] <<
"!" << endl;
225 gSystem->Load(
"libFWCoreFWLite");
228 cout <<
"Getting parameters" << endl;
231 std::shared_ptr<edm::ProcessDesc>
b = builder.processDesc();
232 std::shared_ptr<edm::ParameterSet>
parameters =
b->getProcessPSet();
243 cout <<
"Making RunLumiSelector" << endl;
246 cout <<
"setting up TFileService" << endl;
251 cout <<
"Setting up chain event" << endl;
256 cout <<
"Booking histograms" << endl;
259 std::map<std::string, TH1*>
hists;
261 hists[
"hist_nJet"] = theDir.
make<TH1D>(
"hist_nJet",
"Number of Calo Jets", 10, 0, 10);
262 hists[
"hist_nPFJet"] = theDir.
make<TH1D>(
"hist_nPFJet",
"Number of PF Jets", 10, 0, 10);
264 hists[
"hist_jetPt"] = theDir.
make<TH1D>(
"hist_jetPt",
"Jet p_{T}", 400, 0, 400);
265 hists[
"hist_jetEtaVsPhi"] = theDir.
make<TH2D>(
266 "hist_jetEtaVsPhi",
"Jet #phi versus #eta;#eta;#phi", 50, -5.0, 5.0, 50, -
TMath::Pi(),
TMath::Pi());
267 hists[
"hist_jetNTracks"] = theDir.
make<TH1D>(
"hist_jetNTracks",
"Jet N_{TRACKS}", 20, 0, 20);
268 hists[
"hist_jetNTracksVsPt"] = theDir.
make<TH2D>(
269 "hist_jetNTracksVsPt",
"Number of Tracks versus Jet p_{T};Jet p_{T}(GeV/c) ;N_{Tracks}", 20, 0, 200, 20, 0, 20);
270 hists[
"hist_jetEMF"] = theDir.
make<TH1D>(
"hist_jetEMF",
"Jet EMF", 200, 0, 1);
271 hists[
"hist_jetPdgID"] = theDir.
make<TH1D>(
"hist_jetPdgID",
"PDG Id of Jet Constituents", 10000, 0, 10000);
272 hists[
"hist_jetGenEmE"] = theDir.
make<TH1D>(
"hist_jetGenEmE",
"Gen Jet EM Energy", 200, 0, 200);
273 hists[
"hist_jetGenHadE"] = theDir.
make<TH1D>(
"hist_jetGenHadE",
"Gen Jet HAD Energy", 200, 0, 200);
274 hists[
"hist_jetGenEMF"] = theDir.
make<TH1D>(
"hist_jetGenEMF",
"Gen Jet EMF", 200, 0, 1);
275 hists[
"hist_jetEoverGenE"] =
276 theDir.
make<TH1D>(
"hist_jetEoverGenE",
"Energy of reco Jet / Energy of gen Jet", 200, 0, 2.0);
277 hists[
"hist_jetCorr"] = theDir.
make<TH1D>(
"hist_jetCorr",
"Jet Correction Factor", 200, 0, 1.0);
278 hists[
"hist_n90Hits"] = theDir.make<TH1D>(
"hist_n90Hits",
"Jet n90Hits", 20, 0, 20);
279 hists[
"hist_fHPD"] = theDir.make<TH1D>(
"hist_fHPD",
"Jet fHPD", 200, 0, 1);
280 hists[
"hist_nConstituents"] = theDir.make<TH1D>(
"hist_nConstituents",
"Jet nConstituents", 20, 0, 20);
281 hists[
"hist_jetCHF"] = theDir.make<TH1D>(
"hist_jetCHF",
"Jet Charged Hadron Fraction", 200, 0, 1.0);
283 hists[
"hist_good_jetPt"] = theDir.make<TH1D>(
"hist_good_jetPt",
"Jet p_{T}", 400, 0, 400);
284 hists[
"hist_good_jetEtaVsPhi"] = theDir.make<TH2D>(
285 "hist_good_jetEtaVsPhi",
"Jet #phi versus #eta;#eta;#phi", 50, -5.0, 5.0, 50, -
TMath::Pi(),
TMath::Pi());
286 hists[
"hist_good_jetNTracks"] = theDir.make<TH1D>(
"hist_good_jetNTracks",
"Jet N_{TRACKS}", 20, 0, 20);
287 hists[
"hist_good_jetNTracksVsPt"] =
288 theDir.make<TH2D>(
"hist_good_jetNTracksVsPt",
289 "Number of Tracks versus Jet p_{T};Jet p_{T}(GeV/c) ;N_{Tracks}",
296 hists[
"hist_good_jetEMF"] = theDir.make<TH1D>(
"hist_good_jetEMF",
"Jet EMF", 200, 0, 1);
297 hists[
"hist_good_jetPdgID"] = theDir.make<TH1D>(
"hist_good_jetPdgID",
"PDG Id of Jet Constituents", 10000, 0, 10000);
298 hists[
"hist_good_jetGenEmE"] = theDir.make<TH1D>(
"hist_good_jetGenEmE",
"Gen Jet EM Energy", 200, 0, 200);
299 hists[
"hist_good_jetGenHadE"] = theDir.make<TH1D>(
"hist_good_jetGenHadE",
"Gen Jet HAD Energy", 200, 0, 200);
300 hists[
"hist_good_jetGenEMF"] = theDir.make<TH1D>(
"hist_good_jetGenEMF",
"Gen Jet EMF", 200, 0, 1);
301 hists[
"hist_good_jetEoverGenE"] =
302 theDir.make<TH1D>(
"hist_good_jetEoverGenE",
"Energy of reco Jet / Energy of gen Jet", 200, 0, 2.0);
303 hists[
"hist_good_jetCorr"] = theDir.make<TH1D>(
"hist_good_jetCorr",
"Jet Correction Factor", 200, 0, 1.0);
304 hists[
"hist_good_n90Hits"] = theDir.make<TH1D>(
"hist_good_n90Hits",
"Jet n90Hits", 20, 0, 20);
305 hists[
"hist_good_fHPD"] = theDir.make<TH1D>(
"hist_good_fHPD",
"Jet fHPD", 200, 0, 1);
306 hists[
"hist_good_nConstituents"] = theDir.make<TH1D>(
"hist_good_nConstituents",
"Jet nConstituents", 20, 0, 20);
307 hists[
"hist_good_jetCHF"] = theDir.make<TH1D>(
"hist_good_jetCHF",
"Jet Charged Hadron Fraction", 200, 0, 1.0);
309 hists[
"hist_pf_jetPt"] = theDir.make<TH1D>(
"hist_pf_jetPt",
"PFJet p_{T}", 400, 0, 400);
310 hists[
"hist_pf_jetEtaVsPhi"] = theDir.make<TH2D>(
311 "hist_pf_jetEtaVsPhi",
"PFJet #phi versus #eta;#eta;#phi", 50, -5.0, 5.0, 50, -
TMath::Pi(),
TMath::Pi());
312 hists[
"hist_pf_jetNTracks"] = theDir.make<TH1D>(
"hist_pf_jetNTracks",
"PFJet N_{TRACKS}", 20, 0, 20);
313 hists[
"hist_pf_jetNTracksVsPt"] = theDir.make<TH2D>(
314 "hist_pf_jetNTracksVsPt",
"Number of Tracks versus Jet p_{T};Jet p_{T}(GeV/c) ;N_{Tracks}", 20, 0, 200, 20, 0, 20);
315 hists[
"hist_pf_jetEMF"] = theDir.make<TH1D>(
"hist_pf_jetEMF",
"PFJet EMF", 200, 0, 1);
316 hists[
"hist_pf_jetCHF"] = theDir.make<TH1D>(
"hist_pf_jetCHF",
"PFJet CHF", 200, 0, 1);
317 hists[
"hist_pf_jetNHF"] = theDir.make<TH1D>(
"hist_pf_jetNHF",
"PFJet NHF", 200, 0, 1);
318 hists[
"hist_pf_jetCEF"] = theDir.make<TH1D>(
"hist_pf_jetCEF",
"PFJet CEF", 200, 0, 1);
319 hists[
"hist_pf_jetNEF"] = theDir.make<TH1D>(
"hist_pf_jetNEF",
"PFJet NEF", 200, 0, 1);
320 hists[
"hist_pf_jetPdgID"] = theDir.make<TH1D>(
"hist_pf_jetPdgID",
"PDG Id of Jet Constituents", 10000, 0, 10000);
321 hists[
"hist_pf_jetGenEmE"] = theDir.make<TH1D>(
"hist_pf_jetGenEmE",
"Gen Jet EM Energy", 200, 0, 200);
322 hists[
"hist_pf_jetGenHadE"] = theDir.make<TH1D>(
"hist_pf_jetGenHadE",
"Gen Jet HAD Energy", 200, 0, 200);
323 hists[
"hist_pf_jetGenEMF"] = theDir.make<TH1D>(
"hist_pf_jetGenEMF",
"Gen Jet EMF", 200, 0, 1);
324 hists[
"hist_pf_jetEoverGenE"] =
325 theDir.make<TH1D>(
"hist_pf_jetEoverGenE",
"Energy of reco Jet / Energy of gen Jet", 200, 0, 2.0);
326 hists[
"hist_pf_jetCorr"] = theDir.make<TH1D>(
"hist_pf_jetCorr",
"PFJet Correction Factor", 200, 0, 1.0);
327 hists[
"hist_pf_nConstituents"] = theDir.make<TH1D>(
"hist_pf_nConstituents",
"PFJet nConstituents", 20, 0, 20);
329 hists[
"hist_pf_good_jetPt"] = theDir.make<TH1D>(
"hist_pf_good_jetPt",
"PFJet p_{T}", 400, 0, 400);
330 hists[
"hist_pf_good_jetEtaVsPhi"] = theDir.make<TH2D>(
331 "hist_pf_good_jetEtaVsPhi",
"PFJet #phi versus #eta;#eta;#phi", 50, -5.0, 5.0, 50, -
TMath::Pi(),
TMath::Pi());
332 hists[
"hist_pf_good_jetNTracks"] = theDir.make<TH1D>(
"hist_pf_good_jetNTracks",
"PFJet N_{TRACKS}", 20, 0, 20);
333 hists[
"hist_pf_good_jetNTracksVsPt"] =
334 theDir.make<TH2D>(
"hist_pf_good_jetNTracksVsPt",
335 "Number of Tracks versus Jet p_{T};Jet p_{T}(GeV/c) ;N_{Tracks}",
342 hists[
"hist_pf_good_jetEMF"] = theDir.make<TH1D>(
"hist_pf_good_jetEMF",
"PFJet EMF", 200, 0, 1);
343 hists[
"hist_pf_good_jetCHF"] = theDir.make<TH1D>(
"hist_pf_good_jetCHF",
"PFJet CHF", 200, 0, 1);
344 hists[
"hist_pf_good_jetNHF"] = theDir.make<TH1D>(
"hist_pf_good_jetNHF",
"PFJet NHF", 200, 0, 1);
345 hists[
"hist_pf_good_jetCEF"] = theDir.make<TH1D>(
"hist_pf_good_jetCEF",
"PFJet CEF", 200, 0, 1);
346 hists[
"hist_pf_good_jetNEF"] = theDir.make<TH1D>(
"hist_pf_good_jetNEF",
"PFJet NEF", 200, 0, 1);
347 hists[
"hist_pf_good_jetPdgID"] =
348 theDir.make<TH1D>(
"hist_pf_good_jetPdgID",
"PDG Id of Jet Constituents", 10000, 0, 10000);
349 hists[
"hist_pf_good_jetGenEmE"] = theDir.make<TH1D>(
"hist_pf_good_jetGenEmE",
"Gen Jet EM Energy", 200, 0, 200);
350 hists[
"hist_pf_good_jetGenHadE"] = theDir.make<TH1D>(
"hist_pf_good_jetGenHadE",
"Gen Jet HAD Energy", 200, 0, 200);
351 hists[
"hist_pf_good_jetGenEMF"] = theDir.make<TH1D>(
"hist_pf_good_jetGenEMF",
"Gen Jet EMF", 200, 0, 1);
352 hists[
"hist_pf_good_jetEoverGenE"] =
353 theDir.make<TH1D>(
"hist_pf_good_jetEoverGenE",
"Energy of reco Jet / Energy of gen Jet", 200, 0, 2.0);
354 hists[
"hist_pf_good_jetCorr"] = theDir.make<TH1D>(
"hist_pf_good_jetCorr",
"PFJet Correction Factor", 200, 0, 1.0);
355 hists[
"hist_pf_good_nConstituents"] =
356 theDir.make<TH1D>(
"hist_pf_good_nConstituents",
"PFJet nConstituents", 20, 0, 20);
358 hists[
"hist_mjj"] = theDir.make<TH1D>(
"hist_mjj",
"Dijet mass", 300, 0, 300);
359 hists[
"hist_dR_jj"] = theDir.make<TH1D>(
"hist_dR_jj",
"#Delta R_{JJ}", 200, 0,
TMath::TwoPi());
360 hists[
"hist_imbalance_jj"] = theDir.make<TH1D>(
"hist_imbalance_jj",
"Dijet imbalance", 200, -1.0, 1.0);
362 hists[
"hist_pf_mjj"] = theDir.make<TH1D>(
"hist_pf_mjj",
"Dijet mass", 300, 0, 300);
363 hists[
"hist_pf_dR_jj"] = theDir.make<TH1D>(
"hist_pf_dR_jj",
"#Delta R_{JJ}", 200, 0,
TMath::TwoPi());
364 hists[
"hist_pf_imbalance_jj"] = theDir.make<TH1D>(
"hist_pf_imbalance_jj",
"Dijet imbalance", 200, -1.0, 1.0);
366 cout <<
"Making functors" << endl;
374 cout <<
"About to begin looping" << endl;
378 for (
ev.toBegin(); !
ev.atEnd(); ++
ev, ++nev) {
381 if (runLumiSel(
ev) ==
false)
385 cout <<
"Processing run " <<
event.id().run() <<
", lumi " <<
event.id().luminosityBlock() <<
", event "
386 <<
event.id().event() << endl;
389 caloSelector(
event, retCalo);
392 pfSelector(
event, retPF);
397 if (retCalo.
test(caloSelector.caloKin())) {
398 if (retCalo.
test(caloSelector.caloDeltaPhi())) {
399 vector<pat::Jet>
const& allCaloJets = caloSelector.allCaloJets();
401 for (std::vector<pat::Jet>::const_iterator jetBegin = allCaloJets.begin(),
402 jetEnd = jetBegin + 2,
408 double pt =
jet.pt();
413 hists[
"hist_jetEtaVsPhi"]->Fill(
jet.eta(),
jet.phi());
416 hists[
"hist_jetEMF"]->Fill(
jet.emEnergyFraction());
417 hists[
"hist_jetCorr"]->Fill(
jet.jecFactor(
"Uncorrected"));
418 hists[
"hist_n90Hits"]->Fill(static_cast<int>(
jet.jetID().n90Hits));
419 hists[
"hist_fHPD"]->Fill(
jet.jetID().fHPD);
420 hists[
"hist_nConstituents"]->Fill(
jet.nConstituents());
422 if (
useMC &&
jet.genJet() !=
nullptr) {
423 hists[
"hist_jetGenEmE"]->Fill(
jet.genJet()->emEnergy());
424 hists[
"hist_jetGenHadE"]->Fill(
jet.genJet()->hadEnergy());
425 hists[
"hist_jetEoverGenE"]->Fill(
jet.energy() /
jet.genJet()->energy());
426 hists[
"hist_jetGenEMF"]->Fill(
jet.genJet()->emEnergy() /
jet.genJet()->energy());
429 TLorentzVector p4_tracks(0, 0, 0, 0);
433 TLorentzVector p4_trk;
434 double M_PION = 0.140;
435 p4_trk.SetPtEtaPhiM((*itrk)->pt(), (*itrk)->eta(), (*itrk)->phi(), M_PION);
438 hists[
"hist_jetCHF"]->Fill(p4_tracks.Energy() /
jet.energy());
443 if (retCalo.
test(caloSelector.caloJetID())) {
444 pat::Jet const& jet0 = caloSelector.caloJet0();
445 pat::Jet const& jet1 = caloSelector.caloJet1();
447 TLorentzVector p4_j0(jet0.
px(), jet0.
py(), jet0.
pz(), jet0.
energy());
448 TLorentzVector p4_j1(jet1.
px(), jet1.
py(), jet1.
pz(), jet1.
energy());
450 TLorentzVector p4_jj = p4_j0 + p4_j1;
452 hists[
"hist_mjj"]->Fill(p4_jj.M());
453 hists[
"hist_dR_jj"]->Fill(p4_j0.DeltaR(p4_j1));
454 hists[
"hist_imbalance_jj"]->Fill((p4_j0.Perp() - p4_j1.Perp()) / (p4_j0.Perp() + p4_j1.Perp()));
456 hists[
"hist_good_jetPt"]->Fill(jet0.
pt());
457 hists[
"hist_good_jetEtaVsPhi"]->Fill(jet0.
eta(), jet0.
phi());
466 hists[
"hist_good_jetPt"]->Fill(jet1.
pt());
467 hists[
"hist_good_jetEtaVsPhi"]->Fill(jet1.
eta(), jet1.
phi());
483 if (retPF.
test(pfSelector.pfDeltaPhi())) {
484 vector<pat::Jet>
const& allPFJets = pfSelector.allPFJets();
486 for (std::vector<pat::Jet>::const_iterator jetBegin = allPFJets.begin(), jetEnd = jetBegin + 2, ijet = jetBegin;
491 double pt =
jet.pt();
493 hists[
"hist_pf_jetPt"]->Fill(
pt);
494 hists[
"hist_pf_jetEtaVsPhi"]->Fill(
jet.eta(),
jet.phi());
495 hists[
"hist_pf_nConstituents"]->Fill(
jet.nConstituents());
496 hists[
"hist_pf_jetCEF"]->Fill(
jet.chargedEmEnergyFraction());
497 hists[
"hist_pf_jetNEF"]->Fill(
jet.neutralEmEnergyFraction());
498 hists[
"hist_pf_jetCHF"]->Fill(
jet.chargedHadronEnergyFraction());
499 hists[
"hist_pf_jetNHF"]->Fill(
jet.neutralHadronEnergyFraction());
501 if (
useMC &&
jet.genJet() !=
nullptr) {
502 hists[
"hist_pf_jetGenEmE"]->Fill(
jet.genJet()->emEnergy());
503 hists[
"hist_pf_jetGenHadE"]->Fill(
jet.genJet()->hadEnergy());
504 hists[
"hist_pf_jetEoverGenE"]->Fill(
jet.energy() /
jet.genJet()->energy());
506 hists[
"hist_pf_jetGenEMF"]->Fill(
jet.genJet()->emEnergy() /
jet.genJet()->energy());
511 if (retPF.
test(pfSelector.pfJetID())) {
512 pat::Jet const& jet0 = pfSelector.pfJet0();
513 pat::Jet const& jet1 = pfSelector.pfJet1();
515 TLorentzVector p4_j0(jet0.
px(), jet0.
py(), jet0.
pz(), jet0.
energy());
516 TLorentzVector p4_j1(jet1.
px(), jet1.
py(), jet1.
pz(), jet1.
energy());
518 TLorentzVector p4_jj = p4_j0 + p4_j1;
520 hists[
"hist_pf_mjj"]->Fill(p4_jj.M());
521 hists[
"hist_pf_dR_jj"]->Fill(p4_j0.DeltaR(p4_j1));
522 hists[
"hist_pf_imbalance_jj"]->Fill((p4_j0.Perp() - p4_j1.Perp()) / (p4_j0.Perp() + p4_j1.Perp()));
524 hists[
"hist_pf_good_jetPt"]->Fill(jet0.
pt());
525 hists[
"hist_pf_good_jetEtaVsPhi"]->Fill(jet0.
eta(), jet0.
phi());
532 hists[
"hist_pf_good_jetPt"]->Fill(jet1.
pt());
533 hists[
"hist_pf_good_jetEtaVsPhi"]->Fill(jet1.
eta(), jet1.
phi());
546 cout <<
"Calo jet selection" << endl;
548 cout <<
"PF jet selection" << endl;