| 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: G4hTestLossTableProduction.cc,v 1.7 2006/06/29 19:44:44 gunter Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $
|
|---|
| 29 | //
|
|---|
| 30 | // -------------------------------------------------------------------
|
|---|
| 31 | // GEANT 4 class file --- Copyright CERN 1998
|
|---|
| 32 | // CERN Geneva Switzerland
|
|---|
| 33 | //
|
|---|
| 34 | //
|
|---|
| 35 | // File name: G4hLETestLossTable.cc
|
|---|
| 36 | //
|
|---|
| 37 | // Author: Stephane Chauvie
|
|---|
| 38 | //
|
|---|
| 39 | // Creation date: 22nd April 2001
|
|---|
| 40 | //
|
|---|
| 41 | // This test perform check on creation of loss table
|
|---|
| 42 | // Devoted to antiproton/proton differences
|
|---|
| 43 | //
|
|---|
| 44 | // Modifications:
|
|---|
| 45 | //
|
|---|
| 46 | // -------------------------------------------------------------------
|
|---|
| 47 |
|
|---|
| 48 | #include "globals.hh"
|
|---|
| 49 | #include "G4ios.hh"
|
|---|
| 50 | #include <fstream>
|
|---|
| 51 | #include <iomanip>
|
|---|
| 52 |
|
|---|
| 53 | #include "G4Material.hh"
|
|---|
| 54 | #include "G4ProcessManager.hh"
|
|---|
| 55 | #include "G4hLowEnergyIonisation.hh"
|
|---|
| 56 | #include "G4VParticleChange.hh"
|
|---|
| 57 | #include "G4ParticleChange.hh"
|
|---|
| 58 | #include "G4DynamicParticle.hh"
|
|---|
| 59 |
|
|---|
| 60 | #include "G4Electron.hh"
|
|---|
| 61 | #include "G4Proton.hh"
|
|---|
| 62 | #include "G4AntiProton.hh"
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 | main()
|
|---|
| 66 | {
|
|---|
| 67 |
|
|---|
| 68 | // Setup
|
|---|
| 69 |
|
|---|
| 70 | G4int particleID = 1;
|
|---|
| 71 | G4cout <<"Which particle?"<<G4endl<<setw(30)<<"[1] Proton, [2] AntiProton,"<<G4endl;
|
|---|
| 72 | cin>>particleID;
|
|---|
| 73 |
|
|---|
| 74 | G4cout.setf( ios::scientific, ios::floatfield );
|
|---|
| 75 | // -------------------------------------------------------------------
|
|---|
| 76 | ofstream out("g4hletestlosstable.dat");
|
|---|
| 77 | ofstream wout("wg4hletestlosstable.dat");
|
|---|
| 78 | ofstream bout("bg4hletestlosstable.dat");
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 | //--------- Materials definition ---------
|
|---|
| 82 |
|
|---|
| 83 | G4Material* Be = new G4Material("Beryllium", 4., 9.01*g/mole, 1.848*g/cm3);
|
|---|
| 84 | G4Material* Graphite = new G4Material("Graphite",6., 12.00*g/mole, 2.265*g/cm3 );
|
|---|
| 85 | G4Material* Al = new G4Material("Aluminum", 13., 26.98*g/mole, 2.7 *g/cm3);
|
|---|
| 86 | G4Material* Si = new G4Material("Silicon", 14., 28.055*g/mole, 2.33*g/cm3);
|
|---|
| 87 | G4Material* LAr = new G4Material("LArgon", 18., 39.95*g/mole, 1.393*g/cm3);
|
|---|
| 88 | G4Material* Fe = new G4Material("Iron", 26., 55.85*g/mole, 7.87*g/cm3);
|
|---|
| 89 | G4Material* Cu = new G4Material("Copper", 29., 63.55*g/mole, 8.96*g/cm3);
|
|---|
| 90 | G4Material* W = new G4Material("Tungsten", 74., 183.85*g/mole, 19.30*g/cm3);
|
|---|
| 91 | G4Material* Pb = new G4Material("Lead", 82., 207.19*g/mole, 11.35*g/cm3);
|
|---|
| 92 | G4Material* U = new G4Material("Uranium", 92., 238.03*g/mole, 18.95*g/cm3);
|
|---|
| 93 |
|
|---|
| 94 | G4Element* H = new G4Element ("Hydrogen", "H", 1. , 1.01*g/mole);
|
|---|
| 95 | G4Element* O = new G4Element ("Oxygen" , "O", 8. , 16.00*g/mole);
|
|---|
| 96 | G4Element* C = new G4Element ("Carbon" , "C", 6. , 12.00*g/mole);
|
|---|
| 97 | G4Element* Cs = new G4Element ("Cesium" , "Cs", 55. , 132.905*g/mole);
|
|---|
| 98 | G4Element* I = new G4Element ("Iodide" , "I", 53. , 126.9044*g/mole);
|
|---|
| 99 |
|
|---|
| 100 | G4Material* maO = new G4Material("Oxygen", 8., 16.00*g/mole, 1.1*g/cm3);
|
|---|
| 101 |
|
|---|
| 102 | G4Material* water = new G4Material ("Water" , 1.*g/cm3, 2);
|
|---|
| 103 | water->AddElement(H,2);
|
|---|
| 104 | water->AddElement(O,1);
|
|---|
| 105 |
|
|---|
| 106 | G4Material* ethane = new G4Material ("Ethane" , 0.4241*g/cm3, 2);
|
|---|
| 107 | ethane->AddElement(H,6);
|
|---|
| 108 | ethane->AddElement(C,2);
|
|---|
| 109 |
|
|---|
| 110 | G4Material* csi = new G4Material ("CsI" , 4.53*g/cm3, 2);
|
|---|
| 111 | csi->AddElement(Cs,1);
|
|---|
| 112 | csi->AddElement(I,1);
|
|---|
| 113 |
|
|---|
| 114 | static const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
|
|---|
| 115 |
|
|---|
| 116 | //--------- Particle definition ---------
|
|---|
| 117 | G4Electron* theElectron = G4Electron::Electron();
|
|---|
| 118 |
|
|---|
| 119 | G4ParticleDefinition* electron = G4Electron::ElectronDefinition();
|
|---|
| 120 | G4ParticleDefinition* proton = G4Proton::ProtonDefinition();
|
|---|
| 121 | G4ParticleDefinition* antiproton = G4AntiProton::AntiProtonDefinition();
|
|---|
| 122 |
|
|---|
| 123 | electron->SetCuts(1e-6*mm);
|
|---|
| 124 | proton->SetCuts(1e-6*mm);
|
|---|
| 125 |
|
|---|
| 126 | //--------- Processes definition ---------
|
|---|
| 127 |
|
|---|
| 128 | G4hLowEnergyIonisation* hIonisationProcess = new G4hLowEnergyIonisation("ionLowEIoni");
|
|---|
| 129 | //hIonisationProcess->SetNuclearStoppingOn();
|
|---|
| 130 | //hIonisationProcess->SetStoppingPowerTableName("ICRU_R49p");
|
|---|
| 131 |
|
|---|
| 132 | // Ionisation loss with/without Barkas effect
|
|---|
| 133 | hIonisationProcess->SetBarkasOn();
|
|---|
| 134 | //hIonisationProcess->SetBarkasOff();
|
|---|
| 135 |
|
|---|
| 136 | G4ProcessManager* theProtonProcessManager = new G4ProcessManager(proton);
|
|---|
| 137 | proton->SetProcessManager(theProtonProcessManager);
|
|---|
| 138 | theProtonProcessManager->AddProcess(hIonisationProcess);
|
|---|
| 139 |
|
|---|
| 140 | G4ProcessManager* theAntiProtonProcessManager = new G4ProcessManager(antiproton);
|
|---|
| 141 | antiproton->SetProcessManager(theAntiProtonProcessManager);
|
|---|
| 142 | theAntiProtonProcessManager->AddProcess(hIonisationProcess);
|
|---|
| 143 |
|
|---|
| 144 | // -------- create 1 Dynamic Particle ----
|
|---|
| 145 |
|
|---|
| 146 | G4double partEnergy = 200*MeV;
|
|---|
| 147 |
|
|---|
| 148 | G4ParticleMomentum partDirection(1,0,0);
|
|---|
| 149 |
|
|---|
| 150 | G4DynamicParticle p(proton,partDirection,partEnergy);
|
|---|
| 151 | G4DynamicParticle pbar(antiproton,partDirection,partEnergy);
|
|---|
| 152 |
|
|---|
| 153 | // --------- check applicability
|
|---|
| 154 |
|
|---|
| 155 | G4ParticleDefinition* ProtonDefinition = p.GetDefinition();
|
|---|
| 156 | G4ParticleDefinition* AntiProtonDefinition = pbar.GetDefinition();
|
|---|
| 157 | if(! (hIonisationProcess->IsApplicable(*ProtonDefinition)
|
|---|
| 158 | || hIonisationProcess->IsApplicable(*AntiProtonDefinition) ) )
|
|---|
| 159 | {
|
|---|
| 160 | G4Exception("FAIL: *** Not Applicable ***\n");
|
|---|
| 161 | }
|
|---|
| 162 |
|
|---|
| 163 | // Initialize the physics tables for ALL processes
|
|---|
| 164 |
|
|---|
| 165 | hIonisationProcess->BuildPhysicsTable(*ProtonDefinition);
|
|---|
| 166 |
|
|---|
| 167 | hIonisationProcess->BuildPhysicsTable(*AntiProtonDefinition);
|
|---|
| 168 |
|
|---|
| 169 | //------------------------------- Loss Table Test------------------------
|
|---|
| 170 |
|
|---|
| 171 | G4Material* apttoMaterial ;
|
|---|
| 172 | G4String MaterialName ;
|
|---|
| 173 |
|
|---|
| 174 | G4double minArg = 1*eV, maxArg = 200*MeV, argStp;
|
|---|
| 175 | const G4int pntNum = 1000;
|
|---|
| 176 | G4double Tkin[pntNum+1];
|
|---|
| 177 | argStp = (std::log10(maxArg)-std::log10(minArg))/pntNum;
|
|---|
| 178 | for(G4int d = 0; d < pntNum+1; d++){
|
|---|
| 179 | Tkin[d] = std::pow(10,(std::log10(minArg) + d*argStp));
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | //____________________LOSS TABLE TEST________________________________________________
|
|---|
| 183 |
|
|---|
| 184 | for ( G4int J = 0 ; J < G4Material::GetNumberOfMaterials() ; J++ ){
|
|---|
| 185 |
|
|---|
| 186 | apttoMaterial = (*theMaterialTable)[ J ] ;
|
|---|
| 187 | MaterialName = apttoMaterial->GetName() ;
|
|---|
| 188 |
|
|---|
| 189 | //G4cout<<"Material: "<<MaterialName<<G4endl;
|
|---|
| 190 |
|
|---|
| 191 | for (G4int ipnt=0 ; ipnt<pntNum; ipnt++){
|
|---|
| 192 |
|
|---|
| 193 | p.SetKineticEnergy(Tkin[ipnt]);
|
|---|
| 194 | pbar.SetKineticEnergy(Tkin[ipnt]);
|
|---|
| 195 |
|
|---|
| 196 | G4double dedxnow = 0 , cf = 0 , dedx =0 ;
|
|---|
| 197 | G4double* deltaCut = theElectron->GetCutsInEnergy();
|
|---|
| 198 |
|
|---|
| 199 | if( particleID == 1){
|
|---|
| 200 | dedxnow = hIonisationProcess->
|
|---|
| 201 | ComputeDEDX(p.GetDefinition(),
|
|---|
| 202 | apttoMaterial,
|
|---|
| 203 | p.GetKineticEnergy()) ;
|
|---|
| 204 | // if(Tkin[ipnt]<=2*MeV) dedxnow+= hIonisationProcess->
|
|---|
| 205 | // G4hLowEnergyIonisation::DeltaRaysEnergy( apttoMaterial,
|
|---|
| 206 | // p.GetKineticEnergy(),
|
|---|
| 207 | // deltaCut[J]);
|
|---|
| 208 | }
|
|---|
| 209 | if( particleID == 2){
|
|---|
| 210 | dedxnow = hIonisationProcess->
|
|---|
| 211 | ComputeDEDX(pbar.GetDefinition(),
|
|---|
| 212 | apttoMaterial,
|
|---|
| 213 | pbar.GetKineticEnergy()) ;
|
|---|
| 214 | // if(Tkin[ipnt]<=2*MeV) dedxnow+= hIonisationProcess->
|
|---|
| 215 | // DeltaRaysEnergy( apttoMaterial,
|
|---|
| 216 | // pbar.GetKineticEnergy(),
|
|---|
| 217 | // deltaCut[J]);
|
|---|
| 218 | }
|
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 | //-----------data-------------------------------------
|
|---|
| 223 |
|
|---|
| 224 | if(MaterialName=="Silicon") out<<Tkin[ipnt]/MeV<<" "<<dedxnow/MeV/mm<<G4endl;
|
|---|
| 225 | if(MaterialName=="Water") wout<<Tkin[ipnt]/MeV<<" "<<dedxnow/MeV/mm<<G4endl;
|
|---|
| 226 | if(MaterialName=="Beryllium") bout<<Tkin[ipnt]/MeV<<" "<<dedxnow/MeV/mm<<G4endl;
|
|---|
| 227 |
|
|---|
| 228 | }
|
|---|
| 229 | }// for loop on materials
|
|---|
| 230 |
|
|---|
| 231 |
|
|---|
| 232 |
|
|---|
| 233 |
|
|---|
| 234 | // delete materials and elements
|
|---|
| 235 | delete Be;
|
|---|
| 236 | delete Graphite;
|
|---|
| 237 | delete Al;
|
|---|
| 238 | delete Si;
|
|---|
| 239 | delete LAr;
|
|---|
| 240 | delete Fe;
|
|---|
| 241 | delete Cu;
|
|---|
| 242 | delete W;
|
|---|
| 243 | delete Pb;
|
|---|
| 244 | delete U;
|
|---|
| 245 | delete H;
|
|---|
| 246 | delete maO;
|
|---|
| 247 | delete C;
|
|---|
| 248 | delete Cs;
|
|---|
| 249 | delete I;
|
|---|
| 250 | delete O;
|
|---|
| 251 | delete water;
|
|---|
| 252 | delete ethane;
|
|---|
| 253 | delete csi;
|
|---|
| 254 |
|
|---|
| 255 | cout<<"END OF THE MAIN PROGRAM"<<G4endl;
|
|---|
| 256 | }
|
|---|