1 #include <TGeoManager.h> 16 #include <G4EventManager.hh> 17 #include <G4UnitsTable.hh> 18 #include <G4PrimaryVertex.hh> 19 #include <G4PrimaryParticle.hh> 20 #include <G4ParticleDefinition.hh> 22 #include <G4SDManager.hh> 23 #include <G4HCtable.hh> 24 #include <Randomize.hh> 32 <<
" w/ " << evt->GetNumberOfPrimaryVertex()
37 if (!evt->GetUserInformation()) {
38 G4EventManager::GetEventManager()->
48 for (G4PrimaryVertex* vtx = evt->GetPrimaryVertex();
50 vtx = vtx->GetNext()) {
52 gGeoManager->PushPath();
54 G4ThreeVector(vtx->GetX0(), vtx->GetY0(), vtx->GetZ0()));
57 "Vertex: " << vtxNumber
58 <<
" w/ " << vtx->GetNumberOfParticle() <<
" primaries" 59 " in " << gGeoManager->GetPath());
60 gGeoManager->PopPath();
64 <<
" (" << G4BestUnit(vtx->GetX0(),
"Length")
65 <<
", " << G4BestUnit(vtx->GetY0(),
"Length")
66 <<
", " << G4BestUnit(vtx->GetZ0(),
"Length")
67 <<
", " << G4BestUnit(vtx->GetT0(),
"Time") <<
")");
74 for (
int iVert = 0; iVert<infoVertices; ++iVert) {
75 const G4PrimaryVertex* ivtx
77 for (
int p=0;
p<ivtx->GetNumberOfParticle(); ++
p) {
78 G4PrimaryParticle* prim = ivtx->GetPrimary(
p);
79 G4ParticleDefinition* partDef = prim->GetG4code();
80 G4ThreeVector
dir = prim->GetMomentum().unit();
84 "Info: " << partDef->GetParticleName()
86 << G4BestUnit(prim->GetMomentum().mag(),
"Energy")
87 <<
" Dir: (" << dir.x()
89 <<
", " << dir.z() <<
")");
94 "Info: " << prim->GetPDGcode()
96 << G4BestUnit(prim->GetMomentum().mag(),
"Energy")
97 <<
" Dir: (" << dir.x()
99 <<
", " << dir.z() <<
")");
104 for (
int p=0;
p<vtx->GetNumberOfParticle(); ++
p) {
105 G4PrimaryParticle* prim = vtx->GetPrimary(
p);
106 G4ParticleDefinition* partDef = prim->GetG4code();
107 G4ThreeVector
dir = prim->GetMomentum().unit();
111 partDef->GetParticleName()
113 << G4BestUnit(prim->GetMomentum().mag(),
"Energy")
114 <<
" Dir: (" << dir.x()
116 <<
", " << dir.z() <<
")");
123 << G4BestUnit(prim->GetMomentum().mag(),
"Energy")
124 <<
" Dir: (" << dir.x()
126 <<
", " << dir.z() <<
")");
135 EDepSimInfo(
"Event " << evt->GetEventID() <<
" completed.");
139 G4HCofThisEvent* HCofEvent = evt->GetHCofThisEvent();
140 if (!HCofEvent)
return;
141 G4SDManager *sdM = G4SDManager::GetSDMpointer();
142 G4HCtable *hcT = sdM->GetHCtable();
144 for (
int i=0; i<hcT->entries(); ++i) {
145 G4String SDname = hcT->GetSDname(i);
146 G4String HCname = hcT->GetHCname(i);
147 int HCId = sdM->GetCollectionID(SDname+
"/"+HCname);
148 G4VHitsCollection* g4Hits = HCofEvent->GetHC(HCId);
149 if (g4Hits->GetSize()<1) {
150 EDepSimWarn(
"No hits for " << SDname <<
"/" << HCname);
153 for (
unsigned int h=0;
h<g4Hits->GetSize(); ++
h) {
171 for (
int loopCount = 0; ; ++loopCount) {
173 if (!parentId)
break;
185 if (loopCount>9999) {
186 EDepSimError(
"Infinite loop for trajectory id " << trackId);
#define EDepSimNamedInfo(trace, outStream)
double GetTrackLength(void) const
void EndOfEventAction(const G4Event *)
#define EDepSimNamedVerbose(trace, outStream)
const G4String & GetReaction() const
Get the reaction code that created this vertex.
#define EDepSimThrow(message)
Print an error message, and then throw an exception.
#define EDepSimNamedLog(trace, outStream)
#define EDepSimInfo(outStream)
void AddSDLength(double len)
Add the length that has been deposited into a sensitive detector.
void BeginOfEventAction(const G4Event *)
virtual int GetNumberOfInformationalVertex() const
Return the number of informational vertices.
void AddSDEnergyDeposit(double energy)
Add energy deposited into a sensitive detector.
#define EDepSimError(outStream)
#define EDepSimWarn(outStream)
virtual ~UserEventAction()
virtual const G4PrimaryVertex * GetInformationalVertex(int i=0) const
int GetNodeId(const G4ThreeVector &pos)
Get a volume ID base on the volume position.
std::vector< int > & GetContributors()
Provide public access to the contributors for internal G4 classes.
static G4VTrajectory * Get(int trackId)
Provide a map between the track id and the trajectory object.
double GetEnergyDeposit(void) const
Get the total energy deposited in this hit.
G4int GetParentID() const
static EDepSim::RootGeometryManager * Get(void)
If a persistency manager has not been created, create one.
void AddSDDaughterEnergyDeposit(double energy)
Add energy deposited into a sensitive detector by a daughter.