ATLAS Offline Software
Loading...
Searching...
No Matches
iGeant4::ISFG4Helper Class Reference

#include <ISFG4Helper.h>

Collaboration diagram for iGeant4::ISFG4Helper:

Public Member Functions

 ISFG4Helper ()=delete

Static Public Member Functions

static ISF::ISFParticleconvertG4TrackToISFParticle (const G4Track &aTrack, const ISF::ISFParticle &parent, ISF::TruthBinding *truth=nullptr)
 convert the given G4Track into an ISFParticle
static VTrackInformationgetISFTrackInfo (const G4Track &aTrack)
 return a valid UserInformation object of the G4Track for use within the ISF
static void setG4TrackInfoFromBaseISFParticle (G4Track &aTrack, const ISF::ISFParticle &baseIsp, bool setReturnToISF=false)
 link the given G4Track to the given ISFParticle
static TrackInformationattachTrackInfoToNewG4Track (G4Track &aTrack, ISF::ISFParticle &baseIsp, VTrackInformation::TrackClassification classification, HepMC::GenParticlePtr generationZeroGenParticle=nullptr)
 attach a new TrackInformation object to the given new (!) G4Track (the G4Track must not have a UserInformation object attached to it)
static AtlasG4EventUserInfogetAtlasG4EventUserInfo ()
 return pointer to current AtlasG4EventUserInfo

Detailed Description

Definition at line 25 of file ISFG4Helper.h.

Constructor & Destructor Documentation

◆ ISFG4Helper()

iGeant4::ISFG4Helper::ISFG4Helper ( )
delete

Member Function Documentation

◆ attachTrackInfoToNewG4Track()

TrackInformation * iGeant4::ISFG4Helper::attachTrackInfoToNewG4Track ( G4Track & aTrack,
ISF::ISFParticle & baseIsp,
VTrackInformation::TrackClassification classification,
HepMC::GenParticlePtr generationZeroGenParticle = nullptr )
static

attach a new TrackInformation object to the given new (!) G4Track (the G4Track must not have a UserInformation object attached to it)

link the given G4Track to the given ISFParticle

Definition at line 78 of file ISFG4Helper.cxx.

82{
83 if ( aTrack.GetUserInformation() ) {
84 G4ExceptionDescription description;
85 description << G4String("ISFG4Helper::attachTrackInfoToNewG4Track: ")
86 << "Trying to attach new TrackInformation object to G4Track which already has a TrackUserInformation attached (trackID: "
87 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
88 << ", parentID " << aTrack.GetParentID() << ")";
89 G4Exception("ISFG4Helper::attachTrackInfoToNewG4Track", "TrackUserInformationAlreadyExists", FatalException, description);
90 return nullptr;
91 }
92
93 auto* truthBinding = baseIsp.getTruthBinding();
94 if ( !truthBinding ) {
95 G4ExceptionDescription description;
96 description << G4String("ISFG4Helper::attachTrackInfoToNewG4Track: ")
97 << "No TruthBinding present in base ISFParticle (trackID: "
98 << aTrack.GetTrackID() << ", track pos: "<<aTrack.GetPosition() << ", mom: "<<aTrack.GetMomentum()
99 << ", parentID " << aTrack.GetParentID() << ", ISFParticle: "<<baseIsp<<")";
100 G4Exception("ISFG4Helper::attachTrackInfoToNewG4Track", "NoISFTruthBinding", FatalException, description);
101 return nullptr;
102 }
103
104 TrackInformation *trackInfo = new TrackInformation( generationZeroGenParticle, &baseIsp );
105 trackInfo->SetPrimaryGenParticle( truthBinding->getPrimaryGenParticle() );
106 trackInfo->SetClassification( classification );
107 aTrack.SetUserInformation( trackInfo );
108
109 return trackInfo;
110}
const TruthBinding * getTruthBinding() const
pointer to the simulation truth - optional, can be 0
void SetPrimaryGenParticle(HepMC::GenParticlePtr)
set the pointer to the GenParticle used to create the initial G4PrimaryParticle from which the curren...
void SetClassification(TrackClassification tc)
update the classification of the currently tracked particle, usually called when a new G4Track is cre...
std::string description
glabal timer - how long have I taken so far?
Definition hcg.cxx:91

◆ convertG4TrackToISFParticle()

ISF::ISFParticle * iGeant4::ISFG4Helper::convertG4TrackToISFParticle ( const G4Track & aTrack,
const ISF::ISFParticle & parent,
ISF::TruthBinding * truth = nullptr )
static

convert the given G4Track into an ISFParticle

Definition at line 31 of file ISFG4Helper.cxx.

34{
35 const G4ThreeVector& g4pos = aTrack.GetPosition();
36 const double gTime = aTrack.GetGlobalTime();
37 const Amg::Vector3D position(g4pos.x(),g4pos.y(),g4pos.z());
38
39 const G4ThreeVector& g4mom = aTrack.GetMomentum();
40 const Amg::Vector3D momentum(g4mom.x(),g4mom.y(),g4mom.z());
41
42 const G4ParticleDefinition &particleDefinition = *aTrack.GetDefinition();
43 double mass = particleDefinition.GetPDGMass();
44 double charge = particleDefinition.GetPDGCharge();
45 int pdgID = particleDefinition.GetPDGEncoding();
46
47 int barcode = (truth && truth->getCurrentGenParticle() ) ? HepMC::barcode(truth->getCurrentGenParticle()) : HepMC::UNDEFINED_ID; // FIXME barcode-based
48 const int id = (truth && truth->getCurrentGenParticle() ) ? HepMC::uniqueID(truth->getCurrentGenParticle()) : HepMC::UNDEFINED_ID;
49 const int status = (truth && truth->getCurrentGenParticle() ) ? truth->getCurrentGenParticle()->status() : 1;
50 ISF::ISFParticle *isp = new ISF::ISFParticle( position,
51 momentum,
52 mass,
53 charge,
54 pdgID,
55 status,
56 gTime,
57 parent,
58 id,
59 barcode, // FIXME barcode-based
60 truth
61 );
62
63 return isp;
64}
double charge(const T &p)
Definition AtlasPID.h:997
HepMC::GenParticlePtr getCurrentGenParticle()
pointer to the particle in the simulation truth
Eigen::Matrix< double, 3, 1 > Vector3D
int barcode(const T *p)
Definition Barcode.h:16
int uniqueID(const T &p)
constexpr int UNDEFINED_ID
status
Definition merge.py:16

◆ getAtlasG4EventUserInfo()

AtlasG4EventUserInfo * iGeant4::ISFG4Helper::getAtlasG4EventUserInfo ( )
static

return pointer to current AtlasG4EventUserInfo

Definition at line 114 of file ISFG4Helper.cxx.

115{
116 return ( static_cast<AtlasG4EventUserInfo*> (G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetUserInformation()) );
117}

◆ getISFTrackInfo()

VTrackInformation * iGeant4::ISFG4Helper::getISFTrackInfo ( const G4Track & aTrack)
static

return a valid UserInformation object of the G4Track for use within the ISF

Definition at line 69 of file ISFG4Helper.cxx.

70{
71 VTrackInformation* trackInfo = static_cast<VTrackInformation*>(aTrack.GetUserInformation());
72 return trackInfo;
73}

◆ setG4TrackInfoFromBaseISFParticle()

void iGeant4::ISFG4Helper::setG4TrackInfoFromBaseISFParticle ( G4Track & aTrack,
const ISF::ISFParticle & baseIsp,
bool setReturnToISF = false )
static

link the given G4Track to the given ISFParticle


The documentation for this class was generated from the following files: