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] [ 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 ]

Diff markup

Differences between /examples/advanced/stim_pixe_tomography/scripts/Extract_Slice.C (Version 11.3.0) and /examples/advanced/stim_pixe_tomography/scripts/Extract_Slice.C (Version 11.2.1)


  1 //********************************************      1 //***********************************************************************************************************
  2 //     Extract_Slice.C                              2 //     Extract_Slice.C
  3 // Root command file                                3 // Root command file
  4 // Use it by typing in the command line of Roo      4 // Use it by typing in the command line of Root terminal: root Extract_Slice.C
  5 //                                                  5 //
  6 //                                                  6 //
  7 // More information is available in UserGuide       7 // More information is available in UserGuide
  8 // Created by Z.LI LP2i Bordeaux 2022               8 // Created by Z.LI LP2i Bordeaux 2022
  9 //********************************************      9 //***********************************************************************************************************
 10                                                    10 
 11 #include <math.h>                                  11 #include <math.h>
 12 #include <stdint.h>                                12 #include <stdint.h>
 13 #include <stdio.h>                                 13 #include <stdio.h>
 14 #include <string.h>                                14 #include <string.h>
 15                                                    15 
 16 #include <vector>                                  16 #include <vector>
 17 // using namespace std;                            17 // using namespace std;
 18                                                    18 
 19 #define PI 3.14159265f                             19 #define PI 3.14159265f
 20                                                    20 
 21 // Define a structure to read and write each e     21 // Define a structure to read and write each event in the required binary format
 22 struct PixeEvent                                   22 struct PixeEvent
 23 {                                                  23 {
 24   uint16_t energy_10eV;                            24   uint16_t energy_10eV;
 25   uint16_t pixelIndex;                             25   uint16_t pixelIndex;
 26   uint16_t sliceIndex;                             26   uint16_t sliceIndex;
 27   uint8_t projectionIndex;                         27   uint8_t projectionIndex;
 28 };                                                 28 };
 29                                                    29 
 30 // to extract a certain slice or slices            30 // to extract a certain slice or slices
 31                                                    31 
 32 void Extract_Slice()                               32 void Extract_Slice()
 33 {                                                  33 {
 34   int start_slice = 0;  // start_slice: the fi     34   int start_slice = 0;  // start_slice: the first slice you would like to select
 35   int end_slice = 0;  // end_slice: the last s     35   int end_slice = 0;  // end_slice: the last slice you would like to select
 36                                                    36 
 37   FILE* in = fopen("../build/PixeEvent_std_AtC     37   FILE* in = fopen("../build/PixeEvent_std_AtCreation.DAT", "rb");
 38   // FILE *in =fopen("PixeEvent_std_AtExit.DAT     38   // FILE *in =fopen("PixeEvent_std_AtExit.DAT.DAT","rb");
 39                                                    39 
 40   FILE* out = fopen("../build/PixeEvent_std_At     40   FILE* out = fopen("../build/PixeEvent_std_AtCreation_slice.DAT", "wb");
 41   // FILE* out = fopen("PixeEvent_std_AtExit_s     41   // FILE* out = fopen("PixeEvent_std_AtExit_slice.DAT","wb");
 42                                                    42 
 43   if (in == NULL) {                                43   if (in == NULL) {
 44     printf("error for opening the intput file\     44     printf("error for opening the intput file\n");
 45     return;                                        45     return;
 46   }                                                46   }
 47                                                    47 
 48   PixeEvent p;                                     48   PixeEvent p;
 49   PixeEvent pp;                                    49   PixeEvent pp;
 50                                                    50 
 51   while (fread(&p, 7, 1, in)) {                    51   while (fread(&p, 7, 1, in)) {
 52     if (p.sliceIndex >= start_slice && p.slice     52     if (p.sliceIndex >= start_slice && p.sliceIndex <= end_slice) {
 53       pp.energy_10eV = p.energy_10eV;              53       pp.energy_10eV = p.energy_10eV;
 54       pp.projectionIndex = p.projectionIndex;      54       pp.projectionIndex = p.projectionIndex;
 55       pp.sliceIndex =                              55       pp.sliceIndex =
 56         p.sliceIndex - start_slice;  // index      56         p.sliceIndex - start_slice;  // index of slices should be reset, starting from 0
 57       pp.pixelIndex = p.pixelIndex;                57       pp.pixelIndex = p.pixelIndex;
 58       pp.pixelIndex = p.pixelIndex;                58       pp.pixelIndex = p.pixelIndex;
 59       // printf("__ProjectionIndex=%d, SliceIn     59       // printf("__ProjectionIndex=%d, SliceIndex=%d, PixelIndex=%d, Energy_10eV=%d\n",
 60       // pp.projectionIndex, pp.sliceIndex, pp     60       // pp.projectionIndex, pp.sliceIndex, pp.pixelIndex, pp.energy_10eV);
 61       fwrite(&pp, 7, 1, out);                      61       fwrite(&pp, 7, 1, out);
 62     }                                              62     }
 63   }                                                63   }
 64   fclose(in);                                      64   fclose(in);
 65   fclose(out);                                     65   fclose(out);
 66 }                                                  66 }
 67                                                    67