24 m_muon(muon), m_regMu(regMu)
67 return sqrt(dEta*dEta + dPhi*dPhi);
103 m_resStrings({ {
kResPt,
"pt"}, {
kRes1OverPt,
"1overpt"}, {
kResQOverPt,
"qoverpt"}, {
kResPhi,
"phi"}, {
kResEta,
"eta"}, {
kResCh,
"charge"} }),
104 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}"} }),
107 m_verbose(ps.getUntrackedParameter<
bool>(
"verbose")),
108 m_HistFolder(ps.getUntrackedParameter<
string>(
"histFolder")),
109 m_TagPtCut(ps.getUntrackedParameter<
double>(
"tagPtCut")),
111 m_cutsVPSet(ps.getUntrackedParameter<std::vector<edm::ParameterSet>>(
"cuts")),
117 m_trigProcess(ps.getUntrackedParameter<
string>(
"trigProcess")),
119 m_trigNames(ps.getUntrackedParameter<vector<string> >(
"triggerNames")),
120 m_effVsPtBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsPtBins")),
121 m_effVsPhiBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsPhiBins")),
122 m_effVsEtaBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsEtaBins")),
123 m_effVsVtxBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsVtxBins")),
129 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] ____________ Storage initialization ____________ " << endl;
132 const auto qCut = cutsPSet.getUntrackedParameter<
int>(
"qualCut");
136 }
else if (qCut > 7) {
138 }
else if (qCut > 3) {
141 m_cuts.emplace_back(std::make_pair(cutsPSet.getUntrackedParameter<
int>(
"ptCut"), qLevel));
149 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Called beginRun." << endl;
162 vector<string>::const_iterator trigNamesIt =
m_trigNames.begin();
163 vector<string>::const_iterator trigNamesEnd =
m_trigNames.end();
165 for (; trigNamesIt!=trigNamesEnd; ++trigNamesIt) {
166 TString tNameTmp = TString(*trigNamesIt);
167 TRegexp tNamePattern = TRegexp(tNameTmp,
true);
172 if (tmpName.Contains(tNamePattern)) {
177 if (tIndex < 0 &&
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Warning: Could not find trigger " << (*trigNamesIt) << endl;
205 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Computing efficiencies" << endl;
207 vector<MuonGmtPair>::const_iterator muonGmtPairsIt =
m_MuonGmtPairs.begin();
208 vector<MuonGmtPair>::const_iterator muonGmtPairsEnd =
m_MuonGmtPairs.end();
214 for(; muonGmtPairsIt!=muonGmtPairsEnd; ++muonGmtPairsIt) {
216 if( (muonGmtPairsIt->etaRegion() !=
kEtaRegionOut) && (muonGmtPairsIt->gmtPt() > 0) ){
217 regsToFill[1] = muonGmtPairsIt->etaRegion();
220 const auto varToFill = muonGmtPairsIt->getDeltaVar(
var);
221 std::get<0>(histoKeyRes) =
var;
223 for (
const auto regToFill : regsToFill) {
224 std::get<1>(histoKeyRes) = regToFill;
228 int qualCut = qualLevel * 4;
229 if (muonGmtPairsIt->gmtQual() >= qualCut) {
230 std::get<2>(histoKeyRes) = qualLevel;
240 unsigned int cutsCounter = 0;
242 const auto gmtPtCut =
cut.first;
243 const auto qualLevel =
cut.second;
244 const bool gmtAboveCut = (muonGmtPairsIt->gmtPt() > gmtPtCut);
250 regsToFill[1] = muonGmtPairsIt->etaRegion();
257 varToFill =
static_cast<double>(nVtx);
259 varToFill = muonGmtPairsIt->getVar(
var);
265 std::get<0>(histoKeyEffDenVar) =
var;
267 for (
const auto regToFill : regsToFill) {
269 if (cutsCounter == 0) {
273 std::get<2>(histoKeyEffDenVar) = regToFill;
279 std::get<0>(histoKeyEffNumVar) =
var;
281 if (gmtAboveCut && muonGmtPairsIt->gmtQual() >= qualLevel * 4) {
286 std::get<3>(histoKeyEffNumVar) = qualLevel;
288 for (
const auto regToFill : regsToFill) {
289 std::get<2>(histoKeyEffNumVar) = regToFill;
300 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Computation finished" << endl;
305 if(
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Booking Control Plot Histos" << endl;
334 const auto gmtPtCut =
cut.first;
335 const auto qualLevel =
cut.second;
350 const int gmtPtCut =
cut.first;
357 const auto gmtPtCut =
cut.first;
358 const auto qualLevel =
cut.second;
369 if(
m_verbose)
cout <<
"[L1TMuonOffline:] Booking Resolution Plot Histos" << endl;
388 unsigned int nVtx = 0;
391 for (
const auto vertexIt : *vertex) {
392 if (vertexIt.isValid() && !vertexIt.isFake()) {
406 bool hasPrimaryVertex =
false;
409 vector<Vertex>::const_iterator vertexIt = vertex->begin();
410 vector<Vertex>::const_iterator vertexEnd = vertex->end();
412 for (;vertexIt!=vertexEnd;++vertexIt) {
413 if (vertexIt->isValid() && !vertexIt->isFake()) {
414 posVtx = vertexIt->position();
415 errVtx = vertexIt->error();
416 hasPrimaryVertex =
true;
422 if ( !hasPrimaryVertex ) {
426 errVtx(2,2) = beamSpot->
sigmaZ();
435 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Getting tight muons" << endl;
437 MuonCollection::const_iterator muonIt = muons->begin();
438 MuonCollection::const_iterator muonEnd = muons->end();
440 for(; muonIt!=muonEnd; ++muonIt) {
452 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] getting probe muons" << endl;
454 std::vector<const reco::Muon*> tagMuonsInHist;
456 tagMuonsInHist.clear();
458 vector<const reco::Muon*>::const_iterator probeCandIt =
m_TightMuons.begin();
459 vector<const reco::Muon*>::const_iterator tightMuonsEnd =
m_TightMuons.end();
461 for (; probeCandIt!=tightMuonsEnd; ++probeCandIt) {
462 bool isProbe =
false;
463 vector<const reco::Muon*>::const_iterator tagCandIt =
m_TightMuons.begin();
466 for (; tagCandIt!=tightMuonsEnd; ++tagCandIt) {
467 bool tagMuonAlreadyInHist =
false;
468 bool tagHasTrig =
false;
469 float eta = (*tagCandIt)->eta();
470 float phi = (*tagCandIt)->phi();
471 float pt = (*tagCandIt)->pt();
472 float dEta = eta - (*probeCandIt)->eta();
473 float dPhi = phi - (*probeCandIt)->phi();
474 deltar =
sqrt(dEta*dEta + dPhi*dPhi);
476 if ( (*tagCandIt) == (*probeCandIt) || deltar<
m_minTagProbeDR )
continue;
477 auto matchHltDeltaR =
matchHlt(trigEvent,(*tagCandIt));
478 tagHasTrig = (matchHltDeltaR < m_maxHltMuonDR) && (pt >
m_TagPtCut);
479 isProbe |= tagHasTrig;
482 for (vector<const reco::Muon*>::const_iterator tagMuonsInHistIt = tagMuonsInHist.begin(); tagMuonsInHistIt!=tagMuonsInHist.end(); ++tagMuonsInHistIt) {
483 if ( (*tagCandIt) == (*tagMuonsInHistIt) ) {
484 tagMuonAlreadyInHist =
true;
488 if (tagMuonAlreadyInHist ==
false) tagMuonsInHist.push_back((*tagCandIt));
490 if (tagMuonAlreadyInHist ==
false) {
508 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Getting muon GMT pairs" << endl;
510 vector<const reco::Muon*>::const_iterator probeMuIt =
m_ProbeMuons.begin();
511 vector<const reco::Muon*>::const_iterator probeMuEnd =
m_ProbeMuons.end();
516 for (; probeMuIt!=probeMuEnd; ++probeMuIt) {
524 gmtIt = gmtCands->
begin(0);
526 for(; gmtIt!=gmtEnd; ++gmtIt) {
530 pairBestCand = pairTmpCand;
542 double matchDeltaR = 9999;
546 vector<int>::const_iterator trigIndexIt =
m_trigIndices.begin();
547 vector<int>::const_iterator trigIndexEnd =
m_trigIndices.end();
549 for(; trigIndexIt!=trigIndexEnd; ++trigIndexIt) {
554 if (hltFilterIndex < triggerEvent->sizeFilters()) {
556 const Vids triggerVids(triggerEvent->
filterIds(hltFilterIndex));
557 const unsigned nTriggers = triggerVids.size();
558 for (
size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
559 const TriggerObject trigObject = trigObjs[triggerKeys[iTrig]];
560 double dRtmp =
deltaR((*mu),trigObject);
561 if (dRtmp < matchDeltaR) matchDeltaR = dRtmp;
589 if (res ==
kResPt)
return {50, -2., 2.};
592 if (res ==
kResPhi)
return {96, -0.2, 0.2};
593 if (res ==
kResEta)
return {100, -0.1, 0.1};
594 if (res ==
kResCh)
return {5, -2, 3};
std::map< EffType, std::string > m_effStrings
unsigned int size() const
number of trigger paths in trigger table
constexpr double deltaPhi(double phi1, double phi2)
const_iterator end(int bx) const
double m_recoToL1PtCutFactor
TrajectoryStateOnSurface extrapolate(const reco::Track &tk) const
edm::EDGetTokenT< reco::BeamSpot > m_BsInputTag
double eta() const final
momentum pseudorapidity
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
std::map< EtaRegion, std::string > m_etaStrings
edm::EDGetTokenT< edm::TriggerResults > m_trigProcess_token
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
std::map< std::tuple< ResType, EtaRegion, QualLevel >, MonitorElement * > m_ResolutionHistos
const std::vector< EtaRegion > m_etaRegions
const Keys & filterKeys(trigger::size_type index) const
Geom::Phi< T > phi() const
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
std::vector< double > m_effVsPhiBins
math::Error< dimension >::type Error
covariance error matrix (3x3)
GlobalPoint globalPosition() const
double getVar(const L1TMuonDQMOffline::EffType) const
std::map< EtaRegion, MonitorElement * > m_EfficiencyDenPtHistos
std::tuple< EffType, int, EtaRegion, QualLevel > m_histoKeyEffNumVarType
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
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
const l1t::Muon * m_regMu
const Vids & filterIds(trigger::size_type index) const
std::vector< edm::ParameterSet > m_cutsVPSet
#define DEFINE_FWK_MODULE(type)
Propagate an object (usually a track) to the second muon station. Support for other muon stations wil...
std::map< EffType, std::string > m_effLabelStrings
void setCurrentFolder(std::string const &fullpath)
std::tuple< int, double, double > getHistBinsRes(ResType res)
edm::EDGetTokenT< l1t::MuonBxCollection > m_GmtInputTag
const TriggerObjectCollection & getObjects() const
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 reco::Muon * m_muon
MonitorElement * book1D(Args &&...args)
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
double BeamWidthX() const
beam width X
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
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)
void getMuonGmtPairs(edm::Handle< l1t::MuonBxCollection > &gmtCands)
std::map< ResType, std::string > m_resStrings
MonitorElement * book2D(Args &&...args)
std::vector< size_type > Keys
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
double sigmaZ() const
sigma z
double BeamWidthY() const
beam width Y
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)
std::vector< double > m_effVsEtaBins
std::vector< const reco::Muon * > m_TightMuons
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
const Point & position() const
position
std::map< std::tuple< EffType, int, EtaRegion, QualLevel >, MonitorElement * > m_EfficiencyNumVarHistos
PropagateToMuon m_propagator
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
L1TMuonDQMOffline::EtaRegion etaRegion() const
const_iterator begin(int bx) const
MuonGmtPair(const reco::Muon *muon, const l1t::Muon *regMu, const PropagateToMuon &propagator, bool useAtVtxCoord)
double phi() const final
momentum azimuthal angle
std::map< Control, MonitorElement * > m_ControlHistos
std::vector< int > m_trigIndices
virtual void bookEfficiencyHistos(DQMStore::IBooker &ibooker)
std::vector< T >::const_iterator const_iterator
void getTightMuons(edm::Handle< reco::MuonCollection > &muons, const reco::Vertex &vertex)