ATLAS Offline Software
Functions
G4LegacyTransportTool.cxx File Reference
#include "G4LegacyTransportTool.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 "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::G4LegacyTransportTool::initializeOnce ATLAS_NOT_THREAD_SAFE ()
 Install fatal handler with default options. More...
 

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

void iGeant4::G4LegacyTransportTool::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 102 of file G4LegacyTransportTool.cxx.

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