ACTARSim
ACTAR TPC Simulation Reference Guide
ActarSimPrimaryInfo.cc
Go to the documentation of this file.
1 // - AUTHOR: Hector Alvarez-Pol 04/2008
2 /******************************************************************
3  * Copyright (C) 2005-2016, Hector Alvarez-Pol *
4  * All rights reserved. *
5  * *
6  * License according to GNU LESSER GPL (see lgpl-3.0.txt). *
7  * For the list of contributors see CREDITS. *
8  ******************************************************************/
9 //////////////////////////////////////////////////////////////////
10 /// \class ActarSimPrimaryInfo
11 /// The information from the primaries generated in the reaction
12 /// vertex. Information to be accessed in the ROOT file per event
13 /////////////////////////////////////////////////////////////////
14 
15 #include "ActarSimPrimaryInfo.hh"
16 
17 #include "G4PrimaryParticle.hh"
18 #include "G4ThreeVector.hh"
19 
20 #include "G4PhysicalConstants.hh"
21 #include "G4SystemOfUnits.hh"
22 
23 
25 
26 //////////////////////////////////////////////////////////////////
27 /// Constructor
29  nbPrimariesInEvent = 0;
30  kineticEnergy = 0;
31  theta = 0;
32  phi =0;
33  PDGcode = 0;
34  Px = 0;
35  Py = 0;
36  Pz = 0;
37  trackID = 0;
38  mass = 0;
39  charge = 0;
40  polX = 0;
41  polY = 0;
42  polZ = 0;
43  Weight0 = 0;
44  properTime = 0;
45  x0 = 0.;
46  y0 = 0.;
47  z0 = 0.;
48  eventID = 0;
49  runID = 0;
50 }
51 
52 //////////////////////////////////////////////////////////////////
53 /// Constructor from a primary
54 ActarSimPrimaryInfo::ActarSimPrimaryInfo(G4PrimaryParticle* prim) {
55  theta = prim->GetMomentum().theta() / rad;
56  phi = prim->GetMomentum().phi() / rad;
57 
58  PDGcode = prim->GetPDGcode();
59  Px = prim->GetPx();
60  Py = prim->GetPy();
61  Pz = prim->GetPz();
62  trackID = prim->GetTrackID();
63  mass = prim->GetMass();
64  charge = prim->GetCharge() / eplus;
65  polX = prim->GetPolX();
66  polY = prim->GetPolY();
67  polZ = prim->GetPolZ();
68  Weight0 = prim->GetWeight();
69  properTime = prim->GetProperTime() / ns;
70 
71  //calculating the kinetic energy
72  Double_t energysquared = (prim->GetMass()*prim->GetMass()) +
73  (prim->GetPx()*prim->GetPx()+
74  prim->GetPy()*prim->GetPy()+
75  prim->GetPz()*prim->GetPz());
76  kineticEnergy = sqrt(energysquared) - prim->GetMass();
77 }
78 
79 //////////////////////////////////////////////////////////////////
80 /// Destructor. Makes nothing
82 }
83 
84 //////////////////////////////////////////////////////////////////
85 /// Prints info
87  G4cout << "-------------------------------------------" << G4endl;
88  G4cout << "------- ActarSimPrimaryInfo::print() ---------" << G4endl;
89  G4cout << " eventID: " << eventID << ", runID: " << runID << G4endl;
90  G4cout << " PDGcode: " << PDGcode
91  << ", trackID: " << trackID
92  << ", mass: " << mass
93  << ", charge: " << charge / eplus << " eplus" << G4endl;
94  G4cout << " Px: " << Px
95  << " Py: " << Py
96  << " Pz: " << Pz
97  << ", properTime: " << properTime / ns << " ns" << G4endl;
98  G4cout << " polX: " << polX
99  << " polY: " << polY
100  << " polZ: " << polZ
101  << ", Weight0: " << Weight0 << G4endl;
102  G4cout << " x0: " << x0 / mm << " mm"
103  << " y0: " << y0 / mm << " mm"
104  << " z0: " << z0 / mm << " mm" << G4endl;
105  G4cout << " nbPrimariesInEvent: " << nbPrimariesInEvent
106  << ", kineticEnergy: " << kineticEnergy
107  << ", theta: " << theta / rad << " rad"
108  << ", phi: " << phi / rad << " rad" << G4endl;
109  G4cout << "-------------------------------------------" << G4endl;
110 }
111 
112 //////////////////////////////////////////////////////////////////
113 /// Sets the position of the vertex (origin of the primary particle)
114 void ActarSimPrimaryInfo::SetVertexPosition(Double_t x, Double_t y, Double_t z) {
115  x0 = x;
116  y0 = y;
117  z0 = z;
118 }
119 
120 //////////////////////////////////////////////////////////////////
121 /// Sets the momentum
122 void ActarSimPrimaryInfo::SetMomentum(Double_t px, Double_t py, Double_t pz) {
123  Px = px;
124  Py = py;
125  Pz = pz;
126  G4ThreeVector mom(Px,Py,Pz);
127  theta = mom.theta();
128  phi = mom.phi();
129 }
130 
131 //////////////////////////////////////////////////////////////////
132 /// Sets the 4momentum
133 void ActarSimPrimaryInfo::Set4Momentum(Double_t px, Double_t py, Double_t pz, Double_t E){
134  Px = px;
135  Py = py;
136  Pz = pz;
137  Double_t mas2 = E*E - px*px - py*py - pz*pz;
138  if(mas2>=0.) {
139  mass = std::sqrt(mas2);
140  }
141  else {
142  mass = -1.0;
143  }
144 }
145 
146 //////////////////////////////////////////////////////////////////
147 /// Sets the polarization
148 void ActarSimPrimaryInfo::SetPolarization(Double_t px,Double_t py,Double_t pz) {
149  polX = px;
150  polY = py;
151  polZ = pz;
152 }
Double_t y0
Vertex position in X.
Double_t x0
Vertex position in X.
UInt_t eventID
Event ID.
Double_t kineticEnergy
Kinetic energy.
Double_t properTime
Partice proper time.
Double_t Weight0
Particle weight.
Double_t Px
X component of the momentum.
Double_t Pz
Z component of the momentum.
Double_t theta
Theta emission angle.
void SetMomentum(Double_t px, Double_t py, Double_t pz)
Sets the momentum.
Double_t mass
Particle mass.
Double_t Py
Y component of the momentum.
ClassImp(ActarSimPrimaryInfo) ActarSimPrimaryInfo
Constructor.
void Set4Momentum(Double_t px, Double_t py, Double_t pz, Double_t E)
Sets the 4momentum.
Int_t PDGcode
PDG code. Datamembers copied from G4PrimaryParticle.
Double_t polZ
Particle polarization along Z.
Double_t polX
Particle polarization along X.
void SetVertexPosition(Double_t x, Double_t y, Double_t z)
Sets the position of the vertex (origin of the primary particle)
Double_t polY
Particle polarization along Y.
Double_t phi
Phi emission angle.
UInt_t nbPrimariesInEvent
Number of primaries in the event.
void print(void)
Prints info.
~ActarSimPrimaryInfo()
Destructor. Makes nothing.
Double_t charge
Partcile charge.
void SetPolarization(Double_t px, Double_t py, Double_t pz)
Sets the polarization.
Double_t z0
Vertex position in X.