Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:48

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 /// \file B1RunAction.cc
0028 /// \brief Implementation of the B1RunAction class
0029 
0030 #include "B1RunAction.hh"
0031 
0032 #include "B1DetectorConstruction.hh"
0033 #include "B1PrimaryGeneratorAction.hh"
0034 #include "B1Run.hh"
0035 
0036 #include "G4LogicalVolume.hh"
0037 #include "G4LogicalVolumeStore.hh"
0038 #include "G4RunManager.hh"
0039 #include "G4SystemOfUnits.hh"
0040 #include "G4UnitsTable.hh"
0041 
0042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0043 
0044 B1RunAction::B1RunAction() : G4UserRunAction()
0045 {
0046   // add new units for dose
0047   //
0048   const G4double milligray = 1.e-3 * gray;
0049   const G4double microgray = 1.e-6 * gray;
0050   const G4double nanogray = 1.e-9 * gray;
0051   const G4double picogray = 1.e-12 * gray;
0052 
0053   new G4UnitDefinition("milligray", "milliGy", "Dose", milligray);
0054   new G4UnitDefinition("microgray", "microGy", "Dose", microgray);
0055   new G4UnitDefinition("nanogray", "nanoGy", "Dose", nanogray);
0056   new G4UnitDefinition("picogray", "picoGy", "Dose", picogray);
0057 }
0058 
0059 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0060 
0061 B1RunAction::~B1RunAction() {}
0062 
0063 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0064 
0065 G4Run* B1RunAction::GenerateRun()
0066 {
0067   return new B1Run;
0068 }
0069 
0070 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0071 
0072 void B1RunAction::BeginOfRunAction(const G4Run*)
0073 {
0074   // inform the runManager to save random number seed
0075   G4RunManager::GetRunManager()->SetRandomNumberStore(false);
0076 }
0077 
0078 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0079 
0080 void B1RunAction::EndOfRunAction(const G4Run* run)
0081 {
0082   G4int nofEvents = run->GetNumberOfEvent();
0083   if (nofEvents == 0) return;
0084 
0085   const B1Run* b1Run = static_cast<const B1Run*>(run);
0086 
0087   // Compute dose
0088   //
0089   G4double edep = b1Run->GetEdep();
0090   G4double edep2 = b1Run->GetEdep2();
0091   G4double rms = edep2 - edep * edep / nofEvents;
0092   if (rms > 0.)
0093     rms = std::sqrt(rms);
0094   else
0095     rms = 0.;
0096 
0097   const B1DetectorConstruction* detectorConstruction = static_cast<const B1DetectorConstruction*>(
0098     G4RunManager::GetRunManager()->GetUserDetectorConstruction());
0099   G4double mass = detectorConstruction->GetScoringVolume()->GetMass();
0100   G4double dose = edep / mass;
0101   G4double rmsDose = rms / mass;
0102 
0103   // Run conditions
0104   //  note: There is no primary generator action object for "master"
0105   //        run manager for multi-threaded mode.
0106   const B1PrimaryGeneratorAction* generatorAction = static_cast<const B1PrimaryGeneratorAction*>(
0107     G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
0108   G4String runCondition;
0109   if (generatorAction) {
0110     const G4ParticleGun* particleGun = generatorAction->GetParticleGun();
0111     runCondition += particleGun->GetParticleDefinition()->GetParticleName();
0112     runCondition += " of ";
0113     G4double particleEnergy = particleGun->GetParticleEnergy();
0114     runCondition += G4BestUnit(particleEnergy, "Energy");
0115   }
0116 
0117   // Print
0118   //
0119   if (IsMaster()) {
0120     G4cout << "\n--------------------End of Global Run-----------------------";
0121   }
0122   else {
0123     G4cout << "\n--------------------End of Local Run------------------------";
0124   }
0125 
0126   G4cout << "\n The run consists of " << nofEvents << " " << runCondition
0127          << "\n Dose in scoring volume : " << G4BestUnit(dose, "Dose") << " +- "
0128          << G4BestUnit(rmsDose, "Dose")
0129          << "\n------------------------------------------------------------\n"
0130          << G4endl;
0131 }
0132 
0133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......