Fork me on GitHub

source: svn/trunk/Utilities/stdhep/stdhep_internal_utils.c@ 857

Last change on this file since 857 was 3, checked in by Xavier Rouby, 16 years ago

first commit

File size: 7.4 KB
Line 
1/*******************************************************************************
2* *
3* stdhep_internal_utils.c -- C version of stdhep internal utility 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#ifndef FALSE
28#define FALSE 0
29#endif
30#ifndef TRUE
31#define TRUE 1
32#endif
33/*
34* StdHep definitions and include files
35*/
36#include "Utilities/stdhep/stdhep.h"
37#include "Utilities/stdhep/hepev4.h"
38#include "Utilities/stdhep/stdtmp.h"
39#include "Utilities/stdhep/hepeup.h"
40
41extern struct stdtmp stdtmp_;
42extern struct tmpev4 tmpev4_;
43
44extern struct hepevt myhepevt;
45extern struct hepev2 hepev2_;
46extern struct hepev3 hepev3_;
47extern struct hepev4 hepev4_;
48extern struct hepev5 hepev5_;
49extern struct hepeup hepeup_;
50
51/* Purpose: copy an event to/from the standard common block */
52int StdHepTempCopy(int idir, int istr)
53{
54 int nh, i, k;
55 if (idir == 1) { /* copy from hepevt to stdtmp */
56 stdtmp_.nevhept = myhepevt.nevhep;
57 stdtmp_.nhept = myhepevt.nhep;
58 tmpev4_.eventweightt = hepev4_.eventweightlh;
59 tmpev4_.alphaqedt = hepev4_.alphaqedlh;
60 tmpev4_.alphaqcdt = hepev4_.alphaqcdlh;
61 for (i = 0; i < 10; i++) {
62 tmpev4_.scalet[i] = hepev4_.scalelh[i];
63 }
64 tmpev4_.idrupt = hepev4_.idruplh;
65 for (i = 0; i < myhepevt.nhep; i++) {
66 stdtmp_.isthept[i] = myhepevt.isthep[i];
67 stdtmp_.idhept[i] = myhepevt.idhep[i];
68 for (k = 0; k < 2; k++) {
69 stdtmp_.jmohept[i][k] = myhepevt.jmohep[i][k];
70 stdtmp_.jdahept[i][k] = myhepevt.jdahep[i][k];
71 tmpev4_.icolorflowt[i][k] = hepev4_.icolorflowlh[i][k];
72 }
73 for (k = 0; k < 5; k++)
74 stdtmp_.phept[i][k] = myhepevt.phep[i][k];
75 for (k = 0; k < 4; k++)
76 stdtmp_.vhept[i][k] = myhepevt.vhep[i][k];
77 for (k = 0; k < 3; k++)
78 tmpev4_.spint[i][k] = hepev4_.spinlh[i][k];
79 }
80 } else if (idir == 2) { /* copy from stdtmp to hepevt */
81 if (myhepevt.nhep + stdtmp_.nhept > NMXHEP) {
82 fprintf(stderr,
83 " StdHepTempCopy: event would overflow HEPEVT array size\n");
84 fprintf(stderr," StdHepTempCopy: event %d has been lost\n",
85 stdtmp_.nevhept);
86 return 5;
87 }
88 myhepevt.nevhep = stdtmp_.nevhept;
89 nh = myhepevt.nhep;
90 hepev4_.eventweightlh = tmpev4_.eventweightt;
91 hepev4_.alphaqedlh = tmpev4_.alphaqedt;
92 hepev4_.alphaqcdlh = tmpev4_.alphaqcdt;
93 for (i = 0; i < 10; i++) {
94 hepev4_.scalelh[i] = tmpev4_.scalet[i];
95 }
96 hepev4_.idruplh = tmpev4_.idrupt;
97 for (i = 0; i < stdtmp_.nhept; i++) {
98 myhepevt.isthep[nh+i] = stdtmp_.isthept[i];
99 myhepevt.idhep[nh+i] = stdtmp_.idhept[i];
100 for (k = 0; k < 2; k++) {
101 myhepevt.jmohep[nh+i][k] = stdtmp_.jmohept[i][k];
102 myhepevt.jdahep[nh+i][k] = stdtmp_.jdahept[i][k];
103 hepev4_.icolorflowlh[nh+i][k] = tmpev4_.icolorflowt[i][k];
104 }
105 for (k = 0; k < 5; k++)
106 myhepevt.phep[nh+i][k] = stdtmp_.phept[i][k];
107 for (k = 0; k < 4; k++)
108 myhepevt.vhep[nh+i][k] = stdtmp_.vhept[i][k];
109 for (k = 0; k < 3; k++)
110 hepev4_.spinlh[nh+i][k] = tmpev4_.spint[i][k];
111 }
112 hepev2_.nmulti += 1;
113 if (hepev2_.nmulti <= NMXMLT ) {
114 hepev3_.nevmulti[hepev2_.nmulti] = stdtmp_.nevhept;
115 hepev3_.itrkmulti[hepev2_.nmulti] = stdtmp_.nhept + 1;
116 hepev3_.mltstr[hepev2_.nmulti] = istr;
117 hepev5_.eventweightmulti[i] = tmpev4_.eventweightt;
118 hepev5_.alphaqedmulti[i] = tmpev4_.alphaqedt;
119 hepev5_.alphaqcdmulti[i] = tmpev4_.alphaqcdt;
120 for( k = 0; k < 10; ++k) {
121 hepev5_.scalemulti[i][k] = tmpev4_.scalet[k];
122 }
123 hepev5_.idrupmulti[i] = tmpev4_.idrupt;
124 } else {
125 fprintf(stderr," StdHepTempCopy: %d multiple interactions in this event\n",
126 hepev2_.nmulti );
127 fprintf(stderr," StdHepTempCopy: only %d multiple interactions are allowed\n",
128 NMXMLT );
129 }
130 for (i = 0; i < stdtmp_.nhept; i++) {
131 hepev2_.jmulti[nh+i] = hepev2_.nmulti;
132 for (k = 0; k < 2; k++) {
133 if (myhepevt.jmohep[nh+i][k] != 0) {
134 myhepevt.jmohep[nh+i][k] += myhepevt.nhep;
135 }
136 if (myhepevt.jdahep[nh+i][k] != 0) {
137 myhepevt.jdahep[nh+i][k] += myhepevt.nhep;
138 }
139 if (hepev4_.icolorflowlh[nh+i][k] != 0) {
140 hepev4_.icolorflowlh[nh+i][k] += myhepevt.nhep;
141 }
142 }
143 }
144 myhepevt.nhep += stdtmp_.nhept;
145 } else {
146 fprintf(stderr," StdHepTempCopy: improper calling flag\n");
147 }
148 return 0;
149}
150
151void StdHepZero(void)
152{
153 int i, k;
154 myhepevt.nhep = 0;
155 hepev2_.nmulti = 0;
156 for (i = 0; i < NMXHEP; i++) {
157 myhepevt.isthep[i] = 0;
158 myhepevt.idhep[i] = 0;
159 hepev2_.jmulti[i] = 0;
160 for (k = 0; k < 2; k++) {
161 myhepevt.jmohep[i][k] = 0;
162 myhepevt.jdahep[i][k] = 0;
163 hepev4_.icolorflowlh[i][k] = 0;
164 }
165 for (k = 0; k < 5; k++)
166 myhepevt.phep[i][k] = 0.;
167 for (k = 0; k < 4; k++)
168 myhepevt.vhep[i][k] = 0.;
169 for (k = 0; k < 3; k++)
170 hepev4_.spinlh[i][k] = 0.;
171 }
172 for (i = 0; i < NMXMLT; i++) {
173 hepev3_.nevmulti[i] = 0;
174 hepev3_.itrkmulti[i] = 0;
175 hepev3_.mltstr[i] = 0;
176 hepev5_.eventweightmulti[i] = 0.;
177 hepev5_.alphaqedmulti[i] = 0.;
178 hepev5_.alphaqcdmulti[i] = 0.;
179 for( k = 0; k < 10; ++k) {
180 hepev5_.scalemulti[i][k] = 0.;
181 }
182 hepev5_.idrupmulti[i] = 0;
183 }
184 hepev4_.eventweightlh = 0.;
185 hepev4_.alphaqedlh = 0.;
186 hepev4_.alphaqcdlh = 0.;
187 for (i = 0; i < 10; i++) {
188 hepev4_.scalelh[i] = 0.;
189 }
190 hepev4_.idruplh = 0;
191}
192
193void StdHepZeroHEPEUP(void)
194{
195 int i, k;
196 hepeup_.nup = 0;
197 hepeup_.idprup = 0;
198 hepeup_.xwgtup = 0;
199 hepeup_.scalup = 0;
200 hepeup_.aqedup = 0;
201 hepeup_.aqcdup = 0;
202 for (i = 0; i < MAXNUP; ++i) {
203 hepeup_.idup[i] = 0;
204 hepeup_.istup[i] = 0;
205 for (k = 0; k < 2; ++k) {
206 hepeup_.mothup[i][k] = 0;
207 hepeup_.icolup[i][k] = 0;
208 }
209 for (k = 0; k < 5; ++k) {
210 hepeup_.pup[i][k] = 0;
211 }
212 hepeup_.vtimup[i] = 0;
213 hepeup_.spinup[i] = 0;
214 }
215}
Note: See TracBrowser for help on using the repository browser.