GEARS
Geant4 Example Application with Rich features and Small footprints
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Output Class Reference

Dump simulation results to screen or a file. More...

Inheritance diagram for Output:
Inheritance graph
[legend]
Collaboration diagram for Output:
Collaboration graph
[legend]

Public Member Functions

 Output ()
 use analysis manager to handle output More...
 
void TrackingStarted ()
 Information of step 0 (initStep) More...
 
void StepInfo ()
 Information of steps>0. More...
 
void Reset ()
 
void SetSteppingVerbose (int level)
 
int GetSteppingVerbose ()
 

Public Attributes

vector< int > trk
 track ID More...
 
vector< int > stp
 step number More...
 
vector< int > vlm
 volume copy number More...
 
vector< int > pro
 process ID * 100 + sub-process ID More...
 
vector< int > pdg
 PDG encoding. More...
 
vector< int > pid
 parent particle's PDG encoding More...
 
vector< double > xx
 x [mm] (origin: center of local volume) More...
 
vector< double > yy
 y [mm] (origin: center of local volume) More...
 
vector< double > zz
 z [mm] (origin: center of local volume) More...
 
vector< double > dt
 time elapsed from previous step point [ns] More...
 
vector< double > de
 energy deposited [keV] More...
 
vector< double > dl
 step length [mm] More...
 
vector< double > l
 length of track till this point [mm] More...
 
vector< double > x
 x [mm] (origin: center of the world) More...
 
vector< double > y
 y [mm] (origin: center of the world) More...
 
vector< double > z
 z [mm] (origin: center of the world) More...
 
vector< double > t
 time elapsed from the beginning of an event [ns] More...
 
vector< double > k
 kinetic energy [keV] More...
 
vector< double > p
 momentum [keV] More...
 
vector< double > px
 x component of momentum direction More...
 
vector< double > py
 y component of momentum direction More...
 
vector< double > pz
 z component of momentum direction More...
 
vector< double > q
 charge [elementary charge] More...
 
vector< double > et
 Total energy deposited in a volume [keV]. More...
 

Protected Member Functions

void Record ()
 Record simulated data. More...
 

Detailed Description

Dump simulation results to screen or a file.

Definition at line 12 of file gears.cc.

Constructor & Destructor Documentation

◆ Output()

Output::Output ( )

use analysis manager to handle output

Definition at line 82 of file gears.cc.

82  : G4SteppingVerbose() {
83  auto manager = G4AnalysisManager::Instance();
84  manager->CreateNtuple("t", "Geant4 step points");
85  manager->CreateNtupleIColumn("n"); // total number of recorded hits
86  manager->CreateNtupleIColumn("m"); // max copy number of sensitive volume
87  manager->CreateNtupleIColumn("trk", trk);
88  manager->CreateNtupleIColumn("stp", stp);
89  manager->CreateNtupleIColumn("vlm", vlm);
90  manager->CreateNtupleIColumn("pro", pro);
91  manager->CreateNtupleIColumn("pdg", pdg);
92  manager->CreateNtupleIColumn("pid", pid);
93  manager->CreateNtupleDColumn("xx", xx);
94  manager->CreateNtupleDColumn("yy", yy);
95  manager->CreateNtupleDColumn("zz", zz);
96  manager->CreateNtupleDColumn("dt", dt);
97  manager->CreateNtupleDColumn("de", de);
98  manager->CreateNtupleDColumn("dl", dl);
99  manager->CreateNtupleDColumn("l", l);
100  manager->CreateNtupleDColumn("x", x);
101  manager->CreateNtupleDColumn("y", y);
102  manager->CreateNtupleDColumn("z", z);
103  manager->CreateNtupleDColumn("t", t);
104  manager->CreateNtupleDColumn("k", k);
105  manager->CreateNtupleDColumn("p", p);
106  manager->CreateNtupleDColumn("px", px);
107  manager->CreateNtupleDColumn("py", py);
108  manager->CreateNtupleDColumn("pz", pz);
109  manager->CreateNtupleDColumn("q", q);
110  manager->CreateNtupleDColumn("et", et);
111  manager->FinishNtuple();
112 }
vector< double > l
length of track till this point [mm]
Definition: gears.cc:66
vector< double > p
momentum [keV]
Definition: gears.cc:72
vector< double > zz
z [mm] (origin: center of local volume)
Definition: gears.cc:62
vector< int > pid
parent particle&#39;s PDG encoding
Definition: gears.cc:59
vector< double > yy
y [mm] (origin: center of local volume)
Definition: gears.cc:61
vector< int > pdg
PDG encoding.
Definition: gears.cc:58
vector< double > q
charge [elementary charge]
Definition: gears.cc:76
vector< double > px
x component of momentum direction
Definition: gears.cc:73
vector< double > k
kinetic energy [keV]
Definition: gears.cc:71
vector< double > dt
time elapsed from previous step point [ns]
Definition: gears.cc:63
vector< double > z
z [mm] (origin: center of the world)
Definition: gears.cc:69
vector< double > py
y component of momentum direction
Definition: gears.cc:74
vector< double > dl
step length [mm]
Definition: gears.cc:65
vector< double > x
x [mm] (origin: center of the world)
Definition: gears.cc:67
vector< double > et
Total energy deposited in a volume [keV].
Definition: gears.cc:77
vector< double > y
y [mm] (origin: center of the world)
Definition: gears.cc:68
vector< double > de
energy deposited [keV]
Definition: gears.cc:64
vector< double > xx
x [mm] (origin: center of local volume)
Definition: gears.cc:60
vector< double > t
time elapsed from the beginning of an event [ns]
Definition: gears.cc:70
vector< int > vlm
volume copy number
Definition: gears.cc:56
vector< int > stp
step number
Definition: gears.cc:55
vector< int > trk
track ID
Definition: gears.cc:54
vector< int > pro
process ID * 100 + sub-process ID
Definition: gears.cc:57
vector< double > pz
z component of momentum direction
Definition: gears.cc:75

