Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // This example is provided by the Geant4-DNA 26 // This example is provided by the Geant4-DNA collaboration 27 // Any report or published results obtained us 27 // Any report or published results obtained using the Geant4-DNA software 28 // shall cite the following Geant4-DNA collabo 28 // shall cite the following Geant4-DNA collaboration publication: 29 // Med. Phys. 37 (2010) 4692-4708 29 // Med. Phys. 37 (2010) 4692-4708 30 // J. Comput. Phys. 274 (2014) 841-882 30 // J. Comput. Phys. 274 (2014) 841-882 31 // The Geant4-DNA web site is available at htt 31 // The Geant4-DNA web site is available at http://geant4-dna.org 32 // 32 // 33 // 33 // 34 /// \file TimeStepAction.hh 34 /// \file TimeStepAction.hh 35 /// \brief Implementation of the TimeStepActio 35 /// \brief Implementation of the TimeStepAction class 36 36 37 #include "TimeStepAction.hh" 37 #include "TimeStepAction.hh" 38 38 39 #include "G4MolecularConfiguration.hh" << 40 #include "G4Molecule.hh" << 41 #include "G4MoleculeTable.hh" << 42 #include "G4SystemOfUnits.hh" << 43 #include "G4UnitsTable.hh" << 44 << 45 #include <G4Scheduler.hh> 39 #include <G4Scheduler.hh> >> 40 #include "G4UnitsTable.hh" >> 41 #include "G4SystemOfUnits.hh" >> 42 //#include "G4Molecule.hh" 46 43 47 TimeStepAction::TimeStepAction() : G4UserTimeS 44 TimeStepAction::TimeStepAction() : G4UserTimeStepAction() 48 { 45 { 49 /** 46 /** 50 * Give to G4ITTimeStepper the user defined 47 * Give to G4ITTimeStepper the user defined time steps 51 * eg : from 1 picosecond to 10 picosecond, 48 * eg : from 1 picosecond to 10 picosecond, the minimum time 52 * step that the TimeStepper can returned is 49 * step that the TimeStepper can returned is 0.1 picosecond. 53 * Those time steps are used for the chemist 50 * Those time steps are used for the chemistry of G4DNA 54 */ 51 */ 55 52 56 AddTimeStep(1 * picosecond, 0.1 * picosecond << 53 AddTimeStep(1*picosecond, 0.1*picosecond); 57 AddTimeStep(10 * picosecond, 1 * picosecond) << 54 AddTimeStep(10*picosecond, 1*picosecond); 58 AddTimeStep(100 * picosecond, 3 * picosecond << 55 AddTimeStep(100*picosecond, 3*picosecond); 59 AddTimeStep(1000 * picosecond, 10 * picoseco << 56 AddTimeStep(1000*picosecond, 10*picosecond); 60 AddTimeStep(10000 * picosecond, 100 * picose << 57 AddTimeStep(10000*picosecond, 100*picosecond); 61 } 58 } 62 59 63 //....oooOO0OOooo........oooOO0OOooo........oo 60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 64 61 65 void TimeStepAction::UserPostTimeStepAction() << 62 TimeStepAction::~TimeStepAction() 66 { 63 { 67 if (G4Scheduler::Instance()->GetGlobalTime() << 64 //dtor 68 G4cout << "_________________" << G4endl; << 65 } 69 G4cout << "At : " << G4BestUnit(G4Schedule << 70 66 71 auto species = G4MoleculeTable::Instance() << 67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 72 PrintSpecieInfo(species); << 68 73 } << 69 TimeStepAction::TimeStepAction(const TimeStepAction& other) : >> 70 G4UserTimeStepAction(other) >> 71 { >> 72 //copy ctor 74 } 73 } 75 74 76 //....oooOO0OOooo........oooOO0OOooo........oo 75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 77 76 78 void TimeStepAction::UserReactionAction(const << 77 TimeStepAction& 79 const << 78 TimeStepAction::operator=(const TimeStepAction& rhs) 80 { 79 { 81 // this function shows how to get species ID << 80 if (this == &rhs) return *this; // handle self assignment 82 G4cout << G4endl; << 81 //assignment operator >> 82 return *this; >> 83 } 83 84 84 G4cout << "At : " << G4Scheduler::Instance() << 85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 85 << " (ns) reactantA = " << GetMolecul << 86 86 << " (ID number = " << reactantA.GetT << 87 void TimeStepAction::UserPostTimeStepAction() 87 << " at position : " << reactantA.Get << 88 { 88 << " reacts with reactantB = " << Get << 89 // G4cout << "_________________" << G4endl; 89 << " (ID number = " << reactantB.GetT << 90 /* 90 << " at position : " << reactantA.Get << 91 G4cout << "Time Step : " 91 << 92 << G4BestUnit(G4ITScheduler::Instance()->GetTimeStep(), 92 if (products) { << 93 "Time") 93 auto nbProducts = (G4int)products->size(); << 94 << G4endl; 94 for (G4int i = 0; i < nbProducts; i++) { << 95 95 G4cout << " creating product " << i << 96 G4cout << "End of step: " 96 << " position : " << (*products)[ << 97 << G4BestUnit(G4ITScheduler::Instance()->GetGlobalTime(), 97 } << 98 "Time") 98 } << 99 << G4endl; 99 G4cout << G4endl; << 100 */ 100 } 101 } 101 102 102 void TimeStepAction::PrintSpecieInfo(G4Molecul << 103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 104 >> 105 void TimeStepAction::UserReactionAction(const G4Track& /*a*/, >> 106 const G4Track& /*b*/, >> 107 const std::vector<G4Track*>* /*products*/) 103 { 108 { 104 // this function shows how to get a specific << 109 // Example to display reactions with product 105 auto moleculeID = molconf->GetMoleculeID(); << 110 // S. Incerti, H. Tran 106 const G4String& moleculeName = molconf->GetF << 111 // 2019/01/24 107 G4cout << "Get inf of : " << moleculeName << << 112 108 auto trackList = G4ITTrackHolder::Instance() << 113 /* 109 << 114 if (products) 110 if (trackList == nullptr) { << 115 { 111 G4cout << "No species" << G4endl; << 116 G4cout << G4endl; 112 return; << 117 G4int nbProducts = products->size(); >> 118 for (int i = 0 ; i < nbProducts ; i ++) >> 119 { >> 120 G4cout << "-> A = " >> 121 << GetMolecule(&a)->GetName() << " (TrackID=" << a.GetTrackID() << ")" >> 122 << " reacts with B = " >> 123 << GetMolecule(&b)->GetName() << " (TrackID=" << b.GetTrackID() << ")" >> 124 << " creating product " << i+1 << " =" >> 125 << GetMolecule((*products)[i])->GetName() >> 126 << G4endl ; >> 127 >> 128 G4cout >> 129 <<" A position: x(nm)="<<a.GetPosition().getX()/nm >> 130 <<" y(nm)="<<a.GetPosition().getY()/nm >> 131 <<" z(nm)="<<a.GetPosition().getZ()/nm >> 132 <<G4endl; >> 133 >> 134 G4cout >> 135 <<" B position: x(nm)="<<b.GetPosition().getX()/nm >> 136 <<" y(nm)="<<b.GetPosition().getY()/nm >> 137 <<" z(nm)="<<b.GetPosition().getZ()/nm >> 138 <<G4endl; >> 139 >> 140 G4cout >> 141 <<" Product " << i+1 << "position: x(nm)="<<(*products)[i]->GetPosition().getX()/nm >> 142 <<" y(nm)="<<a.GetPosition().getY()/nm >> 143 <<" z(nm)="<<a.GetPosition().getZ()/nm >> 144 <<G4endl; >> 145 } 113 } 146 } 114 G4TrackList::iterator it = trackList->begin( << 147 115 G4TrackList::iterator end = trackList->end() << 148 else 116 for (; it != end; ++it) { << 149 117 auto track = *it; << 150 { 118 G4cout << "TrackID: " << track->GetTrackID << 151 G4cout << G4endl; 119 << G4endl; << 152 G4cout << "-> A = " >> 153 << GetMolecule(&a)->GetName() << " (TrackID=" << a.GetTrackID() << ")" >> 154 << " reacts with B = " >> 155 << GetMolecule(&b)->GetName() << " (TrackID=" << b.GetTrackID() << ")" >> 156 << G4endl ; >> 157 >> 158 G4cout >> 159 <<" A position: x(nm)="<<a.GetPosition().getX()/nm >> 160 <<" y(nm)="<<a.GetPosition().getY()/nm >> 161 <<" z(nm)="<<a.GetPosition().getZ()/nm >> 162 <<G4endl; >> 163 >> 164 G4cout >> 165 <<" B position: x(nm)="<<b.GetPosition().getX()/nm >> 166 <<" y(nm)="<<b.GetPosition().getY()/nm >> 167 <<" z(nm)="<<b.GetPosition().getZ()/nm >> 168 <<G4endl; >> 169 120 } 170 } >> 171 */ >> 172 121 } 173 } 122 174