File indexing completed on 2025-01-18 09:17:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 void GPSPointLoop()
0020 {
0021 gSystem->CopyFile("pixe3d_initial.mac", "pixe3d.mac", true);
0022 FILE* pfile = fopen("pixe3d.mac", "a+");
0023
0024
0025
0026
0027
0028
0029
0030
0031 int NumberOfProjections = 10;
0032
0033 int NumberOfSlices = 1;
0034 int NumberOfPixels = 20;
0035 double TotalAngleSpan = 180;
0036 double ScanSize = 40 * 1.8;
0037
0038
0039 double ScanHeight = ScanSize;
0040
0041
0042 int NbParticles = 1000000;
0043 double energy = 1.5;
0044 char typeParticle[10] = "proton";
0045
0046 double PixelWidth = 1. * ScanSize / NumberOfPixels;
0047 double SliceHeight = 1. * ScanHeight / NumberOfSlices;
0048
0049 double AngleStep =
0050 1. * TotalAngleSpan / NumberOfProjections;
0051
0052
0053
0054
0055
0056
0057 double StartScanXY = -0.5 * ScanSize;
0058 double StartScanZ = -0.5 * ScanHeight;
0059
0060
0061 bool isInterrupted = false;
0062 int P_interrupt = 0;
0063
0064
0065
0066
0067
0068
0069
0070
0071 fprintf(pfile, "/tomography/run/scanParameters %d %d %d\n", NumberOfProjections, NumberOfSlices,
0072 NumberOfPixels);
0073 fprintf(pfile, "#\n");
0074
0075 if (isInterrupted) {
0076 fprintf(pfile, "/tomography/run/resumeSimulation true\n");
0077 fprintf(pfile, "/tomography/run/resumeProjectionIndex %d\n", P_interrupt);
0078 fprintf(pfile, "#\n");
0079 }
0080 fprintf(pfile, "/run/initialize\n");
0081 fprintf(pfile, "#\n");
0082
0083
0084 fprintf(pfile, "# Source definition : energy, type\n");
0085 fprintf(pfile, "#\n");
0086 fprintf(pfile, "/gps/energy %.2f MeV\n", energy);
0087 fprintf(pfile, "/gps/particle %s\n", typeParticle);
0088 fprintf(pfile, "#\n");
0089 fprintf(pfile, "# SOURCE POSITION AND DIRECTION\n");
0090 fprintf(pfile, "#\n");
0091 for (int projectionIndex = 0; projectionIndex < NumberOfProjections;
0092 ++projectionIndex)
0093 {
0094 if (isInterrupted) {
0095 if (projectionIndex < P_interrupt) continue;
0096 }
0097
0098 for (int sliceIndex = 0; sliceIndex < NumberOfSlices; ++sliceIndex)
0099 {
0100
0101 for (int pixelIndex = 0; pixelIndex < NumberOfPixels; ++pixelIndex)
0102 {
0103 double px = cos(projectionIndex * AngleStep * TMath::DegToRad());
0104 double py = sin(projectionIndex * AngleStep * TMath::DegToRad());
0105 double pz = 0.0;
0106 double x =
0107 StartScanXY * px - (StartScanXY + (pixelIndex + 0.5) * PixelWidth) * py;
0108 double y = StartScanXY * py + (StartScanXY + (pixelIndex + 0.5) * PixelWidth) * px;
0109 double z = StartScanZ + (sliceIndex + 0.5) * SliceHeight;
0110
0111
0112
0113 fprintf(pfile, "/gps/direction %f %f %f\n", px, py, pz);
0114
0115 fprintf(pfile, "/gps/pos/centre %f %f %f um\n", x, y, z);
0116 fprintf(pfile, "/run/beamOn %d\n", NbParticles);
0117 fprintf(pfile, "#\n");
0118 }
0119 }
0120 }
0121 fclose(pfile);
0122
0123
0124
0125
0126 }