Warning, file /include/Geant4/G4MoleculeGun.hh 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
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 #ifndef MOLECULEGUN_HH_
0046 #define MOLECULEGUN_HH_
0047
0048 #include "G4ITGun.hh"
0049 #include "globals.hh"
0050 #include "G4ThreeVector.hh"
0051 #include "G4memory.hh"
0052
0053 #include <vector>
0054 #include <map>
0055
0056 class G4Track;
0057 class G4MoleculeGunMessenger;
0058 class G4MoleculeShootMessenger;
0059 class G4MoleculeGun;
0060
0061 using G4ContinuousMedium = G4int;
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072 class G4MoleculeShoot : public G4enable_shared_from_this<G4MoleculeShoot>
0073 {
0074 public:
0075
0076 G4MoleculeShoot();
0077 virtual ~G4MoleculeShoot();
0078 virtual void Shoot(G4MoleculeGun*) = 0;
0079
0080 template<typename TYPE> G4shared_ptr<G4MoleculeShoot> ChangeType();
0081
0082 G4String fMoleculeName;
0083 G4ThreeVector fPosition;
0084 G4double fTime;
0085 G4int fNumber;
0086 G4ThreeVector* fBoxSize;
0087
0088 static void RandomPosInBox(const G4ThreeVector& boxSize,
0089 G4ThreeVector& output);
0090 };
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100 template<typename TYPE>
0101 class TG4MoleculeShoot : public G4MoleculeShoot
0102 {
0103 public:
0104 TG4MoleculeShoot() : G4MoleculeShoot(){}
0105 ~TG4MoleculeShoot() override= default;
0106 void Shoot(G4MoleculeGun*) override{}
0107
0108 protected:
0109 void ShootAtRandomPosition(G4MoleculeGun*){}
0110 void ShootAtFixedPosition(G4MoleculeGun*){}
0111 };
0112
0113 template<>
0114 void TG4MoleculeShoot<G4Track>::ShootAtRandomPosition(G4MoleculeGun* gun);
0115
0116 template<>
0117 void TG4MoleculeShoot<G4Track>::ShootAtFixedPosition(G4MoleculeGun* gun);
0118
0119 template<>
0120 void TG4MoleculeShoot<G4Track>::Shoot(G4MoleculeGun* gun);
0121
0122 template<typename TYPE>
0123 G4shared_ptr<G4MoleculeShoot> G4MoleculeShoot::ChangeType()
0124 {
0125 G4shared_ptr<G4MoleculeShoot> output(new TG4MoleculeShoot<TYPE>);
0126 output->fMoleculeName = fMoleculeName;
0127 output->fPosition = fPosition;
0128 output->fTime = fTime;
0129 output->fNumber = fNumber;
0130 output->fBoxSize = fBoxSize;
0131 return output;
0132 }
0133
0134
0135
0136
0137 class G4MoleculeGun : public G4ITGun
0138 {
0139 public:
0140 G4MoleculeGun();
0141 ~G4MoleculeGun() override;
0142
0143 void DefineTracks() override;
0144
0145
0146
0147
0148
0149
0150
0151 void AddMolecule(const G4String& moleculeName,
0152 const G4ThreeVector& position,
0153 G4double time = 0);
0154
0155
0156
0157
0158
0159
0160
0161
0162 void AddNMolecules(std::size_t n,
0163 const G4String& moleculeName,
0164 const G4ThreeVector& position,
0165 G4double time = 0);
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175 void AddMoleculesRandomPositionInBox(std::size_t n,
0176 const G4String& moleculeName,
0177 const G4ThreeVector& boxCenter,
0178 const G4ThreeVector& boxExtension,
0179 G4double time = 0);
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195 void AddMoleculeInCMRepresentation(std::size_t n,
0196 const G4String& moleculeName,
0197 G4double time = 0);
0198
0199 const std::vector<G4shared_ptr<G4MoleculeShoot> >&
0200 GetMoleculeShoot() {
0201 return fShoots;
0202 }
0203
0204 using NameNumber = std::map<G4String, G4int>;
0205 void GetNameAndNumber(NameNumber&);
0206
0207
0208 void AddMoleculeShoot(G4shared_ptr<G4MoleculeShoot>);
0209
0210 protected:
0211 void BuildAndPushTrack(const G4String& name,
0212 const G4ThreeVector& position,
0213 G4double time = 0);
0214 G4MoleculeGunMessenger* fpMessenger;
0215
0216 std::vector<G4shared_ptr<G4MoleculeShoot> > fShoots;
0217 friend class G4MoleculeShoot;
0218 template<class T> friend class TG4MoleculeShoot;
0219 };
0220
0221 #endif