Back to home page

EIC code displayed by LXR

 
 

    


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

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 #include "RunAction.hh"
0027 
0028 #include "Run.hh"
0029 
0030 #include "G4AnalysisManager.hh"
0031 #include "G4DNAEventScheduler.hh"
0032 #include "G4DNAScavengerMaterial.hh"
0033 #include "G4Run.hh"
0034 #include "G4RunManager.hh"
0035 #include "G4Scheduler.hh"
0036 #include "G4SystemOfUnits.hh"
0037 #include "G4VChemistryWorld.hh"
0038 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0039 
0040 RunAction::RunAction() : G4UserRunAction() {}
0041 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0042 
0043 void RunAction::SetEventScheduler(G4DNAEventScheduler* pEventScheduler)
0044 {
0045   fpEventScheduler = pEventScheduler;
0046 }
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0048 
0049 G4Run* RunAction::GenerateRun()
0050 {
0051   Run* run = new Run();
0052   return run;
0053 }
0054 
0055 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0056 
0057 void RunAction::BeginOfRunAction(const G4Run* run)
0058 {
0059   G4cout << "### Run " << run->GetRunID() << " starts." << G4endl;
0060   if (G4Threading::IsMultithreadedApplication() && IsMaster()) {
0061     return;
0062   }
0063   auto runInfo = dynamic_cast<const Run*>(run);
0064   auto GvaluesScorer = dynamic_cast<Scorer<Gvalues>*>(runInfo->GetGvaluesScorer());
0065 
0066   if (fpEventScheduler != nullptr) {
0067     for (const auto& it : GvaluesScorer->GetpScorer()->fTimeToRecord) {
0068       fpEventScheduler->AddTimeToRecord(it);
0069     }
0070   }
0071   GvaluesScorer->SetEventScheduler(fpEventScheduler);
0072 }
0073 
0074 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0075 
0076 void RunAction::EndOfRunAction(const G4Run* run)
0077 {
0078   G4int nofEvents = run->GetNumberOfEvent();
0079   if (nofEvents == 0) {
0080     return;
0081   }
0082   auto chem6Run = dynamic_cast<const Run*>(run);
0083   G4double sumDose = chem6Run->GetSumDose();
0084 
0085   if (G4Threading::IsMultithreadedApplication() && IsMaster()) {
0086     G4cout << G4endl << "--------------------------End of Global Run------------------------------"
0087            << G4endl << "The run has " << nofEvents << " events " << G4endl;
0088 
0089     auto masterGvaluesScorer = dynamic_cast<Scorer<Gvalues>*>(chem6Run->GetGvaluesScorer());
0090 
0091     auto masterDoseLimite = dynamic_cast<Scorer<Dose>*>(chem6Run->GetSumDoseLimit());
0092 
0093     G4cout << "Number of events recorded by the species scorer : "
0094            << masterGvaluesScorer->GetpScorer()->GetNumberOfRecordedEvents() << " events "
0095            << G4endl;
0096     G4double dose_mean = masterDoseLimite->GetpScorer()->fDosesCutOff / gray;
0097     auto boundingBox = masterDoseLimite->GetChemistryWorld()->GetChemistryBoundary();
0098     G4double V = boundingBox->Volume() / cm3;
0099     G4double DoseInGray = (sumDose / eV) / (0.001 * V * 6.242e+18);
0100     G4cout << "Cut-off dose for each beam line : " << dose_mean << " Gy " << G4endl;
0101     G4cout << "Actual dose : " << DoseInGray << " Gy for " << nofEvents
0102            << " events. Actual average dose : " << DoseInGray / nofEvents << " Gy" << G4endl;
0103     masterGvaluesScorer->OutputAndClear(std::to_string(dose_mean));
0104   }
0105   else {
0106     G4cout << G4endl << "--------------------------End of Local Run------------------------------"
0107            << G4endl << "The run has " << nofEvents << " events. Scavenger info:" << G4endl;
0108     auto pScavengerMaterial =
0109       dynamic_cast<G4DNAScavengerMaterial*>(G4Scheduler::Instance()->GetScavengerMaterial());
0110     pScavengerMaterial->PrintInfo();
0111   }
0112 
0113   G4cout << "Total energy deposited in the world volume : " << sumDose / keV << " keV" << G4endl
0114          << "-------------------------------------------------------------------------" << G4endl
0115          << G4endl;
0116 }
0117 
0118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......