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

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