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.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/hadronic/FissionFragment/src/FFPrimaryGeneratorAction.cc (Version 11.3.0) and /examples/extended/hadronic/FissionFragment/src/FFPrimaryGeneratorAction.cc (Version 10.1.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // -------------------------------------------     26 // -------------------------------------------------------------
 27 //  =============== Begin Documentation Commen     27 //  =============== Begin Documentation Comments ===============
 28 //!                                                28 //!
 29 //! \file       FFPrimaryGeneratorAction.cc        29 //! \file       FFPrimaryGeneratorAction.cc
 30 //! \author     B. Wendt (brycen.linn.wendt@ce     30 //! \author     B. Wendt (brycen.linn.wendt@cern.ch)
 31 //! \date       June 06, 2014                      31 //! \date       June 06, 2014
 32 //!                                                32 //!
 33 //! \brief      Implementation of the FFPrimar     33 //! \brief      Implementation of the FFPrimaryGeneratorAction class
 34 //!                                                34 //!
 35 //! \details    Generates 4.5 MeV neutrons fro     35 //! \details    Generates 4.5 MeV neutrons from the solid volume defined in
 36 //!             FFDetectorConstruction as "Net     36 //!             FFDetectorConstruction as "NeturonSource" and shoots them off
 37 //!             in a isotropically sampled dir     37 //!             in a isotropically sampled direction
 38 //!                                                38 //!
 39 //  ================ End Documentation Comment     39 //  ================ End Documentation Comments ================
 40 //                                                 40 //
 41 //  Modified:                                      41 //  Modified:
 42 //                                                 42 //
 43 //  23-06-14                                       43 //  23-06-14                                              BWendt
 44 //  Implemented "GetNeutronSourceCenter()" and     44 //  Implemented "GetNeutronSourceCenter()" and added code to correctly sample
 45 //  the neutron starting location                  45 //  the neutron starting location
 46 //                                                 46 //
 47 // -------------------------------------------     47 // -------------------------------------------------------------
 48                                                    48 
 49 #include "FFPrimaryGeneratorAction.hh"         <<  49 #include "globals.hh"
 50                                                    50 
 51 #include "G4Event.hh"                              51 #include "G4Event.hh"
 52 #include "G4LogicalVolume.hh"                      52 #include "G4LogicalVolume.hh"
 53 #include "G4LogicalVolumeStore.hh"                 53 #include "G4LogicalVolumeStore.hh"
 54 #include "G4Neutron.hh"                            54 #include "G4Neutron.hh"
 55 #include "G4ParticleGun.hh"                        55 #include "G4ParticleGun.hh"
 56 #include "G4PhysicalVolumeStore.hh"                56 #include "G4PhysicalVolumeStore.hh"
 57 #include "G4SystemOfUnits.hh"                      57 #include "G4SystemOfUnits.hh"
 58 #include "G4Tubs.hh"                               58 #include "G4Tubs.hh"
 59 #include "G4VPhysicalVolume.hh"                    59 #include "G4VPhysicalVolume.hh"
 60 #include "Randomize.hh"                            60 #include "Randomize.hh"
 61 #include "globals.hh"                          <<  61 
                                                   >>  62 #include "FFPrimaryGeneratorAction.hh"
                                                   >>  63 
 62                                                    64 
 63 //....oooOO0OOooo........oooOO0OOooo........oo     65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 64 FFPrimaryGeneratorAction::FFPrimaryGeneratorAc <<  66 FFPrimaryGeneratorAction::
 65   : G4VUserPrimaryGeneratorAction(),           <<  67 FFPrimaryGeneratorAction()
                                                   >>  68 :   G4VUserPrimaryGeneratorAction(),
 66 #ifndef NDEBUG                                     69 #ifndef NDEBUG
 67     fEventNumber(0),                               70     fEventNumber(0),
 68 #endif  // NDEBUG                              <<  71 #endif // NDEBUG
 69     fH2OPhysical(NULL),                            72     fH2OPhysical(NULL),
 70     fNeutronPhysical(NULL),                        73     fNeutronPhysical(NULL),
 71     fNeutronSolid(NULL),                           74     fNeutronSolid(NULL),
 72     fParticleGun(new G4ParticleGun(1)),            75     fParticleGun(new G4ParticleGun(1)),
 73     fTankPhysical(NULL)                            76     fTankPhysical(NULL)
 74 {                                                  77 {
 75   fParticleGun->SetParticleDefinition(G4Neutro <<  78     fParticleGun->SetParticleDefinition(G4Neutron::Definition());
 76   fParticleGun->SetParticleEnergy(4.5 * MeV);  <<  79     fParticleGun->SetParticleEnergy(4.5 * MeV);
 77 }                                                  80 }
 78                                                    81 
 79 //....oooOO0OOooo........oooOO0OOooo........oo     82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 80 void FFPrimaryGeneratorAction::GeneratePrimari <<  83 void FFPrimaryGeneratorAction::
                                                   >>  84 GeneratePrimaries(G4Event* event)
 81 {                                                  85 {
 82 #ifndef NDEBUG                                     86 #ifndef NDEBUG
 83   G4cout << "Shooting event " << ++fEventNumbe <<  87     G4cout << "Shooting event " << ++fEventNumber << G4endl;
 84 #endif  // NDEBUG                              <<  88 #endif // NDEBUG
 85   const G4ThreeVector sourceCenter = GetNeutro <<  89     const G4ThreeVector sourceCenter = GetNeutronSourceCenter();
 86                                                <<  90     
 87   // Sample the neutron source location        <<  91     // Sample the neutron source location
 88   const G4double radius = fNeutronSolid->GetOu <<  92     const G4double radius = fNeutronSolid->GetOuterRadius();
 89   const G4double z = fNeutronSolid->GetZHalfLe <<  93     const G4double z = fNeutronSolid->GetZHalfLength() * 2;
 90   G4ThreeVector randomLocation;                <<  94     G4ThreeVector randomLocation;
 91   randomLocation.setRThetaPhi(radius * std::sq <<  95     randomLocation.setRThetaPhi(radius * std::sqrt(G4UniformRand()),
 92   randomLocation.setZ(z * (G4UniformRand() - 0 <<  96                                 G4UniformRand() * 180 * deg,
 93   G4ThreeVector location(randomLocation.x() +  <<  97                                 0);
 94                          randomLocation.y() +  <<  98     randomLocation.setZ(z * (G4UniformRand() - 0.5));
 95                          randomLocation.z() +  <<  99     G4ThreeVector location(randomLocation.x() + sourceCenter.x(),
                                                   >> 100                            randomLocation.y() + sourceCenter.y(),
                                                   >> 101                            randomLocation.z() + sourceCenter.z());
 96 #ifndef NDEBUG                                    102 #ifndef NDEBUG
 97   G4cout << "Emission Location: r: " << locati << 103     G4cout << "Emission Location: r: " << location << G4endl;
 98 #endif  // NDEBUG                              << 104 #endif // NDEBUG
 99                                                << 105     
100   // Sample the neutron emission direction     << 106     // Sample the neutron emission direction
101   G4ThreeVector direction;                     << 107     G4ThreeVector direction;
102   direction.setRThetaPhi(1.0, std::acos(G4Unif << 108     direction.setRThetaPhi(1.0,
103                          (G4UniformRand() * 2  << 109                            std::acos(G4UniformRand() * 2 - 1),
                                                   >> 110                            (G4UniformRand() * 2 - 1) * 180 * deg);
104 #ifndef NDEBUG                                    111 #ifndef NDEBUG
105   G4cout << "Emission Direction: r: " << direc << 112     G4cout << "Emission Direction: r: " << direction << G4endl;
106 #endif  // NDEBUG                              << 113 #endif // NDEBUG
107                                                << 114     
108   // Load the event                            << 115     // Load the event
109   fParticleGun->SetParticlePosition(location); << 116     fParticleGun->SetParticlePosition(location);
110   fParticleGun->SetParticleMomentumDirection(d << 117     fParticleGun->SetParticleMomentumDirection(direction);
111   fParticleGun->GeneratePrimaryVertex(event);  << 118     fParticleGun->GeneratePrimaryVertex(event);
112 }                                                 119 }
113                                                   120 
114 //....oooOO0OOooo........oooOO0OOooo........oo    121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
115 G4ThreeVector FFPrimaryGeneratorAction::GetNeu << 122 G4ThreeVector FFPrimaryGeneratorAction::
                                                   >> 123 GetNeutronSourceCenter(void)
116 {                                                 124 {
117   // Get the dimensions of the neutron source  << 125     // Get the dimensions of the neutron source
118   if (fNeutronSolid == NULL) {                 << 126     if(fNeutronSolid == NULL)
119     G4LogicalVolume* temp = G4LogicalVolumeSto << 127     {
120     if (temp != NULL) {                        << 128         G4LogicalVolume* temp
121       fNeutronSolid = dynamic_cast<G4Tubs*>(te << 129             = G4LogicalVolumeStore::GetInstance()->GetVolume("NeutronSource");
                                                   >> 130         if(temp != NULL)
                                                   >> 131         {
                                                   >> 132             fNeutronSolid = dynamic_cast< G4Tubs* >(temp->GetSolid());
                                                   >> 133         }
                                                   >> 134         
                                                   >> 135         if(fNeutronSolid == NULL)
                                                   >> 136         {
                                                   >> 137             G4Exception("FFPrimaryGeneratorAction::"
                                                   >> 138                             "GeneratePrimaries(G4Event*)",
                                                   >> 139                         "Neutron source solid volume not found",
                                                   >> 140                         EventMustBeAborted,
                                                   >> 141                         "This run will be aborted");
                                                   >> 142         }
122     }                                             143     }
123                                                << 144     
124     if (fNeutronSolid == NULL) {               << 145     // Get the position of the neutron source within the water
125       G4Exception(                             << 146     if(fNeutronPhysical == NULL)
126         "FFPrimaryGeneratorAction::"           << 147     {
127         "GeneratePrimaries(G4Event*)",         << 148         fNeutronPhysical = G4PhysicalVolumeStore::GetInstance()
128         "Neutron source solid volume not found << 149             ->GetVolume("NeutronSource");
129     }                                             150     }
130   }                                            << 151     
131                                                << 152     if(fNeutronPhysical == NULL)
132   // Get the position of the neutron source wi << 153     {
133   if (fNeutronPhysical == NULL) {              << 154         G4Exception("FFPrimaryGeneratorAction::GetNeutronSourceCenter(void)",
134     fNeutronPhysical = G4PhysicalVolumeStore:: << 155                     "Neutron source physical volume not found",
135   }                                            << 156                     EventMustBeAborted,
136                                                << 157                     "This run will be aborted");
137   if (fNeutronPhysical == NULL) {              << 
138     G4Exception("FFPrimaryGeneratorAction::Get << 
139                 "Neutron source physical volum << 
140                 "This run will be aborted");   << 
141   }                                            << 
142                                                << 
143   // Get the position of the water within the  << 
144   if (fH2OPhysical == NULL) {                  << 
145     fH2OPhysical = G4PhysicalVolumeStore::GetI << 
146                                                << 
147     if (fH2OPhysical == NULL) {                << 
148       G4Exception(                             << 
149         "FFPrimaryGeneratorAction::"           << 
150         "GetNeutronSourceCenter(void)",        << 
151         "Tank H2O physical volume not found",  << 
152     }                                             158     }
153   }                                            << 159     
154                                                << 160     // Get the position of the water within the tank
155   // Get the position of the tank within the w << 161     if(fH2OPhysical == NULL)
156   if (fTankPhysical == NULL) {                 << 162     {
157     fTankPhysical = G4PhysicalVolumeStore::Get << 163         fH2OPhysical = G4PhysicalVolumeStore::GetInstance()
158                                                << 164             ->GetVolume("Tank_H2O");
159     if (fTankPhysical == NULL) {               << 165     
160       G4Exception(                             << 166         if(fH2OPhysical == NULL)
161         "FFPrimaryGeneratorAction::"           << 167         {
162         "GetNeutronSourceCenter(void)",        << 168             G4Exception("FFPrimaryGeneratorAction::"
163         "Tank physical volume not found", Even << 169                             "GetNeutronSourceCenter(void)",
                                                   >> 170                         "Tank H2O physical volume not found",
                                                   >> 171                         EventMustBeAborted,
                                                   >> 172                         "This run will be aborted");
                                                   >> 173         }
164     }                                             174     }
165   }                                            << 175     
166                                                << 176     // Get the position of the tank within the world
167   return fNeutronPhysical->GetTranslation() +  << 177     if(fTankPhysical == NULL)
168          + fTankPhysical->GetTranslation();    << 178     {
                                                   >> 179         fTankPhysical = G4PhysicalVolumeStore::GetInstance()
                                                   >> 180             ->GetVolume("Tank_Wall");
                                                   >> 181     
                                                   >> 182         if(fTankPhysical == NULL)
                                                   >> 183         {
                                                   >> 184             G4Exception("FFPrimaryGeneratorAction::"
                                                   >> 185                             "GetNeutronSourceCenter(void)",
                                                   >> 186                         "Tank physical volume not found",
                                                   >> 187                         EventMustBeAborted,
                                                   >> 188                         "This run will be aborted");
                                                   >> 189         }
                                                   >> 190     }
                                                   >> 191     
                                                   >> 192     return fNeutronPhysical->GetTranslation()
                                                   >> 193                + fH2OPhysical->GetTranslation()
                                                   >> 194                + fTankPhysical->GetTranslation();
169 }                                                 195 }
170                                                   196 
171 //....oooOO0OOooo........oooOO0OOooo........oo    197 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
172 FFPrimaryGeneratorAction::~FFPrimaryGeneratorA << 198 FFPrimaryGeneratorAction::
                                                   >> 199 ~FFPrimaryGeneratorAction()
173 {                                                 200 {
174   delete fParticleGun;                         << 201     delete fParticleGun;
175 }                                                 202 }
                                                   >> 203 
                                                   >> 204 
176                                                   205