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 58 of file gears.cc.

58  : G4SteppingVerbose()
59 {
60  auto manager = G4AnalysisManager::Instance();
61  manager->CreateNtuple("t", "Geant4 step points");
62  manager->CreateNtupleIColumn("n"); // total number of recorded hits
63  manager->CreateNtupleIColumn("m"); // max copy number of sensitive volume
64  manager->CreateNtupleIColumn("trk", trk);
65  manager->CreateNtupleIColumn("stp", stp);
66  manager->CreateNtupleIColumn("vlm", vlm);
67  manager->CreateNtupleIColumn("pro", pro);
68  manager->CreateNtupleIColumn("pdg", pdg);
69  manager->CreateNtupleIColumn("pid", pid);
70  manager->CreateNtupleDColumn("xx", xx);
71  manager->CreateNtupleDColumn("yy", yy);
72  manager->CreateNtupleDColumn("zz", zz);
73  manager->CreateNtupleDColumn("dt", dt);
74  manager->CreateNtupleDColumn("de", de);
75  manager->CreateNtupleDColumn("dl", dl);
76  manager->CreateNtupleDColumn("l", l);
77  manager->CreateNtupleDColumn("x", x);
78  manager->CreateNtupleDColumn("y", y);
79  manager->CreateNtupleDColumn("z", z);
80  manager->CreateNtupleDColumn("t", t);
81  manager->CreateNtupleDColumn("k", k);
82  manager->CreateNtupleDColumn("p", p);
83  manager->CreateNtupleDColumn("px", px);
84  manager->CreateNtupleDColumn("py", py);
85  manager->CreateNtupleDColumn("pz", pz);
86  manager->CreateNtupleDColumn("q", q);
87  manager->CreateNtupleDColumn("et", et);
88  manager->FinishNtuple();
89 }
vector< double > l
length of track till this point [mm]
Definition: gears.cc:42
vector< double > p
momentum [keV]
Definition: gears.cc:48
vector< double > zz
z [mm] (origin: center of local volume)
Definition: gears.cc:38
vector< int > pid
parent particle&#39;s PDG encoding
Definition: gears.cc:35
vector< double > yy
y [mm] (origin: center of local volume)
Definition: gears.cc:37
vector< int > pdg
PDG encoding.
Definition: gears.cc:34
vector< double > q
charge [elementary charge]
Definition: gears.cc:52
vector< double > px
x component of momentum direction
Definition: gears.cc:49
vector< double > k
kinetic energy [keV]
Definition: gears.cc:47
vector< double > dt
time elapsed from previous step point [ns]
Definition: gears.cc:39
vector< double > z
z [mm] (origin: center of the world)
Definition: gears.cc:45
vector< double > py
y component of momentum direction
Definition: gears.cc:50
vector< double > dl
step length [mm]
Definition: gears.cc:41
vector< double > x
x [mm] (origin: center of the world)
Definition: gears.cc:43
vector< double > et
Total energy deposited in a volume [keV].
Definition: gears.cc:53
vector< double > y
y [mm] (origin: center of the world)
Definition: gears.cc:44
vector< double > de
energy deposited [keV]
Definition: gears.cc:40
vector< double > xx
x [mm] (origin: center of local volume)
Definition: gears.cc:36
vector< double > t
time elapsed from the beginning of an event [ns]
Definition: gears.cc:46
vector< int > vlm
volume copy number
Definition: gears.cc:32
vector< int > stp
step number
Definition: gears.cc:31
vector< int > trk
track ID
Definition: gears.cc:30
vector< int > pro
process ID * 100 + sub-process ID
Definition: gears.cc:33
vector< double > pz
z component of momentum direction
Definition: gears.cc:51

Member Function Documentation

◆ GetSteppingVerbose()

int Output::GetSteppingVerbose ( )
inline

Definition at line 28 of file gears.cc.

28 { return fManager->GetverboseLevel(); }

◆ Record()

void Output::Record ( )
protected

Record simulated data.

Definition at line 93 of file gears.cc.

