22 using namespace trigger;
31 m_muon = muonGmtPair.
m_muon;
32 m_gmt = muonGmtPair.
m_gmt;
33 m_eta = muonGmtPair.
m_eta;
42 float dEta = m_gmt ? (m_gmt->etaValue() -
eta()) : 999.;
43 float dPhi = m_gmt ? (m_gmt->phiValue() -
phi()) : 999.;
45 float dr =
sqrt(dEta*dEta + dPhi*dPhi);
60 TrackRef standaloneMuon = m_muon->outerTrack();
63 trajectory = cylExtrapTrkSam(standaloneMuon, 500);
69 trajectory = surfExtrapTrkSam(standaloneMuon, 790);
75 trajectory = surfExtrapTrkSam(standaloneMuon, -790);
93 recoProp = m_propagatorAlong->propagate(recoStart, *myCylinder);
95 recoProp = m_propagatorOpposite->propagate(recoStart, *myCylinder);
111 recoProp = m_propagatorAlong->propagate(recoStart, *myPlane);
113 recoProp = m_propagatorOpposite->propagate(recoStart, *myPlane);
122 GlobalPoint innerPoint(track->innerPosition().x(), track->innerPosition().y(), track->innerPosition().z());
123 GlobalVector innerVec (track->innerMomentum().x(), track->innerMomentum().y(), track->innerMomentum().z());
136 cout <<
"[L1TEfficiencyMuons_Offline:] ____________ Storage initialization ____________ " << endl;
150 m_trigProcess_token = consumes<edm::TriggerResults>(ps.
getUntrackedParameter<
string>(
"trigProcess_token"));
155 m_MaxGmtMuonDR = 0.7;
156 m_MaxHltMuonDR = 0.1;
168 if (m_verbose) {
cout <<
"[L1TEfficiencyMuons_Offline:] Called beginRun." << endl;}
172 m_hltConfig.init(run,iSetup,m_trigProcess,changed);
179 bookControlHistos(ibooker);
181 vector<int>::const_iterator gmtPtCutsIt = m_GmtPtCuts.begin();
182 vector<int>::const_iterator gmtPtCutsEnd = m_GmtPtCuts.end();
184 for (; gmtPtCutsIt!=gmtPtCutsEnd; ++ gmtPtCutsIt) {
185 bookEfficiencyHistos(ibooker, (*gmtPtCutsIt));
188 vector<string>::const_iterator trigNamesIt = m_trigNames.begin();
189 vector<string>::const_iterator trigNamesEnd = m_trigNames.end();
191 for (; trigNamesIt!=trigNamesEnd; ++trigNamesIt) {
193 TString tNameTmp = TString(*trigNamesIt);
194 TRegexp tNamePattern = TRegexp(tNameTmp,
true);
197 for (
unsigned ipath = 0; ipath < m_hltConfig.size(); ++ipath) {
199 TString tmpName = TString(m_hltConfig.triggerName(ipath));
200 if (tmpName.Contains(tNamePattern)) {
202 m_trigIndices.push_back(tIndex);
206 if (tIndex < 0 && m_verbose) {
207 cout <<
"[L1TEfficiencyMuons_Offline:] Warning: Could not find trigger "
208 << (*trigNamesIt) << endl;
219 cout <<
"[L1TEfficiencyMuons_Offline:] Called beginLuminosityBlock at LS="
230 cout <<
"[L1TEfficiencyMuons_Offline:] Called endLuminosityBlock at LS="
253 iEvent.
getByToken(m_trigProcess_token,trigResults);
265 getTightMuons(muons,primaryVertex);
266 getProbeMuons(trigResults,trigEvent);
267 getMuonGmtPairs(gmtCands);
269 cout <<
"[L1TEfficiencyMuons_Offline:] Computing efficiencies" << endl;
271 vector<MuonGmtPair>::const_iterator muonGmtPairsIt = m_MuonGmtPairs.begin();
272 vector<MuonGmtPair>::const_iterator muonGmtPairsEnd = m_MuonGmtPairs.end();
274 for(; muonGmtPairsIt!=muonGmtPairsEnd; ++muonGmtPairsIt) {
276 float eta = muonGmtPairsIt->eta();
277 float phi = muonGmtPairsIt->phi();
278 float pt = muonGmtPairsIt->pt();
281 float gmtPt = muonGmtPairsIt->gmtPt();
283 vector<int>::const_iterator gmtPtCutsIt = m_GmtPtCuts.begin();
284 vector<int>::const_iterator gmtPtCutsEnd = m_GmtPtCuts.end();
286 for (; gmtPtCutsIt!=gmtPtCutsEnd; ++ gmtPtCutsIt) {
288 int gmtPtCut = (*gmtPtCutsIt);
289 bool gmtAboveCut = (gmtPt > gmtPtCut);
291 stringstream ptCutToTag; ptCutToTag << gmtPtCut;
292 string ptTag = ptCutToTag.str();
294 if (fabs(eta) < m_MaxMuonEta) {
296 m_EfficiencyHistos[gmtPtCut][
"EffvsPt" + ptTag +
"Den"]->Fill(pt);
297 if (gmtAboveCut) m_EfficiencyHistos[gmtPtCut][
"EffvsPt" + ptTag +
"Num"]->Fill(pt);
299 if (pt > gmtPtCut + 8.) {
301 m_EfficiencyHistos[gmtPtCut][
"EffvsPhi" + ptTag +
"Den"]->Fill(phi);
302 m_EfficiencyHistos[gmtPtCut][
"EffvsEta" + ptTag +
"Den"]->Fill(eta);
305 m_EfficiencyHistos[gmtPtCut][
"EffvsPhi" + ptTag +
"Num"]->Fill(phi);
306 m_EfficiencyHistos[gmtPtCut][
"EffvsEta" + ptTag +
"Num"]->Fill(eta);
313 cout <<
"[L1TEfficiencyMuons_Offline:] Computation finished" << endl;
322 if(m_verbose){
cout <<
"[L1TEfficiencyMuons_Offline:] Booking Control Plot Histos" << endl;}
326 string name =
"MuonGmtDeltaR";
327 m_ControlHistos[
name] = ibooker.
book1D(name.c_str(),name.c_str(),25.,0.,2.5);
329 name =
"NTightVsAll";
330 m_ControlHistos[
name] = ibooker.
book2D(name.c_str(),name.c_str(),5,-0.5,4.5,5,-0.5,4.5);
332 name =
"NProbesVsTight";
333 m_ControlHistos[
name] = ibooker.
book2D(name.c_str(),name.c_str(),5,-0.5,4.5,5,-0.5,4.5);
342 cout <<
"[L1TEfficiencyMuons_Offline:] Booking Efficiency Plot Histos for pt cut = "
346 stringstream ptCutToTag; ptCutToTag << ptCut;
347 string ptTag = ptCutToTag.str();
351 string effTag[2] = {
"Den",
"Num"};
353 for(
int iEffTag=0; iEffTag<2; ++ iEffTag) {
354 string name =
"EffvsPt" + ptTag + effTag[iEffTag];
355 m_EfficiencyHistos[ptCut][
name] = ibooker.
book1D(name.c_str(),name.c_str(),16,0.,40.);
357 name =
"EffvsPhi" + ptTag + effTag[iEffTag];
358 m_EfficiencyHistos[ptCut][
name] = ibooker.
book1D(name.c_str(),name.c_str(),12,0.,2*
TMath::Pi());
360 name =
"EffvsEta" + ptTag + effTag[iEffTag];
361 m_EfficiencyHistos[ptCut][
name] = ibooker.
book1D(name.c_str(),name.c_str(),12,-2.4,2.4);
374 bool hasPrimaryVertex =
false;
379 vector<Vertex>::const_iterator vertexIt = vertex->begin();
380 vector<Vertex>::const_iterator vertexEnd = vertex->end();
382 for (;vertexIt!=vertexEnd;++vertexIt)
384 if (vertexIt->isValid() &&
387 posVtx = vertexIt->position();
388 errVtx = vertexIt->error();
389 hasPrimaryVertex =
true;
395 if ( !hasPrimaryVertex ) {
398 cout <<
"[L1TEfficiencyMuons_Offline:] PrimaryVertex not found, use BeamSpot position instead" << endl;
401 posVtx = beamSpot->position();
402 errVtx(0,0) = beamSpot->BeamWidthX();
403 errVtx(1,1) = beamSpot->BeamWidthY();
404 errVtx(2,2) = beamSpot->sigmaZ();
418 cout <<
"[L1TEfficiencyMuons_Offline:] Getting tight muons" << endl;
420 m_TightMuons.clear();
422 MuonCollection::const_iterator muonIt = muons->begin();
423 MuonCollection::const_iterator muonEnd = muons->end();
425 for(; muonIt!=muonEnd; ++muonIt) {
427 m_TightMuons.push_back(&(*muonIt));
431 m_ControlHistos[
"NTightVsAll"]->Fill(muons->size(),m_TightMuons.size());
440 cout <<
"[L1TEfficiencyMuons_Offline:] getting probe muons" << endl;
442 m_ProbeMuons.clear();
444 vector<const Muon*>::const_iterator probeCandIt = m_TightMuons.begin();
445 vector<const Muon*>::const_iterator tightMuonsEnd = m_TightMuons.end();
447 for (; probeCandIt!=tightMuonsEnd; ++probeCandIt) {
449 bool tagHasTrig =
false;
450 vector<const Muon*>::const_iterator tagCandIt = m_TightMuons.begin();
452 for (; tagCandIt!=tightMuonsEnd; ++tagCandIt) {
453 if ((*tagCandIt) == (*probeCandIt))
continue;
454 tagHasTrig |= matchHlt(trigEvent,(*tagCandIt));
457 if (tagHasTrig) m_ProbeMuons.push_back((*probeCandIt));
461 m_ControlHistos[
"NProbesVsTight"]->Fill(m_TightMuons.size(),m_ProbeMuons.size());
468 m_MuonGmtPairs.clear();
470 cout <<
"[L1TEfficiencyMuons_Offline:] Getting muon GMT pairs" << endl;
472 vector<const Muon*>::const_iterator probeMuIt = m_ProbeMuons.begin();
473 vector<const Muon*>::const_iterator probeMuEnd = m_ProbeMuons.end();
475 vector<L1MuGMTExtendedCand> gmtContainer = gmtCands->getRecord(0).getGMTCands();
477 vector<L1MuGMTExtendedCand>::const_iterator gmtIt;
478 vector<L1MuGMTExtendedCand>::const_iterator gmtEnd = gmtContainer.end();
480 for (; probeMuIt!=probeMuEnd; ++probeMuIt) {
483 pairBestCand.
propagate(m_BField,m_propagatorAlong,m_propagatorOpposite);
485 gmtIt = gmtContainer.begin();
487 for(; gmtIt!=gmtEnd; ++gmtIt) {
490 pairTmpCand.
propagate(m_BField,m_propagatorAlong,m_propagatorOpposite);
492 if (pairTmpCand.
dR() < m_MaxGmtMuonDR && pairTmpCand.
gmtPt() > pairBestCand.
gmtPt())
493 pairBestCand = pairTmpCand;
497 m_MuonGmtPairs.push_back(pairBestCand);
499 m_ControlHistos[
"MuonGmtDeltaR"]->Fill(pairBestCand.
dR());
509 double matchDeltaR = 9999;
513 vector<int>::const_iterator trigIndexIt = m_trigIndices.begin();
514 vector<int>::const_iterator trigIndexEnd = m_trigIndices.end();
516 for(; trigIndexIt!=trigIndexEnd; ++trigIndexIt) {
518 const vector<string> moduleLabels(m_hltConfig.moduleLabels(*trigIndexIt));
519 const unsigned moduleIndex = m_hltConfig.size((*trigIndexIt))-2;
520 const unsigned hltFilterIndex = triggerEvent->filterIndex(
InputTag(moduleLabels[moduleIndex],
523 if (hltFilterIndex < triggerEvent->sizeFilters()) {
524 const Keys triggerKeys(triggerEvent->filterKeys(hltFilterIndex));
525 const Vids triggerVids(triggerEvent->filterIds(hltFilterIndex));
527 const unsigned nTriggers = triggerVids.size();
528 for (
size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
529 const TriggerObject trigObject = trigObjs[triggerKeys[iTrig]];
531 double dRtmp =
deltaR((*mu),trigObject);
532 if (dRtmp < matchDeltaR) matchDeltaR = dRtmp;
538 return (matchDeltaR < m_MaxHltMuonDR);
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
virtual void bookEfficiencyHistos(DQMStore::IBooker &ibooker, int ptCut)
MuonGmtPair(const reco::Muon *muon, const L1MuGMTExtendedCand *gmt)
void getTightMuons(edm::Handle< reco::MuonCollection > &muons, const reco::Vertex &vertex)
const reco::Vertex getPrimaryVertex(edm::Handle< reco::VertexCollection > &vertex, edm::Handle< reco::BeamSpot > &beamSpot)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
#define DEFINE_FWK_MODULE(type)
Geom::Phi< T > phi() const
math::Error< dimension >::type Error
covariance error matrix (3x3)
GlobalPoint globalPosition() const
const L1MuGMTExtendedCand * m_gmt
Single trigger physics object (e.g., an isolated muon)
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, Bounds *bounds=0)
virtual void dqmEndLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
double dPhi(double phi1, double phi2)
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
L1TEfficiencyMuons_Offline(const edm::ParameterSet &ps)
void getMuonGmtPairs(edm::Handle< L1MuGMTReadoutCollection > &gmtCands)
void getProbeMuons(edm::Handle< edm::TriggerResults > &trigResults, edm::Handle< trigger::TriggerEvent > &trigEvent)
void analyze(const edm::Event &e, const edm::EventSetup &c)
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
FreeTrajectoryState freeTrajStateMuon(reco::TrackRef track)
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 &)
LuminosityBlockNumber_t luminosityBlock() const
Geom::Phi< T > phi() const
virtual void dqmBeginRun(const edm::Run &run, const edm::EventSetup &iSetup)
virtual ~L1TEfficiencyMuons_Offline()
bool matchHlt(edm::Handle< trigger::TriggerEvent > &triggerEvent, const reco::Muon *mu)
bool isTightMuon(const reco::Muon &, const reco::Vertex &)