~maddevelopers/mg5amcnlo/2.9.4

« back to all changes in this revision

Viewing changes to vendor/StdHEP/src/stdhep/mcf_StdHep_cxx.c

pass to v2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
*                                                                              *
 
3
* mcf_StdHep_cxx.c -- XDR Utility routines for the Block Stdhep filters        *
 
4
*                                                                              *
 
5
* Copyright (c) 1994 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 <sys/param.h>
 
27
#include <rpc/types.h>
 
28
#include <sys/types.h>
 
29
#include <rpc/xdr.h>
 
30
#include <limits.h>
 
31
#ifdef SUNOS
 
32
#include <floatingpoint.h>
 
33
#else /* SUNOS */
 
34
#include <float.h>
 
35
#endif /* SUNOS */
 
36
#include <stdlib.h>
 
37
#include <time.h>
 
38
#include "mcfio_Dict.h"
 
39
#include "mcf_xdr.h"
 
40
#include "stdevent.h"
 
41
#include "stdver.h"
 
42
#ifndef FALSE
 
43
#define FALSE 0
 
44
#endif
 
45
#ifndef TRUE
 
46
#define TRUE 1
 
47
#endif
 
48
 
 
49
struct stdver stdver_;
 
50
 
 
51
bool_t xdr_stdhep_cxx_(XDR *xdrs, int *blockid,
 
52
                                 int *ntot, char** version)
 
