//=////////////////////////////////////////////////////////////////////// //= //= 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.9 $ //= $Author: blanch $ //= $Date: 2001-03-05 10:43:18 $ //= //=////////////////////////////////////////////////////////////////////// // @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[PATH_MAX_LENGTH]; //@< input filename static char Starfield_filename[PATH_MAX_LENGTH]; //@< starfield input filename 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 char CT_filename[PATH_MAX_LENGTH]; //@< name of the CT def. file static int simulateNSB = TRUE; //@< Will we simulate NSB? static int anaPixels = -1; //@< number of pixels for the analysis static float meanNSB; //@< NSB mean value (per pixel) static int nphe2NSB=0; //@< Number of phe from shower to do NSB simulation static float qThreshold; //@< Threshold value static char NSB_directory[PATH_MAX_LENGTH]; //@< database for NSB static float qTailCut; //@< Tail Cut value static int nIslandsCut; //@< Islands Cut value static int countIslands = TRUE; //@< Will we count the islands? static long int Seeds[2]; static int *Skip; static int nSkip=0; static int Data_From_STDIN = FALSE; static int Read_Phe = FALSE; static int Read_Phe_All = 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 = FALSE; static int Write_All_Data = FALSE; static int Select_Energy = TRUE; static float Select_Energy_le = 0.0; //@< GeV static float Select_Energy_ue = 100000.0; //@< GeV static float Trigger_Radius; static int Set_Trigger_Radius=FALSE; static float fCorrection; static int Apply_Correction=FALSE; 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 = 7.0; static int Trigger_multiplicity = 4; static int Trigger_topology = 2; static int Trigger_loop_lthres = 0; static int Trigger_loop_uthres = 10; 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_AMPLITUDE; static float FADC_response_fwhm = MFADC_RESPONSE_FWHM; //!@} //!@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; //@< dummy counters ifstream ifile; // 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(line, sign); 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 %s", token, Input_filename); 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 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_file: //@< name of the telescope file // get the name of the ct_file from the line sscanf(line, "%s %s", token, CT_filename); 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 output_file from the line sscanf(line, "%s %s", token, NSB_directory); break; case ana_pixels: //@< number of pixels for analysis // number of pixels for analysis sscanf(line, "%s %d", token, &anaPixels); break; case threshold: //@< value of threshold for trigger (q0) // get value of threshold (in ph.e.) sscanf(line, "%s %f", token, &qThreshold); break; case tail_cut: //@< value of tail_cut (t0) // get value of tail_cut (in ph.e.) sscanf(line, "%s %f", token, &qTailCut); break; case islands_on: //@< DO count islands // DO count islands countIslands = TRUE; break; case islands_off: //@< do NOT count islands // do NOT count islands countIslands = FALSE; break; case islands_cut: //@< value of islands_cut (i0) // get value of islands_cut (in ph.e.) sscanf(line, "%s %d", token, &nIslandsCut); countIslands = TRUE; 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 read_phe: //@< to read PHE files // change boolean value Read_Phe = TRUE; break; case read_phe_all: //@< to read PHE files from write_all_images // change boolean value Read_Phe_All = TRUE; break; case write_all_images: //@< 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 write_all_data: //@< to write single pixel data // change boolean value Write_All_Data = TRUE; 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 trigger_radius: //@< set radius of trigger area // get trigger radius sscanf(line, "%s %f", token, &Trigger_Radius); Set_Trigger_Radius = TRUE; break; case correction: //@< apply a kind of correction to pixel values // get trigger radius sscanf(line, "%s %f", token, &fCorrection); Apply_Correction = 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 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 %d %d %d %d %d %d", token, &Trigger_loop_lthres, &Trigger_loop_uthres, &Trigger_loop_lmult, &Trigger_loop_umult, &Trigger_loop_ltop, &Trigger_loop_utop ); // change boolean value Trigger_Loop = TRUE; Write_RawEvt = FALSE; break; case trigger_single: // Get trigger conditions sscanf(line, "%s %f %d %d", token, &Trigger_threshold, &Trigger_multiplicity, &Trigger_topology); // change boolean value Trigger_Loop = FALSE; Write_RawEvt = TRUE; break; case Trigger_Loop_Output_Only_Specialists: // get the name of the data_file from the line sscanf(line, "%s %s", token, Loop_filename); cout << '[' << Loop_filename << ']' << endl << flush; // change boolean value Write_RawEvt = TRUE; break; case end_file: //@< end of the parameters file // show a short message is_end = TRUE; break; } // switch ( i ) } // while (! is_end) // after the loop is finished, return to the main function return; } //!@} //!----------------------------------------------------------- // @name get_input_filename // // @desc get name of the input file // // @return Name of the Input file // // @date Mon Sep 14 13:27:56 MET DST 1998 //------------------------------------------------------------ // @function //!@{ char * get_input_filename(void) { return (Input_filename); } //!@} //!----------------------------------------------------------- // @name get_starfield_filename // // @desc get name of the starfield input file // // @return Name of the starfield file // // @date Tue Feb 15 16:02:18 CET 2000 //------------------------------------------------------------ // @function //!@{ char * get_starfield_filename(void) { return (Starfield_filename); } //!@} //!----------------------------------------------------------- // @name get_data_filename // // @desc get name of the data file // // @return Name of the Data file // // @date Mon Sep 14 13:27:56 MET DST 1998 //------------------------------------------------------------ // @function //!@{ char * get_data_filename(void) { return (Data_filename); } //!@} //!----------------------------------------------------------- // @name get_root_filename // // @desc get name of the ROOT file // // @return Name of the ROOT file // // @date Mon Sep 14 13:27:56 MET DST 1998 //------------------------------------------------------------ // @function //!@{ char * get_root_filename(void) { return (ROOT_filename); } //!@} //!----------------------------------------------------------- // @name get_loop_filename // // @desc get name of the special ROOT file // // @return Name of the special ROOT file // // @date Fri Jun 23 17:34:19 CEST 2000 //------------------------------------------------------------ // @function //!@{ char * get_loop_filename(void) { return (Loop_filename); } //!----------------------------------------------------------- // @name get_ct_filename // // @desc get name of CT definition file // // @return Name of the CT definition file // // @date Mon Sep 14 13:27:56 MET DST 1998 //------------------------------------------------------------ // @function //!@{ char * get_ct_filename(void) { return (CT_filename); } //!@} //!----------------------------------------------------------- // @name get_nsb_directory // // @desc get name of the directory where the database for NSB is // // @return Name of the NSB directory // // @date Tue Jan 30 12:07:56 MET 2001 //------------------------------------------------------------ // @function //!@{ char * get_nsb_directory(void) { return (NSB_directory); } //!@} //!----------------------------------------------------------- // @name get_nsb // // @desc are we going to simulate NSB ? // // @var *n Mean value for the NSB (ph.e./pixel) // @return TRUE: we'll simulate NSB; FALSE: we won't // // @date Mon Sep 14 13:27:56 MET DST 1998 //------------------------------------------------------------ // @function //!@{ int get_nsb(float *n, int *m) { *n = meanNSB; *m = nphe2NSB; return ( simulateNSB ); } //!@} //!----------------------------------------------------------- // @name get_threshold // // @desc get threshold value // // @return Value of the threshold q$_0$ // // @date Mon Sep 14 13:27:56 MET DST 1998 //------------------------------------------------------------ // @function //!@{ float get_threshold(void) { return( qThreshold ); } //!@} //!----------------------------------------------------------- // @name get_tail_cut // // @desc get tail cut value // // @return Value for the Tail-cut // // @date Mon Sep 14 13:27:56 MET DST 1998 //------------------------------------------------------------ // @function //!@{ float get_tail_cut(void) { return( qTailCut ); } //!@} //!----------------------------------------------------------- // @name get_islands_cut // // @desc are we going to count the islands ? // // @var *n Cut on islands number // @return TRUE: we'll count the islands; FALSE: we won't // // @date Mon Sep 14 13:27:56 MET DST 1998 //------------------------------------------------------------ // @function //!@{ int get_islands_cut(int *n) { *n = nIslandsCut; return ( countIslands ); } //!@} //!----------------------------------------------------------- // @name get_ana_pixels // // @desc number of pixels for the analysis // // @return Number of pixels to use in the image parameters // // @date Mon Sep 14 13:27:56 MET DST 1998 //------------------------------------------------------------ // @function //!@{ int get_ana_pixels(void) { return ( anaPixels ); } //!@} //!----------------------------------------------------------- // @name get_seeds // // @desc are we going to count the islands ? // // @var *n Number of the seed // @return N-th random-number Seed // // @date Mon Sep 14 13:27:56 MET DST 1998 //------------------------------------------------------------ // @function //!@{ long int get_seeds(int n) { return ( Seeds[n] ); } //!@} //!----------------------------------------------------------- // @name get_skip_showers // // @desc get list of showers to skip // // @var *s1 Pointer to a vector of number of showers // // @date Mon Sep 14 13:27:56 MET DST 1998 //------------------------------------------------------------ // @function //!@{ void get_skip_showers( int *s ) { int i; for (i=0; i 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