Geant4 Cross Reference |
1 //******************************************** 1 2 // GPSPointLoop.C 3 // Root command file 4 // Type: root GPSPointLoop.C 5 // 6 // It generates a macro file to run the simula 7 // 8 // More information is available in UserGuide 9 // Created by Z.LI LP2i Bordeaux 2022 10 //******************************************** 11 12 // include <stdio.h> 13 // include <string.h> 14 // include <stdint.h> 15 // include <vector> 16 // include <math.h> 17 // using namespace std; 18 19 void GPSPointLoop() 20 { 21 gSystem->CopyFile("pixe3d_initial.mac", "pix 22 FILE* pfile = fopen("pixe3d.mac", "a+"); 23 24 // gSystem->CopyFile("pixe3d_initial.mac" 25 // FILE* pfile = fopen("pixe3d_stim.mac", 26 27 //****************************************** 28 //***(begin)** Define scan parameters******* 29 //****************************************** 30 //****************************************** 31 int NumberOfProjections = 10; // Define the 32 // (last valu 33 int NumberOfSlices = 1; // Define the numbe 34 int NumberOfPixels = 20; // Define the numb 35 double TotalAngleSpan = 180; // scan angula 36 double ScanSize = 40 * 1.8; // unit um, sca 37 // double ScanSize = 42.48*1.8; // 38 // double ScanSize = 500; // unit u 39 double ScanHeight = ScanSize; // Height of 40 // double ScanHeight = 201.127; //Height o 41 // slices 42 int NbParticles = 1000000; 43 double energy = 1.5; // MeV 44 char typeParticle[10] = "proton"; 45 46 double PixelWidth = 1. * ScanSize / NumberOf 47 double SliceHeight = 1. * ScanHeight / Numbe 48 49 double AngleStep = 50 1. * TotalAngleSpan / NumberOfProjections; 51 52 // 53 // The beam position is at the center of eac 54 // Starting position of the beam = StartScan 55 // The scan starts from the bottom left of t 56 // 57 double StartScanXY = -0.5 * ScanSize; 58 double StartScanZ = -0.5 * ScanHeight; 59 // double StartScanZ = 0; 60 61 bool isInterrupted = false; 62 int P_interrupt = 0; // the start of projec 63 64 //****************************************** 65 //***(end)** Define scan parameters********* 66 //****************************************** 67 68 //************************************ 69 //***(begin)** SCAN IMPLEMENTATION *** 70 //************************************ 71 fprintf(pfile, "/tomography/run/scanParamete 72 NumberOfPixels); 73 fprintf(pfile, "#\n"); 74 75 if (isInterrupted) { 76 fprintf(pfile, "/tomography/run/resumeSimu 77 fprintf(pfile, "/tomography/run/resumeProj 78 fprintf(pfile, "#\n"); 79 } 80 fprintf(pfile, "/run/initialize\n"); 81 fprintf(pfile, "#\n"); 82 // fprintf(pfile, "/run/printProgress 500000\ 83 // fprintf(pfile, "#\n"); 84 fprintf(pfile, "# Source definition : energy 85 fprintf(pfile, "#\n"); 86 fprintf(pfile, "/gps/energy %.2f MeV\n", ene 87 fprintf(pfile, "/gps/particle %s\n", typePar 88 fprintf(pfile, "#\n"); 89 fprintf(pfile, "# SOURCE POSITION AND DIRECT 90 fprintf(pfile, "#\n"); 91 for (int projectionIndex = 0; projectionInde 92 ++projectionIndex) // projections 93 { 94 if (isInterrupted) { 95 if (projectionIndex < P_interrupt) conti 96 } 97 98 for (int sliceIndex = 0; sliceIndex < Numb 99 { 100 // if(sliceIndex<15) continue; 101 for (int pixelIndex = 0; pixelIndex < Nu 102 { 103 double px = cos(projectionIndex * Angl 104 double py = sin(projectionIndex * Angl 105 double pz = 0.0; 106 double x = 107 StartScanXY * px - (StartScanXY + (p 108 double y = StartScanXY * py + (StartSc 109 double z = StartScanZ + (sliceIndex + 110 // z = 18.07; //if z is fixed 111 // z = z + 1.953125; 112 // z = z + 3.90625; 113 fprintf(pfile, "/gps/direction %f %f % 114 // fprintf(pfile, "/gps/pos/centre %.6 115 fprintf(pfile, "/gps/pos/centre %f %f 116 fprintf(pfile, "/run/beamOn %d\n", NbP 117 fprintf(pfile, "#\n"); 118 } 119 } 120 } 121 fclose(pfile); 122 123 //************************************ 124 //***(end)** SCAN IMPLEMENTATION *** 125 //************************************ 126 } 127