1 | /*******************************************************************************
|
---|
2 | * *
|
---|
3 | * stdhep_mcfio.c -- C version of mcfio interface routines *
|
---|
4 | * *
|
---|
5 | * Copyright (c) 1995 Universities Research Association, Inc. *
|
---|
6 | * All rights reserved. *
|
---|
7 | * *
|
---|
8 | * This material resulted from work developed under a Government Contract and *
|
---|
9 | * is subject to the following license: The Government retains a paid-up, *
|
---|
10 | * nonexclusive, irrevocable worldwide license to reproduce, prepare derivative *
|
---|
11 | * works, perform publicly and display publicly by or for the Government, *
|
---|
12 | * including the right to distribute to other Government contractors. Neither *
|
---|
13 | * the United States nor the United States Department of Energy, nor any of *
|
---|
14 | * their employees, makes any warranty, express or implied, or assumes any *
|
---|
15 | * legal liability or responsibility for the accuracy, completeness, or *
|
---|
16 | * usefulness of any information, apparatus, product, or process disclosed, or *
|
---|
17 | * represents that its use would not infringe privately owned rights. *
|
---|
18 | * *
|
---|
19 | * *
|
---|
20 | * Written by Lynn Garren *
|
---|
21 | * *
|
---|
22 | * *
|
---|
23 | *******************************************************************************/
|
---|
24 | #include <stdio.h>
|
---|
25 | #include <string.h>
|
---|
26 | #include <stdlib.h>
|
---|
27 | #include <rpc/types.h>
|
---|
28 | #include <rpc/xdr.h>
|
---|
29 | #ifndef FALSE
|
---|
30 | #define FALSE 0
|
---|
31 | #endif
|
---|
32 | #ifndef TRUE
|
---|
33 | #define TRUE 1
|
---|
34 | #endif
|
---|
35 | /*
|
---|
36 | * mcfio/StdHep definitions and include files
|
---|
37 | */
|
---|
38 | #include "Utilities/mcfio/mcf_xdr.h"
|
---|
39 | #include "Utilities/mcfio/mcfio_Block.h"
|
---|
40 | #include "Utilities/mcfio/mcfio_Dict.h"
|
---|
41 | #include "Utilities/mcfio/mcfio_Direct.h"
|
---|
42 | #include "Utilities/mcfio/mcfio_Util1.h"
|
---|
43 | #include "Utilities/stdhep/stdhep.h"
|
---|
44 | #include "Utilities/stdhep/hepev4.h"
|
---|
45 | #include "Utilities/stdhep/hepeup.h"
|
---|
46 | #include "Utilities/stdhep/heprup.h"
|
---|
47 | #include "Utilities/stdhep/stdtmp.h"
|
---|
48 | #include "Utilities/stdhep/stdhd.h"
|
---|
49 | #include "Utilities/stdhep/stdcnt.h"
|
---|
50 | #include "Utilities/stdhep/stdhep_mcfio.h"
|
---|
51 |
|
---|
52 | #define LUN_ARRAY 16 /* I/O array size */
|
---|
53 | struct stdstr {
|
---|
54 | int ixdrstr[LUN_ARRAY]; /* array of xdr stream addresses */
|
---|
55 | } stdstr_;
|
---|
56 |
|
---|
57 | /* extern struct hepevt hepevt_; */
|
---|
58 | extern struct hepevt myhepevt;
|
---|
59 | extern struct hepev2 hepev2_;
|
---|
60 | extern struct hepev3 hepev3_;
|
---|
61 | extern struct hepev4 hepev4_;
|
---|
62 | extern struct hepev5 hepev5_;
|
---|
63 | extern struct hepeup hepeup_;
|
---|
64 | extern struct heprup heprup_;
|
---|
65 | extern struct stdcnt stdcnt_;
|
---|
66 | extern struct stdhd1 stdhd1_;
|
---|
67 | extern struct stdhd2 stdhd2_;
|
---|
68 | extern struct stdtmp stdtmp_;
|
---|
69 | extern struct tmpev4 tmpev4_;
|
---|
70 |
|
---|
71 | extern int xdr_stdhep_();
|
---|
72 | extern int xdr_stdhep_multi_();
|
---|
73 | extern int xdr_stdhep_4_();
|
---|
74 | extern int xdr_stdhep_4_multi_();
|
---|
75 | extern int xdr_stdhep_cm1_();
|
---|
76 | extern int xdr_hepeup_();
|
---|
77 | extern int xdr_heprup_();
|
---|
78 |
|
---|
79 | int StdHepXdrReadInit(char *filename, int *ntries, int ist)
|
---|
80 | {
|
---|
81 | int ierr;
|
---|
82 |
|
---|
83 | mcfioC_Init();
|
---|
84 | ierr = StdHepXdrReadOpen(filename, ntries, ist);
|
---|
85 | return ierr;
|
---|
86 | }
|
---|
87 | int StdHepXdrReadOpen(char *filename, int *ntries, int ist)
|
---|
88 | {
|
---|
89 | int istream, iblk;
|
---|
90 | int numblocks, blkids[50];
|
---|
91 |
|
---|
92 | istream = mcfioC_OpenReadDirect(filename);
|
---|
93 | stdstr_.ixdrstr[ist] = istream;
|
---|
94 | if (istream == -1) {
|
---|
95 | fprintf(stderr," StdHepXdrReadOpen: cannot open output file \n");
|
---|
96 | return -1;
|
---|
97 | }
|
---|
98 | mcfioC_InfoStreamChar(istream, MCFIO_CREATIONDATE, stdhd1_.date, &stdhd2_.dlen);
|
---|
99 | mcfioC_InfoStreamChar(istream, MCFIO_TITLE, stdhd1_.title, &stdhd2_.tlen);
|
---|
100 | mcfioC_InfoStreamChar(istream, MCFIO_COMMENT, stdhd1_.comment, &stdhd2_.clen);
|
---|
101 | mcfioC_InfoStreamInt(istream, MCFIO_NUMEVTS, ntries);
|
---|
102 | mcfioC_InfoStreamInt(istream, MCFIO_NUMBLOCKS, &numblocks);
|
---|
103 | mcfioC_InfoStreamInt(istream, MCFIO_BLOCKIDS, blkids);
|
---|
104 |
|
---|
105 | stdhd2_.numblocks = numblocks;
|
---|
106 | for ( iblk=0; iblk < numblocks; ++iblk ) {
|
---|
107 | stdhd2_.blkids[iblk] = blkids[iblk];
|
---|
108 | }
|
---|
109 |
|
---|
110 | stdcnt_.nstdrd = 0;
|
---|
111 | stdcnt_.nlhrd = 0;
|
---|
112 | /*
|
---|
113 | fprintf(stdout,
|
---|
114 | " StdHepXdrReadOpen: successfully opened input stream %d\n", istream);
|
---|
115 | fprintf(stdout," title: %s\n", stdhd1_.title);
|
---|
116 | fprintf(stdout," date: %s\n", stdhd1_.date);
|
---|
117 | fprintf(stdout," %d events\n", *ntries);
|
---|
118 | fprintf(stdout," %d blocks per event\n", stdhd2_.numblocks);
|
---|
119 | */
|
---|
120 | return 0;
|
---|
121 | }
|
---|
122 | int StdHepXdrRead(int *ilbl, int ist)
|
---|
123 | {
|
---|
124 | /* Purpose: to read a buffer or an event from the standard common block.
|
---|
125 | C
|
---|
126 | C returns ilbl
|
---|
127 | C
|
---|
128 | C ilbl = 1 - standard HEPEVT common block
|
---|
129 | C ilbl = 2 - standard HEPEVT common block and HEPEV2
|
---|
130 | C ilbl = 3 - stdevent struct
|
---|
131 | C ilbl = 4 - standard HEPEVT common block with Les Houches
|
---|
132 | C ilbl = 5 - standard HEPEVT common block with Les Houches
|
---|
133 | C and multiple collisions
|
---|
134 | C ilbl = 11 - HEPEUP common block
|
---|
135 | C ilbl = 12 - HEPRUP common block
|
---|
136 | C ilbl = 100 - STDHEP begin run record
|
---|
137 | C ilbl = 200 - STDHEP end run record
|
---|
138 | C */
|
---|
139 |
|
---|
140 | int istat;
|
---|
141 | int istream;
|
---|
142 | int i, numblocks, blkids[50];
|
---|
143 |
|
---|
144 | istream = stdstr_.ixdrstr[ist];
|
---|
145 | if(mcfioC_NextEvent(istream) != MCFIO_RUNNING) {
|
---|
146 | mcfioC_InfoStreamInt(istream, MCFIO_STATUS, &istat);
|
---|
147 | if(istat == MCFIO_EOF) {
|
---|
148 | fprintf(stderr," StdHepXdrRead: end of file found\n");
|
---|
149 | return 1;
|
---|
150 | }
|
---|
151 | else {
|
---|
152 | fprintf(stderr," StdHepXdrRead: unrecognized status - stop\n");
|
---|
153 | return 2;
|
---|
154 | }
|
---|
155 | }
|
---|
156 | mcfioC_InfoStreamInt(istream, MCFIO_NUMBLOCKS, &numblocks);
|
---|
157 | mcfioC_InfoStreamInt(istream, MCFIO_BLOCKIDS, blkids);
|
---|
158 |
|
---|
159 | for (i = 0; i < numblocks; i++) {
|
---|
160 | if (blkids[i] == MCFIO_STDHEP) {
|
---|
161 | StdHepZero();
|
---|
162 | if (mcfioC_Block(istream,MCFIO_STDHEP,xdr_stdhep_) != -1) {
|
---|
163 | *ilbl = 1;
|
---|
164 | if (StdHepTempCopy(2,istream) == 0)
|
---|
165 | stdcnt_.nstdrd = stdcnt_.nstdrd + 1;
|
---|
166 | return 0;
|
---|
167 | }
|
---|
168 | }
|
---|
169 | else if (blkids[i] == MCFIO_STDHEPM) {
|
---|
170 | StdHepZero();
|
---|
171 | if (mcfioC_Block(istream,MCFIO_STDHEPM,xdr_stdhep_multi_) != -1) {
|
---|
172 | *ilbl = 2;
|
---|
173 | stdcnt_.nstdrd = stdcnt_.nstdrd + 1;
|
---|
174 | return 0;
|
---|
175 | }
|
---|
176 | }
|
---|
177 | else if (blkids[i] == MCFIO_STDHEP4) {
|
---|
178 | StdHepZero();
|
---|
179 | if (mcfioC_Block(istream,MCFIO_STDHEP4,xdr_stdhep_4_) != -1) {
|
---|
180 | *ilbl = 4;
|
---|
181 | if (StdHepTempCopy(2,istream) == 0)
|
---|
182 | stdcnt_.nstdrd = stdcnt_.nstdrd + 1;
|
---|
183 | return 0;
|
---|
184 | }
|
---|
185 | }
|
---|
186 | else if (blkids[i] == MCFIO_STDHEP4M) {
|
---|
187 | StdHepZero();
|
---|
188 | if (mcfioC_Block(istream,MCFIO_STDHEP4M,xdr_stdhep_4_multi_) != -1) {
|
---|
189 | *ilbl = 5;
|
---|
190 | stdcnt_.nstdrd = stdcnt_.nstdrd + 1;
|
---|
191 | return 0;
|
---|
192 | }
|
---|
193 | }
|
---|
194 | else if (blkids[i] == MCFIO_STDHEPBEG) {
|
---|
195 | if (mcfioC_Block(istream,MCFIO_STDHEPBEG,xdr_stdhep_cm1_) != -1) {
|
---|
196 | *ilbl = 100;
|
---|
197 | return 0;
|
---|
198 | }
|
---|
199 | }
|
---|
200 | else if (blkids[i] == MCFIO_STDHEPEND) {
|
---|
201 | if (mcfioC_Block(istream,MCFIO_STDHEPEND,xdr_stdhep_cm1_) != -1) {
|
---|
202 | *ilbl = 200;
|
---|
203 | return 0;
|
---|
204 | }
|
---|
205 | }
|
---|
206 | else if (blkids[i] == MCFIO_HEPEUP) {
|
---|
207 | if (mcfioC_Block(istream,MCFIO_HEPEUP,xdr_hepeup_) != -1) {
|
---|
208 | *ilbl = 11;
|
---|
209 | stdcnt_.nlhrd = stdcnt_.nlhrd + 1;
|
---|
210 | return 0;
|
---|
211 | }
|
---|
212 | }
|
---|
213 | else if (blkids[i] == MCFIO_HEPRUP) {
|
---|
214 | if (mcfioC_Block(istream,MCFIO_HEPRUP,xdr_heprup_) != -1) {
|
---|
215 | *ilbl = 12;
|
---|
216 | stdcnt_.nlhrd = stdcnt_.nlhrd + 1;
|
---|
217 | return 0;
|
---|
218 | }
|
---|
219 | }
|
---|
220 | }
|
---|
221 | return 1;
|
---|
222 | }
|
---|
223 | int StdHepXdrReadMulti(int *ilbl, int ist)
|
---|
224 | {
|
---|
225 | /* Purpose: to read a buffer or an event from the standard common block
|
---|
226 | this routine handles multiple input streams
|
---|
227 | C
|
---|
228 | C return ilbl
|
---|
229 | C
|
---|
230 | C ilbl = 1 - standard HEPEVT common block
|
---|
231 | C ilbl = 2 - standard HEPEVT common block and HEPEV2
|
---|
232 | C ilbl = 100 - STDHEP begin run record
|
---|
233 | C ilbl = 200 - STDHEP end run record
|
---|
234 | C */
|
---|
235 |
|
---|
236 | int istat;
|
---|
237 | int istream;
|
---|
238 | int i, numblocks, blkids[50];
|
---|
239 |
|
---|
240 | istream = stdstr_.ixdrstr[ist];
|
---|
241 | if(mcfioC_NextEvent(istream) != MCFIO_RUNNING) {
|
---|
242 | mcfioC_InfoStreamInt(istream, MCFIO_STATUS, &istat);
|
---|
243 | if(istat == MCFIO_EOF) {
|
---|
244 | fprintf(stderr," StdHepXdrReadMulti: end of file found\n");
|
---|
245 | return 1;
|
---|
246 | }
|
---|
247 | else {
|
---|
248 | fprintf(stderr,
|
---|
249 | " StdHepXdrReadMulti: unrecognized status - stop\n");
|
---|
250 | return 2;
|
---|
251 | }
|
---|
252 | }
|
---|
253 | mcfioC_InfoStreamInt(istream, MCFIO_NUMBLOCKS, &numblocks);
|
---|
254 | mcfioC_InfoStreamInt(istream, MCFIO_BLOCKIDS, blkids);
|
---|
255 | for (i = 0; i < numblocks; i++) {
|
---|
256 | if (blkids[i] == MCFIO_STDHEP) {
|
---|
257 | if (mcfioC_Block(istream,MCFIO_STDHEP,xdr_stdhep_) == -1) {
|
---|
258 | fprintf(stderr,
|
---|
259 | " StdHepXdrReadMulti: unable to read xdr block\n");
|
---|
260 | return 1;
|
---|
261 | }
|
---|
262 | *ilbl = 1;
|
---|
263 | if (StdHepTempCopy(2,istream) == 0)
|
---|
264 | stdcnt_.nstdrd = stdcnt_.nstdrd + 1;
|
---|
265 | }
|
---|
266 | else if (blkids[i] == MCFIO_STDHEPM) {
|
---|
267 | fprintf(stderr,
|
---|
268 | " StdHepXdrRead: multiple interaction event - HEPEVT is zeroed\n");
|
---|
269 | StdHepZero();
|
---|
270 | if (mcfioC_Block(istream,MCFIO_STDHEPM,xdr_stdhep_multi_) == -1) {
|
---|
271 | fprintf(stderr,
|
---|
272 | " StdHepXdrReadMulti: unable to read xdr block\n");
|
---|
273 | return 1;
|
---|
274 | }
|
---|
275 | *ilbl = 2;
|
---|
276 | stdcnt_.nstdrd = stdcnt_.nstdrd + 1;
|
---|
277 | }
|
---|
278 | else if (blkids[i] == MCFIO_STDHEP4) {
|
---|
279 | if (mcfioC_Block(istream,MCFIO_STDHEP4,xdr_stdhep_4_) == -1) {
|
---|
280 | fprintf(stderr,
|
---|
281 | " StdHepXdrReadMulti: unable to read xdr block\n");
|
---|
282 | return 1;
|
---|
283 | }
|
---|
284 | *ilbl = 4;
|
---|
285 | if (StdHepTempCopy(2,istream) == 0)
|
---|
286 | stdcnt_.nstdrd = stdcnt_.nstdrd + 1;
|
---|
287 | }
|
---|
288 | else if (blkids[i] == MCFIO_STDHEP4M) {
|
---|
289 | fprintf(stderr,
|
---|
290 | " StdHepXdrRead: multiple interaction event - HEPEVT is zeroed\n");
|
---|
291 | StdHepZero();
|
---|
292 | if (mcfioC_Block(istream,MCFIO_STDHEP4M,xdr_stdhep_4_multi_) == -1) {
|
---|
293 | fprintf(stderr,
|
---|
294 | " StdHepXdrReadMulti: unable to read xdr block\n");
|
---|
295 | return 1;
|
---|
296 | }
|
---|
297 | *ilbl = 5;
|
---|
298 | stdcnt_.nstdrd = stdcnt_.nstdrd + 1;
|
---|
299 | }
|
---|
300 | }
|
---|
301 | return 0;
|
---|
302 | }
|
---|
303 | int StdHepXdrWriteInit(char *filename, char *title, int ntries, int ist)
|
---|
304 | {
|
---|
305 | int ierr;
|
---|
306 |
|
---|
307 | mcfioC_Init();
|
---|
308 | ierr = StdHepXdrWriteOpen(filename, title, ntries, ist);
|
---|
309 | return ierr;
|
---|
310 | }
|
---|
311 | int StdHepXdrWriteOpen(char *filename, char *title, int ntries, int ist)
|
---|
312 | {
|
---|
313 | int istream, iblk;
|
---|
314 | int numblocks = 8;
|
---|
315 | int blkids[50];
|
---|
316 | char *comment = '\0';
|
---|
317 |
|
---|
318 | blkids[0] = MCFIO_STDHEP;
|
---|
319 | blkids[1] = MCFIO_STDHEPM;
|
---|
320 | blkids[2] = MCFIO_STDHEPBEG;
|
---|
321 | blkids[3] = MCFIO_STDHEPEND;
|
---|
322 | blkids[4] = MCFIO_STDHEP4;
|
---|
323 | blkids[5] = MCFIO_STDHEP4M;
|
---|
324 | blkids[6] = MCFIO_HEPEUP;
|
---|
325 | blkids[7] = MCFIO_HEPRUP;
|
---|
326 |
|
---|
327 | strncpy(stdhd1_.title,title,255);
|
---|
328 | stdhd2_.numblocks = numblocks;
|
---|
329 | for ( iblk=0; iblk < numblocks; ++iblk ) {
|
---|
330 | stdhd2_.blkids[iblk] = blkids[iblk];
|
---|
331 | }
|
---|
332 |
|
---|
333 | istream = mcfioC_OpenWriteDirect(filename, title, comment,
|
---|
334 | ntries, blkids, numblocks);
|
---|
335 | stdstr_.ixdrstr[ist] = istream;
|
---|
336 | if (istream == -1) {
|
---|
337 | fprintf(stderr," StdHepXdrWriteOpen: cannot open output file \n");
|
---|
338 | return -1;
|
---|
339 | }
|
---|
340 | fprintf(stdout," StdHepXdrWriteOpen: I/O initialized for StdHep only\n");
|
---|
341 | return 0;
|
---|
342 | }
|
---|
343 | int StdHepXdrWrite(int ilbl, int ist)
|
---|
344 | {
|
---|
345 | int iret = 0;
|
---|
346 |
|
---|
347 | if ((ilbl == 1) || (ilbl == 2))
|
---|
348 | iret = StdHepXdrWriteEvent(ilbl, ist);
|
---|
349 | else if ((ilbl == 4) || (ilbl == 5))
|
---|
350 | iret = StdHepXdrWriteEventLH(ilbl, ist);
|
---|
351 | else if (ilbl == 11)
|
---|
352 | iret = StdHepXdrWriteEventEUP(ilbl, ist);
|
---|
353 | else if (ilbl == 12)
|
---|
354 | iret = StdHepXdrWriteEventRUP(ilbl, ist);
|
---|
355 | else if ((ilbl == 100) || (ilbl == 200))
|
---|
356 | iret = StdHepXdrWriteCM(ilbl, ist);
|
---|
357 | else
|
---|
358 | fprintf(stderr,
|
---|
359 | " StdHepXdrWrite: don't know what to do with record type %d\n", ilbl);
|
---|
360 | return iret;
|
---|
361 | }
|
---|
362 | int StdHepXdrWriteCM(int ilbl, int ist)
|
---|
363 | {
|
---|
364 | int istream;
|
---|
365 |
|
---|
366 | istream = stdstr_.ixdrstr[ist];
|
---|
367 | if (ilbl == 100) {
|
---|
368 | if (mcfioC_Block(istream, MCFIO_STDHEPBEG, xdr_stdhep_cm1_) == -1) {
|
---|
369 | fprintf(stderr,
|
---|
370 | " StdHepXdrWriteCM: error filling stdhep cm1 common block\n");
|
---|
371 | return 2;
|
---|
372 | }
|
---|
373 | }
|
---|
374 | else if (ilbl == 200) {
|
---|
375 | if (mcfioC_Block(istream, MCFIO_STDHEPEND, xdr_stdhep_cm1_) == -1) {
|
---|
376 | fprintf(stderr,
|
---|
377 | " StdHepXdrWriteCM: error filling stdhep cm1 common block\n");
|
---|
378 | return 2;
|
---|
379 | }
|
---|
380 | }
|
---|
381 | else {
|
---|
382 | fprintf(stderr,
|
---|
383 | " StdHepXdrWriteCM: called with improper label %d\n",ilbl);
|
---|
384 | return 3;
|
---|
385 | }
|
---|
386 | if (mcfioC_NextEvent(istream) == -1) {
|
---|
387 | fprintf(stderr,
|
---|
388 | " StdHepXdrWriteCM: error writing stdhep cm1 xdr block\n");
|
---|
389 | return 1;
|
---|
390 | }
|
---|
391 | return 0;
|
---|
392 | }
|
---|
393 | int StdHepXdrWriteEvent(int ilbl, int ist)
|
---|
394 | {
|
---|
395 | int istream;
|
---|
396 |
|
---|
397 | istream = stdstr_.ixdrstr[ist];
|
---|
398 | if ((ilbl != 1) && (ilbl != 2)) {
|
---|
399 | fprintf(stderr,
|
---|
400 | " StdHepXdrWriteEvent: called with illegal label %d\n",
|
---|
401 | ilbl);
|
---|
402 | return 3;
|
---|
403 | }
|
---|
404 | else if (myhepevt.nhep <= 0) {
|
---|
405 | fprintf(stderr,
|
---|
406 | " StdHepXdrWriteEvent: event %d is empty\n", myhepevt.nevhep);
|
---|
407 | return 0;
|
---|
408 | }
|
---|
409 | else if (ilbl == 1) {
|
---|
410 | if (StdHepTempCopy(1,istream) != 0) {
|
---|
411 | fprintf(stderr,
|
---|
412 | " StdHepXdrWriteEvent: copy failed - event not written\n");
|
---|
413 | return 4;
|
---|
414 | }
|
---|
415 | if (mcfioC_Block(istream, MCFIO_STDHEP, xdr_stdhep_) == -1) {
|
---|
416 | fprintf(stderr,
|
---|
417 | " StdHepXdrWriteEvent: error filling stdhep block for event %d\n",
|
---|
418 | myhepevt.nevhep);
|
---|
419 | return 2;
|
---|
420 | }
|
---|
421 | mcfioC_SetEventInfo(istream, MCFIO_STORENUMBER, &myhepevt.nevhep);
|
---|
422 | }
|
---|
423 | else if (ilbl == 2) {
|
---|
424 | if (mcfioC_Block(istream, MCFIO_STDHEPM, xdr_stdhep_multi_) == -1) {
|
---|
425 | fprintf(stderr,
|
---|
426 | " StdHepXdrWriteEvent: error filling stdhep block for event %d\n",
|
---|
427 | myhepevt.nevhep);
|
---|
428 | return 2;
|
---|
429 | }
|
---|
430 | mcfioC_SetEventInfo(istream, MCFIO_STORENUMBER, &myhepevt.nevhep);
|
---|
431 | }
|
---|
432 | if (mcfioC_NextEvent(istream) == -1) {
|
---|
433 | fprintf(stderr," StdHepXdrWriteCM: error writing event %d\n",
|
---|
434 | myhepevt.nevhep);
|
---|
435 | return 1;
|
---|
436 | }
|
---|
437 | stdcnt_.nstdwrt = stdcnt_.nstdwrt + 1;
|
---|
438 | return 0;
|
---|
439 | }
|
---|
440 | int StdHepXdrWriteEventLH(int ilbl, int ist)
|
---|
441 | {
|
---|
442 | int istream;
|
---|
443 |
|
---|
444 | istream = stdstr_.ixdrstr[ist];
|
---|
445 | if ((ilbl != 4) && (ilbl != 5)) {
|
---|
446 | fprintf(stderr,
|
---|
447 | " StdHepXdrWriteEventLH: called with illegal label %d\n",
|
---|
448 | ilbl);
|
---|
449 | return 3;
|
---|
450 | }
|
---|
451 | else if (myhepevt.nhep <= 0) {
|
---|
452 | fprintf(stderr,
|
---|
453 | " StdHepXdrWriteEventLH: event %d is empty\n", myhepevt.nevhep);
|
---|
454 | return 0;
|
---|
455 | }
|
---|
456 | else if (ilbl == 4) {
|
---|
457 | if (StdHepTempCopy(1,istream) != 0) {
|
---|
458 | fprintf(stderr,
|
---|
459 | " StdHepXdrWriteEventLH: copy failed - event not written\n");
|
---|
460 | return 4;
|
---|
461 | }
|
---|
462 | if (mcfioC_Block(istream, MCFIO_STDHEP4, xdr_stdhep_4_) == -1) {
|
---|
463 | fprintf(stderr,
|
---|
464 | " StdHepXdrWriteEventLH: error filling stdhep block for event %d\n",
|
---|
465 | myhepevt.nevhep);
|
---|
466 | return 2;
|
---|
467 | }
|
---|
468 | mcfioC_SetEventInfo(istream, MCFIO_STORENUMBER, &myhepevt.nevhep);
|
---|
469 | }
|
---|
470 | else if (ilbl == 5) {
|
---|
471 | if (mcfioC_Block(istream, MCFIO_STDHEP4M, xdr_stdhep_4_multi_) == -1) {
|
---|
472 | fprintf(stderr,
|
---|
473 | " StdHepXdrWriteEventLH: error filling stdhep block for event %d\n",
|
---|
474 | myhepevt.nevhep);
|
---|
475 | return 2;
|
---|
476 | }
|
---|
477 | mcfioC_SetEventInfo(istream, MCFIO_STORENUMBER, &myhepevt.nevhep);
|
---|
478 | }
|
---|
479 | if (mcfioC_NextEvent(istream) == -1) {
|
---|
480 | fprintf(stderr," StdHepXdrWriteLH: error writing event %d\n",
|
---|
481 | myhepevt.nevhep);
|
---|
482 | return 1;
|
---|
483 | }
|
---|
484 | stdcnt_.nstdwrt = stdcnt_.nstdwrt + 1;
|
---|
485 | return 0;
|
---|
486 | }
|
---|
487 | int StdHepXdrWriteEventEUP(int ilbl, int ist)
|
---|
488 | {
|
---|
489 | int istream;
|
---|
490 |
|
---|
491 | istream = stdstr_.ixdrstr[ist];
|
---|
492 | if ( ilbl != 11 ) {
|
---|
493 | fprintf(stderr,
|
---|
494 | " StdHepXdrWriteEventEUP: called with illegal label %d\n",
|
---|
495 | ilbl);
|
---|
496 | return 3;
|
---|
497 | }
|
---|
498 | else if (hepeup_.nup <= 0) {
|
---|
499 | fprintf(stderr,
|
---|
500 | " StdHepXdrWriteEventEUP: event is empty\n");
|
---|
501 | return 0;
|
---|
502 | }
|
---|
503 | else if (ilbl == 11) {
|
---|
504 | if (mcfioC_Block(istream, MCFIO_HEPEUP, xdr_hepeup_) == -1) {
|
---|
505 | fprintf(stderr,
|
---|
506 | " StdHepXdrWriteEventEUP: error filling stdhep block for event\n");
|
---|
507 | return 2;
|
---|
508 | }
|
---|
509 | }
|
---|
510 | if (mcfioC_NextEvent(istream) == -1) {
|
---|
511 | fprintf(stderr," StdHepXdrWriteEUP: error writing event\n");
|
---|
512 | return 1;
|
---|
513 | }
|
---|
514 | stdcnt_.nlhwrt = stdcnt_.nlhwrt + 1;
|
---|
515 | return 0;
|
---|
516 | }
|
---|
517 | int StdHepXdrWriteEventRUP(int ilbl, int ist)
|
---|
518 | {
|
---|
519 | int istream;
|
---|
520 |
|
---|
521 | istream = stdstr_.ixdrstr[ist];
|
---|
522 | if ( ilbl != 12 ) {
|
---|
523 | fprintf(stderr,
|
---|
524 | " StdHepXdrWriteEventRUP: called with illegal label %d\n",
|
---|
525 | ilbl);
|
---|
526 | return 3;
|
---|
527 | }
|
---|
528 | else if (ilbl == 12) {
|
---|
529 | if (mcfioC_Block(istream, MCFIO_HEPRUP, xdr_heprup_) == -1) {
|
---|
530 | fprintf(stderr,
|
---|
531 | " StdHepXdrWriteEventRUP: error filling stdhep block for event\n");
|
---|
532 | return 2;
|
---|
533 | }
|
---|
534 | }
|
---|
535 | if (mcfioC_NextEvent(istream) == -1) {
|
---|
536 | fprintf(stderr," StdHepXdrWriteRUP: error writing event\n");
|
---|
537 | return 1;
|
---|
538 | }
|
---|
539 | stdcnt_.nlhwrt = stdcnt_.nlhwrt + 1;
|
---|
540 | return 0;
|
---|
541 | }
|
---|
542 | void StdHepXdrEnd(int ist)
|
---|
543 | {
|
---|
544 | int istream;
|
---|
545 | int inum, ieff;
|
---|
546 |
|
---|
547 | istream = stdstr_.ixdrstr[ist];
|
---|
548 | mcfioC_InfoStreamInt(istream, MCFIO_NUMWORDS, &inum);
|
---|
549 | mcfioC_InfoStreamInt(istream, MCFIO_EFFICIENCY, &ieff);
|
---|
550 | mcfioC_Close(istream);
|
---|
551 | /*
|
---|
552 | fprintf(stdout,
|
---|
553 | " StdHepXdrEnd: %d words i/o with %d efficiency\n",inum,ieff);
|
---|
554 | */
|
---|
555 | }
|
---|
556 | void StdHepPrintHeader( )
|
---|
557 | {
|
---|
558 | fprintf(stdout," StdHep MCFio header information:\n");
|
---|
559 | fprintf(stdout," title: %s\n",stdhd1_.title);
|
---|
560 | fprintf(stdout," date: %s\n",stdhd1_.date);
|
---|
561 | fprintf(stdout," %s\n",stdhd1_.comment);
|
---|
562 | fprintf(stdout," %d blocks per event\n",stdhd2_.numblocks);
|
---|
563 | }
|
---|