ATLAS Offline Software
Functions
G4LegacyTransportTool.cxx File Reference
#include "G4LegacyTransportTool.h"
#include "AthenaKernel/RNGWrapper.h"
#include "CxxUtils/checker_macros.h"
#include "G4AtlasAlg/G4AtlasRunManager.h"
#include "G4AtlasTools/G4AtlasActionInitialization.h"
#include "G4AtlasTools/G4AtlasUserWorkerInitialization.h"
#include "ISFFluxRecorder.h"
#include "ISF_Event/ISFParticle.h"
#include "ISF_Event/ISFParticleContainer.h"
#include "AtlasDetDescr/AtlasRegionHelper.h"
#include "GeneratorObjects/McEventCollection.h"
#include "HitManagement/HitCollectionMap.h"
#include "MCTruth/AtlasG4EventUserInfo.h"
#include "MCTruth/PrimaryParticleInformation.h"
#include "AtlasHepMC/GenParticle.h"
#include "G4ChargedGeantino.hh"
#include "G4Event.hh"
#include "G4Geantino.hh"
#include "G4LorentzVector.hh"
#include "G4ParallelWorldPhysics.hh"
#include "G4ParticleTable.hh"
#include "G4PrimaryParticle.hh"
#include "G4PrimaryVertex.hh"
#include "G4SDManager.hh"
#include "G4ScoringManager.hh"
#include "G4StateManager.hh"
#include "G4Timer.hh"
#include "G4Trajectory.hh"
#include "G4TransportationManager.hh"
#include "G4UImanager.hh"
#include "G4VModularPhysicsList.hh"
#include "G4VUserPhysicsList.hh"
#include <memory>
#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

getCoefficientMap(label, EigenIdxList)

input value:

  1. label: falvor label in std::string format, could be one of B, C, T, Light
  2. EigenIdxList is user defined vector containing all eigenvector index that user interested in. output: Map of format map<string, map<string, float>> containing decomposition coefficient of the list of eigenvectors defined by EigenIdxList.

getCoefficients(label, evIdx)

input value:

  1. label: falvor label in std::string format, could be one of B, C, T, Light
  2. evIdx: The index of eigenvector user interested in. output value: vector of coefficient values. The order is the same as output given by getListOfOriginalNuisanceParameters()

getListOfOriginalNuisanceParameters(label)

input value:

  1. label: falvor label in std::string format, could be one of B, C, T, Light output value: List of original nuisance parameter names.

getNumEigenVectors(label)

input value:

  1. label: falvor label in std::string format, could be one of B, C, T, Light return value: number of eigen vectors used for chosen label. Return 0 if error occured.

now add branches and leaves to the tree

now add branches and leaves to the tree

Definition at line 103 of file G4LegacyTransportTool.cxx.

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