59 std::vector<float>& offlineIP3D,
60 std::vector<float>& offlineIP3DSig);
68 std::vector<float>& onlineIP3D,
69 std::vector<float>& onlineIP3DSig);
205 using namespace reco;
210 : dirname_(iConfig.getUntrackedParameter(
"dirname",
std::
string(
"HLT/BTV/"))),
211 processname_(iConfig.getParameter<
std::
string>(
"processname")),
212 verbose_(iConfig.getUntrackedParameter<
bool>(
"verbose",
false)),
213 triggerSummaryLabel_(iConfig.getParameter<
edm::
InputTag>(
"triggerSummaryLabel")),
214 triggerResultsLabel_(iConfig.getParameter<
edm::
InputTag>(
"triggerResultsLabel")),
215 turnon_threshold_loose_(iConfig.getParameter<double>(
"turnon_threshold_loose")),
216 turnon_threshold_medium_(iConfig.getParameter<double>(
"turnon_threshold_medium")),
217 turnon_threshold_tight_(iConfig.getParameter<double>(
"turnon_threshold_tight")),
219 offlineDiscrTokenbb_(
233 shallowTagInfosTokenCalo_(
235 shallowTagInfosTokenPf_(
238 edm::
InputTag(
"hltInclusiveSecondaryVertexFinderTagInfos"))),
242 minDecayLength_(iConfig.getParameter<double>(
"minDecayLength")),
243 maxDecayLength_(iConfig.getParameter<double>(
"maxDecayLength")),
244 minJetDistance_(iConfig.getParameter<double>(
"minJetDistance")),
245 maxJetDistance_(iConfig.getParameter<double>(
"maxJetDistance")),
246 dRTrackMatch_(iConfig.getParameter<double>(
"dRTrackMatch")) {
247 std::vector<edm::ParameterSet>
paths = iConfig.
getParameter<std::vector<edm::ParameterSet>>(
"pathPairs");
259 LogDebug(
"BTVHLTOfflineSource") <<
"HLTConfigProvider failed to initialize.";
266 if (
pathname.find(custompathnamepair.first) != std::string::npos) {
279 edm::LogInfo(
"BTVHLTOfflineSource") <<
"TriggerResults not found, skipping event";
291 edm::LogInfo(
"BTVHLTOfflineSource") <<
"TriggerEvent not found, skipping event";
317 cout <<
"Run = " <<
iEvent.id().run() <<
", LS = " <<
iEvent.luminosityBlock()
318 <<
", Event = " <<
iEvent.id().event() << endl;
329 edm::LogInfo(
"BTVHLTOfflineSource") <<
"Path " <<
v.getPath() <<
" not in menu, skipping event";
334 edm::LogInfo(
"BTVHLTOfflineSource") <<
"Path " <<
v.getPath() <<
" not accepted, skipping event";
338 if (
v.getTriggerType() ==
"PF") {
345 if ((
v.getTriggerType() ==
"PF" &&
pfTags.isValid()) ||
347 const auto& iter = (
v.getTriggerType() ==
"PF") ?
pfTags->begin() :
caloTags->begin();
349 float Discr_online = iter->second;
350 if (Discr_online < 0)
351 Discr_online = -0.05;
353 v.Discr->Fill(Discr_online);
354 v.Pt->Fill(iter->first->pt());
355 v.Eta->Fill(iter->first->eta());
357 if (offlineJetTagHandlerb.
isValid()) {
358 for (
auto const& iterOffb : *offlineJetTagHandlerb) {
359 float DR =
reco::deltaR(iterOffb.first->eta(), iterOffb.first->phi(), iter->first->eta(), iter->first->phi());
361 float Discr_offline = iterOffb.second;
364 if (offlineJetTagHandlerbb.
isValid()) {
365 for (
auto const& iterOffbb : *offlineJetTagHandlerbb) {
367 iterOffbb.first->eta(), iterOffbb.first->phi(), iter->first->eta(), iter->first->phi());
369 Discr_offline += iterOffbb.second;
375 if (Discr_offline < 0)
376 Discr_offline = -0.05;
377 v.Discr_HLTvsRECO->Fill(Discr_online, Discr_offline);
378 v.Discr_HLTMinusRECO->Fill(Discr_online - Discr_offline);
380 v.Discr_turnon_loose.denominator->Fill(Discr_offline);
381 v.Discr_turnon_medium.denominator->Fill(Discr_offline);
382 v.Discr_turnon_tight.denominator->Fill(Discr_offline);
385 v.Discr_turnon_loose.numerator->Fill(Discr_offline);
387 v.Discr_turnon_medium.numerator->Fill(Discr_offline);
389 v.Discr_turnon_tight.numerator->Fill(Discr_offline);
396 bool pfSVTagCollValid = (
v.getTriggerType() ==
"PF" && jetSVTagsCollPF.
isValid());
397 bool caloSVTagCollValid = (
v.getTriggerType() ==
"Calo" && jetSVTagsCollCalo.
isValid());
398 if (offlineIPTagHandle.
isValid() && (pfSVTagCollValid || caloSVTagCollValid)) {
399 std::vector<float> offlineIP3D;
400 std::vector<float> offlineIP3DSig;
402 iter->first->eta(), iter->first->phi(), offlineIPTagHandle, offlineIP3D, offlineIP3DSig);
403 std::vector<const reco::Track*> onlineTracks;
404 std::vector<float> onlineIP3D;
405 std::vector<float> onlineIP3DSig;
406 if (pfSVTagCollValid)
407 onlineTracks = getOnlineBTagTracks<SVTagInfo>(
408 iter->first->eta(), iter->first->phi(), jetSVTagsCollPF, onlineIP3D, onlineIP3DSig);
409 if (caloSVTagCollValid)
410 onlineTracks = getOnlineBTagTracks<reco::SecondaryVertexTagInfo>(
411 iter->first->eta(), iter->first->phi(), jetSVTagsCollCalo, onlineIP3D, onlineIP3DSig);
413 for (
unsigned int iOffTrk = 0; iOffTrk < offlineTracks.size(); ++iOffTrk) {
414 const reco::Track* offTrk = offlineTracks.at(iOffTrk);
415 bool hasMatch =
false;
416 float offTrkEta = offTrk->
eta();
417 float offTrkPhi = offTrk->
phi();
420 float DR =
reco::deltaR(offTrkEta, offTrkPhi, onTrk->eta(), onTrk->phi());
426 float offTrkPt = offTrk->
pt();
427 v.OnlineTrkEff_Pt.denominator->Fill(offTrkPt);
429 v.OnlineTrkEff_Pt.numerator->Fill(offTrkPt);
431 v.OnlineTrkEff_Eta.denominator->Fill(offTrkEta);
433 v.OnlineTrkEff_Eta.numerator->Fill(offTrkEta);
435 v.OnlineTrkEff_3d_ip_distance.denominator->Fill(offlineIP3D.at(iOffTrk));
437 v.OnlineTrkEff_3d_ip_distance.numerator->Fill(offlineIP3D.at(iOffTrk));
439 v.OnlineTrkEff_3d_ip_sig.denominator->Fill(offlineIP3DSig.at(iOffTrk));
441 v.OnlineTrkEff_3d_ip_sig.numerator->Fill(offlineIP3DSig.at(iOffTrk));
444 for (
unsigned int iOnTrk = 0; iOnTrk < onlineTracks.size(); ++iOnTrk) {
445 const reco::Track* onTrk = onlineTracks.at(iOnTrk);
446 bool hasMatch =
false;
447 float onTrkEta = onTrk->
eta();
448 float onTrkPhi = onTrk->
phi();
451 float DR =
reco::deltaR(onTrkEta, onTrkPhi, offTrk->eta(), offTrk->phi());
457 float onTrkPt = onTrk->
pt();
458 v.OnlineTrkFake_Pt.denominator->Fill(onTrkPt);
460 v.OnlineTrkFake_Pt.numerator->Fill(onTrkPt);
462 v.OnlineTrkFake_Eta.denominator->Fill(onTrkEta);
464 v.OnlineTrkFake_Eta.numerator->Fill(onTrkEta);
466 v.OnlineTrkFake_3d_ip_distance.denominator->Fill(onlineIP3D.at(iOnTrk));
468 v.OnlineTrkFake_3d_ip_distance.numerator->Fill(onlineIP3D.at(iOnTrk));
470 v.OnlineTrkFake_3d_ip_sig.denominator->Fill(onlineIP3DSig.at(iOnTrk));
472 v.OnlineTrkFake_3d_ip_sig.numerator->Fill(onlineIP3DSig.at(iOnTrk));
476 if (
v.getTriggerType() ==
"PF") {
482 v.PVz->Fill(VertexHandler->begin()->z());
483 if (offlineVertexHandler.
isValid()) {
484 v.PVz_HLTMinusRECO->Fill(VertexHandler->begin()->z() - offlineVertexHandler->begin()->z());
493 v.fastPVz->Fill(VertexHandler->begin()->z());
494 if (offlineVertexHandler.
isValid()) {
495 v.fastPVz_HLTMinusRECO->Fill(VertexHandler->begin()->z() - offlineVertexHandler->begin()->z());
516 if ((
v.getTriggerType() ==
"PF" && shallowTagInfosPf.
isValid()) ||
517 (
v.getTriggerType() ==
"Calo" && shallowTagInfosCalo.
isValid())) {
518 const auto& shallowTagInfoCollection = (
v.getTriggerType() ==
"PF") ? shallowTagInfosPf : shallowTagInfosCalo;
519 for (
const auto& shallowTagInfo : *shallowTagInfoCollection) {
520 const auto& tagVars = shallowTagInfo.taggingVariables();
524 v.n_vtx->Fill(tagVar);
527 v.n_sel_tracks->Fill(tagVar);
533 for (
unsigned i_trk = 0; i_trk <
trackSip3dVal.size(); i_trk++) {
536 v.h_3d_ip_distance->Fill(
val);
537 v.h_3d_ip_error->Fill(
val / sig);
538 v.h_3d_ip_sig->Fill(sig);
543 v.vtx_mass->Fill(tagVar);
546 v.n_vtx_trks->Fill(tagVar);
598 std::vector<float>& offlineIP3D,
599 std::vector<float>& offlineIP3DSig) {
600 std::vector<const reco::Track*> offlineTracks;
602 for (
auto const& iterOffIP : *offlineIPTagHandle) {
603 float DR =
reco::deltaR(iterOffIP.jet()->eta(), iterOffIP.jet()->phi(), hltJetEta, hltJetPhi);
613 <<
"BTagPerformanceAnalyzer: Extended TagInfo not of type TrackIPTagInfo. " << std::endl;
617 tagInfo->primaryVertex()->position().y(),
618 tagInfo->primaryVertex()->position().z());
620 const std::vector<reco::btag::TrackIPData>& ip =
tagInfo->impactParameterData();
623 std::vector<reco::CandidatePtr> sortedTracks =
tagInfo->sortedTracks(sortedIndices);
624 std::vector<std::size_t> selectedIndices;
626 for (
unsigned int n = 0;
n != sortedIndices.size(); ++
n) {
628 double jetDistance = ip[sortedIndices[
n]].distanceToJetAxis.value();
631 selectedIndices.push_back(sortedIndices[
n]);
636 for (
unsigned int n = 0;
n != selectedIndices.size(); ++
n) {
638 offlineTracks.push_back(
track);
639 offlineIP3D.push_back(ip[
n].
ip3d.value());
640 offlineIP3DSig.push_back(ip[
n].
ip3d.significance());
643 return offlineTracks;
646 template <
class Base>
650 std::vector<float>& onlineIP3D,
651 std::vector<float>& onlineIP3DSig) {
652 std::vector<const reco::Track*> onlineTracks;
654 for (
auto iterTI = jetSVTagsColl->begin(); iterTI != jetSVTagsColl->end(); ++iterTI) {
655 float DR =
reco::deltaR(iterTI->jet()->eta(), iterTI->jet()->phi(), hltJetEta, hltJetPhi);
659 const auto& ipInfo = *(iterTI->trackIPTagInfoRef().get());
660 const std::vector<reco::btag::TrackIPData>& ip = ipInfo.impactParameterData();
662 unsigned int trackSize = ipInfo.selectedTracks().size();
663 for (
unsigned int itt = 0; itt < trackSize; ++itt) {
664 const auto ptrackRef = (ipInfo.selectedTracks()[itt]);
666 onlineTracks.push_back(ptrackPtr);
667 onlineIP3D.push_back(ip[itt].
ip3d.value());
668 onlineIP3DSig.push_back(ip[itt].
ip3d.significance());
686 histoname = labelname +
"_Discr";
687 title = labelname +
"_Discr " + trigPath;
688 v.Discr = iBooker.
book1D(histoname.c_str(),
title.c_str(), 110, -0.1, 1);
690 histoname = labelname +
"_Pt";
691 title = labelname +
"_Pt " + trigPath;
692 v.Pt = iBooker.
book1D(histoname.c_str(),
title.c_str(), 100, 0, 400);
694 histoname = labelname +
"_Eta";
695 title = labelname +
"_Eta " + trigPath;
696 v.Eta = iBooker.
book1D(histoname.c_str(),
title.c_str(), 60, -3.0, 3.0);
698 histoname =
"HLTvsRECO_Discr";
699 title =
"online discr vs offline discr " + trigPath;
700 v.Discr_HLTvsRECO = iBooker.
book2D(histoname.c_str(),
title.c_str(), 110, -0.1, 1, 110, -0.1, 1);
702 histoname =
"HLTMinusRECO_Discr";
703 title =
"online discr minus offline discr " + trigPath;
704 v.Discr_HLTMinusRECO = iBooker.
book1D(histoname.c_str(),
title.c_str(), 100, -1, 1);
706 histoname =
"Turnon_loose_Discr";
707 title =
"turn-on with loose threshold " + trigPath;
708 v.bookME(iBooker,
v.Discr_turnon_loose, histoname,
title, 22, -0.1, 1.);
710 histoname =
"Turnon_medium_Discr";
711 title =
"turn-on with medium threshold " + trigPath;
712 v.bookME(iBooker,
v.Discr_turnon_medium, histoname,
title, 22, -0.1, 1.);
714 histoname =
"Turnon_tight_Discr";
715 title =
"turn-on with tight threshold " + trigPath;
716 v.bookME(iBooker,
v.Discr_turnon_tight, histoname,
title, 22, -0.1, 1.);
718 histoname = labelname +
"_PVz";
719 title =
"online z(PV) " + trigPath;
720 v.PVz = iBooker.
book1D(histoname.c_str(),
title.c_str(), 80, -20, 20);
722 histoname = labelname +
"_fastPVz";
723 title =
"online z(fastPV) " + trigPath;
724 v.fastPVz = iBooker.
book1D(histoname.c_str(),
title.c_str(), 80, -20, 20);
726 histoname =
"HLTMinusRECO_PVz";
727 title =
"online z(PV) - offline z(PV) " + trigPath;
728 v.PVz_HLTMinusRECO = iBooker.
book1D(histoname.c_str(),
title.c_str(), 200, -0.5, 0.5);
730 histoname =
"HLTMinusRECO_fastPVz";
731 title =
"online z(fastPV) - offline z(PV) " + trigPath;
732 v.fastPVz_HLTMinusRECO = iBooker.
book1D(histoname.c_str(),
title.c_str(), 100, -2, 2);
735 title =
"N vertex candidates " + trigPath;
736 v.n_vtx = iBooker.
book1D(histoname.c_str(),
title.c_str(), 10, -0.5, 9.5);
738 histoname =
"vtx_mass";
739 title =
"secondary vertex mass (GeV)" + trigPath;
740 v.vtx_mass = iBooker.
book1D(histoname.c_str(),
title.c_str(), 20, 0, 10);
742 histoname =
"n_vtx_trks";
743 title =
"N tracks associated to secondary vertex" + trigPath;
744 v.n_vtx_trks = iBooker.
book1D(histoname.c_str(),
title.c_str(), 20, -0.5, 19.5);
746 histoname =
"n_sel_tracks";
747 title =
"N selected tracks" + trigPath;
748 v.n_sel_tracks = iBooker.
book1D(histoname.c_str(),
title.c_str(), 25, -0.5, 24.5);
750 histoname =
"3d_ip_distance";
751 title =
"3D IP distance of tracks (cm)" + trigPath;
752 v.h_3d_ip_distance = iBooker.
book1D(histoname.c_str(),
title.c_str(), 40, -0.1, 0.1);
754 histoname =
"3d_ip_error";
755 title =
"3D IP error of tracks (cm)" + trigPath;
756 v.h_3d_ip_error = iBooker.
book1D(histoname.c_str(),
title.c_str(), 40, 0., 0.1);
758 histoname =
"3d_ip_sig";
759 title =
"3D IP significance of tracks (cm)" + trigPath;
760 v.h_3d_ip_sig = iBooker.
book1D(histoname.c_str(),
title.c_str(), 40, -40, 40);
762 histoname =
"OnlineTrkEff_Pt";
763 title =
"Relative Online Trk Efficiency vs Pt " + trigPath;
764 v.bookME(iBooker,
v.OnlineTrkEff_Pt, histoname,
title, 50, -0.5, 20.);
766 histoname =
"OnlineTrkEff_Eta";
767 title =
"Relative Online Trk Efficiency vs Eta " + trigPath;
768 v.bookME(iBooker,
v.OnlineTrkEff_Eta, histoname,
title, 60, -3.0, 3.0);
770 histoname =
"OnlineTrkEff_3d_ip_distance";
771 title =
"Relative Online Trk Efficiency vs IP3D " + trigPath;
772 v.bookME(iBooker,
v.OnlineTrkEff_3d_ip_distance, histoname,
title, 40, -0.1, 0.1);
774 histoname =
"OnlineTrkEff_3d_ip_sig";
775 title =
"Relative Online Trk Efficiency vs IP3D significance " + trigPath;
776 v.bookME(iBooker,
v.OnlineTrkEff_3d_ip_sig, histoname,
title, 40, -40, 40);
778 histoname =
"OnlineTrkFake_Pt";
779 title =
"Relative Online Trk Fake Rate vs Pt " + trigPath;
780 v.bookME(iBooker,
v.OnlineTrkFake_Pt, histoname,
title, 50, -0.5, 20.);
782 histoname =
"OnlineTrkFake_Eta";
783 title =
"Relative Online Trk Fake Rate vs Eta " + trigPath;
784 v.bookME(iBooker,
v.OnlineTrkFake_Eta, histoname,
title, 60, -3.0, 3.0);
786 histoname =
"OnlineTrkFake_3d_ip_distance";
787 title =
"Relative Online Trk Fake Rate vs IP3D " + trigPath;
788 v.bookME(iBooker,
v.OnlineTrkFake_3d_ip_distance, histoname,
title, 40, -0.1, 0.1);
790 histoname =
"OnlineTrkFake_3d_ip_sig";
791 title =
"Relative Online Trk Fake Rate vs IP3D significance " + trigPath;
792 v.bookME(iBooker,
v.OnlineTrkFake_3d_ip_sig, histoname,
title, 40, -40, 40);