Member Function Documentation

◆ GetSteppingVerbose()

int Output::GetSteppingVerbose ( )
inline

Definition at line 52 of file gears.cc.

52 { return fManager->GetverboseLevel(); }

◆ Record()

void Output::Record ( )
protected

Record simulated data.

Definition at line 116 of file gears.cc.

116  {
117  if (GetSilent() == 1) // CopyState() won't be called in G4SteppingVerbose
118  CopyState(); // point fTrack, fStep, etc. to right places
119 
120  G4TouchableHandle handle = fStep->GetPreStepPoint()->GetTouchableHandle();
121  int copyNo = handle->GetReplicaNumber();
122  if (copyNo <= 0)
123  return; // skip uninteresting volumes (copy No. of world == 0)
124  if (trk.size() >= 10000) {
125  G4cout << "GEARS: # of step points >=10000. Recording stopped." << G4endl;
126  fTrack->SetTrackStatus(fKillTrackAndSecondaries);
127  return;
128  }
129 
130  trk.push_back(fTrack->GetTrackID());
131  stp.push_back(fTrack->GetCurrentStepNumber());
132  vlm.push_back(copyNo);
133  pdg.push_back(fTrack->GetDefinition()->GetPDGEncoding());
134  pid.push_back(fTrack->GetParentID());
135  if (stp.back() == 0) { // step zero
136  if (pid.back() != 0) // not primary particle
137  pro.push_back(fTrack->GetCreatorProcess()->GetProcessType() * 1000 +
138  fTrack->GetCreatorProcess()->GetProcessSubType());
139  else
140  pro.push_back(1000); // primary particle
141  } else {
142  const G4VProcess *pr = fStep->GetPostStepPoint()->GetProcessDefinedStep();
143  if (pr)
144  pro.push_back(pr->GetProcessType() * 1000 + pr->GetProcessSubType());
145  else
146  pro.push_back(900); // not sure why pr can be zero
147  }
148 
149  k.push_back(fTrack->GetKineticEnergy() / CLHEP::keV);
150  p.push_back(fTrack->GetMomentum().mag() / CLHEP::keV);
151  q.push_back(fStep->GetPostStepPoint()->GetCharge());
152  l.push_back(fTrack->GetTrackLength() / CLHEP::mm);
153 
154  px.push_back(fTrack->GetMomentumDirection().x());
155  py.push_back(fTrack->GetMomentumDirection().y());
156  pz.push_back(fTrack->GetMomentumDirection().z());
157  de.push_back(fStep->GetTotalEnergyDeposit() / CLHEP::keV);
158  dl.push_back(fTrack->GetStepLength() / CLHEP::mm);
159 
160  t.push_back(fTrack->GetGlobalTime() / CLHEP::ns);
161  x.push_back(fTrack->GetPosition().x() / CLHEP::mm);
162  y.push_back(fTrack->GetPosition().y() / CLHEP::mm);
163  z.push_back(fTrack->GetPosition().z() / CLHEP::mm);
164 
165  G4ThreeVector pos = handle->GetHistory()->GetTopTransform().TransformPoint(
166  fStep->GetPostStepPoint()->GetPosition());
167  xx.push_back(pos.x() / CLHEP::mm);
168  yy.push_back(pos.y() / CLHEP::mm);
169  zz.push_back(pos.z() / CLHEP::mm);
170  dt.push_back(fTrack->GetLocalTime() / CLHEP::ns);
171 
172  if (de.back() > 0 &&
173  G4StrUtil::contains(handle->GetVolume()->GetName(), "(S)")) {
174  if (et.size() < (unsigned int)copyNo + 1)
175  et.resize((unsigned int)copyNo + 1);
176  et[copyNo] += de.back();
177  et[0] += de.back();
178  }
179 }
vector< double > l
length of track till this point [mm]
Definition: gears.cc:66
vector< double > p
momentum [keV]
Definition: gears.cc:72
vector< double > zz
z [mm] (origin: center of local volume)
Definition: gears.cc:62
vector< int > pid
parent particle&#39;s PDG encoding
Definition: gears.cc:59
vector< double > yy
y [mm] (origin: center of local volume)
Definition: gears.cc:61
vector< int > pdg
PDG encoding.
Definition: gears.cc:58
vector< double > q
charge [elementary charge]
Definition: gears.cc:76
vector< double > px
x component of momentum direction
Definition: gears.cc:73
vector< double > k
kinetic energy [keV]
Definition: gears.cc:71
vector< double > dt
time elapsed from previous step point [ns]
Definition: gears.cc:63
vector< double > z
z [mm] (origin: center of the world)
Definition: gears.cc:69
vector< double > py
y component of momentum direction
Definition: gears.cc:74
vector< double > dl
step length [mm]
Definition: gears.cc:65
vector< double > x
x [mm] (origin: center of the world)
Definition: gears.cc:67
vector< double > et
Total energy deposited in a volume [keV].
Definition: gears.cc:77
vector< double > y
y [mm] (origin: center of the world)
Definition: gears.cc:68
vector< double > de
energy deposited [keV]
Definition: gears.cc:64
vector< double > xx
x [mm] (origin: center of local volume)
Definition: gears.cc:60
vector< double > t
time elapsed from the beginning of an event [ns]
Definition: gears.cc:70
vector< int > vlm
volume copy number
Definition: gears.cc:56
vector< int > stp
step number
Definition: gears.cc:55
vector< int > trk
track ID
Definition: gears.cc:54
vector< int > pro
process ID * 100 + sub-process ID
Definition: gears.cc:57
vector< double > pz
z component of momentum direction
Definition: gears.cc:75

