source: trunk/MagicSoft/Simulation/Detector/Camera/creadparam.cxx@ 2354

Last change on this file since 2354 was 2353, checked in by blanch, 22 years ago
We do not read ct_file anymore.
File size: 43.9 KB
Line 
1//=//////////////////////////////////////////////////////////////////////
2//=
3//= creadparam
4//=
5//= @file creadparam.cxx
6//= @desc Reading of parameters file
7//= @author J C Gonzalez
8//= @email gonzalez@mppmu.mpg.de
9//= @date Thu May 7 16:24:22 1998
10//=
11//=----------------------------------------------------------------------
12//=
13//= Created: Thu May 7 16:24:22 1998
14//= Author: Jose Carlos Gonzalez
15//= Purpose: Program for reflector simulation
16//= Notes: See files README for details
17//=
18//=----------------------------------------------------------------------
19//=
20//= $RCSfile: creadparam.cxx,v $
21//= $Revision: 1.22 $
22//= $Author: blanch $
23//= $Date: 2003-09-23 16:52:07 $
24//=
25//=//////////////////////////////////////////////////////////////////////
26
27// @T \newpage
28
29//!@section Source code of |creadparam.cxx|.
30
31/*!@"
32
33 This section describes briefly the source code for the file
34 |creadparam.cxx|. This file is very closely related to the file
35 |readparams.cxx| from the |reflector| program. Actually, this later
36 file was the ancestror of the file you are looking at.
37
38 All the defines it uses are located in the file |creadparam.h|. In
39 the first one we can see the definitions of the commands available
40 for the parameters file. We describe these commands in a later
41 section.
42
43 @"*/
44
45//!@subsection Includes and Global variables definition.
46
47/*!@"
48
49 All the defines are located in the file {\tt creadparam.h}.
50
51 @"*/
52
53//!@{
54
55#include "creadparam.h"
56
57//!@}
58
59//!@subsection Definition of global variables.
60
61/*!@"
62
63 Here we define the global variables where the values from the
64 parameters file are stored.
65
66 @"*/
67
68//!@{
69
70static char Input_filename[100][PATH_MAX_LENGTH]; //@< input filename
71static char Starfield_filename[PATH_MAX_LENGTH]; //@< starfield input filename
72static int Starfield_center[6]; //@< center of the starfield FOV
73 //@< RA(H,M,S) & DEC (D,M,S)
74static char Data_filename[PATH_MAX_LENGTH]; //@< data filename
75static char ROOT_filename[PATH_MAX_LENGTH]; //@< data filename
76static char Loop_filename[PATH_MAX_LENGTH]; //@< special data filename
77static int CT_geometry = 0; //@< CT camera geometry
78static int CT_number = 1; //@< Number of CT
79static char QE_filename[100][PATH_MAX_LENGTH]; //@< name of the qe file
80static char NSB_directory[PATH_MAX_LENGTH]; //@< database for NSB
81static char NSB_outer_directory[PATH_MAX_LENGTH]; //@< database for NSB
82static int Starfield_rotate = FALSE; //@< switch on starfield rotation
83static int ElecNoise = TRUE; //@< Will we add ElecNoise?
84static float FADC_pedestal = 50.0; //@< Value for FADC Pedestal
85static float FADC_Noise = 2.0; //@< Value for FADC ElecNoise
86static float Trig_Noise = 0.3; //@< Factor for Trigger ElecNoise
87static int simulateNSB = TRUE; //@< Will we simulate NSB?
88static int anaPixels = -1; //@< number of pixels for the analysis
89static float meanNSB; //@< NSB mean value (per pixel)
90static int nphe2NSB=0; //@< Number of phe from shower to do NSB simulation
91static float qThreshold[100][CAMERA_PIXELS]; //@< Threshold values
92static int Individual_Thres = FALSE;
93static float RiseDisc = -1.0;
94static float SecureDisc = 7.0;
95static long int Seeds[2];
96static int *Skip;
97static int nSkip=0;
98static int Data_From_STDIN = FALSE;
99static int Write_All_Images = FALSE;
100static int Write_McEvt = TRUE;
101static int Write_McTrig = FALSE;
102static int Write_McFadc = FALSE;
103static int Write_RawEvt = TRUE;
104static int Write_All_Data = FALSE;
105static int Select_Energy = TRUE;
106static float Select_Energy_le = 0.0; //@< GeV
107static float Select_Energy_ue = 100000.0; //@< GeV
108static int Trigger_Scan = FALSE;
109static int FADC_Scan = FALSE;
110static int Trigger_Loop = FALSE;
111static float Trigger_gate_length = 3.0;
112static float Trigger_over_time = 0.25;
113static float Trigger_response_ampl = 1.0;
114static float Trigger_response_fwhm = 2.0;
115static float Trigger_threshold[100];
116static int Trigger_multiplicity[100];
117static int Trigger_topology[100];
118static float Trigger_loop_lthres = 3.0;
119static float Trigger_loop_uthres = 10.0;
120static float Trigger_loop_sthres = 1.0;
121static int Trigger_loop_lmult = 2;
122static int Trigger_loop_umult = 10;
123static int Trigger_loop_ltop = 0;
124static int Trigger_loop_utop = 2;
125static float FADC_response_ampl = MFADC_RESPONSE_AMPLITUDE;
126static float FADC_response_fwhm = MFADC_RESPONSE_FWHM;
127static float FADC_resp_ampl_out = MFADC_RESPONSE_AMPLITUDE;
128static float FADC_resp_fwhm_out = MFADC_RESPONSE_FWHM;
129static float Source_offset_th=0.; //<@ Displacement in Theta of the
130 //<@ source from the center
131static float Source_offset_ph=0.; //<@ Displacement in Phi of the
132 //<@ source from the center
133
134//!@}
135
136//!@subsection The function |readparam()|.
137
138//!-----------------------------------------------------------
139// @name creadparam
140//
141// @desc read parameters from the stdin / parameters file
142//
143// @var *filename Name of the parameters file (NULL->STDIN)
144//
145// @date Mon Sep 14 13:27:56 MET DST 1998
146//------------------------------------------------------------
147// @function
148
149//!@{
150void
151readparam(char * filename)
152{
153 char sign[] = GLUE_postp( PROGRAM, VERSION ); //@< initialize sign
154 char line[LINE_MAX_LENGTH]; //@< line to get from the stdin
155 char token[ITEM_MAX_LENGTH]; //@< a single token
156 int i, j, k; //@< dummy counters
157 float aux, aux2; //@< auxiliar variable
158 int aux3, aux4; //@< auxiliar variable
159 ifstream ifile;
160 char filename_tmp[PATH_MAX_LENGTH];
161 // use cin or ifile (reading from STDIN or from parameters file?
162 if ( filename != NULL )
163 ifile.open( filename );
164
165 // get signature
166 if ( filename != NULL )
167 ifile.getline(line, LINE_MAX_LENGTH);
168 else
169 cin.getline(line, LINE_MAX_LENGTH);
170 line[strlen(SIGNATURE)] = '\0';
171 strcpy(sign, line);
172 cout<< '"' << sign << '"' << '\n';
173 if (strcmp(sign, SIGNATURE) != 0) {
174 cerr << "ERROR: Signature of parameters file is not correct\n";
175 cerr << '"' << sign << '"' << '\n';
176 cerr << "should be: " << SIGNATURE << '\n';
177 exit(1);
178 }
179
180 // loop till the "end" directive is reached
181 int is_end = FALSE;
182 while (! is_end) {
183
184 // get line from file or stdin
185 if ( filename != NULL )
186 ifile.getline(line, LINE_MAX_LENGTH);
187 else
188 cin.getline(line, LINE_MAX_LENGTH);
189
190 // skip comments (start with '#')
191 if (line[0] == '#')
192 continue;
193
194 // show user comments (start with '>')
195 if (line[0] == '>') {
196 cout << line << endl << flush;
197 continue;
198 }
199
200 // look for each item at the beginning of the line
201 for (i=0; i<=end_file; i++)
202 if (strstr(line, ITEM_NAMES[i]) == line)
203 break;
204
205 // if it is not a valid line, just ignore it
206 if (i == end_file+1) {
207 cerr << "Skipping unknown token in [" << line << "]\n";
208 continue;
209 }
210
211 // case block for each directive
212 switch ( i ) {
213
214 case input_file: //@< name of the input file
215
216 // get the name of the input_file from the line
217 sscanf(line, "%s %i %s", token,&k, filename_tmp);
218 strcpy(&Input_filename[k][0],&filename_tmp[0]);
219 break;
220
221 case starfield_file: //@< name of the output file
222
223 // get the name of the output_file from the line
224 sscanf(line, "%s %s", token, Starfield_filename);
225
226 break;
227
228 case starfield_center: //@< name of the output file
229
230 // get the name of the output_file from the line
231 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]);
232
233 break;
234
235 case data_file: //@< name of the data file
236
237 // get the name of the data_file from the line
238 sscanf(line, "%s %s", token, Data_filename);
239
240 break;
241
242 case root_file: //@< name of the ROOT file
243
244 // get the name of the data_file from the line
245 sscanf(line, "%s %s", token, ROOT_filename);
246 cout << '[' << ROOT_filename << ']' << endl << flush;
247
248 break;
249
250 case ct_num: //@< name of the telescope file
251
252 // get the name of the ct_file from the line
253 sscanf(line, "%s %i", token, &CT_number);
254
255 break;
256
257 case ct_geom: //@< name of the telescope file
258
259 // get the name of the ct_file from the line
260 sscanf(line, "%s %i", token, &CT_geometry);
261
262 break;
263
264 case qe_file: //@< name of the telescope file
265
266 // get the name of the ct_file from the line
267 sscanf(line, "%s %i %s", token, &k, filename_tmp);
268 strcpy(&QE_filename[k][0],&filename_tmp[0]);
269
270 break;
271
272 case elec_noise_off: //@< add ElecNoise?
273
274 // we will not add electronic noise for FADC and Trigger channels.
275 ElecNoise = FALSE;
276 FADC_Noise = 0.0;
277 Trig_Noise =0.0;
278
279 break;
280
281 case fadc_pedestal: //@< FADC ElecNoise
282
283 // value for FADC Pedestal
284 sscanf(line, "%s %f", token, &FADC_pedestal);
285
286 break;
287
288 case fadc_noise: //@< FADC ElecNoise
289
290 // value for FADC Elec Noise
291 sscanf(line, "%s %f", token, &FADC_Noise);
292 ElecNoise = TRUE;
293
294 break;
295
296 case trig_noise: //@< add ElecNoise?
297
298 // factor for Trigger Elec Noise
299 sscanf(line, "%s %f", token, &Trig_Noise);
300 ElecNoise = TRUE;
301
302 break;
303
304 case sfr_on: //@< simulate starfield rotation?
305
306 // we will simulate Starfield rotation
307 Starfield_rotate = TRUE;
308
309 break;
310
311
312 case nsb_on: //@< simulate NSB?
313
314 // we will simulate NSB
315 simulateNSB = TRUE;
316
317 break;
318
319 case nsb_off: //@< simulate NSB?
320
321 // we will NOT simulate NSB
322 simulateNSB = FALSE;
323
324 break;
325
326 case nsb_mean: //@< value of <NSB> per pixel
327
328 // get value of <NSB> (in photons)
329 sscanf(line, "%s %f %d", token, &meanNSB, &nphe2NSB);
330
331 break;
332
333 case nsb_directory: //@< name of the output file
334
335 // get the name of the NSB diretory for inner pixels
336 sscanf(line, "%s %s", token, NSB_directory);
337
338 break;
339
340 case nsb_dir_outer: //@< name of the output file
341
342 // get the name of the NSB diretory for outer pixels
343 sscanf(line, "%s %s", token, NSB_outer_directory);
344
345 break;
346
347 case ana_pixels: //@< number of pixels for analysis
348
349 // number of pixels for analysis
350 sscanf(line, "%s %d", token, &anaPixels);
351
352 break;
353
354 case pixel_thres: //@< value of threshold for trigger (q0)
355
356 // get value of threshold (in ph.e.)
357 sscanf(line, "%s %i %f", token,&k, &aux);
358 qThreshold[0][k]=aux;
359 Individual_Thres = TRUE;
360
361 break;
362
363 case secure_disc: //@< value of secure threshold
364
365 // get value of secure threshold (in ph.e.)
366 sscanf(line, "%s %f %f", token,&aux, &aux2);
367 RiseDisc=aux;
368 SecureDisc=aux2;
369
370 break;
371
372 case seeds: //@< values of seeds for random numbers
373
374 // get seeds
375 sscanf(line, "%s %ld %ld", token, &Seeds[0], &Seeds[1]);
376
377 break;
378
379 case skip: //@< skip pathological showers
380
381 // get showers to skip
382 cin >> nSkip;
383 Skip = new int[nSkip];
384 for (j=0; j<nSkip; ++j) {
385 cin >> Skip[j];
386 cout << Skip[j] << endl << flush;
387 }
388
389 break;
390
391 case data_from_stdin: //@< to read data from stdin
392
393 // change boolean value
394 Data_From_STDIN = TRUE;
395
396 break;
397
398 case write_all_events: //@< to write ALL the images
399
400 // change boolean value
401 Write_All_Images = TRUE;
402
403 break;
404
405 case nowrite_McEvt: //@< do not write the McEvt info
406
407 // change boolean value
408 Write_McEvt = FALSE;
409
410 break;
411
412 case write_McTrig: //@< to write the McTrig info
413
414 // change boolean value
415 Write_McTrig = TRUE;
416
417 break;
418
419 case write_McFadc: //@< to write the McFadc info
420
421 // change boolean value
422 Write_McFadc = TRUE;
423
424 break;
425
426 case nowrite_RawEvt: //@< to write the McFadc info
427
428 // change boolean value
429 Write_RawEvt = FALSE;
430
431 break;
432
433 case write_all_data: //@< to write single pixel data
434
435 // change boolean value
436 Write_All_Data = TRUE;
437
438 break;
439
440 case select_energy: //@< value of islands_cut (i0)
441
442 // get energy range
443 sscanf(line, "%s %f %f", token, &Select_Energy_le, &Select_Energy_ue);
444 Select_Energy = TRUE;
445
446 break;
447
448 case fadc_scan:
449
450 // change boolean value
451 FADC_Scan = TRUE;
452
453 break;
454
455 case fadc_prop:
456
457 // Get parameters for the fadc response for one phe
458 sscanf(line, "%s %f %f", token, &FADC_response_ampl,&FADC_response_fwhm);
459
460 break;
461
462 case fadc_outer:
463
464 // Get parameters for the fadc response for one phe
465 sscanf(line, "%s %f %f", token, &FADC_resp_ampl_out,&FADC_resp_fwhm_out);
466
467 break;
468
469 case trigger_scan:
470
471 // change boolean value
472 Trigger_Scan = TRUE;
473
474 break;
475 case trigger_prop:
476
477 // Get parameters for the diskriminator and the electronic
478 // response for one phe
479 sscanf(line, "%s %f %f %f %f", token, &Trigger_gate_length,&Trigger_over_time, &Trigger_response_ampl,&Trigger_response_fwhm);
480
481 break;
482
483 case trigger_loop:
484
485 // Get loop's limits
486 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 );
487
488 // Set qThreshold to a global value
489 for(k=0;k<CAMERA_PIXELS;k++){
490 qThreshold[0][k]=Trigger_loop_lthres;
491 }
492
493 // change boolean value
494 Trigger_Loop = TRUE;
495 Write_RawEvt = FALSE;
496 Individual_Thres = FALSE;
497
498 break;
499
500 case trigger_single:
501
502 // Get trigger conditions
503 sscanf(line, "%s %d %f %d %d", token, &j, &aux, &aux3, &aux4);
504 Trigger_threshold[j]=aux;
505 Trigger_multiplicity[j]=aux3;
506 Trigger_topology[j]=aux4;
507
508 // Set qThreshold to a global value
509 for(k=0;k<CAMERA_PIXELS;k++){
510 qThreshold[j][k]=Trigger_threshold[j];
511 }
512
513 // change boolean value
514 Trigger_Loop = FALSE;
515 Write_RawEvt = TRUE;
516 Individual_Thres = FALSE;
517
518 break;
519
520 case source_offset:
521
522 // Get offset of source
523 sscanf(line, "%s %f %f", token, &Source_offset_th, &Source_offset_ph);
524
525 break;
526
527 case Trigger_Loop_Output_Only_Specialists:
528
529 // get the name of the data_file from the line
530 sscanf(line, "%s %s", token, Loop_filename);
531 cout << '[' << Loop_filename << ']' << endl << flush;
532
533 // change boolean value
534 Write_RawEvt = TRUE;
535
536 break;
537
538 case end_file: //@< end of the parameters file
539
540 // show a short message
541 is_end = TRUE;
542
543 break;
544
545 } // switch ( i )
546
547 } // while (! is_end)
548
549 // after the loop is finished, return to the main function
550 return;
551}
552//!@}
553
554
555//!-----------------------------------------------------------
556// @name get_input_filename
557//
558// @desc get name of the input file
559//
560// @return Name of the Input file
561//
562// @date Mon Sep 14 13:27:56 MET DST 1998
563//------------------------------------------------------------
564// @function
565
566//!@{
567char *
568get_input_filename(int i)
569{
570 return (Input_filename[i]);
571}
572//!@}
573
574
575//!-----------------------------------------------------------
576// @name get_starfield_filename
577//
578// @desc get name of the starfield input file
579//
580// @return Name of the starfield file
581//
582// @date Tue Feb 15 16:02:18 CET 2000
583//------------------------------------------------------------
584// @function
585
586//!@{
587char *
588get_starfield_filename(void)
589{
590 return (Starfield_filename);
591}
592//!@}
593
594
595//!-----------------------------------------------------------
596// @name get_starfield_center
597//
598// @desc get center of the starfield FOV
599//
600// @return Central co-ordinates in RA and DEC for the centre of FOV
601//
602// @date Tue Feb 15 16:02:18 CET 2000
603//------------------------------------------------------------
604// @function
605
606//!@{
607void get_starfield_center(int *rh,int *rm,int *rs,int *dd,int *dm,int *ds)
608{
609 *rh=Starfield_center[0];
610 *rm=Starfield_center[1];
611 *rs=Starfield_center[2];
612 *dd=Starfield_center[3];
613 *dm=Starfield_center[4];
614 *ds=Starfield_center[5];
615}
616//!-----------------------------------------------------------
617// @name get_starfield_rotate
618//
619// @Starfield_rotate
620//
621// @return
622//
623//------------------------------------------------------------
624// @function
625
626//!@{
627int
628get_starfield_rotate(void)
629{
630 return(Starfield_rotate);
631}
632
633
634//!@}
635//!-----------------------------------------------------------
636// @name get_data_filename
637//
638// @desc get name of the data file
639//
640// @return Name of the Data file
641//
642// @date Mon Sep 14 13:27:56 MET DST 1998
643//------------------------------------------------------------
644// @function
645
646//!@{
647char *
648get_data_filename(void)
649{
650 return (Data_filename);
651}
652//!@}
653
654
655//!-----------------------------------------------------------
656// @name get_root_filename
657//
658// @desc get name of the ROOT file
659//
660// @return Name of the ROOT file
661//
662// @date Mon Sep 14 13:27:56 MET DST 1998
663//------------------------------------------------------------
664// @function
665
666//!@{
667char *
668get_root_filename(void)
669{
670 return (ROOT_filename);
671}
672//!@}
673//!-----------------------------------------------------------
674// @name get_loop_filename
675//
676// @desc get name of the special ROOT file
677//
678// @return Name of the special ROOT file
679//
680// @date Fri Jun 23 17:34:19 CEST 2000
681//------------------------------------------------------------
682// @function
683
684//!@{
685
686char *
687get_loop_filename(void)
688{
689 return (Loop_filename);
690}
691//!@}
692
693//!-----------------------------------------------------------
694// @name get_ct_number
695//
696// @desc get number of CT
697//
698// @return number of CT
699//
700// @date Tue Jul 29 01:48:26 CEST 2003
701//------------------------------------------------------------
702// @function
703
704//!@{
705int
706get_ct_number(void)
707{
708 return (CT_number);
709}
710//!@}
711
712//!-----------------------------------------------------------
713// @name get_ct_geometry
714//
715// @desc get geometry of CT
716//
717// @return geometry of CT
718//
719// @date Mon Sep 14 13:27:56 MET DST 1998
720//------------------------------------------------------------
721// @function
722
723//!@{
724int
725get_ct_geometry(void)
726{
727 return (CT_geometry);
728}
729//!@}
730
731//!-----------------------------------------------------------
732// @name get_qe_filename
733//
734// @desc get name of QE definition file
735//
736// @return Name of the QE definition file
737//
738// @date Thu Jul 10 14:10:13 CEST 2003
739//------------------------------------------------------------
740// @function
741
742//!@{
743char *
744get_qe_filename(int ict)
745{
746 return (QE_filename[ict]);
747}
748//!@}
749
750//!-----------------------------------------------------------
751// @name get_nsb_directory
752//
753// @desc get name of the directory where the database for NSB is
754//
755// @return Name of the NSB directory
756//
757// @date Tue Jan 30 12:07:56 MET 2001
758//------------------------------------------------------------
759// @function
760
761//!@{
762char *
763get_nsb_directory(void)
764{
765 return (NSB_directory);
766}
767//!@}
768
769
770
771//!-----------------------------------------------------------
772// @name get_nsb_directory_outer
773//
774// @desc get name of the directory where the database for NSB is
775//
776// @return Name of the NSB directory for outer pixels
777//
778// @date Thu Jul 10 14:10:13 CEST 2003
779//------------------------------------------------------------
780// @function
781
782//!@{
783char *
784get_nsb_directory_outer(void)
785{
786 return (NSB_outer_directory);
787}
788//!@}
789
790
791
792//!-----------------------------------------------------------
793// @name add_elec_noise
794//
795// @desc are we going to add the ElecNoise?
796//
797// @date Mon Jan 14 19:27:56 MET DST 2002
798//------------------------------------------------------------
799// @function
800
801//!@{
802int
803add_elec_noise(float *fadc, float *trig)
804{
805 *fadc = FADC_Noise;
806 *trig = Trig_Noise;
807 return ( ElecNoise);
808}
809//!@}
810
811//!-----------------------------------------------------------
812// @name get_nsb
813//
814// @desc are we going to simulate NSB ?
815//
816// @var *n Mean value for the NSB (ph.e./pixel)
817// @return TRUE: we'll simulate NSB; FALSE: we won't
818//
819// @date Mon Sep 14 13:27:56 MET DST 1998
820//------------------------------------------------------------
821// @function
822
823//!@{
824int
825get_nsb(float *n, int *m)
826{
827 *n = meanNSB;
828 *m = nphe2NSB;
829 return ( simulateNSB );
830}
831//!@}
832
833
834//!-----------------------------------------------------------
835// @name get_threshold
836//
837// @desc get threshold value
838//
839// @return Value of the threshold q$_0$
840//
841// @date Mon Sep 14 13:27:56 MET DST 1998
842//------------------------------------------------------------
843// @function
844
845//!@{
846void
847get_threshold(float *t)
848{
849 for(int i=0;i<CAMERA_PIXELS;i++)
850 t[i]=qThreshold[0][i];
851}
852//!@}
853
854//!-----------------------------------------------------------
855// @name get_secure_threhold
856//
857// @desc get values for secure threshold.
858//
859// @return AC (ac)value above which discriminator threshold rised to disc
860//
861// @date Wed Jul 18 16:29:43 CEST 2001
862//------------------------------------------------------------
863// @function
864
865//!@{
866void
867get_secure_threhold(float *ac, float *disc)
868{
869 *ac=RiseDisc;
870 *disc=SecureDisc;
871}
872//!@}
873
874//!-----------------------------------------------------------
875// @name get_indi_thres_pixel
876//
877// @desc get boolean information about global (FALSE) or
878// @desc individual (TRUE) pixel trigger threshold
879//
880// @return Value for the Individual_Thres
881//
882// @date Wed Jul 18 16:29:43 CEST 2001
883//------------------------------------------------------------
884// @function
885
886//!@{
887int get_indi_thres_pixel(void){
888 return Individual_Thres;
889}
890//!@}
891
892
893//!-----------------------------------------------------------
894// @name get_ana_pixels
895//
896// @desc number of pixels for the analysis
897//
898// @return Number of pixels to use in the image parameters
899//
900// @date Mon Sep 14 13:27:56 MET DST 1998
901//------------------------------------------------------------
902// @function
903
904//!@{
905int
906get_ana_pixels(void)
907{
908 return ( anaPixels );
909}
910//!@}
911
912
913//!-----------------------------------------------------------
914// @name get_seeds
915//
916// @desc are we going to count the islands ?
917//
918// @var *n Number of the seed
919// @return N-th random-number Seed
920//
921// @date Mon Sep 14 13:27:56 MET DST 1998
922//------------------------------------------------------------
923// @function
924
925//!@{
926long int
927get_seeds(int n)
928{
929 return ( Seeds[n] );
930}
931//!@}
932
933
934//!-----------------------------------------------------------
935// @name get_skip_showers
936//
937// @desc get list of showers to skip
938//
939// @var *s1 Pointer to a vector of number of showers
940//
941// @date Mon Sep 14 13:27:56 MET DST 1998
942//------------------------------------------------------------
943// @function
944
945//!@{
946void
947get_skip_showers( int *s )
948{
949 int i;
950 for (i=0; i<nSkip; ++i)
951 s[i] = Skip[i];
952}
953//!@}
954
955
956//!-----------------------------------------------------------
957// @name get_nskip_showers
958//
959// @desc get number of showers to skip
960//
961// @return Number of showers to be skipped
962//
963// @date Mon Sep 14 13:27:56 MET DST 1998
964//------------------------------------------------------------
965// @function
966
967//!@{
968int
969get_nskip_showers( void )
970{
971 return( nSkip );
972}
973//!@}
974
975
976//!-----------------------------------------------------------
977// @name get_data_from_stdin
978//
979// @desc get whether we will read the data from the STDIN
980//
981// @return TRUE: we'll read data from STDIN; FALSE: we won't
982//
983// @date Wed Nov 25 13:21:00 MET 1998
984//------------------------------------------------------------
985// @function
986
987//!@{
988int
989get_data_from_stdin(void)
990{
991 return ( Data_From_STDIN );
992}
993//!@}
994
995
996//!-----------------------------------------------------------
997// @name write_all_events
998//
999// @desc write all images to .phe, even those without trigger
1000//
1001// @return TRUE: we'll write everything; FALSE: we won't
1002//
1003// @date Wed Nov 25 13:21:00 MET 1998
1004//------------------------------------------------------------
1005// @function
1006
1007//!@{
1008int
1009get_write_all_events(void)
1010{
1011 return ( Write_All_Images );
1012}
1013//!@}
1014
1015
1016//!-----------------------------------------------------------
1017// @name write_all_data
1018//
1019// @desc write single pixel data to file .dat
1020//
1021// @return TRUE: we'll write everything; FALSE: we won't
1022//
1023// @date Wed Nov 25 13:21:00 MET 1998
1024//------------------------------------------------------------
1025// @function
1026
1027//!@{
1028int
1029get_write_all_data(void)
1030{
1031 return ( Write_All_Data );
1032}
1033//!@}
1034
1035//!-----------------------------------------------------------
1036// @name write_McEvt
1037//
1038// @desc write the McEvt class for each event to the .root file
1039//
1040// @return TRUE: we'll write it; FALSE: we won't
1041//
1042//------------------------------------------------------------
1043// @function
1044
1045//!@{
1046int
1047get_write_McEvt(void)
1048{
1049 return ( Write_McEvt );
1050}
1051//!@}
1052
1053//!-----------------------------------------------------------
1054// @name write_McTrig
1055//
1056// @desc write the McTrig class for each event to the .root file
1057//
1058// @return TRUE: we'll write it; FALSE: we won't
1059//
1060//------------------------------------------------------------
1061// @function
1062
1063//!@{
1064int
1065get_write_McTrig(void)
1066{
1067 return ( Write_McTrig );
1068}
1069//!@}
1070
1071//!-----------------------------------------------------------
1072// @name write_McFadc
1073//
1074// @desc write the McFadc class for each event to the .root file
1075//
1076// @return TRUE: we'll write it; FALSE: we won't
1077//
1078//------------------------------------------------------------
1079// @function
1080
1081//!@{
1082int
1083get_write_McFadc(void)
1084{
1085 return ( Write_McFadc );
1086}
1087//!@}
1088
1089//!-----------------------------------------------------------
1090// @name write_RawEvt
1091//
1092// @desc write the RawEvt class for each event to the .root file
1093//
1094// @return TRUE: we'll write it; FALSE: we won't
1095//
1096//------------------------------------------------------------
1097// @function
1098
1099//!@{
1100int
1101get_write_RawEvt(void)
1102{
1103 return ( Write_RawEvt );
1104}
1105//!@}
1106
1107//!-----------------------------------------------------------
1108// @name get_select_energy
1109//
1110// @desc return energy range allowed for showers from .phe file
1111//
1112// @var *le Lower limit in the allowed energy range
1113// @var *ue Lower limit in the allowed energy range
1114// @return TRUE: we make selection on the energy; FALSE: we don't
1115//
1116// @date Wed Nov 25 13:21:00 MET 1998
1117//------------------------------------------------------------
1118// @function
1119
1120//!@{
1121int
1122get_select_energy(float *le, float *ue)
1123{
1124 *le = Select_Energy_le;
1125 *ue = Select_Energy_ue;
1126 return ( Select_Energy );
1127}
1128//!@}
1129
1130//!-----------------------------------------------------------
1131// @name FADC_Scan
1132//
1133// @desc show the FADC signal for each event in the screen
1134//
1135// @return TRUE: we'll show it; FALSE: we won't
1136//
1137//------------------------------------------------------------
1138// @function
1139
1140//!@{
1141int
1142get_FADC_Scan(void)
1143{
1144 return ( FADC_Scan );
1145}
1146//!@}
1147
1148//!-----------------------------------------------------------
1149// @name Trigger_Scan
1150//
1151// @desc show the Trigger signal for each event in the screen
1152//
1153// @return TRUE: we'll show it; FALSE: we won't
1154//
1155//------------------------------------------------------------
1156// @function
1157
1158//!@{
1159int
1160get_Trigger_Scan(void)
1161{
1162 return ( Trigger_Scan );
1163}
1164//!@}
1165
1166//!-----------------------------------------------------------
1167// @name Fadc_Propeties
1168//
1169// @desc fix properties of the FADC response
1170//
1171//------------------------------------------------------------
1172// @function
1173
1174//!@{
1175void
1176get_FADC_properties(float *ra, float *rf, float *rao, float *rfo)
1177{
1178 *ra=FADC_response_ampl;
1179 *rf=FADC_response_fwhm;
1180 *rao=FADC_resp_ampl_out;
1181 *rfo=FADC_resp_fwhm_out;
1182
1183}
1184//!@}
1185
1186//!-----------------------------------------------------------
1187// @name Trigger_Propeties
1188//
1189// @desc fix properties of the diskriminator and amplifier for Trigger
1190//
1191//------------------------------------------------------------
1192// @function
1193
1194//!@{
1195void
1196get_Trigger_properties(float *gl, float *ot, float *ra, float *rf)
1197{
1198 *gl=Trigger_gate_length;
1199 *ot=Trigger_over_time;
1200 *ra=Trigger_response_ampl;
1201 *rf=Trigger_response_fwhm;
1202
1203}
1204//!@}
1205
1206//!-----------------------------------------------------------
1207// @name Trigger_Loop
1208//
1209// @desc make a loop over Trigger conditions
1210//
1211// @return TRUE: we'll make it; FALSE: we won't
1212//
1213//------------------------------------------------------------
1214// @function
1215
1216//!@{
1217int
1218get_Trigger_Loop(float *lt, float *ut, float *st, int *lm, int *um, int *lg, int *ug)
1219{
1220 *lt=Trigger_loop_lthres;
1221 *ut=Trigger_loop_uthres;
1222 *st=Trigger_loop_sthres;
1223 *lm=Trigger_loop_lmult;
1224 *um=Trigger_loop_umult;
1225 *lg=Trigger_loop_ltop;
1226 *ug=Trigger_loop_utop;
1227 return ( Trigger_Loop );
1228}
1229//!@}
1230
1231//!-----------------------------------------------------------
1232// @name Trigger_Single
1233//
1234// @desc fix Trigger conditions
1235//
1236//------------------------------------------------------------
1237// @function
1238
1239//!@{
1240void
1241get_Trigger_Single(float **t, int *m, int *g)
1242{
1243 for(int j=0;j<100;j++){
1244 for(int i=0;i<CAMERA_PIXELS;i++)
1245 t[j][i]=qThreshold[j][i];
1246 m[j]=Trigger_multiplicity[j];
1247 g[j]=Trigger_topology[j];
1248 }
1249}
1250//!@}
1251
1252//!-----------------------------------------------------------
1253// @name get_source_off
1254//
1255// @desc give the offset of the source to the center of the camera
1256//
1257//------------------------------------------------------------
1258// @function
1259
1260//!@{
1261void get_source_off(float *th, float *p){
1262 *th=Source_offset_th;
1263 *p=Source_offset_ph;
1264}
1265//!@}
1266
1267//!-----------------------------------------------------------
1268// @name get_FADC_pedesta
1269//
1270// @desc get the value for the FADC pedestals
1271//
1272//------------------------------------------------------------
1273// @function
1274
1275//!@{
1276
1277
1278float get_FADC_pedestal(void){
1279
1280 return FADC_pedestal;
1281
1282}
1283
1284//!@}
1285//=------------------------------------------------------------
1286//!@subsection Log of this file.
1287
1288//!@{
1289//
1290// $Log: not supported by cvs2svn $
1291// Revision 1.21 2003/09/15 10:17:09 blanch
1292// Some modifications in the input card has been done for the multitelescope
1293// configuration.
1294//
1295// Revision 1.20 2003/07/17 18:04:53 blanch
1296// Some new parameters to be read have been introduced
1297//
1298// - FADC pedestals
1299// - Response outer FADC
1300// - Qe file
1301//
1302// The obsolete ones have been removed.
1303//
1304// Revision 1.19 2003/02/12 13:47:32 blanch
1305// *** empty log message ***
1306//
1307// Revision 1.18 2003/01/14 13:37:47 blanch
1308// Option to set a dc value to rise the discriminator threshold has been added.
1309//
1310// Revision 1.17 2002/07/16 16:20:41 blanch
1311// Modifications done for the camera.cxx version, where a first implementation
1312// of the Star Field Rotation has been introduced.
1313//
1314// Revision 1.16 2002/03/15 15:17:18 blanch
1315// Several modification needed to simulate the actual trigger zone.
1316//
1317// Revision 1.15 2002/03/04 17:15:51 blanch
1318// An item, which allows to switch off the storage of the RawEvt, has been
1319// introduced. It is called nowrite_RawEvt. To avoid confusion the item
1320// write_all_images has been moved to write_all_events.
1321//
1322// Revision 1.14 2002/02/28 15:07:23 blanch
1323// Small changes have been done to introduce thes step variable for the
1324// discriminator threshold in the trigger loop mode.
1325//
1326// Revision 1.13 2002/01/18 17:43:08 blanch
1327// Three new commands have been added: fadc_noise, trig_noise and
1328// elec_noise_off.
1329// A small bug in the SIGNATURE check has been solved.
1330//
1331// Revision 1.12 2001/11/13 17:05:14 blanch
1332// New input items int the input card parameter list have been included to fill
1333// the MMcRunHeader.
1334// There has been also some change to remove warnings in the compilation.
1335//
1336// Revision 1.11 2001/07/25 11:38:00 magicsol
1337// Minnor changes
1338//
1339// Revision 1.10 2001/07/19 09:28:30 blanch
1340// A new command, which allows to set individual trigger threshod for each pixel,
1341// has been added.
1342//
1343// Revision 1.9 2001/03/05 10:43:18 blanch
1344// New input commands have been added:
1345//
1346// - write_McFadc: to write the FADC simulation information.
1347// - fadc_prop: gives the shape of the single phe response of the FADC
1348//
1349// And new value has been added in the mean_NSB command that tells how many phes
1350// have to come from the shower to do the NSB simulation in that shower (it speeds
1351// up the simulation).
1352//
1353// Revision 1.8 2001/02/23 10:55:43 magicsol
1354// An input commmand that talls the path for the NSB database has been added.
1355//
1356// Revision 1.7 2001/01/15 12:37:48 magicsol
1357// It has been introduced the option to read from the input card the overlaping
1358// time.
1359//
1360// Revision 1.6 2000/09/21 11:47:33 harald
1361// Oscar found some smaller errors in the calculation of the pixel shape and
1362// corrected it.
1363//
1364// Revision 1.5 2000/07/04 14:13:02 MagicSol
1365// It reads from the general input card the parameters for the
1366// trigger analysi.
1367//
1368// Revision 1.4 2000/05/11 14:22:33 blanch
1369// New input card option has been introduced:
1370// trigger_loop lt ut lm um lg ug
1371// It forces the camera program to study several condition trigger implementations. Integers after key word fix limits of loop over thershold, multiplicity and topology.
1372//
1373// Revision 1.3 2000/03/24 18:14:05 blanch
1374// Parameters that tell as if we are going to see the diskriminator and/or FADC signal have been included.
1375//
1376// Revision 1.2 2000/02/18 17:45:43 petry
1377// This version belongs to camera.cxx 1.5.
1378// It has been put in the repository in order to be
1379// able to share the further development with others.
1380//
1381// If you need something working, wait or take an earlier one.
1382// See file README
1383//
1384// Revision 1.1.1.1 1999/11/05 11:59:34 harald
1385// This the starting point for CVS controlled further developments of the
1386// camera program. The program was originally written by Jose Carlos.
1387// But here you can find a "rootified" version to the program. This means
1388// that there is no hbook stuff in it now. Also the output of the
1389// program changed to the MagicRawDataFormat.
1390//
1391// The "rootification" was done by Dirk Petry and Harald Kornmayer.
1392//
1393// In the following you can see the README file of that version:
1394//
1395// ==================================================
1396//
1397// Fri Oct 22 1999 D.P.
1398//
1399// The MAGIC Monte Carlo System
1400//
1401// Camera Simulation Programme
1402// ---------------------------
1403//
1404// 1) Description
1405//
1406// This version is the result of the fusion of H.K.'s
1407// root_camera which is described below (section 2)
1408// and another version by D.P. which had a few additional
1409// useful features.
1410//
1411// The version compiles under Linux with ROOT 2.22 installed
1412// (variable ROOTSYS has to be set).
1413//
1414// Compile as before simply using "make" in the root_camera
1415// directory.
1416//
1417// All features of H.K.'s root_camera were retained.
1418//
1419// Additional features of this version are:
1420//
1421// a) HBOOK is no longer used and all references are removed.
1422//
1423// b) Instead of HBOOK, the user is given now the possibility of
1424// having Diagnostic data in ROOT format as a complement
1425// to the ROOT Raw data.
1426//
1427// This data is written to the file which is determined by
1428// the new input parameter "diag_file" in the camera parameter
1429// file.
1430//
1431// All source code file belonging to this part have filenames
1432// starting with "MDiag".
1433//
1434// The user can read the output file using the following commands
1435// in an interactive ROOT session:
1436//
1437// root [0] .L MDiag.so
1438// root [1] new TFile("diag.root");
1439// root [2] new TTreeViewer("T");
1440//
1441// This brings up a viewer from which all variables of the
1442// TTree can be accessed and histogrammed. This example
1443// assumes that you have named the file "diag.root", that
1444// you are using ROOT version 2.22 or later and that you have
1445// the shared object library "MDiag.so" which is produced
1446// by the Makefile along with the executable "camera".
1447//
1448// ! The contents of the so-called diag file is not yet fixed.
1449// ! At the moment it is what J.C.G. used to put into the HBOOK
1450// ! ntuple. In future versions the moments calculation can be
1451// ! removed and the parameter list be modified correspondingly.
1452//
1453// c) Now concatenated reflector files can be read. This is useful
1454// if you have run the reflector with different parameters but
1455// you want to continue the analysis with all reflector data
1456// going into ONE ROOT outputfile.
1457//
1458// The previous camera version contained a bug which made reading
1459// of two or more concatenated reflector files impossible.
1460//
1461// d) The reflector output format was changed. It is now version
1462// 0.4 .
1463// The change solely consists in a shortening of the flag
1464// definition in the file
1465//
1466// include-MC/MCCphoton.hxx
1467//
1468// ! IF YOU WANT TO READ REFLECTOR FORMAT 0.3, you can easily
1469// ! do so by recompiling camera with the previous version of
1470// ! include-MC/MCCphoton.hxx.
1471//
1472// The change was necessary for saving space and better
1473// debugging. From now on, this format can be frozen.
1474//
1475// ! For producing reflector output in the new format, you
1476// ! of course have to recompile your reflector with the
1477// ! new include-MC/MCCphoton.hxx .
1478//
1479// e) A first version of the pixelization with the larger
1480// outer pixels is implemented. THIS IS NOT YET FULLY
1481// TESTED, but first rough tests show that it works
1482// at least to a good approximation.
1483//
1484// The present version implements the camera outline
1485// with 18 "gap-pixels" and 595 pixels in total as
1486// shown in
1487//
1488// http://sarastro.ifae.es/internal/home/hardware/camera/numbering.ps
1489//
1490// This change involved
1491//
1492// (i) The file pixels.dat is no longer needed. Instead
1493// the coordinates are generated by the program itself
1494// (takes maybe 1 second). In the file
1495//
1496// pixel-coords.txt
1497//
1498// in the same directory as this README, you find a list
1499// of the coordinates generated by this new routine. It
1500// has the format
1501//
1502// number i j x y size-factor
1503//
1504// where i and j are J.C.G.'s so called biaxis hexagonal
1505// coordinates (for internal use) and x and y are the
1506// coordinates of the pixel centers in the standard camera
1507// coordinate system in units of centimeters. The value
1508// of "size-factor" determines the linear size of the pixel
1509// relative to the central pixels.
1510//
1511// (ii) The magic.def file has two additional parameters
1512// which give the number of central pixels and the
1513// number of gap pixels
1514//
1515// (iii) In camera.h and camera.cxx several changes were
1516// necessary, among them the introduction of several
1517// new functions
1518//
1519// The newly suggested outline with asymmetric Winston cones
1520// will be implemented in a later version.
1521//
1522// f) phe files can no longer be read since this contradicts
1523// our philosophy that the analysis should be done with other
1524// programs like e.g. EVITA and not with "camera" itself.
1525// This possibility was removed.
1526//
1527// g) ROOT is no longer invoked with an interactive interface.
1528// In this way, camera can better be run as a batch program and
1529// it uses less memory.
1530//
1531// h) small changes concerning the variable "t_chan" were necessary in
1532// order to avoid segmentation faults: The variable is used as an
1533// index and it went sometimes outside the limits when camera
1534// was reading proton data. This is because the reflector files
1535// don't contain the photons in a chronological order and also
1536// the timespread can be considerably longer that the foreseen
1537// digitisation timespan. Please see the source code of camera.cxx
1538// round about line 1090.
1539//
1540// j) several unused variables were removed, a few warning messages
1541// occur when you compile camera.cxx but these can be ignored at
1542// the moment.
1543//
1544// In general the program is of course not finished. It still needs
1545// debugging, proper trigger simulation, simulation of the asymmetric
1546// version of the outer pixels, proper NSB simulation, adaption of
1547// the diag "ntuple" contents to our need and others small improvements.
1548//
1549// In the directory rfl-files there is now a file in reflector format 0.4
1550// containing a single event produced by the starfiled adder. It has
1551// a duration of 30 ns and represents the region around the Crab Nebula.
1552// Using the enclosed input parameter file, camera should process this
1553// file without problems.
1554//
1555// 2) The README for the previous version of root_camera
1556//
1557// README for a preliminary version of the
1558// root_camera program.
1559//
1560// root_camera is based on the program "camera"of Jose Carlos
1561// Gonzalez. It was changed in the way that only the pixelisation
1562// and the distibution of the phe to the FADCs works in a
1563// first version.
1564//
1565// Using the #undef command most possibilities of the orignal
1566// program are switched of.
1567//
1568// The new parts are signed by
1569//
1570// - ROOT or __ROOT__
1571// nearly all important codelines for ROOT output are enclosed
1572// in structures like
1573// #ifdef __ROOT__
1574//
1575// code
1576//
1577// #endif __ROOT__
1578//
1579// In same case the new lines are signed by a comment with the word
1580// ROOT in it.
1581//
1582// For timing of the pulse some variable names are changed.
1583// (t0, t1, t --> t_ini, t_fin, t_1st, t_chan,...)
1584// Look also for this changes.
1585//
1586// For the new root-file is also a change in readparm-files
1587//
1588//
1589// - __DETAIL_TRIGGER__
1590//
1591// This is for the implementation of the current work on trigger
1592// studies. Because the class MTrigger is not well documented it
1593// isn´t a part of this tar file. Only a dummy File exists.
1594//
1595//
1596//
1597// With all files in the archive, the root_camera program should run.
1598//
1599// A reflector file is in the directory rfl-files
1600//
1601// ==================================================
1602//
1603// From now on, use CVS for development!!!!
1604//
1605//
1606//
1607// Revision 1.2 1999/10/22 15:01:28 petry
1608// version sent to H.K. and N.M. on Fri Oct 22 1999
1609//
1610// Revision 1.1.1.1 1999/10/21 16:35:11 petry
1611// first synthesised version
1612//
1613// Revision 1.6 1999/03/15 14:59:08 gonzalez
1614// camera-1_1
1615//
1616// Revision 1.5 1999/03/02 09:56:12 gonzalez
1617// *** empty log message ***
1618//
1619// Revision 1.4 1999/01/14 17:32:41 gonzalez
1620// Added to camera the STDIN input option (data_from_input)
1621//
1622//!@}
1623
1624//=EOF
Note: See TracBrowser for help on using the repository browser.