| [1230] | 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| [1337] | 3 | // * License and Disclaimer *
|
|---|
| [1230] | 4 | // * *
|
|---|
| [1337] | 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| [1230] | 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| [1337] | 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| [1230] | 17 | // * *
|
|---|
| [1337] | 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| [1230] | 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | // The code was written by :
|
|---|
| 27 | // ^Claudio Andenna claudio.andenna@iss.infn.it, claudio.andenna@ispesl.it
|
|---|
| 28 | // *Barbara Caccia barbara.caccia@iss.it
|
|---|
| 29 | // with the support of Pablo Cirrone (LNS, INFN Catania Italy)
|
|---|
| 30 | //
|
|---|
| 31 | // ^ISPESL and INFN Roma, gruppo collegato Sanità , Italy
|
|---|
| 32 | // *Istituto Superiore di Sanità and INFN Roma, gruppo collegato Sanità , Italy
|
|---|
| 33 | // Viale Regina Elena 299, 00161 Roma (Italy)
|
|---|
| 34 | // tel (39) 06 49902246
|
|---|
| 35 | // fax (39) 06 49387075
|
|---|
| 36 | //
|
|---|
| 37 | // more information:
|
|---|
| 38 | // http://g4advancedexamples.lngs.infn.it/Examples/medical-linac
|
|---|
| 39 | //
|
|---|
| 40 | //*******************************************************//
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | #ifndef CML2PrimaryGenerationActionH
|
|---|
| 44 | #define CML2PrimaryGenerationActionH
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 | #include "G4VUserPrimaryGeneratorAction.hh"
|
|---|
| 48 | #include "G4ParticleTable.hh"
|
|---|
| 49 | #include "G4ParticleGun.hh"
|
|---|
| 50 | #include "G4Event.hh"
|
|---|
| 51 | #include "G4Timer.hh"
|
|---|
| 52 | #include "Randomize.hh"
|
|---|
| 53 |
|
|---|
| 54 | #include "G4ParticleDefinition.hh"
|
|---|
| 55 | #include "ML2SinputData.hh"
|
|---|
| 56 | #include "ML2SDWithParticle.hh"
|
|---|
| 57 | #include "ML2SDWithVoxels.hh"
|
|---|
| 58 |
|
|---|
| 59 | class G4ParticleGun;
|
|---|
| 60 | class G4ParticleDefinition;
|
|---|
| 61 | class CML2PrimaryGenerationActionMessenger;
|
|---|
| 62 |
|
|---|
| 63 | class CML2PrimaryGenerationAction : public G4VUserPrimaryGeneratorAction
|
|---|
| 64 | {
|
|---|
| 65 | public:
|
|---|
| 66 | CML2PrimaryGenerationAction(SPrimaryParticle *primaryParticleData);
|
|---|
| 67 | ~CML2PrimaryGenerationAction(void);
|
|---|
| 68 | void design();
|
|---|
| 69 | void GeneratePrimaries(G4Event *anEvent);
|
|---|
| 70 | inline void setNIdenticalParticles(G4int val){this->nIdenticalParticles=val;};
|
|---|
| 71 | inline void setNLoopsPhSpParticles(G4int val){this->nLoopsPhSpParticles=val;};
|
|---|
| 72 | inline void setNMaxParticlesInRamPhaseSpace(G4int val){this->nMaxParticlesInRamPhaseSpace=val;};
|
|---|
| 73 |
|
|---|
| 74 | inline void setGunMeanEnergy(G4double val){this->GunMeanEnegy=val;};
|
|---|
| 75 | inline void setGunStdEnergy(G4double val){this->GunStdEnegy=val;};
|
|---|
| 76 | inline void setGunRadious(G4double val){this->GunRadious=val;};
|
|---|
| 77 | inline void setCalculatedPhaseSpaceFileIN(G4String val){this->calculatedPhaseSpaceFileIN=val;};
|
|---|
| 78 | inline void setSourceTypeName(G4String val)
|
|---|
| 79 | {
|
|---|
| 80 | this->sourceTypeName=val;
|
|---|
| 81 | if (this->sourceTypeName=="randomTarget")
|
|---|
| 82 | {
|
|---|
| 83 | this->idParticleSource=id_randomTarget;
|
|---|
| 84 | }
|
|---|
| 85 | else if (this->sourceTypeName=="phaseSpace")
|
|---|
| 86 | {
|
|---|
| 87 | this->idParticleSource=id_phaseSpace;
|
|---|
| 88 | }
|
|---|
| 89 | };
|
|---|
| 90 |
|
|---|
| 91 | private:
|
|---|
| 92 | void setGunRandom();
|
|---|
| 93 | void setGunCalculatedPhaseSpace();
|
|---|
| 94 | void GenerateFromRandom();
|
|---|
| 95 | void GenerateFromCalculatedPhaseSpace();
|
|---|
| 96 | void fillParticlesContainer();
|
|---|
| 97 | bool itIsTheSameParticle(Sparticle *p1, Sparticle *p2);
|
|---|
| 98 |
|
|---|
| 99 | G4int nBeam, nIdenticalParticles, nLoopsPhSpParticles, idGunType, nMaxParticlesInRamPhaseSpace, idParticleSource;
|
|---|
| 100 | G4double GunMeanEnegy, GunStdEnegy, GunRadious;
|
|---|
| 101 | G4String calculatedPhaseSpaceFileIN;
|
|---|
| 102 |
|
|---|
| 103 | CML2PrimaryGenerationActionMessenger *PrimaryGenerationActionMessenger;
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 | G4ThreeVector dir, pos;
|
|---|
| 107 | G4double ek;
|
|---|
| 108 |
|
|---|
| 109 | G4Timer myTime;
|
|---|
| 110 | G4double sinTheta, cosTheta, phi;
|
|---|
| 111 | G4double ro, alfa;
|
|---|
| 112 | G4ParticleGun *particleGun;
|
|---|
| 113 | G4ParticleDefinition *gamma;
|
|---|
| 114 | G4ParticleDefinition *electron;
|
|---|
| 115 | G4ParticleDefinition *positron;
|
|---|
| 116 | G4int nEventsPerRun;
|
|---|
| 117 | SPrimaryParticle *primaryParticleData;
|
|---|
| 118 | Sparticle *particles, *particle;
|
|---|
| 119 | int nParticle, nPhSpParticles, nRandomParticles, idCurrentParticleSource;
|
|---|
| 120 | Sparticle *firstFileParticle, *lastLoadedParticle;
|
|---|
| 121 | G4String sourceTypeName;
|
|---|
| 122 | };
|
|---|
| 123 |
|
|---|
| 124 | #endif
|
|---|