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

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