Back to home page

EIC code displayed by LXR

 
 

    


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

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 // This example is provided by the Geant4-DNA collaboration
0027 // Any report or published results obtained using the Geant4-DNA software
0028 // shall cite the following Geant4-DNA collaboration publication:
0029 // Med. Phys. 37 (2010) 4692-4708
0030 // and papers
0031 // M. Batmunkh et al. J Radiat Res Appl Sci 8 (2015) 498-507
0032 // O. Belov et al. Physica Medica 32 (2016) 1510-1520
0033 // The Geant4-DNA web site is available at http://geant4-dna.org
0034 //
0035 // -------------------------------------------------------------------
0036 // November 2016
0037 // -------------------------------------------------------------------
0038 //
0039 /// \file ActionInitialization.cc
0040 /// \brief Implementation of the ActionInitialization class
0041 
0042 #include "ActionInitialization.hh"
0043 
0044 #include "DetectorConstruction.hh"
0045 #include "EventAction.hh"
0046 #include "PrimaryGeneratorAction.hh"
0047 #include "RunAction.hh"
0048 #include "SteppingAction.hh"
0049 #include "TrackingAction.hh"
0050 
0051 #include "G4RunManager.hh"
0052 // added for chemistry
0053 #include "DetectorConstruction.hh"
0054 #include "ITSteppingAction.hh"
0055 #include "ITTrackingAction.hh"
0056 #include "ITTrackingInteractivity.hh"
0057 #include "StackingAction.hh"
0058 #include "TimeStepAction.hh"
0059 
0060 #include "G4DNAChemistryManager.hh"
0061 #include "G4Scheduler.hh"
0062 #include "G4SystemOfUnits.hh"
0063 #include "G4Threading.hh"
0064 #include "G4UnitsTable.hh"
0065 
0066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0067 
0068 ActionInitialization::ActionInitialization(DetectorConstruction* detector)
0069   : G4VUserActionInitialization(), fDetector(detector)
0070 {}
0071 
0072 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0073 
0074 ActionInitialization::~ActionInitialization() {}
0075 
0076 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0077 
0078 void ActionInitialization::BuildForMaster() const
0079 {
0080   // In MT mode, to be clearer, the RunAction class for the master thread might
0081   // be different than the one used for the workers.
0082   // This RunAction will be called before and after starting the
0083   // workers.
0084   // For more details, please refer to :
0085   // https://twiki.cern.ch/twiki/bin/view/Geant4/Geant4MTForApplicationDevelopers
0086   //
0087 
0088   SetUserAction(new RunAction(fDetector, 0));
0089 }
0090 
0091 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0092 
0093 void ActionInitialization::Build() const
0094 {
0095   // G4cout << "Build for = "
0096   // << G4RunManager::GetRunManager()->GetRunManagerType()
0097   // << G4endl;
0098 
0099   PrimaryGeneratorAction* kinematics = new PrimaryGeneratorAction();
0100   SetUserAction(kinematics);
0101 
0102   TrackingAction* trackingAction = new TrackingAction();
0103   SetUserAction(trackingAction);
0104 
0105   RunAction* runAction = new RunAction(fDetector, kinematics);
0106   SetUserAction(runAction);
0107 
0108   SetUserAction(new SteppingAction(runAction));
0109   SetUserAction(new EventAction(runAction));
0110   // added
0111   SetUserAction(new StackingAction());
0112 
0113   // chemistry part
0114   if (G4DNAChemistryManager::IsActivated()) {
0115     G4Scheduler::Instance()->SetUserAction(new TimeStepAction());
0116 
0117     // Uncomment and set to stop chemistry stage after:
0118     // ...given number of time steps
0119     // G4Scheduler::Instance()->SetMaxNbSteps(1000);
0120 
0121     // ...OR reaching this time
0122     G4Scheduler::Instance()->SetEndTime(0.01 * nanosecond);  // default: 10 ps
0123 
0124     G4Scheduler::Instance()->SetVerbose(1);  // default: 1-print reactions;
0125 
0126     ITTrackingInteractivity* itInteractivity = new ITTrackingInteractivity();
0127     itInteractivity->SetUserAction(new ITSteppingAction);
0128     itInteractivity->SetUserAction(new ITTrackingAction);
0129     G4Scheduler::Instance()->SetInteractivity(itInteractivity);
0130   }
0131   /*
0132     // To output the pre-chemical stage
0133     //
0134     G4String fileName ("output");
0135 
0136     if(G4RunManager::GetRunManager()->GetRunManagerType() ==
0137         G4RunManager::sequentialRM)
0138     {
0139       // write initial situation at 1 picosecond
0140       G4DNAChemistryManager::Instance()->WriteInto(fileName + ".txt");
0141     }
0142     else
0143     {
0144       G4int id = G4Threading::G4GetThreadId();
0145 
0146       G4String fileName_mt = fileName;
0147       fileName_mt += G4UIcommand::ConvertToString(id);
0148       fileName_mt += ".txt";
0149 
0150       G4cout << "chosen file name : " << fileName_mt << G4endl;
0151 
0152       G4DNAChemistryManager::Instance()->WriteInto(fileName_mt);
0153     }
0154   */
0155 }
0156 
0157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......