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 if (ptrackRef.isAvailable()) {
668 onlineTracks.push_back(ptrackPtr);
669 onlineIP3D.push_back(ip[itt].
ip3d.value());
670 onlineIP3DSig.push_back(ip[itt].
ip3d.significance());
689 histoname = labelname +
"_Discr";
690 title = labelname +
"_Discr " + trigPath;
691 v.Discr = iBooker.
book1D(histoname.c_str(),
title.c_str(), 110, -0.1, 1);
693 histoname = labelname +
"_Pt";
694 title = labelname +
"_Pt " + trigPath;
695 v.Pt = iBooker.
book1D(histoname.c_str(),
title.c_str(), 100, 0, 400);
697 histoname = labelname +
"_Eta";
698 title = labelname +
"_Eta " + trigPath;
699 v.Eta = iBooker.
book1D(histoname.c_str(),
title.c_str(), 60, -3.0, 3.0);
701 histoname =
"HLTvsRECO_Discr";
702 title =
"online discr vs offline discr " + trigPath;
703 v.Discr_HLTvsRECO = iBooker.
book2D(histoname.c_str(),
title.c_str(), 110, -0.1, 1, 110, -0.1, 1);
705 histoname =
"HLTMinusRECO_Discr";
706 title =
"online discr minus offline discr " + trigPath;
707 v.Discr_HLTMinusRECO = iBooker.
book1D(histoname.c_str(),
title.c_str(), 100, -1, 1);
709 histoname =
"Turnon_loose_Discr";
710 title =
"turn-on with loose threshold " + trigPath;
711 v.bookME(iBooker,
v.Discr_turnon_loose, histoname,
title, 22, -0.1, 1.);
713 histoname =
"Turnon_medium_Discr";
714 title =
"turn-on with medium threshold " + trigPath;
715 v.bookME(iBooker,
v.Discr_turnon_medium, histoname,
title, 22, -0.1, 1.);
717 histoname =
"Turnon_tight_Discr";
718 title =
"turn-on with tight threshold " + trigPath;
719 v.bookME(iBooker,
v.Discr_turnon_tight, histoname,
title, 22, -0.1, 1.);
721 histoname = labelname +
"_PVz";
722 title =
"online z(PV) " + trigPath;
723 v.PVz = iBooker.
book1D(histoname.c_str(),
title.c_str(), 80, -20, 20);
725 histoname = labelname +
"_fastPVz";
726 title =
"online z(fastPV) " + trigPath;
727 v.fastPVz = iBooker.
book1D(histoname.c_str(),
title.c_str(), 80, -20, 20);
729 histoname =
"HLTMinusRECO_PVz";
730 title =
"online z(PV) - offline z(PV) " + trigPath;
731 v.PVz_HLTMinusRECO = iBooker.
book1D(histoname.c_str(),
title.c_str(), 200, -0.5, 0.5);
733 histoname =
"HLTMinusRECO_fastPVz";
734 title =
"online z(fastPV) - offline z(PV) " + trigPath;
735 v.fastPVz_HLTMinusRECO = iBooker.
book1D(histoname.c_str(),
title.c_str(), 100, -2, 2);
738 title =
"N vertex candidates " + trigPath;
739 v.n_vtx = iBooker.
book1D(histoname.c_str(),
title.c_str(), 10, -0.5, 9.5);
741 histoname =
"vtx_mass";
742 title =
"secondary vertex mass (GeV)" + trigPath;
743 v.vtx_mass = iBooker.
book1D(histoname.c_str(),
title.c_str(), 20, 0, 10);
745 histoname =
"n_vtx_trks";
746 title =
"N tracks associated to secondary vertex" + trigPath;
747 v.n_vtx_trks = iBooker.
book1D(histoname.c_str(),
title.c_str(), 20, -0.5, 19.5);
749 histoname =
"n_sel_tracks";
750 title =
"N selected tracks" + trigPath;
751 v.n_sel_tracks = iBooker.
book1D(histoname.c_str(),
title.c_str(), 25, -0.5, 24.5);
753 histoname =
"3d_ip_distance";
754 title =
"3D IP distance of tracks (cm)" + trigPath;
755 v.h_3d_ip_distance = iBooker.
book1D(histoname.c_str(),
title.c_str(), 40, -0.1, 0.1);
757 histoname =
"3d_ip_error";
758 title =
"3D IP error of tracks (cm)" + trigPath;
759 v.h_3d_ip_error = iBooker.
book1D(histoname.c_str(),
title.c_str(), 40, 0., 0.1);
761 histoname =
"3d_ip_sig";
762 title =
"3D IP significance of tracks (cm)" + trigPath;
763 v.h_3d_ip_sig = iBooker.
book1D(histoname.c_str(),
title.c_str(), 40, -40, 40);
765 histoname =
"OnlineTrkEff_Pt";
766 title =
"Relative Online Trk Efficiency vs Pt " + trigPath;
767 v.bookME(iBooker,
v.OnlineTrkEff_Pt, histoname,
title, 50, -0.5, 20.);
769 histoname =
"OnlineTrkEff_Eta";
770 title =
"Relative Online Trk Efficiency vs Eta " + trigPath;
771 v.bookME(iBooker,
v.OnlineTrkEff_Eta, histoname,
title, 60, -3.0, 3.0);
773 histoname =
"OnlineTrkEff_3d_ip_distance";
774 title =
"Relative Online Trk Efficiency vs IP3D " + trigPath;
775 v.bookME(iBooker,
v.OnlineTrkEff_3d_ip_distance, histoname,
title, 40, -0.1, 0.1);
777 histoname =
"OnlineTrkEff_3d_ip_sig";
778 title =
"Relative Online Trk Efficiency vs IP3D significance " + trigPath;
779 v.bookME(iBooker,
v.OnlineTrkEff_3d_ip_sig, histoname,
title, 40, -40, 40);
781 histoname =
"OnlineTrkFake_Pt";
782 title =
"Relative Online Trk Fake Rate vs Pt " + trigPath;
783 v.bookME(iBooker,
v.OnlineTrkFake_Pt, histoname,
title, 50, -0.5, 20.);
785 histoname =
"OnlineTrkFake_Eta";
786 title =
"Relative Online Trk Fake Rate vs Eta " + trigPath;
787 v.bookME(iBooker,
v.OnlineTrkFake_Eta, histoname,
title, 60, -3.0, 3.0);
789 histoname =
"OnlineTrkFake_3d_ip_distance";
790 title =
"Relative Online Trk Fake Rate vs IP3D " + trigPath;
791 v.bookME(iBooker,
v.OnlineTrkFake_3d_ip_distance, histoname,
title, 40, -0.1, 0.1);
793 histoname =
"OnlineTrkFake_3d_ip_sig";
794 title =
"Relative Online Trk Fake Rate vs IP3D significance " + trigPath;
795 v.bookME(iBooker,
v.OnlineTrkFake_3d_ip_sig, histoname,
title, 40, -40, 40);
void analyze(const edm::Event &, const edm::EventSetup &) override
ObjME OnlineTrkFake_3d_ip_distance
BTVHLTOfflineSource(const edm::ParameterSet &)
const std::string & triggerName(unsigned int triggerIndex) const
T getParameter(std::string const &) const
edm::EDGetTokenT< std::vector< SVTagInfo > > SVTagInfosTokenPf_
The single EDProduct to be saved for each event (AOD case)
ObjME OnlineTrkEff_3d_ip_distance
const bool operator==(const std::string &v) const
ObjME OnlineTrkEff_3d_ip_sig
virtual void setCurrentFolder(std::string const &fullpath)
static PFTauRenderPlugin instance
MonitorElement * fastPVz_HLTMinusRECO
#define DEFINE_FWK_MODULE(type)
MonitorElement * h_3d_ip_sig
edm::EDGetTokenT< std::vector< reco::ShallowTagInfo > > shallowTagInfosTokenCalo_
edm::EDGetTokenT< reco::JetTagCollection > pfTagsToken_
edm::EDGetTokenT< reco::JetTagCollection > offlineDiscrTokenb_
void setLabel(std::string labelName)
edm::EDGetTokenT< std::vector< reco::Vertex > > hltCaloPVToken_
ObjME Discr_turnon_medium
reco::TemplatedSecondaryVertexTagInfo< reco::CandIPTagInfo, reco::VertexCompositePtrCandidate > SVTagInfo
MonitorElement * h_3d_ip_error
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const reco::Track * toTrack(const reco::TrackBaseRef &t)
edm::EDGetTokenT< std::vector< reco::SecondaryVertexTagInfo > > SVTagInfosTokenCalo_
static const std::string removeVersion(const std::string &trigger)
edm::EDGetTokenT< std::vector< reco::Vertex > > offlinePVToken_
edm::EDGetTokenT< trigger::TriggerEvent > triggerSummaryFUToken
double pt() const
track transverse momentum
std::vector< PathInfo >::iterator find(const std::string &pathName)
edm::InputTag triggerResultsLabel_
MonitorElement * vtx_mass
ObjME OnlineTrkFake_3d_ip_sig
edm::Handle< reco::JetTagCollection > pfTags
unsigned int size() const
number of trigger paths in trigger table
edm::InputTag triggerSummaryLabel_
const int getprescaleUsed() const
const std::string getTriggerType() const
~PathInfo() override=default
PathInfo(const int prescaleUsed, const std::string &pathName, const std::string &filterName, const std::string &processName, const int type, const std::string &triggerType)
double phi() const
azimuthal angle of momentum vector
PathInfoCollection hltPathsAll_
MonitorElement * PVz_HLTMinusRECO
MonitorElement * n_vtx_trks
~BTVHLTOfflineSource() override
static std::string const triggerResults
const std::string getProcess() const
HLTConfigProvider hltConfig_
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
edm::EDGetTokenT< reco::JetTagCollection > offlineDiscrTokenbb_
edm::EDGetTokenT< std::vector< reco::Vertex > > hltFastPVToken_
Log< level::Info, false > LogInfo
double eta() const
pseudorapidity of momentum vector
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken
MonitorElement * Discr_HLTMinusRECO
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
edm::EDGetTokenT< std::vector< reco::Vertex > > hltPFPVToken_
float turnon_threshold_loose_
void dqmBeginRun(edm::Run const &run, edm::EventSetup const &c) override
MonitorElement * h_3d_ip_distance
std::vector< const reco::Track * > getOfflineBTagTracks(float hltJetEta, float hltJetPhi, edm::Handle< edm::View< reco::BaseTagInfo >> offlineIPTagHandle, std::vector< float > &offlineIP3D, std::vector< float > &offlineIP3DSig)
std::vector< std::pair< std::string, std::string > > custompathnamepairs_
edm::EDGetTokenT< trigger::TriggerEvent > triggerSummaryToken
const std::string getPath() const
edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > offlineIPToken_
const int getObjectType() const
edm::EDGetTokenT< std::vector< reco::ShallowTagInfo > > shallowTagInfosTokenPf_
edm::Handle< reco::JetTagCollection > caloTags
MonitorElement * Discr_HLTvsRECO
const edm::InputTag getTag() const
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
void bookHistograms(DQMStore::IBooker &, edm::Run const &run, edm::EventSetup const &c) override
const std::string getLabel() const
edm::EDGetTokenT< reco::JetTagCollection > caloTagsToken_
float turnon_threshold_tight_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsFUToken
std::vector< const reco::Track * > getOnlineBTagTracks(float hltJetEta, float hltJetPhi, edm::Handle< std::vector< Base >> jetSVTagsColl, std::vector< float > &onlineIP3D, std::vector< float > &onlineIP3DSig)
MonitorElement * n_sel_tracks
float turnon_threshold_medium_