ATLAS Offline Software
Classes | Public Member Functions | Private Attributes | List of all members
G4UA::ScoringPlane Class Reference

#include <ScoringPlane.h>

Inheritance diagram for G4UA::ScoringPlane:
Collaboration diagram for G4UA::ScoringPlane:

Classes

struct  Config
 

Public Member Functions

 ScoringPlane (const Config &config)
 
 ~ScoringPlane ()
 
virtual void BeginOfRunAction (const G4Run *) override
 
virtual void EndOfRunAction (const G4Run *) override
 
virtual void UserSteppingAction (const G4Step *) override
 
virtual void BeginOfEventAction (const G4Event *) override
 
virtual void EndOfEventAction (const G4Event *) override
 

Private Attributes

Config m_config
 
std::unique_ptr< TTree > m_tree0
 
std::unique_ptr< TTree > m_tree1
 
int m_evt
 
int m_ntr
 
int m_pdg
 
double m_cha
 
double m_ene
 
double m_vx
 
double m_vy
 
double m_vz
 
double m_x0
 
double m_y0
 
double m_z0
 
double m_t0
 
double m_px0
 
double m_py0
 
double m_pz0
 
double m_x1
 
double m_y1
 
double m_z1
 
double m_t1
 
double m_px1
 
double m_py1
 
double m_pz1
 
double m_x
 
double m_y
 
double m_z
 

Detailed Description

Todo:
TODO NEEDS DOCUMENTATION

Definition at line 23 of file ScoringPlane.h.

Constructor & Destructor Documentation

◆ ScoringPlane()

G4UA::ScoringPlane::ScoringPlane ( const Config config)

Definition at line 18 of file ScoringPlane.cxx.

19  : m_config(config),
20  m_evt(0), m_ntr(0), m_pdg(0), m_cha(0), m_ene(0),
21  m_vx(0), m_vy(0), m_vz(0),
22  m_x0(0), m_y0(0), m_z0(0), m_t0(0),
23  m_px0(0), m_py0(0), m_pz0(0),
24  m_x1(0), m_y1(0), m_z1(0), m_t1(0),
25  m_px1(0), m_py1(0), m_pz1(0),
26  m_x(0), m_y(0), m_z(0)
27  {
28  }

◆ ~ScoringPlane()

G4UA::ScoringPlane::~ScoringPlane ( )

Definition at line 30 of file ScoringPlane.cxx.

31  {
32  }

Member Function Documentation

◆ BeginOfEventAction()

void G4UA::ScoringPlane::BeginOfEventAction ( const G4Event *  )
overridevirtual

Definition at line 140 of file ScoringPlane.cxx.

141  {
142  m_evt++;
143  m_ntr = 0;
144  }

◆ BeginOfRunAction()

void G4UA::ScoringPlane::BeginOfRunAction ( const G4Run *  )
overridevirtual

Definition at line 34 of file ScoringPlane.cxx.