53
 
 
54
{
 
55
/*  Translate a copy of the StdHep::Event class to/from
 
56
    an XDR stream. Note that we do not allocate memory, because we fill
 
57
    directly the COMMON.  Also, mcfio will allocate the space for the 
 
58
    string version.  */
 
59
    
 
60
    unsigned int nn, nnint, nndbl, nnw, nnw4, nnw5, nmlt, nnmlt;
 
61
    int i;
 
62
    int *idat;
 
63
    double *dat;
 
64
    
 
65
    if ((xdrs->x_op == XDR_ENCODE) || (xdrs->x_op == XDR_MCFIOCODE))  {
 
66
        if (*blockid != MCFIO_STDHEPCXX) {
 
67
           fprintf (stderr, "mcf_StdHep_cxx: Inconsistent Blockid %d \n ", 
 
68
            (*blockid));
 
69
           return FALSE;
 
70
        }
 
71
        nnint = 8 * sizeof(int) * stdevent_.nhep;
 
72
        nndbl = 16 * sizeof(double) * stdevent_.nhep;
 
73
        nmlt = 3 * sizeof(int) * stdevent_.ncol;
 
74
        nnw = (unsigned int) stdevent_.nhep;
 
75
        nnw4 = 4 * nnw;
 
76
        nnmlt = (unsigned int) stdevent_.ncol;
 
77
        *ntot = 6 * sizeof(int) + nnint + nndbl + nmlt;
 
78
        if (xdrs->x_op == XDR_MCFIOCODE) return TRUE;
 
79
        strncpy(version[0],stdver_.stdhep_ver, 4);
 
80
     } 
 
81
      
 
82
     if     ( (xdr_int(xdrs, blockid) &&
 
83
              xdr_int(xdrs, ntot) &&
 
84
              xdr_string(xdrs, version, MCF_XDR_VERSION_LENGTH) &&
 
85
              xdr_int(xdrs, &(stdevent_.nevhep)) &&
 
86
              xdr_int(xdrs, &(stdevent_.nhep)) &&
 
87
              xdr_int(xdrs, &(stdevent_.ncol))) == FALSE) return FALSE;
 
88
              
 
89
     if ((xdrs->x_op == XDR_DECODE) && ( *blockid != MCFIO_STDHEPCXX) ) {
 
90
          fprintf (stderr, "mcf_StdHep_cxx: Inconsistent Blockid %d \n ", 
 
91
           (*blockid));
 
92
          return FALSE;
 
93
     }
 
94
     idat = stdevent_.nevcol;
 
95
     if     ( xdr_array(xdrs, (char **)   &idat,
 
96
            &nnmlt, NMXMLT, sizeof(int), xdr_int) == FALSE) return FALSE;
 
97
     idat = stdevent_.iostr;
 
98
     if     ( xdr_array(xdrs, (char **)   &idat,
 
99
            &nnmlt, NMXMLT, sizeof(int), xdr_int) == FALSE) return FALSE;
 
100
     idat = stdevent_.nhepcol;
 
101
     if     ( xdr_array(xdrs, (char **)   &idat,
 
102
            &nnmlt, NMXMLT, sizeof(int), xdr_int) == FALSE) return FALSE;
 
103
     idat = stdevent_.isthep;
 
104
     if     ( xdr_array(xdrs, (char **)  &idat,
 
105
            &nnw, NMXHEP, sizeof(int), xdr_int) == FALSE) return FALSE;
 
106
     idat = stdevent_.idhep;
 
107
     if     ( xdr_array(xdrs, (char **)   &idat,
 
108
            &nnw, NMXHEP, sizeof(int), xdr_int) == FALSE) return FALSE;
 
109
     idat = stdevent_.jmohep1;
 
110
     if     ( xdr_array(xdrs, (char **)   &idat,
 
111
                &nnw, NMXHEP, sizeof(int), xdr_int) == FALSE) return FALSE;
 
112
     idat = stdevent_.jmohep2;
 
113
     if     ( xdr_array(xdrs, (char **)   &idat,
 
114
                &nnw, NMXHEP, sizeof(int), xdr_int) == FALSE) return FALSE;
 
115
     idat = stdevent_.jdahep1;
 
116
     if     ( xdr_array(xdrs, (char **)   &idat,
 
117
                &nnw, NMXHEP, sizeof(int), xdr_int) == FALSE) return FALSE;
 
118
     idat = stdevent_.jdahep2;
 
119
     if     ( xdr_array(xdrs, (char **)   &idat,
 
120
                &nnw, NMXHEP, sizeof(int), xdr_int) == FALSE) return FALSE;
 
121
     idat = stdevent_.color;
 
122
     if     ( xdr_array(xdrs, (char **)   &idat,
 
123
                &nnw, NMXHEP, sizeof(int), xdr_int) == FALSE) return FALSE;
 
124
     idat = stdevent_.jcol;
 
125
     if     ( xdr_array(xdrs, (char **)   &idat,
 
126
                &nnw, NMXHEP, sizeof(int), xdr_int) == FALSE) return FALSE;
 
127
     dat = (double *)  stdevent_.phep;
 
128
     if     ( xdr_array(xdrs,  (char **)   &dat,
 
129
                &nnw4, 4*NMXHEP, sizeof(double), xdr_double) == FALSE) return FALSE; 
 
130
     dat = stdevent_.mass;
 
131
     if     ( xdr_array(xdrs,  (char **)   &dat,
 
132
                &nnw, NMXHEP, sizeof(double), xdr_double) == FALSE) return FALSE; 
 
133
     dat = stdevent_.helicity;
 
134
     if     ( xdr_array(xdrs,  (char **)   &dat,
 
135
                &nnw, NMXHEP, sizeof(double), xdr_double) == FALSE) return FALSE; 
 
136
     dat = (double *) stdevent_.vcr;
 
137
     if     ( xdr_array(xdrs, (char **)    &dat,
 
138
                &nnw4, 4*NMXHEP, sizeof(double), xdr_double) == FALSE) return FALSE;
 
139
     dat = (double *) stdevent_.vdcy;
 
140
     if     ( xdr_array(xdrs, (char **)    &dat,
 
141
                &nnw4, 4*NMXHEP, sizeof(double), xdr_double) == FALSE) return FALSE;
 
142
     if ( xdr_int(xdrs, &(stdevent_.ncol)) == FALSE) return FALSE;
 
143
 
 
144
     return TRUE;
 
145
}