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_Projection() 33 { 34 // FILE *in =fopen("PixeEvent_std_AtCreation 35 FILE* in = fopen("../build/PixeEvent_std_AtE 36 37 // FILE* out = fopen("PixeEvent_std_AtCreati 38 FILE* out = fopen("../build/PixeEvent_std_At 39 40 if (in == NULL) { 41 printf("error for opening the intput file\ 42 return; 43 } 44 45 PixeEvent p; 46 PixeEvent pp; 47 vector<int> valid_projections; 48 for (int i = 0; i < 50; ++i) { 49 int p = 2 * i; 50 valid_projections.push_back(p); 51 } 52 53 while (fread(&p, 7, 1, in)) { 54 int key = p.projectionIndex; 55 56 if (std::find(valid_projections.begin(), v 57 != valid_projections.end()) { 58 pp.energy_10eV = p.energy_10eV; 59 pp.projectionIndex = p.projectionIndex / 60 pp.sliceIndex = p.sliceIndex; // index 61 pp.pixelIndex = p.pixelIndex; 62 pp.pixelIndex = p.pixelIndex; 63 // printf("__ProjectionIndex=%d, SliceIn 64 // pp.projectionIndex, pp.sliceIndex, pp 65 fwrite(&pp, 7, 1, out); 66 } 67 } 68 fclose(in); 69 fclose(out); 70 } 71