ATLAS Offline Software
DefectsEmulatorBase.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 // Silicon trackers includes
5 #include "DefectsEmulatorBase.h"
6 #include "TH2.h"
7 #include <sstream>
8 
9 
10 namespace InDet{
11  using namespace InDet;
12  DefectsEmulatorBase::DefectsEmulatorBase(const std::string &name, ISvcLocator *pSvcLocator)
13  : AthReentrantAlgorithm(name, pSvcLocator)
14  {}
15 
17  if (!m_histSvc.name().empty() && !m_histogramGroupName.value().empty()) {
18  ATH_CHECK( m_histSvc.retrieve() );
19  // allow histogramming for at most 6 different pixel module types
20  // histgram for additional module types will end up in the last histogram
21  constexpr unsigned int n_different_pixel_matrices_max=6;
22  m_dimPerHist.reserve(n_different_pixel_matrices_max);
23  m_hist.reserve(n_different_pixel_matrices_max);
24 
25  m_moduleHist = new TH2F("rejected_hits_per_module","Rejected hits per module",
26  100, -0.5, 100-0.5,
27  100, -0.5, 100-0.5
28  );
29  m_moduleHist->GetXaxis()->SetTitle("ID hash % 100");
30  m_moduleHist->GetYaxis()->SetTitle("ID hash / 100");
31  if ( m_histSvc->regHist(m_histogramGroupName.value() + m_moduleHist->GetName(),m_moduleHist).isFailure() ) {
32  return StatusCode::FAILURE;
33  }
35  }
36  return StatusCode::SUCCESS;
37  }
39  ATH_MSG_INFO( "Total number of rejected RDOs " << m_rejectedRDOs << ", kept " << m_totalRDOs);
40  return StatusCode::SUCCESS;
41  }
42 
43  TH2 *DefectsEmulatorBase::findHist(unsigned int n_rows, unsigned int n_cols) const {
44  unsigned int key=(n_rows << 16) | n_cols;
45  std::vector<unsigned int>::const_iterator iter = std::find(m_dimPerHist.begin(),m_dimPerHist.end(), key );
46  if (iter == m_dimPerHist.end()) {
47  if (m_dimPerHist.size() == m_dimPerHist.capacity()) {
48  if (m_dimPerHist.capacity()==0) {
49  return nullptr;
50  }
51  else {
52  return m_hist.back();
53  }
54  }
55  else {
56  std::stringstream name;
57  name << "rejected_hits_" << n_rows << "_" << n_cols;
58  std::stringstream title;
59  title << "Rejected hits for " << n_rows << "(rows) #times " << n_cols << " (columns)";
60  m_hist.push_back(new TH2F(name.str().c_str(), title.str().c_str(),
61  n_cols, -0.5, n_cols-0.5,
62  n_rows, -0.5, n_rows-0.5
63  ));
64  m_hist.back()->GetXaxis()->SetTitle("offline column");
65  m_hist.back()->GetYaxis()->SetTitle("offline row");
66  if ( m_histSvc->regHist(m_histogramGroupName.value() + name.str(),m_hist.back()).isFailure() ) {
67  throw std::runtime_error("Failed to register histogram.");
68  }
69  m_dimPerHist.push_back(key);
70  return m_hist.back();
71  }
72  }
73  else {
74  return m_hist.at(iter-m_dimPerHist.begin());
75  }
76  }
77 
78 }// namespace closure
InDet::DefectsEmulatorBase::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
Definition: DefectsEmulatorBase.h:32
InDet::DefectsEmulatorBase::finalize
virtual StatusCode finalize() override
Definition: DefectsEmulatorBase.cxx:38
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
InDet::DefectsEmulatorBase::findHist
TH2 * findHist(unsigned int n_rows, unsigned int n_cols) const
Definition: DefectsEmulatorBase.cxx:43
InDet::DefectsEmulatorBase::m_totalRDOs
std::atomic< std::size_t > m_totalRDOs
Definition: DefectsEmulatorBase.h:48
InDet
Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
InDet::DefectsEmulatorBase::DefectsEmulatorBase
DefectsEmulatorBase(const std::string &name, ISvcLocator *pSvcLocator)
Definition: DefectsEmulatorBase.cxx:12
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
covarianceTool.title
title
Definition: covarianceTool.py:542
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDet::DefectsEmulatorBase::m_histogrammingEnabled
bool m_histogrammingEnabled
Definition: DefectsEmulatorBase.h:50
InDet::DefectsEmulatorBase::initialize
virtual StatusCode initialize() override
Definition: DefectsEmulatorBase.cxx:16
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
InDet::DefectsEmulatorBase::m_histogramGroupName
Gaudi::Property< std::string > m_histogramGroupName
Definition: DefectsEmulatorBase.h:34
DefectsEmulatorBase.h
InDet::DefectsEmulatorBase::m_rejectedRDOs
std::atomic< std::size_t > m_rejectedRDOs
Definition: DefectsEmulatorBase.h:47
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37