24 m_muon(muon), m_regMu(regMu)
64 return sqrt(dEta*dEta + dPhi*dPhi);
100 m_resStrings({ {
kResPt,
"pt"}, {
kRes1OverPt,
"1overpt"}, {
kResQOverPt,
"qoverpt"}, {
kResPhi,
"phi"}, {
kResEta,
"eta"}, {
kResCh,
"charge"} }),
101 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}"} }),
104 m_verbose(ps.getUntrackedParameter<
bool>(
"verbose")),
105 m_HistFolder(ps.getUntrackedParameter<
string>(
"histFolder")),
106 m_TagPtCut(ps.getUntrackedParameter<
double>(
"tagPtCut")),
108 m_cutsVPSet(ps.getUntrackedParameter<std::vector<edm::ParameterSet>>(
"cuts")),
114 m_trigProcess(ps.getUntrackedParameter<
string>(
"trigProcess")),
116 m_trigNames(ps.getUntrackedParameter<vector<string> >(
"triggerNames")),
117 m_effVsPtBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsPtBins")),
118 m_effVsPhiBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsPhiBins")),
119 m_effVsEtaBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsEtaBins")),
120 m_effVsVtxBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsVtxBins")),
126 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] ____________ Storage initialization ____________ " << endl;
129 const auto qCut = cutsPSet.getUntrackedParameter<
int>(
"qualCut");
133 }
else if (qCut > 7) {
135 }
else if (qCut > 3) {
138 m_cuts.emplace_back(std::make_pair(cutsPSet.getUntrackedParameter<
int>(
"ptCut"), qLevel));
146 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Called beginRun." << endl;
159 vector<string>::const_iterator trigNamesIt =
m_trigNames.begin();
160 vector<string>::const_iterator trigNamesEnd =
m_trigNames.end();
162 for (; trigNamesIt!=trigNamesEnd; ++trigNamesIt) {
163 TString tNameTmp = TString(*trigNamesIt);
164 TRegexp tNamePattern = TRegexp(tNameTmp,
true);
169 if (tmpName.Contains(tNamePattern)) {
174 if (tIndex < 0 &&
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Warning: Could not find trigger " << (*trigNamesIt) << endl;
212 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Computing efficiencies" << endl;
214 vector<MuonGmtPair>::const_iterator muonGmtPairsIt =
m_MuonGmtPairs.begin();
215 vector<MuonGmtPair>::const_iterator muonGmtPairsEnd =
m_MuonGmtPairs.end();
221 for(; muonGmtPairsIt!=muonGmtPairsEnd; ++muonGmtPairsIt) {
223 if( (muonGmtPairsIt->etaRegion() !=
kEtaRegionOut) && (muonGmtPairsIt->gmtPt() > 0) ){
224 regsToFill[1] = muonGmtPairsIt->etaRegion();
227 const auto varToFill = muonGmtPairsIt->getDeltaVar(
var);
228 std::get<0>(histoKeyRes) =
var;
230 for (
const auto regToFill : regsToFill) {
231 std::get<1>(histoKeyRes) = regToFill;
235 int qualCut = qualLevel * 4;
236 if (muonGmtPairsIt->gmtQual() >= qualCut) {
237 std::get<2>(histoKeyRes) = qualLevel;
247 unsigned int cutsCounter = 0;
249 const auto gmtPtCut =
cut.first;
250 const auto qualLevel =
cut.second;
251 const bool gmtAboveCut = (muonGmtPairsIt->gmtPt() > gmtPtCut);
257 regsToFill[1] = muonGmtPairsIt->etaRegion();
264 varToFill =
static_cast<double>(nVtx);
266 varToFill = muonGmtPairsIt->getVar(
var);
272 std::get<0>(histoKeyEffDenVar) =
var;
274 for (
const auto regToFill : regsToFill) {
276 if (cutsCounter == 0) {
280 std::get<2>(histoKeyEffDenVar) = regToFill;
286 std::get<0>(histoKeyEffNumVar) =
var;
288 if (gmtAboveCut && muonGmtPairsIt->gmtQual() >= qualLevel * 4) {
293 std::get<3>(histoKeyEffNumVar) = qualLevel;
295 for (
const auto regToFill : regsToFill) {
296 std::get<2>(histoKeyEffNumVar) = regToFill;
307 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Computation finished" << endl;
312 if(
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Booking Control Plot Histos" << endl;
341 const auto gmtPtCut =
cut.first;
342 const auto qualLevel =
cut.second;
357 const int gmtPtCut =
cut.first;
364 const auto gmtPtCut =
cut.first;
365 const auto qualLevel =
cut.second;
376 if(
m_verbose)
cout <<
"[L1TMuonOffline:] Booking Resolution Plot Histos" << endl;
395 unsigned int nVtx = 0;
398 for (
const auto vertexIt : *vertex) {
399 if (vertexIt.isValid() && !vertexIt.isFake()) {
413 bool hasPrimaryVertex =
false;
416 vector<Vertex>::const_iterator vertexIt = vertex->begin();
417 vector<Vertex>::const_iterator vertexEnd = vertex->end();
419 for (;vertexIt!=vertexEnd;++vertexIt) {
420 if (vertexIt->isValid() && !vertexIt->isFake()) {
421 posVtx = vertexIt->position();
422 errVtx = vertexIt->error();
423 hasPrimaryVertex =
true;
429 if ( !hasPrimaryVertex ) {
433 errVtx(2,2) = beamSpot->
sigmaZ();
442 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Getting tight muons" << endl;
444 MuonCollection::const_iterator muonIt = muons->begin();
445 MuonCollection::const_iterator muonEnd = muons->end();
447 for(; muonIt!=muonEnd; ++muonIt) {
459 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] getting probe muons" << endl;
461 std::vector<const reco::Muon*> tagMuonsInHist;
463 tagMuonsInHist.clear();
465 vector<const reco::Muon*>::const_iterator probeCandIt =
m_TightMuons.begin();
466 vector<const reco::Muon*>::const_iterator tightMuonsEnd =
m_TightMuons.end();
468 for (; probeCandIt!=tightMuonsEnd; ++probeCandIt) {
469 bool isProbe =
false;
470 vector<const reco::Muon*>::const_iterator tagCandIt =
m_TightMuons.begin();
473 for (; tagCandIt!=tightMuonsEnd; ++tagCandIt) {
474 bool tagMuonAlreadyInHist =
false;
475 bool tagHasTrig =
false;
476 float eta = (*tagCandIt)->eta();
477 float phi = (*tagCandIt)->phi();
478 float pt = (*tagCandIt)->pt();
479 float dEta = eta - (*probeCandIt)->eta();
480 float dPhi = phi - (*probeCandIt)->phi();
481 deltar =
sqrt(dEta*dEta + dPhi*dPhi);
483 if ( (*tagCandIt) == (*probeCandIt) || deltar<
m_minTagProbeDR )
continue;
484 auto matchHltDeltaR =
matchHlt(trigEvent,(*tagCandIt));
485 tagHasTrig = (matchHltDeltaR < m_maxHltMuonDR) && (pt >
m_TagPtCut);
486 isProbe |= tagHasTrig;
489 for (vector<const reco::Muon*>::const_iterator tagMuonsInHistIt = tagMuonsInHist.begin(); tagMuonsInHistIt!=tagMuonsInHist.end(); ++tagMuonsInHistIt) {
490 if ( (*tagCandIt) == (*tagMuonsInHistIt) ) {
491 tagMuonAlreadyInHist =
true;
495 if (tagMuonAlreadyInHist ==
false) tagMuonsInHist.push_back((*tagCandIt));
497 if (tagMuonAlreadyInHist ==
false) {
515 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Getting muon GMT pairs" << endl;
517 vector<const reco::Muon*>::const_iterator probeMuIt =
m_ProbeMuons.begin();
518 vector<const reco::Muon*>::const_iterator probeMuEnd =
m_ProbeMuons.end();
523 for (; probeMuIt!=probeMuEnd; ++probeMuIt) {
531 gmtIt = gmtCands->
begin(0);
533 for(; gmtIt!=gmtEnd; ++gmtIt) {
537 pairBestCand = pairTmpCand;
549 double matchDeltaR = 9999;
553 vector<int>::const_iterator trigIndexIt =
m_trigIndices.begin();
554 vector<int>::const_iterator trigIndexEnd =
m_trigIndices.end();
556 for(; trigIndexIt!=trigIndexEnd; ++trigIndexIt) {
561 if (hltFilterIndex < triggerEvent->sizeFilters()) {
563 const Vids triggerVids(triggerEvent->
filterIds(hltFilterIndex));
564 const unsigned nTriggers = triggerVids.size();
565 for (
size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
566 const TriggerObject trigObject = trigObjs[triggerKeys[iTrig]];
567 double dRtmp =
deltaR((*mu),trigObject);
568 if (dRtmp < matchDeltaR) matchDeltaR = dRtmp;
596 if (res ==
kResPt)
return {50, -2., 2.};
599 if (res ==
kResPhi)
return {96, -0.2, 0.2};
600 if (res ==
kResEta)
return {100, -0.1, 0.1};
601 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
LuminosityBlockID id() const
constexpr double deltaPhi(double phi1, double phi2)
const_iterator end(int bx) const
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
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 beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
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
#define DEFINE_FWK_MODULE(type)
const std::vector< EtaRegion > m_etaRegions
const Keys & filterKeys(trigger::size_type index) const
Geom::Phi< T > phi() const
virtual void dqmEndLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
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
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
double deltaR(double eta1, double eta2, double phi1, double phi2)
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
LuminosityBlockNumber_t luminosityBlock() const
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 run, to initialize geometry, magnetic field and propagators...
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< Muon >::const_iterator const_iterator
void getTightMuons(edm::Handle< reco::MuonCollection > &muons, const reco::Vertex &vertex)