35  {
36 
37  m_tree0 = std::make_unique<TTree>("t0", "ATHENA event tree");
38 
39  m_tree0->Branch("evt", &m_evt, "evt/I");
40  m_tree0->Branch("ntr", &m_ntr, "ntr/I");
41 
42  m_tree1 = std::make_unique<TTree>("t1", "ATHENA particle tree");
43 
44  m_tree1->Branch("evt", &m_evt, "evt/I");
45  m_tree1->Branch("ntr", &m_ntr, "ntr/I");
46  m_tree1->Branch("pdg", &m_pdg, "pdg/I");
47  m_tree1->Branch("cha", &m_cha, "cha/D");
48  m_tree1->Branch("ene", &m_ene, "ene/D");
49  m_tree1->Branch("x0", &m_x0, "x0/D");
50  m_tree1->Branch("y0", &m_y0, "y0/D");
51  m_tree1->Branch("z0", &m_z0, "z0/D");
52  m_tree1->Branch("t0", &m_t0, "t0/D");
53  m_tree1->Branch("px0", &m_px0, "px0/D");
54  m_tree1->Branch("py0", &m_py0, "py0/D");
55  m_tree1->Branch("pz0", &m_pz0, "pz0/D");
56  m_tree1->Branch("x1", &m_x1, "x1/D");
57  m_tree1->Branch("y1", &m_y1, "y1/D");
58  m_tree1->Branch("z1", &m_z1, "z1/D");
59  m_tree1->Branch("t1", &m_t1, "t1/D");
60  m_tree1->Branch("px1", &m_px1, "px1/D");
61  m_tree1->Branch("py1", &m_py1, "py1/D");
62  m_tree1->Branch("pz1", &m_pz1, "pz1/D");
63  m_tree1->Branch("vx", &m_vx, "vx/D");
64  m_tree1->Branch("vy", &m_vy, "vy/D");
65  m_tree1->Branch("vz", &m_vz, "vz/D");
66  m_tree1->Branch("x", &m_x, "x/D");
67  m_tree1->Branch("y", &m_y, "y/D");
68  m_tree1->Branch("z", &m_z, "z/D");
69 
70  m_evt = 0;
71 
72  G4cout<<"ScoringPlane: placing scoring plane at [mm]: " << m_config.plane << G4endl;
73  G4cout<<"ScoringPlane: stop and kill particles: " << m_config.pkill << G4endl;
74  G4cout<<"ScoringPlane: output root filename: " << m_config.fname << G4endl;
75  }

◆ EndOfEventAction()

void G4UA::ScoringPlane::EndOfEventAction ( const G4Event *  )
overridevirtual

Definition at line 146 of file ScoringPlane.cxx.

147  {
148  m_tree0->Fill();
149  }

◆ EndOfRunAction()

void G4UA::ScoringPlane::EndOfRunAction ( const G4Run *  )
overridevirtual

Definition at line 77 of file ScoringPlane.cxx.

77  {
78  TFile* file = new TFile(m_config.fname.c_str(), "RECREATE", "ATHENA ufo simulation");
79 
80  m_tree0->Write();
81  m_tree1->Write();
82 
83  file->Close();
84  }

◆ UserSteppingAction()

void G4UA::ScoringPlane::UserSteppingAction ( const G4Step *  aStep)
overridevirtual

Definition at line 86 of file ScoringPlane.cxx.

87  {
88  m_z0 = aStep->GetPreStepPoint()->GetPosition().z();
89  m_z1 = aStep->GetPostStepPoint()->GetPosition().z();
90 
91  if (m_z0*m_config.plane < 0) return; // take only particles on one side
92  if (m_z1*m_config.plane < 0) return; // take only particles on one side
93  if (std::fabs(m_z0) < std::fabs(m_config.plane)) return; // take only particles flowing towards the IP
94  if (std::fabs(m_z1) > std::fabs(m_config.plane)) return; // take only particles flowing towards the IP
95 
96  m_ntr++;
97 
98  m_pdg = aStep->GetTrack()->GetDefinition()->GetPDGEncoding();
99  m_cha = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
100  m_ene = aStep->GetTrack()->GetTotalEnergy();
101  m_vx = aStep->GetTrack()->GetVertexPosition().x();
102  m_vy = aStep->GetTrack()->GetVertexPosition().y();
103  m_vz = aStep->GetTrack()->GetVertexPosition().z();
104 
105  m_x0 = aStep->GetPreStepPoint()->GetPosition().x();
106  m_y0 = aStep->GetPreStepPoint()->GetPosition().y();
107  m_t0 = aStep->GetPreStepPoint()->GetGlobalTime()/CLHEP::ns;
108  m_px0 = aStep->GetPreStepPoint()->GetMomentum().x();
109  m_py0 = aStep->GetPreStepPoint()->GetMomentum().y();
110  m_pz0 = aStep->GetPreStepPoint()->GetMomentum().z();
111 
112  m_x1 = aStep->GetPostStepPoint()->GetPosition().x();
113  m_y1 = aStep->GetPostStepPoint()->GetPosition().y();
114  m_t1 = aStep->GetPostStepPoint()->GetGlobalTime()/CLHEP::ns;
115  m_px1 = aStep->GetPostStepPoint()->GetMomentum().x();
116  m_py1 = aStep->GetPostStepPoint()->GetMomentum().y();
117  m_pz1 = aStep->GetPostStepPoint()->GetMomentum().z();
118 
119  m_z = m_config.plane;
120  m_x = m_x0 + (m_z0!=m_z1 ? (m_x1-m_x0)/(m_z1-m_z0)*(m_z-m_z0) : (m_x1-m_x0)*0.5);
121  m_y = m_y0 + (m_z0!=m_z1 ? (m_y1-m_y0)/(m_z1-m_z0)*(m_z-m_z0) : (m_y1-m_y0)*0.5);
122 
123  m_tree1->Fill();
124 
125  if (m_config.pkill == 1) aStep->GetTrack()->SetTrackStatus(fStopAndKill);
126  else if (m_config.pkill == 2) aStep->GetTrack()->SetTrackStatus(fKillTrackAndSecondaries);
127 
128  //G4cout<<
129  // " z0: " << std::setw(10) << m_z0
130  // << " z1: " << std::setw(10) << m_z1
131  // << " x0: " << std::setw(10) << m_x0
132  // << " x1: " << std::setw(10) << m_x1
133  // << " x: " << std::setw(10) << m_x
134  // << " y0: " << std::setw(10) << m_y0
135  // << " y1: " << std::setw(10) << m_y1
136  // << " y: " << std::setw(10) << m_y << G4endl;
137 
138  }

