ATLAS Offline Software
MuonPhysValMonitoringTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // MuonPhysValMonitoringTool.cxx
6 // Implementation file for class MuonPhysValMonitoringTool
7 // Author: S.Binet<binet@cern.ch>
9 
10 // PhysVal includes
12 
14 
16 
17 
18 #include "xAODTrigger/MuonRoI.h"
20 
24 
25 #include "TString.h"
26 
27 #include <cmath>
28 #include <limits>
29 #include <format>
30 
31 namespace{
34  using MuonSegmentLink = ElementLink<xAOD::MuonSegmentContainer>;
36 
37  constexpr int comm_bit = (1<<xAOD::Muon::Commissioning);
38 }
39 using namespace xAOD::P4Helpers;
40 
42 
44  // Public methods:
46  template <class ContType> StatusCode MuonPhysValMonitoringTool::retrieveContainer(const EventContext& ctx,
48  const ContType* & container) const{
49  container = nullptr;
50  if (key.empty()) {
51  ATH_MSG_DEBUG("No key of type "<<typeid(ContType).name()<<" has been parsed");
52  return StatusCode::SUCCESS;
53  }
54  SG::ReadHandle readHandle{key,ctx};
55  if (!readHandle.isPresent()) {
56  ATH_MSG_ERROR("Failed to retrieve "<<key.fullKey()<<". Please check.");
57  return StatusCode::FAILURE;
58  }
59  container = readHandle.cptr();
60  return StatusCode::SUCCESS;
61  }
62 
63  // Athena algtool's Hooks
66  ATH_MSG_INFO("Initializing " << name() << "...");
68 
69  for (unsigned int i = 0; i < m_selectHLTMuonItems.size(); i++) {
70  if (m_selectHLTMuonItems[i][0] == "" || m_selectHLTMuonItems[i][1] == "") continue;
71  m_muonItems.emplace_back(m_selectHLTMuonItems[i][0]);
72  m_L1Seed.emplace_back(m_selectHLTMuonItems[i][1]);
73  }
74 
75  // setup flags
76  if (m_doTrigMuonValidation == false) {
77  m_doTrigMuonL1Validation = false;
78  m_doTrigMuonL2Validation = false;
79  m_doTrigMuonEFValidation = false;
80  }
81  ATH_CHECK(m_trigDec.retrieve(DisableTool{!m_doTrigMuonValidation}));
82 
83  ATH_CHECK(m_eventInfo.initialize());
84  ATH_CHECK(m_muonSelectionTool.retrieve());
85  ATH_CHECK(m_trackSelector.retrieve());
86  ATH_CHECK(m_isoTool.retrieve());
87 
88  ATH_CHECK(m_tracksName.initialize());
89  ATH_CHECK(m_fwdtracksName.initialize(!m_fwdtracksName.empty()));
90  ATH_CHECK(m_muonsName.initialize());
91  ATH_CHECK(m_slowMuonsName.initialize(!m_slowMuonsName.empty()));
92 
93  ATH_CHECK(m_muonTracksName.initialize());
94  ATH_CHECK(m_muonExtrapolatedTracksName.initialize());
95  ATH_CHECK(m_muonMSOnlyExtrapolatedTracksName.initialize());
96 
97  ATH_CHECK(m_muonSegmentsName.initialize());
98  ATH_CHECK(m_muonsTruthName.initialize(!m_isData));
99  ATH_CHECK(m_muonSegmentsTruthName.initialize(!m_isData));
100  ATH_CHECK(m_muonL1TrigName.initialize(m_doTrigMuonL1Validation));
101  ATH_CHECK(m_muonL2SAName.initialize(m_doTrigMuonL2Validation));
102  ATH_CHECK(m_muonL2CBName.initialize(m_doTrigMuonL2Validation));
103  ATH_CHECK(m_muonEFCombTrigName.initialize(m_doTrigMuonEFValidation));
104 
105  if (!m_isData) {
106  const std::vector<std::string> truthDecors{"truthOrigin", "truthType", "truthParticleLink"};
107  const std::vector<std::string> keys{m_tracksName.key(), m_fwdtracksName.key(), m_muonsName.key(),
108  m_slowMuonsName.key(), m_muonTracksName.key(), m_muonExtrapolatedTracksName.key(),
109  m_muonMSOnlyExtrapolatedTracksName.key()};
110  for (const std::string& key : keys) {
111  if (key.empty()) continue;
112  for (const std::string& decor : truthDecors){
113  m_decorDep.emplace_back(std::format("{:}.{:}", key , decor));
114  }
115  }
116  const std::vector<std::string> truthPartDecors{"MuonEntryLayer_px", "nprecLayers",
117  "truthOrigin", "truthType"};
118 
119  for (const std::string& decor: truthPartDecors) {
120  m_decorDep.emplace_back(m_muonsTruthName, decor);
121  }
122 
123 
124 
125  }
126 
127  ATH_CHECK(m_decorDep.initialize());
128  return StatusCode::SUCCESS;
129  }
130 
131 
132 
133  StatusCode MuonPhysValMonitoringTool::bookHistograms() {
134  ATH_MSG_INFO("Booking hists " << name() << "...");
135 
136  if (m_selectMuonWPs.size() == 1 && m_selectMuonWPs[0] < 0) m_selectMuonWPs.clear();
137 
138  if (m_selectMuonAuthors.size() == 1 && m_selectMuonAuthors[0] == 0) m_selectMuonAuthors.clear();
139 
140  static const std::map<int,std::string> theMuonCategories = {
141  {ALL, "All"},
142  {PROMPT, "Prompt"},
143  {INFLIGHT, "InFlight"},
144  {NONISO, "NonIsolated"},
145  {REST, "Rest"}
146  };
147 
148  for (const auto& category : m_selectMuonCategories) m_selectMuonCategoriesStr.emplace_back(theMuonCategories.at(category));
149 
150  // no such muons in case of SlowMuon reco
151  bool separateSAFMuons = m_slowMuonsName.empty();
152 
153  std::string muonContainerName = m_muonsName.key();
154  for (const auto& category : m_selectMuonCategoriesStr) {
155  std::string categoryPath = muonContainerName + "/" + category + "/";
156 
157  m_muonValidationPlots.emplace_back(std::make_unique<MuonValidationPlots>(
158  nullptr, categoryPath, m_selectMuonWPs, m_selectMuonAuthors, m_isData,
159  (category == theMuonCategories.at(ALL) ? false : m_doBinnedResolutionPlots.value()), separateSAFMuons, false));
160 
161  if (!m_slowMuonsName.empty()) m_slowMuonValidationPlots.emplace_back(std::make_unique<SlowMuonValidationPlots>(nullptr, categoryPath, m_isData));
162  if (m_doTrigMuonValidation) {
163  if (category == "All") {
164  m_TriggerMuonValidationPlots.emplace_back(std::make_unique<TriggerMuonValidationPlots>(
165  nullptr, categoryPath, m_selectMuonAuthors, m_isData, m_doTrigMuonL1Validation, m_doTrigMuonL2Validation,
166  m_doTrigMuonEFValidation, m_selectHLTMuonItems, m_L1MuonItems));
167  }
168  }
169  if (!m_muonTracksName.empty()) {
170  m_muonMSTrackValidationPlots.emplace_back(std::make_unique<MuonTrackValidationPlots>(nullptr, categoryPath, "MSTrackParticles", m_isData));
171  if (!m_isData)
172  m_oUnmatchedRecoMuonTrackPlots = std::make_unique<Muon::RecoMuonTrackPlotOrganizer>(nullptr, muonContainerName + "/UnmatchedRecoMuonTracks/");
173  }
174  if (!m_muonExtrapolatedTracksName.empty())
175  m_muonMETrackValidationPlots.emplace_back(std::make_unique<MuonTrackValidationPlots>(nullptr, categoryPath, "METrackParticles", m_isData));
176  if (!m_muonMSOnlyExtrapolatedTracksName.empty())
177  m_muonMSOnlyMETrackValidationPlots.emplace_back(
178  std::make_unique<MuonTrackValidationPlots>(nullptr, categoryPath, "MSOnlyMETrackParticles", m_isData));
179 
180  if (!m_tracksName.empty()) {
181  m_muonIDTrackValidationPlots.emplace_back(std::make_unique<MuonTrackValidationPlots>(nullptr, categoryPath, "IDTrackParticles", m_isData));
182  m_muonIDSelectedTrackValidationPlots.emplace_back(
183  std::make_unique<MuonTrackValidationPlots>(nullptr, categoryPath, "IDSelectedTrackParticles", m_isData));
184  }
185  if (!m_fwdtracksName.empty())
186  m_muonIDForwardTrackValidationPlots.emplace_back(
187  std::make_unique<MuonTrackValidationPlots>(nullptr, categoryPath, "IDForwardTrackParticles", m_isData));
188 
189  if (!m_muonSegmentsName.empty()) {
190  if (category != theMuonCategories.at(ALL)) continue; // cannot identify the truth origin of segments...
191  m_muonSegmentValidationPlots.emplace_back(std::make_unique<MuonSegmentValidationPlots>(nullptr, categoryPath, m_isData));
192  if (!m_isData)
193  m_oUnmatchedRecoMuonSegmentPlots.reset(
194  new Muon::MuonSegmentPlots(nullptr, Form("%s/UnmatchedRecoMuonSegments/", muonContainerName.c_str())));
195  }
196  }
197 
198  if (!m_isData) {
199  m_oUnmatchedRecoMuonPlots = std::make_unique<Muon::RecoMuonPlotOrganizer>(nullptr, muonContainerName +"/UnmatchedRecoMuons/");
200  m_oUnmatchedTruthMuonPlots = std::make_unique<Muon::TruthMuonPlotOrganizer>(nullptr, muonContainerName +"/UnmatchedTruthMuons/");
201  }
202 
203  for (const auto& plots : m_muonValidationPlots) bookValidationPlots(*plots).ignore();
204  for (const auto& plots : m_slowMuonValidationPlots) bookValidationPlots(*plots).ignore();
205  for (const auto& plots : m_TriggerMuonValidationPlots) bookValidationPlots(*plots).ignore();
206  for (const auto& plots : m_muonIDTrackValidationPlots) bookValidationPlots(*plots).ignore();
207  for (const auto& plots : m_muonIDSelectedTrackValidationPlots) bookValidationPlots(*plots).ignore();
208  for (const auto& plots : m_muonIDForwardTrackValidationPlots) bookValidationPlots(*plots).ignore();
209  for (const auto& plots : m_muonMSTrackValidationPlots) bookValidationPlots(*plots).ignore();
210  for (const auto& plots : m_muonMETrackValidationPlots) bookValidationPlots(*plots).ignore();
211  for (const auto& plots : m_muonMSOnlyMETrackValidationPlots) bookValidationPlots(*plots).ignore();
212  if (!m_isData) {
213  bookValidationPlots(*m_oUnmatchedRecoMuonPlots).ignore();
214  bookValidationPlots(*m_oUnmatchedTruthMuonPlots).ignore();
215  if (m_oUnmatchedRecoMuonTrackPlots) bookValidationPlots(*m_oUnmatchedRecoMuonTrackPlots).ignore();
216  for (const auto& plots : m_muonSegmentValidationPlots) bookValidationPlots(*plots).ignore();
217  if (m_oUnmatchedRecoMuonSegmentPlots) bookValidationPlots(*m_oUnmatchedRecoMuonSegmentPlots).ignore();
218  }
219  // book overview hists
220  m_h_overview_Z_mass = new TH1F(Form("%s_Overview_Z_mass", muonContainerName.c_str()), "", 20, 76, 106);
221  ATH_CHECK(regHist(m_h_overview_Z_mass, Form("%s/Overview", muonContainerName.c_str()), all));
222  m_h_overview_Z_mass_ME = new TH1F(Form("%s_Overview_Z_mass_ME", muonContainerName.c_str()), "", 20, 76, 106);
223  ATH_CHECK(regHist(m_h_overview_Z_mass_ME, Form("%s/Overview", muonContainerName.c_str()), all));
224  m_h_overview_Z_mass_ID = new TH1F(Form("%s_Overview_Z_mass_ID", muonContainerName.c_str()), "", 20, 76, 106);
225  ATH_CHECK(regHist(m_h_overview_Z_mass_ID, Form("%s/Overview", muonContainerName.c_str()), all));
226 
227  m_h_overview_nObjects.clear();
228  m_h_overview_nObjects.emplace_back(new TH1F(Form("%s_Overview_N_perevent_truth_muons", muonContainerName.c_str()),
229  "Number of truth Muons per event", 20, -0.5, 19.5));
230  m_h_overview_nObjects.emplace_back(
231  new TH1F(Form("%s_Overview_N_perevent_muons", muonContainerName.c_str()), "Number of Muons per event", 20, -0.5, 19.5));
232  m_h_overview_nObjects.emplace_back(
233  new TH1F(Form("%s_Overview_N_perevent_tracks", muonContainerName.c_str()), "Number of Tracks per event", 50, -0.5, 49.5));
234  m_h_overview_nObjects.emplace_back(new TH1F(Form("%s_Overview_N_perevent_truth_segments", muonContainerName.c_str()),
235  "Number of truth Segments per event", 200, -0.5, 199.5));
236  m_h_overview_nObjects.emplace_back(
237  new TH1F(Form("%s_Overview_N_perevent_segments", muonContainerName.c_str()), "Number of Segments per event", 200, -0.5, 199.5));
238  for (const auto& hist : m_h_overview_nObjects) {
239  if (hist) ATH_CHECK(regHist(hist, Form("%s/Overview", muonContainerName.c_str()), all));
240  }
241 
242  m_h_overview_reco_category =
243  new TH1F(Form("%s_Overview_reco_category", muonContainerName.c_str()), "", 4, 0, 4); // prompt/in-flight/non-isolated/other
244  for (int i = 1; i < 4; i++) { // skip 'All'
245  m_h_overview_reco_category->GetXaxis()->SetBinLabel(i, theMuonCategories.at(i).c_str());
246  }
247  m_h_overview_reco_category->GetXaxis()->SetBinLabel(4, "Other"); // of some other origin or fakes
248  ATH_CHECK(regHist(m_h_overview_reco_category, Form("%s/Overview", muonContainerName.c_str()), all));
249 
251  for (int i = 1; i < 4; i++) {
252  m_h_overview_reco_authors.emplace_back(new TH1F((muonContainerName + "_" + theMuonCategories.at(i) + "_reco_authors").c_str(),
253  (muonContainerName + "_" + theMuonCategories.at(i) + "_reco_authors").c_str(),
254  nAuth + 1, -0.5, nAuth + 0.5));
255  }
256  m_h_overview_reco_authors.emplace_back(new TH1F((muonContainerName + "_Overview_Other_reco_authors").c_str(),
257  (muonContainerName + "_Other_reco_authors").c_str(), nAuth + 1, -0.5, nAuth + 0.5));
258 
259  for (const auto& hist : m_h_overview_reco_authors) {
260  if (hist) ATH_CHECK(regHist(hist, Form("%s/Overview", muonContainerName.c_str()), all));
261  }
262 
263  return StatusCode::SUCCESS;
264  }//bookHistograms*/
265 
266  StatusCode MuonPhysValMonitoringTool::bookValidationPlots(PlotBase& valPlots) {
267  valPlots.initialize();
268  std::vector<HistData> hists = valPlots.retrieveBookedHistograms();
269 
270  for (auto& hist : hists) {
271  TString sHistName = hist.first->GetName();
272  ATH_MSG_VERBOSE("Initializing " << hist.first << " " << sHistName << " " << hist.second << "...");
273 
274  // check for histograms that are useless and skip regHist:
275  if (sHistName.Contains("momentumPulls")) {
276  if (sHistName.Contains(Muon::EnumDefs::toString(xAOD::Muon::MuidSA))) continue; // empty for standalone muons
277  if (!(sHistName.Contains("Prompt") && (sHistName.Contains("AllMuons") || sHistName.Contains("SiAssocForward"))))
278  continue; // don't need binned eloss plots for separate muon types, keep only for Prompt AllMuons
279  }
280  if ((sHistName.Contains("resolution") || sHistName.Contains("pulls")) && !sHistName.Contains("Prompt"))
281  continue; // don't need resolution plots except for prompt muons
282  if (sHistName.Contains("trigger") && sHistName.Contains("wrt") && sHistName.Contains("Features")) continue;
283  modifyHistogram(hist.first);
284  ATH_CHECK(regHist(hist.first, hist.second, all));
285  }
286 
287  // register trees
288  std::vector<TreeData> trees = valPlots.retrieveBookedTrees();
289  for (auto& tree : trees) {
290  std::string sTreeName = tree.first->GetName();
291  ATH_MSG_VERBOSE("Initializing " << tree.first << " " << sTreeName << " " << tree.second << "...");
292  ATH_CHECK(regTree(tree.first, tree.second, all));
293  }
294 
295  return StatusCode::SUCCESS;
296  }
297 
298  StatusCode MuonPhysValMonitoringTool::fillHistograms() {
299  ATH_MSG_DEBUG("Filling hists " << name() << "...");
300  m_vMatchedTruthMuons.clear();
301  m_vMatchedMuons.clear();
302  m_vMatchedSlowMuons.clear();
303  m_vMatchedMuonTracks.clear();
304  m_vMatchedMuonSegments.clear();
305  m_vZmumuIDTracks.clear();
306  m_vZmumuMETracks.clear();
307  m_vZmumuMuons.clear();
308  m_vEFMuons.clear();
309  m_vEFMuonsSelected.clear();
310  m_vL2SAMuons.clear();
311  m_vL2SAMuonsSelected.clear();
312  m_vL2CBMuons.clear();
313  m_vL2CBMuonsSelected.clear();
314  m_vRecoMuons.clear();
315  m_vRecoMuons_EffDen.clear();
316  m_vRecoMuons_EffDen_CB.clear();
317  m_vRecoMuons_EffDen_MS.clear();
318 
319  const EventContext& ctx{Gaudi::Hive::currentContext()};
320  const xAOD::EventInfo* eventInfo{nullptr};
321  ATH_CHECK(retrieveContainer(ctx, m_eventInfo, eventInfo));
322 
323  float beamSpotWeight = eventInfo->beamSpotWeight();
324 
325  const xAOD::TruthParticleContainer* TruthMuons{nullptr};
326  ATH_CHECK(retrieveContainer(ctx, m_muonsTruthName, TruthMuons));
327 
328  if (!m_isData) {
329  m_h_overview_nObjects[0]->Fill(TruthMuons->size(), beamSpotWeight);
330  }
331 
332  const xAOD::MuonContainer* Muons = nullptr;
333  const xAOD::SlowMuonContainer* SlowMuons{nullptr};
334  ATH_CHECK(retrieveContainer(ctx, m_slowMuonsName, SlowMuons));
335  ATH_CHECK(retrieveContainer(ctx, m_muonsName, Muons));
336  if (SlowMuons) {
337  ATH_MSG_DEBUG("Retrieved slow muons " << SlowMuons->size());
338  m_h_overview_nObjects[1]->Fill(SlowMuons->size(), beamSpotWeight);
339  }
340  if (Muons) {
341  ATH_MSG_DEBUG("Retrieved muons " << Muons->size());
342  m_h_overview_nObjects[1]->Fill(Muons->size(), beamSpotWeight);
343  }
344 
346  // @@@ Temp hack to get the MuonSpectrometerTrackParticle (@MS Entry, not extrapolated), needed for eloss plots
347  // Remove when the link to the real MuonSpectrometerTrackParticle appears in the xAOD muon
348  ATH_CHECK(retrieveContainer(ctx, m_muonTracksName, m_MSTracks));
350 
351  // Do resonance selection
352  std::vector<std::pair<const xAOD::Muon*, const xAOD::Muon*> > pairs;
353  if (Muons) {
354  // Use iterator loop to avoid double counting
355  for (xAOD::MuonContainer::const_iterator mu1_itr = Muons->begin(); mu1_itr != Muons->end(); ++mu1_itr) {
356  const xAOD::Muon* mu1 = (*mu1_itr);
357  if (!m_selectComissioning && mu1->allAuthors() & comm_bit) continue;
358  for (xAOD::MuonContainer::const_iterator mu2_itr = Muons->begin(); mu2_itr != mu1_itr; ++mu2_itr) {
359  const xAOD::Muon* mu2 = (*mu2_itr);
360  if (!m_selectComissioning && mu2->allAuthors() & comm_bit) continue;
361  if (mu1->charge() * mu2->charge() >= 0) continue;
362  pairs.emplace_back(std::make_pair(mu1, mu2));
363  }
364  }
365  }
366 
367  float dMmin {1e10}, mZ{0.};
368  for (std::pair<const xAOD::Muon*, const xAOD::Muon*>& x : pairs) {
369  // select best Z
370  const TLorentzVector mu1{x.first->p4()}, mu2{x.second->p4()};
371  const float M = (mu1 + mu2).M();
372  if (M < 66000. || M > 116000.) continue;
373 
374  // choose the Z candidate closest to the Z pole - if multiple exist
375  float dM = std::abs(M - 91187.);
376  if (dM > dMmin) continue;
377  dMmin = dM;
378  mZ = M;
379 
380  m_vZmumuMuons.clear();
381  m_vZmumuMuons.emplace_back(x.first);
382  m_vZmumuMuons.emplace_back(x.second);
383  }
384 
385  if (m_vZmumuMuons.size() == 2) {
386  m_h_overview_Z_mass->Fill(mZ / 1000., beamSpotWeight);
387 
388  const xAOD::TrackParticle* metr1 = m_vZmumuMuons[0]->trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle);
389  const xAOD::TrackParticle* metr2 = m_vZmumuMuons[1]->trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle);
390  if (metr1 && metr2) {
391  const TLorentzVector mu1ME{metr1->p4()}, mu2ME{metr2->p4()};
392  m_h_overview_Z_mass_ME->Fill((mu1ME + mu2ME).M() / 1000., beamSpotWeight);
393  if (m_isData) {
394  m_vZmumuMETracks.clear();
395  m_vZmumuMETracks.emplace_back(metr1);
396  m_vZmumuMETracks.emplace_back(metr2);
397  }
398  }
399 
400  const xAOD::TrackParticle* tr1 = m_vZmumuMuons[0]->trackParticle(xAOD::Muon::InnerDetectorTrackParticle);
401  const xAOD::TrackParticle* tr2 = m_vZmumuMuons[1]->trackParticle(xAOD::Muon::InnerDetectorTrackParticle);
402  if (tr1 && tr2) {
403  const TLorentzVector mu1ID{tr1->p4()}, mu2ID{tr2->p4()};
404  m_h_overview_Z_mass_ID->Fill((mu1ID + mu2ID).M() / 1000., beamSpotWeight);
405  if (m_isData) {
406  m_vZmumuIDTracks.clear();
407  m_vZmumuIDTracks.emplace_back(tr1);
408  m_vZmumuIDTracks.emplace_back(tr2);
409  }
410  }
411  }
412 
413  if (!m_isData) {
414  for (const auto truthMu : *TruthMuons) handleTruthMuon(truthMu, beamSpotWeight);
415  }
416 
417  if (SlowMuons) {
418  for (const auto smu : *SlowMuons) {
419  if (!smu) continue;
420  const MuonLink link = smu->muonLink();
421  if (!link.isValid()) continue;
422  handleMuon(*link, smu, beamSpotWeight);
423  }
424  }
425  if (Muons) {
426  for (const xAOD::Muon* mu : *Muons) {
427  handleMuon(mu, nullptr, beamSpotWeight);
428  }
429  }
430 
431  const xAOD::TrackParticleContainer* IDTracks{nullptr};
432  ATH_CHECK(retrieveContainer(ctx, m_tracksName, IDTracks));
433  if (IDTracks) {
434  ATH_MSG_DEBUG("handling " << IDTracks->size() << " " << m_tracksName);
435  for (const auto tp : *IDTracks) handleMuonTrack(tp, xAOD::Muon::InnerDetectorTrackParticle, beamSpotWeight);
436  }
437  const xAOD::TrackParticleContainer* FwdIDTracks{nullptr};
438  ATH_CHECK(retrieveContainer(ctx, m_fwdtracksName, IDTracks));
439  if (FwdIDTracks) {
440  ATH_MSG_DEBUG("handling " << FwdIDTracks->size() << " " << m_fwdtracksName);
441  for (const auto tp : *FwdIDTracks) handleMuonTrack(tp, xAOD::Muon::InnerDetectorTrackParticle, beamSpotWeight);
442  }
443  const xAOD::TrackParticleContainer* MuonTracks{nullptr};
444  ATH_CHECK(retrieveContainer(ctx, m_muonTracksName, MuonTracks));
445  if (MuonTracks) {
446  ATH_MSG_DEBUG("handling " << MuonTracks->size() << " " << m_muonTracksName);
447  m_h_overview_nObjects[2]->Fill(MuonTracks->size(), beamSpotWeight);
448  for (const auto tp : *MuonTracks) handleMuonTrack(tp, xAOD::Muon::MuonSpectrometerTrackParticle, beamSpotWeight);
449  }
450  const xAOD::TrackParticleContainer* MuonExtrapolatedTracks{nullptr};
451  ATH_CHECK(retrieveContainer(ctx, m_muonExtrapolatedTracksName, MuonExtrapolatedTracks));
452  if (MuonExtrapolatedTracks) {
453  ATH_MSG_DEBUG("handling " << MuonExtrapolatedTracks->size() << " " << m_muonExtrapolatedTracksName);
454  for (const auto tp : *MuonExtrapolatedTracks)
455  handleMuonTrack(tp, xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle, beamSpotWeight);
456  }
457  const xAOD::TrackParticleContainer* MSOnlyMuonExtrapolatedTracks{nullptr};
458  ATH_CHECK(retrieveContainer(ctx, m_muonMSOnlyExtrapolatedTracksName, MSOnlyMuonExtrapolatedTracks));
459 
460  if (MSOnlyMuonExtrapolatedTracks) {
461  ATH_MSG_DEBUG("handling " << MSOnlyMuonExtrapolatedTracks->size() << " " << m_muonMSOnlyExtrapolatedTracksName);
462  for (const auto tp : *MSOnlyMuonExtrapolatedTracks)
463  handleMuonTrack(tp, xAOD::Muon::MSOnlyExtrapolatedMuonSpectrometerTrackParticle, beamSpotWeight);
464  }
465 
466  const xAOD::MuonSegmentContainer* TruthMuonSegments{nullptr};
467  ATH_CHECK(retrieveContainer(ctx, m_muonSegmentsTruthName, TruthMuonSegments));
468  if (TruthMuonSegments) {
469  m_h_overview_nObjects[3]->Fill(TruthMuonSegments->size(), beamSpotWeight);
470  ATH_MSG_DEBUG("handling " << TruthMuonSegments->size() << " " << m_muonSegmentsTruthName);
471  for (const auto truthMuSeg : *TruthMuonSegments) handleTruthMuonSegment(truthMuSeg, TruthMuons, beamSpotWeight);
472  }
473 
474  const xAOD::MuonSegmentContainer* MuonSegments{nullptr};
475  ATH_CHECK(retrieveContainer(ctx, m_muonSegmentsName, MuonSegments));
476  if (MuonSegments) {
477  m_h_overview_nObjects[4]->Fill(MuonSegments->size(), beamSpotWeight);
478  ATH_MSG_DEBUG("handling " << MuonSegments->size() << " " << m_muonSegmentsName);
479  for (const auto muSeg : *MuonSegments) handleMuonSegment(muSeg, beamSpotWeight);
480  }
481 
482  //@@@@@@@@@@@@@@@@ TRIGGER MONITORING IMPLEMENTATION @@@@@@@@@@@@@@@@@
483  if (m_doTrigMuonValidation) {
484  auto chainGroups = m_trigDec->getChainGroup("HLT_.*mu.*");
485  for (auto& trig : chainGroups->getListOfTriggers()) {
486  if (m_trigDec->isPassed(trig, TrigDefs::EF_passedRaw)) {
487  ATH_MSG_DEBUG("Chain " << trig << " is passed: YES");
488  } else
489  ATH_MSG_DEBUG("Chain " << trig << " is passed: NO");
490  }
491  auto L1chainGroups = m_trigDec->getChainGroup("L1_MU.*");
492  for (auto& L1trig : L1chainGroups->getListOfTriggers()) {
493  if (m_trigDec->isPassed(L1trig, TrigDefs::EF_passedRaw))
494  ATH_MSG_DEBUG("Chain " << L1trig << " is passed: YES");
495  else
496  ATH_MSG_DEBUG("Chain " << L1trig << " is passed: NO");
497  }
498  for (auto mu : m_vRecoMuons) {
499  if (passesAcceptanceCuts(mu) && std::abs(mu->eta()) < 2.4) {
500  if (mu->author() == 1) {
501  m_vRecoMuons_EffDen_CB.emplace_back(mu);
502  ATH_MSG_DEBUG("##### m_vRecoMuons_EffDen_CB pt:" << mu->pt() << " phi:" << mu->phi() << " eta:" << mu->eta());
503  } else if (mu->author() == 5) {
504  m_vRecoMuons_EffDen_MS.emplace_back(mu);
505  ATH_MSG_DEBUG("##### m_vRecoMuons_EffDen_MS pt:" << mu->pt() << " phi:" << mu->phi() << " eta:" << mu->eta());
506  }
507  }
508  }
509 
510  //@@@@@ L1 @@@@@
511  if (m_doTrigMuonL1Validation) {
512  const xAOD::MuonRoIContainer* L1TrigMuons{nullptr};
513  ATH_CHECK(retrieveContainer(ctx, m_muonL1TrigName, L1TrigMuons));
514  ATH_MSG_DEBUG("Retrieved L1 triggered muons " << L1TrigMuons->size());
515  for (const auto TrigL1mu : *L1TrigMuons) handleMuonL1Trigger(TrigL1mu);
516  }
517 
518  //@@@@@ L2 @@@@@
519  if (m_doTrigMuonL2Validation) {
520  //@@@@@ L2SA @@@@@
521  const xAOD::L2StandAloneMuonContainer* L2SAMuons{nullptr};
522  ATH_CHECK(retrieveContainer(ctx, m_muonL2SAName, L2SAMuons));
523  ATH_MSG_DEBUG("Retrieved L2 StandAlone triggered muons " << L2SAMuons->size());
524  if (L2SAMuons->size() != 0) {
525  for (const auto L2SAmu : *L2SAMuons) {
526  ATH_MSG_DEBUG("Muon L2SA Trigger: pt " << L2SAmu->pt() << " phi " << L2SAmu->phi() << " eta " << L2SAmu->eta()
527  << " roiWord " << L2SAmu->roiWord() << " sAddress " << L2SAmu->sAddress());
528  m_vL2SAMuons.emplace_back(L2SAmu);
529  }
530  for (const auto& mu : m_vL2SAMuons) {
531  if (mu->pt() != 0.) {
532  m_vL2SAMuonsSelected.emplace_back(mu);
533  break;
534  }
535  }
536  for (unsigned int i = 0; i < m_vL2SAMuons.size(); i++) {
537  unsigned int cont = 0;
538  for (unsigned int j = 0; j < m_vL2SAMuonsSelected.size(); j++) {
539  if (((m_vL2SAMuons.at(i)->pt()) != 0.) && ((deltaR(m_vL2SAMuonsSelected.at(j), m_vL2SAMuons.at(i))) > 0.1))
540  cont++;
541  if (cont == m_vL2SAMuonsSelected.size()) {
542  m_vL2SAMuonsSelected.emplace_back(m_vL2SAMuons.at(i));
543  break;
544  }
545  }
546  }
547  for (unsigned int i = 0; i < m_vL2SAMuonsSelected.size(); i++) { handleMuonL2Trigger(m_vL2SAMuonsSelected.at(i)); }
548  L2SATriggerResolution();
549  }
550  for (const auto& muonItem : m_muonItems) {
551  std::vector<Trig::Feature<xAOD::L2StandAloneMuonContainer> > vec_muons;
552  TString muonItem_str = (TString)muonItem;
553  if (muonItem_str.Contains("_OR_")) {
554  muonItem_str.ReplaceAll("_OR_", " ");
555  TString delim = " ";
556  std::vector<TString> v_subchains;
557  SplitString(muonItem_str, delim, v_subchains);
558  for (int i = 0; i < (int)v_subchains.size(); i++) {
559  Trig::FeatureContainer fc1 = m_trigDec->features((std::string)v_subchains.at(i));
560  std::vector<Trig::Feature<xAOD::L2StandAloneMuonContainer> > vec_muons_1 =
562  for (const auto& mufeat : vec_muons_1) { vec_muons.emplace_back(mufeat); }
563  }
564  } else {
565  Trig::FeatureContainer fc = m_trigDec->features(muonItem);
566  vec_muons = fc.get<xAOD::L2StandAloneMuonContainer>();
567  }
568  ATH_MSG_DEBUG("Size of vector Trig::Feature<xAOD::L2StandAloneMuonContainer> for chain " << muonItem << " = "
569  << vec_muons.size());
570  for (const auto& mufeat : vec_muons) {
571  ATH_MSG_DEBUG(muonItem << " vec_muons.size() = " << vec_muons.size()
572  << " mufeat.cptr()->size() = " << mufeat.cptr()->size());
573  for (unsigned int i = 0; i < mufeat.cptr()->size(); i++) {
574  ATH_MSG_DEBUG("#####" << muonItem << " L2SA feature pt: " << (*mufeat.cptr())[i]->pt()
575  << " eta: " << (*mufeat.cptr())[i]->eta() << " phi: " << (*mufeat.cptr())[i]->phi());
576  }
577  }
578  }
579 
580  //@@@@@ L2CB @@@@@
581 
582  const xAOD::L2CombinedMuonContainer* L2CBMuons{nullptr};
583  ATH_CHECK(retrieveContainer(ctx, m_muonL2CBName, L2CBMuons));
584  ATH_MSG_DEBUG("Retrieved L2 Combined triggered muons " << L2CBMuons->size());
585  if (L2CBMuons->size() != 0) {
586  for (const auto L2CBmu : *L2CBMuons) {
587  ATH_MSG_DEBUG("Muon L2CB Trigger: pt " << L2CBmu->pt() << " phi " << L2CBmu->phi() << " eta " << L2CBmu->eta());
588  m_vL2CBMuons.emplace_back(L2CBmu);
589  }
590  for (unsigned int i = 0; i < m_vL2CBMuons.size(); i++) {
591  if ((m_vL2CBMuons.at(i)->pt()) != 0.) {
592  m_vL2CBMuonsSelected.emplace_back(m_vL2CBMuons.at(i));
593  break;
594  }
595  }
596  for (unsigned int i = 0; i < m_vL2CBMuons.size(); i++) {
597  unsigned int cont = 0;
598  for (unsigned int j = 0; j < m_vL2CBMuonsSelected.size(); j++) {
599  if (((m_vL2CBMuons.at(i)->pt()) != 0.) && ((deltaR(m_vL2CBMuonsSelected.at(j), m_vL2CBMuons.at(i))) > 0.1))
600  cont++;
601  if (cont == m_vL2CBMuonsSelected.size()) {
602  m_vL2CBMuonsSelected.emplace_back(m_vL2CBMuons.at(i));
603  break;
604  }
605  }
606  }
607  for (unsigned int i = 0; i < m_vL2CBMuonsSelected.size(); i++) { handleMuonL2Trigger(m_vL2CBMuonsSelected.at(i)); }
608  L2CBTriggerResolution();
609  }
610  for (const auto& muonItem : m_muonItems) {
611  std::vector<Trig::Feature<xAOD::L2CombinedMuonContainer> > vec_muons;
612  TString muonItem_str = (TString)muonItem;
613  if (muonItem_str.Contains("_OR_")) {
614  muonItem_str.ReplaceAll("_OR_", " ");
615  TString delim = " ";
616  std::vector<TString> v_subchains;
617  SplitString(muonItem_str, delim, v_subchains);
618  for (int i = 0; i < (int)v_subchains.size(); i++) {
619  Trig::FeatureContainer fc1 = m_trigDec->features((std::string)v_subchains.at(i));
620  std::vector<Trig::Feature<xAOD::L2CombinedMuonContainer> > vec_muons_1 =
622  for (const auto& mufeat : vec_muons_1) { vec_muons.emplace_back(mufeat); }
623  }
624  } else {
625  Trig::FeatureContainer fc = m_trigDec->features(muonItem);
626  vec_muons = fc.get<xAOD::L2CombinedMuonContainer>();
627  }
628  ATH_MSG_DEBUG("Size of vector Trig::Feature<xAOD::L2CombinedMuonContainer> for chain " << muonItem << " = "
629  << vec_muons.size());
630  for (const auto& mufeat : vec_muons) {
631  ATH_MSG_DEBUG(muonItem << " vec_muons.size() = " << vec_muons.size()
632  << " mufeat.cptr()->size() = " << mufeat.cptr()->size());
633  for (unsigned int i = 0; i < mufeat.cptr()->size(); i++) {
634  ATH_MSG_DEBUG("#####" << muonItem << " L2CB feature pt: " << (*mufeat.cptr())[i]->pt()
635  << " eta: " << (*mufeat.cptr())[i]->eta() << " phi: " << (*mufeat.cptr())[i]->phi());
636  }
637  }
638  }
639  } // close if(m_doTrigMuonL2Validation)
640 
641  //@@@@@ EF @@@@@
642  if (m_doTrigMuonEFValidation) {
643  const xAOD::MuonContainer* EFCombTrigMuons{nullptr};
644  const xAOD::MuonRoIContainer* L1TrigMuons{nullptr};
645  ATH_CHECK(retrieveContainer(ctx, m_muonEFCombTrigName, EFCombTrigMuons));
646  ATH_CHECK(retrieveContainer(ctx, m_muonL1TrigName, L1TrigMuons));
647  ATH_MSG_DEBUG("Retrieved EF triggered muons " << EFCombTrigMuons->size());
648  if (EFCombTrigMuons->size() != 0) {
649  for (const auto Trigmu : *EFCombTrigMuons) {
650  ATH_MSG_DEBUG("Muon EF Trigger: pt " << Trigmu->pt() << " phi " << Trigmu->phi() << " eta " << Trigmu->eta()
651  << " author" << Trigmu->author());
652  m_vEFMuons.emplace_back(Trigmu);
653  }
654  m_vEFMuonsSelected.emplace_back(m_vEFMuons.at(0));
655  for (unsigned int i = 0; i < m_vEFMuons.size(); i++) {
656  unsigned int cont = 0;
657  for (unsigned int j = 0; j < m_vEFMuonsSelected.size(); j++) {
658  if (((deltaR(m_vEFMuonsSelected.at(j), m_vEFMuons.at(i))) > 0.1) ||
659  ((m_vEFMuons.at(i)->author() - m_vEFMuonsSelected.at(j)->author()) != 0))
660  cont++;
661  if (cont == m_vEFMuonsSelected.size()) {
662  m_vEFMuonsSelected.emplace_back(m_vEFMuons.at(i));
663  break;
664  }
665  }
666  }
667  for (unsigned int i = 0; i < m_vEFMuonsSelected.size(); i++) { handleMuonTrigger(m_vEFMuonsSelected.at(i)); }
668  EFTriggerResolution();
669  }
670  if (!m_isData) {
671  for (const auto truthMu : *TruthMuons) {
672  ATH_MSG_DEBUG("TRUTH:: pt=" << truthMu->pt() << " eta=" << truthMu->eta() << " phi=" << truthMu->phi());
673  }
674  }
675  // handleMuonTrigger_ResoWRTTruth(m_vEFMuonsSelected,)
676  //@@@@@ chains efficiency @@@@@
677  for (const auto& muonItem : m_muonItems) {
678  m_vRecoMuons_EffDen = m_vRecoMuons_EffDen_CB;
679  m_SelectedAuthor = 1;
680  if ((muonItem.find("msonly") != std::string::npos)) {
681  m_vRecoMuons_EffDen = m_vRecoMuons_EffDen_MS;
682  m_SelectedAuthor = 5;
683  }
684  std::vector<Trig::Feature<xAOD::MuonContainer> > vec_muons;
685  TString muonItem_str = (TString)muonItem;
686  if (muonItem_str.Contains("_OR_")) {
687  muonItem_str.ReplaceAll("_OR_", " ");
688  TString delim = " ";
689  std::vector<TString> v_subchains;
690  SplitString(muonItem_str, delim, v_subchains);
691  for (int i = 0; i < (int)v_subchains.size(); i++) {
692  Trig::FeatureContainer fc1 = m_trigDec->features((std::string)v_subchains.at(i));
693  std::vector<Trig::Feature<xAOD::MuonContainer> > vec_muons_1 = fc1.get<xAOD::MuonContainer>();
694  for (const auto& mufeat : vec_muons_1) { vec_muons.emplace_back(mufeat); }
695  }
696  } else {
697  Trig::FeatureContainer fc = m_trigDec->features(muonItem);
698  vec_muons = fc.get<xAOD::MuonContainer>();
699  }
700  ATH_MSG_DEBUG("Size of vector Trig::Feature<xAOD::MuonContainer> for chain " << muonItem << " = " << vec_muons.size());
701  for (const auto& mufeat : vec_muons) {
702  ATH_MSG_DEBUG(muonItem << " vec_muons.size() = " << vec_muons.size()
703  << " mufeat.cptr()->size() = " << mufeat.cptr()->size());
704  for (unsigned int i = 0; i < mufeat.cptr()->size(); i++) {
705  ATH_MSG_DEBUG("#####" << muonItem << " EF feature pt: " << (*mufeat.cptr())[i]->pt()
706  << " eta: " << (*mufeat.cptr())[i]->eta() << " phi: " << (*mufeat.cptr())[i]->phi()
707  << " author: " << (*mufeat.cptr())[i]->author());
708  for (unsigned int j = 0; j < m_selectMuonCategories.size(); j++) {
709  if (m_selectMuonCategories[j] == ALL) {
710  if (((*mufeat.cptr())[i]->author()) == m_SelectedAuthor)
711  m_TriggerMuonValidationPlots[j]->fillFeatPlots(*(*mufeat.cptr())[i], muonItem);
712  } // if categ=ALL
713  } // categories
714  } // mufeat.cptr
715  } // mufeat
716  for (unsigned int k = 0; k < m_vRecoMuons_EffDen.size(); k++) {
717  bool break_flag = false;
718  for (unsigned int j = 0; j < m_selectMuonCategories.size(); j++) {
719  if (m_selectMuonCategories[j] == ALL) {
720  m_TriggerMuonValidationPlots[j]->fillDenEff(*m_vRecoMuons_EffDen.at(k), muonItem);
721  }
722  }
723  for (const auto& mufeat : vec_muons) {
724  for (unsigned int i = 0; i < mufeat.cptr()->size(); i++) {
725  if ((((*mufeat.cptr())[i]->author()) == m_SelectedAuthor) &&
726  (deltaR((*mufeat.cptr())[i], m_vRecoMuons_EffDen.at(k)) < 0.1)) {
727  break_flag = true;
728  ATH_MSG_DEBUG(" $$$ match Reco_EffDen "
729  << muonItem << " pt: " << m_vRecoMuons_EffDen.at(k)->pt() << " eta: "
730  << m_vRecoMuons_EffDen.at(k)->eta() << " phi: " << m_vRecoMuons_EffDen.at(k)->phi()
731  << " author: " << m_vRecoMuons_EffDen.at(k)->author());
732  ATH_MSG_DEBUG(" $$$ match EF MuidCo feature "
733  << muonItem << " pt: " << (*mufeat.cptr())[i]->pt()
734  << " eta: " << (*mufeat.cptr())[i]->eta() << " phi: " << (*mufeat.cptr())[i]->phi()
735  << " author: " << (*mufeat.cptr())[i]->author() << " rel_p "
736  << (std::abs(((*mufeat.cptr())[i]->pt() - m_vRecoMuons_EffDen.at(k)->pt()) /
737  (m_vRecoMuons_EffDen.at(k)->pt()))));
738  for (unsigned int j = 0; j < m_selectMuonCategories.size(); j++) {
739  if (m_selectMuonCategories[j] == ALL) {
740  m_TriggerMuonValidationPlots[j]->fillNumEff(*m_vRecoMuons_EffDen.at(k), muonItem);
741  // if (muonItem=="HLT_2mu10") m_TriggerMuonValidationPlots[j]->fill(
742  // *(*mufeat.cptr())[i],*m_vRecoMuons_EffDen.at(k));
743 
744  } // if categ=ALL
745  } // categories
746  break;
747  } // if(Delta_R)
748  } // mufeat
749  if (break_flag) break;
750  } // vec_muons
751  } // m_vRecoMuons_EffDen
752  } // m_muonItems
753  //@@@@@ L1 items efficiency @@@@@
754  for (const auto& L1MuonItem : m_L1MuonItems) {
755  m_vRecoMuons_EffDen = m_vRecoMuons_EffDen_CB;
756  m_SelectedAuthor = 1;
757  float threshold = 0.;
758  if (L1MuonItem == "L1_MU4") threshold = 4000;
759  else if (L1MuonItem == "L1_MU6") threshold = 6000;
760  else if (L1MuonItem == "L1_MU10") threshold = 10000;
761  else if (L1MuonItem == "L1_MU11") threshold = 11000;
762  else if (L1MuonItem == "L1_MU15") threshold = 15000;
763  else if (L1MuonItem == "L1_MU20") threshold = 20000;
764  for (const auto TrigL1mu : *L1TrigMuons) {
765  for (unsigned int j = 0; j < m_selectMuonCategories.size(); j++) {
766  if (m_selectMuonCategories[j] == ALL) {
767  if ((TrigL1mu->thrValue()) >= threshold)
768  m_TriggerMuonValidationPlots[j]->fillFeatPlots(*TrigL1mu, L1MuonItem);
769  } // if categ=ALL
770  } // categories
771  } // L1TrigMuons
772  for (unsigned int k = 0; k < m_vRecoMuons_EffDen.size(); k++) {
773  for (unsigned int j = 0; j < m_selectMuonCategories.size(); j++) {
774  if (m_selectMuonCategories[j] == ALL) {
775  m_TriggerMuonValidationPlots[j]->fillDenL1Eff(*m_vRecoMuons_EffDen.at(k), L1MuonItem);
776  }
777  }
778  for (const auto TrigL1mu : *L1TrigMuons) {
779  if (((TrigL1mu->thrValue()) >= threshold) &&
780  (sqrt(pow(m_vRecoMuons_EffDen.at(k)->eta() - TrigL1mu->eta(), 2.) +
781  pow(m_vRecoMuons_EffDen.at(k)->phi() - TrigL1mu->phi(), 2.)) < 0.2)) {
782  ATH_MSG_DEBUG(" $$$ match Reco_EffDen "
783  << L1MuonItem << " pt: " << m_vRecoMuons_EffDen.at(k)->pt() << " eta: "
784  << m_vRecoMuons_EffDen.at(k)->eta() << " phi: " << m_vRecoMuons_EffDen.at(k)->phi()
785  << " author: " << m_vRecoMuons_EffDen.at(k)->author());
786  ATH_MSG_DEBUG(" $$$ L1 feature " << L1MuonItem << " pt: " << TrigL1mu->thrValue()
787  << " eta: " << TrigL1mu->eta() << " phi: " << TrigL1mu->phi());
788  for (unsigned int j = 0; j < m_selectMuonCategories.size(); j++) {
789  if (m_selectMuonCategories[j] == ALL) {
790  m_TriggerMuonValidationPlots[j]->fillNumL1Eff(*m_vRecoMuons_EffDen.at(k), L1MuonItem);
791  } // if categ=ALL
792  } // categories
793  break;
794  } // if(Delta_R)
795  } // L1TrigMuons
796  } // m_vRecoMuons_EffDen
797  }
798  //@@@@@ chains efficiency w.r.t. L1 @@@@@
799  for (unsigned int m = 0; m < m_muonItems.size(); m++) {
800  std::vector<Trig::Feature<xAOD::MuonContainer> > vec_muons;
801  TString muonItem_str = (TString)m_muonItems[m];
802  if (muonItem_str.Contains("_OR_")) {
803  muonItem_str.ReplaceAll("_OR_", " ");
804  TString delim = " ";
805  std::vector<TString> v_subchains;
806  SplitString(muonItem_str, delim, v_subchains);
807  for (int i = 0; i < (int)v_subchains.size(); i++) {
808  Trig::FeatureContainer fc1 = m_trigDec->features((std::string)v_subchains.at(i));
809  std::vector<Trig::Feature<xAOD::MuonContainer> > vec_muons_1 = fc1.get<xAOD::MuonContainer>();
810  for (const auto& mufeat : vec_muons_1) { vec_muons.emplace_back(mufeat); }
811  }
812  } else {
813  Trig::FeatureContainer fc = m_trigDec->features(m_muonItems[m]);
814  vec_muons = fc.get<xAOD::MuonContainer>();
815  }
816  m_vRecoMuons_EffDen = m_vRecoMuons_EffDen_CB;
817  m_SelectedAuthor = 1;
818  if ((m_muonItems[m].find("msonly") != std::string::npos)) {
819  m_vRecoMuons_EffDen = m_vRecoMuons_EffDen_MS;
820  m_SelectedAuthor = 5;
821  }
822  float threshold = 0.;
823  if (m_L1Seed[m] == "L1_MU4") threshold = 4000;
824  if (m_L1Seed[m] == "L1_MU6") threshold = 6000;
825  if (m_L1Seed[m] == "L1_MU10") threshold = 10000;
826  if (m_L1Seed[m] == "L1_MU11") threshold = 11000;
827  if (m_L1Seed[m] == "L1_MU15") threshold = 15000;
828  if (m_L1Seed[m] == "L1_MU20") threshold = 20000;
829  for (unsigned int k = 0; k < m_vRecoMuons_EffDen.size(); k++) {
830  bool break_flag = false;
831  for (const auto TrigL1mu : *L1TrigMuons) {
832  if (((TrigL1mu->thrValue()) >= threshold) &&
833  (sqrt(pow(m_vRecoMuons_EffDen.at(k)->eta() - TrigL1mu->eta(), 2.) +
834  pow(m_vRecoMuons_EffDen.at(k)->phi() - TrigL1mu->phi(), 2.)) < 0.2)) {
835  for (unsigned int j = 0; j < m_selectMuonCategories.size(); j++) {
836  if (m_selectMuonCategories[j] == ALL) {
837  m_TriggerMuonValidationPlots[j]->fillDenRELEff(*m_vRecoMuons_EffDen.at(k), m_muonItems[m]);
838  } // if categ=ALL
839  } // categories
840  for (const auto& mufeat : vec_muons) {
841  for (unsigned int i = 0; i < mufeat.cptr()->size(); i++) {
842  if ((((*mufeat.cptr())[i]->author()) == m_SelectedAuthor) &&
843  (deltaR((*mufeat.cptr())[i], m_vRecoMuons_EffDen.at(k)) < 0.1)) {
844  break_flag = true;
845  for (unsigned int j = 0; j < m_selectMuonCategories.size(); j++) {
846  if (m_selectMuonCategories[j] == ALL) {
847  m_TriggerMuonValidationPlots[j]->fillNumRELEff(*m_vRecoMuons_EffDen.at(k),
848  m_muonItems[m]);
849  } // if categ=ALL
850  } // categories
851  break;
852  } // if(Delta_R)
853  } // mufeat
854  if (break_flag) break;
855  } // vec_muons
856  break;
857  } // if(Delta_R)
858  } // L1TrigMuons
859  } // m_vRecoMuons_EffDen
860  } // m_muonItems.size()
861  } // m_doTrigMuonEFValidation
862  }
863  return StatusCode::SUCCESS;
864  }//fillHistograms()*/
865 
866  void MuonPhysValMonitoringTool::handleTruthMuonSegment(const xAOD::MuonSegment* truthMuSeg,
867  const xAOD::TruthParticleContainer* /*muonTruthContainer*/, float weight) {
868  const xAOD::MuonSegment* muSeg = findRecoMuonSegment(truthMuSeg);
870 
871  unsigned int thisMuonCategory = ALL; // getMuonSegmentTruthCategory(truthMuSeg, muonTruthContainer) @@@ Does not work...
872 
873  for (unsigned int i = 0; i < m_selectMuonCategories.size(); i++) {
874  if (m_selectMuonCategories[i] == ALL || m_selectMuonCategories[i] == thisMuonCategory) {
875  m_muonSegmentValidationPlots[i]->fill(truthMuSeg, muSeg,
876  weight); // if no reco muon segment is found a protection inside
877  // MuonSegmentValidationPlots will ensure, its plots won't be filled
878  }
879  }
880  }
881 
882  void MuonPhysValMonitoringTool::handleMuonSegment(const xAOD::MuonSegment* muSeg, float weight) {
883  if (!muSeg) {
884  ATH_MSG_WARNING("No muon segment found");
885  return;
886  }
887  if (std::find(std::begin(m_vMatchedMuonSegments), std::end(m_vMatchedMuonSegments), muSeg) != std::end(m_vMatchedMuonSegments))
888  return;
889  if (!m_isData) m_oUnmatchedRecoMuonSegmentPlots->fill(*muSeg, weight);
890  for (unsigned int i = 0; i < m_selectMuonCategories.size(); i++) {
891  if (m_selectMuonCategories[i] == ALL) {
892  m_muonSegmentValidationPlots[i]->fill(muSeg, weight);
893  break;
894  }
895  }
896  }
897 
898  void MuonPhysValMonitoringTool::handleMuon(const xAOD::Muon* mu, const xAOD::SlowMuon* smu, float weight) {
899  if (!mu) return;
900  if (!m_selectComissioning && mu->allAuthors() & comm_bit) return;
901 
902  if (msgLvl(MSG::DEBUG)) printMuonDebug(mu);
903 
904  // make deep copy of muon and decorate with quality
905  std::unique_ptr<xAOD::Muon> mu_c;
906  try {
907  mu_c = getCorrectedMuon(*mu);
908  } catch (const SG::ExcBadAuxVar&) {
909  ATH_MSG_ERROR("Cannot retrieve aux-item - rejecting muon");
910  return;
911  }
912 
913  if (m_isData) {
914  MUCATEGORY thisMuonCategory = ALL;
915  // for events with a Zmumu candidate, separate Z muons from the rest:
916  if (m_vZmumuMuons.size() > 0) {
917  thisMuonCategory = REST;
918  if (std::find(m_vZmumuMuons.begin(), m_vZmumuMuons.end(), mu) != m_vZmumuMuons.end()) { thisMuonCategory = PROMPT; }
919  }
920  // fill plots
921  for (unsigned int i = 0; i < m_selectMuonCategories.size(); i++) {
922  if (m_selectMuonCategories[i] == ALL or m_selectMuonCategories[i] == thisMuonCategory) {
923  if (mu_c){
924  // histos
925  m_muonValidationPlots[i]->fill(*mu_c, weight);
926  if (smu) m_slowMuonValidationPlots[i]->fill(*smu, *mu_c, weight);
927  // tree branches
928  m_muonValidationPlots[i]->fillTreeBranches(*mu_c);
929  }
930  }
931  }
932  }
933 
935  // SELECT MUON MEDIUM QUALITY FOR TRIGGER VALIDATION
936  xAOD::Muon::Quality my_quality = m_muonSelectionTool->getQuality(*mu_c);
937  if (my_quality <= xAOD::Muon::Medium && m_isoTool->accept(*mu_c)) m_vRecoMuons.emplace_back(mu);
939 
940  if (smu) {
941  if (std::find(std::begin(m_vMatchedSlowMuons), std::end(m_vMatchedSlowMuons), smu) != std::end(m_vMatchedSlowMuons)) { return; }
942  } else {
943  if (std::find(std::begin(m_vMatchedMuons), std::end(m_vMatchedMuons), mu) != std::end(m_vMatchedMuons)) { return; }
944  }
945 
946  // unmatched reco muons (not matched with any kind of truth particle, fakes)
947  if (!m_isData) m_oUnmatchedRecoMuonPlots->fill(*mu_c, weight);
948 
949  m_h_overview_reco_category->Fill("Other", weight);
950  m_h_overview_reco_authors[3]->Fill(mu->author(), weight);
951 
952  for (unsigned int i = 0; i < m_selectMuonCategories.size(); i++) {
953  if (m_selectMuonCategories[i] == ALL) {
954  if (mu_c){// histos
955  m_muonValidationPlots[i]->fill(*mu_c);
956  if (smu) m_slowMuonValidationPlots[i]->fill(*smu, *mu_c, weight);
957  // tree branches
958  m_muonValidationPlots[i]->fillTreeBranches(*mu_c);
959  break;
960  }
961  }
962  }
963  }
964 
965  void MuonPhysValMonitoringTool::handleTruthMuon(const xAOD::TruthParticle* truthMu, float weight) {
966  const xAOD::SlowMuon* smu = nullptr;
967  const xAOD::Muon* mu = nullptr;
968  if (!m_slowMuonsName.empty()) {
969  smu = findRecoSlowMuon(truthMu);
970  if (smu) {
971  const MuonLink muLink = smu->muonLink();
972  if (muLink.isValid()) mu = *muLink;
973 
974  if (!mu) {
975  ATH_MSG_WARNING("Found SlowMuon without valid muon link");
976  smu = nullptr;
977  }
978  }
979  } else {
980  mu = findRecoMuon(truthMu);
981  }
982 
983  if (msgLvl(MSG::DEBUG)) printTruthMuonDebug(truthMu, mu);
984  if (!passesAcceptanceCuts(truthMu)) return;
985 
986  std::unique_ptr<xAOD::Muon> mu_c;
987  if (mu) {
988  try {
989  mu_c = getCorrectedMuon(*mu);
990  } catch (const SG::ExcBadAuxVar&) {
991  ATH_MSG_ERROR("Cannot retrieve aux-item - rejecting muon");
992  return;
993  }
994  }
995 
996  unsigned int thisMuonCategory = getMuonTruthCategory(truthMu);
997  for (unsigned int i = 0; i < m_selectMuonCategories.size(); i++) {
998  if (m_selectMuonCategories[i] == ALL || m_selectMuonCategories[i] == thisMuonCategory) {
999  // histos
1000  m_muonValidationPlots[i]->fill(
1001  truthMu, mu_c.get(), m_MSTracks,
1002  weight); // if no muon is found a protection inside MuonValidationPlots will ensure, its plots won't be filled
1003  if (!m_slowMuonsName.empty()) m_slowMuonValidationPlots[i]->fill(truthMu, smu, mu_c.get(), weight);
1004  // tree branches
1005  m_muonValidationPlots[i]->fillTreeBranches(truthMu, mu_c.get(), m_MSTracks);
1006  }
1007  }
1008  if (mu_c) {
1009  m_h_overview_reco_category->Fill(thisMuonCategory - 1, weight);
1010  m_h_overview_reco_authors[thisMuonCategory - 1]->Fill(mu_c->author(), weight);
1011  } else if (!m_isData)
1012  m_oUnmatchedTruthMuonPlots->fill(*truthMu, weight);
1013  }
1014 
1015  void MuonPhysValMonitoringTool::handleMuonTrack(const xAOD::TrackParticle* tp, xAOD::Muon::TrackParticleType type, float weight) {
1016  if (!tp) {
1017  ATH_MSG_WARNING("No track particle found");
1018  return;
1019  }
1020 
1021  // if ID track, check that it passes standard combined mu reco selections
1022  bool passesMuonTrackSel = false;
1023  if (type == xAOD::Muon::InnerDetectorTrackParticle) { passesMuonTrackSel = m_trackSelector->decision(*tp); }
1024 
1025  if (m_isData) {
1026  if (type == xAOD::Muon::InnerDetectorTrackParticle) {
1027  MUCATEGORY thisTrkCategory = ALL;
1028  // for events with a Zmumu candidate, separate Z muon tracks from the rest:
1029  if (m_vZmumuIDTracks.size() > 0) {
1030  thisTrkCategory = REST;
1031  for (const auto& zmu : m_vZmumuIDTracks) {
1032  if (deltaR(zmu, tp) < 0.01) {
1033  thisTrkCategory = PROMPT;
1034  break;
1035  }
1036  }
1037  }
1038 
1039  for (unsigned int i = 0; i < m_selectMuonCategories.size(); i++) {
1040  if (m_selectMuonCategories[i] == ALL || m_selectMuonCategories[i] == thisTrkCategory) {
1041  m_muonIDTrackValidationPlots[i]->fill(*tp, weight);
1042  if (passesMuonTrackSel) m_muonIDSelectedTrackValidationPlots[i]->fill(*tp, weight);
1043  }
1044  }
1045  } else if (type == xAOD::Muon::MuonSpectrometerTrackParticle)
1046  m_muonMSTrackValidationPlots[ALL]->fill(*tp, weight);
1047  else if (type == xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle)
1048  m_muonMETrackValidationPlots[ALL]->fill(*tp, weight);
1049  else if (type == xAOD::Muon::MSOnlyExtrapolatedMuonSpectrometerTrackParticle)
1050  m_muonMSOnlyMETrackValidationPlots[ALL]->fill(*tp, weight);
1051 
1052  return;
1053  }
1054 
1055  static const SG::ConstAccessor<TruthLink> truthParticleLinkAcc("truthParticleLink");
1056  TruthLink truthLink = truthParticleLinkAcc.withDefault(*tp, TruthLink());
1057 
1058  if (!truthLink.isValid()) {
1059  ATH_MSG_DEBUG("No truth link available");
1060  if (type == xAOD::Muon::InnerDetectorTrackParticle) return;
1061  if (!passesAcceptanceCuts(tp)) return;
1062 
1063  for (unsigned int i = 0; i < m_selectMuonCategories.size(); i++) {
1064  if (m_selectMuonCategories[i] == ALL) {
1065  // ID track plots for any track
1066  // if (type==xAOD::Muon::InnerDetectorTrackParticle) {
1067  // m_muonIDTrackValidationPlots[i]->fill(*tp);
1068  // if (passesMuonTrackSel) m_muonIDSelectedTrackValidationPlots[i]->fill(*tp);
1069  // } else
1070  if (type == xAOD::Muon::MuonSpectrometerTrackParticle) {
1071  if (!m_isData) m_oUnmatchedRecoMuonTrackPlots->fill(*tp, weight);
1072  m_muonMSTrackValidationPlots[i]->fill(*tp, weight);
1073  } else if (type == xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle) {
1074  m_muonMETrackValidationPlots[i]->fill(*tp, weight);
1075  } else if (type == xAOD::Muon::MSOnlyExtrapolatedMuonSpectrometerTrackParticle) {
1076  m_muonMSOnlyMETrackValidationPlots[i]->fill(*tp, weight);
1077  }
1078  break;
1079  }
1080  }
1081  } // end if no valid truth link
1082  else { // here: valid truth link and truthType
1083 
1084  if (type ==
1085  xAOD::Muon::InnerDetectorTrackParticle) { // don't fill histograms for any ID track, only for muons; buys a lot of time
1086  if ((*truthLink)->absPdgId() != 13 || !MC::isStable(*truthLink)) return; // not a muon
1087  if (HepMC::uniqueID(*truthLink) == HepMC::UNDEFINED_ID || HepMC::is_simulation_particle((*truthLink))) return; // must have valid barcode
1088  }
1089 
1090  if (!passesAcceptanceCuts(*truthLink)) return;
1091  unsigned int thisMuonCategory = getMuonTruthCategory(tp);
1092 
1093  for (unsigned int i = 0; i < m_selectMuonCategories.size(); i++) {
1094  if (m_selectMuonCategories[i] == ALL || m_selectMuonCategories[i] == thisMuonCategory) {
1095  if (type == xAOD::Muon::InnerDetectorTrackParticle) {
1096  if (!m_fwdtracksName.empty() && std::abs((*truthLink)->eta()) > 2.5)
1097  m_muonIDForwardTrackValidationPlots[i]->fill(*truthLink, tp, weight);
1098  else if (!m_tracksName.empty()) {
1099  m_muonIDTrackValidationPlots[i]->fill(*truthLink, tp, weight);
1100  if (passesMuonTrackSel) m_muonIDSelectedTrackValidationPlots[i]->fill(*truthLink, tp, weight);
1101  }
1102  } else if (type == xAOD::Muon::MuonSpectrometerTrackParticle) {
1103  m_muonMSTrackValidationPlots[i]->fill(*truthLink, tp, weight);
1104  } else if (type == xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle) {
1105  m_muonMETrackValidationPlots[i]->fill(*truthLink, tp, weight);
1106  } else if (type == xAOD::Muon::MSOnlyExtrapolatedMuonSpectrometerTrackParticle) {
1107  m_muonMSOnlyMETrackValidationPlots[i]->fill(*truthLink, tp, weight);
1108  }
1109  }
1110  }
1111  }
1112 
1113  return;
1114  }
1115 
1116  void MuonPhysValMonitoringTool::handleMuonL1Trigger(const xAOD::MuonRoI* TrigL1mu) {
1117  ATH_MSG_DEBUG("MuonRoI L1 Trigger: ptThr " << TrigL1mu->thrValue() << " phi " << TrigL1mu->phi() << " eta " << TrigL1mu->eta());
1118  for (unsigned int i = 0; i < m_selectMuonCategories.size(); i++) {
1119  if (m_selectMuonCategories[i] == ALL) {
1120  m_TriggerMuonValidationPlots[i]->fill(*TrigL1mu);
1121  break;
1122  }
1123  }
1124  }
1125 
1126  void MuonPhysValMonitoringTool::handleMuonL2Trigger(const xAOD::L2StandAloneMuon* L2SAMu) {
1127  for (unsigned int i = 0; i < m_selectMuonCategories.size(); i++) {
1128  if (m_selectMuonCategories[i] == ALL) {
1129  m_TriggerMuonValidationPlots[i]->fill(*L2SAMu);
1130  break;
1131  }
1132  }
1133  ATH_MSG_DEBUG(" ==> Geometrical selection of Muon L2SA Trigger : pt " << L2SAMu->pt() << " phi " << L2SAMu->phi() << " eta "
1134  << L2SAMu->eta() << " roiWord " << L2SAMu->roiWord()
1135  << " sAddress " << L2SAMu->sAddress());
1136  }
1137 
1138  void MuonPhysValMonitoringTool::L2SATriggerResolution() {
1139  int k_L2SAMu_MinDeltaR = -1;
1140  float MinDeltaR = 0.;
1141  ATH_MSG_DEBUG(" m_vL2SAMuons.size()" << m_vL2SAMuons.size());
1142  for (unsigned int i = 0; i < m_vRecoMuons.size(); i++) {
1143  ATH_MSG_DEBUG(":: TEST: listing all Recomu pt=" << m_vRecoMuons.at(i)->pt() << " eta=" << m_vRecoMuons.at(i)->eta() << " phi="
1144  << m_vRecoMuons.at(i)->phi() << " auth=" << m_vRecoMuons.at(i)->author());
1145  }
1146  for (unsigned int i = 0; i < m_vRecoMuons.size(); i++) {
1147  if ((m_vRecoMuons.at(i)->author() != 1) || (std::abs(m_vRecoMuons.at(i)->eta()) > 2.4)) continue;
1148  ATH_MSG_DEBUG(":::: TEST: Recomu pt=" << m_vRecoMuons.at(i)->pt() << " eta=" << m_vRecoMuons.at(i)->eta()
1149  << " phi=" << m_vRecoMuons.at(i)->phi() << " auth=" << m_vRecoMuons.at(i)->author());
1150  k_L2SAMu_MinDeltaR = -1;
1151  MinDeltaR = 1000;
1152  ATH_MSG_DEBUG("==============>>>> k_L2SAMu_MinDeltaR=" << k_L2SAMu_MinDeltaR << " MinDeltaR" << MinDeltaR);
1153  for (unsigned int k = 0; k < m_vL2SAMuons.size(); k++) {
1154  ATH_MSG_DEBUG(" :::::::: TEST: L2SA pt=" << m_vL2SAMuons.at(k)->pt() << " eta=" << m_vL2SAMuons.at(k)->eta()
1155  << " phi=" << m_vL2SAMuons.at(k)->phi()
1156  << " DeltaR=" << deltaR(m_vRecoMuons.at(i), m_vL2SAMuons.at(k)));
1157  if ((deltaR(m_vRecoMuons.at(i), m_vL2SAMuons.at(k)) < 0.1 &&
1158  (deltaR(m_vRecoMuons.at(i), m_vL2SAMuons.at(k)) < MinDeltaR))) {
1159  k_L2SAMu_MinDeltaR = k;
1160  MinDeltaR = deltaR(m_vRecoMuons.at(i), m_vL2SAMuons.at(k));
1161  ATH_MSG_DEBUG("==============>>>> taken!!!! k_L2SAMu_MinDeltaR=" << k_L2SAMu_MinDeltaR << " MinDeltaR"
1162  << MinDeltaR);
1163  }
1164  }
1165  if (k_L2SAMu_MinDeltaR == -1) continue;
1166  for (unsigned int c = 0; c < m_selectMuonCategories.size(); c++) {
1167  if (m_selectMuonCategories[c] == ALL) {
1168  m_TriggerMuonValidationPlots[c]->fill(*m_vL2SAMuons.at(k_L2SAMu_MinDeltaR), *m_vRecoMuons.at(i));
1169  }
1170  }
1171  }
1172  }
1173 
1174  void MuonPhysValMonitoringTool::handleMuonL2Trigger(const xAOD::L2CombinedMuon* L2CBMu) {
1175  for (unsigned int i = 0; i < m_selectMuonCategories.size(); i++) {
1176  if (m_selectMuonCategories[i] == ALL) {
1177  m_TriggerMuonValidationPlots[i]->fill(*L2CBMu);
1178  break;
1179  }
1180  }
1181  ATH_MSG_DEBUG(" ==> Geometrical selection of Muon L2CB Trigger : pt " << L2CBMu->pt() << " phi " << L2CBMu->phi() << " eta "
1182  << L2CBMu->eta());
1183  }
1184 
1185  void MuonPhysValMonitoringTool::L2CBTriggerResolution() {
1186  int k_L2CBMu_MinDeltaR = -1;
1187  float MinDeltaR = 0.;
1188  ATH_MSG_DEBUG(" m_vL2CBMuons.size()" << m_vL2CBMuons.size());
1189  for (unsigned int i = 0; i < m_vRecoMuons.size(); i++) {
1190  ATH_MSG_DEBUG(":: TEST: listing all Recomu pt=" << m_vRecoMuons.at(i)->pt() << " eta=" << m_vRecoMuons.at(i)->eta() << " phi="
1191  << m_vRecoMuons.at(i)->phi() << " auth=" << m_vRecoMuons.at(i)->author());
1192  }
1193  for (unsigned int i = 0; i < m_vRecoMuons.size(); i++) {
1194  if ((m_vRecoMuons.at(i)->author() != 1) || (std::abs(m_vRecoMuons.at(i)->eta()) > 2.4)) continue;
1195  ATH_MSG_DEBUG(":::: TEST: Recomu pt=" << m_vRecoMuons.at(i)->pt() << " eta=" << m_vRecoMuons.at(i)->eta()
1196  << " phi=" << m_vRecoMuons.at(i)->phi() << " auth=" << m_vRecoMuons.at(i)->author());
1197  k_L2CBMu_MinDeltaR = -1;
1198  MinDeltaR = 1000;
1199  ATH_MSG_DEBUG("==============>>>> k_L2CBMu_MinDeltaR=" << k_L2CBMu_MinDeltaR << " MinDeltaR" << MinDeltaR);
1200  for (unsigned int k = 0; k < m_vL2CBMuons.size(); k++) {
1201  ATH_MSG_DEBUG(" :::::::: TEST: L2CB pt=" << m_vL2CBMuons.at(k)->pt() << " eta=" << m_vL2CBMuons.at(k)->eta()
1202  << " phi=" << m_vL2CBMuons.at(k)->phi()
1203  << " DeltaR=" << deltaR(m_vRecoMuons.at(i), m_vL2CBMuons.at(k)));
1204  if ((deltaR(m_vRecoMuons.at(i), m_vL2CBMuons.at(k)) < 0.1 &&
1205  (deltaR(m_vRecoMuons.at(i), m_vL2CBMuons.at(k)) < MinDeltaR))) {
1206  k_L2CBMu_MinDeltaR = k;
1207  MinDeltaR = deltaR(m_vRecoMuons.at(i), m_vL2CBMuons.at(k));
1208  ATH_MSG_DEBUG("==============>>>> taken!!!! k_L2CBMu_MinDeltaR=" << k_L2CBMu_MinDeltaR << " MinDeltaR"
1209  << MinDeltaR);
1210  }
1211  }
1212  if (k_L2CBMu_MinDeltaR == -1) continue;
1213  for (unsigned int c = 0; c < m_selectMuonCategories.size(); c++) {
1214  if (m_selectMuonCategories[c] == ALL) {
1215  m_TriggerMuonValidationPlots[c]->fill(*m_vL2CBMuons.at(k_L2CBMu_MinDeltaR), *m_vRecoMuons.at(i));
1216  }
1217  }
1218  }
1219  }
1220 
1221  void MuonPhysValMonitoringTool::handleMuonTrigger(const xAOD::Muon* EFMu) {
1222  for (unsigned int i = 0; i < m_selectMuonCategories.size(); i++) {
1223  if (m_selectMuonCategories[i] == ALL) {
1224  m_TriggerMuonValidationPlots[i]->fill(*EFMu);
1225  break;
1226  }
1227  }
1228  ATH_MSG_DEBUG("==> Geometrical selection of EF Trigger muons: pt " << EFMu->pt() << " phi " << EFMu->phi() << " eta " << EFMu->eta()
1229  << " author " << EFMu->author());
1230  }
1231 
1232  void MuonPhysValMonitoringTool::EFTriggerResolution() {
1233  int k_EFMu_MinDeltaR = -1;
1234  float MinDeltaR = 0.;
1235  std::vector<int> vAvailableAuthors;
1236  vAvailableAuthors.clear();
1237  vAvailableAuthors.emplace_back(m_vEFMuons[0]->author());
1238  unsigned int iter = 0;
1239  for (unsigned int k = 0; k < m_vEFMuons.size(); k++) {
1240  iter = 0;
1241  for (unsigned int l = 0; l < vAvailableAuthors.size(); l++) {
1242  if (m_vEFMuons[k]->author() != vAvailableAuthors[l]) iter++;
1243  }
1244  if (iter == vAvailableAuthors.size()) vAvailableAuthors.emplace_back(m_vEFMuons[k]->author());
1245  }
1246  ATH_MSG_DEBUG(" m_vEFMuons.size()" << m_vEFMuons.size());
1247  for (unsigned int i = 0; i < m_vRecoMuons.size(); i++) {
1248  ATH_MSG_DEBUG(":: TEST: listing all Recomu pt=" << m_vRecoMuons.at(i)->pt() << " eta=" << m_vRecoMuons.at(i)->eta() << " phi="
1249  << m_vRecoMuons.at(i)->phi() << " auth=" << m_vRecoMuons.at(i)->author());
1250  }
1251  for (unsigned int i = 0; i < m_vRecoMuons.size(); i++) {
1252  if ((m_vRecoMuons.at(i)->author() != 1) || (std::abs(m_vRecoMuons.at(i)->eta()) > 2.4)) continue;
1253  ATH_MSG_DEBUG(":::: TEST: Recomu pt=" << m_vRecoMuons.at(i)->pt() << " eta=" << m_vRecoMuons.at(i)->eta()
1254  << " phi=" << m_vRecoMuons.at(i)->phi() << " auth=" << m_vRecoMuons.at(i)->author());
1255  for (unsigned int l = 0; l < vAvailableAuthors.size(); l++) {
1256  k_EFMu_MinDeltaR = -1;
1257  MinDeltaR = 1000;
1258  for (unsigned int k = 0; k < m_vEFMuons.size(); k++) {
1259  ATH_MSG_DEBUG(" :::::::: TEST: EF pt=" << m_vEFMuons.at(k)->pt() << " eta=" << m_vEFMuons.at(k)->eta()
1260  << " phi=" << m_vEFMuons.at(k)->phi()
1261  << " DeltaR=" << deltaR(m_vRecoMuons.at(i), m_vEFMuons.at(k))
1262  << " author=" << m_vEFMuons.at(k)->author());
1263  if (m_vEFMuons.at(k)->author() == vAvailableAuthors.at(l) &&
1264  (deltaR(m_vRecoMuons.at(i), m_vEFMuons.at(k)) < 0.1 &&
1265  (deltaR(m_vRecoMuons.at(i), m_vEFMuons.at(k)) < MinDeltaR))) {
1266  k_EFMu_MinDeltaR = k;
1267  MinDeltaR = deltaR(m_vRecoMuons.at(i), m_vEFMuons.at(k));
1268  }
1269  }
1270  if (k_EFMu_MinDeltaR == -1) continue;
1271  for (unsigned int c = 0; c < m_selectMuonCategories.size(); c++) {
1272  if (m_selectMuonCategories[c] == ALL) {
1273  m_TriggerMuonValidationPlots[c]->fill(*m_vEFMuons.at(k_EFMu_MinDeltaR), *m_vRecoMuons.at(i));
1274  }
1275  }
1276  }
1277  }
1278  }
1279 
1280  void MuonPhysValMonitoringTool::printMuonDebug(const xAOD::Muon* mu) {
1281  const xAOD::TrackParticle* tp = mu->primaryTrackParticle();
1282  static const SG::ConstAccessor<TruthLink> truthParticleLinkAcc("truthParticleLink");
1283  TruthLink truthLink;
1284  if (tp) {
1285  truthLink = truthParticleLinkAcc.withDefault(*tp, TruthLink());
1286  }
1287  ATH_MSG_DEBUG("Muon: pt " << mu->pt() << " eta " << mu->eta() << " link " << truthLink.isValid());
1288  }
1289 
1290  const xAOD::Muon* MuonPhysValMonitoringTool::findRecoMuon(const xAOD::TruthParticle* truthMu) {
1291  static const SG::ConstAccessor<MuonLink> acc_muon("recoMuonLink");
1292  if (!acc_muon.isAvailable(*truthMu)) return nullptr;
1293  MuonLink link = acc_muon(*truthMu);
1294  if (!link.isValid()) return nullptr;
1295  const xAOD::Muon* reco_mu = (*link);
1296  if (!m_selectComissioning && reco_mu->allAuthors() & comm_bit) return nullptr;
1297  m_vMatchedMuons.emplace_back(reco_mu);
1298  return reco_mu;
1299  }
1300 
1301  const xAOD::SlowMuon* MuonPhysValMonitoringTool::findRecoSlowMuon(const xAOD::TruthParticle* truthMu) {
1302  const xAOD::SlowMuonContainer* SlowMuons = nullptr;
1303  retrieveContainer(Gaudi::Hive::currentContext() , m_slowMuonsName, SlowMuons).ignore();
1304  if (!SlowMuons) return nullptr;
1305  for (const auto smu : *SlowMuons) {
1306  const MuonLink muLink = smu->muonLink();
1307  if (!muLink.isValid()) continue;
1308  float DR = deltaR(*muLink , truthMu);
1309  if (DR < 0.005) {
1310  m_vMatchedSlowMuons.emplace_back(smu);
1311  return smu;
1312  }
1313  }
1314 
1315  return nullptr;
1316  }
1317 
1318  void MuonPhysValMonitoringTool::printTruthMuonDebug(const xAOD::TruthParticle* truthMu, const xAOD::Muon* mu) {
1319  ATH_MSG_DEBUG("Truth muon: " << truthMu->pt() << " eta " << truthMu->eta());
1320  if (!mu) return;
1321  ATH_MSG_DEBUG("Reco muon: " << mu->pt() << " eta " << mu->eta());
1322  }
1323 
1324  StatusCode MuonPhysValMonitoringTool::procHistograms() {
1325  ATH_MSG_INFO("Finalising hists " << name() << "...");
1326  for (const auto& plots : m_muonValidationPlots) plots->finalize();
1327  for (const auto& plots : m_TriggerMuonValidationPlots) plots->finalize();
1328  if (!m_isData) {
1329  m_oUnmatchedRecoMuonPlots->finalize();
1330  m_oUnmatchedTruthMuonPlots->finalize();
1331  }
1332 
1333  for (const auto& plots : m_muonMSTrackValidationPlots) plots->finalize();
1334  for (const auto& plots : m_muonMETrackValidationPlots) plots->finalize();
1335  for (const auto& plots : m_muonMSOnlyMETrackValidationPlots) plots->finalize();
1336  for (const auto& plots : m_muonIDTrackValidationPlots) plots->finalize();
1337  for (const auto& plots : m_muonIDSelectedTrackValidationPlots) plots->finalize();
1338  for (const auto& plots : m_muonIDForwardTrackValidationPlots) plots->finalize();
1339  if (!m_isData)
1340  if (m_oUnmatchedRecoMuonTrackPlots) m_oUnmatchedRecoMuonTrackPlots->finalize();
1341 
1342  for (const auto& plots : m_muonSegmentValidationPlots) plots->finalize();
1343  if (!m_isData)
1344  if (m_oUnmatchedRecoMuonSegmentPlots) m_oUnmatchedRecoMuonSegmentPlots->finalize();
1345 
1346  return StatusCode::SUCCESS;
1347  }//procHistograms*/
1348 
1349  const xAOD::MuonSegment* MuonPhysValMonitoringTool::findRecoMuonSegment(const xAOD::MuonSegment* truthMuSeg) {
1350  static const SG::ConstAccessor<MuonSegmentLink> recoSegmentLinkAcc("recoSegmentLink");
1351  if (!recoSegmentLinkAcc.isAvailable(*truthMuSeg)) {
1352  ATH_MSG_DEBUG("recoSegmentLink not found");
1353  return nullptr;
1354  }
1355  MuonSegmentLink link = recoSegmentLinkAcc(*truthMuSeg);
1356  if (!link.isValid()) {
1357  ATH_MSG_DEBUG("recoSegmentLink not valid");
1358  return nullptr;
1359  }
1360  m_vMatchedMuonSegments.emplace_back(*link);
1361  return (*link);
1362  }
1363 
1364  TH1F* MuonPhysValMonitoringTool::findHistogram(const std::vector<HistData>& hists, const std::string& hnameTag,
1365  const std::string& hdirTag, const std::string& hNewName) {
1366  TH1F* h = nullptr;
1367  for (const auto& hist : hists) {
1368  if (hist.second.find(hdirTag) != std::string::npos || hdirTag.empty()) {
1369  std::string histname = hist.first->GetName();
1370  if (histname.find(hnameTag) != std::string::npos) {
1371  h = (TH1F*)hist.first->Clone(hNewName.c_str());
1372  return h;
1373  }
1374  }
1375  }
1376  return h;
1377  }
1378 
1379  MuonPhysValMonitoringTool::MUCATEGORY MuonPhysValMonitoringTool::getMuonSegmentTruthCategory(
1380  const xAOD::MuonSegment* truthMuSeg, const xAOD::TruthParticleContainer* muonTruthContainer) {
1381  static const SG::ConstAccessor<TruthLink> truthParticleLinkAcc("truthParticleLink");
1382  TruthLink truthLink;
1383  if (truthParticleLinkAcc.isAvailable(*truthMuSeg)) {
1384  truthLink = truthParticleLinkAcc(*truthMuSeg);
1385  if (truthLink.isValid()) {
1386  const int theUniqueID = HepMC::uniqueID(*truthLink);
1387  if (std::abs((*truthLink)->pdgId()) != 13) return REST;
1388 
1389  for (const auto muTruthPart : *muonTruthContainer) {
1390  if ( HepMC::uniqueID(muTruthPart) == theUniqueID ) { return getMuonTruthCategory(muTruthPart); }
1391  }
1392  }
1393  } else
1394  ATH_MSG_WARNING("No truth link available for muon truth segment");
1395 
1396  return REST;
1397  }
1398 
1399  MuonPhysValMonitoringTool::MUCATEGORY MuonPhysValMonitoringTool::getMuonTruthCategory(const xAOD::IParticle* mu) {
1400  static const SG::ConstAccessor<int> truthTypeAcc("truthType");
1401  static const SG::ConstAccessor<int> truthOriginAcc("truthOrigin");
1402  int truthType = truthTypeAcc(*mu);
1403  if (truthType == 6)
1404  return PROMPT;
1405  else if (truthType == 8 && (truthOriginAcc(*mu) == 34 || truthOriginAcc(*mu) == 35))
1406  return INFLIGHT;
1407  else if (truthType == 7)
1408  return NONISO;
1409  return REST;
1410  }
1411 
1412  std::unique_ptr<xAOD::Muon> MuonPhysValMonitoringTool::getCorrectedMuon(const xAOD::Muon& mu) {
1413  std::unique_ptr<xAOD::Muon> mu_c;
1414  if (mu.m() <= 0) return mu_c;
1415  mu_c = std::make_unique<xAOD::Muon>();
1416  mu_c->makePrivateStore(mu);
1417 
1418  // add decorations too fool the muon selector tool
1419  const xAOD::TrackParticle* idtrk{mu_c->trackParticle(xAOD::Muon::InnerDetectorTrackParticle)};
1420  const xAOD::TrackParticle* metrk{mu_c->trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle)};
1421  if (idtrk && metrk) {
1422  const static SG::Decorator<float> InnerDetectorPtDec("InnerDetectorPt");
1423  const static SG::Decorator<float> MuonSpectrometerPtDec("MuonSpectrometerPt");
1424  InnerDetectorPtDec(*mu_c) = idtrk->pt();
1425  MuonSpectrometerPtDec(*mu_c) = metrk->pt();
1426  }
1427  m_muonSelectionTool->setQuality(*mu_c);
1428  m_muonSelectionTool->setPassesIDCuts(*mu_c);
1429  return mu_c;
1430  }
1431 
1432  void MuonPhysValMonitoringTool::modifyHistogram(TH1* hist) {
1433  std::string histname = hist->GetName();
1434 
1435  if(m_muonsName.key() == "Muons"){
1436  if (histname.find("parameters_z0") != std::string::npos) {
1437  hist->GetXaxis()->Set(80, -200., 200.);
1438  }
1439  if (histname.find("parameters_d0") != std::string::npos && histname.find("parameters_d0_small") == std::string::npos) {
1440  hist->GetXaxis()->Set(80, -1., 1.);
1441  hist->GetYaxis()->SetTitle("Entries / 0.025 mm");
1442  }
1443  } else if(m_muonsName.key() == "MuonsLRT"){
1444  if (histname.find("parameters_d0") != std::string::npos && histname.find("parameters_d0_small") == std::string::npos) {
1445  hist->Rebin(100);
1446  hist->GetYaxis()->SetTitle("Entries / 2.5 mm");
1447  }
1448  }
1449 
1450 
1451  if (histname.find("trigger_L1_pt") != std::string::npos) { // if (histname=="Muons_All_trigger_L1_pt"){
1452  hist->SetTitle("L1Trigger Muons pt threshold");
1453  hist->GetXaxis()->SetTitle("L1Trigger Muons pt threshold [GeV]");
1454  hist->GetXaxis()->Set(30, -0.5, 29.5);
1455  }
1456  if (histname.find("trigger_L1_eta_pt") != std::string::npos) { // if (histname=="Muons_All_trigger_L1_eta_pt") {
1457  hist->SetTitle("L1Trigger Muons pt threshold vs eta");
1458  hist->GetYaxis()->Set(90, -0.5, 29.5);
1459  hist->GetYaxis()->SetTitle("L1Trigger Muons pt threshold [GeV]");
1460  }
1461 
1462  if (histname.find("trigger") != std::string::npos &&
1463  ((histname.find("Denom_pt") != std::string::npos) || (histname.find("Numer_pt") != std::string::npos) ||
1464  (histname.find("Features_pt") != std::string::npos)))
1465  hist->GetXaxis()->Set(200, 0., 200.);
1466 
1467  if (histname.find("hits") != std::string::npos) {
1468  if (histname.find("etaLayer2") != std::string::npos)
1469  hist->GetXaxis()->Set(15, -0.5, 14.5);
1470  else if (histname.find("etaLayer") != std::string::npos)
1471  hist->GetXaxis()->Set(11, -0.5, 10.5);
1472  }
1473 
1475  bool is2D = !(histname.find("_vs_") == std::string::npos);
1477 
1478  if (histname.find("METrackParticles") != std::string::npos) {
1479  if (histname.find("Res_eta") != std::string::npos) {
1480  if (is2D)
1481  hist->GetYaxis()->Set(50, -0.025, 0.025);
1482  else
1483  hist->GetXaxis()->Set(50, -0.025, 0.025);
1484  } else if (histname.find("Res_phi") != std::string::npos) {
1485  if (is2D)
1486  hist->GetYaxis()->Set(50, -0.02, 0.02);
1487  else
1488  hist->GetXaxis()->Set(50, -0.02, 0.02);
1489  }
1490  } else if (histname.find("MSTrackParticles") != std::string::npos) {
1491  if (histname.find("Res_eta") != std::string::npos) {
1492  if (is2D)
1493  hist->GetYaxis()->Set(50, -0.025, 0.025);
1494  else
1495  hist->GetXaxis()->Set(50, -0.025, 0.025);
1496  } else if (histname.find("Res_phi") != std::string::npos) {
1497  if (is2D)
1498  hist->GetYaxis()->Set(50, -0.05, 0.05);
1499  else
1500  hist->GetXaxis()->Set(50, -0.05, 0.05);
1501  }
1502  } else {
1503  if (histname.find("Res_eta") != std::string::npos) {
1504  if (is2D)
1505  hist->GetYaxis()->Set(50, -0.005, 0.005);
1506  else
1507  hist->GetXaxis()->Set(50, -0.005, 0.005);
1508  } else if (histname.find("Res_phi") != std::string::npos) {
1509  if (is2D)
1510  hist->GetYaxis()->Set(50, -0.002, 0.002);
1511  else
1512  hist->GetXaxis()->Set(50, -0.002, 0.002);
1513  }
1514  }
1515 
1516  if (histname.find("trigger") != std::string::npos) {
1517  // RESO EF - MC
1518  if ((!m_isData) && histname.find("MuidCo") != std::string::npos &&
1519  (histname.find("BARREL") != std::string::npos || histname.find("WHOLE_DETECT") != std::string::npos)) {
1520  if (histname.find("Res_pT") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1521  hist->GetXaxis()->Set(100, -0.04, 0.04);
1522  }
1523  if (histname.find("Res_pT_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.04, 0.04); }
1524  if (histname.find("Res_eta") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1525  hist->GetXaxis()->Set(100, -0.0005, 0.0005);
1526  }
1527  if (histname.find("Res_eta_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.0005, 0.0005); }
1528 
1529  if (histname.find("Res_phi") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1530  hist->GetXaxis()->Set(100, -0.0002, 0.0002);
1531  }
1532  if (histname.find("Res_phi_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.0002, 0.0002); }
1533  }
1534  if ((!m_isData) && histname.find("MuidCo") != std::string::npos && (histname.find("ENDCAPS") != std::string::npos)) {
1535  if (histname.find("Res_pT") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1536  hist->GetXaxis()->Set(100, -0.05, 0.05);
1537  }
1538  if (histname.find("Res_pT_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.05, 0.05); }
1539  if (histname.find("Res_eta") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1540  hist->GetXaxis()->Set(100, -0.001, 0.001);
1541  }
1542  if (histname.find("Res_eta_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.001, 0.001); }
1543 
1544  if (histname.find("Res_phi") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1545  hist->GetXaxis()->Set(100, -0.0003, 0.0003);
1546  }
1547  if (histname.find("Res_phi_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.0003, 0.0003); }
1548  }
1549  if ((!m_isData) && histname.find("MuidSA") != std::string::npos) {
1550  if (histname.find("Res_eta") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1551  hist->GetXaxis()->Set(100, -0.03, 0.03);
1552  }
1553  if (histname.find("Res_eta_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.03, 0.03); }
1554 
1555  if (histname.find("Res_phi") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1556  hist->GetXaxis()->Set(100, -0.03, 0.03);
1557  }
1558  if (histname.find("Res_phi_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.03, 0.03); }
1559  }
1560  if ((!m_isData) && histname.find("MuidSA") != std::string::npos && (histname.find("BARREL") != std::string::npos)) {
1561  if (histname.find("Res_pT") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1562  hist->GetXaxis()->Set(100, -0.15, 0.15);
1563  }
1564  if (histname.find("Res_pT_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.15, 0.15); }
1565  }
1566  if ((!m_isData) && histname.find("MuidSA") != std::string::npos &&
1567  (histname.find("ENDCAPS") != std::string::npos || histname.find("WHOLE_DETECT") != std::string::npos)) {
1568  if (histname.find("Res_pT") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1569  hist->GetXaxis()->Set(100, -0.2, 0.2);
1570  }
1571  if (histname.find("Res_pT_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.2, 0.2); }
1572  }
1573 
1574  // RESO EF - DATA
1575  if ((m_isData) && histname.find("MuidCo") != std::string::npos &&
1576  (histname.find("BARREL") != std::string::npos || histname.find("WHOLE_DETECT") != std::string::npos)) {
1577  if (histname.find("Res_pT") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1578  hist->GetXaxis()->Set(100, -0.06, 0.06);
1579  }
1580  if (histname.find("Res_pT_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.06, 0.06); }
1581  if (histname.find("Res_eta") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1582  hist->GetXaxis()->Set(100, -0.001, 0.001);
1583  }
1584  if (histname.find("Res_eta_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.001, 0.001); }
1585 
1586  if (histname.find("Res_phi") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1587  hist->GetXaxis()->Set(100, -0.0005, 0.0005);
1588  }
1589  if (histname.find("Res_phi_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.0005, 0.0005); }
1590  }
1591  if ((m_isData) && histname.find("MuidCo") != std::string::npos && (histname.find("ENDCAPS") != std::string::npos)) {
1592  if (histname.find("Res_pT") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1593  hist->GetXaxis()->Set(100, -0.1, 0.1);
1594  }
1595  if (histname.find("Res_pT_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.1, 0.1); }
1596  if (histname.find("Res_eta") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1597  hist->GetXaxis()->Set(100, -0.0015, 0.0015);
1598  }
1599  if (histname.find("Res_eta_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.0015, 0.0015); }
1600 
1601  if (histname.find("Res_phi") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1602  hist->GetXaxis()->Set(100, -0.0005, 0.0005);
1603  }
1604  if (histname.find("Res_phi_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.0005, 0.0005); }
1605  }
1606  if ((m_isData) && histname.find("MuidSA") != std::string::npos) {
1607  if (histname.find("Res_eta") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1608  hist->GetXaxis()->Set(100, -0.03, 0.03);
1609  }
1610  if (histname.find("Res_eta_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.03, 0.03); }
1611 
1612  if (histname.find("Res_phi") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1613  hist->GetXaxis()->Set(100, -0.03, 0.03);
1614  }
1615  if (histname.find("Res_phi_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.03, 0.03); }
1616  }
1617  if ((m_isData) && histname.find("MuidSA") != std::string::npos && (histname.find("BARREL") != std::string::npos)) {
1618  if (histname.find("Res_pT") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1619  hist->GetXaxis()->Set(100, -0.3, 0.3);
1620  }
1621  if (histname.find("Res_pT_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.3, 0.3); }
1622  }
1623  if ((m_isData) && histname.find("MuidSA") != std::string::npos &&
1624  (histname.find("ENDCAPS") != std::string::npos || histname.find("WHOLE_DETECT") != std::string::npos)) {
1625  if (histname.find("Res_pT") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1626  hist->GetXaxis()->Set(100, -0.5, 0.5);
1627  }
1628  if (histname.find("Res_pT_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.5, 0.5); }
1629  }
1630 
1631  // LEVEL2
1632  if ((histname.find("L2_StandAlone") != std::string::npos)) {
1633  if (histname.find("Res_eta") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1634  hist->GetXaxis()->Set(100, -0.03, 0.03);
1635  }
1636  if (histname.find("Res_eta_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.03, 0.03); }
1637 
1638  if (histname.find("Res_phi") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1639  hist->GetXaxis()->Set(100, -0.03, 0.03);
1640  }
1641  if (histname.find("Res_phi_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.03, 0.03); }
1642  }
1643  if ((histname.find("L2_StandAlone") != std::string::npos) && (histname.find("BARREL") != std::string::npos)) {
1644  if (histname.find("Res_pT") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1645  hist->GetXaxis()->Set(100, -0.3, 0.3);
1646  }
1647  if (histname.find("Res_pT_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.3, 0.3); }
1648  }
1649  if ((histname.find("L2_StandAlone") != std::string::npos) &&
1650  ((histname.find("ENDCAPS") != std::string::npos) || (histname.find("WHOLE_DETECT") != std::string::npos))) {
1651  if (histname.find("Res_pT") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1652  hist->GetXaxis()->Set(100, -0.5, 0.5);
1653  }
1654  if (histname.find("Res_pT_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.5, 0.5); }
1655  }
1656 
1657  if ((histname.find("L2_Combined") != std::string::npos)) {
1658  if (histname.find("Res_eta") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1659  hist->GetXaxis()->Set(100, -0.002, 0.002);
1660  }
1661  if (histname.find("Res_eta_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.002, 0.002); }
1662 
1663  if (histname.find("Res_phi") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1664  hist->GetXaxis()->Set(100, -0.001, 0.001);
1665  }
1666  if (histname.find("Res_phi_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.001, 0.001); }
1667  if (histname.find("Res_pT") != std::string::npos && histname.find("_vs_") == std::string::npos) {
1668  hist->GetXaxis()->Set(100, -0.2, 0.2);
1669  }
1670  if (histname.find("Res_pT_vs_") != std::string::npos) { hist->GetYaxis()->Set(100, -0.2, 0.2); }
1671  }
1672  }
1673  }
1674 
1675  bool MuonPhysValMonitoringTool::passesAcceptanceCuts(const xAOD::IParticle* prt) {
1676  if (prt->pt() < 2000.) return false;
1677  if (std::abs(prt->eta()) > 2.7) return false;
1678  return true;
1679  }
1680 
1681  void MuonPhysValMonitoringTool::SplitString(TString x, const TString& delim, std::vector<TString>& v) {
1682  v.clear();
1683  int stringLength = x.Length();
1684  int delimLength = delim.Length();
1685 
1686  int stop = 1;
1687  TString temp = "---";
1688  while (stop != -1) {
1689  stop = x.First(delim);
1690 
1691  if (stop != -1) {
1692  temp = x(0, stop);
1693  TSubString newString = x(stop + delimLength, stringLength);
1694  x = newString;
1695  stringLength = x.Length();
1696  } else {
1697  stringLength = x.Length();
1698  temp = x(0, stringLength);
1699  }
1700 
1701  v.emplace_back(temp);
1702  }
1703  }
1704 
1705 } // namespace MuonPhysValMonitoring
xAOD::L2CombinedMuon_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
temp
Definition: JetEventDict.h:21
xAOD::Muon_v1::allAuthors
uint16_t allAuthors() const
Get all the authors of this Muon.
createLinkingScheme.iter
iter
Definition: createLinkingScheme.py:62
xAOD::name
name
Definition: TriggerMenuJson_v1.cxx:29
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
xAOD::SlowMuon_v1
Class describing a SlowMuon.
Definition: SlowMuon_v1.h:26
PlotBase::retrieveBookedTrees
std::vector< TreeData > retrieveBookedTrees()
Retrieve all booked trees.
Definition: PlotBase.cxx:73
PlotBase
Definition: PlotBase.h:34
vtune_athena.format
format
Definition: vtune_athena.py:14
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
xAOD::Muon_v1::trackParticle
const TrackParticle * trackParticle(TrackParticleType type) const
Returns a pointer (which can be NULL) to the TrackParticle used in identification of this muon.
Definition: Muon_v1.cxx:487
MuonPhysValMonitoring::MuonPhysValMonitoringTool::MUCATEGORY
MUCATEGORY
Definition: MuonPhysValMonitoringTool.h:79
xAOD::L2StandAloneMuon_v2
Class describing standalone muons reconstructed in the LVL2 trigger.
Definition: L2StandAloneMuon_v2.h:36
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
xAODP4Helpers.h
xAOD::Muon_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
TruthVertexContainer.h
plotmaker.hist
hist
Definition: plotmaker.py:148
initialize
void initialize()
Definition: run_EoverP.cxx:894
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
TruthLink
ElementLink< xAOD::TruthParticleContainer > TruthLink
Definition: TruthRelatedMuonPlotOrganizer.cxx:12
RTTAlgmain.trees
list trees
Definition: RTTAlgmain.py:40
tree
TChain * tree
Definition: tile_monitor.h:30
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
xAOD::Muon_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
xAOD::MuonRoI_v1::eta
float eta() const
The pseudorapidity ( ) of the muon candidate.
xAOD::MuonSegment_v1
Class describing a MuonSegment.
Definition: MuonSegment_v1.h:33
ParticleTest.tp
tp
Definition: ParticleTest.py:25
xAOD::MuonRoI_v1::thrValue
float thrValue() const
The highest threshold value (in MeV) passed by the muon candidate.
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:157
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
xAOD::Muon_v1::author
Author author() const
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
x
#define x
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
IDTPM::truthType
int truthType(const U &p)
Definition: TrackParametersHelper.h:274
xAOD::L2StandAloneMuon_v2::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
python.CreateTierZeroArgdict.pairs
pairs
Definition: CreateTierZeroArgdict.py:201
xAOD::L2CombinedMuon_v1
Class describing combined muon reconstructed in the LVL2 trigger.
Definition: L2CombinedMuon_v1.h:41
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:190
Trig::FeatureContainer
Definition: FeatureContainer.h:54
xAOD::Muon_v1::charge
float charge() const
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
xAOD::TrackParticle_v1::p4
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
Definition: TrackParticle_v1.cxx:130
xAOD::L2CombinedMuon_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
PlotBase::retrieveBookedHistograms
std::vector< HistData > retrieveBookedHistograms()
Retrieve all booked histograms.
Definition: PlotBase.cxx:63
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
PixelAthClusterMonAlgCfg.histname
histname
Definition: PixelAthClusterMonAlgCfg.py:106
SG::ExcBadAuxVar
Exception — Attempt to retrieve nonexistent aux data item.
Definition: Control/AthContainers/AthContainers/exceptions.h:59
ManagedMonitorToolBase::initialize
virtual StatusCode initialize()
Definition: ManagedMonitorToolBase.cxx:616
SG::Decorator< float >
HepMC::is_simulation_particle
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
Definition: MagicNumbers.h:354
xAOD::L2StandAloneMuon_v2::sAddress
int sAddress() const
Get the station address of the muon.
lumiFormat.i
int i
Definition: lumiFormat.py:85
MuonPhysValMonitoringTool.h
PlotBase::initialize
void initialize()
Definition: PlotBase.cxx:39
xAOD::P4Helpers::deltaR
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Definition: xAODP4Helpers.h:150
h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
extractSporadic.h
list h
Definition: extractSporadic.py:96
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ReweightUtils.category
category
Definition: ReweightUtils.py:15
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
xAOD::L2CombinedMuon_v1::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
xAOD::MuonRoI_v1
Class describing a LVL1 muon region of interest.
Definition: MuonRoI_v1.h:29
HepMC::uniqueID
int uniqueID(const T &p)
Definition: MagicNumbers.h:116
xAOD::Muon_v1::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MakeTH3DFromTH2Ds.hists
hists
Definition: MakeTH3DFromTH2Ds.py:72
xAOD::int
setRawEt setRawPhi int
Definition: TrigCaloCluster_v1.cxx:33
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
MuonParameters::NumberOfMuonAuthors
@ NumberOfMuonAuthors
Definition: MuonParamDefs.h:69
MuonPhysValMonitoring
Definition: MuonPhysValMonitoringTool.cxx:41
HepMC::UNDEFINED_ID
constexpr int UNDEFINED_ID
Definition: MagicNumbers.h:56
xAOD::IParticle::pt
virtual double pt() const =0
The transverse momentum ( ) of the particle.
xAOD::SlowMuon_v1::muonLink
const ElementLink< MuonContainer > & muonLink() const
Trig::FeatureContainer::get
const std::vector< Trig::Feature< T > > get(const std::string &label="", unsigned int condition=TrigDefs::Physics, const std::string &teName="") const
returns flattened vector of Features of given type This method is in fact sullied by 3 arguments.
Definition: FeatureContainer.h:151
threshold
Definition: chainparser.cxx:74
MuonParameters::MuidSA
@ MuidSA
Definition: MuonParamDefs.h:59
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:192
xAOD::TruthParticle_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: TruthParticle_v1.cxx:169
xAOD::L2StandAloneMuon_v2::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
python.PyAthena.v
v
Definition: PyAthena.py:154
Muon::MuonSegmentPlots
Definition: MuonSegmentPlots.h:18
MC::isStable
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
Definition: HepMCHelpers.h:45
Muons
Definition: Muons.py:1
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::P4Helpers
Definition: xAODP4Helpers.h:36
xAOD::IParticle::eta
virtual double eta() const =0
The pseudorapidity ( ) of the particle.
MuonRoI.h
DEBUG
#define DEBUG
Definition: page_access.h:11
CaloCondBlobAlgs_fillNoiseFromASCII.author
string author
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:25
covarianceTool.plots
plots
Definition: covarianceTool.py:698
xAOD::TruthParticle_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: TruthParticle_v1.cxx:161
xAOD::L2StandAloneMuon_v2::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
IParticleHelpers.h
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
xAOD::L2StandAloneMuon_v2::roiWord
uint32_t roiWord() const
Get the RoI ID of the seeding LVL1 muon.
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
VectorOperations::SplitString
std::vector< std::string > SplitString(std::string &s, char delimiter, bool IncludeEmptyStrings=false)
MuonEnumDefs.h
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:51
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:67
python.compressB64.c
def c
Definition: compressB64.py:93
HepMCHelpers.h
fitman.k
k
Definition: fitman.py:528
python.SystemOfUnits.m
float m
Definition: SystemOfUnits.py:106
SG::ConstAccessor::withDefault
const_reference_type withDefault(const ELT &e, const T &deflt) const
Fetch the variable for one element, as a const reference, with a default.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
xAOD::MuonRoI_v1::phi
float phi() const
The azimuthal angle ( ) of the muon candidate.