Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CexmcRunManager Class Reference

#include <CexmcRunManager.hh>

Inheritance diagram for CexmcRunManager:
Collaboration diagram for CexmcRunManager:

Public Member Functions

 CexmcRunManager (const G4String &projectId="", const G4String &rProject="", G4bool overrideExistingProject=false)
 
virtual ~CexmcRunManager ()
 
void SetPhysicsManager (CexmcPhysicsManager *physicsManager_)
 
void SetProductionModelType (CexmcProductionModelType productionModelType_)
 
void SetGdmlFileName (const G4String &gdmlFileName_)
 
void SetGdmlFileValidation (G4bool on=true)
 
void SetGuiMacroName (const G4String &guiMacroName_)
 
void SetEventCountPolicy (CexmcEventCountPolicy value)
 
void SetEventDataVerboseLevel (CexmcEventDataVerboseLevel value)
 
void RegisterScenePrimitives (void)
 
void BeamParticleChangeHook (void)
 
void SetupConstructionHook (void)
 
CexmcPhysicsManagerGetPhysicsManager (void)
 
CexmcProductionModelType GetProductionModelType (void) const
 
G4String GetGdmlFileName (void) const
 
G4bool ShouldGdmlFileBeValidated (void) const
 
G4String GetGuiMacroName (void) const
 
G4bool ProjectIsSaved (void) const
 
G4bool ProjectIsRead (void) const
 
G4String GetProjectsDir (void) const
 
G4String GetProjectId (void) const
 
CexmcEventDataVerboseLevel GetEventDataVerboseLevel (void) const
 
- Public Member Functions inherited from G4RunManager
 G4RunManager ()
 
virtual ~G4RunManager ()
 
virtual void BeamOn (G4int n_event, const char *macroFile=0, G4int n_select=-1)
 
virtual void Initialize ()
 