Member Data Documentation

◆ m_cha

double G4UA::ScoringPlane::m_cha
private

Definition at line 54 of file ScoringPlane.h.

◆ m_config

Config G4UA::ScoringPlane::m_config
private

Definition at line 45 of file ScoringPlane.h.

◆ m_ene

double G4UA::ScoringPlane::m_ene
private

Definition at line 55 of file ScoringPlane.h.

◆ m_evt

int G4UA::ScoringPlane::m_evt
private

Definition at line 50 of file ScoringPlane.h.

◆ m_ntr

int G4UA::ScoringPlane::m_ntr
private

Definition at line 51 of file ScoringPlane.h.

◆ m_pdg

int G4UA::ScoringPlane::m_pdg
private

Definition at line 53 of file ScoringPlane.h.

◆ m_px0

double G4UA::ScoringPlane::m_px0
private

Definition at line 63 of file ScoringPlane.h.

◆ m_px1

double G4UA::ScoringPlane::m_px1
private

Definition at line 70 of file ScoringPlane.h.

◆ m_py0

double G4UA::ScoringPlane::m_py0
private

Definition at line 64 of file ScoringPlane.h.

◆ m_py1

double G4UA::ScoringPlane::m_py1
private

Definition at line 71 of file ScoringPlane.h.

◆ m_pz0

double G4UA::ScoringPlane::m_pz0
private

Definition at line 65 of file ScoringPlane.h.

◆ m_pz1

double G4UA::ScoringPlane::m_pz1
private

Definition at line 72 of file ScoringPlane.h.

◆ m_t0

double G4UA::ScoringPlane::m_t0
private

Definition at line 62 of file ScoringPlane.h.

◆ m_t1

double G4UA::ScoringPlane::m_t1
private

Definition at line 69 of file ScoringPlane.h.

◆ m_tree0

std::unique_ptr<TTree> G4UA::ScoringPlane::m_tree0
private

Definition at line 47 of file ScoringPlane.h.

◆ m_tree1

std::unique_ptr<TTree> G4UA::ScoringPlane::m_tree1
private

Definition at line 48 of file ScoringPlane.h.

◆ m_vx

double G4UA::ScoringPlane::m_vx
private

Definition at line 56 of file ScoringPlane.h.

◆ m_vy

double G4UA::ScoringPlane::m_vy
private

Definition at line 57 of file ScoringPlane.h.

◆ m_vz

double G4UA::ScoringPlane::m_vz
private

Definition at line 58 of file ScoringPlane.h.

◆ m_x

double G4UA::ScoringPlane::m_x
private

Definition at line 73 of file ScoringPlane.h.

◆ m_x0

double G4UA::ScoringPlane::m_x0
private

Definition at line 59 of file ScoringPlane.h.

◆ m_x1

double G4UA::ScoringPlane::m_x1
private

Definition at line 66 of file ScoringPlane.h.

