ATLAS Offline Software
Functions
ISF_Geant4/ISF_Geant4Tools/src/TransportTool.cxx File Reference
#include "TransportTool.h"
#include "G4AtlasAlg/G4AtlasMTRunManager.h"
#include "G4AtlasAlg/G4AtlasWorkerRunManager.h"
#include "G4AtlasAlg/G4AtlasUserWorkerThreadInitialization.h"
#include "G4AtlasAlg/G4AtlasRunManager.h"
#include "G4AtlasAlg/G4AtlasActionInitialization.h"
#include "ISFFluxRecorder.h"
#include "AthenaKernel/RNGWrapper.h"
#include "ISF_Event/ISFParticle.h"
#include "ISF_Event/ISFParticleContainer.h"
#include "GeneratorObjects/McEventCollection.h"
#include "GaudiKernel/IThreadInitTool.h"
#include "MCTruth/PrimaryParticleInformation.h"
#include "MCTruth/AtlasG4EventUserInfo.h"
#include "AtlasHepMC/GenParticle.h"
#include "G4LorentzVector.hh"
#include "G4PrimaryVertex.hh"
#include "G4PrimaryParticle.hh"
#include "G4Trajectory.hh"
#include "G4Geantino.hh"
#include "G4ChargedGeantino.hh"
#include "G4ParticleTable.hh"
#include "G4StateManager.hh"
#include "G4TransportationManager.hh"
#include "G4UImanager.hh"
#include "G4ScoringManager.hh"
#include "G4Timer.hh"
#include "G4SDManager.hh"
#include "G4VUserPhysicsList.hh"
#include "G4VModularPhysicsList.hh"
#include "G4ParallelWorldPhysics.hh"
#include "AtlasDetDescr/AtlasRegionHelper.h"
#include <mutex>

Go to the source code of this file.

Functions

void iGeant4::G4TransportTool::initializeOnce ATLAS_NOT_THREAD_SAFE ()
 Install fatal handler with default options. More...
 

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

void iGeant4::G4TransportTool::initializeOnce ATLAS_NOT_THREAD_SAFE ( )
inline

Install fatal handler with default options.

This is meant to be easy to call from python via ctypes.

Install fatal handler with default options.

getLorentzAngle() Read LorentzAngle from HIST and write out into local DB

getBSErrors() Read BSErrors from Monitoring HIST and write out into local DB

getEfficiency() Read Efficiency from Monitoring HIST and write out into local DB

getRawOccupancy() Read RawOccupancy from Monitoring HIST and write out into local DB

getNoiseOccupancy() Read NoiseOccupancy from HIST and write out into local DB

getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats

beginning of the loop of channels

bad bit newly found

known bad bit

for low noisy cells

for high noisy cells

0.01 is used to scale "PER" to the same order of magnitude to "SIG"

smaller deviation: distorted

checking TmaxAmp, Not mixed with MaxAmp and Width

channel information output

Only dead or distorted, or short known BCs are considered below.

index of bc

now add branches and leaves to the tree

now add branches and leaves to the tree

Definition at line 105 of file ISF_Geant4/ISF_Geant4Tools/src/TransportTool.cxx.

