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

Last change on this file since 1194 was 1068, checked in by blanch, 24 years ago
New input items int the input card parameter list have been included to fill the MMcRunHeader. There has been also some change to remove warnings in the compilation.
File size: 41.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.12 $
22//= $Author: blanch $
23//= $Date: 2001-11-13 17:05:14 $
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 simulateNSB = TRUE; //@< Will we simulate NSB?
80static int anaPixels = -1; //@< number of pixels for the analysis
81static float meanNSB; //@< NSB mean value (per pixel)
82static int nphe2NSB=0; //@< Number of phe from shower to do NSB simulation
83static float qThreshold[TRIGGER_PIXELS]; //@< Threshold values
84static int Individual_Thres = FALSE;
85static float qTailCut; //@< Tail Cut value
86static int nIslandsCut; //@< Islands Cut value
87static int countIslands = TRUE; //@< Will we count the islands?
88static long int Seeds[2];
89static int *Skip;
90static int nSkip=0;
91static int Data_From_STDIN = FALSE;
92static int Read_Phe = FALSE;
93static int Read_Phe_All = FALSE;
94static int Write_All_Images = FALSE;
95static int Write_McEvt = TRUE;
96static int Write_McTrig = FALSE;
97static int Write_McFadc = FALSE;
98static int Write_RawEvt = FALSE;
99static int Write_All_Data = FALSE;
100static int Select_Energy = TRUE;
101static float Select_Energy_le = 0.0; //@< GeV
102static float Select_Energy_ue = 100000.0; //@< GeV
103static float Trigger_Radius;
104static int Set_Trigger_Radius=FALSE;
105static float fCorrection;
106static int Apply_Correction=FALSE;
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 int Trigger_loop_lthres = 0;
118static int Trigger_loop_uthres = 10;
119static int Trigger_loop_lmult = 2;
120static int Trigger_loop_umult = 10;
121static int Trigger_loop_ltop = 0;
122static int Trigger_loop_utop = 2;
123static float FADC_response_ampl = MFADC_RESPONSE_AMPLITUDE;
124static float FADC_response_fwhm = MFADC_RESPONSE_FWHM;
125static float Telescope_axis_th = 0.; //<@ Theta of the axis telescope
126static float Telescope_axis_ph = 90.; //<@ Phi of the axis telescope
127static float Source_offset_th=0.; //<@ Displacement in Theta of the
128 //<@ source from the center
129static float Source_offset_ph=0.; //<@ Displacement in Phi of the
130 //<@ source from the center
131static int Corsika_vers=5200; //<@ Version of Corsika
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; //@< 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(line, sign);
170 if (strcmp(sign, SIGNATURE) != 0) {
171 cerr << "ERROR: Signature of parameters file is not correct\n";
172 cerr << '"' << sign << '"' << '\n';
173 cerr << "should be: " << SIGNATURE << '\n';
174 exit(1);
175 }
176
177 // loop till the "end" directive is reached
178 int is_end = FALSE;
179 while (! is_end) {
180
181 // get line from file or stdin
182 if ( filename != NULL )
183 ifile.getline(line, LINE_MAX_LENGTH);
184 else
185 cin.getline(line, LINE_MAX_LENGTH);
186
187 // skip comments (start with '#')
188 if (line[0] == '#')
189 continue;
190
191 // show user comments (start with '>')
192 if (line[0] == '>') {
193 cout << line << endl << flush;
194 continue;
195 }
196
197 // look for each item at the beginning of the line
198 for (i=0; i<=end_file; i++)
199 if (strstr(line, ITEM_NAMES[i]) == line)
200 break;
201
202 // if it is not a valid line, just ignore it
203 if (i == end_file+1) {
204 cerr << "Skipping unknown token in [" << line << "]\n";
205 continue;
206 }
207
208 // case block for each directive
209 switch ( i ) {
210
211 case input_file: //@< name of the input file
212
213 // get the name of the input_file from the line
214 sscanf(line, "%s %s", token, Input_filename);
215
216 break;
217
218 case starfield_file: //@< name of the output file
219
220 // get the name of the output_file from the line
221 sscanf(line, "%s %s", token, Starfield_filename);
222
223 break;
224
225 case starfield_center: //@< name of the output file
226
227 // get the name of the output_file from the line
228 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]);
229
230 break;
231
232 case data_file: //@< name of the data file
233
234 // get the name of the data_file from the line
235 sscanf(line, "%s %s", token, Data_filename);
236
237 break;
238
239 case root_file: //@< name of the ROOT file
240
241 // get the name of the data_file from the line
242 sscanf(line, "%s %s", token, ROOT_filename);
243 cout << '[' << ROOT_filename << ']' << endl << flush;
244
245 break;
246
247 case ct_file: //@< name of the telescope file
248
249 // get the name of the ct_file from the line
250 sscanf(line, "%s %s", token, CT_filename);
251
252 break;
253
254 case nsb_on: //@< simulate NSB?
255
256 // we will simulate NSB
257 simulateNSB = TRUE;
258
259 break;
260
261 case nsb_off: //@< simulate NSB?
262
263 // we will NOT simulate NSB
264 simulateNSB = FALSE;
265
266 break;
267
268 case nsb_mean: //@< value of <NSB> per pixel
269
270 // get value of <NSB> (in photons)
271 sscanf(line, "%s %f %d", token, &meanNSB, &nphe2NSB);
272
273 break;
274
275 case nsb_directory: //@< name of the output file
276
277 // get the name of the output_file from the line
278 sscanf(line, "%s %s", token, NSB_directory);
279
280 break;
281
282 case ana_pixels: //@< number of pixels for analysis
283
284 // number of pixels for analysis
285 sscanf(line, "%s %d", token, &anaPixels);
286
287 break;
288
289 case pixel_thres: //@< value of threshold for trigger (q0)
290
291 // get value of threshold (in ph.e.)
292 sscanf(line, "%s %i %f", token,&k, &aux);
293 qThreshold[k]=aux;
294 Individual_Thres = TRUE;
295
296 break;
297
298 case tail_cut: //@< value of tail_cut (t0)
299
300 // get value of tail_cut (in ph.e.)
301 sscanf(line, "%s %f", token, &qTailCut);
302
303 break;
304
305 case islands_on: //@< DO count islands
306
307 // DO count islands
308 countIslands = TRUE;
309
310 break;
311
312 case islands_off: //@< do NOT count islands
313
314 // do NOT count islands
315 countIslands = FALSE;
316
317 break;
318
319 case islands_cut: //@< value of islands_cut (i0)
320
321 // get value of islands_cut (in ph.e.)
322 sscanf(line, "%s %d", token, &nIslandsCut);
323 countIslands = TRUE;
324
325 break;
326
327 case seeds: //@< values of seeds for random numbers
328
329 // get seeds
330 sscanf(line, "%s %ld %ld", token, &Seeds[0], &Seeds[1]);
331
332 break;
333
334 case skip: //@< skip pathological showers
335
336 // get showers to skip
337 cin >> nSkip;
338 Skip = new int[nSkip];
339 for (j=0; j<nSkip; ++j) {
340 cin >> Skip[j];
341 cout << Skip[j] << endl << flush;
342 }
343
344 break;
345
346 case data_from_stdin: //@< to read data from stdin
347
348 // change boolean value
349 Data_From_STDIN = TRUE;
350
351 break;
352
353 case read_phe: //@< to read PHE files
354
355 // change boolean value
356 Read_Phe = TRUE;
357
358 break;
359
360 case read_phe_all: //@< to read PHE files from write_all_images
361
362 // change boolean value
363 Read_Phe_All = TRUE;
364
365 break;
366
367 case write_all_images: //@< to write ALL the images
368
369 // change boolean value
370 Write_All_Images = TRUE;
371
372 break;
373
374 case nowrite_McEvt: //@< do not write the McEvt info
375
376 // change boolean value
377 Write_McEvt = FALSE;
378
379 break;
380
381 case write_McTrig: //@< to write the McTrig info
382
383 // change boolean value
384 Write_McTrig = TRUE;
385
386 break;
387
388 case write_McFadc: //@< to write the McFadc info
389
390 // change boolean value
391 Write_McFadc = TRUE;
392
393 break;
394
395 case write_all_data: //@< to write single pixel data
396
397 // change boolean value
398 Write_All_Data = TRUE;
399
400 break;
401
402 case select_energy: //@< value of islands_cut (i0)
403
404 // get energy range
405 sscanf(line, "%s %f %f", token, &Select_Energy_le, &Select_Energy_ue);
406 Select_Energy = TRUE;
407
408 break;
409
410 case trigger_radius: //@< set radius of trigger area
411
412 // get trigger radius
413 sscanf(line, "%s %f", token, &Trigger_Radius);
414 Set_Trigger_Radius = TRUE;
415
416 break;
417
418 case correction: //@< apply a kind of correction to pixel values
419
420 // get trigger radius
421 sscanf(line, "%s %f", token, &fCorrection);
422 Apply_Correction = TRUE;
423
424 break;
425
426 case fadc_scan:
427
428 // change boolean value
429 FADC_Scan = TRUE;
430
431 break;
432
433 case fadc_prop:
434
435 // Get parameters for the fadc response for one phe
436 sscanf(line, "%s %f %f", token, &FADC_response_ampl,&FADC_response_fwhm);
437
438 break;
439
440 case trigger_scan:
441
442 // change boolean value
443 Trigger_Scan = TRUE;
444
445 break;
446 case trigger_prop:
447
448 // Get parameters for the diskriminator and the electronic
449 // response for one phe
450 sscanf(line, "%s %f %f %f %f", token, &Trigger_gate_length,&Trigger_over_time, &Trigger_response_ampl,&Trigger_response_fwhm);
451
452 break;
453
454 case trigger_loop:
455
456 // Get loop's limits
457 sscanf(line, "%s %d %d %d %d %d %d", token, &Trigger_loop_lthres, &Trigger_loop_uthres, &Trigger_loop_lmult, &Trigger_loop_umult, &Trigger_loop_ltop, &Trigger_loop_utop );
458
459 // Set qThreshold to a global value
460 for(k=0;k<TRIGGER_PIXELS;k++){
461 qThreshold[k]=Trigger_loop_lthres;
462 }
463
464 // change boolean value
465 Trigger_Loop = TRUE;
466 Write_RawEvt = FALSE;
467 Individual_Thres = FALSE;
468
469 break;
470
471 case trigger_single:
472
473 // Get trigger conditions
474 sscanf(line, "%s %f %d %d", token, &Trigger_threshold, &Trigger_multiplicity, &Trigger_topology);
475
476 // Set qThreshold to a global value
477 for(k=0;k<TRIGGER_PIXELS;k++){
478 qThreshold[k]=Trigger_threshold;
479 }
480
481 // change boolean value
482 Trigger_Loop = FALSE;
483 Write_RawEvt = TRUE;
484 Individual_Thres = FALSE;
485
486 break;
487
488 case telescope_axis:
489
490 // Get axis of the telescope
491 sscanf(line, "%s %f %f", token, &Telescope_axis_th, &Telescope_axis_ph);
492
493 break;
494
495 case source_offset:
496
497 // Get offset of source
498 sscanf(line, "%s %f %f", token, &Source_offset_th, &Source_offset_ph);
499
500 break;
501
502 case corsika_vers:
503
504 // Get Corsika version
505 sscanf(line, "%s %i", token, &Corsika_vers);
506
507 break;
508
509 case Trigger_Loop_Output_Only_Specialists:
510
511 // get the name of the data_file from the line
512 sscanf(line, "%s %s", token, Loop_filename);
513 cout << '[' << Loop_filename << ']' << endl << flush;
514
515 // change boolean value
516 Write_RawEvt = TRUE;
517
518 break;
519
520 case end_file: //@< end of the parameters file
521
522 // show a short message
523 is_end = TRUE;
524
525 break;
526
527 } // switch ( i )
528
529 } // while (! is_end)
530
531 // after the loop is finished, return to the main function
532 return;
533}
534//!@}
535
536
537//!-----------------------------------------------------------
538// @name get_input_filename
539//
540// @desc get name of the input file
541//
542// @return Name of the Input file
543//
544// @date Mon Sep 14 13:27:56 MET DST 1998
545//------------------------------------------------------------
546// @function
547
548//!@{
549char *
550get_input_filename(void)
551{
552 return (Input_filename);
553}
554//!@}
555
556
557//!-----------------------------------------------------------
558// @name get_starfield_filename
559//
560// @desc get name of the starfield input file
561//
562// @return Name of the starfield file
563//
564// @date Tue Feb 15 16:02:18 CET 2000
565//------------------------------------------------------------
566// @function
567
568//!@{
569char *
570get_starfield_filename(void)
571{
572 return (Starfield_filename);
573}
574//!@}
575
576
577//!-----------------------------------------------------------
578// @name get_starfield_center
579//
580// @desc get center of the starfield FOV
581//
582// @return Central co-ordinates in RA and DEC for the centre of FOV
583//
584// @date Tue Feb 15 16:02:18 CET 2000
585//------------------------------------------------------------
586// @function
587
588//!@{
589void get_starfield_center(int *rh,int *rm,int *rs,int *dd,int *dm,int *ds)
590{
591 *rh=Starfield_center[0];
592 *rm=Starfield_center[1];
593 *rs=Starfield_center[2];
594 *dd=Starfield_center[3];
595 *dm=Starfield_center[4];
596 *ds=Starfield_center[5];
597}
598//!@}
599
600//!-----------------------------------------------------------
601// @name get_data_filename
602//
603// @desc get name of the data file
604//
605// @return Name of the Data file
606//
607// @date Mon Sep 14 13:27:56 MET DST 1998
608//------------------------------------------------------------
609// @function
610
611//!@{
612char *
613get_data_filename(void)
614{
615 return (Data_filename);
616}
617//!@}
618
619
620//!-----------------------------------------------------------
621// @name get_root_filename
622//
623// @desc get name of the ROOT file
624//
625// @return Name of the ROOT file
626//
627// @date Mon Sep 14 13:27:56 MET DST 1998
628//------------------------------------------------------------
629// @function
630
631//!@{
632char *
633get_root_filename(void)
634{
635 return (ROOT_filename);
636}
637//!@}
638//!-----------------------------------------------------------
639// @name get_loop_filename
640//
641// @desc get name of the special ROOT file
642//
643// @return Name of the special ROOT file
644//
645// @date Fri Jun 23 17:34:19 CEST 2000
646//------------------------------------------------------------
647// @function
648
649//!@{
650
651char *
652get_loop_filename(void)
653{
654 return (Loop_filename);
655}
656
657//!-----------------------------------------------------------
658// @name get_ct_filename
659//
660// @desc get name of CT definition file
661//
662// @return Name of the CT definition file
663//
664// @date Mon Sep 14 13:27:56 MET DST 1998
665//------------------------------------------------------------
666// @function
667
668//!@{
669char *
670get_ct_filename(void)
671{
672 return (CT_filename);
673}
674//!@}
675
676//!-----------------------------------------------------------
677// @name get_nsb_directory
678//
679// @desc get name of the directory where the database for NSB is
680//
681// @return Name of the NSB directory
682//
683// @date Tue Jan 30 12:07:56 MET 2001
684//------------------------------------------------------------
685// @function
686
687//!@{
688char *
689get_nsb_directory(void)
690{
691 return (NSB_directory);
692}
693//!@}
694
695
696
697//!-----------------------------------------------------------
698// @name get_nsb
699//
700// @desc are we going to simulate NSB ?
701//
702// @var *n Mean value for the NSB (ph.e./pixel)
703// @return TRUE: we'll simulate NSB; FALSE: we won't
704//
705// @date Mon Sep 14 13:27:56 MET DST 1998
706//------------------------------------------------------------
707// @function
708
709//!@{
710int
711get_nsb(float *n, int *m)
712{
713 *n = meanNSB;
714 *m = nphe2NSB;
715 return ( simulateNSB );
716}
717//!@}
718
719
720//!-----------------------------------------------------------
721// @name get_threshold
722//
723// @desc get threshold value
724//
725// @return Value of the threshold q$_0$
726//
727// @date Mon Sep 14 13:27:56 MET DST 1998
728//------------------------------------------------------------
729// @function
730
731//!@{
732void
733get_threshold(float *t)
734{
735 for(int i=0;i<TRIGGER_PIXELS;i++)
736 t[i]=qThreshold[i];
737}
738//!@}
739
740
741//!-----------------------------------------------------------
742// @name get_indi_thres_pixel
743//
744// @desc get boolean information about global (FALSE) or
745// @desc individual (TRUE) pixel trigger threshold
746//
747// @return Value for the Individual_Thres
748//
749// @date Wed Jul 18 16:29:43 CEST 2001
750//------------------------------------------------------------
751// @function
752
753//!@{
754int get_indi_thres_pixel(void){
755 return Individual_Thres;
756}
757//!@}
758
759
760//!-----------------------------------------------------------
761// @name get_tail_cut
762//
763// @desc get tail cut value
764//
765// @return Value for the Tail-cut
766//
767// @date Mon Sep 14 13:27:56 MET DST 1998
768//------------------------------------------------------------
769// @function
770
771//!@{
772float
773get_tail_cut(void)
774{
775 return( qTailCut );
776}
777//!@}
778
779
780//!-----------------------------------------------------------
781// @name get_islands_cut
782//
783// @desc are we going to count the islands ?
784//
785// @var *n Cut on islands number
786// @return TRUE: we'll count the islands; FALSE: we won't
787//
788// @date Mon Sep 14 13:27:56 MET DST 1998
789//------------------------------------------------------------
790// @function
791
792//!@{
793int
794get_islands_cut(int *n)
795{
796 *n = nIslandsCut;
797 return ( countIslands );
798}
799//!@}
800
801
802//!-----------------------------------------------------------
803// @name get_ana_pixels
804//
805// @desc number of pixels for the analysis
806//
807// @return Number of pixels to use in the image parameters
808//
809// @date Mon Sep 14 13:27:56 MET DST 1998
810//------------------------------------------------------------
811// @function
812
813//!@{
814int
815get_ana_pixels(void)
816{
817 return ( anaPixels );
818}
819//!@}
820
821
822//!-----------------------------------------------------------
823// @name get_seeds
824//
825// @desc are we going to count the islands ?
826//
827// @var *n Number of the seed
828// @return N-th random-number Seed
829//
830// @date Mon Sep 14 13:27:56 MET DST 1998
831//------------------------------------------------------------
832// @function
833
834//!@{
835long int
836get_seeds(int n)
837{
838 return ( Seeds[n] );
839}
840//!@}
841
842
843//!-----------------------------------------------------------
844// @name get_skip_showers
845//
846// @desc get list of showers to skip
847//
848// @var *s1 Pointer to a vector of number of showers
849//
850// @date Mon Sep 14 13:27:56 MET DST 1998
851//------------------------------------------------------------
852// @function
853
854//!@{
855void
856get_skip_showers( int *s )
857{
858 int i;
859 for (i=0; i<nSkip; ++i)
860 s[i] = Skip[i];
861}
862//!@}
863
864
865//!-----------------------------------------------------------
866// @name get_nskip_showers
867//
868// @desc get number of showers to skip
869//
870// @return Number of showers to be skipped
871//
872// @date Mon Sep 14 13:27:56 MET DST 1998
873//------------------------------------------------------------
874// @function
875
876//!@{
877int
878get_nskip_showers( void )
879{
880 return( nSkip );
881}
882//!@}
883
884
885//!-----------------------------------------------------------
886// @name get_data_from_stdin
887//
888// @desc get whether we will read the data from the STDIN
889//
890// @return TRUE: we'll read data from STDIN; FALSE: we won't
891//
892// @date Wed Nov 25 13:21:00 MET 1998
893//------------------------------------------------------------
894// @function
895
896//!@{
897int
898get_data_from_stdin(void)
899{
900 return ( Data_From_STDIN );
901}
902//!@}
903
904
905//!-----------------------------------------------------------
906// @name get_read_phe
907//
908// @desc get whether we will read PHE files
909//
910// @return TRUE: we'll read PHE files; FALSE: we won't
911//
912// @date Wed Nov 25 13:21:00 MET 1998
913//------------------------------------------------------------
914// @function
915
916//!@{
917int
918get_read_phe(void)
919{
920 return ( Read_Phe );
921}
922//!@}
923
924
925//!-----------------------------------------------------------
926// @name get_read_phe_all
927//
928// @desc get whether we will read PHE files, with write_all_images
929//
930// @return TRUE: we'll do it; FALSE: we won't
931//
932// @date Wed Nov 25 13:21:00 MET 1998
933//------------------------------------------------------------
934// @function
935
936//!@{
937int
938get_read_phe_all(void)
939{
940 return ( Read_Phe_All );
941}
942//!@}
943
944
945//!-----------------------------------------------------------
946// @name write_all_images
947//
948// @desc write all images to .phe, even those without trigger
949//
950// @return TRUE: we'll write everything; FALSE: we won't
951//
952// @date Wed Nov 25 13:21:00 MET 1998
953//------------------------------------------------------------
954// @function
955
956//!@{
957int
958get_write_all_images(void)
959{
960 return ( Write_All_Images );
961}
962//!@}
963
964
965//!-----------------------------------------------------------
966// @name write_all_data
967//
968// @desc write single pixel data to file .dat
969//
970// @return TRUE: we'll write everything; FALSE: we won't
971//
972// @date Wed Nov 25 13:21:00 MET 1998
973//------------------------------------------------------------
974// @function
975
976//!@{
977int
978get_write_all_data(void)
979{
980 return ( Write_All_Data );
981}
982//!@}
983
984//!-----------------------------------------------------------
985// @name write_McEvt
986//
987// @desc write the McEvt class for each event to the .root file
988//
989// @return TRUE: we'll write it; FALSE: we won't
990//
991//------------------------------------------------------------
992// @function
993
994//!@{
995int
996get_write_McEvt(void)
997{
998 return ( Write_McEvt );
999}
1000//!@}
1001
1002//!-----------------------------------------------------------
1003// @name write_McTrig
1004//
1005// @desc write the McTrig class for each event to the .root file
1006//
1007// @return TRUE: we'll write it; FALSE: we won't
1008//
1009//------------------------------------------------------------
1010// @function
1011
1012//!@{
1013int
1014get_write_McTrig(void)
1015{
1016 return ( Write_McTrig );
1017}
1018//!@}
1019
1020//!-----------------------------------------------------------
1021// @name write_McFadc
1022//
1023// @desc write the McFadc class for each event to the .root file
1024//
1025// @return TRUE: we'll write it; FALSE: we won't
1026//
1027//------------------------------------------------------------
1028// @function
1029
1030//!@{
1031int
1032get_write_McFadc(void)
1033{
1034 return ( Write_McFadc );
1035}
1036//!@}
1037
1038//!-----------------------------------------------------------
1039// @name write_RawEvt
1040//
1041// @desc write the RawEvt class for each event to the .root file
1042//
1043// @return TRUE: we'll write it; FALSE: we won't
1044//
1045//------------------------------------------------------------
1046// @function
1047
1048//!@{
1049int
1050get_write_RawEvt(void)
1051{
1052 return ( Write_RawEvt );
1053}
1054//!@}
1055
1056//!-----------------------------------------------------------
1057// @name get_select_energy
1058//
1059// @desc return energy range allowed for showers from .phe file
1060//
1061// @var *le Lower limit in the allowed energy range
1062// @var *ue Lower limit in the allowed energy range
1063// @return TRUE: we make selection on the energy; FALSE: we don't
1064//
1065// @date Wed Nov 25 13:21:00 MET 1998
1066//------------------------------------------------------------
1067// @function
1068
1069//!@{
1070int
1071get_select_energy(float *le, float *ue)
1072{
1073 *le = Select_Energy_le;
1074 *ue = Select_Energy_ue;
1075 return ( Select_Energy );
1076}
1077//!@}
1078
1079
1080//!-----------------------------------------------------------
1081// @name get_trigger_radius
1082//
1083// @desc return the radius of the trigger area in the camera (if set)
1084//
1085// @var *radius Radius of the trigger area in the camera
1086// @return TRUE: we choose a given radius for the trigger area
1087//
1088// @date Fri May 7 11:07:43 MET DST 1999
1089//------------------------------------------------------------
1090// @function
1091
1092//!@{
1093int get_trigger_radius(float *radius)
1094{
1095 *radius = Trigger_Radius;
1096 return ( Set_Trigger_Radius );
1097}
1098//!@}
1099
1100
1101//!-----------------------------------------------------------
1102// @name get_trigger_radius
1103//
1104// @desc return the radius of the trigger area in the camera (if set)
1105//
1106// @var *radius Radius of the trigger area in the camera
1107// @return TRUE: we choose a given radius for the trigger area
1108//
1109// @date Fri May 7 11:07:43 MET DST 1999
1110//------------------------------------------------------------
1111// @function
1112
1113//!@{
1114int get_correction(float *corr)
1115{
1116 *corr = fCorrection;
1117 return ( Apply_Correction );
1118}
1119//!@}
1120
1121//!-----------------------------------------------------------
1122// @name FADC_Scan
1123//
1124// @desc show the FADC signal for each event in the screen
1125//
1126// @return TRUE: we'll show it; FALSE: we won't
1127//
1128//------------------------------------------------------------
1129// @function
1130
1131//!@{
1132int
1133get_FADC_Scan(void)
1134{
1135 return ( FADC_Scan );
1136}
1137//!@}
1138
1139//!-----------------------------------------------------------
1140// @name Trigger_Scan
1141//
1142// @desc show the Trigger signal for each event in the screen
1143//
1144// @return TRUE: we'll show it; FALSE: we won't
1145//
1146//------------------------------------------------------------
1147// @function
1148
1149//!@{
1150int
1151get_Trigger_Scan(void)
1152{
1153 return ( Trigger_Scan );
1154}
1155//!@}
1156
1157//!-----------------------------------------------------------
1158// @name Fadc_Propeties
1159//
1160// @desc fix properties of the FADC response
1161//
1162//------------------------------------------------------------
1163// @function
1164
1165//!@{
1166void
1167get_FADC_properties(float *ra, float *rf)
1168{
1169 *ra=FADC_response_ampl;
1170 *rf=FADC_response_fwhm;
1171
1172}
1173//!@}
1174
1175//!-----------------------------------------------------------
1176// @name Trigger_Propeties
1177//
1178// @desc fix properties of the diskriminator and amplifier for Trigger
1179//
1180//------------------------------------------------------------
1181// @function
1182
1183//!@{
1184void
1185get_Trigger_properties(float *gl, float *ot, float *ra, float *rf)
1186{
1187 *gl=Trigger_gate_length;
1188 *ot=Trigger_over_time;
1189 *ra=Trigger_response_ampl;
1190 *rf=Trigger_response_fwhm;
1191
1192}
1193//!@}
1194
1195//!-----------------------------------------------------------
1196// @name Trigger_Loop
1197//
1198// @desc make a loop over Trigger conditions
1199//
1200// @return TRUE: we'll make it; FALSE: we won't
1201//
1202//------------------------------------------------------------
1203// @function
1204
1205//!@{
1206int
1207get_Trigger_Loop(int *lt, int *ut, int *lm, int *um, int *lg, int *ug)
1208{
1209 *lt=Trigger_loop_lthres;
1210 *ut=Trigger_loop_uthres;
1211 *lm=Trigger_loop_lmult;
1212 *um=Trigger_loop_umult;
1213 *lg=Trigger_loop_ltop;
1214 *ug=Trigger_loop_utop;
1215 return ( Trigger_Loop );
1216}
1217//!@}
1218
1219//!-----------------------------------------------------------
1220// @name Trigger_Single
1221//
1222// @desc fix Trigger conditions
1223//
1224//------------------------------------------------------------
1225// @function
1226
1227//!@{
1228void
1229get_Trigger_Single(float *t, int *m, int *g)
1230{
1231 for(int i=0;i<TRIGGER_PIXELS;i++)
1232 t[i]=qThreshold[i];
1233 *m=Trigger_multiplicity;
1234 *g=Trigger_topology;
1235
1236}
1237//!@}
1238
1239//!-----------------------------------------------------------
1240// @name get_teles_axis
1241//
1242// @desc give axis of the telescope
1243//
1244//------------------------------------------------------------
1245// @function
1246
1247//!@{
1248void get_teles_axis(float *th, float *p){
1249 *th=Telescope_axis_th;
1250 *p=Telescope_axis_ph;
1251}
1252//!@}
1253
1254//!-----------------------------------------------------------
1255// @name get_source_off
1256//
1257// @desc give the offset of the source to the center of the camera
1258//
1259//------------------------------------------------------------
1260// @function
1261
1262//!@{
1263void get_source_off(float *th, float *p){
1264 *th=Source_offset_th;
1265 *p=Source_offset_ph;
1266}
1267//!@}
1268
1269//!-----------------------------------------------------------
1270// @name get_corsika_vers
1271//
1272// @desc give the vrsion of corsika
1273//
1274//------------------------------------------------------------
1275// @function
1276
1277//!@{
1278int get_corsika_ver(void){
1279 return(Corsika_vers);
1280}
1281//!@}
1282
1283
1284//=------------------------------------------------------------
1285//!@subsection Log of this file.
1286
1287//!@{
1288//
1289// $Log: not supported by cvs2svn $
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.