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