ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
NeutronFastSimTool Class Reference

#include <NeutronFastSimTool.h>

Inheritance diagram for NeutronFastSimTool:
Collaboration diagram for NeutronFastSimTool:

Public Member Functions

 NeutronFastSimTool (const std::string &type, const std::string &name, const IInterface *parent)
 
 ~NeutronFastSimTool ()
 
StatusCode initializeFastSim () override
 Construct and setup the fast simulation model. More...
 
virtual StatusCode BeginOfAthenaEvent () override
 Begin of an athena event - do anything that needs to be done at the beginning of each athena event. More...
 
virtual StatusCode EndOfAthenaEvent () override
 End of an athena event - do any tidying up required at the end of each athena event. More...
 

Protected Member Functions

virtual G4VFastSimulationModel * makeFastSimModel () override final
 Method to make the actual fast simulation model itself, which will be owned by the tool. More...
 
G4VFastSimulationModel * getFastSimModel ()
 Retrieve the current Fast Simulation Model. More...
 

Protected Attributes

Gaudi::Property< std::vector< std::string > > m_regionNames {this, "RegionNames", {}}
 All the regions to which this fast sim is assigned. More...
 
Gaudi::Property< bool > m_noRegions {this, "NoRegions", false}
 This Fast Simulation has no regions associated with it. More...
 

Private Member Functions

void setFastSimModel (G4VFastSimulationModel *)
 Set the current model. In hive, this gets assigned as the thread-local model. More...
 
void deleteFastSimModel ()
 Delete the current model. More...
 

Private Attributes

std::string m_trackFastSimSDName
 
double m_etaCut
 
double m_timeCut
 !< Eta cut for primaries More...
 
G4VFastSimulationModel * m_FastSimModel {}
 The Fast Simulation Model to which this thing corresponds. More...
 

Detailed Description

Definition at line 14 of file NeutronFastSimTool.h.

Constructor & Destructor Documentation

◆ NeutronFastSimTool()

NeutronFastSimTool::NeutronFastSimTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 9 of file NeutronFastSimTool.cxx.

11  m_trackFastSimSDName("TrackFastSimSDTool"),
12  m_etaCut(6.0),
13  m_timeCut(150.)
14 {
15  declareProperty("TrackFastSimSDName", m_trackFastSimSDName);
16  declareProperty("PrimaryEtaCut",m_etaCut);
17  declareProperty("NeutronTimeCut",m_timeCut);
18 }

◆ ~NeutronFastSimTool()

NeutronFastSimTool::~NeutronFastSimTool ( )
inline

Definition at line 19 of file NeutronFastSimTool.h.

19 {}

Member Function Documentation

◆ BeginOfAthenaEvent()

virtual StatusCode FastSimulationBase::BeginOfAthenaEvent ( )
inlineoverridevirtualinherited

Begin of an athena event - do anything that needs to be done at the beginning of each athena event.

Reimplemented in FastCaloSimTool.

Definition at line 41 of file FastSimulationBase.h.

41 { return StatusCode::SUCCESS; }

◆ deleteFastSimModel()

void FastSimulationBase::deleteFastSimModel ( )
privateinherited

Delete the current model.

Definition at line 99 of file FastSimulationBase.cxx.

100 {
101 #ifdef G4MULTITHREADED
102  for(auto& threadMapPair : m_fastsimmodelThreadMap)
103  {
104  auto fastSimModel = threadMapPair.second;
105  if (fastSimModel)
106  delete fastSimModel;
107  }
108  m_fastsimmodelThreadMap.clear();
109 #else
110  if(m_FastSimModel)
111  {
112  delete m_FastSimModel;
113  m_FastSimModel = 0;
114  }
115 #endif
116 }

◆ EndOfAthenaEvent()

virtual StatusCode FastSimulationBase::EndOfAthenaEvent ( )
inlineoverridevirtualinherited

End of an athena event - do any tidying up required at the end of each athena event.

