26 m_muon(muon), m_regMu(regMu), m_eta(999.), m_phi_bar(999.), m_phi_end(999.)
57 return sqrt(dEta*dEta + dPhi*dPhi);
141 GlobalPoint innerPoint(track->innerPosition().x(), track->innerPosition().y(), track->innerPosition().z());
142 GlobalVector innerVec (track->innerMomentum().x(), track->innerMomentum().y(), track->innerMomentum().z());
155 m_resStrings({ {
kResPt,
"pt"}, {
kRes1OverPt,
"1overpt"}, {
kResQOverPt,
"qoverpt"}, {
kResPhi,
"phi"}, {
kResEta,
"eta"}, {
kResCh,
"charge"} }),
156 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}"} }),
159 m_verbose(ps.getUntrackedParameter<
bool>(
"verbose")),
160 m_HistFolder(ps.getUntrackedParameter<
string>(
"histFolder")),
161 m_TagPtCut(ps.getUntrackedParameter<
double>(
"tagPtCut")),
163 m_cutsVPSet(ps.getUntrackedParameter<std::vector<edm::ParameterSet>>(
"cuts")),
169 m_trigProcess(ps.getUntrackedParameter<
string>(
"trigProcess")),
171 m_trigNames(ps.getUntrackedParameter<vector<string> >(
"triggerNames")),
172 m_effVsPtBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsPtBins")),
173 m_effVsPhiBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsPhiBins")),
174 m_effVsEtaBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsEtaBins")),
175 m_effVsVtxBins(ps.getUntrackedParameter<std::vector<double>>(
"efficiencyVsVtxBins")),
181 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] ____________ Storage initialization ____________ " << endl;
184 const auto qCut = cutsPSet.getUntrackedParameter<
int>(
"qualCut");
188 }
else if (qCut > 7) {
190 }
else if (qCut > 3) {
193 m_cuts.emplace_back(std::make_pair(cutsPSet.getUntrackedParameter<
int>(
"ptCut"), qLevel));
201 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Called beginRun." << endl;
213 vector<string>::const_iterator trigNamesIt =
m_trigNames.begin();
214 vector<string>::const_iterator trigNamesEnd =
m_trigNames.end();
216 for (; trigNamesIt!=trigNamesEnd; ++trigNamesIt) {
217 TString tNameTmp = TString(*trigNamesIt);
218 TRegexp tNamePattern = TRegexp(tNameTmp,
true);
223 if (tmpName.Contains(tNamePattern)) {
228 if (tIndex < 0 &&
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Warning: Could not find trigger " << (*trigNamesIt) << endl;
270 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Computing efficiencies" << endl;
272 vector<MuonGmtPair>::const_iterator muonGmtPairsIt =
m_MuonGmtPairs.begin();
273 vector<MuonGmtPair>::const_iterator muonGmtPairsEnd =
m_MuonGmtPairs.end();
279 for(; muonGmtPairsIt!=muonGmtPairsEnd; ++muonGmtPairsIt) {
281 if( (muonGmtPairsIt->etaRegion() !=
kEtaRegionOut) && (muonGmtPairsIt->gmtPt() > 0) ){
282 regsToFill[1] = muonGmtPairsIt->etaRegion();
285 const auto varToFill = muonGmtPairsIt->getDeltaVar(
var);
286 std::get<0>(histoKeyRes) =
var;
288 for (
const auto regToFill : regsToFill) {
289 std::get<1>(histoKeyRes) = regToFill;
293 int qualCut = qualLevel * 4;
294 if (muonGmtPairsIt->gmtQual() >= qualCut) {
295 std::get<2>(histoKeyRes) = qualLevel;
305 unsigned int cutsCounter = 0;
307 const auto gmtPtCut =
cut.first;
308 const auto qualLevel =
cut.second;
309 const bool gmtAboveCut = (muonGmtPairsIt->gmtPt() > gmtPtCut);
315 regsToFill[1] = muonGmtPairsIt->etaRegion();
322 varToFill =
static_cast<double>(nVtx);
324 varToFill = muonGmtPairsIt->getVar(
var);
330 std::get<0>(histoKeyEffDenVar) =
var;
332 for (
const auto regToFill : regsToFill) {
334 if (cutsCounter == 0) {
338 std::get<2>(histoKeyEffDenVar) = regToFill;
344 std::get<0>(histoKeyEffNumVar) =
var;
346 if (gmtAboveCut && muonGmtPairsIt->gmtQual() >= qualLevel * 4) {
351 std::get<3>(histoKeyEffNumVar) = qualLevel;
353 for (
const auto regToFill : regsToFill) {
354 std::get<2>(histoKeyEffNumVar) = regToFill;
365 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Computation finished" << endl;
370 if(
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Booking Control Plot Histos" << endl;
399 const auto gmtPtCut =
cut.first;
400 const auto qualLevel =
cut.second;
415 const int gmtPtCut =
cut.first;
422 const auto gmtPtCut =
cut.first;
423 const auto qualLevel =
cut.second;
434 if(
m_verbose)
cout <<
"[L1TMuonOffline:] Booking Resolution Plot Histos" << endl;
453 unsigned int nVtx = 0;
456 for (
const auto vertexIt : *vertex) {
457 if (vertexIt.isValid() && !vertexIt.isFake()) {
471 bool hasPrimaryVertex =
false;
474 vector<Vertex>::const_iterator vertexIt = vertex->begin();
475 vector<Vertex>::const_iterator vertexEnd = vertex->end();
477 for (;vertexIt!=vertexEnd;++vertexIt) {
478 if (vertexIt->isValid() && !vertexIt->isFake()) {
479 posVtx = vertexIt->position();
480 errVtx = vertexIt->error();
481 hasPrimaryVertex =
true;
487 if ( !hasPrimaryVertex ) {
491 errVtx(2,2) = beamSpot->
sigmaZ();
500 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Getting tight muons" << endl;
502 MuonCollection::const_iterator muonIt = muons->begin();
503 MuonCollection::const_iterator muonEnd = muons->end();
505 for(; muonIt!=muonEnd; ++muonIt) {
517 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] getting probe muons" << endl;
519 std::vector<const reco::Muon*> tagMuonsInHist;
521 tagMuonsInHist.clear();
523 vector<const reco::Muon*>::const_iterator probeCandIt =
m_TightMuons.begin();
524 vector<const reco::Muon*>::const_iterator tightMuonsEnd =
m_TightMuons.end();
526 for (; probeCandIt!=tightMuonsEnd; ++probeCandIt) {
527 bool isProbe =
false;
528 vector<const reco::Muon*>::const_iterator tagCandIt =
m_TightMuons.begin();
531 for (; tagCandIt!=tightMuonsEnd; ++tagCandIt) {
532 bool tagMuonAlreadyInHist =
false;
533 bool tagHasTrig =
false;
534 float eta = (*tagCandIt)->eta();
535 float phi = (*tagCandIt)->phi();
536 float pt = (*tagCandIt)->pt();
537 float dEta = eta - (*probeCandIt)->eta();
538 float dPhi = phi - (*probeCandIt)->phi();
539 deltar =
sqrt(dEta*dEta + dPhi*dPhi);
541 if ( (*tagCandIt) == (*probeCandIt) || deltar<
m_minTagProbeDR )
continue;
542 auto matchHltDeltaR =
matchHlt(trigEvent,(*tagCandIt));
543 tagHasTrig = (matchHltDeltaR < m_maxHltMuonDR) && (pt >
m_TagPtCut);
544 isProbe |= tagHasTrig;
547 for (vector<const reco::Muon*>::const_iterator tagMuonsInHistIt = tagMuonsInHist.begin(); tagMuonsInHistIt!=tagMuonsInHist.end(); ++tagMuonsInHistIt) {
548 if ( (*tagCandIt) == (*tagMuonsInHistIt) ) {
549 tagMuonAlreadyInHist =
true;
553 if (tagMuonAlreadyInHist ==
false) tagMuonsInHist.push_back((*tagCandIt));
555 if (tagMuonAlreadyInHist ==
false) {
573 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Getting muon GMT pairs" << endl;
575 vector<const reco::Muon*>::const_iterator probeMuIt =
m_ProbeMuons.begin();
576 vector<const reco::Muon*>::const_iterator probeMuEnd =
m_ProbeMuons.end();
581 for (; probeMuIt!=probeMuEnd; ++probeMuIt) {
588 gmtIt = gmtCands->
begin(0);
590 for(; gmtIt!=gmtEnd; ++gmtIt) {
595 pairBestCand = pairTmpCand;
607 double matchDeltaR = 9999;
611 vector<int>::const_iterator trigIndexIt =
m_trigIndices.begin();
612 vector<int>::const_iterator trigIndexEnd =
m_trigIndices.end();
614 for(; trigIndexIt!=trigIndexEnd; ++trigIndexIt) {
619 if (hltFilterIndex < triggerEvent->sizeFilters()) {
621 const Vids triggerVids(triggerEvent->
filterIds(hltFilterIndex));
622 const unsigned nTriggers = triggerVids.size();
623 for (
size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
624 const TriggerObject trigObject = trigObjs[triggerKeys[iTrig]];
625 double dRtmp =
deltaR((*mu),trigObject);
626 if (dRtmp < matchDeltaR) matchDeltaR = dRtmp;
654 if (res ==
kResPt)
return {50, -2., 2.};
657 if (res ==
kResPhi)
return {96, -0.2, 0.2};
658 if (res ==
kResEta)
return {100, -0.1, 0.1};
659 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
edm::ESHandle< Propagator > m_propagatorOpposite
edm::EDGetTokenT< reco::BeamSpot > m_BsInputTag
MuonGmtPair(const reco::Muon *muon, const l1t::Muon *regMu, bool useAtVtxCoord)
double eta() const final
momentum pseudorapidity
edm::ESHandle< Propagator > m_propagatorOpposite
edm::ESHandle< Propagator > m_propagatorAlong
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 &)
edm::ESHandle< MagneticField > m_BField
std::map< QualLevel, std::string > m_qualStrings
double matchHlt(edm::Handle< trigger::TriggerEvent > &triggerEvent, const reco::Muon *mu)
std::string m_trigProcess
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, Bounds *bounds=0)
const l1t::Muon * m_regMu
const Vids & filterIds(trigger::size_type index) const
std::vector< edm::ParameterSet > m_cutsVPSet
std::map< EffType, std::string > m_effLabelStrings
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
static PlanePointer build(Args &&...args)
TrajectoryStateOnSurface cylExtrapTrkSam(reco::TrackRef track, double rho)
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
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
edm::ESHandle< MagneticField > m_BField
edm::ESHandle< Propagator > m_propagatorAlong
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)
FreeTrajectoryState freeTrajStateMuon(reco::TrackRef track)
void getMuonGmtPairs(edm::Handle< l1t::MuonBxCollection > &gmtCands)
std::map< ResType, std::string > m_resStrings
void setCurrentFolder(const std::string &fullpath)
MonitorElement * book2D(Args &&...args)
void propagate(edm::ESHandle< MagneticField > bField, edm::ESHandle< Propagator > propagatorAlong, edm::ESHandle< Propagator > propagatorOpposite)
std::vector< size_type > Keys
TrajectoryStateOnSurface surfExtrapTrkSam(reco::TrackRef track, double z)
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)
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
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
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
L1TMuonDQMOffline::EtaRegion etaRegion() const
const_iterator begin(int bx) const
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)