1 | /////////////////////////////////////////////////////////////////
|
---|
2 | //
|
---|
3 | // CORStatfile
|
---|
4 | //
|
---|
5 | // Created: Tue Apr 28 16:14:05 1998
|
---|
6 | // Author: Jose Carlos Gonzales
|
---|
7 | // Purpose: Base class for Event-classes
|
---|
8 | // Notes:
|
---|
9 | //
|
---|
10 | /////////////////////////////////////////////////////////////////
|
---|
11 |
|
---|
12 | // @T \newpage
|
---|
13 |
|
---|
14 | // @section Source code of {\tt CORStatfile.cxx}
|
---|
15 |
|
---|
16 | // @subsection Class {\em CORStatfile}: Implementation
|
---|
17 |
|
---|
18 | // @code
|
---|
19 |
|
---|
20 | #include "CORStatfile.hxx"
|
---|
21 |
|
---|
22 | CORStatfile::CORStatfile ()
|
---|
23 | {
|
---|
24 | init ( 79 ); // assumes thstep = 10 g/cm2 (790/10 = 79)
|
---|
25 | }
|
---|
26 |
|
---|
27 | CORStatfile::CORStatfile ( Int_t n )
|
---|
28 | {
|
---|
29 | init ( n );
|
---|
30 | }
|
---|
31 |
|
---|
32 | void
|
---|
33 | CORStatfile::init ( Int_t n )
|
---|
34 | {
|
---|
35 | Int_t i, k;
|
---|
36 |
|
---|
37 | nstep = n;
|
---|
38 |
|
---|
39 | evth = new Float_t[MAXBUF]; // event header
|
---|
40 | evte = new Float_t[MAXBUF]; // event end
|
---|
41 |
|
---|
42 | nproto = new Int_t[nstep];
|
---|
43 | nprotb = new Int_t[nstep];
|
---|
44 | nneutr = new Int_t[nstep];
|
---|
45 | nneutb = new Int_t[nstep];
|
---|
46 | nphoto = new Int_t[nstep];
|
---|
47 | nelect = new Int_t[nstep];
|
---|
48 | nposit = new Int_t[nstep];
|
---|
49 | nnu = new Int_t[nstep];
|
---|
50 | nmum = new Int_t[nstep];
|
---|
51 | nmup = new Int_t[nstep];
|
---|
52 | npi0 = new Int_t[nstep];
|
---|
53 | npim = new Int_t[nstep];
|
---|
54 | npip = new Int_t[nstep];
|
---|
55 | nk0l = new Int_t[nstep];
|
---|
56 | nk0s = new Int_t[nstep];
|
---|
57 | nkmi = new Int_t[nstep];
|
---|
58 | nkpl = new Int_t[nstep];
|
---|
59 | nhyp = new Int_t[nstep];
|
---|
60 | ndeut = new Int_t[nstep];
|
---|
61 | ntrit = new Int_t[nstep];
|
---|
62 | nalpha = new Int_t[nstep];
|
---|
63 | nother = new Int_t[nstep];
|
---|
64 |
|
---|
65 | plong = new Float_t * [9];
|
---|
66 | aplong = new Float_t * [9];
|
---|
67 |
|
---|
68 | for ( i=0; i<9; i++ ) {
|
---|
69 | plong[i] = new Float_t[NPLONG];
|
---|
70 | aplong[i] = new Float_t[NPLONG];
|
---|
71 | }
|
---|
72 |
|
---|
73 | for ( i=0; i<9; i++ )
|
---|
74 | for ( k=0; k<NPLONG; k++ )
|
---|
75 | plong[i][k] = aplong[i][k] = 0.;
|
---|
76 |
|
---|
77 | opened = 0;
|
---|
78 | bunch = 1.0;
|
---|
79 | }
|
---|
80 |
|
---|
81 | CORStatfile::~CORStatfile ()
|
---|
82 | {
|
---|
83 | Int_t i;
|
---|
84 |
|
---|
85 | for ( i=0; i<9; i++ ) {
|
---|
86 | delete [] plong[i];
|
---|
87 | delete [] aplong[i];
|
---|
88 | plong[i] = aplong[i] = NULL;
|
---|
89 | }
|
---|
90 |
|
---|
91 | delete [] plong;
|
---|
92 | delete [] aplong;
|
---|
93 | plong = aplong = NULL;
|
---|
94 |
|
---|
95 | delete [] evth;
|
---|
96 | delete [] evte;
|
---|
97 | evth = evte = NULL;
|
---|
98 |
|
---|
99 | delete [] nproto;
|
---|
100 | delete [] nprotb;
|
---|
101 | delete [] nneutr;
|
---|
102 | delete [] nneutb;
|
---|
103 | delete [] nphoto;
|
---|
104 | delete [] nelect;
|
---|
105 | delete [] nposit;
|
---|
106 | delete [] nnu;
|
---|
107 | delete [] nmum;
|
---|
108 | delete [] nmup;
|
---|
109 | delete [] npi0;
|
---|
110 | delete [] npim;
|
---|
111 | delete [] npip;
|
---|
112 | delete [] nk0l;
|
---|
113 | delete [] nk0s;
|
---|
114 | delete [] nkmi;
|
---|
115 | delete [] nkpl;
|
---|
116 | delete [] nhyp;
|
---|
117 | delete [] ndeut;
|
---|
118 | delete [] ntrit;
|
---|
119 | delete [] nalpha;
|
---|
120 | delete [] nother;
|
---|
121 |
|
---|
122 | nproto = nprotb = nneutr = nneutb =
|
---|
123 | nphoto = nelect = nposit = nnu =
|
---|
124 | nmum = nmup = npi0 = npim = npip =
|
---|
125 | nk0l = nk0s = nkmi = nkpl = nhyp =
|
---|
126 | ndeut = ntrit = nalpha = nother = NULL;
|
---|
127 |
|
---|
128 | }
|
---|
129 |
|
---|
130 | Int_t
|
---|
131 | CORStatfile::openfile ( char *fname )
|
---|
132 | {
|
---|
133 | if ( input_file != NULL )
|
---|
134 | input_file.close();
|
---|
135 | input_file.open( fname );
|
---|
136 | opened = 1;
|
---|
137 | return ( ! input_file.bad() );
|
---|
138 | }
|
---|
139 |
|
---|
140 | void
|
---|
141 | CORStatfile::closefile ( void )
|
---|
142 | {
|
---|
143 | input_file.close();
|
---|
144 | opened = 0;
|
---|
145 | }
|
---|
146 |
|
---|
147 | void
|
---|
148 | CORStatfile::read()
|
---|
149 | {
|
---|
150 | Int_t i, k;
|
---|
151 | Float_t f;
|
---|
152 |
|
---|
153 | input_file.read ( (char *)evth, sizeof (Float_t) * MAXBUF );
|
---|
154 | input_file.read ( (char *)evte, sizeof (Float_t) * MAXBUF );
|
---|
155 | input_file.read ( (char *)&timefirst, sizeof (Float_t) );
|
---|
156 | input_file.read ( (char *)&timelast, sizeof (Float_t) );
|
---|
157 |
|
---|
158 | for (i = 0; i < 10; i++) {
|
---|
159 |
|
---|
160 | input_file.read ( (char *)(nproto + i), sizeof (Int_t) );
|
---|
161 | input_file.read ( (char *)(nprotb + i), sizeof (Int_t) );
|
---|
162 | input_file.read ( (char *)(nneutr + i), sizeof (Int_t) );
|
---|
163 | input_file.read ( (char *)(nneutb + i), sizeof (Int_t) );
|
---|
164 | input_file.read ( (char *)(nphoto + i), sizeof (Int_t) );
|
---|
165 | input_file.read ( (char *)(nelect + i), sizeof (Int_t) );
|
---|
166 | input_file.read ( (char *)(nposit + i), sizeof (Int_t) );
|
---|
167 | input_file.read ( (char *)(nnu + i), sizeof (Int_t) );
|
---|
168 | input_file.read ( (char *)(nmum + i), sizeof (Int_t) );
|
---|
169 | input_file.read ( (char *)(nmup + i), sizeof (Int_t) );
|
---|
170 | input_file.read ( (char *)(npi0 + i), sizeof (Int_t) );
|
---|
171 | input_file.read ( (char *)(npim + i), sizeof (Int_t) );
|
---|
172 | input_file.read ( (char *)(npip + i), sizeof (Int_t) );
|
---|
173 | input_file.read ( (char *)(nk0l + i), sizeof (Int_t) );
|
---|
174 | input_file.read ( (char *)(nk0s + i), sizeof (Int_t) );
|
---|
175 | input_file.read ( (char *)(nkmi + i), sizeof (Int_t) );
|
---|
176 | input_file.read ( (char *)(nkpl + i), sizeof (Int_t) );
|
---|
177 | input_file.read ( (char *)(nhyp + i), sizeof (Int_t) );
|
---|
178 | input_file.read ( (char *)(ndeut + i), sizeof (Int_t) );
|
---|
179 | input_file.read ( (char *)(ntrit + i), sizeof (Int_t) );
|
---|
180 | input_file.read ( (char *)(nalpha + i), sizeof (Int_t) );
|
---|
181 | input_file.read ( (char *)(nother + i), sizeof (Int_t) );
|
---|
182 |
|
---|
183 | }
|
---|
184 |
|
---|
185 | input_file.read ( (char *)&ifinnu, sizeof (Int_t) );
|
---|
186 | input_file.read ( (char *)&ifinpi, sizeof (Int_t) );
|
---|
187 | input_file.read ( (char *)&ifinet, sizeof (Int_t) );
|
---|
188 | input_file.read ( (char *)&ifinka, sizeof (Int_t) );
|
---|
189 | input_file.read ( (char *)&ifinhy, sizeof (Int_t) );
|
---|
190 | input_file.read ( (char *)&cerele, sizeof (Int_t) );
|
---|
191 | input_file.read ( (char *)&cerhad, sizeof (Int_t) );
|
---|
192 |
|
---|
193 | input_file.read ( (char *)&lpct1, sizeof (Int_t) );
|
---|
194 | input_file.read ( (char *)&nstep, sizeof (Int_t) );
|
---|
195 | input_file.read ( (char *)&thstep, sizeof (Float_t) );
|
---|
196 |
|
---|
197 | for (k = 0; k < 9; k++)
|
---|
198 | for (i = 0; i < nstep; i++) {
|
---|
199 | input_file.read ( (char *)&f, sizeof (Float_t) );
|
---|
200 | plong[k][i] = f;
|
---|
201 | }
|
---|
202 |
|
---|
203 | for (k = 0; k < 9; k++)
|
---|
204 | for (i = 0; i < nstep; i++)
|
---|
205 | aplong[k][i] += plong[k][i] * bunch;
|
---|
206 |
|
---|
207 | }
|
---|
208 |
|
---|
209 | void
|
---|
210 | CORStatfile::write(ofstream &output_file)
|
---|
211 | {
|
---|
212 | Int_t i, k;
|
---|
213 | Float_t f = 0.;
|
---|
214 |
|
---|
215 | output_file.write ( (char *)evth, sizeof (Float_t) * MAXBUF );
|
---|
216 | output_file.write ( (char *)evte, sizeof (Float_t) * MAXBUF );
|
---|
217 | output_file.write ( (char *)&timefirst, sizeof (Float_t) );
|
---|
218 | output_file.write ( (char *)&timelast, sizeof (Float_t) );
|
---|
219 |
|
---|
220 | for (i = 0; i < 10; i++) {
|
---|
221 |
|
---|
222 | output_file.write ( (char *)(nproto + i), sizeof (Int_t) );
|
---|
223 | output_file.write ( (char *)(nprotb + i), sizeof (Int_t) );
|
---|
224 | output_file.write ( (char *)(nneutr + i), sizeof (Int_t) );
|
---|
225 | output_file.write ( (char *)(nneutb + i), sizeof (Int_t) );
|
---|
226 | output_file.write ( (char *)(nphoto + i), sizeof (Int_t) );
|
---|
227 | output_file.write ( (char *)(nelect + i), sizeof (Int_t) );
|
---|
228 | output_file.write ( (char *)(nposit + i), sizeof (Int_t) );
|
---|
229 | output_file.write ( (char *)(nnu + i), sizeof (Int_t) );
|
---|
230 | output_file.write ( (char *)(nmum + i), sizeof (Int_t) );
|
---|
231 | output_file.write ( (char *)(nmup + i), sizeof (Int_t) );
|
---|
232 | output_file.write ( (char *)(npi0 + i), sizeof (Int_t) );
|
---|
233 | output_file.write ( (char *)(npim + i), sizeof (Int_t) );
|
---|
234 | output_file.write ( (char *)(npip + i), sizeof (Int_t) );
|
---|
235 | output_file.write ( (char *)(nk0l + i), sizeof (Int_t) );
|
---|
236 | output_file.write ( (char *)(nk0s + i), sizeof (Int_t) );
|
---|
237 | output_file.write ( (char *)(nkmi + i), sizeof (Int_t) );
|
---|
238 | output_file.write ( (char *)(nkpl + i), sizeof (Int_t) );
|
---|
239 | output_file.write ( (char *)(nhyp + i), sizeof (Int_t) );
|
---|
240 | output_file.write ( (char *)(ndeut + i), sizeof (Int_t) );
|
---|
241 | output_file.write ( (char *)(ntrit + i), sizeof (Int_t) );
|
---|
242 | output_file.write ( (char *)(nalpha + i), sizeof (Int_t) );
|
---|
243 | output_file.write ( (char *)(nother + i), sizeof (Int_t) );
|
---|
244 |
|
---|
245 | }
|
---|
246 |
|
---|
247 | output_file.write ( (char *)&ifinnu, sizeof (Int_t) );
|
---|
248 | output_file.write ( (char *)&ifinpi, sizeof (Int_t) );
|
---|
249 | output_file.write ( (char *)&ifinet, sizeof (Int_t) );
|
---|
250 | output_file.write ( (char *)&ifinka, sizeof (Int_t) );
|
---|
251 | output_file.write ( (char *)&ifinhy, sizeof (Int_t) );
|
---|
252 | output_file.write ( (char *)&cerele, sizeof (Int_t) );
|
---|
253 | output_file.write ( (char *)&cerhad, sizeof (Int_t) );
|
---|
254 |
|
---|
255 | output_file.write ( (char *)&lpct1, sizeof (Int_t) );
|
---|
256 | output_file.write ( (char *)&nstep, sizeof (Int_t) );
|
---|
257 | output_file.write ( (char *)&thstep, sizeof (Float_t) );
|
---|
258 |
|
---|
259 | for (k = 0; k < 9; k++)
|
---|
260 | for (i = 0; i < nstep; i++) {
|
---|
261 | output_file.write ( (char *)&f, sizeof (Float_t) );
|
---|
262 | }
|
---|
263 |
|
---|
264 | }
|
---|
265 |
|
---|
266 | // @endcode
|
---|