63{
65 if (inputFile.is_open())
66 {
67 inputFile >> NHEP;
68 }
69 else
70 {
71 G4Exception(
"G4HEPEvtInterface::G4HEPEvtInterface",
"Event0201",
73 }
74 if( inputFile.eof() )
75 {
76 G4Exception(
"G4HEPEvtInterface::GeneratePrimaryVertex",
"Event0202",
78 "End-Of-File: HEPEvt input file -- no more event to read!");
79 return;
80 }
81
82 if(vLevel > 0)
83 {
84 G4cout <<
"G4HEPEvtInterface - reading " << NHEP
85 <<
" HEPEvt particles from " << fileName <<
"." <<
G4endl;
86 }
87 for(
G4int IHEP=0; IHEP<NHEP; ++IHEP )
88 {
97
98 inputFile >> ISTHEP >> IDHEP >> JDAHEP1 >> JDAHEP2
99 >> PHEP1 >> PHEP2 >> PHEP3 >> PHEP5;
100 if( inputFile.eof() )
101 {
102 G4Exception(
"G4HEPEvtInterface::GeneratePrimaryVertex",
"Event0203",
104 "Unexpected End-Of-File in the middle of an event");
105 }
106 if(vLevel > 1)
107 {
108 G4cout <<
" " << ISTHEP <<
" " << IDHEP <<
" " << JDAHEP1
109 << " " << JDAHEP2 << " " << PHEP1 << " " << PHEP2
110 <<
" " << PHEP3 <<
" " << PHEP5 <<
G4endl;
111 }
112
113
114
116 particle->SetMass( PHEP5*GeV );
117 particle->SetMomentum(PHEP1*GeV, PHEP2*GeV, PHEP3*GeV );
118
119
120
121 auto* hepParticle
123
124
125
126 HPlist.push_back( hepParticle );
127 }
128
129
130
131 if( HPlist.empty() ) return;
132
133
134
135 for(auto & i : HPlist)
136 {
137 if( i->GetJDAHEP1() > 0 )
138 {
139 G4int jda1 = i->GetJDAHEP1()-1;
140 G4int jda2 = i->GetJDAHEP2()-1;
142 for(
G4int j=jda1; j<=jda2; ++j )
143 {
145 if(HPlist[j]->GetISTHEP()>0)
146 {
148 HPlist[j]->Done();
149 }
150 }
151 }
152 }
153
154
155
157
158
159
160 for(auto & ii : HPlist)
161 {
162 if( ii->GetISTHEP() > 0 )
163
164 {
166 vertex->SetPrimary( initialParticle );
167 }
168 }
169
170
171
172 for(auto & iii : HPlist)
173 {
174 delete iii;
175 }
176 HPlist.clear();
177
178
179
181}
void AddPrimaryVertex(G4PrimaryVertex *aPrimaryVertex)
void SetDaughter(G4PrimaryParticle *np)