| 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: G4PenelopeIonisationTest.cc,v 1.4 2006/06/29 19:44:22 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: G4PenelopeIonisationTest.cc
|
|---|
| 36 | //
|
|---|
| 37 | // Author: Francesco Longo
|
|---|
| 38 | //
|
|---|
| 39 | // Creation date: 04 january 2001
|
|---|
| 40 | //
|
|---|
| 41 | // Modifications: Luciano Pandola (27 november 2002)
|
|---|
| 42 | // Adapted in order to test G4PenelopeIonisation
|
|---|
| 43 | // Minor modification in n-tuple filling
|
|---|
| 44 | // Updated analysis to AIDA 3.0
|
|---|
| 45 | //
|
|---|
| 46 | // -------------------------------------------------------------------
|
|---|
| 47 |
|
|---|
| 48 | #include "globals.hh"
|
|---|
| 49 | #include "G4ios.hh"
|
|---|
| 50 |
|
|---|
| 51 | #include "G4ParticleDefinition.hh"
|
|---|
| 52 | #include "G4ParticleTypes.hh"
|
|---|
| 53 | #include "G4ParticleTable.hh"
|
|---|
| 54 | #include "G4Material.hh"
|
|---|
| 55 | #include "G4MaterialTable.hh"
|
|---|
| 56 | #include "G4VContinuousDiscreteProcess.hh"
|
|---|
| 57 | #include "G4VProcess.hh"
|
|---|
| 58 | #include "G4ProcessManager.hh"
|
|---|
| 59 | #include "G4RunManager.hh"
|
|---|
| 60 |
|
|---|
| 61 | #include "G4PenelopeIonisation.hh"
|
|---|
| 62 | #include "G4LowEnergyIonisation.hh"
|
|---|
| 63 | #include "G4eIonisation.hh"
|
|---|
| 64 |
|
|---|
| 65 | #include "G4EnergyLossTables.hh"
|
|---|
| 66 | #include "G4VParticleChange.hh"
|
|---|
| 67 | #include "G4ParticleChange.hh"
|
|---|
| 68 | #include "G4DynamicParticle.hh"
|
|---|
| 69 | #include "G4ForceCondition.hh"
|
|---|
| 70 |
|
|---|
| 71 | #include "G4MultipleScattering.hh"
|
|---|
| 72 | #include "G4eplusAnnihilation.hh"
|
|---|
| 73 |
|
|---|
| 74 | //#include "G4ComptonScattering.hh"
|
|---|
| 75 | //#include "G4PhotoElectricEffect.hh"
|
|---|
| 76 |
|
|---|
| 77 | #include "G4Electron.hh"
|
|---|
| 78 | #include "G4Positron.hh"
|
|---|
| 79 | #include "G4Gamma.hh"
|
|---|
| 80 |
|
|---|
| 81 | #include "G4GRSVolume.hh"
|
|---|
| 82 | #include "G4Box.hh"
|
|---|
| 83 | #include "G4PVPlacement.hh"
|
|---|
| 84 | #include "G4Step.hh"
|
|---|
| 85 | #include "G4ProductionCutsTable.hh"
|
|---|
| 86 | #include "G4MaterialCutsCouple.hh"
|
|---|
| 87 |
|
|---|
| 88 | #include "G4UnitsTable.hh"
|
|---|
| 89 | #include "AIDA/IManagedObject.h"
|
|---|
| 90 |
|
|---|
| 91 | #include <memory>
|
|---|
| 92 | #include "AIDA/IAnalysisFactory.h"
|
|---|
| 93 | #include "AIDA/ITreeFactory.h"
|
|---|
| 94 | #include "AIDA/ITree.h"
|
|---|
| 95 | #include "AIDA/IHistogramFactory.h"
|
|---|
| 96 | #include "AIDA/IHistogram1D.h"
|
|---|
| 97 | #include "AIDA/IHistogram2D.h"
|
|---|
| 98 | #include "AIDA/IHistogram3D.h"
|
|---|
| 99 | #include "AIDA/ITupleFactory.h"
|
|---|
| 100 | #include "AIDA/ITuple.h"
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 | int main()
|
|---|
| 104 | {
|
|---|
| 105 |
|
|---|
| 106 | // Setup
|
|---|
| 107 |
|
|---|
| 108 | G4int nIterations = 100000;
|
|---|
| 109 | G4int materialId = 3;
|
|---|
| 110 | G4int test=0;
|
|---|
| 111 | G4int tPart=1;
|
|---|
| 112 | //G4cout.setf(G4std::ios::scientific,G4std::ios::floatfield );
|
|---|
| 113 |
|
|---|
| 114 | // -------------------------------------------------------------------
|
|---|
| 115 |
|
|---|
| 116 | // ---- HBOOK initialization
|
|---|
| 117 |
|
|---|
| 118 | std::auto_ptr< AIDA::IAnalysisFactory > af( AIDA_createAnalysisFactory() );
|
|---|
| 119 | std::auto_ptr< AIDA::ITreeFactory > tf (af->createTreeFactory());
|
|---|
| 120 | std::auto_ptr< AIDA::ITree > tree (tf->create("pen_ion_test.hbook","hbook",false,true));
|
|---|
| 121 | G4cout << "Tree store: " << tree->storeName() << G4endl;
|
|---|
| 122 | std::auto_ptr< AIDA::ITupleFactory > tpf (af->createTupleFactory(*tree));
|
|---|
| 123 | std::auto_ptr< AIDA::IHistogramFactory > hf (af->createHistogramFactory(*tree));
|
|---|
| 124 |
|
|---|
| 125 | // ---- primary ntuple ------
|
|---|
| 126 | AIDA::ITuple* ntuple1 = tpf->create("1","Primary Ntuple",
|
|---|
| 127 | "double eprimary,energyf,de,dedx,pxch,pych,pzch,pch,thetach,costhetach");
|
|---|
| 128 |
|
|---|
| 129 | // ---- secondary ntuple ------
|
|---|
| 130 | AIDA::ITuple* ntuple2 = tpf->create("2","Secondary Ntuple",
|
|---|
| 131 | "double eprimary,px_el,py_el,pz_el,p_el,e_el,theta_el,ekin_el,costheta_el");
|
|---|
| 132 |
|
|---|
| 133 | // ---- table ntuple ------
|
|---|
| 134 | AIDA::ITuple* ntuple3 = tpf->create("3","Mean Free Path Ntuple","double kinen,mfp");
|
|---|
| 135 | // ---- fluorescence ntuple -------
|
|---|
| 136 |
|
|---|
| 137 | //--------- Materials definition ---------
|
|---|
| 138 |
|
|---|
| 139 | G4Material* Si = new G4Material("Silicon", 14., 28.055*g/mole, 2.33*g/cm3);
|
|---|
| 140 | G4Material* Fe = new G4Material("Iron", 26., 55.85*g/mole, 7.87*g/cm3);
|
|---|
| 141 | G4Material* Cu = new G4Material("Copper", 29., 63.55*g/mole, 8.96*g/cm3);
|
|---|
| 142 | G4Material* W = new G4Material("Tungsten", 74., 183.85*g/mole, 19.30*g/cm3);
|
|---|
| 143 | G4Material* Pb = new G4Material("Lead", 82., 207.19*g/mole, 11.35*g/cm3);
|
|---|
| 144 | G4Material* U = new G4Material("Uranium", 92., 238.03*g/mole, 18.95*g/cm3);
|
|---|
| 145 | G4Material* Al = new G4Material("Aluminum",13.,26.98*g/mole,2.7*g/cm3);
|
|---|
| 146 | G4Material* Au = new G4Material("Gold" ,79.,196.97*g/mole,19.3*g/cm3);
|
|---|
| 147 |
|
|---|
| 148 | G4Element* H = new G4Element ("Hydrogen", "H", 1. , 1.01*g/mole);
|
|---|
| 149 | G4Element* O = new G4Element ("Oxygen" , "O", 8. , 16.00*g/mole);
|
|---|
| 150 | G4Element* C = new G4Element ("Carbon" , "C", 6. , 12.00*g/mole);
|
|---|
| 151 | G4Element* Cs = new G4Element ("Cesium" , "Cs", 55. , 132.905*g/mole);
|
|---|
| 152 | G4Element* I = new G4Element ("Iodine" , "I", 53. , 126.9044*g/mole);
|
|---|
| 153 |
|
|---|
| 154 | G4Material* maO = new G4Material("Oxygen", 8., 16.00*g/mole, 1.1*g/cm3);
|
|---|
| 155 |
|
|---|
| 156 | G4Material* water = new G4Material ("Water" , 1.*g/cm3, 2);
|
|---|
| 157 | water->AddElement(H,2);
|
|---|
| 158 | water->AddElement(O,1);
|
|---|
| 159 |
|
|---|
| 160 | G4Material* ethane = new G4Material ("Ethane" , 0.4241*g/cm3, 2);
|
|---|
| 161 | ethane->AddElement(H,6);
|
|---|
| 162 | ethane->AddElement(C,2);
|
|---|
| 163 |
|
|---|
| 164 | G4Material* csi = new G4Material ("CsI" , 4.53*g/cm3, 2);
|
|---|
| 165 | csi->AddElement(Cs,1);
|
|---|
| 166 | csi->AddElement(I,1);
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 | // Interactive set-up
|
|---|
| 170 | G4cout << "Electrons [1] or Positrons [2] ?" << G4endl;
|
|---|
| 171 | G4cin >> tPart;
|
|---|
| 172 | if ( !(tPart == 1 || tPart == 2)) G4Exception("Wrong input");
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 | G4cout << "Test AlongStepDoIt [1] or PostStepDoIt [2] ?" << G4endl;
|
|---|
| 176 | G4cin >> test;
|
|---|
| 177 | if ( !(test == 1 || test == 2)) G4Exception("Wrong input");
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 | G4cout << "How many interactions? " << G4endl;
|
|---|
| 182 | G4cin >> nIterations;
|
|---|
| 183 |
|
|---|
| 184 | if (nIterations <= 0) G4Exception("Wrong input");
|
|---|
| 185 |
|
|---|
| 186 | G4double initEnergy = 1*MeV;
|
|---|
| 187 | G4double initX = 0.;
|
|---|
| 188 | G4double initY = 0.;
|
|---|
| 189 | G4double initZ = 1.;
|
|---|
| 190 |
|
|---|
| 191 | G4cout << "Enter the initial particle energy E (MeV)" << G4endl;
|
|---|
| 192 | G4cin >> initEnergy ;
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 | initEnergy = initEnergy*MeV;
|
|---|
| 196 |
|
|---|
| 197 | if (initEnergy <= 0.) G4Exception("Wrong input");
|
|---|
| 198 |
|
|---|
| 199 | static const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
|
|---|
| 200 |
|
|---|
| 201 | G4int nMaterials = G4Material::GetNumberOfMaterials();
|
|---|
| 202 |
|
|---|
| 203 | G4cout << "Available materials are: " << G4endl;
|
|---|
| 204 | for (G4int mat = 0; mat < nMaterials; mat++)
|
|---|
| 205 | {
|
|---|
| 206 | G4cout << mat << ") "
|
|---|
| 207 | << (*theMaterialTable)[mat]->GetName()
|
|---|
| 208 | << G4endl;
|
|---|
| 209 | }
|
|---|
| 210 |
|
|---|
| 211 | G4cout << "Which material? " << G4endl;
|
|---|
| 212 | G4cin >> materialId;
|
|---|
| 213 |
|
|---|
| 214 | G4Material* material = (*theMaterialTable)[materialId] ;
|
|---|
| 215 |
|
|---|
| 216 | G4cout << "The selected material is: "
|
|---|
| 217 | << material->GetName()
|
|---|
| 218 | << G4endl;
|
|---|
| 219 |
|
|---|
| 220 | G4double dimX = 1*mm;
|
|---|
| 221 | G4double dimY = 1*mm;
|
|---|
| 222 | G4double dimZ = 1*mm;
|
|---|
| 223 |
|
|---|
| 224 | // Geometry
|
|---|
| 225 |
|
|---|
| 226 | G4Box* theFrame = new G4Box ("Frame",dimX, dimY, dimZ);
|
|---|
| 227 |
|
|---|
| 228 | G4LogicalVolume* logicalFrame = new G4LogicalVolume(theFrame,
|
|---|
| 229 | (*theMaterialTable)[materialId],
|
|---|
| 230 | "LFrame", 0, 0, 0);
|
|---|
| 231 | logicalFrame->SetMaterial(material);
|
|---|
| 232 |
|
|---|
| 233 | G4PVPlacement* physicalFrame = new G4PVPlacement(0,G4ThreeVector(),
|
|---|
| 234 | "PFrame",logicalFrame,0,false,0);
|
|---|
| 235 | G4RunManager* rm = new G4RunManager();
|
|---|
| 236 | G4cout << "World is defined " << G4endl;
|
|---|
| 237 | rm->GeometryHasBeenModified();
|
|---|
| 238 | rm->DefineWorldVolume(physicalFrame);
|
|---|
| 239 | // Particle definitions
|
|---|
| 240 |
|
|---|
| 241 | G4ParticleDefinition* gamma = G4Gamma::GammaDefinition();
|
|---|
| 242 | G4ParticleDefinition* electron = G4Electron::ElectronDefinition();
|
|---|
| 243 | G4ParticleDefinition* positron = G4Positron::PositronDefinition();
|
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 | G4ParticleDefinition* realpt = G4Electron::ElectronDefinition();
|
|---|
| 247 |
|
|---|
| 248 | if (tPart == 2)
|
|---|
| 249 | {
|
|---|
| 250 | realpt = G4Positron::PositronDefinition();
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 | G4ProductionCutsTable* cutsTable = G4ProductionCutsTable::GetProductionCutsTable();
|
|---|
| 254 | G4ProductionCuts* cuts = cutsTable->GetDefaultProductionCuts();
|
|---|
| 255 | G4double cutG=1*micrometer;
|
|---|
| 256 | G4double cutE=1*micrometer;
|
|---|
| 257 | cuts->SetProductionCut(cutG, 0); //gammas
|
|---|
| 258 | cuts->SetProductionCut(cutE, 1); //electrons
|
|---|
| 259 | cuts->SetProductionCut(cutE, 2); //positrons
|
|---|
| 260 | G4cout << "Cuts are defined " << G4endl;
|
|---|
| 261 |
|
|---|
| 262 | //G4Gamma::SetEnergyRange(2.5e-4*MeV,1e5*MeV);
|
|---|
| 263 | //G4Electron::SetEnergyRange(2.5e-4*MeV,1e5*MeV);
|
|---|
| 264 | //G4Positron::SetEnergyRange(2.5e-4*MeV,1e5*MeV);
|
|---|
| 265 |
|
|---|
| 266 | cutsTable->UpdateCoupleTable();
|
|---|
| 267 | //cutsTable->DumpCouples();
|
|---|
| 268 | const G4MaterialCutsCouple* theCouple = cutsTable->GetMaterialCutsCouple(material,cuts);
|
|---|
| 269 | G4int index = theCouple->GetIndex();
|
|---|
| 270 | G4double tCut = (*(cutsTable->GetEnergyCutsVector(1)))[index];
|
|---|
| 271 |
|
|---|
| 272 | G4cout << "Cut for delta in " << theCouple->GetMaterial()->GetName() << ": " << tCut/keV << " keV" << G4endl;
|
|---|
| 273 |
|
|---|
| 274 | // Processes
|
|---|
| 275 | G4int processType;
|
|---|
| 276 | G4cout << "Standard [1] or LowEnergy[2] or Penelope [3] Ionisation?" << G4endl;
|
|---|
| 277 | G4cin >> processType;
|
|---|
| 278 | if ( !(processType == 1 || processType == 2 || processType == 3))
|
|---|
| 279 | {
|
|---|
| 280 | G4Exception("Wrong input");
|
|---|
| 281 | }
|
|---|
| 282 |
|
|---|
| 283 | G4VContinuousDiscreteProcess* bremProcess;
|
|---|
| 284 |
|
|---|
| 285 | if (processType == 1)
|
|---|
| 286 | {
|
|---|
| 287 | bremProcess = new G4eIonisation();
|
|---|
| 288 | G4cout << "The selected model is Standard" << G4endl;
|
|---|
| 289 | }
|
|---|
| 290 | else if (processType == 2)
|
|---|
| 291 | {
|
|---|
| 292 | bremProcess = new G4LowEnergyIonisation();
|
|---|
| 293 | G4cout << "The selected model is Low Energy" << G4endl;
|
|---|
| 294 | }
|
|---|
| 295 | else if (processType == 3)
|
|---|
| 296 | {
|
|---|
| 297 |
|
|---|
| 298 | bremProcess = new G4PenelopeIonisation();
|
|---|
| 299 | G4cout << "The selected model is Penelope" << G4endl;
|
|---|
| 300 | }
|
|---|
| 301 |
|
|---|
| 302 | //----------------
|
|---|
| 303 | // process manager
|
|---|
| 304 | //----------------
|
|---|
| 305 |
|
|---|
| 306 | // electron or positron
|
|---|
| 307 |
|
|---|
| 308 |
|
|---|
| 309 | G4ProcessManager* ProcessManager = new G4ProcessManager(realpt);
|
|---|
| 310 | realpt->SetProcessManager(ProcessManager);
|
|---|
| 311 | ProcessManager->AddProcess(bremProcess);
|
|---|
| 312 | G4ForceCondition* condition;
|
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 | //--------------
|
|---|
| 316 | // set ordering
|
|---|
| 317 | //--------------
|
|---|
| 318 |
|
|---|
| 319 |
|
|---|
| 320 | // eProcessManager->
|
|---|
| 321 | // SetProcessOrdering(theeminusMultipleScattering, idxAlongStep,1);
|
|---|
| 322 | // eProcessManager->
|
|---|
| 323 | // SetProcessOrdering(theeminusIonisation, idxAlongStep,2);
|
|---|
| 324 |
|
|---|
| 325 | // eProcessManager->
|
|---|
| 326 | // SetProcessOrdering(theeminusMultipleScattering, idxPostStep,1);
|
|---|
| 327 | // eProcessManager->
|
|---|
| 328 | // SetProcessOrdering(theeminusIonisation, idxPostStep,2);
|
|---|
| 329 | // eProcessManager->
|
|---|
| 330 | // SetProcessOrdering(theeminusIonisation, idxPostStep,3);
|
|---|
| 331 |
|
|---|
| 332 |
|
|---|
| 333 |
|
|---|
| 334 | // pProcessManager->SetProcessOrderingToFirst(theeplusAnnihilation, idxAtRest);
|
|---|
| 335 | // pProcessManager->
|
|---|
| 336 | // SetProcessOrdering(theeplusMultipleScattering, idxAlongStep,1);
|
|---|
| 337 | // pProcessManager->
|
|---|
| 338 | // SetProcessOrdering(theeplusIonisation, idxAlongStep,2);
|
|---|
| 339 |
|
|---|
| 340 | // pProcessManager->
|
|---|
| 341 | // SetProcessOrdering(theeplusMultipleScattering, idxPostStep,1);
|
|---|
| 342 | // pProcessManager->
|
|---|
| 343 | // SetProcessOrdering(theeplusIonisation, idxPostStep,2);
|
|---|
| 344 | // pProcessManager->
|
|---|
| 345 | // SetProcessOrdering(theeplusIonisation, idxPostStep,3);
|
|---|
| 346 | // pProcessManager->
|
|---|
| 347 | // SetProcessOrdering(theeplusAnnihilation, idxPostStep,4);
|
|---|
| 348 |
|
|---|
| 349 | // G4LowEnergyIonisation IonisationProcess;
|
|---|
| 350 | // eProcessManager->AddProcess(&IonisationProcess);
|
|---|
| 351 | // eProcessManager->SetProcessOrdering(&IonisationProcess,idxAlongStep,1);
|
|---|
| 352 | // eProcessManager->SetProcessOrdering(&IonisationProcess,idxPostStep, 1);
|
|---|
| 353 |
|
|---|
| 354 | // G4LowEnergyIonisation BremstrahlungProcess;
|
|---|
| 355 | // eProcessManager->AddProcess(&BremstrahlungProcess);
|
|---|
| 356 | // eProcessManager->SetProcessOrdering(&BremstrahlungProcess,idxAlongStep,1);
|
|---|
| 357 | // eProcessManager->SetProcessOrdering(&BremstrahlungProcess,idxPostStep, 1);
|
|---|
| 358 |
|
|---|
| 359 | // G4eIonisation IonisationPlusProcess;
|
|---|
| 360 | // pPositronProcessManager->AddProcess(&IonisationPlusProcess);
|
|---|
| 361 | // pProcessManager->
|
|---|
| 362 | // SetProcessOrdering(&IonisationPlusProcess,idxAlongStep,1);
|
|---|
| 363 | // pProcessManager->SetProcessOrdering(&IonisationPlusProcess,idxPostStep,1);
|
|---|
| 364 |
|
|---|
| 365 |
|
|---|
| 366 |
|
|---|
| 367 | // Create a DynamicParticle
|
|---|
| 368 |
|
|---|
| 369 | G4double eEnergy = initEnergy*MeV;
|
|---|
| 370 | G4ParticleMomentum eDirection(initX,initY,initZ);
|
|---|
| 371 | //eEnergy is the KINETIK energy
|
|---|
| 372 | G4DynamicParticle dynamicPrimary(realpt,eDirection,eEnergy);
|
|---|
| 373 |
|
|---|
| 374 | dynamicPrimary.DumpInfo(0);
|
|---|
| 375 |
|
|---|
| 376 | // Track
|
|---|
| 377 |
|
|---|
| 378 | G4ThreeVector aPosition(0.,0.,0.);
|
|---|
| 379 | G4double aTime = 0. ;
|
|---|
| 380 |
|
|---|
| 381 | G4Track* eTrack = new G4Track(&dynamicPrimary,aTime,aPosition);
|
|---|
| 382 | G4GRSVolume* touche = new G4GRSVolume(physicalFrame, NULL, aPosition);
|
|---|
| 383 | eTrack->SetTouchableHandle(touche); //verificare!!!!!!!!!!!!
|
|---|
| 384 |
|
|---|
| 385 |
|
|---|
| 386 | // Step
|
|---|
| 387 |
|
|---|
| 388 | G4Step* step = new G4Step();
|
|---|
| 389 | step->SetTrack(eTrack);
|
|---|
| 390 |
|
|---|
| 391 | G4StepPoint* aPoint = new G4StepPoint();
|
|---|
| 392 | aPoint->SetPosition(aPosition);
|
|---|
| 393 | aPoint->SetMaterial(material);
|
|---|
| 394 | aPoint->SetMaterialCutsCouple(theCouple);
|
|---|
| 395 | G4double safety = 10000.*cm;
|
|---|
| 396 | aPoint->SetSafety(safety);
|
|---|
| 397 | step->SetPreStepPoint(aPoint);
|
|---|
| 398 |
|
|---|
| 399 | // Check applicability
|
|---|
| 400 |
|
|---|
| 401 | if (! (bremProcess->IsApplicable(*realpt)))
|
|---|
| 402 | {
|
|---|
| 403 | G4Exception("Not Applicable");
|
|---|
| 404 | }
|
|---|
| 405 | else
|
|---|
| 406 | {
|
|---|
| 407 | G4cout<< "applicability OK" << G4endl;
|
|---|
| 408 | }
|
|---|
| 409 |
|
|---|
| 410 | // Initialize the physics tables (in which material?)
|
|---|
| 411 | //G4cout << "Prima del build" << G4endl;
|
|---|
| 412 | bremProcess->BuildPhysicsTable(*realpt);
|
|---|
| 413 | //G4cout << "Dopo il buildt" << G4endl;
|
|---|
| 414 |
|
|---|
| 415 | G4cout<< "table OK" << G4endl;
|
|---|
| 416 |
|
|---|
| 417 | // Test GetMeanFreePath()
|
|---|
| 418 | // E' protected! Il membro accessibile e' DumpMeanFreePath()
|
|---|
| 419 |
|
|---|
| 420 | G4Material* apttoMaterial ;
|
|---|
| 421 | G4String MaterialName ;
|
|---|
| 422 |
|
|---|
| 423 | G4double minArg = 100*eV,maxArg = 100*GeV, argStp;
|
|---|
| 424 | const G4int pntNum = 300;
|
|---|
| 425 | G4double Tkin[pntNum+1];
|
|---|
| 426 | G4double meanFreePath=0. ;
|
|---|
| 427 |
|
|---|
| 428 | argStp = (std::log10(maxArg)-std::log10(minArg))/pntNum;
|
|---|
| 429 |
|
|---|
| 430 | for(G4int d = 0; d < pntNum+1; d++)
|
|---|
| 431 | {
|
|---|
| 432 | Tkin[d] = std::pow(10,(std::log10(minArg) + d*argStp));
|
|---|
| 433 | }
|
|---|
| 434 |
|
|---|
| 435 | G4double sti = 1.*mm;
|
|---|
| 436 | step->SetStepLength(sti);
|
|---|
| 437 |
|
|---|
| 438 | // for ( G4int J = 0 ; J < nMaterials ; J++ )
|
|---|
| 439 | // {
|
|---|
| 440 | apttoMaterial = (*theMaterialTable)[materialId] ;
|
|---|
| 441 | MaterialName = apttoMaterial->GetName() ;
|
|---|
| 442 | logicalFrame->SetMaterial(apttoMaterial);
|
|---|
| 443 |
|
|---|
| 444 | eTrack->SetStep(step);
|
|---|
| 445 |
|
|---|
| 446 | G4PenelopeIonisation* LowEProcess =
|
|---|
| 447 | (G4PenelopeIonisation*) bremProcess;
|
|---|
| 448 | G4LowEnergyIonisation* LowEProcess2 =
|
|---|
| 449 | (G4LowEnergyIonisation*) bremProcess;
|
|---|
| 450 | G4eIonisation* StdProcess =
|
|---|
| 451 | (G4eIonisation*) bremProcess;
|
|---|
| 452 |
|
|---|
| 453 |
|
|---|
| 454 | for (G4int i=0 ; i<pntNum; i++)
|
|---|
| 455 | {
|
|---|
| 456 | dynamicPrimary.SetKineticEnergy(Tkin[i]);
|
|---|
| 457 | if (processType == 3)
|
|---|
| 458 | {
|
|---|
| 459 | // meanFreePath=LowEProcess
|
|---|
| 460 | //->DumpMeanFreePath(*eTrack, sti, condition);
|
|---|
| 461 | }
|
|---|
| 462 | else if (processType == 2)
|
|---|
| 463 | {
|
|---|
| 464 | //meanFreePath=electronLowEProcess2
|
|---|
| 465 | // ->DumpMeanFreePath(*eTrack, sti, condition);
|
|---|
| 466 |
|
|---|
| 467 | }
|
|---|
| 468 | else if (processType == 1)
|
|---|
| 469 | {
|
|---|
| 470 | // meanFreePath=StdProcess
|
|---|
| 471 | // ->GetMeanFreePath(*eTrack, sti, condition);
|
|---|
| 472 | }
|
|---|
| 473 |
|
|---|
| 474 | ntuple3->fill(ntuple3->findColumn("kinen"),std::log10(Tkin[i]));
|
|---|
| 475 | ntuple3->fill(ntuple3->findColumn("mfp"),meanFreePath/cm);
|
|---|
| 476 | ntuple3->addRow();
|
|---|
| 477 |
|
|---|
| 478 |
|
|---|
| 479 | //G4cout << Tkin[i]/MeV << " " << meanFreePath/cm << G4endl;
|
|---|
| 480 |
|
|---|
| 481 | }
|
|---|
| 482 | G4cout << "Mean Free Path OK" << G4endl;
|
|---|
| 483 |
|
|---|
| 484 | // --------- Test the DoIt
|
|---|
| 485 |
|
|---|
| 486 | G4cout << "DoIt in " << material->GetName() << G4endl;
|
|---|
| 487 |
|
|---|
| 488 |
|
|---|
| 489 | dynamicPrimary.SetKineticEnergy(eEnergy);
|
|---|
| 490 | G4int iter;
|
|---|
| 491 | for (iter=0; iter<nIterations; iter++)
|
|---|
| 492 | {
|
|---|
| 493 |
|
|---|
| 494 | step->SetStepLength(1*micrometer);
|
|---|
| 495 |
|
|---|
| 496 | G4cout << "Iteration = " << iter
|
|---|
| 497 | << " - Step Length = "
|
|---|
| 498 | << step->GetStepLength()/mm << " mm "
|
|---|
| 499 | << G4endl;
|
|---|
| 500 |
|
|---|
| 501 |
|
|---|
| 502 | eTrack->SetStep(step);
|
|---|
| 503 |
|
|---|
| 504 |
|
|---|
| 505 | // G4cout << "Iteration = " << iter
|
|---|
| 506 | // << " - Step Length = "
|
|---|
| 507 | // << step->GetStepLength()/mm << " mm "
|
|---|
| 508 | // << G4endl;
|
|---|
| 509 |
|
|---|
| 510 | //G4cout << eTrack->GetStep()->GetStepLength()/mm
|
|---|
| 511 | // << G4endl;
|
|---|
| 512 |
|
|---|
| 513 | //G4cout << "Prima" << G4endl;
|
|---|
| 514 | G4VParticleChange* dummy;
|
|---|
| 515 | if (test==1) dummy = bremProcess->AlongStepDoIt(*eTrack, *step);
|
|---|
| 516 | if (test==2) dummy = bremProcess->PostStepDoIt(*eTrack,*step);
|
|---|
| 517 | //G4cout << "Dopo" << G4endl;
|
|---|
| 518 |
|
|---|
| 519 | G4ParticleChange* particleChange = (G4ParticleChange*) dummy;
|
|---|
| 520 |
|
|---|
| 521 | // Primary physical quantities
|
|---|
| 522 |
|
|---|
| 523 | G4double energyChange = particleChange->GetEnergyChange();
|
|---|
| 524 | G4double dedx = initEnergy - energyChange ;
|
|---|
| 525 | G4double dedxNow = dedx / (step->GetStepLength());
|
|---|
| 526 |
|
|---|
| 527 | G4ThreeVector eChange =
|
|---|
| 528 | particleChange->CalcMomentum(energyChange,
|
|---|
| 529 | (*particleChange->GetMomentumChange()),
|
|---|
| 530 | particleChange->GetMassChange());
|
|---|
| 531 |
|
|---|
| 532 | G4double pxChange = eChange.x();
|
|---|
| 533 | G4double pyChange = eChange.y();
|
|---|
| 534 | G4double pzChange = eChange.z();
|
|---|
| 535 | G4double pChange =
|
|---|
| 536 | std::sqrt(pxChange*pxChange + pyChange*pyChange + pzChange*pzChange);
|
|---|
| 537 |
|
|---|
| 538 | G4double xChange = particleChange->GetPositionChange()->x();
|
|---|
| 539 | G4double yChange = particleChange->GetPositionChange()->y();
|
|---|
| 540 | G4double zChange = particleChange->GetPositionChange()->z();
|
|---|
| 541 |
|
|---|
| 542 | G4double thetaChange = particleChange->GetMomentumChange()->theta();
|
|---|
| 543 | thetaChange = thetaChange/deg; //conversion in degrees
|
|---|
| 544 |
|
|---|
| 545 | G4cout << "---- Primary after the step ---- " << G4endl;
|
|---|
| 546 |
|
|---|
| 547 | // G4cout << "Position (x,y,z) = "
|
|---|
| 548 | // << xChange << " "
|
|---|
| 549 | // << yChange << " "
|
|---|
| 550 | // << zChange << " "
|
|---|
| 551 | // << G4endl;
|
|---|
| 552 |
|
|---|
| 553 | G4cout << "---- Energy: " << energyChange/MeV << " MeV, "
|
|---|
| 554 | << "(px,py,pz): ("
|
|---|
| 555 | << pxChange/MeV << ","
|
|---|
| 556 | << pyChange/MeV << ","
|
|---|
| 557 | << pzChange/MeV << ") MeV"
|
|---|
| 558 | << G4endl;
|
|---|
| 559 |
|
|---|
| 560 | G4cout << "---- Energy loss (dE) = " << dedx/keV << " keV" << G4endl;
|
|---|
| 561 | // G4cout << "Stopping power (dE/dx)=" << dedxNow << G4endl;
|
|---|
| 562 |
|
|---|
| 563 | ntuple1->fill(ntuple1->findColumn("eprimary"),initEnergy/MeV);
|
|---|
| 564 | ntuple1->fill(ntuple1->findColumn("energyf"),energyChange/MeV);
|
|---|
| 565 | ntuple1->fill(ntuple1->findColumn("de"),dedx/MeV);
|
|---|
| 566 | ntuple1->fill(ntuple1->findColumn("dedx"),dedxNow/(MeV/cm));
|
|---|
| 567 | ntuple1->fill(ntuple1->findColumn("pxch"),pxChange/MeV);
|
|---|
| 568 | ntuple1->fill(ntuple1->findColumn("pych"),pyChange/MeV);
|
|---|
| 569 | ntuple1->fill(ntuple1->findColumn("pzch"),pzChange/MeV);
|
|---|
| 570 | ntuple1->fill(ntuple1->findColumn("pch"),pChange/MeV);
|
|---|
| 571 | ntuple1->fill(ntuple1->findColumn("thetach"),thetaChange);
|
|---|
| 572 | ntuple1->fill(ntuple1->findColumn("costhetach"),std::cos(particleChange->GetMomentumChange()->theta()));
|
|---|
| 573 | ntuple1->addRow();
|
|---|
| 574 |
|
|---|
| 575 | // Secondaries physical quantities
|
|---|
| 576 |
|
|---|
| 577 | // Secondaries
|
|---|
| 578 | G4cout << " secondaries " <<
|
|---|
| 579 | particleChange->GetNumberOfSecondaries() << G4endl;
|
|---|
| 580 | G4double px_el,py_el,pz_el,p_el,e_el,theta_el,eKin_el;
|
|---|
| 581 |
|
|---|
| 582 | for (G4int i = 0; i < (particleChange->GetNumberOfSecondaries()); i++)
|
|---|
| 583 | {
|
|---|
| 584 | // The following two items should be filled per event, not
|
|---|
| 585 | // per secondary; filled here just for convenience, to avoid
|
|---|
| 586 | // complicated logic to dump ntuple when there are no secondaries
|
|---|
| 587 |
|
|---|
| 588 | G4Track* finalParticle = particleChange->GetSecondary(i) ;
|
|---|
| 589 |
|
|---|
| 590 | G4double e = finalParticle->GetTotalEnergy();
|
|---|
| 591 | G4double eKin = finalParticle->GetKineticEnergy();
|
|---|
| 592 | G4double px = (finalParticle->GetMomentum()).x();
|
|---|
| 593 | G4double py = (finalParticle->GetMomentum()).y();
|
|---|
| 594 | G4double pz = (finalParticle->GetMomentum()).z();
|
|---|
| 595 | G4double theta = (finalParticle->GetMomentum()).theta();
|
|---|
| 596 | G4double p = std::sqrt(px*px+py*py+pz*pz);
|
|---|
| 597 | theta = theta/deg; //conversion in degrees
|
|---|
| 598 | if (e > initEnergy)
|
|---|
| 599 | {
|
|---|
| 600 | G4cout << "WARNING: eFinal > eInit " << G4endl;
|
|---|
| 601 | // << e
|
|---|
| 602 | // << " > " initEnergy
|
|---|
| 603 |
|
|---|
| 604 | }
|
|---|
| 605 |
|
|---|
| 606 | G4String particleName =
|
|---|
| 607 | finalParticle->GetDefinition()->GetParticleName();
|
|---|
| 608 | G4cout << "==== Final "
|
|---|
| 609 | << particleName << " "
|
|---|
| 610 | << "energy: " << e/MeV << " MeV, "
|
|---|
| 611 | << "eKin: " << eKin/MeV << " MeV, "
|
|---|
| 612 | << "(px,py,pz): ("
|
|---|
| 613 | << px/MeV << ","
|
|---|
| 614 | << py/MeV << ","
|
|---|
| 615 | << pz/MeV << ") MeV "
|
|---|
| 616 | << G4endl;
|
|---|
| 617 |
|
|---|
| 618 |
|
|---|
| 619 | G4int partType;
|
|---|
| 620 | if (particleName == "e-") {
|
|---|
| 621 | partType = 1;
|
|---|
| 622 | px_el=px;
|
|---|
| 623 | py_el=py;
|
|---|
| 624 | pz_el=pz;
|
|---|
| 625 | p_el=p;
|
|---|
| 626 | e_el=e;
|
|---|
| 627 | theta_el=theta;
|
|---|
| 628 | eKin_el=eKin;
|
|---|
| 629 | }
|
|---|
| 630 | else if (particleName == "gamma") partType = 2;
|
|---|
| 631 |
|
|---|
| 632 |
|
|---|
| 633 | delete particleChange->GetSecondary(i);
|
|---|
| 634 |
|
|---|
| 635 |
|
|---|
| 636 | // Fill the secondaries ntuple
|
|---|
| 637 |
|
|---|
| 638 | // Normalize all to the energy of primary
|
|---|
| 639 | // for gammas initEnergy=initP
|
|---|
| 640 | ntuple2->fill(ntuple2->findColumn("eprimary"),initEnergy);
|
|---|
| 641 | ntuple2->fill(ntuple2->findColumn("px_el"),px_el/initEnergy);
|
|---|
| 642 | ntuple2->fill(ntuple2->findColumn("py_el"),py_el/initEnergy);
|
|---|
| 643 | ntuple2->fill(ntuple2->findColumn("pz_el"),pz_el/initEnergy);
|
|---|
| 644 | ntuple2->fill(ntuple2->findColumn("p_el"),p_el/initEnergy);
|
|---|
| 645 | ntuple2->fill(ntuple2->findColumn("e_el"),e_el/MeV);
|
|---|
| 646 | ntuple2->fill(ntuple2->findColumn("theta_el"),theta_el);
|
|---|
| 647 | ntuple2->fill(ntuple2->findColumn("ekin_el"),eKin_el/MeV);
|
|---|
| 648 | ntuple2->fill(ntuple2->findColumn("costheta_el"),std::cos(particleChange->GetMomentumChange()->theta()));
|
|---|
| 649 | ntuple2->addRow();
|
|---|
| 650 | }
|
|---|
| 651 | particleChange->Clear();
|
|---|
| 652 | }
|
|---|
| 653 |
|
|---|
| 654 |
|
|---|
| 655 | G4cout << "Iteration number: " << iter << G4endl;
|
|---|
| 656 |
|
|---|
| 657 | G4cout << "Committing.............." << G4endl;
|
|---|
| 658 | tree->commit();
|
|---|
| 659 | G4cout << "Closing the tree........" << G4endl;
|
|---|
| 660 | tree->close();
|
|---|
| 661 |
|
|---|
| 662 | delete step;
|
|---|
| 663 |
|
|---|
| 664 |
|
|---|
| 665 | G4cout << "END OF THE MAIN PROGRAM" << G4endl;
|
|---|
| 666 | return 0;
|
|---|
| 667 | }
|
|---|
| 668 |
|
|---|
| 669 |
|
|---|
| 670 |
|
|---|
| 671 |
|
|---|
| 672 |
|
|---|
| 673 |
|
|---|
| 674 |
|
|---|
| 675 |
|
|---|
| 676 |
|
|---|
| 677 |
|
|---|
| 678 |
|
|---|
| 679 |
|
|---|
| 680 |
|
|---|
| 681 |
|
|---|
| 682 |
|
|---|
| 683 |
|
|---|
| 684 |
|
|---|