//=////////////////////////////////////////////////////////////////////// //= //= creadparam //= //= @file creadparam.cxx //= @desc Reading of parameters file //= @author J C Gonzalez //= @email gonzalez@mppmu.mpg.de //= @date Thu May 7 16:24:22 1998 //= //=---------------------------------------------------------------------- //= //= Created: Thu May 7 16:24:22 1998 //= Author: Jose Carlos Gonzalez //= Purpose: Program for reflector simulation //= Notes: See files README for details //= //=---------------------------------------------------------------------- //= //= $RCSfile: creadparam.cxx,v $ //= $Revision: 1.26 $ //= $Author: blanch $ //= $Date: 2004-01-30 09:58:39 $ //= //=////////////////////////////////////////////////////////////////////// // @T \newpage //!@section Source code of |creadparam.cxx|. /*!@" This section describes briefly the source code for the file |creadparam.cxx|. This file is very closely related to the file |readparams.cxx| from the |reflector| program. Actually, this later file was the ancestror of the file you are looking at. All the defines it uses are located in the file |creadparam.h|. In the first one we can see the definitions of the commands available for the parameters file. We describe these commands in a later section. @"*/ //!@subsection Includes and Global variables definition. /*!@" All the defines are located in the file {\tt creadparam.h}. @"*/ //!@{ #include "creadparam.h" //!@} //!@subsection Definition of global variables. /*!@" Here we define the global variables where the values from the parameters file are stored. @"*/ //!@{ static char Input_filename[100][PATH_MAX_LENGTH]; //@< input filename static char Starfield_filename[PATH_MAX_LENGTH]; //@< starfield input filename static int Starfield_center[6]={0,0,0,0,0,0}; //@< center of the starfield FOV //@< RA(H,M,S) & DEC (D,M,S) static char Data_filename[PATH_MAX_LENGTH]; //@< data filename static char ROOT_filename[PATH_MAX_LENGTH]; //@< data filename static char Loop_filename[PATH_MAX_LENGTH]; //@< special data filename static int CT_geometry = 0; //@< CT camera geometry static int CT_number = 1; //@< Number of CT static char QE_filename[100][PATH_MAX_LENGTH]; //@< name of the qe file static char NSB_directory[PATH_MAX_LENGTH]; //@< database for NSB static char NSB_outer_directory[PATH_MAX_LENGTH]; //@< database for NSB static int Starfield_rotate = FALSE; //@< switch on starfield rotation static int ElecNoise = TRUE; //@< Will we add ElecNoise? static float FADC_pedestal = 10.0; //@< Value for FADC Pedestal static float FADC_Noise = 2.0; //@< Value for FADC ElecNoise static float Digital_Noise = 1.0; //@< Value for FADC digital Noise static float Trig_Noise = 0.3; //@< Factor for Trigger ElecNoise static int simulateNSB = TRUE; //@< Will we simulate NSB? static float meanNSB; //@< NSB mean value (per pixel) static int nphe2NSB=0; //@< Number of phe from shower to do NSB simulation static float qThreshold[100][CAMERA_PIXELS]; //@< Threshold values static int Individual_Thres = FALSE; static float RiseDisc = -1.0; static float SecureDisc = 7.0; static long int Seeds[2]={69184,10406}; static int *Skip; static int nSkip=0; static int Data_From_STDIN = FALSE; static int Write_All_Images = FALSE; static int Write_McEvt = TRUE; static int Write_McTrig = FALSE; static int Write_McFadc = FALSE; static int Write_RawEvt = TRUE; static int Select_Energy = TRUE; static float Select_Energy_le = 0.0; //@< GeV static float Select_Energy_ue = 100000.0; //@< GeV static int Trigger_Scan = FALSE; static int FADC_Scan = FALSE; static int Trigger_Loop = FALSE; static float Trigger_gate_length = 3.0; static float Trigger_over_time = 0.25; static float Trigger_response_ampl = 1.0; static float Trigger_response_fwhm = 2.0; static float Trigger_threshold[100]; static int Trigger_multiplicity[100]; static int Trigger_topology[100]; static float Trigger_loop_lthres = 3.0; static float Trigger_loop_uthres = 10.0; static float Trigger_loop_sthres = 1.0; static int Trigger_loop_lmult = 2; static int Trigger_loop_umult = 10; static int Trigger_loop_ltop = 0; static int Trigger_loop_utop = 2; static float FADC_response_ampl = MFADC_RESPONSE_INTEGRAL; static float FADC_response_fwhm = MFADC_RESPONSE_FWHM; static float FADC_resp_ampl_out = MFADC_RESPONSE_INTEGRAL; static float FADC_resp_fwhm_out = MFADC_RESPONSE_FWHM; static float High_to_Low = 10.0; //@< Low gain channel respct to High static float Source_offset_th=0.; //@< Displacement in Theta of the //@< source from the center static float Source_offset_ph=0.; //@< Displacement in Phi of the //@< source from the center static float sigma_spot = -1.; // Sigma in x and y for additional // gaussian spread of the mirror spot. static float trig_delay = 25.; // Delay in ns between beginning of FADC // time window and the trigger instant. //!@} //!@subsection The function |readparam()|. //!----------------------------------------------------------- // @name creadparam // // @desc read parameters from the stdin / parameters file // // @var *filename Name of the parameters file (NULL->STDIN) // // @date Mon Sep 14 13:27:56 MET DST 1998 //------------------------------------------------------------ // @function //!@{ void readparam(char * filename) { char sign[] = GLUE_postp( PROGRAM, VERSION ); //@< initialize sign char line[LINE_MAX_LENGTH]; //@< line to get from the stdin char token[ITEM_MAX_LENGTH]; //@< a single token int i, j, k; //@< dummy counters float aux, aux2; //@< auxiliar variable int aux3, aux4; //@< auxiliar variable ifstream ifile; char filename_tmp[PATH_MAX_LENGTH]; // use cin or ifile (reading from STDIN or from parameters file? if ( filename != NULL ) ifile.open( filename ); // get signature if ( filename != NULL ) ifile.getline(line, LINE_MAX_LENGTH); else cin.getline(line, LINE_MAX_LENGTH); line[strlen(SIGNATURE)] = '\0'; strcpy(sign, line); cout<< '"' << sign << '"' << '\n'; if (strcmp(sign, SIGNATURE) != 0) { cerr << "ERROR: Signature of parameters file is not correct\n"; cerr << '"' << sign << '"' << '\n'; cerr << "should be: " << SIGNATURE << '\n'; exit(1); } // loop till the "end" directive is reached int is_end = FALSE; while (! is_end) { // get line from file or stdin if ( filename != NULL ) ifile.getline(line, LINE_MAX_LENGTH); else cin.getline(line, LINE_MAX_LENGTH); // skip comments (start with '#') if (line[0] == '#') continue; // show user comments (start with '>') if (line[0] == '>') { cout << line << endl << flush; continue; } // look for each item at the beginning of the line for (i=0; i<=end_file; i++) if (strstr(line, ITEM_NAMES[i]) == line) break; // if it is not a valid line, just ignore it if (i == end_file+1) { cerr << "Skipping unknown token in [" << line << "]\n"; continue; } // case block for each directive switch ( i ) { case input_file: //@< name of the input file // get the name of the input_file from the line sscanf(line, "%s %i %s", token,&k, filename_tmp); if(k>99 || k<0){ printf("ERROR : The input_file command in input card is faulty. \n\t Most likely the control index for CT is missing.\n"); exit(1); } strcpy(&Input_filename[k][0],&filename_tmp[0]); break; case starfield_file: //@< name of the output file // get the name of the output_file from the line sscanf(line, "%s %s", token, Starfield_filename); break; case starfield_center: //@< name of the output file // get the name of the output_file from the line sscanf(line, "%s %i %i %i %i %i %i", token, &Starfield_center[0], &Starfield_center[1], &Starfield_center[2], &Starfield_center[3], &Starfield_center[4], &Starfield_center[5]); break; case data_file: //@< name of the data file // get the name of the data_file from the line sscanf(line, "%s %s", token, Data_filename); break; case root_file: //@< name of the ROOT file // get the name of the data_file from the line sscanf(line, "%s %s", token, ROOT_filename); cout << '[' << ROOT_filename << ']' << endl << flush; break; case ct_num: //@< name of the telescope file // get the name of the ct_file from the line sscanf(line, "%s %i", token, &CT_number); break; case ct_geom: //@< name of the telescope file // get the name of the ct_file from the line sscanf(line, "%s %i", token, &CT_geometry); break; case qe_file: //@< name of the telescope file // get the name of the ct_file from the line sscanf(line, "%s %i %s", token, &k, filename_tmp); strcpy(&QE_filename[k][0],&filename_tmp[0]); break; case elec_noise_off: //@< add ElecNoise? // we will not add electronic noise for FADC and Trigger channels. ElecNoise = FALSE; FADC_Noise = 0.0; Trig_Noise =0.0; break; case fadc_pedestal: //@< FADC ElecNoise // value for FADC Pedestal sscanf(line, "%s %f", token, &FADC_pedestal); // // A. Moralejo: // Require integer mean pedestal. Although it seems a silly // restriction, this saves lots of trouble (due to rounding // happening in the FADC), particularly when running the // simulation with no noise (NSB or electronic): // if (fmod(FADC_pedestal, 1.) > 1.e-4) { printf("ERROR : requested average FADC pedestal (%f) is not integer. Please use an integer value.\n", FADC_pedestal); exit(1); } break; case high_to_low: //@< FADC ElecNoise // Value for the Low Gain channel respect to the High gain sscanf(line, "%s %f", token, &High_to_Low); break; case fadc_noise: //@< FADC ElecNoise // value for FADC Elec Noise sscanf(line, "%s %f %f", token, &FADC_Noise, &Digital_Noise); ElecNoise = TRUE; break; case trig_noise: //@< add ElecNoise? // factor for Trigger Elec Noise sscanf(line, "%s %f", token, &Trig_Noise); ElecNoise = TRUE; break; case sfr_on: //@< simulate starfield rotation? // we will simulate Starfield rotation Starfield_rotate = TRUE; break; case nsb_on: //@< simulate NSB? // we will simulate NSB simulateNSB = TRUE; break; case nsb_off: //@< simulate NSB? // we will NOT simulate NSB simulateNSB = FALSE; break; case nsb_mean: //@< value of per pixel // get value of (in photons) sscanf(line, "%s %f %d", token, &meanNSB, &nphe2NSB); break; case nsb_directory: //@< name of the output file // get the name of the NSB diretory for inner pixels sscanf(line, "%s %s", token, NSB_directory); break; case nsb_dir_outer: //@< name of the output file // get the name of the NSB diretory for outer pixels sscanf(line, "%s %s", token, NSB_outer_directory); break; case pixel_thres: //@< value of threshold for trigger (q0) // get value of threshold (in ph.e.) sscanf(line, "%s %i %f", token,&k, &aux); if(k>99 || k<0){ printf("ERROR : The input_file command in input card is faulty. \n\t Most likely the control index for CT is missing.\n"); exit(1); } qThreshold[0][k]=aux; Individual_Thres = TRUE; break; case secure_disc: //@< value of secure threshold // get value of secure threshold (in ph.e.) sscanf(line, "%s %f %f", token,&aux, &aux2); RiseDisc=aux; SecureDisc=aux2; break; case seeds: //@< values of seeds for random numbers // get seeds sscanf(line, "%s %ld %ld", token, &Seeds[0], &Seeds[1]); break; case skip: //@< skip pathological showers // get showers to skip cin >> nSkip; Skip = new int[nSkip]; for (j=0; j> Skip[j]; cout << Skip[j] << endl << flush; } break; case data_from_stdin: //@< to read data from stdin // change boolean value Data_From_STDIN = TRUE; break; case write_all_events: //@< to write ALL the images // change boolean value Write_All_Images = TRUE; break; case nowrite_McEvt: //@< do not write the McEvt info // change boolean value Write_McEvt = FALSE; break; case write_McTrig: //@< to write the McTrig info // change boolean value Write_McTrig = TRUE; break; case write_McFadc: //@< to write the McFadc info // change boolean value Write_McFadc = TRUE; break; case nowrite_RawEvt: //@< to write the McFadc info // change boolean value Write_RawEvt = FALSE; break; case select_energy: //@< value of islands_cut (i0) // get energy range sscanf(line, "%s %f %f", token, &Select_Energy_le, &Select_Energy_ue); Select_Energy = TRUE; break; case fadc_scan: // change boolean value FADC_Scan = TRUE; break; case fadc_prop: // Get parameters for the fadc response for one phe sscanf(line, "%s %f %f", token, &FADC_response_ampl,&FADC_response_fwhm); break; case fadc_outer: // Get parameters for the fadc response for one phe sscanf(line, "%s %f %f", token, &FADC_resp_ampl_out,&FADC_resp_fwhm_out); break; case trigger_scan: // change boolean value Trigger_Scan = TRUE; break; case trigger_prop: // Get parameters for the diskriminator and the electronic // response for one phe sscanf(line, "%s %f %f %f %f", token, &Trigger_gate_length,&Trigger_over_time, &Trigger_response_ampl,&Trigger_response_fwhm); break; case trigger_loop: // Get loop's limits sscanf(line, "%s %f %f %f %d %d %d %d", token, &Trigger_loop_lthres, &Trigger_loop_uthres, &Trigger_loop_sthres, &Trigger_loop_lmult, &Trigger_loop_umult, &Trigger_loop_ltop, &Trigger_loop_utop ); // Set qThreshold to a global value for(k=0;k99 || j<0){ printf("ERROR : The input_file command in input card is faulty. \n\t Most likely the control index for CT is missing.\n"); exit(1); } Trigger_threshold[j]=aux; Trigger_multiplicity[j]=aux3; Trigger_topology[j]=aux4; // Set qThreshold to a global value for(k=0;k t_ini, t_fin, t_1st, t_chan,...) // Look also for this changes. // // For the new root-file is also a change in readparm-files // // // - __DETAIL_TRIGGER__ // // This is for the implementation of the current work on trigger // studies. Because the class MTrigger is not well documented it // isnīt a part of this tar file. Only a dummy File exists. // // // // With all files in the archive, the root_camera program should run. // // A reflector file is in the directory rfl-files // // ================================================== // // From now on, use CVS for development!!!! // // // // Revision 1.2 1999/10/22 15:01:28 petry // version sent to H.K. and N.M. on Fri Oct 22 1999 // // Revision 1.1.1.1 1999/10/21 16:35:11 petry // first synthesised version // // Revision 1.6 1999/03/15 14:59:08 gonzalez // camera-1_1 // // Revision 1.5 1999/03/02 09:56:12 gonzalez // *** empty log message *** // // Revision 1.4 1999/01/14 17:32:41 gonzalez // Added to camera the STDIN input option (data_from_input) // //!@} //=EOF