15 #include <boost/algorithm/string/replace.hpp>
38 : hltProcessName_(
pset.getParameter<
string>(
"hltProcessName")),
39 destination_(
pset.getUntrackedParameter<
string>(
"destination")),
40 requiredTriggers_(
pset.getUntrackedParameter<
vstring>(
"requiredTriggers")),
45 isLastFilter_(islastfilter),
46 hasTargetRecoCuts(targetParams_.exists(
"recoCuts")),
47 hasProbeRecoCuts(probeParams_.exists(
"recoCuts")),
48 targetMuonSelector_(targetParams_.getUntrackedParameter<
string>(
"recoCuts",
"")),
49 targetZ0Cut_(targetParams_.getUntrackedParameter<double>(
"z0Cut", 0.)),
50 targetD0Cut_(targetParams_.getUntrackedParameter<double>(
"d0Cut", 0.)),
51 targetptCutZ_(targetParams_.getUntrackedParameter<double>(
"ptCut_Z", 20.)),
52 targetptCutJpsi_(targetParams_.getUntrackedParameter<double>(
"ptCut_Jpsi", 20.)),
53 probeMuonSelector_(probeParams_.getUntrackedParameter<
string>(
"recoCuts",
"")),
54 probeZ0Cut_(probeParams_.getUntrackedParameter<double>(
"z0Cut", 0.)),
55 probeD0Cut_(probeParams_.getUntrackedParameter<double>(
"d0Cut", 0.)),
56 triggerSelector_(targetParams_.getUntrackedParameter<
string>(
"hltCuts",
"")),
57 hasTriggerCuts_(targetParams_.exists(
"hltCuts")) {
64 TPRegexp levelRegexp(
"L[1-3]");
67 TObjArray* levelArray = levelRegexp.MatchS(
moduleLabel_);
68 if (levelArray->GetEntriesFast() > 0) {
69 triggerLevel_ = static_cast<const char*>(((TObjString*)levelArray->At(0))->GetString());
75 TPRegexp ptRegexp(
"Mu([0-9]*)");
76 TObjArray* objArray = ptRegexp.MatchS(
hltPath_);
77 if (objArray->GetEntriesFast() >= 2) {
78 auto* ptCutString = (TObjString*)objArray->At(1);
79 cutMinPt_ = atoi(ptCutString->GetString());
86 TPRegexp suffixPtCut(
"Mu[0-9]+$");
103 book1D(iBooker,
"hltPt",
"pt",
";p_{T} of HLT object");
104 book1D(iBooker,
"hltEta",
"eta",
";#eta of HLT object");
105 book1D(iBooker,
"hltPhi",
"phi",
";#phi of HLT object");
106 book1D(iBooker,
"resolutionEta",
"resolutionEta",
";#eta^{reco}-#eta^{HLT};");
107 book1D(iBooker,
"resolutionPhi",
"resolutionPhi",
";#phi^{reco}-#phi^{HLT};");
109 book1D(iBooker,
"deltaR",
"deltaR",
";#Deltar(reco, HLT);");
111 book1D(iBooker,
"resolutionPt",
"resolutionRel",
";(p_{T}^{reco}-p_{T}^{HLT})/|p_{T}^{reco}|;");
119 book1D(iBooker,
"efficiencyEta_" +
suffix,
"eta",
";#eta;");
120 book1D(iBooker,
"efficiencyPhi_" +
suffix,
"phi",
";#phi;");
121 book1D(iBooker,
"efficiencyTurnOn_" +
suffix,
"pt",
";p_{T};");
122 book1D(iBooker,
"efficiencyVertex_" +
suffix,
"NVertex",
";NVertex;");
123 book1D(iBooker,
"efficiencyDeltaR_" +
suffix,
"deltaR2",
";#Delta R;");
125 book2D(iBooker,
"efficiencyPhiVsEta_" +
suffix,
"etaCoarse",
"phiCoarse",
";#eta;#phi");
127 auto MRbaseDir = boost::replace_all_copy<string>(
baseDir,
"HLT/Muon",
"HLT/Muon/MR");
133 book2D(iBooker,
"MR_efficiencyPhiVsEta_" +
suffix,
"etaCoarse",
"phiHEP17",
";#eta;#phi");
143 book1D(iBooker,
"efficiencyD0_" +
suffix,
"d0",
";d0;");
144 book1D(iBooker,
"efficiencyZ0_" +
suffix,
"z0",
";z0;");
145 book1D(iBooker,
"efficiencyCharge_" +
suffix,
"charge",
";charge;");
147 book1D(iBooker,
"fakerateEta_" +
suffix,
"eta",
";#eta;");
148 book1D(iBooker,
"fakerateVertex_" +
suffix,
"NVertex",
";NVertex;");
149 book1D(iBooker,
"fakeratePhi_" +
suffix,
"phi",
";#phi;");
150 book1D(iBooker,
"fakerateTurnOn_" +
suffix,
"pt",
";p_{T};");
152 book1D(iBooker,
"massVsEtaZ_" +
suffix,
"etaCoarse",
";#eta");
153 book1D(iBooker,
"massVsEtaJpsi_" +
suffix,
"etaCoarse",
";#eta");
154 book1D(iBooker,
"massVsPtZ_" +
suffix,
"ptCoarse",
";p_{T}");
155 book1D(iBooker,
"massVsPtJpsi_" +
suffix,
"ptCoarse",
";p_{T}");
156 book1D(iBooker,
"massVsVertexZ_" +
suffix,
"NVertex",
";NVertex");
157 book1D(iBooker,
"massVsVertexJpsi_" +
suffix,
"NVertex",
";NVertex");
161 book1D(iBooker,
"Refefficiency_Eta_Mu1_" +
suffix,
"etaCoarse",
";#eta;");
162 book1D(iBooker,
"Refefficiency_Eta_Mu2_" +
suffix,
"etaCoarse",
";#eta;");
163 book1D(iBooker,
"Refefficiency_TurnOn_Mu1_" +
suffix,
"ptCoarse",
";p_{T};");
164 book1D(iBooker,
"Refefficiency_TurnOn_Mu2_" +
suffix,
"ptCoarse",
";p_{T};");
165 book1D(iBooker,
"Refefficiency_Vertex_" +
suffix,
"NVertex",
";NVertex;");
166 book1D(iBooker,
"Refefficiency_DZ_Mu_" +
suffix,
"z0",
";z0;");
168 book2D(iBooker,
"Refefficiency_Eta_" +
suffix,
"etaCoarse",
"etaCoarse",
";#eta;#eta");
169 book2D(iBooker,
"Refefficiency_Pt_" +
suffix,
"ptCoarse",
"ptCoarse",
";p_{T};p_{T}");
170 book1D(iBooker,
"Refefficiency_DZ_Vertex_" +
suffix,
"NVertex",
";NVertex;");
171 book1D(iBooker,
"Ref_SS_pt1_" +
suffix,
"ptCoarse",
";p_{T}");
172 book1D(iBooker,
"Ref_SS_pt2_" +
suffix,
"ptCoarse",
";p_{T}");
173 book1D(iBooker,
"Ref_SS_eta1_" +
suffix,
"etaCoarse",
";#eta;");
174 book1D(iBooker,
"Ref_SS_eta2_" +
suffix,
"etaCoarse",
";#eta;");
181 book1D(iBooker,
"MR_Refefficiency_TurnOn_Mu1_" +
suffix,
"pt",
";p_{T};");
182 book1D(iBooker,
"MR_Refefficiency_TurnOn_Mu2_" +
suffix,
"pt",
";p_{T};");
183 book1D(iBooker,
"MR_Refefficiency_Vertex_" +
suffix,
"NVertexFine",
";NVertex;");
184 book1D(iBooker,
"MR_Refefficiency_DZ_Mu_" +
suffix,
"z0Fine",
";z0;");
186 book2D(iBooker,
"MR_Refefficiency_Pt_" +
suffix,
"pt",
"pt",
";p_{T};p_{T}");
187 book1D(iBooker,
"MR_Refefficiency_DZ_Vertex_" +
suffix,
"NVertexFine",
";NVertex;");
189 book1D(iBooker,
"MR_massVsPtZ_" +
suffix,
"pt",
";p_{T}");
190 book1D(iBooker,
"MR_massVsPtJpsi_" +
suffix,
"pt",
";p_{T}");
191 book1D(iBooker,
"MR_massVsVertexZ_" +
suffix,
"NVertex",
";NVertex");
192 book1D(iBooker,
"MR_massVsVertexJpsi_" +
suffix,
"NVertexFine",
";NVertex");
193 book1D(iBooker,
"MR_massVsDZZ_" +
suffix,
"z0Fine",
";z0;");
194 book1D(iBooker,
"MR_massVsEtaZ_" +
suffix,
"etaFine",
";#eta");
195 book1D(iBooker,
"MR_massVsEtaJpsi_" +
suffix,
"etaFine",
";#eta");
196 book1D(iBooker,
"MR_massVsPhiZ_" +
suffix,
"phiFine",
";#phi");
197 book1D(iBooker,
"MR_massVsPhiJpsi_" +
suffix,
"phiFine",
";#phi");
263 hists_[
"hltPt"]->Fill(hltMuon.pt());
264 hists_[
"hltEta"]->Fill(hltMuon.eta());
265 hists_[
"hltPhi"]->Fill(hltMuon.phi());
272 bool pairalreadyconsidered =
false;
273 for (
size_t i = 0;
i < targetMuons.size();
i++) {
277 if (
matches[
i] < targetMuons.size()) {
279 double ptRes = (
muon.pt() - hltMuon.
pt()) /
muon.pt();
280 hists_[
"resolutionPt"]->Fill(ptRes);
284 double etaRes =
muon.eta() - hltMuon.
eta();
285 double phiRes =
muon.phi() - hltMuon.
phi();
286 hists_[
"resolutionEta"]->Fill(etaRes);
287 hists_[
"resolutionPhi"]->Fill(phiRes);
309 if (
muon.isTrackerMuon())
311 else if (
muon.isStandAloneMuon())
332 if (
matches[
i] >= targetMuons.size())
334 for (
size_t k = 0;
k < targetMuons.size();
k++) {
337 Muon& theProbe = targetMuons[
k];
338 if (
muon.charge() != theProbe.
charge() && !pairalreadyconsidered) {
339 double mass = (
muon.p4() + theProbe.
p4()).M();
344 hists_[
"massVsPtZ_denom"]->Fill(theProbe.
pt());
345 hists_[
"massVsEtaZ_denom"]->Fill(theProbe.
eta());
347 hists_[
"MR_massVsEtaZ_denom"]->Fill(theProbe.
eta());
348 hists_[
"MR_massVsPhiZ_denom"]->Fill(theProbe.
phi());
349 hists_[
"MR_massVsPtZ_denom"]->Fill(theProbe.
pt());
363 if (
matches[
k] < targetMuons.size()) {
364 hists_[
"massVsPtZ_numer"]->Fill(theProbe.
pt());
365 hists_[
"MR_massVsPtZ_numer"]->Fill(theProbe.
pt());
367 hists_[
"MR_massVsPhiZ_numer"]->Fill(theProbe.
phi());
368 hists_[
"massVsEtaZ_numer"]->Fill(theProbe.
eta());
369 hists_[
"MR_massVsEtaZ_numer"]->Fill(theProbe.
eta());
379 pairalreadyconsidered =
true;
384 hists_[
"massVsEtaJpsi_denom"]->Fill(theProbe.
eta());
385 hists_[
"MR_massVsEtaJpsi_denom"]->Fill(theProbe.
eta());
386 hists_[
"massVsPtJpsi_denom"]->Fill(theProbe.
pt());
387 hists_[
"MR_massVsPtJpsi_denom"]->Fill(theProbe.
pt());
390 if (
matches[
k] < targetMuons.size()) {
391 hists_[
"massVsEtaJpsi_numer"]->Fill(theProbe.
eta());
392 hists_[
"MR_massVsEtaJpsi_numer"]->Fill(theProbe.
eta());
393 hists_[
"massVsPtJpsi_numer"]->Fill(theProbe.
pt());
394 hists_[
"MR_massVsPtJpsi_numer"]->Fill(theProbe.
pt());
398 pairalreadyconsidered =
true;
410 unsigned int numTriggers =
trigNames.size();
411 bool passTrigger =
false;
415 for (
unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
416 passTrigger = (
trigNames.triggerName(hltIndex).find(requiredTrigger) != std::string::npos &&
424 for (
unsigned long matche :
matches) {
425 if (matche < targetMuons.size())
430 hists_[
"Refefficiency_Eta_Mu1_denom"]->Fill(targetMuons.at(0).eta());
431 hists_[
"Refefficiency_Eta_Mu2_denom"]->Fill(targetMuons.at(1).eta());
432 hists_[
"Refefficiency_TurnOn_Mu1_denom"]->Fill(targetMuons.at(0).pt());
433 hists_[
"MR_Refefficiency_TurnOn_Mu1_denom"]->Fill(targetMuons.at(0).pt());
434 hists_[
"Refefficiency_TurnOn_Mu2_denom"]->Fill(targetMuons.at(1).pt());
435 hists_[
"MR_Refefficiency_TurnOn_Mu2_denom"]->Fill(targetMuons.at(1).pt());
438 hists_[
"MR_Refefficiency_Pt_denom"]->Fill(targetMuons.at(0).pt(), targetMuons.at(1).pt());
439 hists_[
"Refefficiency_Pt_denom"]->Fill(targetMuons.at(0).pt(), targetMuons.at(1).pt());
440 hists_[
"Refefficiency_Eta_denom"]->Fill(targetMuons.at(0).eta(), targetMuons.at(1).eta());
454 hists_[
"Refefficiency_Eta_Mu1_numer"]->Fill(targetMuons.at(0).eta());
455 hists_[
"Refefficiency_Eta_Mu2_numer"]->Fill(targetMuons.at(1).eta());
456 hists_[
"Refefficiency_TurnOn_Mu1_numer"]->Fill(targetMuons.at(0).pt());
457 hists_[
"MR_Refefficiency_TurnOn_Mu1_numer"]->Fill(targetMuons.at(0).pt());
458 hists_[
"Refefficiency_TurnOn_Mu2_numer"]->Fill(targetMuons.at(1).pt());
459 hists_[
"MR_Refefficiency_TurnOn_Mu2_numer"]->Fill(targetMuons.at(1).pt());
462 hists_[
"MR_Refefficiency_Pt_numer"]->Fill(targetMuons.at(0).pt(), targetMuons.at(1).pt());
463 hists_[
"Refefficiency_Pt_numer"]->Fill(targetMuons.at(0).pt(), targetMuons.at(1).pt());
464 hists_[
"Refefficiency_Eta_numer"]->Fill(targetMuons.at(0).eta(), targetMuons.at(1).eta());
479 if (nonSameSignPath.rfind(
"_SameSign") < nonSameSignPath.length()) {
481 nonSameSignPath = boost::replace_all_copy<string>(nonSameSignPath,
"_SameSign",
"");
482 nonSameSignPath = nonSameSignPath.substr(0, nonSameSignPath.rfind(
"_v") + 2);
484 bool passTriggerSS =
false;
486 for (
unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
488 passTriggerSS || (
trigNames.triggerName(hltIndex).substr(0, nonSameSignPath.size()) == nonSameSignPath &&
492 if (ssPath && targetMuons.size() > 1 && passTriggerSS) {
493 if (targetMuons[0].
charge() * targetMuons[1].charge() > 0) {
494 hists_[
"Ref_SS_pt1_denom"]->Fill(targetMuons[0].
pt());
495 hists_[
"Ref_SS_pt2_denom"]->Fill(targetMuons[1].
pt());
496 hists_[
"Ref_SS_eta1_denom"]->Fill(targetMuons[0].
eta());
497 hists_[
"Ref_SS_eta2_denom"]->Fill(targetMuons[1].
eta());
499 hists_[
"Ref_SS_pt1_numer"]->Fill(targetMuons[0].
pt());
500 hists_[
"Ref_SS_pt2_numer"]->Fill(targetMuons[1].
pt());
501 hists_[
"Ref_SS_eta1_numer"]->Fill(targetMuons[0].
eta());
502 hists_[
"Ref_SS_eta2_numer"]->Fill(targetMuons[1].
eta());
510 if (nonDZPath.rfind(
"_DZ") < nonDZPath.length()) {
512 nonDZPath = boost::replace_all_copy<string>(nonDZPath,
"_DZ",
"");
513 nonDZPath = nonDZPath.substr(0, nonDZPath.rfind(
"_v") + 2);
515 bool passTriggerDZ =
false;
517 for (
unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
518 passTriggerDZ = passTriggerDZ || (
trigNames.triggerName(hltIndex).find(nonDZPath) != std::string::npos &&
523 if (dzPath && targetMuons.size() > 1 && passTriggerDZ) {
524 const Track* track0 =
nullptr;
525 const Track* track1 =
nullptr;
526 if (targetMuons.at(0).isTrackerMuon())
527 track0 = &*targetMuons.at(0).innerTrack();
528 else if (targetMuons.at(0).isTrackerMuon())
529 track0 = &*targetMuons.at(0).outerTrack();
530 if (targetMuons.at(1).isTrackerMuon())
531 track1 = &*targetMuons.at(1).innerTrack();
532 else if (targetMuons.at(1).isTrackerMuon())
533 track1 = &*targetMuons.at(1).outerTrack();
535 if (track0 && track1) {
540 hists_[
"MR_Refefficiency_DZ_Vertex_denom"]->Fill(
vertices->size());
542 if (track0 && track1) {
544 hists_[
"MR_Refefficiency_DZ_Mu_numer"]->Fill(track0->
dz(
beamSpot->position()) -
547 hists_[
"MR_Refefficiency_DZ_Vertex_numer"]->Fill(
vertices->size());
556 bool isFake = hltMatches[
i] >
hltMuons.size();
559 if (
suffix ==
"numer" && !isFake)
573 LogWarning(
"HLTMuonVal") <<
"Invalid binning parameters!";
606 targetPset =
pset.getUntrackedParameterSet(
target);
610 vector<string>::const_iterator iter;
612 for (iter =
names.begin(); iter !=
names.end(); ++iter) {
615 else if (targetPset.
existsAs<
T>(*iter,
false))
621 template <
class T1,
class T2>
623 const vector<T2>& collection2,
625 const size_t n1 = collection1.size();
626 const size_t n2 = collection2.size();
628 vector<size_t>
result(n1, -1);
629 vector<vector<double> > deltaRMatrix(n1, vector<double>(n2,
NOMATCH));
631 for (
size_t i = 0;
i < n1;
i++)
632 for (
size_t j = 0;
j < n2;
j++) {
633 deltaRMatrix[
i][
j] =
deltaR(collection1[
i], collection2[
j]);
637 for (
size_t k = 0;
k < n1;
k++) {
642 for (
size_t i = 0;
i < n1;
i++)
643 for (
size_t j = 0;
j < n2;
j++)
652 deltaRMatrix[i_min] = vector<double>(n2,
NOMATCH);
653 for (
size_t i = 0;
i < n1;
i++)
674 if (
mu.isTrackerMuon())
676 else if (
mu.isStandAloneMuon())
680 reducedMuons.push_back(
mu);
701 for (
unsigned short key :
keys) {
703 if (triggerSelector(foundObject))
704 selectedObjects.push_back(foundObject);
708 return selectedObjects;
719 float*
edges =
nullptr;
732 const string& binningTypeX,
733 const string& binningTypeY,
734 const string&
title) {
742 float* edgesX =
nullptr;
746 float* edgesY =
nullptr;