◆ Reset()

void Output::Reset ( )
inline

Definition at line 25 of file gears.cc.

25  {
26  trk.clear();
27  stp.clear();
28  vlm.clear();
29  pro.clear();
30  pdg.clear();
31  pid.clear();
32  xx.clear();
33  yy.clear();
34  zz.clear();
35  dt.clear();
36  de.clear();
37  dl.clear();
38  l.clear();
39  x.clear();
40  y.clear();
41  z.clear();
42  t.clear();
43  k.clear();
44  p.clear();
45  px.clear();
46  py.clear();
47  pz.clear();
48  q.clear();
49  et.clear();
50  }
vector< double > l
length of track till this point [mm]
Definition: gears.cc:66
vector< double > p
momentum [keV]
Definition: gears.cc:72
vector< double > zz
z [mm] (origin: center of local volume)
Definition: gears.cc:62
vector< int > pid
parent particle&#39;s PDG encoding
Definition: gears.cc:59
vector< double > yy
y [mm] (origin: center of local volume)
Definition: gears.cc:61
vector< int > pdg
PDG encoding.
Definition: gears.cc:58
vector< double > q
charge [elementary charge]
Definition: gears.cc:76
vector< double > px
x component of momentum direction
Definition: gears.cc:73
vector< double > k
kinetic energy [keV]
Definition: gears.cc:71
vector< double > dt
time elapsed from previous step point [ns]
Definition: gears.cc:63
vector< double > z
z [mm] (origin: center of the world)
Definition: gears.cc:69
vector< double > py
y component of momentum direction
Definition: gears.cc:74
vector< double > dl
step length [mm]
Definition: gears.cc:65
vector< double > x
x [mm] (origin: center of the world)
Definition: gears.cc:67
vector< double > et
Total energy deposited in a volume [keV].
Definition: gears.cc:77
vector< double > y
y [mm] (origin: center of the world)
Definition: gears.cc:68
vector< double > de
energy deposited [keV]
Definition: gears.cc:64
vector< double > xx
x [mm] (origin: center of local volume)
Definition: gears.cc:60
vector< double > t
time elapsed from the beginning of an event [ns]
Definition: gears.cc:70
vector< int > vlm
volume copy number
Definition: gears.cc:56
vector< int > stp
step number
Definition: gears.cc:55
vector< int > trk
track ID
Definition: gears.cc:54
vector< int > pro
process ID * 100 + sub-process ID
Definition: gears.cc:57
vector< double > pz
z component of momentum direction
Definition: gears.cc:75

