|
||||
File indexing completed on 2025-01-18 09:58:41
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // Author: Mathieu Karamitros 0027 0028 // The code is developed in the framework of the ESA AO7146 0029 // 0030 // We would be very happy hearing from you, send us your feedback! :) 0031 // 0032 // In order for Geant4-DNA to be maintained and still open-source, 0033 // article citations are crucial. 0034 // If you use Geant4-DNA chemistry and you publish papers about your software, 0035 // in addition to the general paper on Geant4-DNA: 0036 // 0037 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 157–178 0038 // 0039 // we would be very happy if you could please also cite the following 0040 // reference papers on chemistry: 0041 // 0042 // J. Comput. Phys. 274 (2014) 841-882 0043 // Prog. Nucl. Sci. Tec. 2 (2011) 503-508 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 * Define a specific species shoot 0067 * Multiple shoots maybe be defined 0068 * TODO: make the shoots fully time dependent with 0069 * user access in the new framework 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 * Define a shoot type = 0096 * track (used by the Smoluchowski code) 0097 * or continuous medium (used by the gillespie code) 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 * Create a single molecule 0147 * @param moleculeName name of the molecule such as recorded in molecule table 0148 * @param position position where the molecule should pop up 0149 * @param time time at which the molecule should pop up 0150 */ 0151 void AddMolecule(const G4String& moleculeName, 0152 const G4ThreeVector& position, 0153 G4double time = 0); 0154 0155 /* 0156 * Create N molecules at a single point 0157 * @param n number of molecules to create 0158 * @param moleculeName name of the molecules such as recorded in molecule table 0159 * @param position position where the molecules should pop up 0160 * @param time time at which the molecules should pop up 0161 */ 0162 void AddNMolecules(std::size_t n, 0163 const G4String& moleculeName, 0164 const G4ThreeVector& position, 0165 G4double time = 0); 0166 0167 /* 0168 * Create N molecules in a box 0169 * @param n number of molecules to create 0170 * @param moleculeName name of the molecules such as recorded in molecule table 0171 * @param boxCenter center of the box 0172 * @param boxExtension size of the box 0173 * @param time time at which the molecules should pop up 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 * Create N molecules as component of the continuous medium in a box 0183 * @param n number of molecules to create 0184 * @param moleculeName name of the molecules such as recorded in molecule table 0185 * @param boxCenter center of the box 0186 * @param boxExtension size of the box 0187 * @param time time at which the molecules should pop up 0188 */ 0189 // void AddMoleculeInCMRepresentation(std::size_t n, 0190 // const G4String& moleculeName, 0191 // const G4ThreeVector& boxCenter, 0192 // const G4ThreeVector& boxExtension, 0193 // G4double time = 0); 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 /* MOLECULEGUN_HH_ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |