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

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