16 using namespace trigger;
27 :
m_muon(muon), m_regMu(regMu) {
69 return sqrt(dEta * dEta + dPhi * dPhi);
111 : m_propagator(ps.getParameter<edm::
ParameterSet>(
"muProp"), consumesCollector()),
113 m_resTypes({kResPt, kResQOverPt, kResPhi, kResEta}),
114 m_etaRegions({kEtaRegionAll, kEtaRegionBmtf, kEtaRegionOmtf, kEtaRegionEmtf}),
116 m_effStrings({{kEffPt,
"pt"}, {kEffPhi,
"phi"}, {kEffEta,
"eta"}, {kEffVtx,
"vtx"}}),
117 m_effLabelStrings({{kEffPt,
"p_{T} (GeV)"}, {kEffPhi,
"#phi"}, {kEffEta,
"#eta"}, {kEffVtx,
"# vertices"}}),
119 {kRes1OverPt,
"1overpt"},
120 {kResQOverPt,
"qoverpt"},
123 {kResCh,
"charge"}}),
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}"}}),
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")),
140 m_cutsVPSet(ps.getUntrackedParameter<std::vector<edm::ParameterSet>>(
"cuts")),
146 m_trigProcess(ps.getUntrackedParameter<
string>(
"trigProcess")),
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")),
158 cout <<
"[L1TMuonDQMOffline:] ____________ Storage initialization ____________ " << endl;
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 cout <<
"[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)) {
207 cout <<
"[L1TMuonDQMOffline:] Warning: Could not find trigger " << (*trigNamesIt) << endl;
237 cout <<
"[L1TMuonDQMOffline:] Computing efficiencies" << endl;
239 vector<MuonGmtPair>::const_iterator muonGmtPairsIt =
m_MuonGmtPairs.begin();
240 vector<MuonGmtPair>::const_iterator muonGmtPairsEnd =
m_MuonGmtPairs.end();
246 for (; muonGmtPairsIt != muonGmtPairsEnd; ++muonGmtPairsIt) {
248 if ((muonGmtPairsIt->etaRegion() !=
kEtaRegionOut) && (muonGmtPairsIt->gmtPt() > 0)) {
249 regsToFill[1] = muonGmtPairsIt->etaRegion();
252 const auto varToFill = muonGmtPairsIt->getDeltaVar(
var);
253 std::get<0>(histoKeyRes) =
var;
255 for (
const auto regToFill : regsToFill) {
256 std::get<1>(histoKeyRes) = regToFill;
261 if (muonGmtPairsIt->gmtQual() >=
qualCut) {
262 std::get<2>(histoKeyRes) = qualLevel;
272 unsigned int cutsCounter = 0;
274 const auto gmtPtCut =
cut.first;
275 const auto qualLevel =
cut.second;
276 const bool gmtAboveCut = (muonGmtPairsIt->gmtPt() > gmtPtCut);
282 regsToFill[1] = muonGmtPairsIt->etaRegion();
290 varToFill =
static_cast<double>(nVtx);
292 varToFill = muonGmtPairsIt->getVar(
var);
298 std::get<0>(histoKeyEffDenVar) =
var;
300 for (
const auto regToFill : regsToFill) {
302 if (cutsCounter == 0) {
306 std::get<2>(histoKeyEffDenVar) = regToFill;
312 std::get<0>(histoKeyEffNumVar) =
var;
314 if (gmtAboveCut && muonGmtPairsIt->gmtQual() >= qualLevel * 4) {
319 std::get<3>(histoKeyEffNumVar) = qualLevel;
321 for (
const auto regToFill : regsToFill) {
322 std::get<2>(histoKeyEffNumVar) = regToFill;
334 cout <<
"[L1TMuonDQMOffline:] Computation finished" << endl;
340 cout <<
"[L1TMuonDQMOffline:] Booking Control Plot Histos" << endl;
346 ibooker.
book2D(
"NTightVsAll",
"NTightVsAll; # muons; # tight muons", 20, -0.5, 19.5, 16, -0.5, 15.5);
348 ibooker.
book2D(
"NProbesVsTight",
"NProbesVsTight; # tight muons; # probe muons", 8, -0.5, 7.5, 8, -0.5, 7.5);
359 ibooker.
book1D(
"TagMuonProbeMuonDeltaR",
"TagMuonProbeMuonDeltaR; #DeltaR", 50, 0., 5.0);
372 const auto gmtPtCut =
cut.first;
373 const auto qualLevel =
cut.second;
391 const int gmtPtCut =
cut.first;
400 const auto gmtPtCut =
cut.first;
401 const auto qualLevel =
cut.second;
415 cout <<
"[L1TMuonOffline:] Booking Resolution Plot Histos" << endl;
435 unsigned int nVtx = 0;
438 for (
const auto& vertexIt : *vertex) {
439 if (vertexIt.isValid() && !vertexIt.isFake()) {
452 bool hasPrimaryVertex =
false;
455 vector<Vertex>::const_iterator vertexIt = vertex->begin();
456 vector<Vertex>::const_iterator vertexEnd = vertex->end();
458 for (; vertexIt != vertexEnd; ++vertexIt) {
459 if (vertexIt->isValid() && !vertexIt->isFake()) {
460 posVtx = vertexIt->position();
461 errVtx = vertexIt->error();
462 hasPrimaryVertex =
true;
468 if (!hasPrimaryVertex) {
469 posVtx = beamSpot->position();
470 errVtx(0, 0) = beamSpot->BeamWidthX();
471 errVtx(1, 1) = beamSpot->BeamWidthY();
472 errVtx(2, 2) = beamSpot->sigmaZ();
481 cout <<
"[L1TMuonDQMOffline:] Getting tight muons" << endl;
483 MuonCollection::const_iterator muonIt = muons->begin();
484 MuonCollection::const_iterator muonEnd = muons->end();
486 for (; muonIt != muonEnd; ++muonIt) {
498 cout <<
"[L1TMuonDQMOffline:] getting probe muons" << endl;
500 std::vector<const reco::Muon*> tagMuonsInHist;
502 tagMuonsInHist.clear();
504 vector<const reco::Muon*>::const_iterator probeCandIt =
m_TightMuons.begin();
505 vector<const reco::Muon*>::const_iterator tightMuonsEnd =
m_TightMuons.end();
507 for (; probeCandIt != tightMuonsEnd; ++probeCandIt) {
508 bool isProbe =
false;
509 vector<const reco::Muon*>::const_iterator tagCandIt =
m_TightMuons.begin();
512 for (; tagCandIt != tightMuonsEnd; ++tagCandIt) {
513 bool tagMuonAlreadyInHist =
false;
514 bool tagHasTrig =
false;
515 float eta = (*tagCandIt)->eta();
516 float phi = (*tagCandIt)->phi();
517 float pt = (*tagCandIt)->pt();
518 float dEta = eta - (*probeCandIt)->eta();
519 float dPhi = phi - (*probeCandIt)->phi();
520 deltar =
sqrt(dEta * dEta + dPhi * dPhi);
524 auto matchHltDeltaR =
matchHlt(trigEvent, (*tagCandIt));
525 tagHasTrig = (matchHltDeltaR < m_maxHltMuonDR) && (pt >
m_TagPtCut);
526 isProbe |= tagHasTrig;
529 for (vector<const reco::Muon*>::const_iterator tagMuonsInHistIt = tagMuonsInHist.begin();
530 tagMuonsInHistIt != tagMuonsInHist.end();
531 ++tagMuonsInHistIt) {
532 if ((*tagCandIt) == (*tagMuonsInHistIt)) {
533 tagMuonAlreadyInHist =
true;
537 if (tagMuonAlreadyInHist ==
false)
538 tagMuonsInHist.push_back((*tagCandIt));
540 if (tagMuonAlreadyInHist ==
false) {
559 cout <<
"[L1TMuonDQMOffline:] Getting muon GMT pairs" << endl;
561 vector<const reco::Muon*>::const_iterator probeMuIt =
m_ProbeMuons.begin();
562 vector<const reco::Muon*>::const_iterator probeMuEnd =
m_ProbeMuons.end();
567 for (; probeMuIt != probeMuEnd; ++probeMuIt) {
575 gmtIt = gmtCands->begin(0);
577 for (; gmtIt != gmtEnd; ++gmtIt) {
581 pairBestCand = pairTmpCand;
591 double matchDeltaR = 9999;
595 vector<int>::const_iterator trigIndexIt =
m_trigIndices.begin();
596 vector<int>::const_iterator trigIndexEnd =
m_trigIndices.end();
598 for (; trigIndexIt != trigIndexEnd; ++trigIndexIt) {
601 const unsigned hltFilterIndex = triggerEvent->filterIndex(
InputTag(moduleLabels[moduleIndex],
"",
m_trigProcess));
603 if (hltFilterIndex < triggerEvent->sizeFilters()) {
604 const Keys triggerKeys(triggerEvent->filterKeys(hltFilterIndex));
605 const Vids triggerVids(triggerEvent->filterIds(hltFilterIndex));
606 const unsigned nTriggers = triggerVids.size();
607 for (
size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
608 const TriggerObject trigObject = trigObjs[triggerKeys[iTrig]];
609 double dRtmp =
deltaR((*mu), trigObject);
610 if (dRtmp < matchDeltaR)
640 return {50, -2., 2.};
642 return {50, -2., 2.};
644 return {50, -2., 2.};
646 return {96, -0.2, 0.2};
648 return {100, -0.1, 0.1};
std::map< EffType, std::string > m_effStrings
unsigned int size() const
number of trigger paths in trigger table
m_VtxInputTag(consumes< VertexCollection >(ps.getUntrackedParameter< InputTag >("vtxInputTag")))
constexpr double deltaPhi(double phi1, double phi2)
double m_recoToL1PtCutFactor
TrajectoryStateOnSurface extrapolate(const reco::Track &tk) const
Extrapolate reco::Track to the muon station 2, return an invalid TSOS if it fails.
edm::EDGetTokenT< reco::BeamSpot > m_BsInputTag
m_trigProcess(ps.getUntrackedParameter< string >("trigProcess"))
edm::EDGetTokenT< reco::MuonCollection > m_MuonInputTag
const std::string & triggerName(unsigned int triggerIndex) const
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
m_qualLevelsRes({kQualAll})
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void analyze(const edm::Event &e, const edm::EventSetup &c) override
double getDeltaVar(const L1TMuonDQMOffline::ResType) const
m_verbose(ps.getUntrackedParameter< bool >("verbose"))
std::map< std::tuple< ResType, EtaRegion, QualLevel >, MonitorElement * > m_ResolutionHistos
#define DEFINE_FWK_MODULE(type)
const std::vector< EtaRegion > m_etaRegions
m_effVsVtxBins(ps.getUntrackedParameter< std::vector< double >>("efficiencyVsVtxBins"))
Geom::Phi< T > phi() const
m_etaStrings({{kEtaRegionAll,"etaMin0_etaMax2p4"},{kEtaRegionBmtf,"etaMin0_etaMax0p83"},{kEtaRegionOmtf,"etaMin0p83_etaMax1p24"},{kEtaRegionEmtf,"etaMin1p24_etaMax2p4"}})
m_effStrings({{kEffPt,"pt"},{kEffPhi,"phi"},{kEffEta,"eta"},{kEffVtx,"vtx"}})
m_cutsVPSet(ps.getUntrackedParameter< std::vector< edm::ParameterSet >>("cuts"))
std::vector< double > m_effVsPhiBins
math::Error< dimension >::type Error
covariance error matrix (3x3)
m_resStrings({{kResPt,"pt"},{kRes1OverPt,"1overpt"},{kResQOverPt,"qoverpt"},{kResPhi,"phi"},{kResEta,"eta"},{kResCh,"charge"}})
GlobalPoint globalPosition() const
double getVar(const L1TMuonDQMOffline::EffType) const
m_MuonInputTag(consumes< reco::MuonCollection >(ps.getUntrackedParameter< InputTag >("muonInputTag")))
std::map< EtaRegion, MonitorElement * > m_EfficiencyDenPtHistos
std::tuple< EffType, int, EtaRegion, QualLevel > m_histoKeyEffNumVarType
std::pair< int, QualLevel > m_histoKeyEffNumEtaType
m_GmtInputTag(consumes< l1t::MuonBxCollection >(ps.getUntrackedParameter< InputTag >("gmtInputTag")))
std::tuple< ResType, EtaRegion, QualLevel > m_histoKeyResType
std::vector< const reco::Muon * > m_ProbeMuons
std::vector< float > getHistBinsEff(EffType eff)
m_trigNames(ps.getUntrackedParameter< vector< string >>("triggerNames"))
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
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
Single trigger physics object (e.g., an isolated muon)
std::vector< T >::const_iterator const_iterator
const l1t::Muon * m_regMu
m_resLabelStrings({{kResPt,"(p_{T}^{L1} - p_{T}^{reco})/p_{T}^{reco}"},{kRes1OverPt,"(p_{T}^{reco} - p_{T}^{L1})/p_{T}^{L1}"},{kResQOverPt,"(q^{L1}*q^{reco}*p_{T}^{reco} - p_{T}^{L1})/p_{T}^{L1}"},{kResPhi,"#phi_{L1} - #phi_{reco}"},{kResEta,"#eta_{L1} - #eta_{reco}"},{kResCh,"charge^{L1} - charge^{reco}"}})
Propagate an object (usually a track) to the second muon station. Support for other muon stations wil...
std::map< EffType, std::string > m_effLabelStrings
std::tuple< int, double, double > getHistBinsRes(ResType res)
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
m_trigProcess_token(consumes< edm::TriggerResults >(ps.getUntrackedParameter< InputTag >("trigProcess_token")))
std::tuple< EffType, int, EtaRegion > m_histoKeyEffDenVarType
std::map< std::pair< int, QualLevel >, MonitorElement * > m_EfficiencyNumEtaHistos
list var
if using global norm cols_to_minmax = ['t_delta', 't_hmaxNearP','t_emaxNearP', 't_hAnnular', 't_eAnnular','t_pt','t_nVtx','t_ieta','t_eHcal10', 't_eHcal30','t_rhoh','t_eHcal'] df[cols_to_minmax] = df[cols_to_minmax].apply(lambda x: (x - x.min()) / (x.max() - x.min()) if (x.max() - x.min() > 0) else 1.0/200.0)
m_HistFolder(ps.getUntrackedParameter< string >("histFolder"))
const reco::Muon * m_muon
m_useAtVtxCoord(ps.getUntrackedParameter< bool >("useL1AtVtxCoord"))
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
m_etaRegions({kEtaRegionAll, kEtaRegionBmtf, kEtaRegionOmtf, kEtaRegionEmtf})
m_effVsEtaBins(ps.getUntrackedParameter< std::vector< double >>("efficiencyVsEtaBins"))
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
m_recoToL1PtCutFactor(ps.getUntrackedParameter< double >("recoToL1PtCutFactor"))
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
L1TMuonDQMOffline(const edm::ParameterSet &ps)
m_trigInputTag(consumes< trigger::TriggerEvent >(ps.getUntrackedParameter< InputTag >("trigInputTag")))
m_effVsPhiBins(ps.getUntrackedParameter< std::vector< double >>("efficiencyVsPhiBins"))
void getMuonGmtPairs(edm::Handle< l1t::MuonBxCollection > &gmtCands)
m_qualStrings({{kQualAll,"qualAll"},{kQualOpen,"qualOpen"},{kQualDouble,"qualDouble"},{kQualSingle,"qualSingle"}})
std::map< ResType, std::string > m_resStrings
m_BsInputTag(consumes< BeamSpot >(ps.getUntrackedParameter< InputTag >("bsInputTag")))
std::vector< size_type > Keys
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())
virtual void bookResolutionHistos(DQMStore::IBooker &ibooker)
HLTConfigProvider m_hltConfig
const reco::Vertex getPrimaryVertex(edm::Handle< reco::VertexCollection > &vertex, edm::Handle< reco::BeamSpot > &beamSpot)
void init(const edm::EventSetup &iSetup)
Call this method at the beginning of each event, to initialize geometry, magnetic field and propagato...
m_TagPtCut(ps.getUntrackedParameter< double >("tagPtCut"))
std::vector< double > m_effVsEtaBins
m_resTypes({kResPt, kResQOverPt, kResPhi, kResEta})
std::vector< const reco::Muon * > m_TightMuons
const std::vector< ResType > m_resTypes
m_effVsPtBins(ps.getUntrackedParameter< std::vector< double >>("efficiencyVsPtBins"))
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
PropagateToMuon m_propagator
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())
L1TMuonDQMOffline::EtaRegion etaRegion() const
double phi() const final
momentum azimuthal angle
MuonGmtPair(const reco::Muon *muon, const l1t::Muon *regMu, const PropagateToMuon &propagator, bool useAtVtxCoord)
std::map< Control, MonitorElement * > m_ControlHistos
std::vector< int > m_trigIndices
virtual void bookEfficiencyHistos(DQMStore::IBooker &ibooker)
m_effLabelStrings({{kEffPt,"p_{T} (GeV)"},{kEffPhi,"#phi"},{kEffEta,"#eta"},{kEffVtx,"# vertices"}})
void getTightMuons(edm::Handle< reco::MuonCollection > &muons, const reco::Vertex &vertex)
double eta() const final
momentum pseudorapidity