Reimplemented in FastCaloSimTool, and LArFastShowerTool.

Definition at line 44 of file FastSimulationBase.h.

44 { return StatusCode::SUCCESS; }

◆ getFastSimModel()

G4VFastSimulationModel * FastSimulationBase::getFastSimModel ( )
protectedinherited

Retrieve the current Fast Simulation Model.

In MT, this means the thread-local Fast Simulation Model. Otherwise, it is simply the single Fast Simulation Model.

Definition at line 73 of file FastSimulationBase.cxx.

74 {
75 #ifdef G4MULTITHREADED
76  // Get current thread-ID
77  const auto tid = std::this_thread::get_id();
78  // Retrieve it from the FastSimModel map
79  auto fastsimmodelPair = m_fastsimmodelThreadMap.find(tid);
80  if(fastsimmodelPair == m_fastsimmodelThreadMap.end()) return nullptr;
81  return fastsimmodelPair->second;
82 #else
83  return m_FastSimModel;
84 #endif
85 }

◆ initializeFastSim()

StatusCode FastSimulationBase::initializeFastSim ( )
overrideinherited

Construct and setup the fast simulation model.

This method invokes the makeFastSimModel of the derived concrete tool type and assigns the configured regions. Errors are reported if regions are missing. In multi-threading jobs, this method is called once per worker thread.

Definition at line 23 of file FastSimulationBase.cxx.

23  {
24  ATH_MSG_VERBOSE( name() << "::initializeFastSim()" );
25 
26  // Make sure Fast Simulation Model isn't already registered
27  if(getFastSimModel()){
28  ATH_MSG_ERROR("Trying to create a Fast Simulation Model which already exists!");
29  return StatusCode::FAILURE;
30  }
31 
32  // Make the FastSimModel stored by this tool
33  auto* fastsimmodel = makeFastSimModel();
34  setFastSimModel(fastsimmodel);
35 
36  // Set the verbosity information on this thing - this will have to go into the makeFastSimModel methods...
37  //if(msgLvl(MSG::VERBOSE)) m_FastSimModel->SetVerboseLevel(10);
38  //else if(msgLvl(MSG::DEBUG)) m_FastSimModel->SetVerboseLevel(5);
39 
40  // Go through the regions and hook the fast simulation up
41  G4RegionStore* regionStore = G4RegionStore::GetInstance();
42  bool missedOne = false;
43  for (const auto& myreg : m_regionNames.value()){
44  int found=0; // Regions with more than one name...
45  for (auto* areg : *regionStore){
46  if (myreg.data()==areg->GetName()){
47  ++found;
48  G4FastSimulationManager* theFastSimulationManager = areg->GetFastSimulationManager();
49 
50  // Build a new fast sim manager if necessary
51  if ( theFastSimulationManager == 0 ) theFastSimulationManager = new G4FastSimulationManager(areg);
52  theFastSimulationManager->AddFastSimulationModel(getFastSimModel());
53  theFastSimulationManager->ActivateFastSimulationModel(getFastSimModel()->GetName());
54  }
55  } // Loop over regions
56  if (0==found){
57  ATH_MSG_ERROR( "Region " << myreg << " not found." );
58  missedOne=true;
59  } else {
60  ATH_MSG_VERBOSE( found << " copies of region " << myreg << " found; fast simulation " << name() << " assigned." );
61  }
62  } // Loop over regions I want
63 
64  // Crash out if we have failed to assign a volume - this is bad news!
65  if (missedOne && !m_noRegions){
66  ATH_MSG_ERROR( "Failed to assign at least one volume to Fast Simulation Model " << name() );
67  return StatusCode::FAILURE;
68  }
69 
70  return StatusCode::SUCCESS;
71 }

◆ makeFastSimModel()

G4VFastSimulationModel * NeutronFastSimTool::makeFastSimModel ( )
finaloverrideprotectedvirtual

Method to make the actual fast simulation model itself, which will be owned by the tool.

Must be implemented in all concrete base classes.

