Warning, file /geant4/examples/advanced/dna/dsbandrepair/src/UserMoleculeGun.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 #include "UserMoleculeGun.hh"
0031 #include "UserMolecule.hh"
0032
0033 #include "G4MoleculeTable.hh"
0034 #include "G4SystemOfUnits.hh"
0035 #include "G4VITTrackHolder.hh"
0036 #include "G4H2O.hh"
0037 #include "G4Track.hh"
0038
0039 UserMoleculeShoot::UserMoleculeShoot() :
0040 G4enable_shared_from_this<UserMoleculeShoot>()
0041 {
0042 fMoleculeName = "";
0043 fTime = 0;
0044 fNumber = 1;
0045 fBoxSize = 0;
0046 fCopyNumber = -1;
0047 fStrand = -1;
0048 }
0049
0050
0051
0052 UserMoleculeShoot::~UserMoleculeShoot()
0053 {
0054 if(fBoxSize) delete fBoxSize;
0055 }
0056
0057
0058
0059 template<>
0060 void TUserMoleculeShoot<G4Track>::ShootAtRandomPosition(UserMoleculeGun* gun)
0061 {
0062 G4ThreeVector positionInLocalCoordinate;
0063
0064 for(int i = 0; i < fNumber; ++i)
0065 {
0066 RandomPosInBox(*fBoxSize, positionInLocalCoordinate);
0067 if(fStrand<=0)
0068 gun->BuildAndPushTrack(fMoleculeName,
0069 fPosition + positionInLocalCoordinate,
0070 fTime);
0071 else
0072 gun->BuildAndPushTrack(fMoleculeName,
0073 fPosition + positionInLocalCoordinate,
0074 fTime,fCopyNumber,fStrand);
0075 }
0076 }
0077
0078
0079
0080 template<>
0081 void TUserMoleculeShoot<G4Track>::ShootAtFixedPosition(UserMoleculeGun* gun)
0082 {
0083 for(int i = 0; i < fNumber; ++i)
0084 {
0085 if(fStrand<=0)
0086 gun->BuildAndPushTrack(fMoleculeName, fPosition, fTime);
0087 else
0088 gun->BuildAndPushTrack(fMoleculeName,fPosition,fTime,fCopyNumber,fStrand);
0089 }
0090 }
0091
0092
0093
0094 template<>
0095 void TUserMoleculeShoot<G4Track>::MyShoot(UserMoleculeGun* gun)
0096 {
0097 if(fBoxSize) ShootAtRandomPosition(gun);
0098 else ShootAtFixedPosition(gun);
0099 }
0100
0101
0102
0103 void UserMoleculeGun::DefineTracks()
0104 {
0105 for (size_t i = 0; i < fShoots.size(); i++)
0106 {
0107 fShoots[i]->MyShoot(this);
0108 }
0109 }
0110
0111
0112
0113 void UserMoleculeGun::AddMolecule(const G4String& name,
0114 const G4ThreeVector& position,
0115 G4double time,
0116 G4int copyNumber,
0117 G4int strand)
0118 {
0119 G4shared_ptr<UserMoleculeShoot> shoot(new TUserMoleculeShoot<G4Track>());
0120 shoot->fMoleculeName = name;
0121 shoot->fPosition = position;
0122 shoot->fTime = time;
0123 shoot->fCopyNumber = copyNumber;
0124 shoot->fStrand = strand;
0125 fShoots.push_back(shoot);
0126 }
0127
0128
0129
0130 void UserMoleculeGun::AddWaterMolecule(const G4ThreeVector& position,
0131 G4int trackId,
0132 ElectronicModification elecModif,
0133 G4int electronicLevel)
0134 {
0135 UserMolecule * H2O = new UserMolecule (G4H2O::Definition() );
0136 switch (elecModif)
0137 {
0138 case eDissociativeAttachment:
0139 H2O -> AddElectron(5,1);
0140 break;
0141 case eExcitedMolecule :
0142 H2O -> ExciteMolecule(electronicLevel);
0143 break;
0144 case eIonizedMolecule :
0145 H2O -> IonizeMolecule(electronicLevel);
0146 break;
0147 }
0148
0149 G4Track * H2OTrack = H2O->BuildTrack(1*picosecond, position);
0150 H2OTrack->SetParentID(trackId);
0151 H2OTrack->SetTrackStatus(fStopButAlive);
0152 H2OTrack->SetKineticEnergy(0.);
0153 G4VITTrackHolder::Instance()->Push(H2OTrack);
0154 }
0155
0156
0157
0158 void UserMoleculeGun::BuildAndPushTrack(const G4String& name,
0159 const G4ThreeVector& position,
0160 G4double time)
0161 {
0162 G4MolecularConfiguration* conf =
0163 G4MoleculeTable::Instance()->GetConfiguration(name);
0164 assert(conf != 0);
0165 UserMolecule* molecule = new UserMolecule(conf);
0166 PushTrack(molecule->BuildTrack(time, position));
0167 }
0168
0169
0170
0171 void UserMoleculeGun::BuildAndPushTrack(const G4String& name,
0172 const G4ThreeVector& position,
0173 G4double time,
0174 G4int copyNumber,
0175 G4int strand)
0176 {
0177 G4MoleculeDefinition* def = G4MoleculeTable::Instance()->GetMoleculeDefinition(name);
0178 assert(def != 0);
0179 UserMolecule* molecule = new UserMolecule(def);
0180 molecule->SetCopyNumber(copyNumber);
0181 molecule->SetStrand(strand);
0182
0183 PushTrack(molecule->BuildTrack(time, position));
0184 }
0185
0186