Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 08:29:39

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 /// \file TimeStepAction.cc
0027 /// \brief Implementation of the TimeStepAction class
0028 
0029 // This example is provided by the Geant4-DNA collaboration
0030 // Any report or published results obtained using the Geant4-DNA software
0031 // shall cite the following Geant4-DNA collaboration publication:
0032 // Med. Phys. 37 (2010) 4692-4708
0033 // J. Comput. Phys. 274 (2014) 841-882
0034 // The Geant4-DNA web site is available at http://geant4-dna.org
0035 //
0036 //
0037 
0038 #include "TimeStepAction.hh"
0039 
0040 #include "G4SystemOfUnits.hh"
0041 #include "G4UnitsTable.hh"
0042 // #include "G4ITScheduler.hh"
0043 // #include "G4Molecule.hh"
0044 
0045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0046 
0047 TimeStepAction::TimeStepAction() : G4UserTimeStepAction()
0048 {
0049   /**
0050    * Inform G4ITTimeStepper of the selected minimum time steps
0051    * eg : from 1 picosecond to 10 picosecond, the minimum time
0052    * step that the TimeStepper can returned is 0.1 picosecond.
0053    *
0054    * Case 1) If the rection model calculates a minimum reaction time
0055    * bigger than the user defined time step, the reaction model wins
0056    *
0057    * Case 2) If an interaction process with the continuous medium
0058    * calculates a time step less than the selected minimum time step,
0059    * the interaction process wins
0060    */
0061 
0062   AddTimeStep(1 * picosecond, 0.1 * picosecond);
0063   AddTimeStep(10 * picosecond, 1 * picosecond);
0064   AddTimeStep(100 * picosecond, 10 * picosecond);
0065   AddTimeStep(1000 * picosecond, 100 * picosecond);
0066   AddTimeStep(10000 * picosecond, 1000 * picosecond);
0067 }
0068 
0069 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0070 
0071 TimeStepAction::~TimeStepAction() {}
0072 
0073 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0074 
0075 TimeStepAction::TimeStepAction(const TimeStepAction& other) : G4UserTimeStepAction(other) {}
0076 
0077 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0078 TimeStepAction& TimeStepAction::operator=(const TimeStepAction& rhs)
0079 {
0080   if (this == &rhs) return *this;  // handle self assignment
0081   // assignment operator
0082   return *this;
0083 }
0084 
0085 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0086 
0087 void TimeStepAction::StartProcessing()
0088 {
0089   // You want to know why the simulation stopped ?
0090   // G4ITScheduler::Instance()->WhyDoYouStop();
0091   // At the end of the simulation, information will be printed
0092   // It is better to place this command before the simulation starts
0093 }
0094 
0095 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0096 
0097 void TimeStepAction::UserPreTimeStepAction() {}
0098 
0099 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0100 
0101 void TimeStepAction::UserPostTimeStepAction() {}
0102 
0103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0104 
0105 // Here you can retrieve information related to reactions
0106 void TimeStepAction::UserReactionAction(const G4Track& /*a*/, const G4Track& /*b*/,
0107                                         const std::vector<G4Track*>* /*products*/)
0108 {
0109   // Example to display reactions with product
0110   // S. Incerti, H. Tran
0111   // 2019/01/24
0112 
0113   /*
0114   if (products)
0115   {
0116     G4cout << G4endl;
0117     G4int nbProducts = products->size();
0118     for (int i = 0 ; i < nbProducts ; i ++)
0119     {
0120       G4cout << "-> A = "
0121         << GetMolecule(&a)->GetName() << " (TrackID=" << a.GetTrackID() << ")"
0122         << " reacts with B = "
0123         << GetMolecule(&b)->GetName() << " (TrackID=" << b.GetTrackID() << ")"
0124         << " creating product " << i+1 << " ="
0125         << GetMolecule((*products)[i])->GetName()
0126         << G4endl ;
0127 
0128       G4cout
0129       <<" A position: x(nm)="<<a.GetPosition().getX()/nm
0130       <<" y(nm)="<<a.GetPosition().getY()/nm
0131       <<" z(nm)="<<a.GetPosition().getZ()/nm
0132       <<G4endl;
0133 
0134       G4cout
0135       <<" B position: x(nm)="<<b.GetPosition().getX()/nm
0136       <<" y(nm)="<<b.GetPosition().getY()/nm
0137       <<" z(nm)="<<b.GetPosition().getZ()/nm
0138       <<G4endl;
0139 
0140       G4cout
0141       <<" Product " << i+1 << "position: x(nm)="<<(*products)[i]->GetPosition().getX()/nm
0142       <<" y(nm)="<<a.GetPosition().getY()/nm
0143       <<" z(nm)="<<a.GetPosition().getZ()/nm
0144       <<G4endl;
0145     }
0146   }
0147 
0148   else
0149 
0150   {
0151      G4cout << G4endl;
0152      G4cout << "-> A = "
0153         << GetMolecule(&a)->GetName() << " (TrackID=" << a.GetTrackID() << ")"
0154         << " reacts with B = "
0155         << GetMolecule(&b)->GetName() << " (TrackID=" << b.GetTrackID() << ")"
0156         << G4endl ;
0157 
0158       G4cout
0159       <<" A position: x(nm)="<<a.GetPosition().getX()/nm
0160       <<" y(nm)="<<a.GetPosition().getY()/nm
0161       <<" z(nm)="<<a.GetPosition().getZ()/nm
0162       <<G4endl;
0163 
0164       G4cout
0165       <<" B position: x(nm)="<<b.GetPosition().getX()/nm
0166       <<" y(nm)="<<b.GetPosition().getY()/nm
0167       <<" z(nm)="<<b.GetPosition().getZ()/nm
0168       <<G4endl;
0169 
0170   }
0171   */
0172 }
0173 
0174 void TimeStepAction::EndProcessing() {}