◆ SetSteppingVerbose()

void Output::SetSteppingVerbose ( int  level)
inline

Definition at line 51 of file gears.cc.

51 { fManager->SetVerboseLevel(level); }

◆ StepInfo()

void Output::StepInfo ( )
inline

Information of steps>0.

Definition at line 21 of file gears.cc.

◆ TrackingStarted()

void Output::TrackingStarted ( )
inline

Information of step 0 (initStep)

Definition at line 17 of file gears.cc.

Member Data Documentation

◆ de

vector<double> Output::de

energy deposited [keV]

Definition at line 64 of file gears.cc.

◆ dl

vector<double> Output::dl

step length [mm]

Definition at line 65 of file gears.cc.

◆ dt

vector<double> Output::dt

time elapsed from previous step point [ns]

Definition at line 63 of file gears.cc.

◆ et

vector<double> Output::et

Total energy deposited in a volume [keV].

Definition at line 77 of file gears.cc.

◆ k

vector<double> Output::k

kinetic energy [keV]

Definition at line 71 of file gears.cc.

◆ l

vector<double> Output::l

length of track till this point [mm]

Definition at line 66 of file gears.cc.

◆ p

vector<double> Output::p

momentum [keV]

Definition at line 72 of file gears.cc.

◆ pdg

vector<int> Output::pdg

PDG encoding.

Definition at line 58 of file gears.cc.

◆ pid

vector<int> Output::pid

parent particle's PDG encoding

Definition at line 59 of file gears.cc.

◆ pro

vector<int> Output::pro

process ID * 100 + sub-process ID

Definition at line 57 of file gears.cc.

◆ px

vector<double> Output::px

x component of momentum direction

Definition at line 73 of file gears.cc.

◆ py

vector<double> Output::py

y component of momentum direction

Definition at line 74 of file gears.cc.

◆ pz

vector<double> Output::pz

z component of momentum direction

Definition at line 75 of file gears.cc.

◆ q

vector<double> Output::q

charge [elementary charge]

Definition at line 76 of file gears.cc.

◆ stp

vector<int> Output::stp

step number

Definition at line 55 of file gears.cc.

◆ t

vector<double> Output::t

time elapsed from the beginning of an event [ns]

Definition at line 70 of file gears.cc.

◆ trk

vector<int> Output::trk

track ID

Definition at line 54 of file gears.cc.

◆ vlm

vector<int> Output::vlm

volume copy number

Definition at line 56 of file gears.cc.

◆ x

vector<double> Output::x

x [mm] (origin: center of the world)

Definition at line 67 of file gears.cc.

◆ xx

vector<double> Output::xx

x [mm] (origin: center of local volume)

Definition at line 60 of file gears.cc.

◆ y

vector<double> Output::y

y [mm] (origin: center of the world)

Definition at line 68 of file gears.cc.

◆ yy

vector<double> Output::yy

y [mm] (origin: center of local volume)

Definition at line 61 of file gears.cc.

◆ z

vector<double> Output::z

z [mm] (origin: center of the world)

Definition at line 69 of file gears.cc.

◆ zz

vector<double> Output::zz

z [mm] (origin: center of local volume)

Definition at line 62 of file gears.cc.


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