13 static constexpr
double const MeVtoGeV = 1. / 1000.;
17 std::vector<int> initializeChamberIdxOrder() {
22 const std::vector<int> chamberIndicesOrdered = {
33 for (
unsigned int i = 0;
i < chamberIndicesOrdered.size();
i++) chamberIndexOrder[chamberIndicesOrdered[
i]] =
i;
35 return chamberIndexOrder;
40 static const std::vector<int> chamberIndexOrder = initializeChamberIdxOrder();
42 return (chamberIndexOrder[
first->chamberIndex()] < chamberIndexOrder[
second->chamberIndex()]);
75 "Not using allAuthors variable as currently missing in many derivations; LowPtEfficiency working point will always return "
76 "false, but this is expected at the moment. Have a look here: "
77 "https://twiki.cern.ch/twiki/bin/view/Atlas/MuonSelectionToolR21#New_LowPtEfficiency_working_poin");
81 ATH_MSG_INFO(
"You have opted to select only 3-station muons in the high-pT selection! "
82 <<
"Please feed 'HighPt3Layers' to the 'WorkingPoint' property to retrieve the appropriate scale-factors");
86 ATH_MSG_WARNING(
"No cut-based selection is defined for segment-tagged muons in the Low-pT working point. "
87 <<
"Please set UseMVALowPt=true if you want to try the UseSegmentTaggedLowPt=true option.");
91 ATH_MSG_INFO(
"MuonSelectionTool will assume both Standard and LRT Muons are being used, and that the necessary information is available to identify the type (standard or LRT).");
92 if (
m_quality!=1)
ATH_MSG_WARNING(
"Currently, only Medium quality is supported for LRT muons. Your chosen WP will be applied (w/o ID cuts), but no recommendations are available for this quality.");
97 m_acceptInfo.
addCut(
"IDHits",
"Selection of muons according to whether they passed the MCP ID Hit cuts");
98 m_acceptInfo.
addCut(
"Preselection",
"Selection of muons according to their type/author");
103 "Invalid quality (i.e. selection WP) set: "
105 <<
" - it must be an integer between 0 and 5! (0=Tight, 1=Medium, 2=Loose, 3=Veryloose, 4=HighPt, 5=LowPtEfficiency)");
106 return StatusCode::FAILURE;
109 ATH_MSG_ERROR(
"Cannot use lowPt working point if allAuthors is not available!");
110 return StatusCode::FAILURE;
113 if(m_caloScoreWP<1 || m_caloScoreWP>4){
114 ATH_MSG_FATAL(
"CaloScoreWP property must be set to 1, 2, 3 or 4");
115 return StatusCode::FAILURE;
119 ATH_MSG_INFO(
"Initialising tight working point histograms...");
120 std::string tightWP_rootFile_fullPath;
125 Form(
"MuonSelectorTools/%s/muonSelection_tightWPHisto.root",
m_calibration_version.value().c_str()));
128 ATH_MSG_INFO(
"Reading muon tight working point histograms from " << tightWP_rootFile_fullPath);
130 std::unique_ptr<TFile>
file(TFile::Open(tightWP_rootFile_fullPath.c_str(),
"READ"));
132 if (!
file->IsOpen()) {
133 ATH_MSG_ERROR(
"Cannot read tight working point file from " << tightWP_rootFile_fullPath);
134 return StatusCode::FAILURE;
148 ATH_MSG_INFO(
"Reading bad muon veto cut functions from " << BMVcutFile_fullPath);
150 std::unique_ptr<TFile> BMVfile(TFile::Open(BMVcutFile_fullPath.c_str(),
"READ"));
152 if (!BMVfile->IsOpen()) {
153 ATH_MSG_ERROR(
"Cannot read bad muon veto cut function file from " << BMVcutFile_fullPath);
154 return StatusCode::FAILURE;
164 return StatusCode::FAILURE;
175 auto make_mva_reader = [](TString
file_path) {
176 std::vector<std::string> mva_var_names{
"momentumBalanceSignificance",
177 "scatteringCurvatureSignificance",
178 "scatteringNeighbourSignificance",
180 "middleLargeHoles+middleSmallHoles",
181 "muonSegmentDeltaEta",
182 "muonSeg1ChamberIdx",
183 "muonSeg2ChamberIdx"};
184 std::unique_ptr<TMVA::Reader>
reader = std::make_unique<TMVA::Reader>(mva_var_names);
201 auto make_mva_reader_MuTagIMO = [](TString
file_path,
bool useSeg2ChamberIndex) {
202 std::vector<std::string> mva_var_names;
203 if (useSeg2ChamberIndex) mva_var_names.push_back(
"muonSeg2ChamberIndex");
204 mva_var_names.push_back(
"muonSeg1ChamberIndex");
205 mva_var_names.push_back(
"muonSeg1NPrecisionHits");
206 mva_var_names.push_back(
"muonSegmentDeltaEta");
207 mva_var_names.push_back(
"muonSeg1GlobalR");
208 mva_var_names.push_back(
"muonSeg1Chi2OverDoF");
209 mva_var_names.push_back(
"muonSCS");
211 std::unique_ptr<TMVA::Reader>
reader = std::make_unique<TMVA::Reader>(mva_var_names);
224 return StatusCode::SUCCESS;
230 ATH_MSG_ERROR(
" getHist(...) TFile is nullptr! Check that the Tight cut map is loaded correctly");
231 return StatusCode::FAILURE;
233 TH1* h_ptr =
nullptr;
239 return StatusCode::FAILURE;
241 hist = std::unique_ptr<TH1>{h_ptr};
242 hist->SetDirectory(
nullptr);
243 ATH_MSG_INFO(
"Successfully read tight working point histogram: " <<
hist->GetName());
245 return StatusCode::SUCCESS;
260 ATH_MSG_FATAL(
"accept(...) Failed to cast particle to muon");
271 static std::atomic<bool> checkDone{
false};
279 <<
" while on-the fly check for runNumber "<<
getRunNumber(
true)<<
" indicates isRun3Geo="<<
isRun3(
true));
285 ATH_MSG_WARNING(
"MuonSelectionTool currently supports Loose, Medium, Tight and HighPt WPs for Run3; all other WPs can only be used in ExpertDevelopMode mode");
289 ATH_MSG_WARNING(
"For Run3, Tight WP is supported only when ExcludeNSWFromPrecisionLayers=False and RecalcPrecisionLayerswNSW=True");
304 else if (
mu.muonType() == xAOD::Muon::MuonStandAlone)
306 else if (
mu.muonType() == xAOD::Muon::SegmentTagged)
308 else if (
mu.muonType() == xAOD::Muon::CaloTagged)
310 else if (
mu.muonType() == xAOD::Muon::SiliconAssociatedForwardMuon)
337 if (!passIDCuts || !passMuonCuts) {
return acceptData; }
341 bool thisMu_highpt =
false;
343 bool thisMu_lowptE =
false;
346 ATH_MSG_VERBOSE(
"Muon quality: " << thisMu_quality <<
" passes HighPt: " << thisMu_highpt
347 <<
" passes LowPtEfficiency: " << thisMu_lowptE);
348 if (m_quality < 4 && thisMu_quality >
m_quality) {
return acceptData; }
349 if (
m_quality == 4 && !thisMu_highpt) {
return acceptData; }
350 if (
m_quality == 5 && !thisMu_lowptE) {
return acceptData; }
362 const xAOD::TrackParticle* metrack =
mu.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle);
363 if (!idtrack || !metrack) idPt = mePt = -1.;
365 mePt = metrack->
pt();
366 idPt = idtrack->
pt();
368 if (!mePt_acc.isAvailable(
mu) || !idPt_acc.isAvailable(
mu)) {
370 <<
" q:" <<
mu.charge() <<
", author:" <<
mu.author()
371 <<
" is not decorated with calibrated momenta. Please fix");
372 throw std::runtime_error(
"MuonSelectionTool() - qOverP significance calculation failed");
385 <<
" Momentum dependent cuts are disabled. Return 0.");
389 const xAOD::TrackParticle* metrack =
muon.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle);
390 if (!idtrack || !metrack) {
391 ATH_MSG_VERBOSE(
"No ID / MS track. Return dummy large value of 1 mio");
394 float mePt{-1.}, idPt{-1.};
401 return std::abs((metrack->
charge() / meP) - (idtrack->
charge() / idP)) / qOverPsigma;
406 <<
"Momentum dependent cuts are disabled. Return 0.");
409 float mePt{-1.}, idPt{-1.};
411 return std::abs(idPt - mePt) /
muon.pt();
420 ATH_MSG_VERBOSE(
"tool configured with quality="<<
m_quality<<
" which is currently only supported in expert mode for run3");
429 if (
mu.muonType() == xAOD::Muon::SegmentTagged) {
432 if (std::abs(
mu.eta()) < 0.1) {
436 ATH_MSG_VERBOSE(
"Do not allow segment-tagged muon at |eta| > 0.1 - return VeryLoose");
442 if (
mu.muonType() == xAOD::Muon::CaloTagged) {
467 ATH_MSG_VERBOSE(
"Muon has out-of-bounds precision hits - return VeryLoose");
473 const xAOD::TrackParticle* metrack =
mu.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle);
477 const float reducedChi2 =
mu.primaryTrackParticle()->chiSquared() /
mu.primaryTrackParticle()->numberDoF();
485 if (
summary.nprecisionLayers > 1 && reducedChi2 < 8 && std::abs(qOverPsignif) < 7) {
492 ATH_MSG_VERBOSE(
"Muon did not pass requirements for tight combined muon");
496 (
summary.nprecisionLayers > 1 ||(
summary.nprecisionLayers == 1 &&
summary.nprecisionHoleLayers < 2 && std::abs(
mu.eta()) < 0.1))
503 ATH_MSG_VERBOSE(
"Muon did not pass requirements for medium combined muon");
509 if ((
summary.nprecisionLayers > 1 ||
510 (
summary.nprecisionLayers == 1 &&
summary.nprecisionHoleLayers < 2 && std::abs(
mu.eta()) < 0.1))) {
526 ATH_MSG_VERBOSE(
"Muon passed selection for loose working point at low pT");
531 ATH_MSG_VERBOSE(
"Did not pass selections for combined muon - returning VeryLoose");
540 ATH_MSG_VERBOSE(
"Standalone muons currently only used when in expert mode for run3");
544 if (std::abs(
mu.eta()) > 2.5) {
555 ATH_MSG_VERBOSE(
"Muon did not pass selection for medium stand-alone muon - return VeryLoose");
560 if (
mu.muonType() == xAOD::Muon::SiliconAssociatedForwardMuon) {
564 ATH_MSG_VERBOSE(
"Silicon-associated forward muon muons currently only used when in expert mode for run3");
569 const xAOD::TrackParticle* metrack =
mu.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle);
571 if (cbtrack && metrack) {
572 if (std::abs(cbtrack->
eta()) > 2.5) {
579 "SiliconForwardAssociated muon has ID track as primary track particle. "
580 <<
"This is a bug fixed starting with xAODMuon-00-17-07, which should be present in this release. "
581 <<
"Please report this to the Muon CP group!");
590 ATH_MSG_VERBOSE(
"Muon did not pass selection for medium silicon-associated forward muon - return VeryLoose");
594 ATH_MSG_VERBOSE(
"Muon did not pass selection for loose/medium/tight for any muon type - return VeryLoose");
606 if (isLRTmuon(
mu))
return true;
613 ATH_MSG_FATAL(
"No information available to tell if the muon is LRT or standard. Either run MuonLRTMergingAlg to decorate with `isLRT` flag, or supply the patternRecoInfo for the original ID track.");
614 throw std::runtime_error(
"MuonSelectionTool() - isLRT decor and patternRecoInfo both unavailable for a muon.");
616 std::bitset<xAOD::NumberOfTrackRecoInfo> patternBitSet(patternAcc(*idtrack));
624 }
else if (
mu.muonType() == xAOD::Muon::SiliconAssociatedForwardMuon) {
626 if (cbtrack && std::abs(cbtrack->
eta()) > 2.5) {
return true; }
629 if (
mu.trackParticle(xAOD::Muon::InnerDetectorTrackParticle))
630 return passedIDCuts(*
mu.trackParticle(xAOD::Muon::InnerDetectorTrackParticle));
631 else if (
mu.primaryTrackParticle())
641 const xAOD::TrackParticle* metrack =
mu.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle);
647 bool IsBadMuon =
false;
648 if (idtrack && metrack && cbtrack) {
650 double qOverP_ID = idtrack->
qOverP();
652 double qOverP_ME = metrack->
qOverP();
654 double qOverP_CB = cbtrack->
qOverP();
667 double IdCbRatio = std::abs((qOverPerr_ID / qOverP_ID) / (qOverPerr_CB / qOverP_CB));
668 double MeCbRatio = std::abs((qOverPerr_ME / qOverP_ME) / (qOverPerr_CB / qOverP_CB));
669 IsBadMuon = (IdCbRatio < 0.8 || MeCbRatio < 0.8 || IsBadMuon);
673 double IdCbRatio = std::abs((qOverPerr_ID / qOverP_ID) / (qOverPerr_CB / qOverP_CB));
674 double MeCbRatio = std::abs((qOverPerr_ME / qOverP_ME) / (qOverPerr_CB / qOverP_CB));
675 IsBadMuon = (IdCbRatio < 0.8 || MeCbRatio < 0.8);
693 ATH_MSG_VERBOSE(
"LowPt WP currently not supported for run3 if not in expert mode");
709 ATH_MSG_VERBOSE(
"Muon is not combined or segment-tagged - fail low-pT");
722 ATH_MSG_VERBOSE(
"Muon is neither MuGirl / MuidCo / MuTagIMO - fail low-pT");
741 ATH_MSG_VERBOSE(
"Not using MVA selection, failing low-pT selection due to medium requirement in forward region");
749 ATH_MSG_VERBOSE(
"Muon has out-of-bounds precision hits - fail low-pT");
757 uint nStationsCut = (std::abs(
mu.eta()) > 1.3 && std::abs(
mu.eta()) < 1.55) ? 2 : 1;
758 if (
summary.nprecisionLayers < nStationsCut) {
759 ATH_MSG_VERBOSE(
"number of precision layers = " << (
int)
summary.nprecisionLayers <<
" is lower than cut value " << nStationsCut
760 <<
" - fail low-pT");
768 ATH_MSG_VERBOSE(
"MuGirl muon is not confirmed by MuTagIMO - fail low-pT");
804 std::vector<const xAOD::MuonSegment*> segments_sorted;
805 segments_sorted.reserve(
mu.nMuonSegments());
807 for (
unsigned int i = 0;
i <
mu.nMuonSegments();
i++) {
808 if (!
mu.muonSegment(
i))
809 ATH_MSG_WARNING(
"The muon reports more segments than are available. Please report this to the muon software community!");
811 segments_sorted.push_back(
mu.muonSegment(
i));
814 std::sort(segments_sorted.begin(), segments_sorted.end(), chamberIndexCompare);
816 return segments_sorted;
822 ATH_MSG_VERBOSE(
"LowPt WP currently not supported for run3 if not in expert mode");
831 float momentumBalanceSig{-1}, CurvatureSig{-1}, energyLoss{-1}, muonSegmentDeltaEta{-1}, scatteringNeigbour{-1};
842 float seg1ChamberIdx{-1.}, seg2ChamberIdx{-1.}, middleHoles{-1.}, seg1NPrecisionHits{-1.}, seg1GlobalR{-1.}, seg1Chi2OverDoF{-1.};
847 ATH_MSG_WARNING(
"passedLowPtEfficiencyMVACut - found segment-tagged muon with no segments!");
849 seg1ChamberIdx = (!muonSegments.empty()) ? muonSegments[0]->chamberIndex() : -9;
850 seg2ChamberIdx = (muonSegments.size() > 1) ? muonSegments[1]->chamberIndex() : -9;
854 seg1NPrecisionHits = (!muonSegments.empty()) ? muonSegments[0]->nPrecisionHits() : -1;
855 seg1GlobalR = (!muonSegments.empty())
856 ? std::hypot(muonSegments[0]->
x(), muonSegments[0]->y(), muonSegments[0]->z())
858 seg1Chi2OverDoF = (!muonSegments.empty()) ? muonSegments[0]->
chiSquared() / muonSegments[0]->numberDoF() : -1;
867 std::vector<float> var_vector;
869 var_vector = {momentumBalanceSig, CurvatureSig, scatteringNeigbour, energyLoss,
870 middleHoles, muonSegmentDeltaEta, seg1ChamberIdx, seg2ChamberIdx};
872 if (std::abs(
mu.eta()) >= 1.3)
873 var_vector = {seg2ChamberIdx, seg1ChamberIdx, seg1NPrecisionHits, muonSegmentDeltaEta,
874 seg1GlobalR, seg1Chi2OverDoF, std::abs(CurvatureSig)};
876 var_vector = {seg1ChamberIdx, seg1NPrecisionHits, muonSegmentDeltaEta,
877 seg1GlobalR, seg1Chi2OverDoF, std::abs(CurvatureSig)};
892 if (std::abs(
mu.eta()) < 0.7)
894 else if (std::abs(
mu.eta()) < 1.3)
900 float BDTdiscriminant;
903 BDTdiscriminant = reader_MUID->EvaluateMVA(var_vector,
"BDTG");
905 BDTdiscriminant = reader_MUGIRL->EvaluateMVA(var_vector,
"BDTG");
907 BDTdiscriminant = reader_MUTAGIMO->EvaluateMVA(var_vector,
"BDT");
909 ATH_MSG_WARNING(
"Invalid author for low-pT MVA, failing selection...");
916 if (BDTdiscriminant > BDTcut) {
942 ATH_MSG_VERBOSE(
"Muon has out-of-bounds precision hits - fail high-pT");
962 ATH_MSG_VERBOSE(
"passedHighPtCuts - No MS track available for muon. Using combined track.");
963 MS_track =
mu.trackParticle(xAOD::Muon::CombinedTrackParticle);
966 if (MS_track && CB_track) {
968 float phiMS = MS_track->
phi();
969 float etaCB = CB_track->
eta();
972 if (!
isRun3() && (std::abs(
etaMS) > 2.0 || std::abs(etaCB) > 2.0)) {
973 if (
summary.cscUnspoiledEtaHits == 0) {
980 if (!
isRun3() &&
mu.eta() < -1.899 && std::abs(
mu.phi()) < 0.211) {
981 ATH_MSG_VERBOSE(
"Muon is in eta/phi region vetoed due to disabled chambers in MC - fail high-pT");
986 if ((1.01 < std::abs(
etaMS) && std::abs(
etaMS) < 1.1) || (1.01 < std::abs(etaCB) && std::abs(etaCB) < 1.1)) {
987 ATH_MSG_VERBOSE(
"Muon is in barrel/endcap overlap region - fail high-pT");
1015 if (
summary.nprecisionLayers < 4) {
1016 ATH_MSG_VERBOSE(
"Muon is in BEE eta/phi region and does not have 4 precision layers - fail high-pT");
1020 if (std::abs(etaCB) > 1.4) {
1024 if (
summary.nprecisionLayers < 4 && (
summary.extendedSmallHits > 0 ||
summary.extendedSmallHoles > 0)) {
1025 ATH_MSG_VERBOSE(
"Muon is in BEE eta/phi region and does not have 4 precision layers - fail high-pT");
1030 ATH_MSG_WARNING(
"passedHighPtCuts - MS or CB track missing in muon! Failing High-pT selection...");
1036 const xAOD::TrackParticle* metrack =
mu.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle);
1041 if (std::abs(qOverPsignif) > 7) {
1053 if (std::abs(
mu.eta()) > 1.2 &&
summary.extendedSmallHits < 3 &&
summary.extendedLargeHits < 3) {
1077 if (
summary.nprecisionLayers < 3) {
1078 ATH_MSG_VERBOSE(
"Muon has less than 3 precision layers - fail high-pT");
1083 if (
summary.isSmallGoodSectors) {
1084 if (!(
summary.innerSmallHits > 2 &&
summary.middleSmallHits > 2 &&
1085 (
summary.outerSmallHits > 2 ||
summary.extendedSmallHits > 2))) {
1086 ATH_MSG_VERBOSE(
"Muon has small/large sectors overlap - fail high-pT");
1090 if (!(
summary.innerLargeHits > 2 &&
summary.middleLargeHits > 2 &&
1091 (
summary.outerLargeHits > 2 ||
summary.extendedLargeHits > 2))) {
1092 ATH_MSG_VERBOSE(
"Muon has small/large sectors overlap - fail high-pT");
1105 double start_cut = 3.0;
1106 double end_cut = 1.6;
1107 double abs_eta = std::abs(
mu.eta());
1110 double p0(8.0), p1(0.), p2(0.);
1117 else if (abs_eta > 1.05 && abs_eta <= 1.3) {
1120 }
else if (abs_eta > 1.3 && abs_eta <= 1.7) {
1123 }
else if (abs_eta > 1.7 && abs_eta <= 2.0) {
1126 }
else if (abs_eta > 2.0) {
1137 else if (abs_eta > 1.05 && abs_eta <= 1.3) {
1140 }
else if (abs_eta > 1.3 && abs_eta <= 1.7) {
1143 }
else if (abs_eta > 1.7 && abs_eta <= 2.0) {
1146 }
else if (abs_eta > 2.0) {
1161 if (abs_eta > 1.05 && abs_eta < 1.3) {
1164 }
else if (abs_eta >= 1.3 && abs_eta < 1.7) {
1167 }
else if (abs_eta >= 1.7 && abs_eta < 2.0) {
1170 }
else if (abs_eta >= 2.0) {
1176 bool passErrorCutCB =
false;
1181 double qOverP_CB = cbtrack->
qOverP();
1187 double a = (end_cut - start_cut) / 4000.0;
1188 double b = end_cut -
a * 5000.0;
1189 double coefficient = (pt_CB > 1000.) ? (
a * pt_CB +
b) : start_cut;
1190 if (std::abs(qOverPerr_CB / qOverP_CB) < coefficient *
sigma) { passErrorCutCB =
true; }
1197 ATH_MSG_DEBUG(
"The current event is a MC event. Use bad muon veto mimic.");
1203 return passErrorCutCB;
1209 if (std::abs(
mu.eta()) < 1.05) {
1219 double qOpRelResolution = std::hypot(p1, p2 *
mu.primaryTrackParticle()->pt() *
MeVtoGeV);
1221 double qOverPabs_unsmeared = std::abs(
mu.primaryTrackParticle()->definingParameters()[4]);
1222 double qOverPabs_smeared = 1.0 / (
mu.pt() * std::cosh(
mu.eta()));
1224 if ((qOverPabs_smeared - qOverPabs_unsmeared) / (qOpRelResolution * qOverPabs_unsmeared) <
1225 cutFunction->Eval(
mu.primaryTrackParticle()->pt() *
MeVtoGeV))
1235 if (
mu.muonType() == xAOD::Muon::CaloTagged && std::abs(
mu.eta()) < 0.105)
1242 if (
mu.muonType() == xAOD::Muon::SiliconAssociatedForwardMuon) {
1244 return (cbtrack && std::abs(cbtrack->
eta()) > 2.4);
1255 " !! Tool configured with some of the ID hits requirements changed... FOR DEVELOPMENT ONLY: muon efficiency SF won't be "
1260 if ((value1 + value2 == 0) && !
m_PixCutOff)
return false;
1264 if ((value1 + value2 <= 4) && !
m_SctCutOff)
return false;
1271 const float abseta = std::abs(
track.eta());
1274 const uint8_t totTRThits = value1 + value2;
1275 if (!((0.1 < abseta && abseta <= 1.9 && totTRThits > 5 && value2 < (0.9 * totTRThits)) || (abseta <= 0.1 || abseta > 1.9)))
1290 int CaloMuonIDTag = -20;
1293 bool readID =
mu.parameter(CaloMuonIDTag, xAOD::Muon::CaloMuonIDTag);
1295 ATH_MSG_WARNING(
"Unable to read CaloMuonIDTag Quality information! Rejecting the CALO muon!");
1300 return (CaloMuonIDTag > 10);
1308 float CaloMuonScore{-999.0};
1319 return (CaloMuonScore >= 0.77);
1335 ATH_MSG_VERBOSE(
"for run3, Tight WP is only supported when ExcludeNSWFromPrecisionLayers=False and RecalcPrecisionLayerswNSW=True");
1338 float symmetric_eta = std::abs(
mu.eta());
1342 if (pt < 4.0 || symmetric_eta >= 2.5)
return false;
1343 ATH_MSG_VERBOSE(
"Muon is passing tight WP kinematic cuts with pT,eta " <<
mu.pt() <<
" , " <<
mu.eta());
1350 ATH_MSG_VERBOSE(
"Applying tight WP cuts to a low pt muon with (pt,eta) ( " <<
pt <<
" , " <<
mu.eta() <<
" ) ");
1352 ATH_MSG_VERBOSE(
"Momentum significance value " << oneOverPSig <<
", required to be less than " << qOverPCut);
1354 if (
rho > rhoCut)
return false;
1357 if (oneOverPSig > qOverPCut)
return false;
1358 ATH_MSG_VERBOSE(
"Muon passed tight WP, low pT momentum significance cut");
1366 else if (
pt < 100.0) {
1369 ATH_MSG_VERBOSE(
"Applying tight WP cuts to a medium pt muon with (pt,eta) (" <<
pt <<
"," <<
mu.eta() <<
")");
1373 if (
rho > rhoCut)
return false;
1381 else if (
pt < 500.0) {
1383 ATH_MSG_VERBOSE(
"Applying tight WP cuts to a high pt muon with (pt,eta) (" <<
pt <<
"," <<
mu.eta() <<
")");
1386 ATH_MSG_VERBOSE(
"Rho value " <<
rho <<
", required to be less than " << rhoCut <<
" unless -1, in which no cut is applied");
1388 if (rhoCut < 0.0)
return true;
1389 if (
rho > rhoCut)
return false;
1396 ATH_MSG_VERBOSE(
"Not applying any tight WP cuts to a very high pt muon with (pt,eta) (" <<
pt <<
"," <<
mu.eta() <<
")");
1428 if (std::abs(
muon.eta()) > 2.0) {
1429 ATH_MSG_VERBOSE(
"Recalculating number of precision layers for combined muon");
1438 + (
summary.extendedSmallHits > 2 ||
summary.extendedLargeHits > 2);
1442 if (!eta1stgchits_acc.isAvailable(
muon) || !eta2stgchits_acc.isAvailable(
muon) || !mmhits_acc.isAvailable(
muon)) {
1443 ATH_MSG_FATAL(__FILE__ <<
":" << __LINE__ <<
" Failed to retrieve NSW hits!"
1444 <<
" (Please use DxAODs with p-tags >= p5834 OR set ExcludeNSWFromPrecisionLayers to True (tests only)");
1445 throw std::runtime_error(
"Failed to retrieve NSW hits");
1459 ATH_MSG_FATAL(__FILE__ <<
":" << __LINE__ <<
" Failed to retrieve parameter " << param
1460 <<
" for muon with pT:" <<
muon.pt() *
MeVtoGeV <<
", eta:" <<
muon.eta() <<
", phi: " <<
muon.phi()
1461 <<
", q:" <<
muon.charge() <<
", author: " <<
muon.author());
1462 throw std::runtime_error(
"Failed to retrieve Parameter");
1477 if (
summary.nprecisionLayers == 2)
1478 return ResolutionCategory::highPt2station;
1486 ATH_MSG_VERBOSE(
"getResolutionCategory - No MS track available for muon. Using combined track.");
1487 MS_track =
mu.trackParticle(xAOD::Muon::CombinedTrackParticle);
1491 const float etaMS = MS_track->
eta();
1492 const float etaCB = CB_track->
eta();
1493 const float phiMS = MS_track->
phi();
1498 category = ResolutionCategory::missingInner;
1501 category = ResolutionCategory::missingMiddle;
1505 category = ResolutionCategory::missingOuter;
1507 if (!
isRun3() && (std::abs(
etaMS) > 2.0 || std::abs(etaCB) > 2.0) &&
summary.cscUnspoiledEtaHits == 0)
1508 category = ResolutionCategory::spoiledCSC;
1510 if ((1.01 < std::abs(
etaMS) && std::abs(
etaMS) < 1.1) || (1.01 < std::abs(etaCB) && std::abs(etaCB) < 1.1))
1511 category = ResolutionCategory::BEoverlap;
1516 if (
isBEE(
etaMS, phiMS) || (std::abs(etaCB) > 1.4 && (
summary.extendedSmallHits > 0 ||
summary.extendedSmallHoles > 0))) {
1518 category = ResolutionCategory::missingBEE;
1520 if (
summary.extendedSmallHits >= 3 &&
summary.outerSmallHits < 3)
category = ResolutionCategory::missingOuter;
1522 if (!
summary.isSmallGoodSectors)
1526 if (
summary.nprecisionLayers == 1)
category = ResolutionCategory::oneStation;
1541 ATH_MSG_DEBUG(
"The current event is a data event. Return runNumber.");
1547 static std::atomic<bool> issuedWarningPRW{
false};
1549 unsigned int rn = acc_rnd(*eventInfo);
1550 if (
rn != 0)
return acc_rnd(*eventInfo);
1552 if (!issuedWarningPRW) {
1554 issuedWarningPRW =
true;
1559 if (needOnlyCorrectYear) {
1561 ATH_MSG_DEBUG(
"Random run number not available and this is mc16a or mc20a, returning dummy 2016 run number.");
1564 }
else if (eventInfo->
runNumber() < 310000) {
1565 ATH_MSG_DEBUG(
"Random run number not available and this is mc16d or mc20d, returning dummy 2017 run number.");
1568 }
else if (eventInfo->
runNumber() < 320000) {
1569 ATH_MSG_DEBUG(
"Random run number not available and this is mc16e or mc20e, returning dummy 2018 run number.");
1572 }
else if (eventInfo->
runNumber() < 500000) {
1573 ATH_MSG_DEBUG(
"Random run number not available and this is mc21/mc23, for the time being we're returing a dummy run number.");
1577 ATH_MSG_FATAL(
"Random run number not available, fallback option of using runNumber failed since "<<eventInfo->
runNumber()<<
" cannot be recognised");
1578 throw std::runtime_error(
"MuonSelectionTool() - need RandomRunNumber decoration by the PileupReweightingTool");
1581 ATH_MSG_FATAL(
"Failed to find the RandomRunNumber decoration by the PileupReweightingTool");
1582 throw std::runtime_error(
"MuonSelectionTool() - need RandomRunNumber decoration from PileupReweightingTool");
1588 static constexpr std::array<float, 2> BIS78_eta{1.05, 1.3};
1589 static constexpr std::array<float, 8> BIS78_phi{0.21, 0.57, 1.00, 1.33, 1.78, 2.14, 2.57, 2.93};
1591 float abs_eta = std::abs(
eta);
1592 float abs_phi = std::abs(
phi);
1594 if (abs_eta >= BIS78_eta[0] && abs_eta <= BIS78_eta[1]) {
1595 if ((abs_phi >= BIS78_phi[0] && abs_phi <= BIS78_phi[1]) || (abs_phi >= BIS78_phi[2] && abs_phi <= BIS78_phi[3]) ||
1596 (abs_phi >= BIS78_phi[4] && abs_phi <= BIS78_phi[5]) || (abs_phi >= BIS78_phi[6] && abs_phi <= BIS78_phi[7])) {
1606 static constexpr std::array<float, 2> BEE_eta{1.440, 1.692};
1607 static constexpr std::array<float, 8> BEE_phi{0.301, 0.478, 1.086, 1.263, 1.872, 2.049, 2.657, 2.834};
1609 float abs_eta = std::abs(
eta);
1610 float abs_phi = std::abs(
phi);
1612 if (abs_eta >= BEE_eta[0] && abs_eta <= BEE_eta[1]) {
1613 if ((abs_phi >= BEE_phi[0] && abs_phi <= BEE_phi[1]) || (abs_phi >= BEE_phi[2] && abs_phi <= BEE_phi[3]) ||
1614 (abs_phi >= BEE_phi[4] && abs_phi <= BEE_phi[5]) || (abs_phi >= BEE_phi[6] && abs_phi <= BEE_phi[7])) {
1624 static constexpr std::array<float, 6> BMG_eta{0.35, 0.47, 0.68, 0.80, 0.925, 1.04};
1625 static constexpr std::array<float, 4> BMG_phi{-1.93, -1.765, -1.38, -1.21};
1627 float abs_eta = std::abs(
eta);
1629 if ((abs_eta >= BMG_eta[0] && abs_eta <= BMG_eta[1]) || (abs_eta >= BMG_eta[2] && abs_eta <= BMG_eta[3]) ||
1630 (abs_eta >= BMG_eta[4] && abs_eta <= BMG_eta[5])) {
1631 if ((
phi >= BMG_phi[0] &&
phi <= BMG_phi[1]) || (
phi >= BMG_phi[2] &&
phi <= BMG_phi[3])) {
return true; }