Bug Summary

File:programs/Simulation/HDGeant/hitFTOF.c
Location:line 313, column 7
Description:Value stored to 'extras' is never read

Annotated Source Code

1/*
2 * hitFTOF - registers hits for forward Time-Of-Flight
3 *
4 * This is a part of the hits package for the
5 * HDGeant simulation program for Hall D.
6 *
7 * version 1.0 -Richard Jones July 16, 2001
8 *
9 * changes: -B. Zihlmann June 19. 2007
10 * add hit position to north and south hit structure
11 * set THRESH_MEV to zero to NOT concatenate hits.
12 *
13 * changes: Wed Jun 20 13:19:56 EDT 2007 B. Zihlmann
14 * add ipart to the function hitforwardTOF
15 *
16 * Programmer's Notes:
17 * -------------------
18 * 1) In applying the attenuation to light propagating down to both ends
19 * of the counters, there has to be some point where the attenuation
20 * factor is 1. I chose it to be the midplane, so that in the middle
21 * of the counter both ends see the unattenuated dE values. Closer to
22 * either end, that end has a larger dE value and the opposite end a
23 * lower dE value than the actual deposition.
24 * 2) In applying the propagation delay to light propagating down to the
25 * ends of the counters, there has to be some point where the timing
26 * offset is 0. I chose it to be the midplane, so that for hits in
27 * the middle of the counter the t values measure time-of-flight from
28 * the t=0 of the event. For hits closer to one end, that end sees
29 * a t value smaller than its true time-of-flight, and the other end
30 * sees a value correspondingly larger. The average is the true tof.
31 */
32
33#include <stdlib.h>
34#include <stdio.h>
35#include <math.h>
36
37#include <HDDM/hddm_s.h>
38#include <geant3.h>
39#include <bintree.h>
40#include <gid_map.h>
41
42#include "calibDB.h"
43
44// plastic scintillator specific constants
45static float ATTEN_LENGTH = 150;
46static float C_EFFECTIVE = 15.0;
47static float BAR_LENGTH = 252.0; // length of the bar
48
49// kinematic constants
50static float TWO_HIT_RESOL = 25.;// separation time between two different hits
51
52static float THRESH_MEV = 0.; // do not through away any hits, one can do that later
53
54// maximum particle tracks per counter
55static int TOF_MAX_HITS = 25; // was 100 changed to 25
56
57// maximum MC hits per paddle
58static int TOF_MAX_PAD_HITS = 25;
59
60// Note by RTJ:
61// This constant "MAX_HITS" is a convenience constant
62// that I introduced to help with preallocating arrays
63// to hold hits. It is NOT a tunable simulation parameter.
64// Do NOT MODIFY, either its name or its role in the code!
65#define MAX_HITS1000 1000
66
67
68// top level pointer of FTOF hit tree
69binTree_t* forwardTOFTree = 0;
70
71static int counterCount = 0;
72static int pointCount = 0;
73static int initialized = 0;
74
75
76/* register hits during tracking (from gustep) */
77// track is ITRA from GEANT
78// stack is ISTAK from GEANT
79// history is ISTORY from GEANT User flag for current track history (reset to 0 in GLTRAC)
80
81void hitForwardTOF (float xin[4], float xout[4],
82 float pin[5], float pout[5], float dEsum,
83 int track, int stack, int history, int ipart) {
84 float x[3], t;
85 // float dx[3];
86 //float dr;
87 // float dEdx; commented out to avoid compiler warnings 4/26/2015 DL
88 float xlocal[3];
89 float xftof[3];
90 float zeroHat[] = {0,0,0};
91
92 if (!initialized) {
93
94
95 mystr_t strings[50];
96 float values[50];
97 int nvalues = 50;
98 int status = GetConstants("TOF/tof_parms", &nvalues, values, strings);
99
100 if (!status) {
101
102 int ncounter = 0;
103 int i;
104 for ( i=0;i<(int)nvalues;i++){
105 //printf("%d %s \n",i,strings[i].str);
106 if (!strcmp(strings[i].str,"TOF_ATTEN_LENGTH")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(strings[i].str) && __builtin_constant_p ("TOF_ATTEN_LENGTH"
) && (__s1_len = strlen (strings[i].str), __s2_len = strlen
("TOF_ATTEN_LENGTH"), (!((size_t)(const void *)((strings[i].
str) + 1) - (size_t)(const void *)(strings[i].str) == 1) || __s1_len
>= 4) && (!((size_t)(const void *)(("TOF_ATTEN_LENGTH"
) + 1) - (size_t)(const void *)("TOF_ATTEN_LENGTH") == 1) || __s2_len
>= 4)) ? __builtin_strcmp (strings[i].str, "TOF_ATTEN_LENGTH"
) : (__builtin_constant_p (strings[i].str) && ((size_t
)(const void *)((strings[i].str) + 1) - (size_t)(const void *
)(strings[i].str) == 1) && (__s1_len = strlen (strings
[i].str), __s1_len < 4) ? (__builtin_constant_p ("TOF_ATTEN_LENGTH"
) && ((size_t)(const void *)(("TOF_ATTEN_LENGTH") + 1
) - (size_t)(const void *)("TOF_ATTEN_LENGTH") == 1) ? __builtin_strcmp
(strings[i].str, "TOF_ATTEN_LENGTH") : (__extension__ ({ __const
unsigned char *__s2 = (__const unsigned char *) (__const char
*) ("TOF_ATTEN_LENGTH"); register int __result = (((__const unsigned
char *) (__const char *) (strings[i].str))[0] - __s2[0]); if
(__s1_len > 0 && __result == 0) { __result = (((__const
unsigned char *) (__const char *) (strings[i].str))[1] - __s2
[1]); if (__s1_len > 1 && __result == 0) { __result
= (((__const unsigned char *) (__const char *) (strings[i].str
))[2] - __s2[2]); if (__s1_len > 2 && __result == 0
) __result = (((__const unsigned char *) (__const char *) (strings
[i].str))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
("TOF_ATTEN_LENGTH") && ((size_t)(const void *)(("TOF_ATTEN_LENGTH"
) + 1) - (size_t)(const void *)("TOF_ATTEN_LENGTH") == 1) &&
(__s2_len = strlen ("TOF_ATTEN_LENGTH"), __s2_len < 4) ? (
__builtin_constant_p (strings[i].str) && ((size_t)(const
void *)((strings[i].str) + 1) - (size_t)(const void *)(strings
[i].str) == 1) ? __builtin_strcmp (strings[i].str, "TOF_ATTEN_LENGTH"
) : (__extension__ ({ __const unsigned char *__s1 = (__const unsigned
char *) (__const char *) (strings[i].str); register int __result
= __s1[0] - ((__const unsigned char *) (__const char *) ("TOF_ATTEN_LENGTH"
))[0]; if (__s2_len > 0 && __result == 0) { __result
= (__s1[1] - ((__const unsigned char *) (__const char *) ("TOF_ATTEN_LENGTH"
))[1]); if (__s2_len > 1 && __result == 0) { __result
= (__s1[2] - ((__const unsigned char *) (__const char *) ("TOF_ATTEN_LENGTH"
))[2]); if (__s2_len > 2 && __result == 0) __result
= (__s1[3] - ((__const unsigned char *) (__const char *) ("TOF_ATTEN_LENGTH"
))[3]); } } __result; }))) : __builtin_strcmp (strings[i].str
, "TOF_ATTEN_LENGTH")))); })
) {
107 ATTEN_LENGTH = values[i];
108 ncounter++;
109 }
110 if (!strcmp(strings[i].str,"TOF_C_EFFECTIVE")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(strings[i].str) && __builtin_constant_p ("TOF_C_EFFECTIVE"
) && (__s1_len = strlen (strings[i].str), __s2_len = strlen
("TOF_C_EFFECTIVE"), (!((size_t)(const void *)((strings[i].str
) + 1) - (size_t)(const void *)(strings[i].str) == 1) || __s1_len
>= 4) && (!((size_t)(const void *)(("TOF_C_EFFECTIVE"
) + 1) - (size_t)(const void *)("TOF_C_EFFECTIVE") == 1) || __s2_len
>= 4)) ? __builtin_strcmp (strings[i].str, "TOF_C_EFFECTIVE"
) : (__builtin_constant_p (strings[i].str) && ((size_t
)(const void *)((strings[i].str) + 1) - (size_t)(const void *
)(strings[i].str) == 1) && (__s1_len = strlen (strings
[i].str), __s1_len < 4) ? (__builtin_constant_p ("TOF_C_EFFECTIVE"
) && ((size_t)(const void *)(("TOF_C_EFFECTIVE") + 1)
- (size_t)(const void *)("TOF_C_EFFECTIVE") == 1) ? __builtin_strcmp
(strings[i].str, "TOF_C_EFFECTIVE") : (__extension__ ({ __const
unsigned char *__s2 = (__const unsigned char *) (__const char
*) ("TOF_C_EFFECTIVE"); register int __result = (((__const unsigned
char *) (__const char *) (strings[i].str))[0] - __s2[0]); if
(__s1_len > 0 && __result == 0) { __result = (((__const
unsigned char *) (__const char *) (strings[i].str))[1] - __s2
[1]); if (__s1_len > 1 && __result == 0) { __result
= (((__const unsigned char *) (__const char *) (strings[i].str
))[2] - __s2[2]); if (__s1_len > 2 && __result == 0
) __result = (((__const unsigned char *) (__const char *) (strings
[i].str))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
("TOF_C_EFFECTIVE") && ((size_t)(const void *)(("TOF_C_EFFECTIVE"
) + 1) - (size_t)(const void *)("TOF_C_EFFECTIVE") == 1) &&
(__s2_len = strlen ("TOF_C_EFFECTIVE"), __s2_len < 4) ? (
__builtin_constant_p (strings[i].str) && ((size_t)(const
void *)((strings[i].str) + 1) - (size_t)(const void *)(strings
[i].str) == 1) ? __builtin_strcmp (strings[i].str, "TOF_C_EFFECTIVE"
) : (__extension__ ({ __const unsigned char *__s1 = (__const unsigned
char *) (__const char *) (strings[i].str); register int __result
= __s1[0] - ((__const unsigned char *) (__const char *) ("TOF_C_EFFECTIVE"
))[0]; if (__s2_len > 0 && __result == 0) { __result
= (__s1[1] - ((__const unsigned char *) (__const char *) ("TOF_C_EFFECTIVE"
))[1]); if (__s2_len > 1 && __result == 0) { __result
= (__s1[2] - ((__const unsigned char *) (__const char *) ("TOF_C_EFFECTIVE"
))[2]); if (__s2_len > 2 && __result == 0) __result
= (__s1[3] - ((__const unsigned char *) (__const char *) ("TOF_C_EFFECTIVE"
))[3]); } } __result; }))) : __builtin_strcmp (strings[i].str
, "TOF_C_EFFECTIVE")))); })
) {
111 C_EFFECTIVE = values[i];
112 ncounter++;
113 }
114 if (!strcmp(strings[i].str,"TOF_PADDLE_LENGTH")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(strings[i].str) && __builtin_constant_p ("TOF_PADDLE_LENGTH"
) && (__s1_len = strlen (strings[i].str), __s2_len = strlen
("TOF_PADDLE_LENGTH"), (!((size_t)(const void *)((strings[i]
.str) + 1) - (size_t)(const void *)(strings[i].str) == 1) || __s1_len
>= 4) && (!((size_t)(const void *)(("TOF_PADDLE_LENGTH"
) + 1) - (size_t)(const void *)("TOF_PADDLE_LENGTH") == 1) ||
__s2_len >= 4)) ? __builtin_strcmp (strings[i].str, "TOF_PADDLE_LENGTH"
) : (__builtin_constant_p (strings[i].str) && ((size_t
)(const void *)((strings[i].str) + 1) - (size_t)(const void *
)(strings[i].str) == 1) && (__s1_len = strlen (strings
[i].str), __s1_len < 4) ? (__builtin_constant_p ("TOF_PADDLE_LENGTH"
) && ((size_t)(const void *)(("TOF_PADDLE_LENGTH") + 1
) - (size_t)(const void *)("TOF_PADDLE_LENGTH") == 1) ? __builtin_strcmp
(strings[i].str, "TOF_PADDLE_LENGTH") : (__extension__ ({ __const
unsigned char *__s2 = (__const unsigned char *) (__const char
*) ("TOF_PADDLE_LENGTH"); register int __result = (((__const
unsigned char *) (__const char *) (strings[i].str))[0] - __s2
[0]); if (__s1_len > 0 && __result == 0) { __result
= (((__const unsigned char *) (__const char *) (strings[i].str
))[1] - __s2[1]); if (__s1_len > 1 && __result == 0
) { __result = (((__const unsigned char *) (__const char *) (
strings[i].str))[2] - __s2[2]); if (__s1_len > 2 &&
__result == 0) __result = (((__const unsigned char *) (__const
char *) (strings[i].str))[3] - __s2[3]); } } __result; }))) :
(__builtin_constant_p ("TOF_PADDLE_LENGTH") && ((size_t
)(const void *)(("TOF_PADDLE_LENGTH") + 1) - (size_t)(const void
*)("TOF_PADDLE_LENGTH") == 1) && (__s2_len = strlen (
"TOF_PADDLE_LENGTH"), __s2_len < 4) ? (__builtin_constant_p
(strings[i].str) && ((size_t)(const void *)((strings
[i].str) + 1) - (size_t)(const void *)(strings[i].str) == 1) ?
__builtin_strcmp (strings[i].str, "TOF_PADDLE_LENGTH") : (__extension__
({ __const unsigned char *__s1 = (__const unsigned char *) (
__const char *) (strings[i].str); register int __result = __s1
[0] - ((__const unsigned char *) (__const char *) ("TOF_PADDLE_LENGTH"
))[0]; if (__s2_len > 0 && __result == 0) { __result
= (__s1[1] - ((__const unsigned char *) (__const char *) ("TOF_PADDLE_LENGTH"
))[1]); if (__s2_len > 1 && __result == 0) { __result
= (__s1[2] - ((__const unsigned char *) (__const char *) ("TOF_PADDLE_LENGTH"
))[2]); if (__s2_len > 2 && __result == 0) __result
= (__s1[3] - ((__const unsigned char *) (__const char *) ("TOF_PADDLE_LENGTH"
))[3]); } } __result; }))) : __builtin_strcmp (strings[i].str
, "TOF_PADDLE_LENGTH")))); })
) {
115 BAR_LENGTH = values[i];
116 ncounter++;
117 }
118 if (!strcmp(strings[i].str,"TOF_TWO_HIT_RESOL")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(strings[i].str) && __builtin_constant_p ("TOF_TWO_HIT_RESOL"
) && (__s1_len = strlen (strings[i].str), __s2_len = strlen
("TOF_TWO_HIT_RESOL"), (!((size_t)(const void *)((strings[i]
.str) + 1) - (size_t)(const void *)(strings[i].str) == 1) || __s1_len
>= 4) && (!((size_t)(const void *)(("TOF_TWO_HIT_RESOL"
) + 1) - (size_t)(const void *)("TOF_TWO_HIT_RESOL") == 1) ||
__s2_len >= 4)) ? __builtin_strcmp (strings[i].str, "TOF_TWO_HIT_RESOL"
) : (__builtin_constant_p (strings[i].str) && ((size_t
)(const void *)((strings[i].str) + 1) - (size_t)(const void *
)(strings[i].str) == 1) && (__s1_len = strlen (strings
[i].str), __s1_len < 4) ? (__builtin_constant_p ("TOF_TWO_HIT_RESOL"
) && ((size_t)(const void *)(("TOF_TWO_HIT_RESOL") + 1
) - (size_t)(const void *)("TOF_TWO_HIT_RESOL") == 1) ? __builtin_strcmp
(strings[i].str, "TOF_TWO_HIT_RESOL") : (__extension__ ({ __const
unsigned char *__s2 = (__const unsigned char *) (__const char
*) ("TOF_TWO_HIT_RESOL"); register int __result = (((__const
unsigned char *) (__const char *) (strings[i].str))[0] - __s2
[0]); if (__s1_len > 0 && __result == 0) { __result
= (((__const unsigned char *) (__const char *) (strings[i].str
))[1] - __s2[1]); if (__s1_len > 1 && __result == 0
) { __result = (((__const unsigned char *) (__const char *) (
strings[i].str))[2] - __s2[2]); if (__s1_len > 2 &&
__result == 0) __result = (((__const unsigned char *) (__const
char *) (strings[i].str))[3] - __s2[3]); } } __result; }))) :
(__builtin_constant_p ("TOF_TWO_HIT_RESOL") && ((size_t
)(const void *)(("TOF_TWO_HIT_RESOL") + 1) - (size_t)(const void
*)("TOF_TWO_HIT_RESOL") == 1) && (__s2_len = strlen (
"TOF_TWO_HIT_RESOL"), __s2_len < 4) ? (__builtin_constant_p
(strings[i].str) && ((size_t)(const void *)((strings
[i].str) + 1) - (size_t)(const void *)(strings[i].str) == 1) ?
__builtin_strcmp (strings[i].str, "TOF_TWO_HIT_RESOL") : (__extension__
({ __const unsigned char *__s1 = (__const unsigned char *) (
__const char *) (strings[i].str); register int __result = __s1
[0] - ((__const unsigned char *) (__const char *) ("TOF_TWO_HIT_RESOL"
))[0]; if (__s2_len > 0 && __result == 0) { __result
= (__s1[1] - ((__const unsigned char *) (__const char *) ("TOF_TWO_HIT_RESOL"
))[1]); if (__s2_len > 1 && __result == 0) { __result
= (__s1[2] - ((__const unsigned char *) (__const char *) ("TOF_TWO_HIT_RESOL"
))[2]); if (__s2_len > 2 && __result == 0) __result
= (__s1[3] - ((__const unsigned char *) (__const char *) ("TOF_TWO_HIT_RESOL"
))[3]); } } __result; }))) : __builtin_strcmp (strings[i].str
, "TOF_TWO_HIT_RESOL")))); })
) {
119 TWO_HIT_RESOL = values[i];
120 ncounter++;
121 }
122 if (!strcmp(strings[i].str,"TOF_THRESH_MEV")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(strings[i].str) && __builtin_constant_p ("TOF_THRESH_MEV"
) && (__s1_len = strlen (strings[i].str), __s2_len = strlen
("TOF_THRESH_MEV"), (!((size_t)(const void *)((strings[i].str
) + 1) - (size_t)(const void *)(strings[i].str) == 1) || __s1_len
>= 4) && (!((size_t)(const void *)(("TOF_THRESH_MEV"
) + 1) - (size_t)(const void *)("TOF_THRESH_MEV") == 1) || __s2_len
>= 4)) ? __builtin_strcmp (strings[i].str, "TOF_THRESH_MEV"
) : (__builtin_constant_p (strings[i].str) && ((size_t
)(const void *)((strings[i].str) + 1) - (size_t)(const void *
)(strings[i].str) == 1) && (__s1_len = strlen (strings
[i].str), __s1_len < 4) ? (__builtin_constant_p ("TOF_THRESH_MEV"
) && ((size_t)(const void *)(("TOF_THRESH_MEV") + 1) -
(size_t)(const void *)("TOF_THRESH_MEV") == 1) ? __builtin_strcmp
(strings[i].str, "TOF_THRESH_MEV") : (__extension__ ({ __const
unsigned char *__s2 = (__const unsigned char *) (__const char
*) ("TOF_THRESH_MEV"); register int __result = (((__const unsigned
char *) (__const char *) (strings[i].str))[0] - __s2[0]); if
(__s1_len > 0 && __result == 0) { __result = (((__const
unsigned char *) (__const char *) (strings[i].str))[1] - __s2
[1]); if (__s1_len > 1 && __result == 0) { __result
= (((__const unsigned char *) (__const char *) (strings[i].str
))[2] - __s2[2]); if (__s1_len > 2 && __result == 0
) __result = (((__const unsigned char *) (__const char *) (strings
[i].str))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
("TOF_THRESH_MEV") && ((size_t)(const void *)(("TOF_THRESH_MEV"
) + 1) - (size_t)(const void *)("TOF_THRESH_MEV") == 1) &&
(__s2_len = strlen ("TOF_THRESH_MEV"), __s2_len < 4) ? (__builtin_constant_p
(strings[i].str) && ((size_t)(const void *)((strings
[i].str) + 1) - (size_t)(const void *)(strings[i].str) == 1) ?
__builtin_strcmp (strings[i].str, "TOF_THRESH_MEV") : (__extension__
({ __const unsigned char *__s1 = (__const unsigned char *) (
__const char *) (strings[i].str); register int __result = __s1
[0] - ((__const unsigned char *) (__const char *) ("TOF_THRESH_MEV"
))[0]; if (__s2_len > 0 && __result == 0) { __result
= (__s1[1] - ((__const unsigned char *) (__const char *) ("TOF_THRESH_MEV"
))[1]); if (__s2_len > 1 && __result == 0) { __result
= (__s1[2] - ((__const unsigned char *) (__const char *) ("TOF_THRESH_MEV"
))[2]); if (__s2_len > 2 && __result == 0) __result
= (__s1[3] - ((__const unsigned char *) (__const char *) ("TOF_THRESH_MEV"
))[3]); } } __result; }))) : __builtin_strcmp (strings[i].str
, "TOF_THRESH_MEV")))); })
) {
123 THRESH_MEV = values[i];
124 ncounter++;
125 }
126 if (!strcmp(strings[i].str,"TOF_MAX_HITS")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(strings[i].str) && __builtin_constant_p ("TOF_MAX_HITS"
) && (__s1_len = strlen (strings[i].str), __s2_len = strlen
("TOF_MAX_HITS"), (!((size_t)(const void *)((strings[i].str)
+ 1) - (size_t)(const void *)(strings[i].str) == 1) || __s1_len
>= 4) && (!((size_t)(const void *)(("TOF_MAX_HITS"
) + 1) - (size_t)(const void *)("TOF_MAX_HITS") == 1) || __s2_len
>= 4)) ? __builtin_strcmp (strings[i].str, "TOF_MAX_HITS"
) : (__builtin_constant_p (strings[i].str) && ((size_t
)(const void *)((strings[i].str) + 1) - (size_t)(const void *
)(strings[i].str) == 1) && (__s1_len = strlen (strings
[i].str), __s1_len < 4) ? (__builtin_constant_p ("TOF_MAX_HITS"
) && ((size_t)(const void *)(("TOF_MAX_HITS") + 1) - (
size_t)(const void *)("TOF_MAX_HITS") == 1) ? __builtin_strcmp
(strings[i].str, "TOF_MAX_HITS") : (__extension__ ({ __const
unsigned char *__s2 = (__const unsigned char *) (__const char
*) ("TOF_MAX_HITS"); register int __result = (((__const unsigned
char *) (__const char *) (strings[i].str))[0] - __s2[0]); if
(__s1_len > 0 && __result == 0) { __result = (((__const
unsigned char *) (__const char *) (strings[i].str))[1] - __s2
[1]); if (__s1_len > 1 && __result == 0) { __result
= (((__const unsigned char *) (__const char *) (strings[i].str
))[2] - __s2[2]); if (__s1_len > 2 && __result == 0
) __result = (((__const unsigned char *) (__const char *) (strings
[i].str))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
("TOF_MAX_HITS") && ((size_t)(const void *)(("TOF_MAX_HITS"
) + 1) - (size_t)(const void *)("TOF_MAX_HITS") == 1) &&
(__s2_len = strlen ("TOF_MAX_HITS"), __s2_len < 4) ? (__builtin_constant_p
(strings[i].str) && ((size_t)(const void *)((strings
[i].str) + 1) - (size_t)(const void *)(strings[i].str) == 1) ?
__builtin_strcmp (strings[i].str, "TOF_MAX_HITS") : (__extension__
({ __const unsigned char *__s1 = (__const unsigned char *) (
__const char *) (strings[i].str); register int __result = __s1
[0] - ((__const unsigned char *) (__const char *) ("TOF_MAX_HITS"
))[0]; if (__s2_len > 0 && __result == 0) { __result
= (__s1[1] - ((__const unsigned char *) (__const char *) ("TOF_MAX_HITS"
))[1]); if (__s2_len > 1 && __result == 0) { __result
= (__s1[2] - ((__const unsigned char *) (__const char *) ("TOF_MAX_HITS"
))[2]); if (__s2_len > 2 && __result == 0) __result
= (__s1[3] - ((__const unsigned char *) (__const char *) ("TOF_MAX_HITS"
))[3]); } } __result; }))) : __builtin_strcmp (strings[i].str
, "TOF_MAX_HITS")))); })
){
127 TOF_MAX_HITS = (int)values[i];
128 ncounter++;
129 }
130 if (!strcmp(strings[i].str,"TOF_MAX_PAD_HITS")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(strings[i].str) && __builtin_constant_p ("TOF_MAX_PAD_HITS"
) && (__s1_len = strlen (strings[i].str), __s2_len = strlen
("TOF_MAX_PAD_HITS"), (!((size_t)(const void *)((strings[i].
str) + 1) - (size_t)(const void *)(strings[i].str) == 1) || __s1_len
>= 4) && (!((size_t)(const void *)(("TOF_MAX_PAD_HITS"
) + 1) - (size_t)(const void *)("TOF_MAX_PAD_HITS") == 1) || __s2_len
>= 4)) ? __builtin_strcmp (strings[i].str, "TOF_MAX_PAD_HITS"
) : (__builtin_constant_p (strings[i].str) && ((size_t
)(const void *)((strings[i].str) + 1) - (size_t)(const void *
)(strings[i].str) == 1) && (__s1_len = strlen (strings
[i].str), __s1_len < 4) ? (__builtin_constant_p ("TOF_MAX_PAD_HITS"
) && ((size_t)(const void *)(("TOF_MAX_PAD_HITS") + 1
) - (size_t)(const void *)("TOF_MAX_PAD_HITS") == 1) ? __builtin_strcmp
(strings[i].str, "TOF_MAX_PAD_HITS") : (__extension__ ({ __const
unsigned char *__s2 = (__const unsigned char *) (__const char
*) ("TOF_MAX_PAD_HITS"); register int __result = (((__const unsigned
char *) (__const char *) (strings[i].str))[0] - __s2[0]); if
(__s1_len > 0 && __result == 0) { __result = (((__const
unsigned char *) (__const char *) (strings[i].str))[1] - __s2
[1]); if (__s1_len > 1 && __result == 0) { __result
= (((__const unsigned char *) (__const char *) (strings[i].str
))[2] - __s2[2]); if (__s1_len > 2 && __result == 0
) __result = (((__const unsigned char *) (__const char *) (strings
[i].str))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p
("TOF_MAX_PAD_HITS") && ((size_t)(const void *)(("TOF_MAX_PAD_HITS"
) + 1) - (size_t)(const void *)("TOF_MAX_PAD_HITS") == 1) &&
(__s2_len = strlen ("TOF_MAX_PAD_HITS"), __s2_len < 4) ? (
__builtin_constant_p (strings[i].str) && ((size_t)(const
void *)((strings[i].str) + 1) - (size_t)(const void *)(strings
[i].str) == 1) ? __builtin_strcmp (strings[i].str, "TOF_MAX_PAD_HITS"
) : (__extension__ ({ __const unsigned char *__s1 = (__const unsigned
char *) (__const char *) (strings[i].str); register int __result
= __s1[0] - ((__const unsigned char *) (__const char *) ("TOF_MAX_PAD_HITS"
))[0]; if (__s2_len > 0 && __result == 0) { __result
= (__s1[1] - ((__const unsigned char *) (__const char *) ("TOF_MAX_PAD_HITS"
))[1]); if (__s2_len > 1 && __result == 0) { __result
= (__s1[2] - ((__const unsigned char *) (__const char *) ("TOF_MAX_PAD_HITS"
))[2]); if (__s2_len > 2 && __result == 0) __result
= (__s1[3] - ((__const unsigned char *) (__const char *) ("TOF_MAX_PAD_HITS"
))[3]); } } __result; }))) : __builtin_strcmp (strings[i].str
, "TOF_MAX_PAD_HITS")))); })
) {
131 TOF_MAX_PAD_HITS = (int)values[i];
132 ncounter++;
133 }
134 }
135 if (ncounter==7){
136 printf("TOF: ALL parameters loaded from Data Base\n");
137 } else if (ncounter<7){
138 printf("TOF: NOT ALL necessary parameters found in Data Base %d out of 7\n",ncounter);
139 } else {
140 printf("TOF: SOME parameters found more than once in Data Base\n");
141 }
142
143 }
144 initialized = 1;
145
146 }
147
148
149
150 // getplane is coded in
151 // src/programs/Simulation/HDGeant/hddsGeant3.F
152 // this file is automatically generated from the geometry file
153 // written in xml format
154 // NOTE: there are three files hddsGeant3.F with the same name in
155 // the source code tree namely
156 // 1) src/programs/Utilities/geantbfield2root/hddsGeant3.F
157 // 2) src/programs/Simulation/HDGeant/hddsGeant3.F
158 // 3) src/programs/Simulation/hdds/hddsGeant3.F
159 //
160 // while 2) and 3) are identical 1) is a part of 2) and 3)
161 int plane = getplane_wrapper_();
162
163 // calculate mean location of track and mean time in [ns] units
164 // the units of xin xout and x are in [cm]
165 x[0] = (xin[0] + xout[0])/2;
166 x[1] = (xin[1] + xout[1])/2;
167 x[2] = (xin[2] + xout[2])/2;
168 t = (xin[3] + xout[3])/2 * 1e9;
169
170 // tranform the the global x coordinate into the local coordinate of the top_volume FTOF
171 // defined in the geometry file src/programs/Simulation/hdds/ForwardTOF_HDDS.xml
172 // the function transform Coord is defined in src/programs/Simulation/HDGeant/hitutil/hitutil.F
173 transformCoord(x,"global",xlocal,"FTOF")transformcoord_(x,"global",xlocal,"FTOF",strlen("global"),strlen
("FTOF"))
;
174 transformCoord(zeroHat,"local",xftof,"FTOF")transformcoord_(zeroHat,"local",xftof,"FTOF",strlen("local"),
strlen("FTOF"))
;
175
176 // track vector of this step
177 //dx[0] = xin[0] - xout[0];
178 //dx[1] = xin[1] - xout[1];
179 //dx[2] = xin[2] - xout[2];
180 // length of the track of this step
181 //dr = sqrt(dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2]);
182 // calculate dEdx only if track length is >0.001 cm
183
184 // The following commented out to avoid compiler warnings 4/26/2015 DL
185// if (dr > 1e-3) {
186// dEdx = dEsum/dr;
187// }
188// else {
189// dEdx = 0;
190// }
191
192 /* post the hit to the truth tree */
193 // in other words: store the GENERATED track information
194
195 if ((history == 0) && (plane == 0)) {
196
197 // save all tracks from particles that hit the first plane of FTOF
198 // save the generated "true" values
199
200 int mark = (1<<30) + pointCount;
201
202 // getTwig is defined in src/programs/Simulation/HDGeant/bintree.c
203 // the two arguments are a pointer to a pointer and an integer
204
205 void** twig = getTwig(&forwardTOFTree, mark);
206 if (*twig == 0) {
207 // make_s_ForwardTOF is defined in src/programs/Analysis/hddm/hddm_s.h
208 // and coded in src/programs/Analysis/hddm/hddm_s.c
209 // the same holds for make_s_FtofTruthPoints
210
211 // make_s_ForwardTOF returns pointer to structure s_ForwardTOF generated memory
212 // tof->ftofCoutners and tof-> ftofTruthPoints are initialized already
213
214 s_ForwardTOF_t* tof = *twig = make_s_ForwardTOF();
215 s_FtofTruthPoints_t* points = make_s_FtofTruthPoints(1);
216 tof->ftofTruthPoints = points;
217 points->in[0].primary = (stack == 0);
218 points->in[0].track = track;
219 points->in[0].x = x[0];
220 points->in[0].y = x[1];
221 points->in[0].z = x[2];
222 points->in[0].t = t;
223 points->in[0].px = pin[0]*pin[4];
224 points->in[0].py = pin[1]*pin[4];
225 points->in[0].pz = pin[2]*pin[4];
226 points->in[0].E = pin[3];
227 points->in[0].ptype = ipart;
228 points->in[0].trackID = make_s_TrackID();
229 points->in[0].trackID->itrack = gidGetId(track);
230 points->mult = 1;
231 pointCount++;
232 }
233 }
234
235 /* post the hit to the hits tree, mark slab as hit */
236 // in other words now store the simulated detector response
237 if (dEsum > 0) {
238 int nhit;
239 s_FtofTruthHits_t* hits;
240 s_FtofTruthExtras_t* extras;
241
242 // getrow and getcolumn are both coded in hddsGeant3.F
243 // see above for function getplane()
244
245 int row = getrow_wrapper_();
246 int column = getcolumn_wrapper_();
247
248 // distance of hit from PMT north w.r.t. center and similar for PMT south
249 // this means positive x points north. to get a right handed system y must
250 // point vertically up as z is the beam axis.
251 // plane==0 horizontal plane, plane==1 vertical plane
252 // float dist = xlocal[0];
253
254 float dist = x[1]; // do not use local coordinate for x and y
255 if (plane==1)
256 dist = x[0];
257 float dxnorth = BAR_LENGTH/2.-dist;
258 float dxsouth = BAR_LENGTH/2.+dist;
259
260 // calculate time at the PMT "normalized" to the center, so a hit in the
261 // center will have time "t" at both PMTs
262 // the speed of signal travel is C_EFFECTIVE
263 // propagte time to the end of the bar
264 // column = 0 is a full paddle column ==1,2 is a half paddle
265
266 float tnorth = t + dxnorth/C_EFFECTIVE;
267 float tsouth = t + dxsouth/C_EFFECTIVE;
268
269 // calculate energy seen by PM for this track step using attenuation factor
270 float dEnorth = dEsum * exp(-dxnorth/ATTEN_LENGTH);
271 float dEsouth = dEsum * exp(-dxsouth/ATTEN_LENGTH);
272
273 if (plane==0){
274 if (column==1){
275 tnorth=0.;
276 dEnorth=0.;
277 }
278 else if (column==2){
279 tsouth=0.;
280 dEsouth=0.;
281 }
282 }
283 else{
284 if (column==2){
285 tnorth=0.;
286 dEnorth=0.;
287 }
288 else if (column==1){
289 tsouth=0.;
290 dEsouth=0.;
291 }
292 }
293
294
295 int padl = row;
296 if (row>44)
297 padl = row-23;
298
299 //int mark = (plane<<20) + (row<<10) + column;
300 int mark = (plane<<20) + (padl<<10);// + column;
301 void** twig = getTwig(&forwardTOFTree, mark);
302
303 if (*twig == 0) { // this paddle has not been hit yet by any particle track
304 // get space and store it
305
306 s_ForwardTOF_t* tof = *twig = make_s_ForwardTOF();
307 s_FtofCounters_t* counters = make_s_FtofCounters(1);
308 counters->mult = 1;
309 counters->in[0].plane = plane;
310 //counters->in[0].bar = row;
311 counters->in[0].bar = padl;
312 hits = HDDM_NULL(void*)&hddm_s_nullTarget;
313 extras = HDDM_NULL(void*)&hddm_s_nullTarget;
Value stored to 'extras' is never read
314
315 // get space for the left/top or right/down PMT data for a total
316 // of MAX_HITS possible hits in a single paddle
317 // Note: column=0 means paddle read out on both ends,
318 // column=1 means single-ended readout to north end
319 // column=2 means single-ended readout to south end
320
321 if (column == 0 || column == 1 || column == 2) {
322 counters->in[0].ftofTruthHits = hits = make_s_FtofTruthHits(MAX_HITS1000);
323 }
324 tof->ftofCounters = counters;
325 counterCount++;
326
327 } else {
328
329 // this paddle is already registered (was hit before)
330 // get the hit list back
331 s_ForwardTOF_t* tof = *twig;
332 hits = tof->ftofCounters->in[0].ftofTruthHits;
333 }
334
335 if (hits != HDDM_NULL(void*)&hddm_s_nullTarget) {
336
337 // loop over hits in this PM to find correct time slot, north end
338
339 for (nhit = 0; nhit < hits->mult; nhit++)
340 {
341 if (hits->in[nhit].end == 0 &&
342 fabs(hits->in[nhit].t - t) < TWO_HIT_RESOL)
343 {
344 break;
345 }
346 }
347
348 // this hit is within the time frame of a previous hit
349 // combine the times of this weighted by the energy of the hit
350
351 if (nhit < hits->mult) { /* merge with former hit */
352 float dEnew=hits->in[nhit].dE + dEnorth;
353 hits->in[nhit].t =
354 (hits->in[nhit].t * hits->in[nhit].dE + tnorth * dEnorth) /dEnew;
355 hits->in[nhit].dE=dEnew;
356
357 // now add MC tracking information
358 // first get MC pointer of this paddle
359
360 extras = hits->in[nhit].ftofTruthExtras;
361 unsigned int nMChit = extras->mult;
362 if (nMChit < MAX_HITS1000) {
363 extras->in[nMChit].x = x[0];
364 extras->in[nMChit].y = x[1];
365 extras->in[nMChit].z = x[2];
366 extras->in[nMChit].E = pin[3];
367 extras->in[nMChit].px = pin[0]*pin[4];
368 extras->in[nMChit].py = pin[1]*pin[4];
369 extras->in[nMChit].pz = pin[2]*pin[4];
370 extras->in[nMChit].ptype = ipart;
371 extras->in[nMChit].itrack = gidGetId(track);
372 extras->in[nMChit].dist = dist;
373 extras->mult++;
374 }
375
376 } else if (nhit < MAX_HITS1000){ // hit in new time window
377 hits->in[nhit].t = tnorth;
378 hits->in[nhit].dE = dEnorth;
379 hits->in[nhit].end = 0;
380 hits->mult++;
381
382 // create memory for MC track hit information
383 hits->in[nhit].ftofTruthExtras =
384 extras = make_s_FtofTruthExtras(MAX_HITS1000);
385
386 extras->in[0].x = x[0];
387 extras->in[0].y = x[1];
388 extras->in[0].z = x[2];
389 extras->in[0].E = pin[3];
390 extras->in[0].px = pin[0]*pin[4];
391 extras->in[0].py = pin[1]*pin[4];
392 extras->in[0].pz = pin[2]*pin[4];
393 extras->in[0].ptype = ipart;
394 extras->in[0].itrack = gidGetId(track);
395 extras->in[0].dist = dist;
396 extras->mult = 1;
397
398 } else {
399 fprintf(stderrstderr,"HDGeant error in hitForwardTOF (file hitFTOF.c): ");
400 fprintf(stderrstderr,"max hit count %d exceeded, truncating!\n",MAX_HITS1000);
401 }
402
403 // loop over hits in this PM to find correct time slot, south end
404
405 for (nhit = 0; nhit < hits->mult; nhit++)
406 {
407 if (hits->in[nhit].end == 1 &&
408 fabs(hits->in[nhit].t - t) < TWO_HIT_RESOL)
409 {
410 break;
411 }
412 }
413
414 // this hit is within the time frame of a previous hit
415 // combine the times of this weighted by the energy of the hit
416
417 if (nhit < hits->mult) { /* merge with former hit */
418 float dEnew=hits->in[nhit].dE + dEsouth;
419 hits->in[nhit].t =
420 (hits->in[nhit].t * hits->in[nhit].dE + tsouth * dEsouth) / dEnew;
421 hits->in[nhit].dE=dEnew;
422 extras = hits->in[nhit].ftofTruthExtras;
423
424 // now add MC tracking information
425 unsigned int nMChit = extras->mult;
426 if (nMChit < MAX_HITS1000) {
427 extras->in[nMChit].x = x[0];
428 extras->in[nMChit].y = x[1];
429 extras->in[nMChit].z = x[2];
430 extras->in[nMChit].E = pin[3];
431 extras->in[nMChit].px = pin[0]*pin[4];
432 extras->in[nMChit].py = pin[1]*pin[4];
433 extras->in[nMChit].pz = pin[2]*pin[4];
434 extras->in[nMChit].ptype = ipart;
435 extras->in[nMChit].itrack = gidGetId(track);
436 extras->in[nMChit].dist = dist;
437 extras->mult++;
438 }
439
440 } else if (nhit < MAX_HITS1000) { // hit in new time window
441 hits->in[nhit].t = tsouth;
442 hits->in[nhit].dE = dEsouth;
443 hits->in[nhit].end = 1;
444 hits->mult++;
445
446 // create memory space for MC track hit information
447 hits->in[nhit].ftofTruthExtras =
448 extras = make_s_FtofTruthExtras(MAX_HITS1000);
449 extras->in[0].x = x[0];
450 extras->in[0].y = x[1];
451 extras->in[0].z = x[2];
452 extras->in[0].E = pin[3];
453 extras->in[0].px = pin[0]*pin[4];
454 extras->in[0].py = pin[1]*pin[4];
455 extras->in[0].pz = pin[2]*pin[4];
456 extras->in[0].ptype = ipart;
457 extras->in[0].itrack = gidGetId(track);
458 extras->in[0].dist = dist;
459 extras->mult = 1;
460
461 } else {
462 fprintf(stderrstderr,"HDGeant error in hitForwardTOF (file hitFTOF.c): ");
463 fprintf(stderrstderr,"max hit count %d exceeded, truncating!\n",MAX_HITS1000);
464 }
465 }
466 }
467}
468
469/* entry point from fortran */
470
471void hitforwardtof_ (float* xin, float* xout,
472 float* pin, float* pout, float* dEsum,
473 int* track, int* stack, int* history, int* ipart)
474{
475 hitForwardTOF(xin,xout,pin,pout,*dEsum,*track,*stack,*history, *ipart);
476}
477
478
479/* pick and package the hits for shipping */
480// this function is called by loadoutput() (coded in hddmOutput.c)
481// which in turn is called by GUOUT at the end of each event
482
483s_ForwardTOF_t* pickForwardTOF ()
484{
485 s_ForwardTOF_t* box;
486 s_ForwardTOF_t* item;
487
488 if ((counterCount == 0) && (pointCount == 0))
489 {
490 return HDDM_NULL(void*)&hddm_s_nullTarget;
491 }
492
493 box = make_s_ForwardTOF();
494 box->ftofCounters = make_s_FtofCounters(counterCount);
495 box->ftofTruthPoints = make_s_FtofTruthPoints(pointCount);
496
497 while ((item = (s_ForwardTOF_t*) pickTwig(&forwardTOFTree))) {
498 s_FtofCounters_t* counters = item->ftofCounters;
499 int counter;
500 s_FtofTruthPoints_t* points = item->ftofTruthPoints;
501 int point;
502
503 for (counter=0; counter < counters->mult; ++counter) {
504 s_FtofTruthHits_t* hits = counters->in[counter].ftofTruthHits;
505
506 /* compress out the hits below threshold */
507 // cut off parameter is THRESH_MEV
508 int iok,i;
509 int mok=0;
510 // loop over all hits in a counter for the left/up PMT
511 for (iok=i=0; i < hits->mult; i++) {
512
513 // check threshold
514 if (hits->in[i].dE >= THRESH_MEV/1e3) {
515
516 if (iok < i) {
517 hits->in[iok] = hits->in[i];
518 }
519 ++mok;
520 ++iok;
521 }
522 }
523
524 if (iok) {
525 hits->mult = iok;
526 } else if (hits != HDDM_NULL(void*)&hddm_s_nullTarget){ // no hits left over for this PMT
527 counters->in[counter].ftofHits = HDDM_NULL(void*)&hddm_s_nullTarget;
528 FREE(hits)free(hits);
529 }
530
531 if (mok){ // total number of time independent FTOF hits in this counter
532 int m = box->ftofCounters->mult++;
533 // add the hit list of this counter to the list
534 box->ftofCounters->in[m] = counters->in[counter];
535 }
536 } // end of loop over all counters
537
538 if (counters != HDDM_NULL(void*)&hddm_s_nullTarget) {
539 FREE(counters)free(counters);
540 }
541
542 // keep also the MC generated primary track particles
543 for (point=0; point < points->mult; ++point) {
544 int m = box->ftofTruthPoints->mult++;
545 box->ftofTruthPoints->in[m] = points->in[point];
546 }
547 if (points != HDDM_NULL(void*)&hddm_s_nullTarget) {
548 FREE(points)free(points);
549 }
550 FREE(item)free(item);
551 }
552
553 // reset the counters
554 counterCount = pointCount = 0;
555
556 // free the hit list memory used by this event
557 if ((box->ftofCounters != HDDM_NULL(void*)&hddm_s_nullTarget) &&
558 (box->ftofCounters->mult == 0)) {
559 FREE(box->ftofCounters)free(box->ftofCounters);
560 box->ftofCounters = HDDM_NULL(void*)&hddm_s_nullTarget;
561 }
562 if ((box->ftofTruthPoints != HDDM_NULL(void*)&hddm_s_nullTarget) &&
563 (box->ftofTruthPoints->mult == 0)) {
564 FREE(box->ftofTruthPoints)free(box->ftofTruthPoints);
565 box->ftofTruthPoints = HDDM_NULL(void*)&hddm_s_nullTarget;
566 }
567 if ((box->ftofCounters->mult == 0) &&
568 (box->ftofTruthPoints->mult == 0)) {
569 FREE(box)free(box);
570 box = HDDM_NULL(void*)&hddm_s_nullTarget;
571 }
572 return box;
573}