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

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

Inheritance diagram for Output:

Public Member Functions

 Output ()
 Create analysis manager to handle output. More...
 
 ~Output ()
 
void TrackingStarted ()
 Infomation of step 0 (initStep) More...
 
void StepInfo ()
 Infomation of steps>0. More...
 
void Reset ()
 

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 > 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

Output simulation results to screen or a file.

Definition at line 12 of file gears.cc.

Constructor & Destructor Documentation

§ Output()

Output::Output ( )

Create analysis manager to handle output.

Definition at line 52 of file gears.cc.

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

§ ~Output()

Output::~Output ( )
inline

Definition at line 18 of file gears.cc.

18 { delete G4AnalysisManager::Instance(); }

Member Function Documentation

§ Record()

void Output::Record ( )
protected

Record simulated data.

Definition at line 84 of file gears.cc.

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

§ Reset()

void Output::Reset ( )
inline

Definition at line 23 of file gears.cc.

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

§ StepInfo()

void Output::StepInfo ( )
inline

Infomation of steps>0.

Definition at line 21 of file gears.cc.

§ TrackingStarted()

void Output::TrackingStarted ( )
inline

Infomation of step 0 (initStep)

Definition at line 19 of file gears.cc.

Member Data Documentation

§ de

vector<double> Output::de

energy deposited [keV]

Definition at line 38 of file gears.cc.

§ dl

vector<double> Output::dl

step length [mm]

Definition at line 39 of file gears.cc.

§ dt

vector<double> Output::dt

time elapsed from previous step point [ns]

Definition at line 37 of file gears.cc.

§ et

vector<double> Output::et

Total energy deposited in a volume [keV].

Definition at line 48 of file gears.cc.

§ k

vector<double> Output::k

kinetic energy [keV]

Definition at line 45 of file gears.cc.

§ l

vector<double> Output::l

length of track till this point [mm]

Definition at line 40 of file gears.cc.

§ p

vector<double> Output::p

momentum [keV]

Definition at line 46 of file gears.cc.

§ pdg

vector<int> Output::pdg

PDG encoding.

Definition at line 32 of file gears.cc.

§ pid

vector<int> Output::pid

parent particle's PDG encoding

Definition at line 33 of file gears.cc.

§ pro

vector<int> Output::pro

process ID * 100 + sub-process ID

Definition at line 31 of file gears.cc.

§ q

vector<double> Output::q

charge [elementary charge]

Definition at line 47 of file gears.cc.

§ stp

vector<int> Output::stp

step number

Definition at line 29 of file gears.cc.

§ t

vector<double> Output::t

time elapsed from the beginning of an event [ns]

Definition at line 44 of file gears.cc.

§ trk

vector<int> Output::trk

track ID

Definition at line 28 of file gears.cc.

§ vlm

vector<int> Output::vlm

volume copy number

Definition at line 30 of file gears.cc.

§ x

vector<double> Output::x

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

Definition at line 41 of file gears.cc.

§ xx

vector<double> Output::xx

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

Definition at line 34 of file gears.cc.

§ y

vector<double> Output::y

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

Definition at line 42 of file gears.cc.

§ yy

vector<double> Output::yy

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

Definition at line 35 of file gears.cc.

§ z

vector<double> Output::z

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

Definition at line 43 of file gears.cc.

§ zz

vector<double> Output::zz

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

Definition at line 36 of file gears.cc.


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