Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 08:29:04

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 #include "TimeStepAction.hh"
0030 
0031 #include "DetectorConstruction.hh"
0032 #include "G4AnalysisManager.hh"
0033 #include "G4IT.hh"
0034 #include "G4ITTrackHolder.hh"
0035 #include "G4RunManager.hh"
0036 #include "G4Scheduler.hh"
0037 #include "G4SystemOfUnits.hh"
0038 
0039 TimeStepAction::TimeStepAction()
0040 {
0041   fpDetector = dynamic_cast<const DetectorConstruction *>(
0042     G4RunManager::GetRunManager()->GetUserDetectorConstruction());
0043 }
0044 
0045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0046 
0047 void TimeStepAction::Save(const G4MolecularConfiguration *molconf)
0048 {
0049   const G4int moleculeID = molconf->GetMoleculeID();
0050   const G4String &moleculeName = molconf->GetFormatedName();
0051   G4TrackList *trackList = G4ITTrackHolder::Instance()->GetMainList(moleculeID);
0052 
0053   if (trackList == nullptr) return;
0054 
0055   for(const G4Track* track : *trackList)
0056   {
0057     SaveMoleculeInfo(track, moleculeID, moleculeName);
0058   }
0059 }
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0062 
0063 void TimeStepAction::
0064 SaveMoleculeInfo(const G4Track *track, const G4int molID,
0065                  const G4String & /*moleculeName*/)
0066 {
0067   G4AnalysisManager *analysisManager = G4AnalysisManager::Instance();
0068   if (!analysisManager->IsActive()) {
0069     return;
0070   }
0071 
0072   const G4ThreeVector &position = track->GetPosition();
0073   // H_{3}O^{1} ID = 0
0074   // OH^{-1}    ID = 1
0075   // OH^{0}     ID = 2
0076   // e_{aq}^{1} ID = 3
0077   // H0         ID = 4
0078   // H_{2}^{0}  ID = 5
0079   // H2O2       ID = 6
0080   // H_{2}O^{0} or H_{2}O^{1} ID=7-17
0081 
0082   const G4double xp = position.x();
0083   const G4double yp = position.y();
0084   const G4double zp = position.z();
0085   const G4double R = std::sqrt(xp * xp + yp * yp + zp * zp) / nm;
0086   if (molID < 7) {
0087     constexpr G4int offset = 10;
0088     analysisManager->FillH1(molID + offset, R);
0089   } else {
0090     analysisManager->FillH1(17, R);
0091   }
0092 }
0093 
0094 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0095 
0096 void TimeStepAction::UserPreTimeStepAction()
0097 {
0098   // Loop over defined molecules
0099   G4ConfigurationIterator it =
0100     G4MoleculeTable::Instance()->GetConfigurationIterator();
0101 
0102   const G4double time = G4Scheduler::Instance()->GetGlobalTime();
0103 
0104   if (time == 1. * us) {
0105     while (it()) {
0106       const G4MolecularConfiguration *molconf = it.value();
0107       Save(molconf);
0108     }
0109   }
0110 }
0111 
0112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......