◆ m_y

double G4UA::ScoringPlane::m_y
private

Definition at line 74 of file ScoringPlane.h.

◆ m_y0

double G4UA::ScoringPlane::m_y0
private

Definition at line 60 of file ScoringPlane.h.

◆ m_y1

double G4UA::ScoringPlane::m_y1
private

Definition at line 67 of file ScoringPlane.h.

◆ m_z

double G4UA::ScoringPlane::m_z
private

Definition at line 75 of file ScoringPlane.h.

◆ m_z0

double G4UA::ScoringPlane::m_z0
private

Definition at line 61 of file ScoringPlane.h.

◆ m_z1

double G4UA::ScoringPlane::m_z1
private

Definition at line 68 of file ScoringPlane.h.


The documentation for this class was generated from the following files:
G4UA::ScoringPlane::m_py1
double m_py1
Definition: ScoringPlane.h:71
G4UA::ScoringPlane::Config::pkill
int pkill
Definition: ScoringPlane.h:33
G4UA::ScoringPlane::m_z1
double m_z1
Definition: ScoringPlane.h:68
G4UA::ScoringPlane::m_x
double m_x
Definition: ScoringPlane.h:73
G4UA::ScoringPlane::m_pdg
int m_pdg
Definition: ScoringPlane.h:53
G4UA::ScoringPlane::m_pz1
double m_pz1
Definition: ScoringPlane.h:72
G4UA::ScoringPlane::m_x0
double m_x0
Definition: ScoringPlane.h:59
G4UA::ScoringPlane::m_y0
double m_y0
Definition: ScoringPlane.h:60
G4UA::ScoringPlane::m_ene
double m_ene
Definition: ScoringPlane.h:55
G4UA::ScoringPlane::m_evt
int m_evt
Definition: ScoringPlane.h:50
G4UA::ScoringPlane::m_ntr
int m_ntr
Definition: ScoringPlane.h:51
G4UA::ScoringPlane::m_vz
double m_vz
Definition: ScoringPlane.h:58
G4UA::ScoringPlane::m_vx
double m_vx
Definition: ScoringPlane.h:56
G4UA::ScoringPlane::m_x1
double m_x1
Definition: ScoringPlane.h:66
G4UA::ScoringPlane::m_px1
double m_px1
Definition: ScoringPlane.h:70
G4UA::ScoringPlane::m_config
Config m_config
Definition: ScoringPlane.h:45
G4UA::ScoringPlane::m_y1
double m_y1
Definition: ScoringPlane.h:67
G4UA::ScoringPlane::m_t0
double m_t0
Definition: ScoringPlane.h:62
G4UA::ScoringPlane::Config::plane
double plane
Definition: ScoringPlane.h:32
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
file
TFile * file
Definition: tile_monitor.h:29
G4UA::ScoringPlane::m_y
double m_y
Definition: ScoringPlane.h:74
G4UA::ScoringPlane::m_tree0
std::unique_ptr< TTree > m_tree0
Definition: ScoringPlane.h:47
G4UA::ScoringPlane::m_z
double m_z
Definition: ScoringPlane.h:75
G4UA::ScoringPlane::m_z0
double m_z0
Definition: ScoringPlane.h:61
G4UA::ScoringPlane::m_cha
double m_cha
Definition: ScoringPlane.h:54
G4UA::ScoringPlane::m_t1
double m_t1
Definition: ScoringPlane.h:69
G4UA::ScoringPlane::m_px0
double m_px0
Definition: ScoringPlane.h:63
G4UA::ScoringPlane::m_tree1
std::unique_ptr< TTree > m_tree1
Definition: ScoringPlane.h:48
G4UA::ScoringPlane::Config::fname
std::string fname
Definition: ScoringPlane.h:34
python.SystemOfUnits.ns
int ns
Definition: SystemOfUnits.py:130
G4UA::ScoringPlane::m_vy
double m_vy
Definition: ScoringPlane.h:57
G4UA::ScoringPlane::m_pz0
double m_pz0
Definition: ScoringPlane.h:65
G4UA::ScoringPlane::m_py0
double m_py0
Definition: ScoringPlane.h:64