CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/SimG4Core/Application/src/RunAction.cc

Go to the documentation of this file.
00001 #include "SimG4Core/Application/interface/RunAction.h"
00002 #include "SimG4Core/Application/interface/RunManager.h"
00003 
00004 #include "SimG4Core/Notification/interface/BeginOfRun.h"
00005 #include "SimG4Core/Notification/interface/EndOfRun.h"
00006  
00007 #include <iostream>
00008 #include <fstream>
00009  
00010 RunAction::RunAction(const edm::ParameterSet& p, RunManager* rm) 
00011    : m_runManager(rm), 
00012     m_stopFile(p.getParameter<std::string>("StopFile")) {}
00013 
00014 void RunAction::BeginOfRunAction(const G4Run * aRun)
00015 {
00016     if (std::ifstream(m_stopFile.c_str()))
00017     {
00018         std::cout << "BeginOfRunAction: termination signal received" << std::endl;
00019         //RunManager::instance()->abortRun(true);
00020         m_runManager->abortRun(true);
00021     }
00022     BeginOfRun r(aRun);
00023     m_beginOfRunSignal(&r);
00024 }
00025 
00026 void RunAction::EndOfRunAction(const G4Run * aRun)
00027 {
00028     if (std::ifstream(m_stopFile.c_str()))
00029     {
00030         std::cout << "EndOfRunAction: termination signal received" << std::endl;
00031         //RunManager::instance()->abortRun(true);
00032         m_runManager->abortRun(true);
00033     }
00034     EndOfRun r(aRun);
00035     m_endOfRunSignal(&r);
00036 }
00037