94 {
95  if (GetSilent()==1) // CopyState() won't be called in G4SteppingVerbose
96  CopyState(); // point fTrack, fStep, etc. to right places
97 
98  G4TouchableHandle handle = fStep->GetPreStepPoint()->GetTouchableHandle();
99  int copyNo=handle->GetReplicaNumber();
100  if (copyNo<=0) return; //skip uninteresting volumes (copy No. of world == 0)
101  if (trk.size()>=10000) {
102  G4cout<<"GEARS: # of step points >=10000. Recording stopped."<<G4endl;
103  fTrack->SetTrackStatus(fKillTrackAndSecondaries);
104  return;
105  }
106 
107  trk.push_back(fTrack->GetTrackID());
108  stp.push_back(fTrack->GetCurrentStepNumber());
109  vlm.push_back(copyNo);
110  pdg.push_back(fTrack->GetDefinition()->GetPDGEncoding());
111  pid.push_back(fTrack->GetParentID());
112  if (stp.back()==0) { // step zero
113  if (pid.back()!=0) // not primary particle
114  pro.push_back(fTrack->GetCreatorProcess()->GetProcessType()*1000
115  + fTrack->GetCreatorProcess()->GetProcessSubType());
116  else pro.push_back(1000); // primary particle
117  } else {
118  const G4VProcess *pr = fStep->GetPostStepPoint()->GetProcessDefinedStep();
119  if (pr) pro.push_back(pr->GetProcessType()*1000 + pr->GetProcessSubType());
120  else pro.push_back(900); // not sure why pr can be zero
121  }
122 
123  k.push_back(fTrack->GetKineticEnergy()/CLHEP::keV);
124  p.push_back(fTrack->GetMomentum().mag()/CLHEP::keV);
125  q.push_back(fStep->GetPostStepPoint()->GetCharge());
126  l.push_back(fTrack->GetTrackLength()/CLHEP::mm);
127 
128  px.push_back(fTrack->GetMomentumDirection().x());
129  py.push_back(fTrack->GetMomentumDirection().y());
130  pz.push_back(fTrack->GetMomentumDirection().z());
131  de.push_back(fStep->GetTotalEnergyDeposit()/CLHEP::keV);
132  dl.push_back(fTrack->GetStepLength()/CLHEP::mm);
133 
134  t.push_back(fTrack->GetGlobalTime()/CLHEP::ns);
135  x.push_back(fTrack->GetPosition().x()/CLHEP::mm);
136  y.push_back(fTrack->GetPosition().y()/CLHEP::mm);
137  z.push_back(fTrack->GetPosition().z()/CLHEP::mm);
138 
139  G4ThreeVector pos = handle->GetHistory()->GetTopTransform()
140  .TransformPoint(fStep->GetPostStepPoint()->GetPosition());
141  xx.push_back(pos.x()/CLHEP::mm);
142  yy.push_back(pos.y()/CLHEP::mm);
143  zz.push_back(pos.z()/CLHEP::mm);
144  dt.push_back(fTrack->GetLocalTime()/CLHEP::ns);
145 
146  if (de.back()>0 && G4StrUtil::contains(handle->GetVolume()->GetName(),"(S)")) {
147  if (et.size()<(unsigned int)copyNo+1) et.resize((unsigned int)copyNo+1);
148  et[copyNo]+=de.back(); et[0]+=de.back();
149  }
150 }
vector< double > l
length of track till this point [mm]
Definition: gears.cc:42
vector< double > p
momentum [keV]
Definition: gears.cc:48
vector< double > zz
z [mm] (origin: center of local volume)
Definition: gears.cc:38
vector< int > pid
parent particle&#39;s PDG encoding
Definition: gears.cc:35
vector< double > yy
y [mm] (origin: center of local volume)
Definition: gears.cc:37
vector< int > pdg
PDG encoding.
Definition: gears.cc:34
vector< double > q
charge [elementary charge]
Definition: gears.cc:52
vector< double > px
x component of momentum direction
Definition: gears.cc:49
vector< double > k
kinetic energy [keV]
Definition: gears.cc:47
vector< double > dt
time elapsed from previous step point [ns]
Definition: gears.cc:39
vector< double > z
z [mm] (origin: center of the world)
Definition: gears.cc:45
vector< double > py
y component of momentum direction
Definition: gears.cc:50
vector< double > dl
step length [mm]
Definition: gears.cc:41
vector< double > x
x [mm] (origin: center of the world)
Definition: gears.cc:43
vector< double > et
Total energy deposited in a volume [keV].
Definition: gears.cc:53
vector< double > y
y [mm] (origin: center of the world)
Definition: gears.cc:44
vector< double > de
energy deposited [keV]
Definition: gears.cc:40
vector< double > xx
x [mm] (origin: center of local volume)
Definition: gears.cc:36
vector< double > t
time elapsed from the beginning of an event [ns]
Definition: gears.cc:46
vector< int > vlm
volume copy number
Definition: gears.cc:32
vector< int > stp
step number
Definition: gears.cc:31
vector< int > trk
track ID
Definition: gears.cc:30
vector< int > pro
process ID * 100 + sub-process ID
Definition: gears.cc:33
vector< double > pz
z component of momentum direction
Definition: gears.cc:51

◆ Reset()

void Output::Reset ( )
inline

Definition at line 22 of file gears.cc.

