Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:47

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 // J. Comput. Phys. 274 (2014) 841-882
0031 // The Geant4-DNA web site is available at http://geant4-dna.org
0032 //
0033 // $Id$
0034 //
0035 /// \file TimeStepAction.hh
0036 /// \brief Implementation of the TimeStepAction class
0037 
0038 #include "TimeStepAction.hh"
0039 
0040 #include "DetectorConstruction.hh"
0041 
0042 #include "G4AnalysisManager.hh"
0043 #include "G4IT.hh"
0044 #include "G4ITTrackHolder.hh"
0045 #include "G4Molecule.hh"
0046 #include "G4RunManager.hh"
0047 #include "G4Scheduler.hh"
0048 #include "G4SystemOfUnits.hh"
0049 #include "G4UnitsTable.hh"
0050 // using namespace G4DNAPARSER;
0051 
0052 TimeStepAction::TimeStepAction() : G4UserTimeStepAction(), fpDetector(0)
0053 {
0054   fpDetector = dynamic_cast<const DetectorConstruction*>(
0055     G4RunManager::GetRunManager()->GetUserDetectorConstruction());
0056 
0057   AddTimeStep(1 * picosecond, 0.1 * picosecond);
0058   AddTimeStep(10 * picosecond, 1 * picosecond);
0059   AddTimeStep(100 * picosecond, 3 * picosecond);
0060   AddTimeStep(1000 * picosecond, 10 * picosecond);
0061   AddTimeStep(10000 * picosecond, 100 * picosecond);
0062 }
0063 
0064 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0065 
0066 TimeStepAction::~TimeStepAction()
0067 {
0068   // dtor
0069 }
0070 
0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0072 
0073 TimeStepAction::TimeStepAction(const TimeStepAction& other) : G4UserTimeStepAction(other)
0074 {
0075   // copy ctor
0076 }
0077 
0078 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0079 
0080 TimeStepAction& TimeStepAction::operator=(const TimeStepAction& rhs)
0081 {
0082   if (this == &rhs) return *this;
0083   return *this;
0084 }
0085 
0086 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0087 
0088 void TimeStepAction::Save(G4MolecularConfiguration* molconf)
0089 {
0090   G4int moleculeID = molconf->GetMoleculeID();
0091   const G4String& moleculeName = molconf->GetFormatedName();
0092   G4TrackList* trackList = G4ITTrackHolder::Instance()->GetMainList(moleculeID);
0093 
0094   if (trackList == 0) return;
0095 
0096   G4TrackList::iterator it = trackList->begin();
0097   G4TrackList::iterator end = trackList->end();
0098 
0099   for (; it != end; ++it) {
0100     G4Track* track = *it;
0101     SaveMoleculeInfo(track, moleculeID, moleculeName);
0102   }
0103 }
0104 
0105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0106 
0107 void TimeStepAction::SaveMoleculeInfo(G4Track* track, G4int molID, const G4String& /*moleculeName*/)
0108 {
0109   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0110   if (!analysisManager->IsActive()) {
0111     return;
0112   }
0113 
0114   const G4ThreeVector& position = track->GetPosition();
0115   // H_{3}O^{1} ID = 0
0116   // OH^{-1}    ID = 1
0117   // OH^{0}     ID = 2
0118   // e_{aq}^{1} ID = 3
0119   // H0         ID = 4
0120   // H_{2}^{0}  ID = 5
0121   // H2O2       ID = 6
0122   // H_{2}O^{0} or H_{2}O^{1} ID=7-17
0123 
0124   G4double xp = position.x();
0125   G4double yp = position.y();
0126   G4double zp = position.z();
0127   G4double R = std::sqrt(xp * xp + yp * yp + zp * zp) / CLHEP::nm;
0128   // G4double RNP   = fpDetector->GetNPRadius()/CLHEP::nm;
0129 
0130   G4int offset = 10;
0131 
0132   if (molID < 7) {
0133     analysisManager->FillH1(molID + offset, R);
0134   }
0135   else {
0136     analysisManager->FillH1(17, R);
0137   }
0138 
0139   G4Scheduler::Instance()->Stop();
0140 }
0141 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0142 
0143 void TimeStepAction::UserPreTimeStepAction()
0144 {
0145   // Loop over defined molecules
0146   G4ConfigurationIterator it = G4MoleculeTable::Instance()->GetConfigurationIterator();
0147 
0148   G4double time = G4Scheduler::Instance()->GetGlobalTime();
0149 
0150   if (time == 1. * picosecond) {
0151     while (it()) {
0152       G4MolecularConfiguration* molconf = it.value();
0153       Save(molconf);
0154     }
0155   }
0156 }
0157 
0158 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0159 
0160 void TimeStepAction::UserReactionAction(const G4Track&, const G4Track&,
0161                                         const std::vector<G4Track*>* /*products*/)
0162 {}