Definition at line 20 of file NeutronFastSimTool.cxx.

21 {
22  ATH_MSG_DEBUG( "Initializing Fast Sim Model" );
23 
24  // Create a fresh Fast Sim Model
26 }

◆ setFastSimModel()

void FastSimulationBase::setFastSimModel ( G4VFastSimulationModel *  fastsimmodel)
privateinherited

Set the current model. In hive, this gets assigned as the thread-local model.

Definition at line 87 of file FastSimulationBase.cxx.

88 {
89 #ifdef G4MULTITHREADED
90  // Make sure one isn't already assigned
91  const auto tid = std::this_thread::get_id();
92  ATH_MSG_DEBUG("Creating and registering FastSimModel " << fastsimmodel << " in thread " << tid);
93  m_fastsimmodelThreadMap.insert( std::make_pair(tid, fastsimmodel) );
94 #else
95  m_FastSimModel = fastsimmodel;
96 #endif
97 }

Member Data Documentation

◆ m_etaCut

double NeutronFastSimTool::m_etaCut
private

Definition at line 27 of file NeutronFastSimTool.h.

◆ m_FastSimModel

G4VFastSimulationModel* FastSimulationBase::m_FastSimModel {}
privateinherited

The Fast Simulation Model to which this thing corresponds.

Definition at line 74 of file FastSimulationBase.h.

◆ m_noRegions

Gaudi::Property<bool> FastSimulationBase::m_noRegions {this, "NoRegions", false}
protectedinherited

This Fast Simulation has no regions associated with it.

Definition at line 55 of file FastSimulationBase.h.

◆ m_regionNames

Gaudi::Property<std::vector<std::string> > FastSimulationBase::m_regionNames {this, "RegionNames", {}}
protectedinherited

All the regions to which this fast sim is assigned.

Definition at line 53 of file FastSimulationBase.h.

◆ m_timeCut

double NeutronFastSimTool::m_timeCut
private

!< Eta cut for primaries

Definition at line 28 of file NeutronFastSimTool.h.

◆ m_trackFastSimSDName

std::string NeutronFastSimTool::m_trackFastSimSDName
private

Definition at line 26 of file NeutronFastSimTool.h.


The documentation for this class was generated from the following files:
NeutronFastSimTool::m_timeCut
double m_timeCut
!< Eta cut for primaries
Definition: NeutronFastSimTool.h:28
FastSimulationBase::m_FastSimModel
G4VFastSimulationModel * m_FastSimModel
The Fast Simulation Model to which this thing corresponds.
Definition: FastSimulationBase.h:74
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
FastSimulationBase::m_noRegions
Gaudi::Property< bool > m_noRegions
This Fast Simulation has no regions associated with it.
Definition: FastSimulationBase.h:55
NeutronFastSim
Definition: NeutronFastSim.h:17
FastSimulationBase::setFastSimModel
void setFastSimModel(G4VFastSimulationModel *)
Set the current model. In hive, this gets assigned as the thread-local model.
Definition: FastSimulationBase.cxx:87
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
NeutronFastSimTool::m_etaCut
double m_etaCut
Definition: NeutronFastSimTool.h:27
FastSimulationBase::FastSimulationBase
FastSimulationBase(const std::string &type, const std::string &name, const IInterface *parent)
Definition: FastSimulationBase.cxx:11
test_pyathena.parent
parent
Definition: test_pyathena.py:15
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
FastSimulationBase::m_regionNames
Gaudi::Property< std::vector< std::string > > m_regionNames
All the regions to which this fast sim is assigned.
Definition: FastSimulationBase.h:53
FastSimulationBase::getFastSimModel
G4VFastSimulationModel * getFastSimModel()
Retrieve the current Fast Simulation Model.
Definition: FastSimulationBase.cxx:73
NeutronFastSimTool::m_trackFastSimSDName
std::string m_trackFastSimSDName
Definition: NeutronFastSimTool.h:26
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78