22  { trk.clear(); stp.clear(); vlm.clear(); pro.clear();
23  pdg.clear(); pid.clear(); xx.clear(); yy.clear(); zz.clear(); dt.clear();
24  de.clear(); dl.clear(); l.clear(); x.clear(); y.clear(); z.clear();
25  t.clear(); k.clear(); p.clear(); px.clear(); py.clear(); pz.clear();
26  q.clear(); et.clear(); }
vector< double > l
length of track till this point [mm]
Definition: gears.cc:42
vector< double > p
momentum [keV]
Definition: gears.cc:48
vector< double > zz
z [mm] (origin: center of local volume)
Definition: gears.cc:38
vector< int > pid
parent particle&#39;s PDG encoding
Definition: gears.cc:35
vector< double > yy
y [mm] (origin: center of local volume)
Definition: gears.cc:37
vector< int > pdg
PDG encoding.
Definition: gears.cc:34
vector< double > q
charge [elementary charge]
Definition: gears.cc:52
vector< double > px
x component of momentum direction
Definition: gears.cc:49
vector< double > k
kinetic energy [keV]
Definition: gears.cc:47
vector< double > dt
time elapsed from previous step point [ns]
Definition: gears.cc:39
vector< double > z
z [mm] (origin: center of the world)
Definition: gears.cc:45
vector< double > py
y component of momentum direction
Definition: gears.cc:50
vector< double > dl
step length [mm]
Definition: gears.cc:41
vector< double > x
x [mm] (origin: center of the world)
Definition: gears.cc:43
vector< double > et
Total energy deposited in a volume [keV].
Definition: gears.cc:53
vector< double > y
y [mm] (origin: center of the world)
Definition: gears.cc:44
vector< double > de
energy deposited [keV]
Definition: gears.cc:40
vector< double > xx
x [mm] (origin: center of local volume)
Definition: gears.cc:36
vector< double > t
time elapsed from the beginning of an event [ns]
Definition: gears.cc:46
vector< int > vlm
volume copy number
Definition: gears.cc:32
vector< int > stp
step number
Definition: gears.cc:31
vector< int > trk
track ID
Definition: gears.cc:30
vector< int > pro
process ID * 100 + sub-process ID
Definition: gears.cc:33
vector< double > pz
z component of momentum direction
Definition: gears.cc:51

◆ SetSteppingVerbose()

void Output::SetSteppingVerbose ( int  level)
inline

Definition at line 27 of file gears.cc.

27 { fManager->SetVerboseLevel(level); }

◆ StepInfo()

void Output::StepInfo ( )
inline

Information of steps>0.

Definition at line 20 of file gears.cc.

◆ TrackingStarted()

void Output::TrackingStarted ( )
inline

Information of step 0 (initStep)

Definition at line 18 of file gears.cc.

Member Data Documentation

◆ de

vector<double> Output::de

energy deposited [keV]

Definition at line 40 of file gears.cc.

◆ dl

vector<double> Output::dl

step length [mm]

Definition at line 41 of file gears.cc.

◆ dt

vector<double> Output::dt

time elapsed from previous step point [ns]

Definition at line 39 of file gears.cc.

◆ et

vector<double> Output::et

Total energy deposited in a volume [keV].

Definition at line 53 of file gears.cc.

◆ k

vector<double> Output::k

kinetic energy [keV]

Definition at line 47 of file gears.cc.

◆ l

vector<double> Output::l

length of track till this point [mm]

Definition at line 42 of file gears.cc.

◆ p

vector<double> Output::p

momentum [keV]

Definition at line 48 of file gears.cc.

◆ pdg

vector<int> Output::pdg

PDG encoding.

Definition at line 34 of file gears.cc.

◆ pid

vector<int> Output::pid

parent particle's PDG encoding

Definition at line 35 of file gears.cc.

◆ pro

vector<int> Output::pro

process ID * 100 + sub-process ID

Definition at line 33 of file gears.cc.

◆ px

vector<double> Output::px

x component of momentum direction

Definition at line 49 of file gears.cc.

◆ py

vector<double> Output::py

y component of momentum direction

Definition at line 50 of file gears.cc.

◆ pz

vector<double> Output::pz

z component of momentum direction

Definition at line 51 of file gears.cc.

◆ q

vector<double> Output::q

charge [elementary charge]

Definition at line 52 of file gears.cc.

◆ stp

vector<int> Output::stp

step number

Definition at line 31 of file gears.cc.

◆ t

vector<double> Output::t

time elapsed from the beginning of an event [ns]

Definition at line 46 of file gears.cc.

◆ trk

vector<int> Output::trk

track ID

Definition at line 30 of file gears.cc.

◆ vlm

vector<int> Output::vlm

volume copy number

Definition at line 32 of file gears.cc.

◆ x

vector<double> Output::x

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

Definition at line 43 of file gears.cc.

◆ xx

vector<double> Output::xx

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

Definition at line 36 of file gears.cc.

◆ y

vector<double> Output::y

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

Definition at line 44 of file gears.cc.

◆ yy

vector<double> Output::yy

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

Definition at line 37 of file gears.cc.

◆ z

vector<double> Output::z

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

Definition at line 45 of file gears.cc.

◆ zz

vector<double> Output::zz

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

Definition at line 38 of file gears.cc.


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