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 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 //***********************************************************************************************************
  2 // LocateInterruption_ProtonAtExit.C
  3 // Root command file
  4 // Type: root LocateInterruption_ProtonAtExit.C
  5 //
  6 // It is used by reading ProtonAtExit.dat file to locate at which projection the interruption is
  7 //
  8 //
  9 // More information is available in UserGuide
 10 // Created by Z.LI LP2i Bordeaux 2022
 11 //***********************************************************************************************************
 12 
 13 #include <math.h>
 14 #include <stdint.h>
 15 #include <stdio.h>
 16 #include <string.h>
 17 
 18 #include <vector>
 19 
 20 struct ParticleInfo
 21 {
 22   float energy_keV;
 23   float mx;
 24   float my;
 25   float mz;
 26 };
 27 
 28 // struct ParticleInfo
 29 // {
 30 // float energy_keV;
 31 // float mx;
 32 // float my;
 33 // float mz;
 34 // float x;
 35 // float y;
 36 // float z;
 37 // };
 38 
 39 struct RunInfo
 40 {
 41   // uint_16t
 42   uint8_t projectionIndex;  // 1 byte
 43   uint16_t sliceIndex;  //
 44   uint16_t pixelIndex;
 45   uint32_t nbParticle;  // 4 bytes int
 46 };
 47 
 48 void LocateInterruption_ProtonAtExit()
 49 {
 50   FILE* input = fopen("../build/ProtonAtExit_1.dat", "rb");
 51   if (input == NULL) {
 52     printf("error for opening the input file\n");
 53     return;
 54   }
 55 
 56   RunInfo runInfo;
 57   int projection = 0;  // the projection when interruption occurs
 58 
 59   //***********************************************************************
 60   //**************************Detection parameters (begin)*****************
 61   //***********************************************************************
 62 
 63   const int nbProjection = 10;
 64   const int nbSlice = 128;
 65   const int nbPixel = 20;
 66 
 67   //***********************************************************************
 68   //**************************Detection parameters (end)*******************
 69   //***********************************************************************
 70 
 71   int runID = -1;
 72   while (fread(&runInfo, sizeof(RunInfo), 1, input)) {
 73     runID++;
 74 
 75     runInfo.projectionIndex = runID / (nbSlice * nbPixel);
 76     int remain = runID % (nbSlice * nbPixel);
 77     runInfo.sliceIndex = remain / nbPixel;
 78     runInfo.pixelIndex = remain % nbPixel;
 79 
 80     int nbParticle = runInfo.nbParticle;
 81     std::vector<ParticleInfo> protonAtExit(nbParticle);
 82     fread(&protonAtExit[0], sizeof(ParticleInfo), nbParticle, input);
 83 
 84     printf("---------ProjectionIndex=%d, SliceIndex=%d, PixelIndex=%d, nbParticle = %d\n",
 85            runInfo.projectionIndex, runInfo.sliceIndex, runInfo.pixelIndex, nbParticle);
 86 
 87     projection = runInfo.projectionIndex;
 88   }
 89 
 90   printf("-----------------------It is interrupted at ProjectionIndex = %d--------------------\n",
 91          projection);
 92   fclose(input);
 93 }