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}"}, {
kRes1OverPt,
"1/p_{T}^{L1} - 1/p_{T}^{reco}"}, {
kResQOverPt,
"q^{L1}/p_{T}^{L1} - q^{reco}/p_{T}^{reco}"}, {
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;
398 const auto gmtPtCut =
cut.first;
399 const auto qualLevel =
cut.second;
414 const int gmtPtCut =
cut.first;
421 const auto gmtPtCut =
cut.first;
422 const auto qualLevel =
cut.second;
433 if(
m_verbose)
cout <<
"[L1TMuonOffline:] Booking Resolution Plot Histos" << endl;
452 unsigned int nVtx = 0;
455 for (
const auto vertexIt : *vertex) {
456 if (vertexIt.isValid() && !vertexIt.isFake()) {
470 bool hasPrimaryVertex =
false;
473 vector<Vertex>::const_iterator vertexIt = vertex->begin();
474 vector<Vertex>::const_iterator vertexEnd = vertex->end();
476 for (;vertexIt!=vertexEnd;++vertexIt) {
477 if (vertexIt->isValid() && !vertexIt->isFake()) {
478 posVtx = vertexIt->position();
479 errVtx = vertexIt->error();
480 hasPrimaryVertex =
true;
486 if ( !hasPrimaryVertex ) {
490 errVtx(2,2) = beamSpot->
sigmaZ();
499 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Getting tight muons" << endl;
501 MuonCollection::const_iterator muonIt = muons->begin();
502 MuonCollection::const_iterator muonEnd = muons->end();
504 for(; muonIt!=muonEnd; ++muonIt) {
516 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] getting probe muons" << endl;
518 std::vector<const reco::Muon*> tagMuonsInHist;
520 tagMuonsInHist.clear();
522 vector<const reco::Muon*>::const_iterator probeCandIt =
m_TightMuons.begin();
523 vector<const reco::Muon*>::const_iterator tightMuonsEnd =
m_TightMuons.end();
525 for (; probeCandIt!=tightMuonsEnd; ++probeCandIt) {
526 bool isProbe =
false;
527 vector<const reco::Muon*>::const_iterator tagCandIt =
m_TightMuons.begin();
530 for (; tagCandIt!=tightMuonsEnd; ++tagCandIt) {
531 bool tagMuonAlreadyInHist =
false;
532 bool tagHasTrig =
false;
533 float eta = (*tagCandIt)->eta();
534 float phi = (*tagCandIt)->phi();
535 float pt = (*tagCandIt)->pt();
536 float dEta = eta - (*probeCandIt)->eta();
537 float dPhi = phi - (*probeCandIt)->phi();
538 deltar =
sqrt(dEta*dEta + dPhi*dPhi);
540 if ( (*tagCandIt) == (*probeCandIt) || deltar<
m_minTagProbeDR )
continue;
542 isProbe |= tagHasTrig;
545 for (vector<const reco::Muon*>::const_iterator tagMuonsInHistIt = tagMuonsInHist.begin(); tagMuonsInHistIt!=tagMuonsInHist.end(); ++tagMuonsInHistIt) {
546 if ( (*tagCandIt) == (*tagMuonsInHistIt) ) {
547 tagMuonAlreadyInHist =
true;
551 if (tagMuonAlreadyInHist ==
false) tagMuonsInHist.push_back((*tagCandIt));
553 if (tagMuonAlreadyInHist ==
false) {
570 if (
m_verbose)
cout <<
"[L1TMuonDQMOffline:] Getting muon GMT pairs" << endl;
572 vector<const reco::Muon*>::const_iterator probeMuIt =
m_ProbeMuons.begin();
573 vector<const reco::Muon*>::const_iterator probeMuEnd =
m_ProbeMuons.end();
578 for (; probeMuIt!=probeMuEnd; ++probeMuIt) {
585 gmtIt = gmtCands->
begin(0);
587 for(; gmtIt!=gmtEnd; ++gmtIt) {
592 pairBestCand = pairTmpCand;
604 double matchDeltaR = 9999;
608 vector<int>::const_iterator trigIndexIt =
m_trigIndices.begin();
609 vector<int>::const_iterator trigIndexEnd =
m_trigIndices.end();
611 for(; trigIndexIt!=trigIndexEnd; ++trigIndexIt) {
616 if (hltFilterIndex < triggerEvent->sizeFilters()) {
618 const Vids triggerVids(triggerEvent->
filterIds(hltFilterIndex));
619 const unsigned nTriggers = triggerVids.size();
620 for (
size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
621 const TriggerObject trigObject = trigObjs[triggerKeys[iTrig]];
622 double dRtmp =
deltaR((*mu),trigObject);
623 if (dRtmp < matchDeltaR) matchDeltaR = dRtmp;
651 if (res ==
kResPt)
return {100, -50., 50.};
654 if (res ==
kResPhi)
return {96, -0.2, 0.2};
655 if (res ==
kResEta)
return {100, -0.1, 0.1};
656 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
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
bool matchHlt(edm::Handle< trigger::TriggerEvent > &triggerEvent, const reco::Muon *mu)
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
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)