00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "BesRunAction.hh"
00012 #include "G4Run.hh"
00013
00014 #include "BesAsciiIO.hh"
00015 #include "BesRootIO.hh"
00016 #include "BesTDSWriter.hh"
00017 #include "BesTuningIO.hh"
00018
00019 #include "ReadBoostRoot.hh"
00020
00021 BesRunAction::BesRunAction()
00022 :m_runId(0), m_MCTruthFlag(1),
00023 m_asciiFlag(""),m_asciiFile(""),m_asciiIO(0),m_rootFlag(true),m_rootFile(""),m_rootIO(0),
00024 m_tuningIO(0),m_TDSFlag(false),m_TDSWriter(0)
00025 {
00026
00027 }
00028
00029 BesRunAction::~BesRunAction()
00030 {
00031
00032 }
00033
00034 void BesRunAction::BeginOfRunAction(const G4Run* aRun)
00035 {
00036
00037
00038 G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
00039 m_runId= aRun->GetRunID();
00040
00041 G4int flag[8];
00042 G4int allflag=0;
00043 for (G4int i=0;i<8;i++)
00044 {
00045 flag[i]=m_asciiFlag[i]-'0';
00046 allflag += flag[i];
00047 }
00048 if (allflag)
00049 m_asciiIO = new BesAsciiIO(flag[0],flag[1],flag[2],flag[3],flag[4],flag[5],flag[6],flag[7],m_asciiFile);
00050
00051 if (m_rootFlag)
00052 m_rootIO = new BesRootIO(1,1,1,1,1,1,1,1,m_rootFile);
00053
00054 if (m_TDSFlag)
00055 m_TDSWriter = new BesTDSWriter;
00056
00057 if (ReadBoostRoot::GetTuning()){
00058 std::vector<std::string>::iterator pd;
00059 for (pd = m_tuningFile.begin(); pd != m_tuningFile.end(); pd++){
00060 std::cout << "BesRunAction tuning File: " << *pd << std::endl;
00061 }
00062
00063 m_tuningIO = new BesTuningIO(m_tuningFile);
00064 }
00065 }
00066
00067
00068 void BesRunAction::EndOfRunAction(const G4Run* )
00069 {
00070 if (m_asciiIO)
00071 delete m_asciiIO;
00072 if (m_rootIO)
00073 delete m_rootIO;
00074 if (m_TDSFlag)
00075 delete m_TDSWriter;
00076 if (m_tuningIO)
00077 delete m_tuningIO;
00078 }