File indexing completed on 2025-02-23 09:21:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
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
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
0065
0066 TimeStepAction::~TimeStepAction()
0067 {
0068
0069 }
0070
0071
0072
0073 TimeStepAction::TimeStepAction(const TimeStepAction& other) : G4UserTimeStepAction(other)
0074 {
0075
0076 }
0077
0078
0079
0080 TimeStepAction& TimeStepAction::operator=(const TimeStepAction& rhs)
0081 {
0082 if (this == &rhs) return *this;
0083 return *this;
0084 }
0085
0086
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
0106
0107 void TimeStepAction::SaveMoleculeInfo(G4Track* track, G4int molID, const G4String& )
0108 {
0109 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0110 if (!analysisManager->IsActive()) {
0111 return;
0112 }
0113
0114 const G4ThreeVector& position = track->GetPosition();
0115
0116
0117
0118
0119
0120
0121
0122
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
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
0142
0143 void TimeStepAction::UserPreTimeStepAction()
0144 {
0145
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
0159
0160 void TimeStepAction::UserReactionAction(const G4Track&, const G4Track&,
0161 const std::vector<G4Track*>* )
0162 {}