1 /****************************************************************************/
2 /* This is rdmc.h - some routines for reading mc and preprocessed data */
3 /* Here are the following units used: meter, nanosecond, radian, MeV */
4 /****************************************************************************/
5 /* Version: $Header: /net/local/cvsroot/siegmund/rdmc/rdmc.h,v 1.188 2004/04/21 14:37:46 wiebusch Exp $ */
19 ////#include <malloc.h>
24 /*****************************/
25 /* general definitions - *******/
26 /*****************************/
30 #define RDMC_MAXCHANNELS 16384
31 #define MAXCHANNELS RDMC_MAXCHANNELS /* OBSOLETE */
33 #define RDMC_MAXLINE 10000 /* maximal input line for the asccii format */
34 #define F2000_MAXLINE 10000
36 #define RDMC_MAXDIGI 4096 /* max. number of digitizations */
38 #define RDMC_MAXTRIGID 8*(sizeof(long)) /* size of a bitmask */
40 #define RDMC_MAXTOKENLENGTH 64 /* maximal token length in f2000 */
41 /* #define RDMC_MAXTOKEN_PER_LINE 250*/ /* maximum user words per line */
42 #define RDMC_MAXTOKEN_PER_LINE 1000 /* maximum user words per line */
43 #define RDMC_MAXUSER_PER_LINE RDMC_MAXTOKEN_PER_LINE /* maximum user words per line */
47 #define RDMC_BIG 1e6 /* a big value (in meter) */
48 #define RDMC_SMALL 1e-9 /* a small value */
49 #define BIG RDMC_BIG /*obsolete */
50 #define SMALL RDMC_SMALL /* obsolete */
52 /* some special values converting the f2000 */
53 #define RDMC_NA -1 /* "not available" number (a quick hack) */
54 #define RDMC_NOT_AV RDMC_NA /* an alias, dont use it */
55 #define RDMC_PARENT_NA -1 /* this is the parent id for noise hits */
56 #define RDMC_PARENT_NOISE -2 /* this is the parent id for noise hits */
57 #define RDMC_PARENT_AFPULS -3 /* this is the parent id for afterpulse hits */
58 #define RDMC_REPEAT_CH -2 /* no adc value because it was already given away */
59 #define RDMC_TDC_NA -RDMC_BIG
60 #define RDMC_SPECIAL_NA -RDMC_BIG
61 #define RDMC_WF_BASELINE_NA -RDMC_BIG
62 #define RDMC_RSORTAMP_ALL 0
63 #define RDMC_RSORTAMP_FIRST 1
64 #define RDMC_RSORTAMP_TOT 2
66 /* special nan values: */
67 #define RDMC_LONGI_NA RDMC_BIG /* ARRAY lattitude */
68 #define RDMC_LATTI_NA RDMC_BIG /* ARRAY longitude */
69 #define RDMC_DEPTH_NA RDMC_BIG /* ARRAY depth longitude */
71 #define RDMC_DINFTY DBL_MAX /* double infinity */
72 #define RDMC_FINFTY FLT_MAX /* singkle infinity */
73 #define RDMC_IINFTY INT_MAX /* integer infinity */
74 #define RDMC_LINFTY LONG_MAX /* long integer infinity */
76 #define RDMC_SMALL_THRESH 0.01
77 #define RDMC_DEFAULT_DEPTH -1730.00
78 #define RDMC_MIN_ION_ENERGY 100e3
80 /****** error messages */
82 RDMC_EOF=EOF, /* end of file from <stdio.h>, usually -1 */
83 RDMC_ILF=-10 , /* error value: invalid format! */
84 RDMC_UNKNOWN_FORMAT=-11, /* format could not be detected */
85 RDMC_UNKNOWN_FORMAT_VERSION=-12, /* format version is not suported */
86 RDMC_INCONSISTENT_GEOMETRY=-13, /*something fishy in the file header*/
87 RDMC_LINE_NOT_PARSED=-14, /* input line is not parsed */
88 RDMC_TOO_MANY_CHANNELS=-15, /* OM number larger RDMC_MAXCHANNEL */
89 RDMC_HEADERTAG_NOTFOUND=-16, /* the current mevt special was not */
90 /* defined in the header */
91 RDMC_EVENT_NOT_RECOGNIZED=-17, /* the f2k block was not identified */
92 RDMC_EE_NOT_RECOGNIZED=-18, /* the end of an f2k block not found */
93 RDMC_LINE_EMPTY=-19, /* the line is only white (not really an error */
94 RDMC_LIBRARY_ERROR=-20, /* a programming error in the rdmc library */
95 RDMC_IO_OK=0 /* everythings fine */
99 #define BAIKAL_BIN_F 0 /* format id for the baikal-like bin format */
100 #define DUMAND_ASCII_F 1 /* format id for the dumand-like ASCII format */
101 #define UWI_ASCII_F 2 /* format id for the ASCII used by Jacobsen etal */
102 #define STOCKHOLM_BIN_F 3 /* format id for swedish amanda binary format */
103 #define AMANDA_ASCII_F 4 /* the proposed AMANDA format (aka "F2000") */
104 #define F2000_F AMANDA_ASCII_F
105 #define RDMC_DEFAULT_ASCII_F AMANDA_ASCII_F
107 /****** Current implemented format versions ********/
109 #define DUMAND_ASCII_VERSION -7 /* ASCII version format id */
110 #define UWI_ASCII_VERSION 3
111 #define AMANDA_ASCII_VERSION 2004 /* minor number; major expected to be 1 */
112 #define AMANDA_ASCII_MINOR 1 /* minor number; major expected to be 1 */
114 /* baikal format dialects */
115 #define BAIKAL_MOS -1 /* id for the moscow bin format */
116 #define BAIKAL_OLD 0 /* id for the old zeuthen bin format */
117 #define BAIKAL_NEW 1 /* id for the new zeuthen bin format */
119 #define DEFAULT_UWI_GEO_FILE "amanda.geo"
120 #define DEFAULT_UWI_GEO_FILE_ENV "RDMC_UWI_GEO_FILE"
121 #ifdef RDMC_DIRTY_AMANDA_ADC /* very ugly */
122 #define UWI_CHANNELS_PER_PE 120. /* number of adc channels per p.e. */
125 #define UWI_CHANNELS_PER_PE 1. /* number of adc channels per p.e. */
127 /* some conventions */
129 #define RDMC_READ_MODE 0
130 #define RDMC_WRITE_MODE 1
132 /****** event types */
135 RDMC_EVENT_HEADER_PREF,
152 NT_36 = 1003 , /* array id for the baikal = telescope */
162 #define QUASAR 1000000 /* Quasar pmt id */
163 #define STD_AMANDA_A_OM 2030030
164 #define STD_AMANDA_B_OM 2020021
165 #define STD_AMANDA_B_10_OM 2020121
166 #define AMANDA_HYBRID 2020221
167 #define RDMC_DEFAULT_OM STD_AMANDA_B_OM
169 /* calibration status */
170 /* the entry array_calib_t is a bitmask of these */
171 #define RDMC_CALIB_TDC 0x01
172 #define RDMC_CALIB_ADC 0x02
173 #define RDMC_CALIB_TOT 0x04
174 #define RDMC_CALIB_GEO 0x08
182 #define MUON_PLUS 5 /* particle id for a mu+ */
183 #define MUON_MINUS 6 /* particle id for a mu- */
184 #define MUON MUON_PLUS /* default: mu+ */
197 #define NU_EL_BAR 204
198 #define NU_MU_BAR 205
199 #define NU_TAU_BAR 206
201 #define BREMS 1001 /* particle id for bremsstrahlung */
202 #define DELTAE 1002 /* delta electron */
203 #define PAIRPROD 1003 /* pair production */
204 #define NUCL_INT 1004 /* nuclear interaction */
205 #define MU_PAIR 1005 /* muon pair */
207 #define FIBERLASER 2100 /* Fiber laser (Baikal or Amanda calib laser) */
208 #define N2LASER 2101 /* N2 laser firing in water or ice */
209 #define YAGLASER 2201 /* YAG laser firing in water or ice */
210 #define Z_PRIMARY 3000 /* CR primary with Z xxx start here */
211 #define A_PRIMARY 3500 /* CR primary with A xxx start here */
213 /* which command to use for retrieving of remote files */
214 #define ALLOW_REMOTE /* allow writing/reading of remote files */
215 #define RSH_CMD_ENV "RDMC_RSH" /* name of the environment variable */
217 /* sorting tags which are allowed by rdmc_sort_hits */
219 RDMC_NO_SORT=0, /* no hit sorting */
220 RDMC_CH_SORT=1, /* sort hits by channels */
221 RDMC_TM_SORT=2, /* sort hits by hit time */
222 RDMC_CZ_SORT=3, /* sort hits by hit channel depth */
223 RDMC_ID_SORT=4, /* sort hits by mhit-id */
224 RDMC_MT_SORT=5 /* sort hits by mt-id */
227 /* types of possible MCinfo inquireies */
228 /* used by rdmc_which_gen in rdmc_genutl.c */
230 enum RDMC_GENINFO_T {
231 MOST_HITS_MUON=1 /* muon responsible for most hits in the event */
232 , HIGHEST_ENERGY_MUON /* the most energetic muon */
233 , CLOSEST_MUON /* the closest track to the detector centre */
234 , FIRST_HIT_MUON /* the muon which makes the first hit */
235 , MOST_HITS_SHOWER /* shower responsible for most hits in the event */
236 , HIGHEST_ENERGY_SHOWER /* the most energetic shower */
237 , ANY_PRIMARY /* the first Primary in the file */
238 , CR_PRIMARY /* the CR PRIMARY */
239 , NEUTRINO_PRIMARY /* the first(index) neutrino primary in event */
242 /********************************** data structures *************************/
246 /************** structures for the maintainance of different formats ********/
249 char parse_line[RDMC_MAXLINE]; /* line buffer during I/O f2k */
250 int unread; /* this flag is 1 if the line is unread */
251 int errline; /* file line where a parse error occurs */
252 int nolex; /* if on, the event is not parsed and can not be used further */
253 struct rdmc_f2k_buffer_s *f2k_buffer; /* this is defined in f2k.h */
257 int mc_id; /* mc id character */
258 /* 'U' = unknown, 'D' =data, 'M' = MC, 'G' = event generator */
259 char mc_vers[RDMC_MAXLINE]; /* mc program version */
260 int igtrack; /* presently unused -1*/
261 int igen; /* id for the generator program */
262 int igeo; /* identifier for expoeriment type */
263 int daswrun; /* Random generator seed */
264 time_t time; /* mc creation date (obsolete) */
265 int nrun; /*run number */
269 int mc_id; /* mc id character */
270 /* 'U' = unknown, 'D' =data, 'M' = MC, 'G' = event generator */
271 char mc_vers[RDMC_MAXLINE]; /* mc program version */
275 int mc; /* 0 - data file, 1 - mc */
276 int swap; /* 1 - Bytes are swapped, 0 - not swapped */
277 int fortran_recs; /* was it a formatted fortran file? */
278 int nw_rec_arr; /* number of words in reco sub header (baikal_bin only)*/
279 int nw_rec_evt; /* number of words in reco sub record (baikal_bin only)*/
280 int rec_vers; /* reco program version (baikal_bin only)*/
281 int min_vers; /* minimization procedure applied (baikal_bin only)*/
282 int enr; /* current event number OBSOLETE */
283 int mc_id; /* mc id character */
284 /* 'U' = unknown, 'D' =data, 'M' = MC, 'G' = event generator */
285 char mc_vers[RDMC_MAXLINE]; /* mc program version */
286 int igtrack; /* presently unused -1*/
287 int igen; /* id for the generator program */
288 time_t time; /* mc creation date (obsolete) */
289 int nrun; /*run number */
292 /* a union type for the mcfile structure */
298 } rdmc_special_format_info_t;
302 FILE *fp; /* this is the file pointer */
303 int mode; /* read or write mode */
304 int format; /* Format: baikal/siegmund/amanda/... */
305 int fpos; /* file position (line nr or byte nr) */
306 int fmajor; /* format version */
307 int fminor; /* minor version number */
308 int zipped; /* == 1 if the file was zipped */
309 int errline; /* source line where an format error occurs */
310 char last_line[RDMC_MAXLINE]; /* buffer for the last input line */
311 /* set to [0]=0 if nothing inside */
312 int sloppy; /* sloppy access to data -> force events after error */
313 char *creator; /* string that points to the History lines */
314 char *comment; /* string that points to the top comment lines */
315 rdmc_special_format_info_t info; /* format specific stuff */
318 /* now the event header structures for CALIBRATION */
321 float beta_t; /* TDC resolution, nsec/channel */
322 float t_0; /* time shift, nsec */
323 float alpha_t; /* amplitude dependend time calibration, nsec*sqrt(ADC) */
324 float ped; /* amplitude pedestal, channels */
325 float beta_a; /* ADC resolution, p.e./channel */
326 float kappa; /* amplitude nonlinearity, p.e. */
327 float ped_tot; /* tot pedestal, channels */
328 float beta_tot; /* TOT resolution, p.e./channel */
329 float kappa_tot; /* tot nonlinearity, p.e. */
330 int flag; /* != 0 if this is a valid calib entry -> RDMC_CALIB_... */
334 char utc_src[RDMC_MAXTOKENLENGTH]; /* source of this calibration */
335 int secs; /* time correction to.be. */
336 int nsecs; /* applied to the event time */
340 int geo; /* 1 if calibration was done */
341 int adc; /* 1 if calibration was done */
342 int tdc; /* 1 if calibration was done */
343 int tot; /* 1 if calibration was done */
344 int utc; /* 1 if calibration was done */
345 } array_calib_stat_t; /* 1 if calibration was done */
347 /* now various header definitions */
351 char tag[RDMC_MAXTOKENLENGTH];
355 char words[RDMC_MAXTOKEN_PER_LINE][RDMC_MAXTOKENLENGTH];
356 char pars[RDMC_MAXTOKEN_PER_LINE][RDMC_MAXTOKENLENGTH];
358 char *words[RDMC_MAXTOKENLENGTH];
359 char *pars[RDMC_MAXTOKENLENGTH];
365 int id; /* geometry id */
366 int nch; /* number of channels */
367 int nstr; /* number of strings */
368 float longitude; /* detector location longitude, [degrees] */
369 float lattitude; /* detector location lattitude, [degrees] */
370 float depth; /* detector depth, [m] */
371 int nrun; /* run number */
372 /* geometry follows */
373 int str[RDMC_MAXCHANNELS]; /* string number */
374 int clust[RDMC_MAXCHANNELS]; /* channel number */
375 float x[RDMC_MAXCHANNELS]; /* x coordinate in meters */
376 float y[RDMC_MAXCHANNELS]; /* y coordinate in meters */
377 float z[RDMC_MAXCHANNELS]; /* z coordinate in meters */
378 float costh[RDMC_MAXCHANNELS]; /* cos theta of the channel (+1=up/-1=dn) */
379 int type[RDMC_MAXCHANNELS]; /* OM type */
380 int serial[RDMC_MAXCHANNELS]; /* serial number of channel */
381 float thresh[RDMC_MAXCHANNELS]; /* thresholds of all pmt */
382 float sensit[RDMC_MAXCHANNELS]; /* sensitivities of all pmt */
383 /* values of the dynamic allocation */
384 int n_trigger; /* number of triggers */
385 int n_user; /* number of userdef lines */
386 int n_fit; /* number of fit def lines */
387 int n_stat; /* number of status defs */
388 int n_mcinfo; /* number of mcinfo's */
389 /* time of the file */
390 time_t tbegin; /* mc creation date */
391 time_t tend; /* mc end date */
393 array_calib_stat_t is_calib; /* which calibrations have been done*/
394 array_calib_t cal[RDMC_MAXCHANNELS]; /* time/amplitude calibration */
395 array_calib_utc_t cal_utc; /* utc calibration */
397 array_hdef_t *def_trig;
399 array_hdef_t *def_user; /* NULL or an array of user line defs */
401 array_hdef_t *def_fit; /* NULL or an array of fit line defs */
402 /* status == housekeeping */
403 array_hdef_t *def_stat; /* see above */
404 /* mcinfo, still a dummy */
405 array_hdef_t *def_mcinfo; /* mcinfos types */
406 /* uniqe array id attached by init and clear */
407 unsigned long int array_id;
409 char *comment; /* comment line: a '\0' terminated string or NULL */
410 void *tmp; /* a stack to hold anything */
411 } array; /* geometric and technic array info of the telescope */
414 /* now the new arry structure */
416 int id; /* unique channel id */
417 int type; /* type of this channel */
418 float thresh; /* diskriminator threshold */
419 array_calib_t cal; /* time/amplitude calibration constants*/
424 int id; /* channel id */
425 int type; /* OM type */
426 int serial; /* serial number of OM */
427 int str; /* string number */
428 int clust; /* OM number in string */
429 int x; /* x coordinate in meters */
430 int y; /* y coordinate in meters */
431 int z; /* z coordinate in meters */
432 int costh; /* cos theta orientation (+1=up/-1=dn) */
433 int sensit; /* rel. sensitivity of the pmt */
434 int n_ch; /* number of readout channels */
435 mch_def_t *ch; /* field of nch readoutchannels */
439 unsigned long int array_id; /* uniqe array id created by init and clear */
440 int id; /* geometry id */
441 float longitude; /* detector location longitude, [degrees] */
442 float lattitude; /* detector location lattitude, [degrees] */
443 float depth; /* detector depth, [m] */
444 int nstr; /* number of strings */
445 int n_om; /* number of OM */
446 int n_trigger; /* number of triggers */
447 int n_user; /* number of userdef */
448 int n_fit; /* number of fit def lines */
449 int n_stat; /* number of status defs */
450 int n_mcinfo; /* number of mcinfo's */
451 mom_def_t *om; /* field of nom OM's */
452 array_calib_stat_t is_calib; /* which calibrations have been done*/
453 array_calib_utc_t cal_utc; /* utc calibration */
454 array_hdef_t *def_trig; /* n_trigger triggerdefs*/
455 array_hdef_t *def_user; /* n_user line defs */
456 array_hdef_t *def_fit; /* n_fit fit defs */
457 array_hdef_t *def_stat; /* n_stat fit defs */
458 array_hdef_t *def_mcinfo; /* n_mcinfo fit defs */
459 char *comment; /* comment line: a '\0' terminated string or NULL */
460 void *tmp; /* a stack to hold anything */
461 } mhead_t; /* structure for the file header/definitions */
465 /* now the event related structures */
469 int nuses; /* number of hits */
470 int *id; /* the hit id */
472 int hitid; /* id of the hit */
473 int useid; /* id of the fit or the trigger */
480 int id; /* identifier/index of e.g. the trigger */
482 float val[RDMC_MAXTOKEN_PER_LINE]; /*the values defined e.g. in the TRIG_DEF line */
489 int id; /* particle id (muon+: id = 5) */
490 float e; /* energy in MeV */
491 float x,y,z; /* parameter of a track point in m */
492 float t; /* time in nsec corresponding the point xyz */
493 float costh; /* theta cosinus of the muon track */
494 float phi; /* phi value in radians */
495 float px, py, pz; /* direction cosinuus */
496 float length; /* length of the track, or BIG if infinity */
497 int nmuon; /* obsolete (baikal only) */
498 int parent; /*track which is mother of this one */
499 int tag; /* unique tag for this track */
500 float weight; /* weight of this track */
501 int nuser; /* DUMMY presently ! */
502 mevt_special_t *user; /* the user words */
503 char *comment; /* comment line: a '\0' terminated string or NULL */
504 void *tmp; /* a stack to hold anything */
505 } mtrack; /* track info from mc, reconstructed, etc */
513 int ch; /* channel number (0,..)*/
514 int str; /* string number (1...str) */
515 float t; /* time in nsec (Leading edge) */
516 float amp; /* amplitude of each channel */
517 float tot; /* time over threshold (nsec) */
518 int mt; /* muon id for this hit (time) */
519 int ma; /* muon id for this hit (amplitude) */
520 int id; /* a unique hit id */
521 float weight; /* weight of this hit */
522 mhit_stat_t hstat; /* some status flags for the channel of this hit */
523 int nuser; /* DUMMY presently ! */
524 mevt_special_t *user; /* the user words */
525 char *comment; /* comment line: a '\0' terminated string or NULL */
526 void *tmp; /* a stack to hold anything */
527 } mhit; /* hit structure */
532 int id; /* a unique WF id */
533 int om; /* OM number */
534 int ch; /* digitizer number */
535 int pa; /* parent id */
536 int ndigi; /* numer of digitizations*/
537 float t_start; /* time of 1. digitization */
538 float t_bin; /* width of time bins */
539 float baseline; /* running mean of baseline */
540 float *digi; /* amplitude digitizations */
541 } waveform; /* waveform structure */
545 int nrun; /* run number */
546 int enr; /* event number */
547 int mjd; /* modified julian day */
548 int secs; /* time in sec after mjd */
549 int nsecs; /* Nanosec part of time */
550 float t_offset; /* time offset; all hits should be centered by time */
551 float weight; /* weight of this event */
552 int ee; /* 1: end of event corectly tagged */
553 int nch; /* number of channels hitted */
554 int nstr; /* number of hitted strings */
555 int nhits; /* number of hits */
556 int nwf; /* number of wafeform digitizations */
557 int ntrack; /* number of mc tracks */
558 int nfit; /* number of fitted tracks AND fitresults */
559 int nuser; /* number of user blocks */
560 int nstat; /* number of status blocks */
561 int ntrig; /* number of triggers */
562 int nmcinfo; /* number of mcinfo blocks (dummy) */
564 int ntrig_uses; /* number of uses words for triggers*/
565 int nfit_uses; /* number of uses words for fits */
567 enum RDMC_SORT_T sort_status; /* sort status of hits, def: RDMC_NO_SORT */
568 unsigned long int event_id; /* uniqe event id attached by init and clear */
569 unsigned long trigger; /* bitmap of the trigger */
570 unsigned long trigid; /* bitmap of the trigger id's */
571 mhit *h; /* pointer to all hits (allocated by revt()) */
572 waveform *wf; /* pointer to all waveform digitizations */
573 mtrack *gen; /* pointer to the generated tracks, or NULL */
574 mtrack *rec; /* pointer to the reconstructed tracks, or NULL */
575 mevt_special_t *fresult; /* the reco results words */
576 mevt_special_t *user; /* the user words */
577 mevt_special_t *status; /* the status words */
578 mevt_special_t *ptrig; /* the trigger words */
579 mevt_special_t *mcinfo; /* the mcinfo words (dummy) */
581 mevt_uses_t *trig_uses; /* the trigger uses words */
582 mevt_uses_t *fit_uses; /* the fit uses words */
584 char *comment; /* comment line: a '\0' terminated string or NULL */
585 void *tmp; /* a stack to hold anything */
589 /* structure that holds converions between strings and numbers */
595 /* some tables defined in rdmc_local.c */
596 extern const rdmc_idtable_t rdmc_pmt_idtable[];
597 extern const rdmc_idtable_t rdmc_sphere_idtable[];
598 extern const rdmc_idtable_t rdmc_datatrans_idtable[];
599 extern const rdmc_idtable_t rdmc_detector_idtable[];
600 extern const rdmc_idtable_t rdmc_particle_idtable[];
603 /********************************** functions *******************************/
605 /*###########################################*/
606 /***** in rdmc.c ********/
607 /*###########################################*/
608 void rdmc_write_parameters(mcfile *fp, int argc, char **arg, const char *version);
609 /* add the current program name to the creator's list (HISTORY) */
611 void rdmc_append_comment(char **comment, const char *src);
612 /* reallocates comment (it must be NULL, or already malloced) */
613 /* then appends the string src via strcat */
615 void rdmc_concat_comment(char **comment, const char *src, const int form);
616 /* reallocates comment (it must be NULL, or already malloced) */
617 /* then appends the string src via strcat */
618 /* prvide with form=mcfile.format, e.g. F2000_F */
622 /*###########################################*/
623 /***** in rdmc_mcopen.c ********/
624 /*###########################################*/
625 mcfile *rdmc_mcopen(const char *name, const char *mode, int format); /* opens a mc/data file */
626 int rdmc_mcclose(mcfile *fp); /* closes a mc/data file */
629 /*###########################################*/
630 /**** in rdmc_mcfile.c *****/
631 /*###########################################*/
632 void rdmc_init_mcfile(mcfile *fp, int format, int mode, FILE *ft); /* init */
633 void rdmc_free_mcfile(mcfile *fp); /*free */
634 int rdmc_mccpfp(const mcfile *src, mcfile *dest); /* copy run parameters */
638 /*###########################################*/
639 /**** in rdmc_mhead.c *****/
640 /*###########################################*/
641 void rdmc_init_mhead(mhead_t *a);
642 void rdmc_clear_mhead(mhead_t *a);
643 void rdmc_free_mhead(mhead_t *a);
645 /***** now function for the header_def and header_def_par */
646 /* functions return 0 on success, 1 else */
647 int rdmc_mhead_add_user_def(mhead_t *mh, array_hdef_t *user, int iuse);
648 int rdmc_mhead_del_user_def(mhead_t *mh , int iuse);
649 int rdmc_mhead_add_stat_def(mhead_t *mh, array_hdef_t *sta, int ista);
650 int rdmc_mhead_del_stat_def(mhead_t *mh, int ista);
651 int rdmc_mhead_add_fit_def(mhead_t *mh, array_hdef_t *fd, int ifd);
652 int rdmc_mhead_del_fit_def(mhead_t *mh, int ifd);
653 int rdmc_mhead_add_mcinfo_def(mhead_t *mh, array_hdef_t *mc, int imc);
654 int rdmc_mhead_del_mcinfo_def(mhead_t *mh, int imc);
655 int rdmc_mhead_add_trigger_def(mhead_t *mh, array_hdef_t *t, int it);
656 int rdmc_mhead_del_trigger_def(mhead_t *mh, int it);
658 int rdmc_mhead_add_mom(mhead_t *mh, mom_def_t *om, int ipos);
662 /*###########################################*/
663 /**** in rdmc_mom.c *****/
664 /*###########################################*/
665 void rdmc_init_mom(mom_def_t *ch);
666 void rdmc_clear_mom(mom_def_t *ch);
667 void rdmc_free_mom(mom_def_t *ch);
670 /*###########################################*/
671 /**** in rdmc_mch.c *****/
672 /*###########################################*/
674 void rdmc_init_mch(mch_def_t *ch);
675 void rdmc_clear_mch(mch_def_t *ch);
676 void rdmc_free_mch(mch_def_t *ch);
680 /*###########################################*/
681 /**** in rdmc_array_calib.c *****/
682 /*###########################################*/
684 void rdmc_init_array_calib(array_calib_t *c);
685 void rdmc_clear_array_calib(array_calib_t *c);
686 void rdmc_free_array_calib(array_calib_t *c);
688 void rdmc_init_array_calib_stat(array_calib_stat_t *cs);
689 void rdmc_clear_array_calib_stat(array_calib_stat_t *cs);
690 void rdmc_free_array_calib_stat(array_calib_stat_t *cs);
691 void rdmc_init_array_calib_utc(array_calib_utc_t *cu);
692 void rdmc_clear_array_calib_utc(array_calib_utc_t *cu);
693 void rdmc_free_array_calib_utc(array_calib_utc_t *cu);
696 /*###########################################*/
697 /**** in array2mhead.c *****/
698 /*###########################################*/
699 /* target has to be allocated and initilized/cleared (freed memory) */
700 int rdmc_array2mhead(const array *ar, mhead_t *mh);
701 int rdmc_mhead2array(const mhead_t *mh, array *ar);
704 /*###########################################*/
705 /**** in rdmc_array.c *****/
706 /*###########################################*/
707 void rdmc_init_array(array *ar); /* structures */
708 void rdmc_free_array(array *ar);
709 void rdmc_clear_array(array *ar); /* clear the array structure */
710 int rdmc_rarr(mcfile *fp, array *ar); /* read the array info from the begin */
711 int rdmc_warr(mcfile *fp, const array *ar); /* writes array info to file */
712 int rdmc_comp_array(const array *a1, const array *a2);/* compares two geometries */
713 /* returns 0 if they are equal */
714 /* else it returns the ored result of: */
715 #define RDMC_ARRAY_COMP_OK 0x0000 /* all OK*/
716 #define RDMC_ARRAY_COMP_HEADER 0x01
717 #define RDMC_ARRAY_COMP_GEO 0x02
718 #define RDMC_ARRAY_COMP_OMS 0x04
719 #define RDMC_ARRAY_COMP_CALIB 0x08
720 #define RDMC_ARRAY_COMP_TRIGGER 0x10
721 #define RDMC_ARRAY_COMP_USER 0x20
722 #define RDMC_ARRAY_COMP_FIT 0x40
723 #define RDMC_ARRAY_COMP_STATUS 0x80
724 #define RDMC_ARRAY_COMP_MC 0x100
726 void rdmc_cp_array(array *out, const array *in);/* copies two geometries */
728 /***** now function for the header_def and header_def_par */
729 /* functions return 0 on success, 1 else */
730 int rdmc_array_add_user_def(array *ar, array_hdef_t *user, int iuse);
731 int rdmc_array_del_user_def(array *ar , int iuse);
732 int rdmc_array_add_stat_def(array *ar, array_hdef_t *sta, int ista);
733 int rdmc_array_del_stat_def(array *ar, int ista);
734 int rdmc_array_add_fit_def(array *ar, array_hdef_t *fd, int ifd);
735 int rdmc_array_del_fit_def(array *ar, int ifd);
736 int rdmc_array_add_mcinfo_def(array *ar, array_hdef_t *mc, int imc);
737 int rdmc_array_del_mcinfo_def(array *ar, int imc);
738 int rdmc_array_add_trigger_def(array *ar, array_hdef_t *t, int it);
739 int rdmc_array_del_trigger_def(array *ar, int it);
742 /* temporary until array is really nuked */
743 #define rdmc_add_user_def rdmc_array_add_user_def
744 #define rdmc_del_user_def rdmc_array_del_user_def
745 #define rdmc_add_stat_def rdmc_array_add_stat_def
746 #define rdmc_del_stat_def rdmc_array_del_stat_def
747 #define rdmc_add_fit_def rdmc_array_add_fit_def
748 #define rdmc_del_fit_def rdmc_array_del_fit_def
749 #define rdmc_add_mcinfo_def rdmc_array_add_mcinfo_def
750 #define rdmc_del_mcinfo_def rdmc_array_del_mcinfo_def
751 #define rdmc_add_trigger_def rdmc_array_add_trigger_def
752 #define rdmc_del_trigger_def rdmc_array_del_trigger_def
755 /* copies all information for channel in_i from geometry *in */
756 /* to channel out_i into geometry *out */
757 void rdmc_channel_cp(array *out,int out_i,const array *in ,int in_i);
759 /* in order to create objects one needs unique id's*/
760 /* these functions return them */
763 /* this function returns a uniqe id AND builds a uniqe tag string */
764 /* on basis of tag_root. The resuklting tag is filled into tag */
765 /* The function should return RDMC_NA if this operation fails, */
766 /* e.g. if there are too many triggers defined */
767 /* the tag usually contains the tag_root appended by a number */
768 /* here the trigger number */
769 int rdmc_unique_trigger_id(char *tag, const array *ar, const char *tag_root);
770 int rdmc_unique_user_id(char *tag, const array *ar, const char *tag_root);
771 int rdmc_unique_stat_id(char *tag, const array *ar, const char *tag_root);
774 /*###########################################*/
775 /**** in rdmc_hdef.c *****/
776 /*###########################################*/
778 /* add a new initilized header def */
779 int rdmc_add_array_hdef(array_hdef_t **list,
781 array_hdef_t *new_ahdt, int ipos);
782 /* remove header def */
783 int rdmc_del_array_hdef(array_hdef_t **list,
784 int *count, int ipos);
787 /* copy two structures */
788 void rdmc_cp_hdef(array_hdef_t *out, const array_hdef_t *in);
789 /* init the structures rdmc_init_array_hdef*/
790 void rdmc_init_array_hdef(array_hdef_t *def);
791 void rdmc_clear_array_hdef(array_hdef_t *def);
792 void rdmc_free_array_hdef(array_hdef_t *def);
794 /* compares two structures, retyurns 0 if they are the same or the
795 number of differences */
796 int rdmc_comp_array_hdef(const array_hdef_t *d1,
797 const array_hdef_t *d2);
798 /* search an array of ndef array_hdef_t elements */
799 /* find the number of a header definition */
800 /* returns the number 0..(ndef-1) or RDMC_NA */
801 int rdmc_get_hdef_tag(const array_hdef_t *hd, int ndef, const char *tag); /*according to the tag */
802 int rdmc_get_hdef_id(const array_hdef_t *hd, int ndef,int id); /*according to an id */
804 /* get a unique id for a new def object */
805 int rdmc_unique_hdef_id(const array_hdef_t *p, int ndef);
807 /* get a unique tag for a new def object. It is the tag_root itself
808 * as long it is unique, or the tag_root with a number at the end */
809 int rdmc_unique_hdef_tag(char *tag,const array_hdef_t *p, int ndef,const char *tag_root);
811 /* returns the index of the string token in the list of hdef parameters */
812 /* if the token is not found RDMC_NA is returned */
813 int rdmc_token_in_hdef(const array_hdef_t *p, const char *token);
816 /*###########################################*/
817 /*********** in rdmc_mevt.c **************/
818 /*###########################################*/
819 int rdmc_revt(mcfile *fp, array *ar, mevt *ev); /* reads an event */
820 int rdmc_skipevt(mcfile *fp); /* skips over the next event record */
821 int rdmc_wevt(mcfile *fp, const mevt *ev, const array *ar); /* writes an event */
823 /**** init = set to default values ****/
824 /*** clear = free also memory *****/
825 void rdmc_init_mevt(mevt *ev); /* init the mevt structure */
826 void rdmc_clear_mevt(mevt *ev); /* clear the mevt structure */
827 void rdmc_free_mevt(mevt *ev); /* free the internal mevt structure */
829 /* counts number of hit channels in an event */
830 /* returns number of hit channels */
831 int rdmc_count_nch(const mevt *e);
832 /* counts number of hit strings in an event */
833 /* returns number of hit strings */
834 int rdmc_count_nstr(const mevt *e);
835 /* fill the string number into mhit */
836 int rdmc_fill_mhit_str(mevt *ev, const array *ar);
837 /* ( rdmc_fill_mhit_str rdmc_count_nstr, replace the old function ns_evt) */
840 /* Routine to copy datastructures from one event (*in) to another (*out) */
841 /* *out has to be allocated by the user before via: */
842 /* out = (mevt *) malloc(sizeof(mevt); */
843 /* the space required for internal substructures e.g. mtrack,mhit */
844 /* is mallocated during execution of this routine */
845 /* return value is 0 */
846 /* previously allocated memory e.g. in tracks is NOT freed ! */
847 /* in case you want to free first call: rdmc_clear_mevt(out) first */
848 int rdmc_cp_mevt(mevt *out, mevt *in);
850 /* now functions which add specific values */
851 /* return value is 0 if OK */
852 /* and 1 on failure */
853 int rdmc_add_gen(mevt *ev, mtrack *tr, int itrack);
854 int rdmc_del_gen(mevt *ev , int itrack);
855 int rdmc_add_fit(mevt *ev, mtrack *ft, mevt_special_t *fr, int ifit);
856 int rdmc_del_fit(mevt *ev , int ifit);
857 int rdmc_add_user(mevt *ev, mevt_special_t *us, int iu);
858 int rdmc_del_user(mevt *ev , int iu);
859 int rdmc_add_status(mevt *ev, mevt_special_t *fr, int ifr);
860 int rdmc_del_status(mevt *ev , int ifr);
861 int rdmc_add_mcinfo(mevt *ev, mevt_special_t *mci, int imci);
862 int rdmc_del_mcinfo(mevt *ev , int imci);
863 int rdmc_add_trigger(mevt *ev, mevt_special_t *tr, int it, int id);
864 int rdmc_del_trigger(mevt *ev , int it, int id);
865 int rdmc_add_trig_uses(mevt *ev, mevt_uses_t *tu, int ituse);
866 int rdmc_del_trig_uses(mevt *ev , int ituse);
867 int rdmc_add_fit_uses(mevt *ev, mevt_uses_t *fu, int ifuse); /*ifuse is iuse number */
868 int rdmc_del_fit_uses(mevt *ev , int ifuse);
869 /* delete all uses for a ifit, itrig or ihit */
870 int rdmc_del_ifit_uses(mevt *ev, int fitid);
871 int rdmc_del_itrig_uses(mevt *ev, int trigid);
872 int rdmc_del_ihit_uses(mevt *ev, int hitid);
874 int rdmc_add_mhit(mevt *ev, mhit *h, int ihit);
875 int rdmc_del_mhit(mevt *ev , int ihit);
877 int rdmc_add_WF(mevt *ev, waveform *wf, int iwf);
878 int rdmc_del_WF(mevt *ev , int iwf);
881 /* now the generic function to add initilized header def */
882 int rdmc_add_mevt_mtrack(mtrack **list, int *count, mtrack *new_mtrack,
884 int rdmc_add_mevt_special(mevt_special_t **list, int *count
885 ,mevt_special_t *new_mst, int ipos);
886 int rdmc_add_mevt_mhit(mhit **list, int *count, mhit *new_mhit, int ipos);
887 int rdmc_add_mevt_uses(mevt_uses_t **list, int *count
888 ,mevt_uses_t *new_mut, int ipos);
890 int rdmc_del_mevt_mtrack(mtrack **list, int *count, int ipos);
891 int rdmc_del_mevt_special(mevt_special_t **list, int *count, int ipos);
892 int rdmc_del_mevt_mhit(mhit **list, int *count, int ipos);
893 int rdmc_del_mevt_uses(mevt_uses_t **list, int *count, int ipos);
896 /* in order to create objects one needs unique id's*/
897 /* these functions return them */
898 int rdmc_unique_mhit_id(const mevt *ev);
899 int rdmc_unique_gen_id(const mevt *ev);
901 /* In case of corrupted hit/track ids (<0 or double counts) */
902 /* this functions assign new ids to all hits (mhit.id) */
903 /* or all MC tracks (mtrack.tag) */
904 /* if inconsitiencies are detected corresponding references */
905 /* e.g. uses, mhit.mt , mtrack.parent are deleted or set to RDMC_NA */
906 /* returns the number of id's which wer inconsistent */
907 int rdmc_repair_mhit_id(mevt *ev);
908 int rdmc_repair_gen_id(mevt *ev);
910 /* return the index of the hit hitid */
911 int rdmc_mevt_ihit(mevt *ev, int hitid);
913 /*###########################################*/
914 /*********** in rdmc_mevt_special.c **************/
915 /*###########################################*/
916 /* init the special structure to RDMC_NA */
917 /* maxtoken is for speedup, if avaliable */
918 /* - if not, set maxtoken < 0 and RDMC_MAXTOKEN_PER_LINE is taken*/
919 void rdmc_init_mevt_special(mevt_special_t *s, int maxtoken);
920 void rdmc_clear_mevt_special(mevt_special_t *s, int maxtoken);
921 void rdmc_free_mevt_special(mevt_special_t *s);
922 /* copies the special structure in to the previusly allocated out */
923 void rdmc_cp_mevt_special(mevt_special_t *out ,mevt_special_t *in);
924 /*###########################################*/
925 /*********** in rdmc_mevt_uses.c **************/
926 /*###########################################*/
927 void rdmc_init_mevt_uses(mevt_uses_t *u);
928 void rdmc_clear_mevt_uses(mevt_uses_t *u);
929 void rdmc_free_mevt_uses(mevt_uses_t *u);
930 /* copies nuses uses_t words from in to the previously allocated out */
931 void rdmc_cp_mevt_nuses(mevt_uses_t *out, mevt_uses_t *in, int nuses);
933 /* sorts the uses array for a) uses id and the hit_id */
934 void rdmc_sort_uses(mevt_uses_t *use, int nuse);
936 /* store all currently used hits as uses block as the given fit/trig num */
937 int rdmc_create_fit_uses(mevt *e, int ifit);
938 int rdmc_create_trig_uses(mevt *e, int itrig);
940 /* count the number of channels which are used by fit or trigger i*/
941 int rdmc_count_fit_nch_uses(mevt *e, array *a, int i);
944 /*###########################################*/
945 /*********** in rdmc_mtrack.c **************/
946 /*###########################################*/
947 /* init the structure */
948 void rdmc_init_mtrack(mtrack *tr);
949 void rdmc_clear_mtrack(mtrack *tr); /* free also */
950 void rdmc_free_mtrack(mtrack *tr); /* free only */
952 /* copies the track *in to *out by overwriting.
953 * If in == out, nothing is done. */
954 void rdmc_cp_mtrack(mtrack *out, const mtrack *in);
955 /* calcs the direction cosine from the entries tr.costh, tr.phi */
956 /* The entries tr.px,tr.py,tr.pz are updated */
957 void rdmc_tau_tr(mtrack *tr);
958 /* calcs the track angles costh, phi angle from tr.px,tr.py,tr.pz */
959 /* the entries tr.costh, tr.phi are updated */
960 void rdmc_tauinv_tr(mtrack *tr);
963 /*###########################################*/
964 /*********** in rdmc_mhit.c **************/
965 /*###########################################*/
966 void rdmc_init_mhit(mhit *h); /* several */
967 void rdmc_init_mhit_stat(mhit_stat_t *s);
968 void rdmc_clear_mhit(mhit *h); /* free also */
969 void rdmc_free_mhit(mhit *h); /* free also */
971 void rdmc_merge_hits(mhit *h1, mhit *h2, int ch);
972 /* merges two hits *hit_1 *hit_2 of the same channel */
973 /* filling them into *hit_1 */
974 /* - amplitudes are added */
975 /* - the earliest time of hit is taken*/
976 /* - mt is used from the earliest hit */
977 /* - ma is taken from the hit with the largest amplitude */
978 /* - ch and str remain unchanged */
979 /* - since rdmc-1.9 mhit->tot is added substracting the overlap*/
980 /* tot = tot_1 + tot_2 - (overlap) */
981 /* the amplitude of the merged hit is added only if ch=-1
982 * else the amplitude of the channel ch is used.
983 * If there is no such channel, a zero amplitude is assumed
986 void rdmc_cp_mhit(mhit *out, mhit *in);
987 /* copies the hit *in to *out by overwriting.
988 * If in == out, nothing is done.
993 /*###########################################*/
994 /*********** in rdmc_WF.c **************/
995 /*###########################################*/
996 void rdmc_init_WF(waveform *wf); /* several */
997 void rdmc_clear_WF(waveform *wf); /* free also */
998 void rdmc_free_WF(waveform *wf); /* free also */
1001 void rdmc_cp_WF(waveform *out, waveform *in);
1002 /* copies the waveform *in to *out by overwriting.
1003 * If in == out, nothing is done.
1008 /*###########################################*/
1009 /**** in rdmc_jk *******/
1010 /*###########################################*/
1011 /* this implements functions that provide compatibility to the old
1012 jk structure of rdmc-1.x */
1013 /* the indices of the special structure values in "rdmc-jk" */
1014 #define JK_N_TOKEN 8 /* number of FRESULT tokens */
1015 #define JK_FITID 0 /* an id of the fit algorithm */
1016 #define JK_RCHI2 1 /* chi2/NDF or Likelihood/nch */
1017 #define JK_PROB 2 /* some reco result parameter */
1018 #define JK_SIGTH 3 /* some reco result parameter */
1019 #define JK_COVMIN 4 /* some reco result parameter */
1020 #define JK_COVMAX 5 /* some reco result parameter */
1021 #define JK_CUTFLAG 6 /* some reco result parameter */
1022 #define JK_CHI2 7 /* chi2 or likelihood */
1024 /* initilizes a header definition as "rdmc-jk" */
1025 void rdmc_jk_to_fitdef(array_hdef_t *jk_def, int id);
1027 /* init values of fitresult as expected for "rdmc-jk" (similar to init_jk) */
1028 void rdmc_init_fit_jk(mevt_special_t *result,int id);
1030 /* checks if fresult ifit is a rdmc-jk fresult returns 1 if yes else 0*/
1031 int rdmc_is_fresult_jk(const array *ar, const mevt *ev, int ifit);
1033 /* checks if special fresult is defined as rdmc-jk returns 1 if yes
1035 int rdmc_is_this_jk(const array_hdef_t *jk_def, const mevt_special_t *result);
1037 /* returns 1 if fitdef idef (0..ar->n_fit-1) is of jk type */
1038 int rdmc_is_fitdef_jk(const array *ar,int idef);
1041 extern const array_hdef_t rdmc_jk_fit_def;
1044 /*###########################################*/
1045 /********* in rdmc_time.c **********/
1046 /*###########################################*/
1048 time_t rdmc_o_dateconv(int date); /* converts a YYMMDD date into unix time */
1049 int rdmc_o_rdateconv(time_t time); /* converts unix time into YYMMDD format */
1051 int rdmc_gps_to_mjd(int gpsyear, int gpsday); /* convert GPS date to mjd */
1052 void rdmc_mjd_to_gps(int mjd, int *gpsyear, int *gpsday); /* mjd to GPS */
1053 void rdmc_tjd_to_mjd(int tjd, double sec, int *mjd, int *secs, int *ns);
1054 /* convert truncated julian days to mjd */
1055 void rdmc_mjd_to_tjd(int mjd, int secs, int ns, int *tjd, double *sec);
1056 /* convert mjd to tjd */
1057 void rdmc_jd_to_mjd(double jd, int *mjd, int *secs, int *ns);
1058 /* convert jd to mjd */
1059 void rdmc_mjd_to_jd(int mjd, int secs, int ns, double *jd);
1060 /* convert mjd to jd */
1061 time_t rdmc_mjd_to_unixtime(int mjd, int secs); /* convert mjd in unix secs */
1062 int rdmc_unixtime_to_mjd(time_t unix_time); /* convert unix secs in mjd */
1063 int rdmc_unixtime_to_mjdsecs(time_t unix_time); /* unix secs in mjd secs */
1064 void rdmc_jd_to_gmst(double jd, double *gmst);
1065 /* Julian Days to Greenwich mean sidereal time */
1066 void rdmc_gmst_to_jd(double gmst, int intjd, double *jd);
1067 /* convert gmst to jd */
1069 /*###########################################*/
1070 /********* in rdmc_local.c **********/
1071 /*###########################################*/
1073 char *rdmc_which_format(mcfile *fp); /* returns string with the format name*/
1076 /*###########################################*/
1077 /********* in amanda.c **********/
1078 /*###########################################*/
1081 /*###########################################*/
1082 /********* in f2k_utl.c **********/
1083 /*###########################################*/
1086 int rdmc_is_f2000_supported(int major, int minor); /* returns 1 if f2000 */
1087 /*format version is supportet */
1088 /* return the rdmc value for the OM/PMT string and vive versa */
1089 int rdmc_amanda_iomid(const char *str, int ar_id);
1090 int rdmc_amanda_ipmtid(const char *str);
1091 const char *rdmc_amanda_spmtid(int type);
1092 const char *rdmc_amanda_somid(int id);
1093 /* convert rdmc particle ids to f2000 names and vice versa */
1094 int rdmc_amanda_ipartid(const char *name);
1095 const char *rdmc_amanda_spartid(int id);
1096 /* convert rdmc detector ids to f2000 names and vice versa */
1097 const char * rdmc_amanda_sdet(int geo_id); /* returns a pointer to the name */
1098 int rdmc_amanda_idet(const char *detnam); /* return the id */
1099 /* WARNING the returned pointers are static local strings, which values may change so do not work on these but imediately copy the contnt to yozur private variable */
1102 /*###########################################*/
1103 /* routines in rdmc_phys.c */
1104 /*###########################################*/
1106 /*****************************************************************************/
1107 /* global const, variables */
1108 /*****************************************************************************/
1110 extern const double rdmc_c_vacuum; /* m/nsec; light speed in vacuum */
1111 extern const double rdmc_rez_c_vacuum; /* 1/c [ ns/m ] */
1113 #ifndef RDMC_OLD_REFIDX
1114 #define RDMC_OLD_REFIDX 0 /* use the old value of the refraction index */
1118 extern const double c_water; /* m/nsec; light speed in water */
1119 extern const double rez_c_water; /* 1/c_water [ns/m ] */
1120 extern const double n_water; /* refraction index of water */
1121 extern const double cer; /* cerenkov angle */
1122 extern const double tg_cer; /* tangens of cerenkov angle */
1123 extern const double sn_cer; /* sin cerencov */
1124 extern const double rez_sn_cer; /* 1/sin cerencov */
1125 extern const double cs_cer; /* cos cerencov */
1127 extern const double rdmc_n_water; /* refraction index of water */
1128 extern const double rdmc_n_ice_p;/* phase refraction index of water */
1129 extern const double rdmc_n_ice_g;/* group refraction index of water */
1130 extern const double rdmc_c_water; /* m/nsec; speed in water */
1131 extern const double rdmc_rez_c_water;/* nsec/m; speed in water */
1132 extern const double rdmc_c_ice_p; /* m/nsec; speed in water */
1133 extern const double rdmc_rez_c_ice_p;/* nsec/m; speed in water */
1134 extern const double rdmc_c_ice_g; /* m/nsec; speed in water */
1135 extern const double rdmc_rez_c_ice_g; /* nsec/m; speed in water */
1136 extern const double rdmc_cs_cer_wat; /* cos cerencov */
1137 extern const double rdmc_cs_cer_ice_p; /* cos cerencov */
1138 extern const double rdmc_cs_cer_ice_g; /* cos cerencov */
1139 extern const double rdmc_cer_wat; /* cerenkov angle in rad */
1140 extern const double rdmc_cer_ice_p; /* cerenkov angle in rad */
1141 extern const double rdmc_cer_ice_g; /* cerenkov angle in rad */
1142 extern const double rdmc_sn_cer_wat; /* sin cerencov */
1143 extern const double rdmc_sn_cer_ice_p; /* sin cerencov */
1144 extern const double rdmc_sn_cer_ice_g; /* sin cerencov */
1145 extern const double rdmc_rez_sn_cer_wat; /* 1/sin cerencov */
1146 extern const double rdmc_rez_sn_cer_ice_p; /* 1/sin cerencov */
1147 extern const double rdmc_rez_sn_cer_ice_g; /* 1/sin cerencov */
1148 extern const double rdmc_tg_cer_wat; /*tan cer */
1149 extern const double rdmc_tg_cer_ice_p; /*tan cer */
1150 extern const double rdmc_tg_cer_ice_g; /*tan cer */
1151 extern const double rdmc_tg_cer_tkoeff; /* koefficient in rdmc_art() */
1154 int rdmc_track_closest(double *dist, double poca_xyz[3],
1155 const mtrack *it, const double x,
1156 const double y, const double z);
1157 /* calculates the distance of closest approach to point of coordinates x,y,z*/
1158 /* it returns the values: perpendicular distance *dist */
1159 /* vector poca_xyz[3] with coordinates of the track point of closest aproach */
1160 /* both dist or xyz may be NULL pointers if you do not want to calculate this*/
1163 int rdmc_track_delta(float *delta, float *dist,
1164 const mtrack *tr1, const mtrack *tr2);
1165 /* calculates the angular difference (solid angle) between two tracks */
1166 /* and the closest distance between them */
1167 int rdmc_deltaang(double theta1, double phi1, double theta2,
1168 double phi2, double *delta);
1169 /* calculate the angular difference between two directions given by */
1174 /* calculate the cherenkov arrival times */
1175 double rdmc_art_xyz(const mtrack *tr, double x, double y, double z);
1176 /* Cerenkov light arrival to point */
1178 double rdmc_art(const array *ar, const mtrack *tr, int i);
1179 /* Cerenkov light arrival to i-th pmt */
1181 double rdmc_pnt_art(const array *ar, const mtrack *tr, int i);
1182 /* arrival time from a point source */
1184 double rdmc_om_dist(const array *a, int ich1, int ich2); /* distance between */
1187 double rdmc_dist(double x1, double y1, double z1, /* distance between */
1188 double x2, double y2, double z2); /* 2 points */
1190 /* rdmc_angtr() calculates the cosinus of the direction angles between two */
1191 /* tracks: returns between 1. (parrallel) and -1. (antiparallel) */
1192 double rdmc_angtr(const mtrack *t1, const mtrack *t2);
1194 double rdmc_tdist_xyz(const mtrack *it, double x, double y, double z);
1195 /* calcs the min distance from a track to a point */
1196 double rdmc_tdist(const array *ar, const mtrack *it, int iom);
1197 /* calcs the min distance between a track and an om */
1198 double rdmc_tdist_orig(const mtrack *it);
1199 /* calcs the min distance between a track and the origin (0,0,0) */
1201 double rdmc_vdist(const array *ar, const mtrack *it, int iom);
1202 /* calcs the distance between a the vertex of track and a pmt */
1204 void rdmc_tang(const array *ar, const mtrack *it, int iom,
1205 double *dist, double *csang);
1208 void rdmc_vang(const array *ar, const mtrack *it, int iom,
1209 double *dist, double *csaxis, double *csang);
1211 /*calculates the perpendicular distance, direction angle and cos(angle) */
1212 /* of incident light if dist, csaxis or csang are NULL, */
1213 /* they are not calculated */
1216 /*###########################################*/
1217 /* routines in rdmc_utl.c */
1218 /*###########################################*/
1220 void rdmc_add_timeoffset(mevt *e, float offset);
1221 /* adds a time offset to all time related values of an event */
1222 /* this are presently ONLY the hit times, and the fit/gen track times */
1224 /* sort hits in a event by a call to quicksort either by time */
1225 /* or by channel number */
1226 int rdmc_sort_hits(mevt *ev, const array *ar, enum RDMC_SORT_T method);
1228 /* remove fit no ifit (counting is: 0..nfit-1) from event */
1229 /* including all associated information, like fit_uses */
1230 void rdmc_remove_fit(mevt *e, int ifit);
1232 /* remove_groups() removes all hits which are not from the leading muon */
1233 /* (invert=0) or which are from the leading muon (invert=1) */
1234 /* returns the number of hits after the procedure */
1235 /* Noise is treated according to the last flag */
1236 /* ev->nch and ev->nstr is NOT updated !!! */
1237 int rdmc_remove_groups(mevt *e, int invert,int keep_noise);
1239 /* remove a hit from the event */
1240 /* including all associated information, like fit_uses */
1241 /* ev->nch and ev->nstr is NOT updated !!! */
1242 void rdmc_remove_hit(mevt *e, int ihit);
1244 /* Return mtrack->tag of track-like parent of a track */
1245 int rdmc_tracklike_parent(const mevt *e,const mtrack *t);
1247 /* returns 1 if this is a secondary shower else 0 */
1248 int rdmc_is_secondary(mtrack *t);
1249 int rdmc_is_neutrino(mtrack *t);
1250 int rdmc_is_cr_primary(mtrack *t);
1252 /* returns 1 if this mtrack is a point-like or track-like light source */
1253 int rdmc_is_point_like(const mtrack *t);
1254 int rdmc_is_track_like(const mtrack *t);
1256 /****************************************************************************/
1257 /* checks if this hit is a ifold [scip] coincident hit */
1258 /* returns 1 if yes, 0if no */
1259 /****************************************************************************/
1260 int rdmc_is_coinc(mevt *e, const array *ar, int ihit,
1261 int fold, float twin);
1262 int rdmc_is_scoinc(mevt *e, const array *ar, int ihit,
1263 int fold, float twin);
1265 /* calculates the number of neighbouring hits */
1266 /* which are coincident in the time window twin */
1267 /* and are within the radius */
1268 /* returns -1 on error */
1269 int rdmc_neighbours(array *a, mevt *e, int ihit, double radius, double twin);
1272 int rdmc_count_geo(const array *a);
1273 /* counts number of strings in an geometry-array *a and returns that number */
1275 void rdmc_make_str(array *a);
1276 /* cleans up the geometry data structure *a */
1277 /* the number of strings (a->nstr) is recalculated */
1278 /* and the string number for each chanel (a->str[i]) are recalculated */
1280 void rdmc_make_clust(array *a);
1281 /* calculates the iclust number for each channel in the data structure *a */
1282 /* the old value a->clust[i] is deleted (Baikal specific) */
1284 int rdmc_give_clust(const array *a,int ich);
1285 /* this function calculates the value iclust for channel ich in array *a */
1286 /* the function returns the result iclust or -1 on error */
1287 /* (Baikal specific) */
1289 double rdmc_count_pe(const mevt *e);
1290 /* calculate total pe in this event */
1292 int rdmc_omhit(float *pesum, int iom, const mevt *event);
1293 /* calculates the sum of PE in OM iom ([0..nom-1]) */
1294 /* return 0 if the om was not hit else 1 */
1296 double rdmc_count_ompe(const mevt *e,const array *a
1297 ,float pe_oms[],int hit_oms[]);
1298 /* calculates for each om if it was hit, */
1299 /* and how many PE (ADCs summed over all hits) this are */
1300 /* the arrays pe_oms[] and hit_oms[] are initlized to 0 */
1301 /* but have to be provided by the user (size: ar->nch) */
1302 /* it fills 1 into hit_om[i] if the channel i was hit */
1303 /* and fills total pe of all hits in this OM into pe_oms[i] */
1304 /* returns the total number of pe of all OM */
1305 /* the function can be called with pe_oms or hit_oms set to NULL */
1306 /* then the corresponding values are not calculated (efficiency) */
1308 int rdmc_centre(const mevt *ev, const array *geom, double rc[3]
1310 /* calculate the vector rc to the centre of gravity of the event */
1311 /* amp_pwr is the power by which the amplitude is to be weighted */
1314 /*###########################################*/
1315 /* routines in rdmc_genutl.c */
1316 /*###########################################*/
1317 /* returns the index of the track in mevt.gen or RDMC_NA
1320 int rdmc_which_gen(mevt *e, enum RDMC_GENINFO_T selection);
1322 /* get the leading muon from the tracks */
1323 /* OLD routine, kept for backward compatibility */
1324 /* eqivalent to rdmc_which_gen(e, MOST_HITS_MUON); */
1325 int rdmc_get_leading_muon(mevt *e); /* OBSOLETE */
1327 /* ************************************************************************ */
1328 /* sort_generated_tracks() sorts all generated tracks with respect to the */
1329 /* number of hits caused by the track, */
1330 /* and removes tracks without hits if keep_tracks==0 && keep_all==0 */
1331 /* and keeps all tracks if keep_all==1 */
1332 /* and removes secondaries (no muon!) without hits if keep_tracks=1 */
1333 /****************************************************************************/
1334 void rdmc_sort_generated_tracks(mevt *e, int keep_tracks, int keep_all);
1338 /*###########################################*/
1339 /* routines in rdmc_sky.c */
1340 /*###########################################*/
1341 void rdmc_spdetec2radec(int mjd, int sec, int nsec, double th, double ph,
1342 double *ra, double *dec);
1343 void rdmc_radec2spdetec(int mjd, int sec, int nsec, double ra, double dec,
1344 double *theta, double *phi);
1345 void rdmc_old_spdetec2radec(int mjd, int sec, int nsec, double th, double ph,
1346 double *ra2, double *dec2);
1347 /* transform south pole detector to equatorial coordinates */
1348 void rdmc_radec2llbb(double ra, double dec, double *ll, double *bb);
1349 /* transform equatorial to galactic coordinates */
1350 void rdmc_llbb2radec(double ll, double bb, double *ra, double *dec);
1351 /* transform galactic to equatorial coordinates */
1352 void rdmc_llbb2sllsbb(double ll, double bb, double *sll, double *sbb);
1353 /* transform galactic to supergalactic coordinates */
1354 void rdmc_sllsbb2llbb(double sll, double sbb, double *ll, double *bb);
1355 /* transform supergalactic to galactic coordinates */
1356 void rdmc_radec2ecliptic(int mjd, int sec, int nsec, double ra, double dec,
1357 double *lamda, double *beta);
1358 /* transform equatorial to ecliptic coordinates */
1359 void rdmc_ecliptic2radec(int mjd, int sec, int nsec, double lamda,
1360 double beta, double *ra, double *dec);
1361 /* transform ecliptic to equatorial coordinates */
1362 void rdmc_lunarradec(int mjd, int sec, int nsec, double *ra, double *dec);
1363 /* calculate the position of the moon in equatorial coordinates */
1364 void rdmc_solarradec(int mjd, int sec, int nsec, double *ra, double *dec);
1365 /* calculate the position of the sun in equatorial coordinates */
1366 void rdmc_solar_anomaly(int mjd, int sec, int nsec,
1367 double *lamda_s, double *M_s);
1368 /* calculate coordinates needed for rdmc_solarradec and rdmc_lunarradec */
1369 void rdmc_get_obliquity(int mjd, int sec, int nsec, double *obl);
1370 /* calculate the obliquity needed for ecliptic coordinates */
1373 /*###########################################*/
1374 /* routines in astrocoord.c OBSOLETE */
1375 /*###########################################*/
1376 void rdmc_coord(float gpssec, int gpsday, int gpsyear, float th, float ph,
1377 float *ra, float *dec, float *ll, float *bb);
1378 /* OBSOLETE use functuions in rdmc_sky.c */
1382 /*###########################################*/
1383 /* routines in rdmc_clean_hits.c */
1384 /*###########################################*/
1387 int modify_mhit; /* flag to indicate modification of mhit during fit*/
1390 /***************** PS hit selection structure ************************/
1391 // +--------------------------------+
1392 // | new structure for hit cleaning |
1393 // +--------------------------------+
1401 int modify_mhit; /* flag to indicate modification of mhit during fit*/
1402 hit_sel_options* opt;
1403 } rdmc_clean_hit_ps;
1404 /***************** * * * * * * * * * * * * * * * ************************/
1406 extern rdmc_clean_hit_ps rdmc_clean_hit;
1408 // +--------------------------------+
1409 // | init. selection options |
1410 // +--------------------------------+
1411 void hit_sel_options_init(rdmc_clean_hit_ps** phit_options);
1412 // +--------------------------------+
1413 // | init. new selection param. |
1414 // +--------------------------------+
1415 void ps_new_sel_opt(rdmc_clean_hit_ps* phit_options);
1416 // +--------------------------------+
1417 // | clear selection options |
1418 // +--------------------------------+
1419 void ps_clear_sel_opt(rdmc_clean_hit_ps* phit_options);
1420 // +--------------------------------+
1421 // | parse selection options |
1422 // +--------------------------------+
1423 int ps_parse_sel_opt(const char *optarg,const char *progname
1424 ,rdmc_clean_hit_ps* phit_options);
1425 // +--------------------------------+
1426 // | print selection options |
1427 // +--------------------------------+
1428 void ps_usage_cleaning();
1429 void ps_print_sel_opt(const char *progname
1430 ,rdmc_clean_hit_ps* phit_options);
1431 // +--------------------------------+
1432 // | do hit cleaning |
1433 // +--------------------------------+
1434 int ps_exec_cleaning(mevt *e, array *a, rdmc_clean_hit_ps* phit_options);
1437 void rdmc_usage_cleaning(void); /* print all cleaning options == help */
1438 int rdmc_parse_cleaning(const char *optarg,const char *progname);
1439 /* parse the cleaning command line */
1440 void rdmc_print_cleaning(const char *progname); /* print the cleaning options */
1442 /* make a copy of the hit data structure return 1 on error */
1443 int rdmc_clean_backup_hits(mevt *e);
1444 /* restore the backuped copy return 1 on error */
1445 int rdmc_clean_restore_hits(mevt *e);
1447 /* function does recalculate mevt.nch and mevt.nstr */
1448 int rdmc_exec_cleaning(mevt *e, array *a); /* delete hits to be cleaned */
1450 /* clear the internal list -> experts use only */
1451 void rdmc_clear_cleaning_list(void); /* reset/clean cleaning list */
1453 /* rountines do not recalculate mevt.nch and mevt.nstr */
1454 int rdmc_rm_h(array *a, mevt *e, int hit_nr,int nhits); /* remove one hit */
1455 /* hit_nr: 0..(nhit-1) */
1456 int rdmc_rm_rnd_h(array *a, mevt *e); /* remove one random hit */
1458 int rdmc_rm_rnd_nh(array *a, mevt *e, int n); /* remove n random hits */
1459 /* returns number of hits*/
1460 int rdmc_rm_earliest_h(array *a, mevt *e,int num);
1461 /* remove num earliest hit*/
1462 /* return number of removed hits */
1463 int rdmc_rm_latest_h(array *a, mevt *e,int num);
1464 /* remove num latest hit */
1465 /* return number of removed hits */
1466 int rdmc_rm_interval_h(array *a, mevt *e,float before, float after);
1467 /* remove outside time window */
1468 /* return number of removed hits */
1469 int rdmc_rm_amp_h(array *a, mevt *e,float amp_low, float amp_high,
1470 int low_channel, int high_channel);
1471 /*remove hits amp_low > amp > amp_high */
1472 /* return number of removed hits */
1473 int rdmc_rm_tot_h(array *a, mevt *e,float tot_low, float tot_high,
1474 int low_channel, int high_channel);
1475 /*remove hits tot_low > tot > tot_high */
1476 /* return number of removed hits */
1477 int rdmc_rm_nocoinc_h(array *a, mevt *e
1478 , int coinc, float twin);
1479 /*remove coinc-fold hits*/
1480 /* the time window twin is aplied */
1481 /* return number of removed hits */
1482 int rdmc_rm_snocoinc_h(array *a, mevt *e
1483 , int coinc, float twin);
1484 /*remove SKIP coinc-fold hits*/
1485 /* the time window twin is aplied */
1486 /* return number of removed hits */
1487 int rdmc_rm_isolate_h(array *a, mevt *e,float window);
1488 /*time separated hits by window*/
1489 /* return number of removed hits */
1490 int rdmc_rm_coinc_h(array *a, mevt *e,float window);
1491 /*time coincident hits in window*/
1492 /* return number of removed hits */
1493 int rdmc_rm_xtalk_h(array *a, mevt *e, float window, float adc_min,
1495 /* remove LE-coincident cross-talk */
1496 int rdmc_rm_xtalk_map_h(array *a, mevt *e, float adc_min, float ratio);
1497 /* remove x-talk using Klug & Hanson channel maps, Klug's time windows */
1498 /* return number of removed hits */
1499 int rdmc_rm_local_h(array *a, mevt *e, double radius, double twin, int nhits);
1500 /* local space and time isolated hits are removed */
1501 /* at least nhits within radius and time twin */
1502 int rdmc_rm_additional_h(array *a, mevt *e,int from);
1503 /* remove additional hits in
1505 /* return number of removed hits */
1506 int rdmc_rm_channel_h(array *a, mevt *e,int ich);
1507 /* OBSOLETE remove all hits in channel ich*/
1508 int rdmc_rm_channels_h(array *a, mevt *e,int ich1, int ich2);
1509 /*remove all hits from channel ich1 to ich2*/
1510 int rdmc_rm_string_h(array *a, mevt *e,int istr);
1511 /*remove all hits in string istr*/
1512 int rdmc_rm_uses_h(array *a, mevt *e,int itrig);
1513 /* remove hits not used by trigger
1515 /* return number of removed hits */
1516 int rdmc_rm_fuses_h(array *a, mevt *e,int ifit);
1517 /* remove hits not used by fit
1519 /* return number of removed hits */
1520 int rdmc_rm_imhoff_h (array *a, mevt *e, int n);
1521 /* remove the hits with highest/lowest */
1522 /* (t-t_bar)*(z-z_bar) */
1523 int rdmc_rm_imhoff_s_h (array *a, mevt *e, double r, int s);
1524 /* remove the hits with a */
1525 /* (t-t_bar)*(z-z_bar) */
1526 /* above/above and below/below*/
1527 /* r*sigma of the (t)(z) */
1529 int rdmc_rm_early_amp_h(array *a, mevt *e,int num, float amp_high);
1530 /* within first num hits, hits with */
1531 /* amplitude larger than amp are removed */
1532 int rdmc_rm_amp_early_h(array *a, mevt *e,int num, float amp_high);
1533 /* within first num hits, hits with */
1534 /* amplitude larger than amp are removed */
1535 int rdmc_rm_dt_rho_h(array *a, mevt *e, int ifit, float rho, float tmin, float tmax); /* removes (truncates) hits with */
1536 /*distance rho and outside time-window tmin,tmax from fit */
1538 int rdmc_rm_inrho_h(array *a, mevt *e, int ifit, float rho); /* removes (truncates) hits with radius smaller than rho from fit */
1539 int rdmc_rm_tunnel_h(array *a, mevt *e, int mode);
1540 int rdmc_rm_split_h (array *a, mevt *e, int splitorder, int splitmode);
1542 /*###########################################*/
1543 /* routines in pandel_track.c and pandel_point.c */
1544 /*###########################################*/
1545 /* naming convention: */
1550 _ph_ : phit _pnh_: nohit
1554 norm : normalisation = integral to infinity of unormalize function.
1555 int : cumulative integral to time t
1556 diff : d/dt differential
1559 psa : poisson saturated
1561 patched: a patched pandel approach
1564 /* init the physics constants */
1565 /*if one does not which to overwrite a certain value
1566 then call with a large negative value (<= RDMC_SPECIAL_NA)*/
1568 double td_tau; /* tau for tracks */
1569 double td_lam; /* lambda for tracks */
1570 double td_att; /* Absorption lenght */
1571 double ps_tau; /* tau for tracks */
1572 double ps_lam; /* lambda for tracks */
1573 double td_sigma; /* pmt jitter -> patched functions */
1574 double td_dist_p1; /* scale for the distance */
1575 double td_dist_p0_cs0; /* const for distance ped (P0) */
1576 double td_dist_p0_cs1; /* const for distance ped (P1*cs_ori) */
1577 double td_dist_p0_cs2; /* const for distance ped (P2*cs_ori^2) */
1578 double td_ph_eps_pe0;
1579 double td_ph_eps_pe1;
1580 double td_ph_eps_ori_n0;
1581 double td_ph_eps_ori_pow;
1582 double td_ph_dist_a;
1583 double td_ph_dist_b;
1584 double td_ph_dist_l;
1585 double td_ph_dist_e0;
1586 } rdmc_pandel_par_t;
1589 extern const rdmc_pandel_par_t
1590 rdmc_pandel_par_h0, /* No irregulaarities in the hole */
1591 rdmc_pandel_par_h1, /* hole irregularities scat=100cm */
1592 rdmc_pandel_par_h2, /* hole irregularities scat=50cm */
1593 rdmc_pandel_par_h3, /* hole irregularities scat=30cm */
1594 rdmc_pandel_par_h4; /* hole irregularities scat=10cm */
1597 void rdmc_td_init(rdmc_pandel_par_t *pandel_par);
1599 /* now the functions */
1600 double rdmc_pt_td(double delay, double perp_dist, double cs_ori);
1601 double rdmc_pt_lgtd(double delay, double perp_dist, double cs_ori);
1603 double rdmc_pt_td_norm(double perp_dist, double cs_ori);
1604 double rdmc_pt_lgtd_norm(double perp_dist, double cs_ori);
1606 double rdmc_pt_td_int(double delay, double perp_dist, double cs_ori);
1607 double rdmc_pt_lgtd_int(double delay, double perp_dist, double cs_ori);
1608 double rdmc_pt_td_diff(double delay, double perp_dist, double cs_ori);
1611 double rdmc_pt_td_mpe(double delay,double perp_dist,double cs_ori,double pe);
1612 double rdmc_pt_lgtd_mpe(double delay,double perp_dist,double cs_ori,double pe);
1614 double rdmc_pt_td_mpe_int(double delay,double perp_dist,double cs_ori,double pe);
1615 double rdmc_pt_lgtd_mpe_int(double delay,double perp_dist,double cs_ori,double pe);
1616 double rdmc_pt_td_mpe_diff(double delay,double perp_dist,double cs_ori,double pe);
1618 double rdmc_pt_td_psa(double delay, double perp_dist, double cs_ori, double mean_pe);
1619 double rdmc_pt_lgtd_psa(double delay, double perp_dist, double cs_ori, double mean_pe);
1621 double rdmc_pt_td_psa_int(double delay, double perp_dist, double cs_ori, double mean_pe);
1622 double rdmc_pt_lgtd_psa_int(double delay, double perp_dist, double cs_ori, double mean_pe);
1623 double rdmc_pt_td_psa_diff(double delay, double perp_dist, double cs_ori, double mean_pe);
1626 double rdmc_pt_td_patched(double delay, double perp_dist, double cs_ori);
1627 double rdmc_pt_lgtd_patched(double delay, double perp_dist, double cs_ori);
1629 double rdmc_pt_td_mpe_patched(double delay, double perp_dist, double cs_ori, double pe);
1630 double rdmc_pt_lgtd_mpe_patched(double delay, double perp_dist, double cs_ori, double pe);
1632 double rdmc_pt_td_psa_patched(double delay, double perp_dist, double cs_ori, double mean_pe);
1633 double rdmc_pt_lgtd_psa_patched(double delay, double perp_dist, double cs_ori, double mean_pe);
1635 double rdmc_pt_ph(double perp_dist, double cs_ori, double energy, double sensit);
1636 double rdmc_pt_pnh(double perp_dist, double cs_ori, double energy, double sensit);
1637 double rdmc_pt_ph_dt(double perp_dist, double cs_ori, double energy, double sensit, double tmin, double tmax);
1638 double rdmc_pt_pnh_dt(double perp_dist, double cs_ori, double energy, double sensit, double tmin, double tmax);
1640 double rdmc_pp_td(double delay, double perp_dist, double cs_ori, double cs_axis);
1641 double rdmc_pp_lgtd(double delay, double perp_dist, double cs_ori, double cs_axis);
1642 double rdmc_pp_td_norm(double perp_dist, double cs_ori, double cs_axis);
1643 double rdmc_pp_lgtd_norm(double perp_dist, double cs_ori, double cs_axis);
1646 double rdmc_pp_td_int(double delay, double perp_dist, double cs_ori, double cs_axis);
1647 double rdmc_pp_lgtd_int(double delay, double perp_dist, double cs_ori, double cs_axis);
1648 double rdmc_pp_td_diff(double delay, double perp_dist, double cs_ori, double cs_axis);
1651 double rdmc_pp_td_mpe(double delay,double perp_dist,double cs_ori, double cs_axis,double pe);
1652 double rdmc_pp_lgtd_mpe(double delay,double perp_dist,double cs_ori, double cs_axis,double pe);
1654 double rdmc_pp_td_mpe_int(double delay,double perp_dist,double cs_ori, double cs_axis,double pe);
1655 double rdmc_pp_lgtd_mpe_int(double delay,double perp_dist,double cs_ori, double cs_axis,double pe);
1656 double rdmc_pp_td_mpe_diff(double delay,double perp_dist,double cs_ori, double cs_axis,double pe);
1658 double rdmc_pp_td_psa(double delay, double perp_dist, double cs_ori, double cs_axis, double mean_pe);
1659 double rdmc_pp_lgtd_psa(double delay, double perp_dist, double cs_ori, double cs_axis, double mean_pe);
1661 double rdmc_pp_td_psa_int(double delay, double perp_dist, double cs_ori, double cs_axis, double mean_pe);
1662 double rdmc_pp_lgtd_psa_int(double delay, double perp_dist, double cs_ori, double cs_axis, double mean_pe);
1663 double rdmc_pp_td_psa_diff(double delay, double perp_dist, double cs_ori, double cs_axis, double mean_pe);
1665 double rdmc_pp_td_psd_patched(double delay, double dist, double cs_ori, double cs_axis, double mean_pe);
1666 double rdmc_pp_td_patched_int(double delay, double dist, double cs_ori, double cs_axis);
1669 double rdmc_pp_td_patched(double delay, double perp_dist, double cs_ori, double cs_axis);
1670 double rdmc_pp_lgtd_patched(double delay, double perp_dist, double cs_ori, double cs_axis);
1672 double rdmc_pp_td_mpe_patched(double delay, double perp_dist, double cs_ori, double cs_axis, double pe);
1673 double rdmc_pp_lgtd_mpe_patched(double delay, double perp_dist, double cs_ori, double cs_axis, double pe);
1675 double rdmc_pp_td_psa_patched(double delay, double perp_dist, double cs_ori, double cs_axis, double mean_pe);
1676 double rdmc_pp_lgtd_psa_patched(double delay, double perp_dist, double cs_ori, double cs_axis, double mean_pe);
1678 #if 0 /* Not all functions for point sources are implemented yet */
1679 double rdmc_pp_ph(double perp_dist, double cs_axis, double energy, double sensit);
1680 double rdmc_pp_pnh(double perp_dist, double cs_axis, double energy, double sensit);
1683 /*###########################################*/
1684 /* routines in rdmc_ndirect.c */
1685 /*###########################################*/
1686 /****************************************************************************/
1687 /* rdmc_get_direct_hits calcultes the number of direct early and delayed hits*/
1688 /* The number of arguments is variable */
1689 /* A format string is passed */
1690 /* for each additional argument it has the form: t-:t+;f */
1691 /* t- and t+ define the time window */
1692 /* f is a format id: */
1693 /* 'c' asks for a number of channels */
1694 /* 's' asks for a number of strings */
1695 /* 'd' asks for the smallest perpendicular distance between the */
1696 /* track and a hit */
1697 /* 'D' asks for the largest perp distance between track and a hit */
1698 /* 'R' asks for the average perp distance between track and a hit */
1699 /* 'L' asks for the length of hits projected on the track */
1700 /* = Zdist(baikal) */
1701 /* 'M' asks for the projected length on the track of all hits */
1702 /* but one: leaving out the most outlying direct hit */
1703 /* 'O' Get the largest polar angle in the projection of hits */
1704 /* onto the plane perp to the track direction */
1705 /* 'x','y','z' = centre of gravity of direct hits */
1707 /* get_direct_hits("-10000.:-5.;c -5.:35.;c -5.:20.;s 75.:10000.;c" */
1708 /* ,&nearly,&ndir,&nsdir,&nlate);*/
1709 /* the function returns gdir */
1710 /****************************************************************************/
1711 double rdmc_get_direct_hits(const array *a, const mtrack *tr, mevt *e
1712 , const char *fmt, ...);
1714 /*###########################################*/
1715 /* routines in rdmc_math.c */
1716 /*###########################################*/
1717 double rdmc_lgamma(double x); /* logarithm of the gamma-function */
1718 double rdmc_gamac(double a, double x); /* incomplete gamma function */
1719 long rdmc_nint(double a); /* double to nearest integer */
1720 void rdmc_vecprod(const double a[3], const double b[3], double c[3]);
1721 double rdmc_scalprod(const double a[3], const double b[3]);
1722 /*###########################################*/
1723 /* routines in random.c */
1724 /*###########################################*/
1725 double rdmc_rand(void); /* random number s from numerical recipes*/
1726 double rdmc_poidev(double xm); /* poisson value with mean xm */
1727 double rdmc_gasdev(void); /* gaussian random number */
1730 /*###########################################*/
1731 /* routines in messages.c */
1732 /*###########################################*/
1734 void rdmc_msgprintf(const char *fmt, ...);
1735 /* msgprintf() prints out a message */
1736 void rdmc_errorprintf(const char *fmt, ...);
1737 /* errorprintf() prints out an error message */
1738 void rdmc_warnprintf(const char *fmt, ...);
1739 /* warnprintf() prints out a warning message */
1741 /*###########################################*/
1742 /* routines in rdmc_error.c */
1743 /*###########################################*/
1745 void rdmc_err_print(mcfile *fp, enum RDMC_ERROR_T ierr);
1746 /* gives more verbose info after an rdmc error occured */
1748 /*###########################################*/
1749 /* routines in rdmc_poem.c */
1750 /*###########################################*/
1752 const char *rdmc_poem(void);
1755 /*###########################################*/
1756 /* routines for Fortran in f_rdmc.c */
1757 /*###########################################*/
1760 void frdmc_mcopen_(char *name, int* mode, int *format, int *res);
1761 void frdmc_mcclose_(int *mode, int *res);
1762 void frdmc_rarr_ (int *res);
1763 void frdmc_revt_ (int *res);
1764 void frdmc_skipevt_(int *res);
1765 void frdmc_warr_ (int *res);
1766 void frdmc_wevt_ (int *res);
1768 /* filling adding and ddeletion functions */
1769 void frdmc_fill_gen_(int *itrack, int *result);
1770 void frdmc_fill_rec_(int *itrack, int *result);
1771 void frdmc_fill_user_(int *iuser, int *result);
1772 void frdmc_fill_usdef_(int *iuser, int *result);
1773 void frdmc_fill_wf_(int *iwf, int *result);
1774 void frdmc_new_gen_(int *itrack, int *result);
1775 void frdmc_new_rec_(int *itrack, int *idef, int *result);
1776 void frdmc_new_user_(int *iuser, int *idef, int *result);
1777 void frdmc_new_trig_(int *itrig, int *idef, int *result);
1778 void frdmc_new_wf_(int *iwf, int *result);
1779 void frdmc_new_usdef_(int *iuser, int *result);
1780 void frdmc_new_trdef_(int *itrig, int *result);
1781 void frdmc_new_ftdef_(int *ifit, int *result);
1782 void frdmc_del_gen_(int *itrack, int *result);
1783 void frdmc_del_user_(int *iuser, int *result);
1784 void frdmc_del_wf_(int *iwf, int *result);
1786 void frdmc_add_history_(char *history, int *result);
1787 void frdmc_add_hdcomment_(char *comment, int *result);
1788 void frdmc_add_evcomment_(char *comment, int *result);
1790 void frdmc_init_dummy_(void);
1791 void frdmc_new_farray_(void);
1792 void frdmc_new_fmevt_(void);
1793 void frdmc_new_hits_(void);
1795 int frdmc_return_eventpointer_(void);
1797 #if 1 /* OBSOLETE */
1798 void frdmc_get_trigs_(int *res, int *MxTrig, int *NTrigpar, int *Trig);
1802 /*** some interfaces to rdmc utility functions ****/
1803 int frdmc_track_closest_(double *dist, double xyz[3],
1804 double *x, double *y, double *z);
1805 int frdmc_get_leading_muon_(void);
1806 int frdmc_is_secondary_(void);
1807 int frdmc_is_point_like_(void);
1808 int frdmc_is_track_like_(void);
1810 void frdmc_amanda_spartid_(int *id, char *string);
1812 /*###########################################*/
1813 /*****OBSOLETE***************/
1814 /*###########################################*/
1820 #endif /* _RDMC_H */