00153 {
00154 if ( m_logLevel <= int(MSG::DEBUG) ) {
00155 std::cout << "AthenaHepMCtoG4EventAction: - Generating Primaries"
00156 << std::endl;
00157 }
00158
00159
00160 p_evt = (const HepMC::GenEvent *)(*p_evtCollItr);
00161
00162
00163 if (p_evt == 0) {
00164
00165 if ( m_logLevel <= int(MSG::WARNING) ) {
00166 std::cout << "AthenaHepMCtoG4EventAction: - HepMC ptr == null"
00167 << std::endl;
00168 }
00169
00170 return;
00171
00172 }
00173
00174 G4PrimaryVertex* vertex = new G4PrimaryVertex(0.,0.,0.,0.);
00175
00176 int n=0;
00177 for ( HepMC::GenEvent::vertex_const_iterator v = p_evt->vertices_begin();
00178 v != p_evt->vertices_end(); ++v ) {
00179 bool IsGood=false;
00180 for (HepMC::GenVertex::particle_iterator it=
00181 (*v)->particles_begin(HepMC::children);
00182 it!=(*v)->particles_end(HepMC::children);
00183 it++) {
00184
00185 if (!(*it)->end_vertex() && (*it)->status()==1 ) {
00186 IsGood=true;
00187 break;
00188 }
00189 }
00190
00191 if (IsGood) {
00192
00193
00194
00195 for (HepMC::GenVertex::particle_iterator it=
00196 (*v)->particles_begin(HepMC::children);
00197 it!=(*v)->particles_end(HepMC::children);
00198 it++) {
00199
00200 if ( (*it)->status() != 1) continue;
00201
00202 int pdgcode=(*it)->pdg_id();
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214 const G4ThreeVector& p=(*it)->momentum();
00215 G4PrimaryParticle *part;
00216 if (pdgcode!=999) {
00217 part=new G4PrimaryParticle (pdgcode,p.x()*GeV,p.y()*GeV,p.z()*GeV);
00218 } else {
00219 G4ParticleDefinition *pdef = G4Geantino::GeantinoDefinition();
00220 part=new G4PrimaryParticle (pdef,p.x()*GeV,p.y()*GeV,p.z()*GeV);
00221 }
00222
00223 vertex->SetPosition((*v)->position().x(),
00224 (*v)->position().y(),
00225 (*v)->position().z());
00226 vertex->SetT0((*v)->position().t());
00227
00228 vertex->SetPrimary(part);
00229
00230 n++;
00231 }
00232 }
00233 }
00234 anEvent->AddPrimaryVertex(vertex);
00235
00236 if ( m_logLevel <= int(MSG::DEBUG) ) {
00237 std::cout << "AthenaHepMCtoG4EventAction: - done. G4Event has "
00238 << n << " particles. "
00239 << std::endl;
00240 }
00241
00242 p_evtCollItr++;
00243
00244 }