106 {
107  // get G4AtlasRunManager
108  ATH_MSG_DEBUG("initialize G4AtlasRunManager");
109 
110  if(m_physListSvc.retrieve().isFailure()) {
111  throw std::runtime_error("Could not initialize ATLAS PhysicsListSvc!");
112  }
113 
114  // Create the (master) run manager
115  if(m_useMT) {
116 #ifdef G4MULTITHREADED
117  auto* runMgr = G4AtlasMTRunManager::GetG4AtlasMTRunManager();
118  m_physListSvc->SetPhysicsList();
119  runMgr->SetDetGeoSvc( m_detGeoSvc.typeAndName() );
120  runMgr->SetFastSimMasterTool(m_fastSimTool.typeAndName() );
121  runMgr->SetPhysListSvc( m_physListSvc.typeAndName() );
122  // Worker Thread initialization used to create worker run manager on demand.
123  std::unique_ptr<G4AtlasUserWorkerThreadInitialization> workerInit =
124  std::make_unique<G4AtlasUserWorkerThreadInitialization>();
125  workerInit->SetDetGeoSvc( m_detGeoSvc.typeAndName() );
126  workerInit->SetFastSimMasterTool( m_fastSimTool.typeAndName() );
127  runMgr->SetUserInitialization( workerInit.release() );
128  std::unique_ptr<G4AtlasActionInitialization> actionInitialization =
129  std::make_unique<G4AtlasActionInitialization>(&*m_userActionSvc);
130  runMgr->SetUserInitialization(actionInitialization.release());
131 #else
132  throw std::runtime_error("Trying to use multi-threading in non-MT build!");
133 #endif
134  }
135  // Single-threaded run manager
136  else {
137  auto* runMgr = G4AtlasRunManager::GetG4AtlasRunManager();
138  m_physListSvc->SetPhysicsList();
139  runMgr->SetRecordFlux( m_recordFlux, std::make_unique<ISFFluxRecorder>() );
140  runMgr->SetLogLevel( int(msg().level()) ); // Synch log levels
141  runMgr->SetDetGeoSvc( m_detGeoSvc.typeAndName() );
142  runMgr->SetFastSimMasterTool(m_fastSimTool.typeAndName() );
143  runMgr->SetPhysListSvc(m_physListSvc.typeAndName() );
144  std::unique_ptr<G4AtlasActionInitialization> actionInitialization =
145  std::make_unique<G4AtlasActionInitialization>(&*m_userActionSvc);
146  runMgr->SetUserInitialization(actionInitialization.release());
147  }
148 
149  G4UImanager *ui = G4UImanager::GetUIpointer();
150 
151  if (!m_libList.empty()) {
152  ATH_MSG_INFO("G4AtlasAlg specific libraries requested ") ;
153  std::string temp="/load "+m_libList;
154  ui->ApplyCommand(temp);
155  }
156 
157  if (!m_physList.empty()) {
158  ATH_MSG_INFO("requesting a specific physics list "<< m_physList) ;
159  std::string temp="/Physics/GetPhysicsList "+m_physList;
160  ui->ApplyCommand(temp);
161  }
162 
163  if (!m_fieldMap.empty()) {
164  ATH_MSG_INFO("requesting a specific field map "<< m_fieldMap) ;
165  ATH_MSG_INFO("the field is initialized straight away") ;
166  std::string temp="/MagneticField/Select "+m_fieldMap;
167  ui->ApplyCommand(temp);
168  ui->ApplyCommand("/MagneticField/Initialize");
169  }
170 
171  // Send UI commands
172  ATH_MSG_DEBUG("G4 Command: Trying at the end of initializeOnce()");
173  for (const auto& g4command : m_g4commands) {
174  int returnCode = ui->ApplyCommand( g4command );
175  commandLog(returnCode, g4command);
176  }
177 
178  // Code from G4AtlasSvc
179  auto* rm = G4RunManager::GetRunManager();
180  if(!rm) {
181  throw std::runtime_error("Run manager retrieval has failed");
182  }
183  rm->Initialize(); // Initialization differs slightly in multi-threading.
184  // TODO: add more details about why this is here.
185  if(!m_useMT && rm->ConfirmBeamOnCondition()) {
186  rm->RunInitialization();
187  }
188 
189  ATH_MSG_INFO( "retireving the Detector Geometry Service" );
190  if(m_detGeoSvc.retrieve().isFailure()) {
191  throw std::runtime_error("Could not initialize ATLAS DetectorGeometrySvc!");
192  }
193 
194  if(m_userLimitsSvc.retrieve().isFailure()) {
195  throw std::runtime_error("Could not initialize ATLAS UserLimitsSvc!");
196  }
197 
198  if (m_activateParallelGeometries) {
199  G4VModularPhysicsList* thePhysicsList=dynamic_cast<G4VModularPhysicsList*>(m_physListSvc->GetPhysicsList());
200  if (!thePhysicsList) {
201  throw std::runtime_error("Failed dynamic_cast!! this is not a G4VModularPhysicsList!");
202  }
203 #if G4VERSION_NUMBER >= 1010
204  std::vector<std::string>& parallelWorldNames=m_detGeoSvc->GetParallelWorldNames();
205  for (auto& it: parallelWorldNames) {
206  thePhysicsList->RegisterPhysics(new G4ParallelWorldPhysics(it,true));
207  }
208 #endif
209  }
210 
211  return;
212 }
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
skel.it
it
Definition: skel.GENtoEVGEN.py:423
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CI_EMPFlowData22test.returnCode
returnCode
Definition: CI_EMPFlowData22test.py:16
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7