203 {
204
205
206
207 const G4VProcess *
process = aStep->GetPostStepPoint()->GetProcessDefinedStep();
208
209
210 G4StepPoint *preStep=aStep->GetPreStepPoint();
211 G4StepPoint *postStep=aStep->GetPostStepPoint();
212
213 G4ThreeVector
mom = preStep->GetMomentum();
214 const G4ThreeVector&
pos = preStep->GetPosition();
215
216
217 G4Track *
track = aStep->GetTrack();
218
219 int trackID=
track->GetTrackID();
220 const bool trackIsAlive = (
track->GetTrackStatus() == fAlive ||
track->GetTrackStatus() == fStopButAlive);
221
223
224 m_pdg =
track->GetDefinition()->GetPDGEncoding();
225 const G4VProcess* creation =
track->GetCreatorProcess();
226 m_scIn = creation? creation->GetProcessSubType() : -1;
227
228 VTrackInformation * trackInfo=
static_cast<VTrackInformation*
>(
track->GetUserInformation());
230 HepMC::GenVertexPtr vtx = currentGenParticle ? currentGenParticle->production_vertex() :
nullptr;
231 m_gen = currentGenParticle? 0 : -1;
232
233 if (currentGenParticle) {
234 while (currentGenParticle && vtx ) {
235 int pdgID=currentGenParticle->pdg_id();
236#ifdef HEPMC3
237 const HepMC::GenParticlePtr genmom = vtx->particles_in().size()>0 ? vtx->particles_in().front() :
nullptr;
238 if ( genmom && pdgID!=genmom->pdg_id() )
m_gen++;
239 else if (vtx->particles_out().size()>0 && currentGenParticle!=vtx->particles_out().front())
m_gen++;
240
241#else
242 HepMC::GenParticlePtr genmom = vtx->particles_in_size()>0 ? *(vtx->particles_in_const_begin()) :
nullptr;
243 if ( genmom && pdgID!=genmom->pdg_id() )
m_gen++;
244 else if (vtx->particles_out_size()>0 && currentGenParticle!=*(vtx->particles_out_const_begin()))
m_gen++;
245#endif
246 vtx = genmom ? genmom->production_vertex() : nullptr;
247 currentGenParticle = genmom;
248 }
249 } else {
250
251 int parentID=
track->GetParentID();
252 std::map<int, int>::iterator genIt =
m_trackGenMap.find(parentID);
254 }
255
257
259
261 }
262
269
270
271
272 double stepLength = aStep->GetStepLength();
273 double radLengthInX0 = preStep->GetMaterial()->GetRadlen();
274 double l0 = preStep->GetMaterial()->GetNuclearInterLength();
275 float stepInX0 = stepLength/radLengthInX0;
276
277 if (stepInX0>1.e-06) {
278
281
282 if (l0>0.) {
284
285
286 double totNA = preStep->GetMaterial()->GetTotNbOfAtomsPerVolume();
287 const G4ElementVector* eVec = preStep->GetMaterial()->GetElementVector();
288 const G4double* atVector = preStep->GetMaterial() ->GetVecNbOfAtomsPerVolume();
289 float mFactor =stepInX0* preStep->GetMaterial()->GetDensity();
290
291 float zOverA = 0.; float frSum = 0.;
292 for (
unsigned int i=0;
i<eVec->size();
i++) {
293 float fEl = atVector ? atVector[
i]/totNA : 0.;
294 m_wZ += stepInX0*fEl*((*eVec)[
i]->GetZ());
295
296
297 zOverA += fEl*((*eVec)[
i]->GetZ())/((*eVec)[
i]->GetA());
298 frSum += fEl;
299 }
300 if (fabs(frSum-1.)>0.01)
ATH_MSG_DEBUG(
"G4 material description inconsistent, sum of element fractions:"<< frSum);
302 }
303
304 }
305
306
307
309
310 float eloss = postStep->GetMomentum().mag()-preStep->GetMomentum().mag();
311
314
315 AtlasG4EventUserInfo* atlasG4EvtUserInfo = static_cast<AtlasG4EventUserInfo*> (G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetUserInformation());
316 VTrackInformation * trackInfo =
static_cast<VTrackInformation*
>(
track->GetUserInformation());
317 ::iGeant4::Geant4TruthIncident truth( aStep, *trackInfo->
GetBaseISFParticle(), geoID, atlasG4EvtUserInfo);
318 unsigned int nSec = truth.numberOfChildren();
319 if (nSec>0 || !trackIsAlive ) {
320
324 G4ThreeVector
mom = preStep->GetMomentum();
326
329 m_vtx_phi = postStep->GetPosition().phi();
330
331 int iPrimSurv = !trackIsAlive ? 0 : 1;
333
334 G4ThreeVector pbal(mom);
335
336 if (iPrimSurv>0) {
340 pbal -= postStep->GetMomentum();
341 }
342
344 for (unsigned int isec=0; isec< nSec; isec++) {
345 G4ThreeVector secMom = truth.childP(isec);
346 if (isec<nSecMax) {
347 m_pdg_child[isec+iPrimSurv] = truth.childPdgCode(isec);
350 }
351 pbal -= secMom;
352 }
353
357
359
360
362 }
363 }
364
365
366 G4VPhysicalVolume *preVol=preStep->GetPhysicalVolume();
367 G4VPhysicalVolume *postVol=postStep->GetPhysicalVolume();
368
369 if (postVol==0) {
370
374
375 m_pth =
track->GetVertexMomentumDirection().theta();
376 m_pph =
track->GetVertexMomentumDirection().phi();
377 m_p =
track->GetVertexKineticEnergy();
379
383
384 m_thEnd=postStep->GetPosition().theta();
385 m_phEnd=postStep->GetPosition().phi();
386 m_dEnd=postStep->GetPosition().mag();
387
393
396
397 return;
398 }
399
400
401 if ( !trackIsAlive ) {
405
406 m_pth =
track->GetVertexMomentumDirection().theta();
407 m_pph =
track->GetVertexMomentumDirection().phi();
408 m_p =
track->GetVertexKineticEnergy();
410
414
415 m_thEnd=postStep->GetPosition().theta();
416 m_phEnd=postStep->GetPosition().phi();
417 m_dEnd=postStep->GetPosition().mag();
418
427 }
428
429 if ( preVol==postVol ) return;
430
431
432 const G4ThreeVector &postPos = postStep->GetPosition();
433 const G4ThreeVector &postMom = postStep->GetMomentum();
435 postPos.y(),
436 postPos.z(),
437 postMom.x(),
438 postMom.y(),
439 postMom.z() );
440
441
442 if ( nextGeoID == geoID) {
444 } else {
445 ATH_MSG_DEBUG(
"track moves from "<<geoID<<
" to "<<nextGeoID);
446
447
448
449 if (aStep->GetStepLength() == 0.) {
450 return;
451 }
452
453
455
456
457
458 const G4ThreeVector& g4pos =
track->GetPosition();
459
460 const HepGeom::Point3D<double> position(g4pos.x(),g4pos.y(),g4pos.z());
461
462 G4ThreeVector g4mom =
track->GetMomentum();
463 const HepGeom::Vector3D<double>
momentum(g4mom.x(),g4mom.y(),g4mom.z());
464
465 bool dead=false;
466 if (
track->GetTrackStatus()==fStopAndKill) {
467 dead=true;
468 }
469
470 if (!dead) {
471
472
473
476
477 m_pth =
track->GetVertexMomentumDirection().theta();
478 m_pph =
track->GetVertexMomentumDirection().phi();
479 m_p =
track->GetVertexKineticEnergy();
481
485
486 m_thEnd=postStep->GetPosition().theta();
487 m_phEnd=postStep->GetPosition().phi();
488 m_dEnd=postStep->GetPosition().mag();
489
497 }
499
500 }
501
502 }
const std::string process
AtlasRegion
A simple enum of ATLAS regions and sub-detectors.
HepMC::GenVertex * GenVertexPtr
GenParticle * GenParticlePtr