[1199] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 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. * |
---|
| 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 * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 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. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
| 27 | // $Id: G4FinalStateTest.cc,v 1.3 2007/10/12 19:57:17 pia Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
| 29 | // |
---|
| 30 | /// |
---|
| 31 | // ------------------------------------------------------------------- |
---|
| 32 | // Author: Maria Grazia Pia |
---|
| 33 | // |
---|
| 34 | // Creation date: 6 August 2001 |
---|
| 35 | // |
---|
| 36 | // Modifications: |
---|
| 37 | // |
---|
| 38 | // ------------------------------------------------------------------- |
---|
| 39 | |
---|
| 40 | #include "globals.hh" |
---|
| 41 | #include "G4ios.hh" |
---|
| 42 | #include <fstream> |
---|
| 43 | #include <iomanip> |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | #include "G4ParticleDefinition.hh" |
---|
| 47 | #include "G4ParticleTypes.hh" |
---|
| 48 | #include "G4ParticleTable.hh" |
---|
| 49 | #include "G4ParticleMomentum.hh" |
---|
| 50 | #include "G4DynamicParticle.hh" |
---|
| 51 | #include "G4ThreeVector.hh" |
---|
| 52 | #include "G4Track.hh" |
---|
| 53 | #include "G4SystemOfUnits.hh" |
---|
| 54 | |
---|
| 55 | #include "G4Material.hh" |
---|
| 56 | #include "G4ProcessManager.hh" |
---|
| 57 | #include "G4VParticleChange.hh" |
---|
| 58 | #include "G4ParticleChange.hh" |
---|
| 59 | #include "G4PVPlacement.hh" |
---|
| 60 | #include "G4Step.hh" |
---|
| 61 | #include "G4GRSVolume.hh" |
---|
| 62 | #include "G4Box.hh" |
---|
| 63 | #include "G4PVPlacement.hh" |
---|
| 64 | |
---|
| 65 | #include "G4FinalStateProduct.hh" |
---|
| 66 | #include "G4DummyFinalState.hh" |
---|
| 67 | #include "G4FinalStateElasticScreenedRutherford.hh" |
---|
| 68 | |
---|
| 69 | int main() |
---|
| 70 | { |
---|
| 71 | // G4cout.setf( ios::scientific, ios::floatfield ); |
---|
| 72 | |
---|
| 73 | // G4DummyFinalState* finalState = new G4DummyFinalState; |
---|
| 74 | G4FinalStateElasticScreenedRutherford* finalState = new G4FinalStateElasticScreenedRutherford; |
---|
| 75 | |
---|
| 76 | // Create particle track |
---|
| 77 | |
---|
| 78 | // Particle definition |
---|
| 79 | G4ParticleDefinition* electron = G4Electron::ElectronDefinition(); |
---|
| 80 | |
---|
| 81 | // Create a DynamicParticle |
---|
| 82 | G4double initX = 0.; |
---|
| 83 | G4double initY = 0.; |
---|
| 84 | G4double initZ = 1.; |
---|
| 85 | G4ParticleMomentum direction(initX,initY,initZ); |
---|
| 86 | |
---|
| 87 | G4cout << "Enter energy " << G4endl; |
---|
| 88 | G4double energy; |
---|
| 89 | G4cin >> energy; |
---|
| 90 | |
---|
| 91 | energy = energy * keV; |
---|
| 92 | |
---|
| 93 | G4DynamicParticle dynamicParticle(electron,direction,energy); |
---|
| 94 | |
---|
| 95 | // dynamicParticle.DumpInfo(0); |
---|
| 96 | |
---|
| 97 | // Materials |
---|
| 98 | G4Element* H = new G4Element ("Hydrogen", "H", 1. , 1.01*g/mole); |
---|
| 99 | G4Element* O = new G4Element ("Oxygen" , "O", 8. , 16.00*g/mole); |
---|
| 100 | G4Material* water = new G4Material ("Water" , 1.*g/cm3, 2); |
---|
| 101 | water->AddElement(H,2); |
---|
| 102 | water->AddElement(O,1); |
---|
| 103 | |
---|
| 104 | // Dump the material table |
---|
| 105 | const G4MaterialTable* materialTable = G4Material::GetMaterialTable(); |
---|
| 106 | G4int nMaterials = G4Material::GetNumberOfMaterials(); |
---|
| 107 | G4cout << "Available materials are: " << G4endl; |
---|
| 108 | for (G4int mat = 0; mat < nMaterials; mat++) |
---|
| 109 | { |
---|
| 110 | G4cout << mat << ") " |
---|
| 111 | << (*materialTable)[mat]->GetName() |
---|
| 112 | << G4endl; |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | G4double dimX = 1 * mm; |
---|
| 116 | G4double dimY = 1 * mm; |
---|
| 117 | G4double dimZ = 1 * mm; |
---|
| 118 | |
---|
| 119 | // Geometry |
---|
| 120 | |
---|
| 121 | G4Box* theFrame = new G4Box ("Frame",dimX, dimY, dimZ); |
---|
| 122 | G4LogicalVolume* logicalFrame = new G4LogicalVolume(theFrame, |
---|
| 123 | water, |
---|
| 124 | "LFrame", 0, 0, 0); |
---|
| 125 | logicalFrame->SetMaterial(water); |
---|
| 126 | G4PVPlacement* physicalFrame = new G4PVPlacement(0,G4ThreeVector(), |
---|
| 127 | "PFrame",logicalFrame,0,false,0); |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | // Track |
---|
| 131 | G4ThreeVector position(0.,0.,0.); |
---|
| 132 | G4double time = 0. ; |
---|
| 133 | |
---|
| 134 | G4Track* track = new G4Track(&dynamicParticle,time,position); |
---|
| 135 | // Do I really need this? |
---|
| 136 | G4GRSVolume* touche = new G4GRSVolume(physicalFrame, 0, position); |
---|
| 137 | // track->SetTouchable(touche); |
---|
| 138 | |
---|
| 139 | G4Step* step = new G4Step(); |
---|
| 140 | step->SetTrack(track); |
---|
| 141 | |
---|
| 142 | G4StepPoint* point = new G4StepPoint(); |
---|
| 143 | point->SetPosition(position); |
---|
| 144 | point->SetMaterial(water); |
---|
| 145 | G4double safety = 10000.*cm; |
---|
| 146 | point->SetSafety(safety); |
---|
| 147 | step->SetPreStepPoint(point); |
---|
| 148 | |
---|
| 149 | G4StepPoint* newPoint = new G4StepPoint(); |
---|
| 150 | G4ThreeVector newPosition(0.,0.,0.05*mm); |
---|
| 151 | newPoint->SetPosition(newPosition); |
---|
| 152 | newPoint->SetMaterial(water); |
---|
| 153 | step->SetPostStepPoint(newPoint); |
---|
| 154 | |
---|
| 155 | step->SetStepLength(1*micrometer); |
---|
| 156 | |
---|
| 157 | track->SetStep(step); |
---|
| 158 | |
---|
| 159 | |
---|
| 160 | // Generate final state |
---|
| 161 | const G4FinalStateProduct product = finalState->GenerateFinalState(*track,*step); |
---|
| 162 | |
---|
| 163 | G4double energyDeposit = product.GetEnergyDeposit(); |
---|
| 164 | G4int nSecondaries = product.NumberOfSecondaries(); |
---|
| 165 | |
---|
| 166 | G4cout << energyDeposit/keV <<" keV deposited" << G4endl; |
---|
| 167 | G4cout << nSecondaries <<" secondaries generated" << G4endl; |
---|
| 168 | |
---|
| 169 | std::vector<G4DynamicParticle*> secondaries = product.GetSecondaries(); |
---|
| 170 | |
---|
| 171 | for (G4int i = 0; i < nSecondaries; i++) |
---|
| 172 | { |
---|
| 173 | G4DynamicParticle* finalParticle = secondaries[i]; |
---|
| 174 | |
---|
| 175 | G4double e = finalParticle->GetTotalEnergy(); |
---|
| 176 | G4double eKin = finalParticle->GetKineticEnergy(); |
---|
| 177 | G4double px = (finalParticle->GetMomentum()).x(); |
---|
| 178 | G4double py = (finalParticle->GetMomentum()).y(); |
---|
| 179 | G4double pz = (finalParticle->GetMomentum()).z(); |
---|
| 180 | G4String particleName = finalParticle->GetDefinition()->GetParticleName(); |
---|
| 181 | G4cout << "==== Final " |
---|
| 182 | << particleName << " " |
---|
| 183 | << "energy: " << e/keV << " keV, " |
---|
| 184 | << "eKin: " << eKin/keV << " keV, " |
---|
| 185 | << "(px,py,pz): (" |
---|
| 186 | << px/keV << "," |
---|
| 187 | << py/keV << "," |
---|
| 188 | << pz/keV << ") keV " |
---|
| 189 | << G4endl; |
---|
| 190 | } |
---|
| 191 | G4double eModified = product.GetModifiedEnergy(); |
---|
| 192 | G4ThreeVector vec = product.GetModifiedDirection(); |
---|
| 193 | |
---|
| 194 | G4cout << "Primary particle modified energy = " |
---|
| 195 | << eModified / keV << " keV, direction (px,py,pz) = (" |
---|
| 196 | << vec.x() << "," |
---|
| 197 | << vec.y() << "," |
---|
| 198 | << vec.z() << ") " |
---|
| 199 | << G4endl; |
---|
| 200 | |
---|
| 201 | |
---|
| 202 | delete finalState; |
---|
| 203 | |
---|
| 204 | G4cout << "END OF THE MAIN PROGRAM" << G4endl; |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | |
---|
| 208 | |
---|
| 209 | |
---|
| 210 | |
---|
| 211 | |
---|
| 212 | |
---|
| 213 | |
---|