Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /// \file RunAction.cc << 26 /// \file hadronic/Hadr00/src/RunAction.cc 27 /// \brief Implementation of the RunAction cla 27 /// \brief Implementation of the RunAction class 28 // 28 // >> 29 // $Id: RunAction.hh,v 1.1 2008-07-07 16:37:26 vnivanch Exp $ 29 // 30 // >> 31 // ------------------------------------------------------------- >> 32 // >> 33 // GEANT4 class file >> 34 // RunAction >> 35 // >> 36 // ------------------------------------------------------------- >> 37 30 //....oooOO0OOooo........oooOO0OOooo........oo 38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 39 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 40 33 #include "RunAction.hh" 41 #include "RunAction.hh" 34 << 35 #include "DetectorConstruction.hh" << 36 #include "HistoManager.hh" 42 #include "HistoManager.hh" 37 #include "PrimaryGeneratorAction.hh" << 43 #include "G4UImanager.hh" 38 #include "Run.hh" << 44 #include "G4VVisManager.hh" 39 << 45 #include "G4SystemOfUnits.hh" 40 #include "G4RunManager.hh" << 46 #include "G4Threading.hh" 41 #include "G4Timer.hh" << 42 #include "Randomize.hh" << 43 47 44 //....oooOO0OOooo........oooOO0OOooo........oo 48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 45 49 46 RunAction::RunAction(DetectorConstruction* det << 50 RunAction::RunAction() 47 : fDetector(det), fPrimary(prim) << 48 { 51 { 49 fHistoManager = new HistoManager(); << 52 fHisto = new HistoManager(); 50 } 53 } 51 54 52 //....oooOO0OOooo........oooOO0OOooo........oo 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 53 56 54 G4Run* RunAction::GenerateRun() << 57 RunAction::~RunAction() 55 { 58 { 56 fRun = new Run(fDetector); << 59 delete fHisto; 57 return fRun; << 58 } 60 } 59 61 60 //....oooOO0OOooo........oooOO0OOooo........oo 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 61 63 62 void RunAction::BeginOfRunAction(const G4Run*) << 64 void RunAction::BeginOfRunAction(const G4Run* aRun) 63 { 65 { 64 // keep run condition << 66 G4bool show = true; 65 if (fPrimary) { << 67 if(G4Threading::IsWorkerThread() == true) { show = false; } 66 G4ParticleDefinition* particle = fPrimary- << 68 67 G4double energy = fPrimary->GetParticleGun << 69 if(show) { 68 fRun->SetPrimary(particle, energy); << 70 G4int id = aRun->GetRunID(); >> 71 G4cout << "### Run " << id << " start" << G4endl; >> 72 fHisto->BeginOfRun(); 69 } 73 } 70 74 71 // histograms << 75 #ifdef G4VIS_USE 72 // << 76 G4UImanager* UI = G4UImanager::GetUIpointer(); 73 G4AnalysisManager* analysis = G4AnalysisMana << 77 74 if (analysis->IsActive()) analysis->OpenFile << 78 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance(); 75 << 79 76 // save Rndm status and open the timer << 80 if(pVVisManager) 77 << 81 { 78 if (isMaster) { << 82 UI->ApplyCommand("/vis/scene/notifyHandlers"); 79 // G4Random::showEngineStatus(); << 80 fTimer = new G4Timer(); << 81 fTimer->Start(); << 82 } 83 } >> 84 #endif >> 85 83 } 86 } 84 87 85 //....oooOO0OOooo........oooOO0OOooo........oo 88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 86 89 87 void RunAction::EndOfRunAction(const G4Run*) 90 void RunAction::EndOfRunAction(const G4Run*) 88 { 91 { 89 // compute and print statistic << 92 G4bool show = true; 90 if (isMaster) { << 93 if(G4Threading::IsWorkerThread() == true) { show = false; } 91 fTimer->Stop(); << 94 92 if (!((G4RunManager::GetRunManager()->GetR << 95 if(show) { 93 G4cout << "\n" << 96 G4cout << "RunAction: End of run actions are started" << G4endl; 94 << "Total number of events: " << << 97 fHisto->EndOfRun(); 95 G4cout << "Master thread time: " << *fT << 96 } << 97 delete fTimer; << 98 fRun->EndOfRun(); << 99 } 98 } 100 // save histograms << 99 #ifdef G4VIS_USE 101 G4AnalysisManager* analysis = G4AnalysisMana << 100 if (G4VVisManager::GetConcreteInstance()) { 102 if (analysis->IsActive()) { << 101 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update"); 103 analysis->Write(); << 104 analysis->CloseFile(); << 105 } 102 } >> 103 #endif 106 104 107 // show Rndm status << 108 // if (isMaster) G4Random::showEngineStatu << 109 } 105 } 110 106 111 //....oooOO0OOooo........oooOO0OOooo........oo 107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 112 108