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 electromagnetic/TestEm12/src/RunActi 26 /// \file electromagnetic/TestEm12/src/RunAction.cc 27 /// \brief Implementation of the RunAction cla 27 /// \brief Implementation of the RunAction class 28 // 28 // 29 // << 29 // $Id: RunAction.cc 93564 2015-10-26 14:47:17Z gcosmo $ >> 30 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 33 33 #include "RunAction.hh" 34 #include "RunAction.hh" 34 << 35 #include "DetectorConstruction.hh" 35 #include "DetectorConstruction.hh" 36 #include "HistoManager.hh" << 37 #include "PhysicsList.hh" 36 #include "PhysicsList.hh" >> 37 #include "StepMax.hh" 38 #include "PrimaryGeneratorAction.hh" 38 #include "PrimaryGeneratorAction.hh" 39 #include "Run.hh" 39 #include "Run.hh" 40 #include "StepMax.hh" << 40 #include "HistoManager.hh" 41 41 >> 42 #include "G4RunManager.hh" 42 #include "G4EmCalculator.hh" 43 #include "G4EmCalculator.hh" 43 #include "G4EmParameters.hh" << 44 44 #include "Randomize.hh" 45 #include "Randomize.hh" 45 46 46 //....oooOO0OOooo........oooOO0OOooo........oo 47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 48 48 RunAction::RunAction(DetectorConstruction* det << 49 RunAction::RunAction(DetectorConstruction* det, PhysicsList* phys, 49 : fDetector(det), fPhysics(phys), fPrimary(k << 50 PrimaryGeneratorAction* kin) >> 51 :G4UserRunAction(), >> 52 fDetector(det),fPhysics(phys),fPrimary(kin),fRun(0),fHistoManager(0) 50 { 53 { 51 // Book predefined histograms 54 // Book predefined histograms 52 fHistoManager = new HistoManager(); 55 fHistoManager = new HistoManager(); 53 } << 56 } 54 57 55 //....oooOO0OOooo........oooOO0OOooo........oo 58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 56 59 57 RunAction::~RunAction() 60 RunAction::~RunAction() 58 { 61 { 59 delete fHistoManager; << 62 delete fHistoManager; 60 } 63 } 61 64 62 //....oooOO0OOooo........oooOO0OOooo........oo 65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 63 66 64 G4Run* RunAction::GenerateRun() 67 G4Run* RunAction::GenerateRun() 65 { << 68 { 66 fRun = new Run(fDetector); << 69 fRun = new Run(fDetector); 67 return fRun; 70 return fRun; 68 } 71 } 69 72 70 //....oooOO0OOooo........oooOO0OOooo........oo 73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 71 74 72 void RunAction::BeginOfRunAction(const G4Run*) 75 void RunAction::BeginOfRunAction(const G4Run*) 73 { << 76 { 74 // show Rndm status << 77 // save Rndm status 75 if (isMaster) { << 78 ////G4RunManager::GetRunManager()->SetRandomNumberStore(true); 76 G4Random::showEngineStatus(); << 79 if (isMaster) G4Random::showEngineStatus(); 77 G4EmParameters::Instance()->Dump(); << 80 78 } << 81 //histograms 79 // histograms << 80 // 82 // 81 G4AnalysisManager* analysisManager = G4Analy 83 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 82 if (analysisManager->IsActive()) { << 84 if ( analysisManager->IsActive() ) { 83 analysisManager->OpenFile(); 85 analysisManager->OpenFile(); 84 } 86 } 85 << 87 86 if (!fPrimary) return; 88 if (!fPrimary) return; 87 << 89 88 // keep run condition 90 // keep run condition 89 G4ParticleDefinition* particle = fPrimary->G << 91 G4ParticleDefinition* particle >> 92 = fPrimary->GetParticleGun()->GetParticleDefinition(); 90 G4double energy = fPrimary->GetParticleGun() 93 G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy(); 91 fRun->SetPrimary(particle, energy); 94 fRun->SetPrimary(particle, energy); 92 95 93 // get CsdaRange from EmCalculator << 96 >> 97 >> 98 //get CsdaRange from EmCalculator 94 // 99 // 95 G4EmCalculator emCalculator; 100 G4EmCalculator emCalculator; 96 G4Material* material = fDetector->GetAbsorMa 101 G4Material* material = fDetector->GetAbsorMaterial(); 97 102 98 G4double csdaRange = DBL_MAX; 103 G4double csdaRange = DBL_MAX; 99 if (particle->GetPDGCharge() != 0.) { 104 if (particle->GetPDGCharge() != 0.) { 100 csdaRange = emCalculator.GetCSDARange(ener << 105 csdaRange = emCalculator.GetCSDARange(energy,particle,material); 101 fRun->SetCsdaRange(csdaRange); 106 fRun->SetCsdaRange(csdaRange); 102 } 107 } 103 << 108 104 // set StepMax from histos 1 and 8 << 109 //set StepMax from histos 1 and 8 105 // 110 // 106 G4double stepMax = csdaRange; 111 G4double stepMax = csdaRange; 107 G4int ih = 1; 112 G4int ih = 1; 108 if (analysisManager->GetH1Activation(ih)) 113 if (analysisManager->GetH1Activation(ih)) 109 stepMax = analysisManager->GetH1Width(ih) << 114 stepMax = analysisManager->GetH1Width(ih)*analysisManager->GetH1Unit(ih); 110 ih = 8; 115 ih = 8; 111 if (analysisManager->GetH1Activation(ih)) { 116 if (analysisManager->GetH1Activation(ih)) { 112 G4double width = analysisManager->GetH1Wid 117 G4double width = analysisManager->GetH1Width(ih); 113 stepMax = std::min(stepMax, width * csdaRa << 118 stepMax = std::min(stepMax, width*csdaRange); 114 } << 119 } 115 fPhysics->GetStepMaxProcess()->SetMaxStep2(s 120 fPhysics->GetStepMaxProcess()->SetMaxStep2(stepMax); 116 << 121 117 /// G4cout << "\n---> stepMax from histos 1 << 122 ///G4cout << "\n---> stepMax from histos 1 and 8 = " 118 /// << G4BestUnit(stepMax,"Length") < << 123 /// << G4BestUnit(stepMax,"Length") << G4endl; 119 } 124 } 120 125 121 //....oooOO0OOooo........oooOO0OOooo........oo 126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 122 127 123 void RunAction::EndOfRunAction(const G4Run*) 128 void RunAction::EndOfRunAction(const G4Run*) 124 { 129 { 125 if (isMaster) fRun->EndOfRun(); << 130 if (isMaster) fRun->EndOfRun(); 126 << 131 127 // save histograms 132 // save histograms 128 G4AnalysisManager* analysisManager = G4Analy << 133 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 129 if (analysisManager->IsActive()) { << 134 if ( analysisManager->IsActive() ) { 130 analysisManager->Write(); 135 analysisManager->Write(); 131 analysisManager->CloseFile(); 136 analysisManager->CloseFile(); 132 } << 137 } 133 << 138 134 // show Rndm status 139 // show Rndm status 135 if (isMaster) G4Random::showEngineStatus(); << 140 if (isMaster) G4Random::showEngineStatus(); 136 } 141 } 137 142 138 //....oooOO0OOooo........oooOO0OOooo........oo 143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 139 144