Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:18

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 // Hadrontherapy advanced example for Geant4
0027 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy
0028 
0029 #include "HadrontherapyRunAction.hh"
0030 #include "HadrontherapyEventAction.hh"
0031 #include "G4AnalysisManager.hh"
0032 #include "G4Run.hh"
0033 #include "G4RunManager.hh"
0034 #include "G4UImanager.hh"
0035 #include "G4ios.hh"
0036 #include "HadrontherapyDetectorConstruction.hh"
0037 #include "G4SDManager.hh"
0038 #include "G4Timer.hh"
0039 #include "HadrontherapyRunAction.hh"
0040 #include "HadrontherapyMatrix.hh"
0041 #include "HadrontherapyRBE.hh"
0042 #include "G4UnitsTable.hh"
0043 #include "G4SystemOfUnits.hh"
0044 
0045 #include <G4AccumulableManager.hh>
0046 
0047 /////////////////////////////////////////////////////////////////////////////
0048 HadrontherapyRunAction::HadrontherapyRunAction()
0049 {
0050     G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
0051     accumulableManager->RegisterAccumulable(&fRBEAccumulable);
0052     
0053 }
0054 
0055 /////////////////////////////////////////////////////////////////////////////
0056 HadrontherapyRunAction::~HadrontherapyRunAction()
0057 {
0058 }
0059 
0060 /////////////////////////////////////////////////////////////////////////////
0061 void HadrontherapyRunAction::BeginOfRunAction(const G4Run* aRun)
0062 {   
0063     G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
0064     accumulableManager->Reset();
0065 
0066     G4RunManager::GetRunManager()-> SetRandomNumberStore(true);
0067     G4cout << "Run " << aRun -> GetRunID() << " starts ..." << G4endl;
0068 
0069     HadrontherapyRBE *rbe = HadrontherapyRBE::GetInstance();
0070     if (rbe->IsCalculationEnabled() && IsMaster() && rbe->GetVerboseLevel() > 0)
0071     {
0072         rbe->PrintParameters();
0073     }
0074     
0075     electromagnetic = 0;
0076     hadronic = 0;
0077 }
0078 
0079 /////////////////////////////////////////////////////////////////////////////
0080 void HadrontherapyRunAction::EndOfRunAction(const G4Run*)
0081 {
0082     auto analysisManager = G4AnalysisManager::Instance();
0083 
0084     G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
0085     accumulableManager->Merge();
0086 
0087     // Tell the RBE class what we have accumulated...
0088     HadrontherapyRBE *rbe = HadrontherapyRBE::GetInstance();
0089     if (rbe->IsCalculationEnabled() && IsMaster())
0090     {
0091         if (rbe->IsAccumulationEnabled())
0092         {
0093             rbe->AddAlphaNumerator(fRBEAccumulable.GetAlphaNumerator());
0094             rbe->AddBetaNumerator(fRBEAccumulable.GetBetaNumerator());
0095             rbe->AddDenominator(fRBEAccumulable.GetDenominator());
0096             rbe->AddEnergyDeposit(fRBEAccumulable.GetEnergyDeposit());
0097         }
0098         else
0099         {
0100             rbe->SetAlphaNumerator(fRBEAccumulable.GetAlphaNumerator());
0101             rbe->SetBetaNumerator(fRBEAccumulable.GetBetaNumerator());
0102             rbe->SetDenominator(fRBEAccumulable.GetDenominator());
0103             rbe->SetEnergyDeposit(fRBEAccumulable.GetEnergyDeposit());
0104         }
0105 
0106         rbe->StoreAlphaAndBeta();
0107         rbe->StoreRBE();
0108     }
0109     
0110     if (analysisManager->IsOpenFile()) {
0111       analysisManager->Write();
0112       analysisManager->CloseFile();
0113     }
0114 }
0115 /////////////////////////////////////////////////////////////////////////////
0116 void HadrontherapyRunAction::AddEMProcess()
0117 {
0118     electromagnetic += 1;
0119 }
0120 
0121 /////////////////////////////////////////////////////////////////////////////
0122 void HadrontherapyRunAction::AddHadronicProcess()
0123 {
0124     hadronic += 1;
0125 }