Geant4 Cross Reference |
1 //******************************************** 1 //*********************************************************************************************************** 2 // Check_PixeEventFile.C 2 // Check_PixeEventFile.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 Check_PixeEventFile.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 struct ParticleInfo 29 struct ParticleInfo 30 { 30 { 31 float energy_keV; 31 float energy_keV; 32 float mx; 32 float mx; 33 float my; 33 float my; 34 float mz; 34 float mz; 35 }; 35 }; 36 struct RunInfo 36 struct RunInfo 37 { 37 { 38 // uint_16t 38 // uint_16t 39 uint8_t projectionIndex; // 1 byte 39 uint8_t projectionIndex; // 1 byte 40 uint16_t sliceIndex; // 40 uint16_t sliceIndex; // 41 uint16_t pixelIndex; 41 uint16_t pixelIndex; 42 uint32_t nbParticle; // 4 bytes int 42 uint32_t nbParticle; // 4 bytes int 43 }; 43 }; 44 44 45 double DegreeToRadian(double degree) 45 double DegreeToRadian(double degree) 46 { 46 { 47 return (PI * degree / 180.); 47 return (PI * degree / 180.); 48 } 48 } 49 49 50 struct Point 50 struct Point 51 { 51 { 52 double m_x; 52 double m_x; 53 double m_y; 53 double m_y; 54 double m_z; 54 double m_z; 55 }; 55 }; 56 bool IsDetected(Point poi1, Point poi2, double 56 bool IsDetected(Point poi1, Point poi2, double theta) 57 { 57 { 58 double a = (poi1.m_x * poi2.m_x + poi1.m_y * 58 double a = (poi1.m_x * poi2.m_x + poi1.m_y * poi2.m_y + poi1.m_z * poi2.m_z) 59 / sqrt(poi1.m_x * poi1.m_x + poi1 59 / sqrt(poi1.m_x * poi1.m_x + poi1.m_y * poi1.m_y + poi1.m_z * poi1.m_z) 60 / sqrt(poi2.m_x * poi2.m_x + poi2 60 / sqrt(poi2.m_x * poi2.m_x + poi2.m_y * poi2.m_y + poi2.m_z * poi2.m_z); 61 if (a > 1.0) a = 1; 61 if (a > 1.0) a = 1; 62 if (a < -1.0) a = -1; 62 if (a < -1.0) a = -1; 63 double r = acos(a); 63 double r = acos(a); 64 if (r > theta) 64 if (r > theta) 65 return false; 65 return false; 66 else 66 else 67 return true; 67 return true; 68 } 68 } 69 69 70 void Check_PixeEventFile() 70 void Check_PixeEventFile() 71 { 71 { 72 FILE* input2 = 72 FILE* input2 = 73 fopen("../build/PixeEvent_std_AtExit_Detec 73 fopen("../build/PixeEvent_std_AtExit_Detector135_Aperture70_50Projections.DAT", "rb"); 74 PixeEvent ppp; 74 PixeEvent ppp; 75 int proj = -1; 75 int proj = -1; 76 while (fread(&ppp, 7, 1, input2)) { 76 while (fread(&ppp, 7, 1, input2)) { 77 if (ppp.projectionIndex != proj) { 77 if (ppp.projectionIndex != proj) { 78 printf("__ProjectionIndex=%d\n", ppp.pro 78 printf("__ProjectionIndex=%d\n", ppp.projectionIndex); 79 proj = ppp.projectionIndex; 79 proj = ppp.projectionIndex; 80 } 80 } 81 // printf("__ProjectionIndex=%d, SliceInde 81 // printf("__ProjectionIndex=%d, SliceIndex=%d, PixelIndex=%d, Energy_10eV=%d\n", 82 // ppp.projectionIndex, ppp.sliceIndex, pp 82 // ppp.projectionIndex, ppp.sliceIndex, ppp.pixelIndex, ppp.energy_10eV); 83 } 83 } 84 fclose(input2); 84 fclose(input2); 85 } 85 } 86 86