111 : m_propagatorSetup(ps.getParameter<
edm::
ParameterSet>(
"muProp"), consumesCollector()),
113 m_resTypes({kResPt, kResQOverPt, kResPhi, kResEta}),
114 m_etaRegions({kEtaRegionAll, kEtaRegionBmtf, kEtaRegionOmtf, kEtaRegionEmtf}),
115 m_qualLevelsRes({kQualAll}),
116 m_effStrings({{kEffPt,
"pt"}, {kEffPhi,
"phi"}, {kEffEta,
"eta"}, {kEffVtx,
"vtx"}}),
117 m_effLabelStrings({{kEffPt,
"p_{T} (GeV)"}, {kEffPhi,
"#phi"}, {kEffEta,
"#eta"}, {kEffVtx,
"# vertices"}}),
118 m_resStrings({{kResPt,
"pt"},
119 {kRes1OverPt,
"1overpt"},
120 {kResQOverPt,
"qoverpt"},
123 {kResCh,
"charge"}}),
124 m_resLabelStrings({{kResPt,
"(p_{T}^{L1} - p_{T}^{reco})/p_{T}^{reco}"},
125 {kRes1OverPt,
"(p_{T}^{reco} - p_{T}^{L1})/p_{T}^{L1}"},
126 {kResQOverPt,
"(q^{L1}*q^{reco}*p_{T}^{reco} - p_{T}^{L1})/p_{T}^{L1}"},
127 {kResPhi,
"#phi_{L1} - #phi_{reco}"},
128 {kResEta,
"#eta_{L1} - #eta_{reco}"},
129 {kResCh,
"charge^{L1} - charge^{reco}"}}),
130 m_etaStrings({{kEtaRegionAll,
"etaMin0_etaMax2p4"},
131 {kEtaRegionBmtf,
"etaMin0_etaMax0p83"},
132 {kEtaRegionOmtf,
"etaMin0p83_etaMax1p24"},
133 {kEtaRegionEmtf,
"etaMin1p24_etaMax2p4"}}),
135 {{kQualAll,
"qualAll"}, {kQualOpen,
"qualOpen"}, {kQualDouble,
"qualDouble"}, {kQualSingle,
"qualSingle"}}),
136 m_verbose(ps.getUntrackedParameter<
bool>(
"verbose")),
137 m_HistFolder(ps.getUntrackedParameter<
string>(
"histFolder")),
138 m_TagPtCut(ps.getUntrackedParameter<
double>(
"tagPtCut")),
139 m_recoToL1PtCutFactor(ps.getUntrackedParameter<
double>(
"recoToL1PtCutFactor")),
140 m_cutsVPSet(ps.getUntrackedParameter<std::vector<edm::ParameterSet>>(
"cuts")),
141 m_MuonInputTag(consumes<reco::MuonCollection>(ps.getUntrackedParameter<
InputTag>(
"muonInputTag"))),
142 m_GmtInputTag(consumes<l1t::MuonBxCollection>(ps.getUntrackedParameter<
InputTag>(
"gmtInputTag"))),
143 m_VtxInputTag(consumes<VertexCollection>(ps.getUntrackedParameter<
InputTag>(
"vtxInputTag"))),
144 m_BsInputTag(consumes<BeamSpot>(ps.getUntrackedParameter<
InputTag>(
"bsInputTag"))),
145 m_trigInputTag(consumes<trigger::TriggerEvent>(ps.getUntrackedParameter<
InputTag>(
"trigInputTag"))),
146 m_trigProcess(ps.getUntrackedParameter<
string>(
"trigProcess")),
147 m_trigProcess_token(consumes<edm::TriggerResults>(ps.getUntrackedParameter<
InputTag>(
"trigProcess_token"))),
148 m_trigNames(ps.getUntrackedParameter<vector<string>>(
"triggerNames")),
149 m_effVsPtBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsPtBins")),
150 m_effVsPhiBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsPhiBins")),
151 m_effVsEtaBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsEtaBins")),
152 m_effVsVtxBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsVtxBins")),
153 m_useAtVtxCoord(ps.getUntrackedParameter<
bool>(
"useL1AtVtxCoord")),
155 m_minTagProbeDR(0.5),
156 m_maxHltMuonDR(0.1) {
158 edm::LogInfo(
"L1TMuonDQMOffline") <<
"____________ Storage initialization ____________ " << endl;
160 for (
const auto& cutsPSet : m_cutsVPSet) {
161 const auto qCut = cutsPSet.getUntrackedParameter<
int>(
"qualCut");
162 QualLevel qLevel = kQualAll;
164 qLevel = kQualSingle;
165 }
else if (qCut > 7) {
166 qLevel = kQualDouble;
167 }
else if (qCut > 3) {
170 m_cuts.emplace_back(std::make_pair(cutsPSet.getUntrackedParameter<
int>(
"ptCut"), qLevel));
179 edm::LogInfo(
"L1TMuonDQMOffline") <<
"Called beginRun." << endl;
191 vector<string>::const_iterator trigNamesIt =
m_trigNames.begin();
192 vector<string>::const_iterator trigNamesEnd =
m_trigNames.end();
194 for (; trigNamesIt != trigNamesEnd; ++trigNamesIt) {
195 TString tNameTmp = TString(*trigNamesIt);
196 TRegexp tNamePattern = TRegexp(tNameTmp,
true);
201 if (tmpName.Contains(tNamePattern)) {
205 edm::LogInfo(
"L1TMuonDQMOffline") <<
"Found trigger " << tmpName <<
" with index " << tIndex << endl;
209 edm::LogInfo(
"L1TMuonDQMOffline") <<
"Warning: Could not find trigger " << (*trigNamesIt) << endl;
216 edm::LogInfo(
"L1TMuonDQMOffline") <<
"\nProcessing new event in analyze" << endl;
234 bool pass_HLT =
false;
236 if (trigResults->
accept(tIndex)) {
245 edm::LogInfo(
"L1TMuonDQMOffline") <<
"Did not fire any triggers - quitting" << endl;
260 <<
" probe muons" << endl;
262 vector<MuonGmtPair>::const_iterator muonGmtPairsIt =
m_MuonGmtPairs.begin();
263 vector<MuonGmtPair>::const_iterator muonGmtPairsEnd =
m_MuonGmtPairs.end();
269 for (; muonGmtPairsIt != muonGmtPairsEnd; ++muonGmtPairsIt) {
271 if ((muonGmtPairsIt->etaRegion() !=
kEtaRegionOut) && (muonGmtPairsIt->gmtPt() > 0)) {
272 regsToFill[1] = muonGmtPairsIt->etaRegion();
275 const auto varToFill = muonGmtPairsIt->getDeltaVar(
var);
276 std::get<0>(histoKeyRes) =
var;
278 for (
const auto regToFill : regsToFill) {
279 std::get<1>(histoKeyRes) = regToFill;
284 if (muonGmtPairsIt->gmtQual() >=
qualCut) {
285 std::get<2>(histoKeyRes) = qualLevel;
289 <<
"Filled resolution histo[" << std::get<0>(histoKeyRes) <<
", " << std::get<1>(histoKeyRes)
290 <<
", " << std::get<2>(histoKeyRes) <<
"] with " << varToFill << endl;
299 unsigned int cutsCounter = 0;
301 const auto gmtPtCut =
cut.first;
302 const auto qualLevel =
cut.second;
303 const bool gmtAboveCut = (muonGmtPairsIt->gmtPt() > gmtPtCut);
309 regsToFill[1] = muonGmtPairsIt->etaRegion();
317 varToFill =
static_cast<double>(
nVtx);
319 varToFill = muonGmtPairsIt->getVar(
var);
326 <<
"Filled eff denom eta histo[" << gmtPtCut <<
"] with " << varToFill << endl;
328 std::get<0>(histoKeyEffDenVar) =
var;
330 for (
const auto regToFill : regsToFill) {
332 if (cutsCounter == 0) {
336 <<
"Filled eff denom pT histo[" << regToFill <<
"] with " << varToFill << endl;
339 std::get<2>(histoKeyEffDenVar) = regToFill;
342 edm::LogInfo(
"L1TMuonDQMOffline") <<
"Filled eff denom histo[" << std::get<0>(histoKeyEffDenVar)
343 <<
", " << std::get<1>(histoKeyEffDenVar) <<
", " 344 << std::get<2>(histoKeyEffDenVar) <<
"] with " << varToFill << endl;
349 std::get<0>(histoKeyEffNumVar) =
var;
351 if (gmtAboveCut && muonGmtPairsIt->gmtQual() >= qualLevel * 4) {
357 <<
"Filled eff num eta histo[" << std::get<0>(histoKeyEffNumEta) <<
", " 358 << std::get<1>(histoKeyEffNumEta) <<
"] with " << varToFill << endl;
360 std::get<3>(histoKeyEffNumVar) = qualLevel;
362 for (
const auto regToFill : regsToFill) {
363 std::get<2>(histoKeyEffNumVar) = regToFill;
367 <<
"Filled eff num histo[" << std::get<0>(histoKeyEffNumVar) <<
", " 368 << std::get<1>(histoKeyEffNumVar) <<
", " << std::get<2>(histoKeyEffNumVar) <<
", " 369 << std::get<3>(histoKeyEffNumVar) <<
"] with " << varToFill << endl;
380 edm::LogInfo(
"L1TMuonDQMOffline") <<
"Computation finished" << endl;
386 edm::LogInfo(
"L1TMuonDQMOffline") <<
"Booking Control Plot Histos" << endl;
392 ibooker.
book2D(
"NTightVsAll",
"NTightVsAll; # muons; # tight muons", 20, -0.5, 19.5, 16, -0.5, 15.5);
394 ibooker.
book2D(
"NProbesVsTight",
"NProbesVsTight; # tight muons; # probe muons", 8, -0.5, 7.5, 8, -0.5, 7.5);
405 ibooker.
book1D(
"TagMuonProbeMuonDeltaR",
"TagMuonProbeMuonDeltaR; #DeltaR", 50, 0., 5.0);
418 const auto gmtPtCut =
cut.first;
419 const auto qualLevel =
cut.second;
437 const int gmtPtCut =
cut.first;
446 const auto gmtPtCut =
cut.first;
447 const auto qualLevel =
cut.second;
461 edm::LogInfo(
"L1TMuonDQMOffline") <<
"Booking Resolution Plot Histos" << endl;
481 unsigned int nVtx = 0;
484 for (
const auto& vertexIt : *
vertex) {
485 if (vertexIt.isValid() && !vertexIt.isFake()) {
498 bool hasPrimaryVertex =
false;
501 vector<Vertex>::const_iterator vertexIt =
vertex->begin();
502 vector<Vertex>::const_iterator vertexEnd =
vertex->end();
504 for (; vertexIt != vertexEnd; ++vertexIt) {
505 if (vertexIt->isValid() && !vertexIt->isFake()) {
506 posVtx = vertexIt->position();
507 errVtx = vertexIt->error();
508 hasPrimaryVertex =
true;
514 if (!hasPrimaryVertex) {
516 errVtx(0, 0) =
beamSpot->BeamWidthX();
517 errVtx(1, 1) =
beamSpot->BeamWidthY();
527 edm::LogInfo(
"L1TMuonDQMOffline") <<
"Getting tight muons" << endl;
529 MuonCollection::const_iterator muonIt =
muons->begin();
530 MuonCollection::const_iterator muonEnd =
muons->end();
532 for (; muonIt != muonEnd; ++muonIt) {
544 edm::LogInfo(
"L1TMuonDQMOffline") <<
"getting probe muons" << endl;
546 std::vector<const reco::Muon*> tagMuonsInHist;
548 tagMuonsInHist.clear();
550 vector<const reco::Muon*>::const_iterator probeCandIt =
m_TightMuons.begin();
551 vector<const reco::Muon*>::const_iterator tightMuonsEnd =
m_TightMuons.end();
553 for (; probeCandIt != tightMuonsEnd; ++probeCandIt) {
554 bool isProbe =
false;
555 vector<const reco::Muon*>::const_iterator tagCandIt =
m_TightMuons.begin();
558 for (; tagCandIt != tightMuonsEnd; ++tagCandIt) {
559 bool tagMuonAlreadyInHist =
false;
560 bool tagHasTrig =
false;
561 float eta = (*tagCandIt)->eta();
562 float phi = (*tagCandIt)->phi();
563 float pt = (*tagCandIt)->pt();
564 float dEta =
eta - (*probeCandIt)->eta();
565 float dPhi =
phi - (*probeCandIt)->phi();
571 tagHasTrig = (matchHltDeltaR < m_maxHltMuonDR) && (pt >
m_TagPtCut);
572 isProbe |= tagHasTrig;
575 for (vector<const reco::Muon*>::const_iterator tagMuonsInHistIt = tagMuonsInHist.begin();
576 tagMuonsInHistIt != tagMuonsInHist.end();
577 ++tagMuonsInHistIt) {
578 if ((*tagCandIt) == (*tagMuonsInHistIt)) {
579 tagMuonAlreadyInHist =
true;
583 if (tagMuonAlreadyInHist ==
false)
584 tagMuonsInHist.push_back((*tagCandIt));
586 if (tagMuonAlreadyInHist ==
false) {
606 edm::LogInfo(
"L1TMuonDQMOffline") <<
"Getting muon GMT pairs" << endl;
608 vector<const reco::Muon*>::const_iterator probeMuIt =
m_ProbeMuons.begin();
609 vector<const reco::Muon*>::const_iterator probeMuEnd =
m_ProbeMuons.end();
614 for (; probeMuIt != probeMuEnd; ++probeMuIt) {
622 gmtIt = gmtCands->
begin(0);
624 for (; gmtIt != gmtEnd; ++gmtIt) {
628 pairBestCand = pairTmpCand;
638 double matchDeltaR = 9999;
642 vector<int>::const_iterator trigIndexIt =
m_trigIndices.begin();
643 vector<int>::const_iterator trigIndexEnd =
m_trigIndices.end();
645 for (; trigIndexIt != trigIndexEnd; ++trigIndexIt) {
650 unsigned int moduleIndex = 999999;
651 for (
int ii = 0;
ii <
int(moduleLabels.size());
ii++) {
652 if (moduleLabels[
ii] ==
"hltBoolEnd") {
653 moduleIndex =
ii - 1;
657 if (moduleIndex == 999999) {
658 edm::LogError(
"L1TMuonDQMOffline") <<
"Found no module label in trigger " << (*trigIndexIt) << endl;
664 if (hltFilterIndex < triggerEvent->sizeFilters()) {
667 const unsigned nTriggers = triggerVids.size();
669 for (
size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
672 edm::LogInfo(
"L1TMuonDQMOffline") <<
"Found trigObject with pt = " << trigObject.
pt()
673 <<
", eta = " << trigObject.
eta() <<
", phi = " << trigObject.
phi() << endl;
675 edm::LogInfo(
"L1TMuonDQMOffline") <<
"Compare to muon with pt = " << (*mu).pt() <<
", eta = " << (*mu).eta()
676 <<
", phi = " << (*mu).phi() << endl;
677 double dRtmp =
deltaR((*
mu), trigObject);
678 if (dRtmp < matchDeltaR)
708 return {50, -2., 2.};
710 return {50, -2., 2.};
712 return {50, -2., 2.};
714 return {96, -0.2, 0.2};
716 return {100, -0.1, 0.1};
std::map< EffType, std::string > m_effStrings
constexpr double deltaPhi(double phi1, double phi2)
bool accept() const
Has at least one path accepted the event?
const std::string & triggerName(unsigned int triggerIndex) const
double m_recoToL1PtCutFactor
edm::EDGetTokenT< reco::BeamSpot > m_BsInputTag
edm::EDGetTokenT< reco::MuonCollection > m_MuonInputTag
std::vector< double > m_effVsVtxBins
std::map< ResType, std::string > m_resLabelStrings
virtual void setCurrentFolder(std::string const &fullpath)
std::map< EtaRegion, std::string > m_etaStrings
edm::EDGetTokenT< edm::TriggerResults > m_trigProcess_token
void analyze(const edm::Event &e, const edm::EventSetup &c) override
std::map< std::tuple< ResType, EtaRegion, QualLevel >, MonitorElement * > m_ResolutionHistos
Geom::Phi< T > phi() const
const std::vector< EtaRegion > m_etaRegions
std::vector< double > m_effVsPhiBins
math::Error< dimension >::type Error
covariance error matrix (3x3)
std::string to_string(const V &value)
std::map< EtaRegion, MonitorElement * > m_EfficiencyDenPtHistos
std::tuple< EffType, int, EtaRegion, QualLevel > m_histoKeyEffNumVarType
double getDeltaVar(const L1TMuonDQMOffline::ResType) const
Log< level::Error, false > LogError
std::pair< int, QualLevel > m_histoKeyEffNumEtaType
std::tuple< ResType, EtaRegion, QualLevel > m_histoKeyResType
std::vector< const reco::Muon * > m_ProbeMuons
std::vector< float > getHistBinsEff(EffType eff)
void getProbeMuons(edm::Handle< edm::TriggerResults > &trigResults, edm::Handle< trigger::TriggerEvent > &trigEvent)
const unsigned int getNVertices(edm::Handle< reco::VertexCollection > &vertex)
~L1TMuonDQMOffline() override
std::vector< std::string > m_trigNames
const_iterator begin(int bx) const
virtual void bookControlHistos(DQMStore::IBooker &)
std::map< QualLevel, std::string > m_qualStrings
double matchHlt(edm::Handle< trigger::TriggerEvent > &triggerEvent, const reco::Muon *mu)
std::string m_trigProcess
std::vector< T >::const_iterator const_iterator
const l1t::Muon * m_regMu
Propagate an object (usually a track) to the second (default) or first muon station.
std::map< EffType, std::string > m_effLabelStrings
GlobalPoint globalPosition() const
std::tuple< int, double, double > getHistBinsRes(ResType res)
unsigned int size() const
number of trigger paths in trigger table
edm::EDGetTokenT< l1t::MuonBxCollection > m_GmtInputTag
std::vector< double > m_effVsPtBins
void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &iSetup) override
std::tuple< EffType, int, EtaRegion > m_histoKeyEffDenVarType
std::map< std::pair< int, QualLevel >, MonitorElement * > m_EfficiencyNumEtaHistos
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
L1TMuonDQMOffline::EtaRegion etaRegion() const
const reco::Muon * m_muon
PropagateToMuonSetup const m_propagatorSetup
Abs< T >::type abs(const T &t)
std::map< int, MonitorElement * > m_EfficiencyDenEtaHistos
std::vector< std::pair< int, QualLevel > > m_cuts
math::XYZPoint Point
point in the space
#define DEFINE_FWK_MODULE(type)
const std::vector< EffType > m_effTypes
const std::vector< QualLevel > m_qualLevelsRes
std::vector< MuonGmtPair > m_MuonGmtPairs
std::map< std::tuple< EffType, int, EtaRegion >, MonitorElement * > m_EfficiencyDenVarHistos
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Log< level::Info, false > LogInfo
L1TMuonDQMOffline(const edm::ParameterSet &ps)
std::map< ResType, std::string > m_resStrings
std::vector< size_type > Keys
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
double getVar(const L1TMuonDQMOffline::EffType) const
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
virtual void bookResolutionHistos(DQMStore::IBooker &ibooker)
HLTConfigProvider m_hltConfig
const reco::Vertex getPrimaryVertex(edm::Handle< reco::VertexCollection > &vertex, edm::Handle< reco::BeamSpot > &beamSpot)
std::vector< double > m_effVsEtaBins
std::vector< const reco::Muon * > m_TightMuons
const_iterator end(int bx) const
const std::vector< ResType > m_resTypes
void dqmBeginRun(const edm::Run &run, const edm::EventSetup &iSetup) override
edm::EDGetTokenT< reco::VertexCollection > m_VtxInputTag
edm::EDGetTokenT< trigger::TriggerEvent > m_trigInputTag
std::map< std::tuple< EffType, int, EtaRegion, QualLevel >, MonitorElement * > m_EfficiencyNumVarHistos
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
double phi() const final
momentum azimuthal angle
primaryVertex
hltOfflineBeamSpot for HLTMON
MuonGmtPair(const reco::Muon *muon, const l1t::Muon *regMu, const PropagateToMuon &propagator, bool useAtVtxCoord)
std::map< Control, MonitorElement * > m_ControlHistos
void getMuonGmtPairs(edm::Handle< l1t::MuonBxCollection > &gmtCands, PropagateToMuon const &propagator)
std::vector< int > m_trigIndices
virtual void bookEfficiencyHistos(DQMStore::IBooker &ibooker)
void getTightMuons(edm::Handle< reco::MuonCollection > &muons, const reco::Vertex &vertex)
double eta() const final
momentum pseudorapidity