29 m_muon = muonGmtPair.
m_muon;
32 m_eta = muonGmtPair.
m_eta;
38 float dEta = m_regMu ? (m_regMu->eta() -
eta()) : 999.;
39 float dPhi = m_regMu ? (m_regMu->phi() - phi()) : 999.;
40 return sqrt(dEta*dEta + dPhi*dPhi);
49 TrackRef standaloneMuon = m_muon->outerTrack();
51 trajectory = cylExtrapTrkSam(standaloneMuon, 500);
56 trajectory = surfExtrapTrkSam(standaloneMuon, 790);
61 trajectory = surfExtrapTrkSam(standaloneMuon, -790);
76 recoProp = m_propagatorAlong->propagate(recoStart, *myCylinder);
78 recoProp = m_propagatorOpposite->propagate(recoStart, *myCylinder);
91 recoProp = m_propagatorAlong->propagate(recoStart, *myPlane);
93 recoProp = m_propagatorOpposite->propagate(recoStart, *myPlane);
100 GlobalPoint innerPoint(track->innerPosition().x(), track->innerPosition().y(), track->innerPosition().z());
101 GlobalVector innerVec (track->innerMomentum().x(), track->innerMomentum().y(), track->innerMomentum().z());
109 if (m_verbose)
cout <<
"[L1TEfficiencyMuons_Offline:] ____________ Storage initialization ____________ " << endl;
124 m_MaxGmtMuonDR = 0.7;
125 m_MaxHltMuonDR = 0.1;
134 if (m_verbose)
cout <<
"[L1TEfficiencyMuons_Offline:] Called beginRun." << endl;
136 m_hltConfig.init(run,iSetup,m_trigProcess,changed);
142 bookControlHistos(ibooker);
143 vector<int>::const_iterator gmtPtCutsIt = m_GmtPtCuts.begin();
144 vector<int>::const_iterator gmtPtCutsEnd = m_GmtPtCuts.end();
146 for (; gmtPtCutsIt!=gmtPtCutsEnd; ++ gmtPtCutsIt) {
147 bookEfficiencyHistos(ibooker, (*gmtPtCutsIt));
150 vector<string>::const_iterator trigNamesIt = m_trigNames.begin();
151 vector<string>::const_iterator trigNamesEnd = m_trigNames.end();
153 for (; trigNamesIt!=trigNamesEnd; ++trigNamesIt) {
154 TString tNameTmp = TString(*trigNamesIt);
155 TRegexp tNamePattern = TRegexp(tNameTmp,
true);
158 for (
unsigned ipath = 0; ipath < m_hltConfig.size(); ++ipath) {
159 TString tmpName = TString(m_hltConfig.triggerName(ipath));
160 if (tmpName.Contains(tNamePattern)) {
162 m_trigIndices.push_back(tIndex);
165 if (tIndex < 0 && m_verbose)
cout <<
"[L1TEfficiencyMuons_Offline:] Warning: Could not find trigger " << (*trigNamesIt) << endl;
171 if(m_verbose)
cout <<
"[L1TEfficiencyMuons_Offline:] Called beginLuminosityBlock at LS=" << lumiBlock.
id().
luminosityBlock() << endl;
176 if(m_verbose)
cout <<
"[L1TEfficiencyMuons_Offline:] Called endLuminosityBlock at LS=" << lumiBlock.
id().
luminosityBlock() << endl;
195 iEvent.
getByToken(m_trigProcess_token,trigResults);
206 getTightMuons(muons,primaryVertex);
207 getProbeMuons(trigResults,trigEvent);
208 getMuonGmtPairs(gmtCands);
213 vector<l1t::Muon> gmtContainer;
215 for (
auto mu = gmtCands->
begin(0);
mu != gmtCands->
end(0); ++
mu) {
216 gmtContainer.push_back(*
mu);
222 if (m_verbose)
cout <<
"[L1TEfficiencyMuons_Offline:] Computing efficiencies" << endl;
224 vector<MuonGmtPair>::const_iterator muonGmtPairsIt = m_MuonGmtPairs.begin();
225 vector<MuonGmtPair>::const_iterator muonGmtPairsEnd = m_MuonGmtPairs.end();
227 for(; muonGmtPairsIt!=muonGmtPairsEnd; ++muonGmtPairsIt) {
228 float eta = muonGmtPairsIt->eta();
229 float phi = muonGmtPairsIt->phi();
230 float pt = muonGmtPairsIt->pt();
232 float gmtPt = muonGmtPairsIt->gmtPt();
233 int qual = muonGmtPairsIt->gmtQual();
235 vector<int>::const_iterator gmtPtCutsIt = m_GmtPtCuts.begin();
236 vector<int>::const_iterator gmtPtCutsEnd = m_GmtPtCuts.end();
238 for (; gmtPtCutsIt!=gmtPtCutsEnd; ++ gmtPtCutsIt) {
239 int gmtPtCut = (*gmtPtCutsIt);
240 bool gmtAboveCut = (gmtPt > gmtPtCut);
242 stringstream ptCutToTag; ptCutToTag << gmtPtCut;
243 string ptTag = ptCutToTag.str();
245 if (fabs(eta) < m_MaxMuonEta) {
246 m_EfficiencyHistos[gmtPtCut][
"EffvsPt" + ptTag +
"Den"]->Fill(pt);
247 m_EfficiencyHistos[gmtPtCut][
"EffvsPt_OPEN_" + ptTag +
"Den"]->Fill(pt);
248 m_EfficiencyHistos[gmtPtCut][
"EffvsPt_DOUBLE_" + ptTag +
"Den"]->Fill(pt);
249 m_EfficiencyHistos[gmtPtCut][
"EffvsPt_SINGLE_" + ptTag +
"Den"]->Fill(pt);
252 m_EfficiencyHistos[gmtPtCut][
"EffvsPt" + ptTag +
"Num"]->Fill(pt);
254 if (qual >= 4) m_EfficiencyHistos[gmtPtCut][
"EffvsPt_OPEN_" + ptTag +
"Num"]->Fill(pt);
255 if (qual >= 8) m_EfficiencyHistos[gmtPtCut][
"EffvsPt_DOUBLE_" + ptTag +
"Num"]->Fill(pt);
256 if (qual >= 12) m_EfficiencyHistos[gmtPtCut][
"EffvsPt_SINGLE_" + ptTag +
"Num"]->Fill(pt);
260 if (pt > 1.25*gmtPtCut) {
262 m_EfficiencyHistos[gmtPtCut][
"EffvsPhi" + ptTag +
"Den"]->Fill(phi);
263 m_EfficiencyHistos[gmtPtCut][
"EffvsEta" + ptTag +
"Den"]->Fill(eta);
265 m_EfficiencyHistos[gmtPtCut][
"EffvsPhi_OPEN_" + ptTag +
"Den"]->Fill(phi);
266 m_EfficiencyHistos[gmtPtCut][
"EffvsEta_OPEN_" + ptTag +
"Den"]->Fill(eta);
268 m_EfficiencyHistos[gmtPtCut][
"EffvsPhi_DOUBLE_" + ptTag +
"Den"]->Fill(phi);
269 m_EfficiencyHistos[gmtPtCut][
"EffvsEta_DOUBLE_" + ptTag +
"Den"]->Fill(eta);
271 m_EfficiencyHistos[gmtPtCut][
"EffvsPhi_SINGLE_" + ptTag +
"Den"]->Fill(phi);
272 m_EfficiencyHistos[gmtPtCut][
"EffvsEta_SINGLE_" + ptTag +
"Den"]->Fill(eta);
275 m_EfficiencyHistos[gmtPtCut][
"EffvsPhi" + ptTag +
"Num"]->Fill(phi);
276 m_EfficiencyHistos[gmtPtCut][
"EffvsEta" + ptTag +
"Num"]->Fill(eta);
279 m_EfficiencyHistos[gmtPtCut][
"EffvsPhi_OPEN_" + ptTag +
"Num"]->Fill(phi);
280 m_EfficiencyHistos[gmtPtCut][
"EffvsEta_OPEN_" + ptTag +
"Num"]->Fill(eta);
283 m_EfficiencyHistos[gmtPtCut][
"EffvsPhi_DOUBLE_" + ptTag +
"Num"]->Fill(phi);
284 m_EfficiencyHistos[gmtPtCut][
"EffvsEta_DOUBLE_" + ptTag +
"Num"]->Fill(eta);
287 m_EfficiencyHistos[gmtPtCut][
"EffvsPhi_SINGLE_" + ptTag +
"Num"]->Fill(phi);
288 m_EfficiencyHistos[gmtPtCut][
"EffvsEta_SINGLE_" + ptTag +
"Num"]->Fill(eta);
295 if (m_verbose)
cout <<
"[L1TEfficiencyMuons_Offline:] Computation finished" << endl;
300 if(m_verbose)
cout <<
"[L1TEfficiencyMuons_Offline:] Booking Control Plot Histos" << endl;
304 string name =
"MuonGmtDeltaR";
305 m_ControlHistos[
name] = ibooker.
book1D(name.c_str(),name.c_str(),25.,0.,2.5);
307 name =
"NTightVsAll";
308 m_ControlHistos[
name] = ibooker.
book2D(name.c_str(),name.c_str(),5,-0.5,4.5,5,-0.5,4.5);
310 name =
"NProbesVsTight";
311 m_ControlHistos[
name] = ibooker.
book2D(name.c_str(),name.c_str(),5,-0.5,4.5,5,-0.5,4.5);
314 string name1 =
"TagMuonEta_Histo";
315 m_EfficiencyHistos[0][name1] = ibooker.
book1D(name1.c_str(),name1.c_str(),50,-2.5,2.5);
316 string name2 =
"TagMuonPhi_Histo";
318 string name3 =
"TagMuonPt_Histo";
319 m_EfficiencyHistos[0][name3] = ibooker.
book1D(name3.c_str(),name3.c_str(),50,0.,100.);
321 name1 =
"ProbeMuonEta_Histo";
322 m_EfficiencyHistos[0][name1] = ibooker.
book1D(name1.c_str(),name1.c_str(),50,-2.5,2.5);
323 name2 =
"ProbeMuonPhi_Histo";
325 name3 =
"ProbeMuonPt_Histo";
326 m_EfficiencyHistos[0][name3] = ibooker.
book1D(name3.c_str(),name3.c_str(),50,0.,100.);
331 if(m_verbose)
cout <<
"[L1TEfficiencyMuons_Offline:] Booking Efficiency Plot Histos for pt cut = " << ptCut << endl;
333 stringstream ptCutToTag; ptCutToTag <<
ptCut;
334 string ptTag = ptCutToTag.str();
337 float xbins[33] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 55, 60, 65, 70, 80, 90, 100};
339 string name1 =
"EffvsPt" + ptTag +
"Den";
340 m_EfficiencyHistos[
ptCut][name1] = ibooker.
book1D(name1.c_str(),name1.c_str(),32,
xbins);
341 string name2 =
"EffvsPt" + ptTag +
"Num";
342 m_EfficiencyHistos[
ptCut][name2] = ibooker.
book1D(name2.c_str(),name2.c_str(),32,
xbins);
344 name1 =
"EffvsPt_OPEN_" + ptTag +
"Den";
345 m_EfficiencyHistos[
ptCut][name1] = ibooker.
book1D(name1.c_str(),name1.c_str(),32,
xbins);
346 name2 =
"EffvsPt_OPEN_" + ptTag +
"Num";
347 m_EfficiencyHistos[
ptCut][name2] = ibooker.
book1D(name2.c_str(),name2.c_str(),32,
xbins);
349 name1 =
"EffvsPt_DOUBLE_" + ptTag +
"Den";
350 m_EfficiencyHistos[
ptCut][name1] = ibooker.
book1D(name1.c_str(),name1.c_str(),32,
xbins);
351 name2 =
"EffvsPt_DOUBLE_" + ptTag +
"Num";
352 m_EfficiencyHistos[
ptCut][name2] = ibooker.
book1D(name2.c_str(),name2.c_str(),32,
xbins);
354 name1 =
"EffvsPt_SINGLE_" + ptTag +
"Den";
355 m_EfficiencyHistos[
ptCut][name1] = ibooker.
book1D(name1.c_str(),name1.c_str(),32,
xbins);
356 name2 =
"EffvsPt_SINGLE_" + ptTag +
"Num";
357 m_EfficiencyHistos[
ptCut][name2] = ibooker.
book1D(name2.c_str(),name2.c_str(),32,
xbins);
361 name1 =
"EffvsPhi" + ptTag +
"Den";
363 name2 =
"EffvsPhi" + ptTag +
"Num";
366 name1 =
"EffvsEta" + ptTag +
"Den";
367 m_EfficiencyHistos[
ptCut][name1] = ibooker.
book1D(name1.c_str(),name1.c_str(),50,-2.5,2.5);
368 name2 =
"EffvsEta" + ptTag +
"Num";
369 m_EfficiencyHistos[
ptCut][name2] = ibooker.
book1D(name2.c_str(),name2.c_str(),50,-2.5,2.5);
373 name1 =
"EffvsPhi_OPEN_" + ptTag +
"Den";
375 name2 =
"EffvsPhi_OPEN_" + ptTag +
"Num";
378 name1 =
"EffvsEta_OPEN_" + ptTag +
"Den";
379 m_EfficiencyHistos[
ptCut][name1] = ibooker.
book1D(name1.c_str(),name1.c_str(),50,-2.5,2.5);
380 name2 =
"EffvsEta_OPEN_" + ptTag +
"Num";
381 m_EfficiencyHistos[
ptCut][name2] = ibooker.
book1D(name2.c_str(),name2.c_str(),50,-2.5,2.5);
385 name1 =
"EffvsPhi_DOUBLE_" + ptTag +
"Den";
387 name2 =
"EffvsPhi_DOUBLE_" + ptTag +
"Num";
390 name1 =
"EffvsEta_DOUBLE_" + ptTag +
"Den";
391 m_EfficiencyHistos[
ptCut][name1] = ibooker.
book1D(name1.c_str(),name1.c_str(),50,-2.5,2.5);
392 name2 =
"EffvsEta_DOUBLE_" + ptTag +
"Num";
393 m_EfficiencyHistos[
ptCut][name2] = ibooker.
book1D(name2.c_str(),name2.c_str(),50,-2.5,2.5);
397 name1 =
"EffvsPhi_SINGLE_" + ptTag +
"Den";
399 name2 =
"EffvsPhi_SINGLE_" + ptTag +
"Num";
403 name1 =
"EffvsEta_SINGLE_" + ptTag +
"Den";
404 m_EfficiencyHistos[
ptCut][name1] = ibooker.
book1D(name1.c_str(),name1.c_str(),50,-2.5,2.5);
405 name2 =
"EffvsEta_SINGLE_" + ptTag +
"Num";
406 m_EfficiencyHistos[
ptCut][name2] = ibooker.
book1D(name2.c_str(),name2.c_str(),50,-2.5,2.5);
415 bool hasPrimaryVertex =
false;
418 vector<Vertex>::const_iterator vertexIt = vertex->begin();
419 vector<Vertex>::const_iterator vertexEnd = vertex->end();
421 for (;vertexIt!=vertexEnd;++vertexIt) {
422 if (vertexIt->isValid() && !vertexIt->isFake()) {
423 posVtx = vertexIt->position();
424 errVtx = vertexIt->error();
425 hasPrimaryVertex =
true;
431 if ( !hasPrimaryVertex ) {
435 errVtx(2,2) = beamSpot->
sigmaZ();
444 if (m_verbose)
cout <<
"[L1TEfficiencyMuons_Offline:] Getting tight muons" << endl;
445 m_TightMuons.clear();
446 MuonCollection::const_iterator muonIt = muons->begin();
447 MuonCollection::const_iterator muonEnd = muons->end();
449 for(; muonIt!=muonEnd; ++muonIt) {
451 m_TightMuons.push_back(&(*muonIt));
454 m_ControlHistos[
"NTightVsAll"]->Fill(muons->size(),m_TightMuons.size());
461 if (m_verbose)
cout <<
"[L1TEfficiencyMuons_Offline:] getting probe muons" << endl;
462 m_ProbeMuons.clear();
464 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 tagHasTrig =
false;
470 vector<const reco::Muon*>::const_iterator tagCandIt = m_TightMuons.begin();
473 for (; tagCandIt!=tightMuonsEnd; ++tagCandIt) {
474 float eta = (*tagCandIt)->eta();
475 float phi = (*tagCandIt)->phi();
476 float pt = (*tagCandIt)->pt();
477 float dEta = eta - (*probeCandIt)->eta();
478 float dPhi = phi - (*probeCandIt)->phi();
480 deltar =
sqrt(dEta*dEta + dPhi*dPhi);
482 if ( (*tagCandIt) == (*probeCandIt) || (deltar<0.7) )
continue;
483 tagHasTrig |= matchHlt(trigEvent,(*tagCandIt));
485 m_EfficiencyHistos[0][
"TagMuonEta_Histo"]->Fill(eta);
486 m_EfficiencyHistos[0][
"TagMuonPhi_Histo"]->Fill(phi);
487 m_EfficiencyHistos[0][
"TagMuonPt_Histo"]->Fill(pt);
490 if (tagHasTrig) m_ProbeMuons.push_back((*probeCandIt));
492 m_ControlHistos[
"NProbesVsTight"]->Fill(m_TightMuons.size(),m_ProbeMuons.size());
498 m_MuonGmtPairs.clear();
499 if (m_verbose)
cout <<
"[L1TEfficiencyMuons_Offline:] Getting muon GMT pairs" << endl;
501 vector<const reco::Muon*>::const_iterator probeMuIt = m_ProbeMuons.begin();
502 vector<const reco::Muon*>::const_iterator probeMuEnd = m_ProbeMuons.end();
503 vector<l1t::Muon> gmtContainer;
505 for (
auto mu = gmtCands->
begin(0);
mu != gmtCands->
end(0); ++
mu) {
506 gmtContainer.push_back(*
mu);
509 vector<l1t::Muon>::const_iterator gmtIt;
510 vector<l1t::Muon>::const_iterator gmtEnd = gmtContainer.end();
512 for (; probeMuIt!=probeMuEnd; ++probeMuIt) {
513 float eta = (*probeMuIt)->eta();
514 float phi = (*probeMuIt)->phi();
515 float pt = (*probeMuIt)->pt();
517 m_EfficiencyHistos[0][
"ProbeMuonEta_Histo"]->Fill(eta);
518 m_EfficiencyHistos[0][
"ProbeMuonPhi_Histo"]->Fill(phi);
519 m_EfficiencyHistos[0][
"ProbeMuonPt_Histo"]->Fill(pt);
523 gmtIt = gmtContainer.begin();
525 for(; gmtIt!=gmtEnd; ++gmtIt) {
529 if ( (pairTmpCand.
dR() < m_MaxGmtMuonDR) && (pairTmpCand.
dR() < pairBestCand.
dR() ) ) {
530 pairBestCand = pairTmpCand;
534 m_MuonGmtPairs.push_back(pairBestCand);
535 m_ControlHistos[
"MuonGmtDeltaR"]->Fill(pairBestCand.
dR());
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) {
550 const vector<string> moduleLabels(m_hltConfig.moduleLabels(*trigIndexIt));
551 const unsigned moduleIndex = m_hltConfig.size((*trigIndexIt))-2;
552 const unsigned hltFilterIndex = triggerEvent->
filterIndex(
InputTag(moduleLabels[moduleIndex],
"",m_trigProcess));
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;
565 return (matchDeltaR < m_MaxHltMuonDR);
LuminosityBlockID id() const
const_iterator end(int bx) const
T getUntrackedParameter(std::string const &, T const &) const
virtual void bookEfficiencyHistos(DQMStore::IBooker &ibooker, int ptCut)
void getTightMuons(edm::Handle< reco::MuonCollection > &muons, const reco::Vertex &vertex)
void getMuonGmtPairs(edm::Handle< l1t::MuonBxCollection > &gmtCands)
const reco::Vertex getPrimaryVertex(edm::Handle< reco::VertexCollection > &vertex, edm::Handle< reco::BeamSpot > &beamSpot)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
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
virtual void dqmBeginRun(const edm::Run &run, const edm::EventSetup &iSetup) override
math::Error< dimension >::type Error
covariance error matrix (3x3)
GlobalPoint globalPosition() const
void analyze(const edm::Event &e, const edm::EventSetup &c) override
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, Bounds *bounds=0)
const l1t::Muon * m_regMu
virtual void dqmEndLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
const Vids & filterIds(trigger::size_type index) const
const TriggerObjectCollection & getObjects() const
static PlanePointer build(Args &&...args)
TrajectoryStateOnSurface cylExtrapTrkSam(reco::TrackRef track, double rho)
const reco::Muon * m_muon
MonitorElement * book1D(Args &&...args)
virtual void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &iSetup) override
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
math::XYZPoint Point
point in the space
double BeamWidthX() const
beam width X
L1TEfficiencyMuons_Offline(const edm::ParameterSet &ps)
void getProbeMuons(edm::Handle< edm::TriggerResults > &trigResults, edm::Handle< trigger::TriggerEvent > &trigEvent)
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
FreeTrajectoryState freeTrajStateMuon(reco::TrackRef track)
virtual void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
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)
virtual void bookControlHistos(DQMStore::IBooker &)
double sigmaZ() const
sigma z
double BeamWidthY() const
beam width Y
LuminosityBlockNumber_t luminosityBlock() const
MuonGmtPair(const reco::Muon *muon, const l1t::Muon *regMu)
virtual ~L1TEfficiencyMuons_Offline()
const Point & position() const
position
bool matchHlt(edm::Handle< trigger::TriggerEvent > &triggerEvent, const reco::Muon *mu)
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
const_iterator begin(int bx) const