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

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