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

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