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 field/field01/src/F01RunAction.cc >> 27 /// \brief Implementation of the F01RunAction class >> 28 // >> 29 // >> 30 // $Id$ >> 31 // >> 32 // >> 33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 35 26 #include "F01RunAction.hh" 36 #include "F01RunAction.hh" >> 37 #include "F01RunMessenger.hh" 27 38 28 #include "G4CoupledTransportation.hh" << 29 #include "G4Electron.hh" << 30 #include "G4ParticleDefinition.hh" << 31 #include "G4ProcessManager.hh" << 32 #include "G4Run.hh" 39 #include "G4Run.hh" 33 #include "G4SystemOfUnits.hh" << 40 #include "G4UImanager.hh" 34 #include "G4Transportation.hh" << 41 #include "G4VVisManager.hh" 35 #include "globals.hh" << 42 >> 43 #include "Randomize.hh" 36 44 37 //....oooOO0OOooo........oooOO0OOooo........oo 45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 38 46 39 void F01RunAction::BeginOfRunAction(const G4Ru << 47 F01RunAction::F01RunAction() >> 48 : G4UserRunAction(), >> 49 fMessenger(0), >> 50 fSaveRndm(0) 40 { 51 { 41 G4cout << "### Run " << aRun->GetRunID() << << 52 fMessenger = new F01RunMessenger(this); 42 << 43 G4cout << " Calling F01RunAction::ChangeLoop << 44 ChangeLooperParameters(G4Electron::Definitio << 45 } 53 } 46 54 47 //....oooOO0OOooo........oooOO0OOooo........oo 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 48 56 49 void F01RunAction::ChangeLooperParameters(cons << 57 F01RunAction::~F01RunAction() 50 { 58 { 51 if (particleDef == nullptr) particleDef = G4 << 59 delete fMessenger; 52 auto transport = FindTransportation(particle << 53 << 54 // Note that all particles that share the sa << 55 // (or Coupled Transportation) process (wit << 56 // will be affected by this change << 57 // -- to change these parameters by partic << 58 // must instead be changed/reset in a ( << 59 << 60 G4cout << " ChangeLooperParameters called wi << 61 << " transport process: "; << 62 if (transport != nullptr) { << 63 G4cout << transport->GetProcessName(); << 64 } << 65 else { << 66 G4cout << " UNKNOWN -- it is neither G4Tra << 67 } << 68 G4cout << G4endl; << 69 << 70 if (transport != nullptr) { << 71 if (fWarningEnergy >= 0.0) { << 72 transport->SetThresholdWarningEnergy(fWa << 73 G4cout << "-- Changed Threshold Warning << 74 << fWarningEnergy / CLHEP::MeV << << 75 } << 76 if (fImportantEnergy >= 0.0) { << 77 transport->SetThresholdImportantEnergy(f << 78 << 79 G4cout << "-- Changed Threshold Importan << 80 << fImportantEnergy / CLHEP::MeV << 81 } << 82 << 83 if (fNumberOfTrials > 0) { << 84 transport->SetThresholdTrials(fNumberOfT << 85 << 86 G4cout << "-- Changed number of Trials ( << 87 } << 88 } << 89 << 90 if (transport == nullptr) { << 91 if (fWarningEnergy >= 0.0) << 92 G4cerr << " Unknown transport process> C << 93 if (fImportantEnergy >= 0.0) << 94 G4cerr << " Unknown transport process> C << 95 if (fNumberOfTrials > 0) << 96 G4cerr << " Unknown transport process> C << 97 } << 98 } 60 } 99 61 100 //....oooOO0OOooo........oooOO0OOooo........oo 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 101 63 102 void F01RunAction::EndOfRunAction(const G4Run* << 64 void F01RunAction::BeginOfRunAction(const G4Run*) 103 { 65 { 104 if (fVerboseLevel > 1) << 66 // save Rndm status 105 G4cout << G4endl << G4endl << " ########## << 67 if (fSaveRndm > 0) 106 << " ########### " << G4endl << " # << 68 { 107 << " ####################### " << G << 69 G4Random::showEngineStatus(); 108 << 70 G4Random::saveEngineStatus("beginOfRun.rndm"); 109 auto transport = FindTransportation(G4Electr << 71 } 110 if (transport) { << 72 G4UImanager* ui = G4UImanager::GetUIpointer(); 111 transport->PrintStatistics(G4cout); << 73 112 } << 74 G4VVisManager* visManager = G4VVisManager::GetConcreteInstance(); >> 75 >> 76 if (visManager) ui->ApplyCommand("/vis/scene/notifyHandlers"); 113 } 77 } 114 78 115 //....oooOO0OOooo........oooOO0OOooo........oo 79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 116 80 117 G4Transportation* F01RunAction::FindTransporta << 81 void F01RunAction::EndOfRunAction(const G4Run*) 118 << 119 { 82 { 120 const auto* partPM = particleDef->GetProcess << 83 if (G4VVisManager::GetConcreteInstance()) 121 << 84 { 122 G4VProcess* partTransport = partPM->GetProce << 85 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update"); 123 auto transport = dynamic_cast<G4Transportati << 124 << 125 if (!transport) { << 126 partTransport = partPM->GetProcess("Couple << 127 auto coupledTransport = dynamic_cast<G4Cou << 128 if (coupledTransport) { << 129 transport = coupledTransport; << 130 } << 131 else { << 132 partTransport = partPM->GetProcess("Tran << 133 auto transportWithMsc = dynamic_cast<G4C << 134 if (transportWithMsc) { << 135 transport = transportWithMsc; << 136 } << 137 } << 138 } 86 } 139 87 140 if (reportError && !transport) { << 88 // save Rndm status 141 G4cerr << "Unable to find Transportation p << 142 << particleDef->GetParticleName() < << 143 << " ) " << G4endl; << 144 } << 145 89 146 return transport; << 90 if (fSaveRndm == 1) >> 91 { >> 92 G4Random::showEngineStatus(); >> 93 G4Random::saveEngineStatus("endOfRun.rndm"); >> 94 } 147 } 95 } >> 96 >> 97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 148 98