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

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