ATLAS Offline Software
EscapedEnergyRegistry.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef CALOG4SIM_ESCAPEDENERGYREGISTRY_H
6 #define CALOG4SIM_ESCAPEDENERGYREGISTRY_H
7 
10 #include "globals.hh"
11 
12 #include <map>
13 #include <memory>
14 
15 #include <thread>
16 #include "G4Types.hh"
17 #ifdef G4MULTITHREADED
18 # include "tbb/concurrent_unordered_map.h"
19 #endif
20 namespace CaloG4
21 {
52  {
53  public:
54 
56 
58 
59  // Add a VEscapedEnergyProcessing object to the registry. The
60  // name include "Adopt" because we assume responsibility for
61  // deleting the pointer.
62  void AddAndAdoptProcessing( const G4String& name, std::unique_ptr<VEscapedEnergyProcessing> process );
63 
64  // Given a volume name,
65  VEscapedEnergyProcessing* GetProcessing( const G4String& volumeName ) const;
66 
67  protected:
68 
69  // Constructor protected according to singleton pattern.
70  EscapedEnergyRegistry() = default;
71 
72  private:
73 
74  typedef std::map< const G4String, std::unique_ptr<VEscapedEnergyProcessing> > m_processingMap_t;
76  typedef m_processingMap_t::const_iterator m_processingMap_const_ptr_t;
78 #ifdef G4MULTITHREADED
79  // Thread-to-EscapeEnergyRegistry concurrent map type
80  using EERThreadMap_t = tbb::concurrent_unordered_map< std::thread::id, EscapedEnergyRegistry*, std::hash<std::thread::id> >;
81  // Concurrent map of EERs, one for each thread
82  static EERThreadMap_t m_EERThreadMap ATLAS_THREAD_SAFE;
83  // @brief Search inside m_EERThreadMap the element with the current threadID
84  // and return it or return a null pointer if the element is not found
85  static EscapedEnergyRegistry* getEER();
86  // @brief Insert the current EER in m_EERThreadMap and
87  // associate it with the current threadID
88  static EscapedEnergyRegistry* setEER();
89 #endif
90  };
91 
92 } // namespace CaloG4
93 
94 #endif // CaloG4_EscapedEnergyRegistry_H
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
CaloG4::EscapedEnergyRegistry::AddAndAdoptProcessing
void AddAndAdoptProcessing(const G4String &name, std::unique_ptr< VEscapedEnergyProcessing > process)
CaloG4::EscapedEnergyRegistry::~EscapedEnergyRegistry
~EscapedEnergyRegistry()=default
CaloG4::EscapedEnergyRegistry::m_processingMap_ptr_t
m_processingMap_t::iterator m_processingMap_ptr_t
Definition: EscapedEnergyRegistry.h:75
CaloG4::EscapedEnergyRegistry::GetProcessing
VEscapedEnergyProcessing * GetProcessing(const G4String &volumeName) const
SUSY_SimplifiedModel_PostInclude.process
string process
Definition: SUSY_SimplifiedModel_PostInclude.py:42
CaloG4::EscapedEnergyRegistry
Keeps track of which types of volumes use which VEscapedEnergyProcessing objects.
Definition: EscapedEnergyRegistry.h:52
CaloG4::EscapedEnergyRegistry::GetInstance
static EscapedEnergyRegistry * GetInstance()
CaloG4
Definition: EscapedEnergyRegistry.h:21
CaloG4::EscapedEnergyRegistry::EscapedEnergyRegistry
EscapedEnergyRegistry()=default
CaloG4::EscapedEnergyRegistry::m_processingMap_const_ptr_t
m_processingMap_t::const_iterator m_processingMap_const_ptr_t
Definition: EscapedEnergyRegistry.h:76
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CaloG4::EscapedEnergyRegistry::m_processingMap
m_processingMap_t m_processingMap
Definition: EscapedEnergyRegistry.h:77
VEscapedEnergyProcessing.h
CaloG4::VEscapedEnergyProcessing
Virtual interface for escaped energy processor classes.
Definition: VEscapedEnergyProcessing.h:43
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
checker_macros.h
Define macros for attributes used to control the static checker.
CaloG4::EscapedEnergyRegistry::m_processingMap_t
std::map< const G4String, std::unique_ptr< VEscapedEnergyProcessing > > m_processingMap_t
Definition: EscapedEnergyRegistry.h:74