ATLAS Offline Software
DefectsEmulatorBase.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef INDET_DEFECTSEMULATORBASE_H
5 #define INDET_DEFECTSEMULATORBASE_H
6 
7 #include "GaudiKernel/ServiceHandle.h"
9 #include "GaudiKernel/ITHistSvc.h"
15 
16 #include <string>
17 #include <vector>
18 #include <mutex>
19 #include <atomic>
20 #include <string_view>
21 #include <array>
22 
23 class TH2;
24 
25 namespace InDet {
26 
31 public:
32  DefectsEmulatorBase(const std::string &name,ISvcLocator *pSvcLocator);
33 
34  StatusCode initializeBase(unsigned int wafer_hash_max);
35  virtual StatusCode finalize() override;
36 
37 protected:
45  virtual bool setModuleData(const ActsDetectorElement &acts_detector_element,
46  ModuleIdentifierMatchUtil::ModuleData_t &module_data) const = 0;
47 
54  std::tuple<TH2 *,TH2 *, TH1 *> findHist(unsigned int n_rows, unsigned int n_cols) const;
55 
57  {this,"HistSvc","THistSvc"};
58  Gaudi::Property<std::string> m_histogramGroupName
59  {this,"HistogramGroupName","", "Histogram group name or empty to disable histogramming"};
60 
61  Gaudi::Property<std::vector<std::vector<int> > > m_modulePattern
62  {this,"ModulePatterns", {},
63  "Integer ranges to select: (0-1) barrel/end-cap range, (2-3) layer, (4-5) eta index range, (6-7) phi index range, "
64  "(8-9) module number of columns or strips, (10) both sides (0,1), (11) all rows (0,1)" };
65 
66  Gaudi::Property<std::vector<float> > m_noiseProbability
67  {this,"NoiseProbability",0., "Probability for a cell to produce a spurious hit per module pattern"};
68  Gaudi::Property<std::vector<std::vector<double>> > m_noiseShape
69  {this,"NoiseShape",{}, "Shape of noise distribution (e.g. used for Pixel tot distribution or strip time bin distribution."};
70 
71 
72  enum EHistType {
76  };
77  static const std::array<std::string_view,kNHistTypes> s_histNames;
78  static const std::array<std::string_view,kNHistTypes> s_histTitles;
79 
81  // access to the following must be protected by m_histMutex during execute
82  mutable std::vector<unsigned int> m_dimPerHist ATLAS_THREAD_SAFE;
83  mutable std::array<TH2 *,kNHistTypes> m_moduleHist ATLAS_THREAD_SAFE {};
84  mutable std::array<std::vector< TH2 *>,2> m_hist ATLAS_THREAD_SAFE;
85  mutable std::vector< TH1 *> m_noiseShapeHist ATLAS_THREAD_SAFE;
86 
87  // Simple counters for dropped and copied RDOs
88  mutable std::atomic<std::size_t> m_rejectedRDOs {};
89  mutable std::atomic<std::size_t> m_totalRDOs {};
90  mutable std::atomic<std::size_t> m_splitRDOs {};
91  mutable std::atomic<std::size_t> m_totalNoise {};
92 
93  PublicToolHandle<ActsTrk::ITrackingGeometryTool> m_trackingGeometryTool
94  {this, "TrackingGeometryTool", "ActsTrackingGeometryTool"};
95 
96  ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""};
97  std::string m_rngName;
98  std::vector<unsigned short> m_noiseParamIdx;
99  std::vector<std::vector<float> > m_noiseShapeCummulative;
100 
101  unsigned int m_maxNShape {};
102 
104 
105 };
106 
107 }
108 
109 #endif
InDet::DefectsEmulatorBase::EHistType
EHistType
Definition: DefectsEmulatorBase.h:72
InDet::DefectsEmulatorBase::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
Definition: DefectsEmulatorBase.h:57
InDet::DefectsEmulatorBase::finalize
virtual StatusCode finalize() override
Definition: DefectsEmulatorBase.cxx:158
InDet::DefectsEmulatorBase
Common base class for the specializations of the DefectsEmulatorAlg template.
Definition: DefectsEmulatorBase.h:30
InDet::DefectsEmulatorBase::m_rngName
std::string m_rngName
Definition: DefectsEmulatorBase.h:97
InDet::DefectsEmulatorBase::m_totalRDOs
std::atomic< std::size_t > m_totalRDOs
Definition: DefectsEmulatorBase.h:89
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
InDet
Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
InDet::DefectsEmulatorBase::m_trackingGeometryTool
PublicToolHandle< ActsTrk::ITrackingGeometryTool > m_trackingGeometryTool
Definition: DefectsEmulatorBase.h:94
InDet::DefectsEmulatorBase::ATLAS_THREAD_SAFE
std::array< std::vector< TH2 * >, 2 > m_hist ATLAS_THREAD_SAFE
Definition: DefectsEmulatorBase.h:84
InDet::DefectsEmulatorBase::m_maxNShape
unsigned int m_maxNShape
Definition: DefectsEmulatorBase.h:101
InDet::DefectsEmulatorBase::setModuleData
virtual bool setModuleData(const ActsDetectorElement &acts_detector_element, ModuleIdentifierMatchUtil::ModuleData_t &module_data) const =0
Set the module data for matching for the given detector element.
InDet::DefectsEmulatorBase::m_noiseShape
Gaudi::Property< std::vector< std::vector< double > > > m_noiseShape
Definition: DefectsEmulatorBase.h:69
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
InDet::DefectsEmulatorBase::s_histNames
static const std::array< std::string_view, kNHistTypes > s_histNames
Definition: DefectsEmulatorBase.h:77
InDet::DefectsEmulatorBase::ATLAS_THREAD_SAFE
std::vector< unsigned int > m_dimPerHist ATLAS_THREAD_SAFE
Definition: DefectsEmulatorBase.h:82
InDet::DefectsEmulatorBase::kNoiseHits
@ kNoiseHits
Definition: DefectsEmulatorBase.h:74
InDet::ModuleIdentifierMatchUtil::ModuleData_t
std::array< int, ModuleIdentifierMatchUtil::kAllRows/2 > ModuleData_t
Definition: ModuleIdentifierMatchUtil.h:67
InDet::DefectsEmulatorBase::DefectsEmulatorBase
DefectsEmulatorBase(const std::string &name, ISvcLocator *pSvcLocator)
Definition: DefectsEmulatorBase.cxx:21
InDet::DefectsEmulatorBase::m_noiseProbability
Gaudi::Property< std::vector< float > > m_noiseProbability
Definition: DefectsEmulatorBase.h:67
InDet::DefectsEmulatorBase::ATLAS_THREAD_SAFE
std::vector< TH1 * > m_noiseShapeHist ATLAS_THREAD_SAFE
Definition: DefectsEmulatorBase.h:85
InDet::DefectsEmulatorBase::m_noiseShapeCummulative
std::vector< std::vector< float > > m_noiseShapeCummulative
Definition: DefectsEmulatorBase.h:99
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
InDet::DefectsEmulatorBase::m_histogrammingEnabled
bool m_histogrammingEnabled
Definition: DefectsEmulatorBase.h:103
ActsDetectorElement
Definition: ActsDetectorElement.h:44
GeometryDefs.h
ActsDetectorElement.h
InDet::DefectsEmulatorBase::m_histMutex
std::mutex m_histMutex
Definition: DefectsEmulatorBase.h:80
InDet::DefectsEmulatorBase::s_histTitles
static const std::array< std::string_view, kNHistTypes > s_histTitles
Definition: DefectsEmulatorBase.h:78
InDet::DefectsEmulatorBase::m_splitRDOs
std::atomic< std::size_t > m_splitRDOs
Definition: DefectsEmulatorBase.h:90
AthReentrantAlgorithm.h
InDet::DefectsEmulatorBase::m_totalNoise
std::atomic< std::size_t > m_totalNoise
Definition: DefectsEmulatorBase.h:91
InDet::DefectsEmulatorBase::kNHistTypes
@ kNHistTypes
Definition: DefectsEmulatorBase.h:75
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
InDet::DefectsEmulatorBase::m_modulePattern
Gaudi::Property< std::vector< std::vector< int > > > m_modulePattern
Definition: DefectsEmulatorBase.h:62
InDet::DefectsEmulatorBase::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Definition: DefectsEmulatorBase.h:96
InDet::DefectsEmulatorBase::m_histogramGroupName
Gaudi::Property< std::string > m_histogramGroupName
Definition: DefectsEmulatorBase.h:59
ITrackingGeometryTool.h
InDet::DefectsEmulatorBase::kRejectedHits
@ kRejectedHits
Definition: DefectsEmulatorBase.h:73
InDet::DefectsEmulatorBase::initializeBase
StatusCode initializeBase(unsigned int wafer_hash_max)
Definition: DefectsEmulatorBase.cxx:25
ModuleIdentifierMatchUtil.h
InDet::DefectsEmulatorBase::m_rejectedRDOs
std::atomic< std::size_t > m_rejectedRDOs
Definition: DefectsEmulatorBase.h:88
InDet::DefectsEmulatorBase::findHist
std::tuple< TH2 *, TH2 *, TH1 * > findHist(unsigned int n_rows, unsigned int n_cols) const
Get rejected hits and noise histograms for a certain module design.
Definition: DefectsEmulatorBase.cxx:165
InDet::DefectsEmulatorBase::m_noiseParamIdx
std::vector< unsigned short > m_noiseParamIdx
Definition: DefectsEmulatorBase.h:98
IAthRNGSvc.h
ServiceHandle< ITHistSvc >