virtual void DefineWorldVolume (G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
 
virtual void AbortRun (G4bool softAbort=false)
 
virtual void AbortEvent ()
 
virtual void InitializeGeometry ()
 
virtual void InitializePhysics ()
 
virtual G4bool ConfirmBeamOnCondition ()
 
virtual void RunInitialization ()
 
virtual void RunTermination ()
 
virtual void InitializeEventLoop (G4int n_event, const char *macroFile=0, G4int n_select=-1)
 
virtual void ProcessOneEvent (G4int i_event)
 
virtual void TerminateOneEvent ()
 
virtual void TerminateEventLoop ()
 
virtual G4EventGenerateEvent (G4int i_event)
 
virtual void AnalyzeEvent (G4Event *anEvent)
 
void DumpRegion (const G4String &rname) const
 
void DumpRegion (G4Region *region=0) const
 
virtual void rndmSaveThisRun ()
 
virtual void rndmSaveThisEvent ()
 
virtual void RestoreRandomNumberStatus (const G4String &fileN)
 
virtual void SetUserInitialization (G4VUserDetectorConstruction *userInit)
 
virtual void SetUserInitialization (G4VUserPhysicsList *userInit)
 
virtual void SetUserInitialization (G4VUserActionInitialization *userInit)
 
virtual void SetUserInitialization (G4UserWorkerInitialization *userInit)
 
virtual void SetUserInitialization (G4UserWorkerThreadInitialization *userInit)
 
virtual void SetUserAction (G4UserRunAction *userAction)
 
virtual void SetUserAction (G4VUserPrimaryGeneratorAction *userAction)
 
virtual void SetUserAction (G4UserEventAction *userAction)
 
virtual void SetUserAction (G4UserStackingAction *userAction)
 
virtual void SetUserAction (G4UserTrackingAction *userAction)
 
virtual void SetUserAction (G4UserSteppingAction *userAction)
 
const G4VUserDetectorConstructionGetUserDetectorConstruction () const
 
const G4VUserPhysicsListGetUserPhysicsList () const
 
const G4VUserActionInitializationGetUserActionInitialization () const
 
G4VUserActionInitializationGetNonConstUserActionInitialization () const
 
const G4UserWorkerInitializationGetUserWorkerInitialization () const
 
const
G4UserWorkerThreadInitialization
GetUserWorkerThreadInitialization () const
 
const G4UserRunActionGetUserRunAction () const
 
const
G4VUserPrimaryGeneratorAction
GetUserPrimaryGeneratorAction () const
 
const G4UserEventActionGetUserEventAction () const
 
const G4UserStackingActionGetUserStackingAction () const
 
const G4UserTrackingActionGetUserTrackingAction () const
 
const G4UserSteppingActionGetUserSteppingAction () const
 
void SetNumberOfAdditionalWaitingStacks (G4int iAdd)
 
const G4StringGetVersionString () const
 
void SetPrimaryTransformer (G4PrimaryTransformer *pt)
 
void StoreRandomNumberStatusToG4Event (G4int vl)
 
G4int GetFlagRandomNumberStatusToG4Event () const
 
void SetRandomNumberStore (G4bool flag)
 
G4bool GetRandomNumberStore () const
 
void SetRandomNumberStoreDir (const G4String &dir)
 
const G4StringGetRandomNumberStoreDir () const
 
const G4StringGetRandomNumberStatusForThisRun () const
 
const G4StringGetRandomNumberStatusForThisEvent () const
 
void SetRandomNumberStorePerEvent (G4bool flag)
 
G4bool GetRandomNumberStorePerEvent () const
 
void GeometryHasBeenModified (G4bool prop=true)
 
void ReinitializeGeometry (G4bool destroyFirst=false, G4bool prop=true)
 
void PhysicsHasBeenModified ()
 
void CutOffHasBeenModified ()
 
void ReOptimizeMotherOf (G4VPhysicalVolume *)
 
void ReOptimize (G4LogicalVolume *)
 
void SetVerboseLevel (G4int vl)
 
G4int GetVerboseLevel () const
 
G4int GetPrintProgress ()
 
void SetPrintProgress (G4int i)
 
void SetGeometryToBeOptimized (G4bool vl)
 
G4bool GetGeometryToBeOptimized ()
 
void SetNumberOfEventsToBeStored (G4int val)
 
const G4RunGetCurrentRun () const
 
G4RunGetNonConstCurrentRun () const
 
const G4EventGetCurrentEvent () const
 
const G4EventGetPreviousEvent (G4int i) const
 
void SetRunIDCounter (G4int i)
 
G4int GetNumberOfParallelWorld () const
 
void SetNumberOfEventsToBeProcessed (G4int val)
 
G4int GetNumberOfEventsToBeProcessed () const
 
G4int GetNumberOfSelectEvents () const
 
G4String GetSelectMacro () const
 
void SetDCtable (G4DCtable *DCtbl)
 
RMType GetRunManagerType () const
 
virtual void ConstructScoringWorlds ()
 
virtual void RestoreRndmEachEvent (G4bool)
 

Protected Member Functions

void DoEventLoop (G4int nEvent, const char *macroFile, G4int nSelect)
 
- Protected Member Functions inherited from G4RunManager
void CleanUpPreviousEvents ()
 
void CleanUpUnnecessaryEvents (G4int keepNEvents)
 
void StackPreviousEvent (G4Event *anEvent)
 
 G4RunManager (RMType rmType)
 
virtual void StoreRNGStatus (const G4String &filenamePrefix)
 
void UpdateScoring ()
 
virtual void DeleteUserInitializations ()
 

Additional Inherited Members

- Public Types inherited from G4RunManager
enum  RMType { sequentialRM, masterRM, workerRM }
 
- Static Public Member Functions inherited from G4RunManager
static G4RunManagerGetRunManager ()
 
static G4bool IfGeometryHasBeenDestroyed ()
 
- Protected Attributes inherited from G4RunManager
G4RunManagerKernelkernel
 
G4EventManagereventManager
 
G4VUserDetectorConstructionuserDetector
 
G4VUserPhysicsListphysicsList
 
G4VUserActionInitializationuserActionInitialization
 
G4UserWorkerInitializationuserWorkerInitialization
 
G4UserWorkerThreadInitializationuserWorkerThreadInitialization
 
G4UserRunActionuserRunAction
 
G4VUserPrimaryGeneratorActionuserPrimaryGeneratorAction
 
G4UserEventActionuserEventAction
 
G4UserStackingActionuserStackingAction
 
G4UserTrackingActionuserTrackingAction
 
G4UserSteppingActionuserSteppingAction
 
G4bool geometryInitialized
 
G4bool physicsInitialized
 
G4bool runAborted
 
G4bool initializedAtLeastOnce
 
G4bool geometryToBeOptimized
 
G4int runIDCounter
 
G4int verboseLevel
 
G4int printModulo
 
G4Timertimer
 
G4DCtableDCtable
 
G4RuncurrentRun
 
G4EventcurrentEvent
 
std::list< G4Event * > * previousEvents
 
G4int n_perviousEventsToBeStored
 
G4int numberOfEventToBeProcessed
 
G4bool storeRandomNumberStatus
 
G4int storeRandomNumberStatusToG4Event
 
G4String randomNumberStatusDir
 
G4String randomNumberStatusForThisRun
 
G4String randomNumberStatusForThisEvent
 
G4bool rngStatusEventsFlag
 
G4VPhysicalVolumecurrentWorld
 
G4int nParallelWorlds
 
G4String msgText
 
G4int n_select_msg
 
G4int numberOfEventProcessed
 
G4String selectMacro
 
G4bool fakeRun
 
RMType runManagerType
 
- Static Protected Attributes inherited from G4RunManager
static G4bool fGeometryHasBeenDestroyed = false
 

Detailed Description

Definition at line 68 of file CexmcRunManager.hh.

Constructor & Destructor Documentation

CexmcRunManager::CexmcRunManager ( const G4String projectId = "",
const G4String rProject = "",
G4bool  overrideExistingProject = false 
)
explicit

Definition at line 105 of file CexmcRunManager.cc.

107  :
108  basePhysicsUsed( CexmcPMFactoryInstance::GetBasePhysics() ),
109  productionModelType( CexmcUnknownProductionModel ),
110  gdmlFileName( "default.gdml" ), shouldGdmlFileBeValidated( true ),
111  zipGdmlFile( false ), projectsDir( "." ), projectId( projectId ),
112  rProject( rProject ), guiMacroName( "" ), cfFileName( "" ),
113  eventCountPolicy( CexmcCountAllEvents ),
114  skipInteractionsWithoutEDTonWrite( true ),
115  evDataVerboseLevel( CexmcWriteEventDataOnEveryEDT ),
116  rEvDataVerboseLevel( CexmcWriteNoEventData ), numberOfEventsProcessed( 0 ),
117  numberOfEventsProcessedEffective( 0 ), curEventRead( 0 ),
118 #ifdef CEXMC_USE_PERSISTENCY
119  eventsArchive( NULL ), fastEventsArchive( NULL ),
120 #ifdef CEXMC_USE_CUSTOM_FILTER
121  customFilter( NULL ),
122 #endif
123 #endif
124  physicsManager( NULL ), messenger( NULL )
125 {
126  /* this exception must be caught before creating the object! */
127  if ( rProject != "" && rProject == projectId )
129 
130  const char * projectsDirEnv( getenv( "CEXMC_PROJECTS_DIR" ) );
131 
132  if ( projectsDirEnv )
133  projectsDir = projectsDirEnv;
134 
135  struct stat tmp;
136  if ( ProjectIsSaved() &&
137  stat( ( projectsDir + "/" + projectId + ".rdb" ).c_str(), &tmp ) == 0
138  && ! overrideExistingProject )
140 
141  messenger = new CexmcRunManagerMessenger( this );
142 
143 #ifdef CEXMC_USE_PERSISTENCY
144  if ( ProjectIsRead() )
145  ReadPreinitProjectData();
146 #endif
147 }
G4bool ProjectIsRead(void) const
static CexmcBasePhysicsUsed GetBasePhysics(void)
G4bool ProjectIsSaved(void) const

Here is the call graph for this function:

CexmcRunManager::~CexmcRunManager ( )
virtual

Definition at line 150 of file CexmcRunManager.cc.

151 {
152 #ifdef CEXMC_USE_CUSTOM_FILTER
153  delete customFilter;
154 #endif
155  delete messenger;
156 }

Member Function Documentation

void CexmcRunManager::BeamParticleChangeHook ( void  )

Definition at line 1348 of file CexmcRunManager.cc.

1349 {
1350  const CexmcEventAction * eventAction(
1351  static_cast< const CexmcEventAction * >( userEventAction ) );
1352  if ( ! eventAction )
1354 
1355  CexmcEventAction * theEventAction( const_cast< CexmcEventAction * >(
1356  eventAction ) );
1357  theEventAction->BeamParticleChangeHook();
1358 }
G4UserEventAction * userEventAction

Here is the call graph for this function:

Here is the caller graph for this function:

void CexmcRunManager::DoEventLoop ( G4int  nEvent,
const char *  macroFile,
G4int  nSelect 
)
protectedvirtual

Reimplemented from G4RunManager.

Definition at line 885 of file CexmcRunManager.cc.

887 {
888  if ( verboseLevel > 0 )
889  timer->Start();
890 
891  G4String cmd;
892  if ( macroFile != 0 )
893  {
894  if ( nSelect < 0 )
895  nSelect = nEvent;
896  cmd = "/control/execute ";
897  cmd += macroFile;
898  }
899  else
900  {
901  nSelect = -1;
902  }
903 
904  numberOfEventsProcessed = 0;
905  numberOfEventsProcessedEffective = 0;
906 
907 #ifdef CEXMC_USE_PERSISTENCY
908  eventsArchive = NULL;
909  fastEventsArchive = NULL;
910  if ( ProjectIsRead() )
911  {
912  if ( ProjectIsSaved() )
913  {
914  std::ofstream eventsDataFile(
915  ( projectsDir + "/" + projectId + ".edb" ).c_str() );
916  boost::archive::binary_oarchive eventsArchive_( eventsDataFile );
917  std::ofstream fastEventsDataFile(
918  ( projectsDir + "/" + projectId + ".fdb" ).c_str() );
919  boost::archive::binary_oarchive fastEventsArchive_(
920  fastEventsDataFile );
921  eventsArchive = &eventsArchive_;
922  fastEventsArchive = &fastEventsArchive_;
923  DoReadEventLoop( nEvent );
924  }
925  else
926  {
927  DoReadEventLoop( nEvent );
928  }
929  }
930  else
931  {
932  if ( ProjectIsSaved() )
933  {
934  std::ofstream eventsDataFile(
935  ( projectsDir + "/" + projectId + ".edb" ).c_str() );
936  boost::archive::binary_oarchive eventsArchive_( eventsDataFile );
937  std::ofstream fastEventsDataFile(
938  ( projectsDir + "/" + projectId + ".fdb" ).c_str() );
939  boost::archive::binary_oarchive fastEventsArchive_(
940  fastEventsDataFile );
941  eventsArchive = &eventsArchive_;
942  fastEventsArchive = &fastEventsArchive_;
943  DoCommonEventLoop( nEvent, cmd, nSelect );
944  }
945  else
946  {
947  DoCommonEventLoop( nEvent, cmd, nSelect );
948  }
949  }
950  eventsArchive = NULL;
951  fastEventsArchive = NULL;
952 #else
953  DoCommonEventLoop( nEvent, cmd, nSelect );
954 #endif
955 
956  if ( verboseLevel > 0 )
957  {
958  timer->Stop();
959  G4cout << "Run terminated." << G4endl;
960  G4cout << "Run Summary" << G4endl;
961  if ( runAborted )
962  {
963  G4cout << " Run Aborted after " << numberOfEventsProcessed <<
964  " events processed." << G4endl;
965  }
966  else
967  {
968  G4cout << " Number of events processed : " <<
969  numberOfEventsProcessed << ", effectively: " <<
970  numberOfEventsProcessedEffective << G4endl;
971  }
972  G4cout << " " << *timer << G4endl;
973  }
974 }
G4Timer * timer
G4bool runAborted
G4bool ProjectIsRead(void) const
G4GLOB_DLL std::ostream G4cout
void Stop()
#define G4endl
Definition: G4ios.hh:61
void Start()
G4bool ProjectIsSaved(void) const
G4int verboseLevel

Here is the call graph for this function:

CexmcEventDataVerboseLevel CexmcRunManager::GetEventDataVerboseLevel ( void  ) const
inline

Definition at line 382 of file CexmcRunManager.hh.

384 {
385  return evDataVerboseLevel;
386 }
G4String CexmcRunManager::GetGdmlFileName ( void  ) const
inline

Definition at line 295 of file CexmcRunManager.hh.

296 {
297  return gdmlFileName;
298 }

Here is the caller graph for this function:

G4String CexmcRunManager::GetGuiMacroName ( void  ) const
inline

Definition at line 307 of file CexmcRunManager.hh.

308 {
309  return guiMacroName;
310 }

Here is the caller graph for this function:

CexmcPhysicsManager * CexmcRunManager::GetPhysicsManager ( void  )
inline

Definition at line 282 of file CexmcRunManager.hh.

283 {
284  return physicsManager;
285 }
CexmcProductionModelType CexmcRunManager::GetProductionModelType ( void  ) const
inline

Definition at line 289 of file CexmcRunManager.hh.

290 {
291  return productionModelType;
292 }

Here is the caller graph for this function:

G4String CexmcRunManager::GetProjectId ( void  ) const
inline

Definition at line 331 of file CexmcRunManager.hh.

332 {
333  return projectId;
334 }
G4String CexmcRunManager::GetProjectsDir ( void  ) const
inline

Definition at line 325 of file CexmcRunManager.hh.

326 {
327  return projectsDir;
328 }
G4bool CexmcRunManager::ProjectIsRead ( void  ) const
inline

Definition at line 319 of file CexmcRunManager.hh.

320 {
321  return rProject != "";
322 }

Here is the caller graph for this function:

G4bool CexmcRunManager::ProjectIsSaved ( void  ) const
inline

Definition at line 313 of file CexmcRunManager.hh.

314 {
315  return projectId != "";
316 }

Here is the caller graph for this function:

void CexmcRunManager::RegisterScenePrimitives ( void  )

Definition at line 1308 of file CexmcRunManager.cc.

1309 {
1310  G4VisManager * visManager( static_cast< G4VisManager * >(
1312  if ( ! visManager )
1313  return;
1314 
1315  G4Scene * curScene( visManager->GetCurrentScene() );
1316  if ( ! curScene )
1317  return;
1318 
1319  /* G4Scene declarations lack this kind of typedef */
1320 #if G4VERSION_NUMBER < 960
1321  typedef std::vector< G4VModel * > MList;
1322 #else
1323  typedef std::vector< G4Scene::Model > MList;
1324 #endif
1325  const MList & mList( curScene->GetRunDurationModelList() );
1326 
1327  for ( MList::const_iterator k( mList.begin() ); k != mList.end(); ++k )
1328  {
1329 #if G4VERSION_NUMBER < 960
1330  const G4String & modelDesc( ( *k )->GetGlobalDescription() );
1331 #else
1332  const G4String & modelDesc( k->fpModel->GetGlobalDescription() );
1333 #endif
1334  if ( modelDesc == CexmcScenePrimitivesDescription )
1335  return;
1336  }
1337 
1338  CexmcSetup * setup( static_cast< CexmcSetup * >( userDetector ) );
1339  if ( ! setup )
1341 
1342  /* BEWARE: looks like G4Scene won't delete models from its lists upon
1343  * termination! Hence destructor of the new model won't be called */
1344  curScene->AddRunDurationModel( new CexmcScenePrimitives( setup ) );
1345 }
const G4String CexmcScenePrimitivesDescription("CexmcScenePrimitives")
static G4VVisManager * GetConcreteInstance()
G4VUserDetectorConstruction * userDetector

Here is the call graph for this function:

Here is the caller graph for this function:

void CexmcRunManager::SetEventCountPolicy ( CexmcEventCountPolicy  value)
inline

Definition at line 262 of file CexmcRunManager.hh.

264 {
265  if ( ProjectIsRead() )
267 
268  eventCountPolicy = value;
269 }
G4bool ProjectIsRead(void) const
const XML_Char int const XML_Char * value
Definition: expat.h:331

Here is the call graph for this function:

Here is the caller graph for this function:

void CexmcRunManager::SetEventDataVerboseLevel ( CexmcEventDataVerboseLevel  value)
inline

Definition at line 272 of file CexmcRunManager.hh.

274 {
275  if ( ProjectIsRead() && value > rEvDataVerboseLevel )
277 
278  evDataVerboseLevel = value;
279 }
G4bool ProjectIsRead(void) const
const XML_Char int const XML_Char * value
Definition: expat.h:331

Here is the call graph for this function:

Here is the caller graph for this function:

void CexmcRunManager::SetGdmlFileName ( const G4String gdmlFileName_)
inline

Definition at line 241 of file CexmcRunManager.hh.

242 {
243  if ( ProjectIsRead() )
245 
246  gdmlFileName = gdmlFileName_;
247 }
G4bool ProjectIsRead(void) const

Here is the call graph for this function:

Here is the caller graph for this function:

void CexmcRunManager::SetGdmlFileValidation ( G4bool  on = true)
inline

Definition at line 250 of file CexmcRunManager.hh.

251 {
252  shouldGdmlFileBeValidated = on;
253 }

Here is the caller graph for this function:

void CexmcRunManager::SetGuiMacroName ( const G4String guiMacroName_)
inline

Definition at line 256 of file CexmcRunManager.hh.

257 {
258  guiMacroName = guiMacroName_;
259 }

Here is the caller graph for this function:

void CexmcRunManager::SetPhysicsManager ( CexmcPhysicsManager physicsManager_)
inline

Definition at line 224 of file CexmcRunManager.hh.

226 {
227  physicsManager = physicsManager_;
228 }

Here is the caller graph for this function:

void CexmcRunManager::SetProductionModelType ( CexmcProductionModelType  productionModelType_)
inline

Definition at line 231 of file CexmcRunManager.hh.

233 {
234  if ( ProjectIsRead() )
236 
237  productionModelType = productionModelType_;
238 }
G4bool ProjectIsRead(void) const

Here is the call graph for this function:

Here is the caller graph for this function:

void CexmcRunManager::SetupConstructionHook ( void  )

Definition at line 1361 of file CexmcRunManager.cc.

1362 {
1363 #ifdef CEXMC_USE_PERSISTENCY
1364  /* save gdml file */
1365  G4String cmd( "" );
1366  CexmcExceptionType exceptionType( CexmcSystemException );
1367 
1368  if ( zipGdmlFile )
1369  {
1370  if ( ProjectIsRead() )
1371  {
1372  cmd = G4String( "bzip2 " ) + projectsDir + "/" + rProject +
1373  gdmlFileExtension;
1374  }
1375  else
1376  {
1377  if ( ProjectIsSaved() )
1378  cmd = G4String( "bzip2 -c " ) + gdmlFileName + " > " +
1379  projectsDir + "/" + projectId + gdmlbz2FileExtension;
1380  }
1381  exceptionType = CexmcFileCompressException;
1382  }
1383  else
1384  {
1385  if ( ! ProjectIsRead() && ProjectIsSaved() )
1386  cmd = G4String( "cp " ) + gdmlFileName + " " + projectsDir + "/" +
1387  projectId + gdmlFileExtension;
1388  /* else already saved in ReadPreinitProjectData() */
1389  }
1390 
1391  if ( ! cmd.empty() && system( cmd ) != 0 )
1392  throw CexmcException( exceptionType );
1393 #endif
1394 }
G4bool ProjectIsRead(void) const
CexmcExceptionType
G4bool ProjectIsSaved(void) const

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool CexmcRunManager::ShouldGdmlFileBeValidated ( void  ) const
inline

Definition at line 301 of file CexmcRunManager.hh.

302 {
303  return shouldGdmlFileBeValidated;
304 }

Here is the caller graph for this function:


The documentation for this class was generated from the following files: