/scratch0/jsnuveri/BDSIM/BDSIMgit/bdsim/src/BDSRunManager.cc

00001 /* BDSIM code.    Version 1.0
00002    Author: Grahame A. Blair, Royal Holloway, Univ. of London.
00003    Last modified 24.7.2002
00004    Copyright (c) 2002 by G.A.Blair.  ALL RIGHTS RESERVED. 
00005 */
00006 //
00007 // SPM: Altered BeamOn function to account for Placet synchronisation
00008 //
00009 
00010 #include "BDSDebug.hh"
00011 #include "BDSGlobalConstants.hh"
00012 #include "BDSRunManager.hh"
00013 
00014 #include "G4Version.hh"
00015 
00016 #include "CLHEP/Random/Random.h"
00017 
00018 // add keyword ThreadLocal for versions 10
00019 #if G4VERSION_NUMBER > 999
00020 G4ThreadLocal
00021 #endif
00022 BDSRunManager* BDSRunManager::fRunManager = 0;
00023 
00024 BDSRunManager* BDSRunManager::GetRunManager() { 
00025   return fRunManager; 
00026 }
00027 
00028 BDSRunManager::BDSRunManager():G4RunManager() { 
00029   fRunManager = this;
00030 }
00031 
00032 BDSRunManager::~BDSRunManager(){
00033   fRunManager = NULL;
00034 }
00035 
00036 void BDSRunManager::BeamOn(G4int n_event,const char* macroFile,G4int n_select)
00037 {
00038   G4RunManager::BeamOn(n_event,macroFile,n_select);
00039 
00040   // only do an additional BeamOn when holdingQueue is not empty
00041   if (BDSGlobalConstants::Instance()->holdingQueue.empty()) return;
00042 
00043   G4bool cond = ConfirmBeamOnCondition();
00044   G4StackManager* SM;
00045   SM = G4EventManager::GetEventManager()->GetStackManager();
00046   SM->SetNumberOfAdditionalWaitingStacks(4);
00047   if(cond)
00048   {
00049     while(!BDSGlobalConstants::Instance()->holdingQueue.empty()){
00050       BDSGlobalConstants::Instance()->setReadFromStack(true);
00051       SM->ClearPostponeStack();
00052 
00053       RunInitialization();
00054 //      DoEventLoop(n_event,macroFile,n_select);
00055       DoEventLoop(BDSGlobalConstants::Instance()->holdingQueue.size(),macroFile,n_select);
00056       RunTermination();
00057 
00058       BDSGlobalConstants::Instance()->setReadFromStack(false);
00059     }
00060   }
00061 }
00062 
00063 void BDSRunManager::DoEventLoop(G4int n_event,const char* macroFile,G4int n_select)
00064 {
00065   // save event loop state
00066   if(verboseLevel>0){
00067     // Print seed to try and recreate an event in a run 
00068     G4cout << __METHOD_NAME__ << "> Random number generator's seed=" 
00069            << CLHEP::HepRandom::getTheSeed() << G4endl;
00070     // Print generator full state to output 
00071     G4cout << __METHOD_NAME__ << "> Random number generator's state: " << G4endl;
00072     CLHEP::HepRandom::saveFullState(G4cout);
00073   }
00074 
00075   G4RunManager::DoEventLoop(n_event,macroFile,n_select);
00076 }
00077 
00078 void BDSRunManager::ProcessOneEvent(G4int i_event)
00079 {
00080   // additional output
00081   if(verboseLevel>3){
00082     G4cout << __METHOD_NAME__ << " Event="<<i_event<<G4endl;
00083     // Print seed to try and recreate an event in a run
00084     G4cout << __METHOD_NAME__ << "> Random number generator's seed=" 
00085            << CLHEP::HepRandom::getTheSeed() << G4endl;
00086     // Print generator full state to output 
00087     G4cout << __METHOD_NAME__ << " Random number generator's state: " << G4endl;
00088     CLHEP::HepRandom::saveFullState(G4cout);
00089   }
00090 
00091   G4RunManager::ProcessOneEvent(i_event);
00092 }
00093 
00094 

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7