Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-18 07:41:08

0001 #ifndef IAEA_HEADER
0002 #define IAEA_HEADER
0003 
0004 /* *********************************************************************** */
0005 #include "iaea_record.h"
0006 
0007 // defines
0008 #define SEGMENT_BEG_TOKEN '$'
0009 #define SEGMENT_END_TOKEN ':'
0010 #ifndef MAX_STR_LEN
0011   #define MAX_STR_LEN 512   /* maximum length of a string */
0012 #endif
0013 #define MAX_NUMB_LINES 30   /* maximum number of lines in a block */
0014 
0015 #define MAX_NUMB_EXTRALONG_TYPES 7 /* maximum number of extra long allowed */
0016 //  0: User defined generic type
0017 //  1: Incremental history number n_hist
0018 //     n_hist = 0 if previous primary particle scored
0019 //     n_hist > 0 indicates how many primary particle read before the current one
0020 //  2: LATCH (EGS)
0021 //  3: ILB5 (PENELOPE) 
0022 //  4: ILB4 (PENELOPE) 
0023 //  5: ILB3 (PENELOPE) 
0024 //  6: ILB2 (PENELOPE) 
0025 //  7: ILB1 (PENELOPE) 
0026 //  more to be defined
0027 
0028 #define MAX_NUMB_EXTRAFLOAT_TYPES 3 /* maximum number of extra float allowed */
0029  //  0: User defined generic type
0030  //  1: XLAST (x coord. of the last interaction)  
0031  //  2: YLAST (y coord. of the last interaction)  
0032  //  3: ZLAST (z coord. of the last interaction)  
0033  //  more to be defined
0034 
0035 
0036 struct iaea_header_type
0037 {
0038   FILE *fheader;
0039   // ******************************************************************************
0040   // 1. PHSP format
0041   
0042   int file_type;            // 0 = phsp file ;  1 = phsp generator 
0043   int byte_order;           // as defined by get_byte_order routine
0044   int record_contents[9];   // record_contents[i] = 1 or 0 (variable or constant)
0045                             // correspond to the following logical variables :
0046                             //             ix,iy,iz,iu.iv,iw;
0047                             //       iweight,iextrafloat,iextralong;  
0048 
0049   float record_constant[7]; // if record_contents[i<7] = 0
0050                             // then record_constant[i] contents the constant value
0051                             // extra floats and longs are always variable
0052                             // so no need to store them
0053 
0054   // contains the keyword describing each stored extrafloat
0055   int extrafloat_contents[NUM_EXTRA_FLOAT];
0056   
0057   // contains the keyword describing each stored extralong
0058   int extralong_contents[NUM_EXTRA_LONG];   
0059 
0060   int record_length;
0061   //  record_length = 1 +                                     (particle)
0062   //                  4 +                                     (energy)
0063   //                  SUM(i=0;i<3) {record_contents[i]*4}     (ix,iy,iz)
0064   //                  SUM(i=3;i<6) {record_contents[i]*4}     (iu,iv,iw)
0065   //                  record_contents[6]*4 +                  (iweigth)
0066   //                  record_contents[7]*4 +                  (iextrafloat)
0067   //                  record_contents[8]*4 +                  (iextralong)
0068   IAEA_I64 checksum;
0069 
0070   // ******************************************************************************
0071   // 2. Mandatory description of the phsp
0072   
0073   char coordinate_system_description[MAX_STR_LEN*MAX_NUMB_LINES+1];
0074 
0075   // Counters for phsp file
0076   IAEA_I64 orig_histories;  
0077   IAEA_I64 nParticles;
0078   IAEA_I64 particle_number[MAX_NUM_PARTICLES];
0079 
0080   // Event generator input file
0081   char input_file_for_event_generator[MAX_STR_LEN*MAX_NUMB_LINES+1];
0082   
0083   // ******************************************************************************
0084   // 3. Mandatory additional information
0085   
0086   unsigned int iaea_index; // Agency ID
0087   char title[MAX_STR_LEN*MAX_NUMB_LINES+1];
0088   
0089   char machine_type[MAX_STR_LEN*MAX_NUMB_LINES+1];
0090   
0091   char MC_code_and_version[MAX_STR_LEN*MAX_NUMB_LINES+1];
0092   
0093   float global_photon_energy_cutoff;
0094   
0095   float global_particle_energy_cutoff;
0096   
0097   char transport_parameters[MAX_STR_LEN*MAX_NUMB_LINES+1];
0098 
0099   // ******************************************************************************
0100   // 4. Optional description
0101   
0102   char beam_name[MAX_STR_LEN*MAX_NUMB_LINES+1];
0103   
0104   char field_size[MAX_STR_LEN*MAX_NUMB_LINES+1];
0105   
0106   char nominal_SSD[MAX_STR_LEN*MAX_NUMB_LINES+1];
0107   
0108   char variance_reduction_techniques[MAX_STR_LEN*MAX_NUMB_LINES+1];
0109   
0110   char initial_source_description[MAX_STR_LEN*MAX_NUMB_LINES+1];
0111 
0112   // Documentation sub-section
0113   char MC_input_filename[MAX_STR_LEN*MAX_NUMB_LINES+1];
0114   
0115   // Assumed to be the preferred citation
0116   char published_reference[MAX_STR_LEN*MAX_NUMB_LINES+1]; 
0117   char authors[MAX_STR_LEN*MAX_NUMB_LINES+1];
0118   
0119   char institution[MAX_STR_LEN*MAX_NUMB_LINES+1];
0120   
0121   char link_validation[MAX_STR_LEN*MAX_NUMB_LINES+1];
0122 
0123   char additional_notes[MAX_STR_LEN*MAX_NUMB_LINES+1];
0124 
0125   // ******************************************************************************
0126   // 5. Optional statistical information
0127   double averageKineticEnergy[MAX_NUM_PARTICLES];
0128   double sumParticleWeight[MAX_NUM_PARTICLES];
0129   double maximumKineticEnergy[MAX_NUM_PARTICLES];
0130   double minimumKineticEnergy[MAX_NUM_PARTICLES];
0131   double minimumX, maximumX;
0132   double minimumY, maximumY;
0133   double minimumZ, maximumZ;  
0134   double minimumWeight[MAX_NUM_PARTICLES];
0135   double maximumWeight[MAX_NUM_PARTICLES];  
0136 
0137   IAEA_I64 read_indep_histories;  
0138 
0139 // CLASS FUNCTIONS
0140 
0141 public:
0142       int read_header();
0143       int write_header();
0144       int print_header();
0145       int set_record_contents(iaea_record_type *p_iaea_record);
0146       int get_record_contents(iaea_record_type *p_iaea_record);
0147       void initialize_counters();
0148       void update_counters(iaea_record_type *p_iaea_record);
0149 
0150 private:
0151       int read_block(char *lineread, const char *blockname);
0152       int get_block(char *lineread);
0153       int get_blockname(char *line, const char *blockname);
0154       int write_blockname(const char *blockname);
0155 
0156       int check_byte_order();
0157       void print_statistics();
0158 };
0159 
0160 #endif