Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 /// \file UserMoleculeGun.cc 28 /// \brief Implementation of the UserMoleculeG 29 30 #include "UserMoleculeGun.hh" 31 #include "UserMolecule.hh" 32 33 #include "G4MoleculeTable.hh" 34 #include "G4SystemOfUnits.hh" 35 #include "G4VITTrackHolder.hh" 36 #include "G4H2O.hh" 37 #include "G4Track.hh" 38 39 UserMoleculeShoot::UserMoleculeShoot() : 40 G4enable_shared_from_this<UserMoleculeShoot>() 41 { 42 fMoleculeName = ""; 43 fTime = 0; 44 fNumber = 1; 45 fBoxSize = 0; 46 fCopyNumber = -1; 47 fStrand = -1; 48 } 49 50 //....oooOO0OOooo........oooOO0OOooo........oo 51 52 UserMoleculeShoot::~UserMoleculeShoot() 53 { 54 if(fBoxSize) delete fBoxSize; 55 } 56 57 //....oooOO0OOooo........oooOO0OOooo........oo 58 59 template<> 60 void TUserMoleculeShoot<G4Track>::ShootAtRando 61 { 62 G4ThreeVector positionInLocalCoordinate; 63 64 for(int i = 0; i < fNumber; ++i) 65 { 66 RandomPosInBox(*fBoxSize, positionInLo 67 if(fStrand<=0) 68 gun->BuildAndPushTrack(fMoleculeName, 69 fPosition + positionInLocalCoordinate, 70 fTime); 71 else 72 gun->BuildAndPushTrack(fMoleculeName, 73 fPosition + positionInLocalCoordinate, 74 fTime,fCopyNumber,fStrand); 75 } 76 } 77 78 //....oooOO0OOooo........oooOO0OOooo........oo 79 80 template<> 81 void TUserMoleculeShoot<G4Track>::ShootAtFixed 82 { 83 for(int i = 0; i < fNumber; ++i) 84 { 85 if(fStrand<=0) 86 gun->BuildAndPushTrack(fMoleculeName, 87 else 88 gun->BuildAndPushTrack(fMoleculeName,f 89 } 90 } 91 92 //....oooOO0OOooo........oooOO0OOooo........oo 93 94 template<> 95 void TUserMoleculeShoot<G4Track>::MyShoot(User 96 { 97 if(fBoxSize) ShootAtRandomPosition(gun); 98 else ShootAtFixedPosition(gun); 99 } 100 101 //....oooOO0OOooo........oooOO0OOooo........oo 102 103 void UserMoleculeGun::DefineTracks() 104 { 105 for (size_t i = 0; i < fShoots.size(); i++ 106 { 107 fShoots[i]->MyShoot(this); 108 } 109 } 110 111 //....oooOO0OOooo........oooOO0OOooo........oo 112 113 void UserMoleculeGun::AddMolecule(const G4Stri 114 const G4ThreeVector& position, 115 G4double time, 116 G4int copyNumber, 117 G4int strand) 118 { 119 G4shared_ptr<UserMoleculeShoot> shoot(new 120 shoot->fMoleculeName = name; 121 shoot->fPosition = position; 122 shoot->fTime = time; 123 shoot->fCopyNumber = copyNumber; 124 shoot->fStrand = strand; 125 fShoots.push_back(shoot); 126 } 127 128 //....oooOO0OOooo........oooOO0OOooo........oo 129 130 void UserMoleculeGun::AddWaterMolecule(const G 131 G4int trackId, 132 ElectronicModification elecModif, 133 G4int electronicLevel) 134 { 135 UserMolecule * H2O = new UserMolecule (G4H 136 switch (elecModif) 137 { 138 case eDissociativeAttachment: 139 H2O -> AddElectron(5,1); 140 break; 141 case eExcitedMolecule : 142 H2O -> ExciteMolecule(electronicLevel) 143 break; 144 case eIonizedMolecule : 145 H2O -> IonizeMolecule(electronicLevel) 146 break; 147 } 148 149 G4Track * H2OTrack = H2O->BuildTrack(1*pic 150 H2OTrack->SetParentID(trackId); 151 H2OTrack->SetTrackStatus(fStopButAlive); 152 H2OTrack->SetKineticEnergy(0.); 153 G4VITTrackHolder::Instance()->Push(H2OTrac 154 } 155 156 //....oooOO0OOooo........oooOO0OOooo........oo 157 158 void UserMoleculeGun::BuildAndPushTrack(const 159 const G4ThreeVector& position, 160 G4double time) 161 { 162 G4MolecularConfiguration* conf = 163 G4MoleculeTable::Instance()->GetConfigurat 164 assert(conf != 0); 165 UserMolecule* molecule = new UserMolecule( 166 PushTrack(molecule->BuildTrack(time, posit 167 } 168 169 //....oooOO0OOooo........oooOO0OOooo........oo 170 171 void UserMoleculeGun::BuildAndPushTrack(const 172 const G4ThreeVector& position, 173 G4double time, 174 G4int copyNumber, 175 G4int strand) 176 { 177 G4MoleculeDefinition* def = G4MoleculeTabl 178 assert(def != 0); 179 UserMolecule* molecule = new UserMolecule( 180 molecule->SetCopyNumber(copyNumber); 181 molecule->SetStrand(strand); 182 183 PushTrack(molecule->BuildTrack(time, posit 184 } 185 186 //....oooOO0OOooo........oooOO0OOooo........oo 187