ATLAS Offline Software
FastSimulationBase.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 G4ATLASTOOLS_FASTSIMULATIONBASE_H
6 #define G4ATLASTOOLS_FASTSIMULATIONBASE_H
7 
8 // Base classes
11 
12 // Members
13 #include <G4Region.hh>
14 #include "G4Types.hh"
15 #include "G4VFastSimulationModel.hh"
16 #ifdef G4MULTITHREADED
17 # include "tbb/concurrent_unordered_map.h"
18 #endif
19 
20 // STL library
21 #include <string>
22 #include <vector>
23 #include <thread>
24 
27 class FastSimulationBase : public extends<AthAlgTool, IFastSimulation> {
28  public:
29  FastSimulationBase(const std::string& type, const std::string& name,
30  const IInterface *parent);
31  virtual ~FastSimulationBase();
32 
39  StatusCode initializeFastSim() override;
40 
42  virtual StatusCode BeginOfAthenaEvent() override { return StatusCode::SUCCESS; }
43 
45  virtual StatusCode EndOfAthenaEvent() override { return StatusCode::SUCCESS; }
46 
47  protected:
51  G4VFastSimulationModel* getFastSimModel();
52 
53  // Helper to retrieve the region to which this fast simulation is assigned from the region store.
54  G4Region* getRegion() const;
55 
57  Gaudi::Property<std::string> m_regionName{this, "RegionName", ""};
59  Gaudi::Property<bool> m_noRegions{this, "NoRegions", false};
60 
61  private:
62 
64  void setFastSimModel(G4VFastSimulationModel*);
65 
67  void deleteFastSimModel();
68 
69 #ifdef G4MULTITHREADED
70  typedef tbb::concurrent_unordered_map < std::thread::id,
72  G4VFastSimulationModel*,
73  std::hash<std::thread::id> > FastSimModelThreadMap_t;
75  FastSimModelThreadMap_t m_fastsimmodelThreadMap;
76 #else
77  G4VFastSimulationModel* m_FastSimModel{};
79 #endif
80 };
81 
82 #endif
FastSimulationBase::m_regionName
Gaudi::Property< std::string > m_regionName
The region to which this fast sim is assigned.
Definition: FastSimulationBase.h:57
FastSimulationBase
Definition: FastSimulationBase.h:27
FastSimulationBase::deleteFastSimModel
void deleteFastSimModel()
Delete the current model.
Definition: FastSimulationBase.cxx:78
FastSimulationBase::m_FastSimModel
G4VFastSimulationModel * m_FastSimModel
The Fast Simulation Model to which this thing corresponds.
Definition: FastSimulationBase.h:78
IFastSimulation.h
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
FastSimulationBase::~FastSimulationBase
virtual ~FastSimulationBase()
Definition: FastSimulationBase.cxx:17
FastSimulationBase::m_noRegions
Gaudi::Property< bool > m_noRegions
This Fast Simulation has no regions associated with it.
Definition: FastSimulationBase.h:59
FastSimulationBase::setFastSimModel
void setFastSimModel(G4VFastSimulationModel *)
Set the current model. In hive, this gets assigned as the thread-local model.
Definition: FastSimulationBase.cxx:66
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthAlgTool.h
FastSimulationBase::FastSimulationBase
FastSimulationBase(const std::string &type, const std::string &name, const IInterface *parent)
Definition: FastSimulationBase.cxx:12
FastSimulationBase::BeginOfAthenaEvent
virtual StatusCode BeginOfAthenaEvent() override
Begin of an athena event - do anything that needs to be done at the beginning of each athena event.
Definition: FastSimulationBase.h:42
test_pyathena.parent
parent
Definition: test_pyathena.py:15
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:239
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
FastSimulationBase::getFastSimModel
G4VFastSimulationModel * getFastSimModel()
Retrieve the current Fast Simulation Model.
Definition: FastSimulationBase.cxx:52
FastSimulationBase::initializeFastSim
StatusCode initializeFastSim() override
Construct and setup the fast simulation model.
Definition: FastSimulationBase.cxx:32
FastSimulationBase::getRegion
G4Region * getRegion() const
Definition: FastSimulationBase.cxx:22
FastSimulationBase::EndOfAthenaEvent
virtual StatusCode EndOfAthenaEvent() override
End of an athena event - do any tidying up required at the end of each athena event.
Definition: FastSimulationBase.h:45