Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PSTrackLength Class Reference

#include <G4PSTrackLength.hh>

+ Inheritance diagram for G4PSTrackLength:

Public Member Functions

 G4PSTrackLength (G4String name, G4int depth=0)
 
 G4PSTrackLength (G4String name, const G4String &unit, G4int depth=0)
 
 ~G4PSTrackLength () override=default
 
void Weighted (G4bool flg=true)
 
void MultiplyKineticEnergy (G4bool flg=true)
 
void DivideByVelocity (G4bool flg=true)
 
void Initialize (G4HCofThisEvent *) override
 
void clear () override
 
void PrintAll () override
 
virtual void SetUnit (const G4String &unit)
 
- Public Member Functions inherited from G4VPrimitiveScorer
 G4VPrimitiveScorer (G4String name, G4int depth=0)
 
virtual ~G4VPrimitiveScorer ()=default
 
G4int GetCollectionID (G4int)
 
virtual void EndOfEvent (G4HCofThisEvent *)
 
virtual void DrawAll ()
 
void SetUnit (const G4String &unit)
 
const G4StringGetUnit () const
 
G4double GetUnitValue () const
 
void SetMultiFunctionalDetector (G4MultiFunctionalDetector *d)
 
G4MultiFunctionalDetectorGetMultiFunctionalDetector () const
 
G4String GetName () const
 
void SetFilter (G4VSDFilter *f)
 
G4VSDFilterGetFilter () const
 
void SetVerboseLevel (G4int vl)
 
G4int GetVerboseLevel () const
 
void SetNijk (G4int i, G4int j, G4int k)
 

Protected Member Functions

G4bool ProcessHits (G4Step *, G4TouchableHistory *) override
 
virtual void DefineUnitAndCategory ()
 
- Protected Member Functions inherited from G4VPrimitiveScorer
G4VSolidComputeSolid (G4Step *aStep, G4int replicaIdx)
 
G4VSolidComputeCurrentSolid (G4Step *aStep)
 
virtual G4int GetIndex (G4Step *)
 
void CheckAndSetUnit (const G4String &unit, const G4String &category)
 

Additional Inherited Members

- Protected Attributes inherited from G4VPrimitiveScorer
G4String primitiveName
 
G4MultiFunctionalDetectordetector {nullptr}
 
G4VSDFilterfilter {nullptr}
 
G4int verboseLevel {0}
 
G4int indexDepth
 
G4String unitName {"NoUnit"}
 
G4double unitValue {1.0}
 
G4int fNi {0}
 
G4int fNj {0}
 
G4int fNk {0}
 

Detailed Description

Definition at line 48 of file G4PSTrackLength.hh.

Constructor & Destructor Documentation

◆ G4PSTrackLength() [1/2]

G4PSTrackLength::G4PSTrackLength ( G4String name,
G4int depth = 0 )

Definition at line 43 of file G4PSTrackLength.cc.

44 : G4PSTrackLength(name, "mm", depth)
45{}
G4PSTrackLength(G4String name, G4int depth=0)

◆ G4PSTrackLength() [2/2]

G4PSTrackLength::G4PSTrackLength ( G4String name,
const G4String & unit,
G4int depth = 0 )

Definition at line 47 of file G4PSTrackLength.cc.

49 : G4VPrimitiveScorer(name, depth)
50 , HCID(-1)
51 , EvtMap(nullptr)
52 , weighted(false)
53 , multiplyKinE(false)
54 , divideByVelocity(false)
55{
57 SetUnit(unit);
58}
virtual void SetUnit(const G4String &unit)
virtual void DefineUnitAndCategory()
G4VPrimitiveScorer(G4String name, G4int depth=0)

◆ ~G4PSTrackLength()

G4PSTrackLength::~G4PSTrackLength ( )
overridedefault

Member Function Documentation

◆ clear()

void G4PSTrackLength::clear ( )
overridevirtual

Reimplemented from G4VPrimitiveScorer.

Definition at line 100 of file G4PSTrackLength.cc.

100{ EvtMap->clear(); }

◆ DefineUnitAndCategory()

void G4PSTrackLength::DefineUnitAndCategory ( )
protectedvirtual

Definition at line 183 of file G4PSTrackLength.cc.

184{
185 // EnergyFlux
186 new G4UnitDefinition("eV_second", "eV_s", "EnergyFlux", (eV * second));
187 new G4UnitDefinition("keV_second", "keV_s", "EnergyFlux", (keV * second));
188 new G4UnitDefinition("MeV_second", "MeV_s", "EnergyFlux", (MeV * second));
189 new G4UnitDefinition("eV_millisecond", "eV_ms", "EnergyFlux", (eV * ms));
190 new G4UnitDefinition("keV_millisecond", "keV_ms", "EnergyFlux", (keV * ms));
191 new G4UnitDefinition("MeV_millisecond", "MeV_ms", "EnergyFlux", (MeV * ms));
192 // EnergyFlow
193 new G4UnitDefinition("eV_millimeter", "eV_mm", "EnergyFlow", (eV * mm));
194 new G4UnitDefinition("keV_millimeter", "keV_mm", "EnergyFlow", (keV * mm));
195 new G4UnitDefinition("MeV_millimeter", "MeV_mm", "EnergyFlow", (MeV * mm));
196 new G4UnitDefinition("eV_centimeter", "eV_cm", "EnergyFlow", (eV * cm));
197 new G4UnitDefinition("keV_centimeter", "keV_cm", "EnergyFlow", (keV * cm));
198 new G4UnitDefinition("MeV_centimeter", "MeV_cm", "EnergyFlow", (MeV * cm));
199 new G4UnitDefinition("eV_meter", "eV_m", "EnergyFlow", (eV * m));
200 new G4UnitDefinition("keV_meter", "keV_m", "EnergyFlow", (keV * m));
201 new G4UnitDefinition("MeV_meter", "MeV_m", "EnergyFlow", (MeV * m));
202}

Referenced by G4PSTrackLength().

◆ DivideByVelocity()

void G4PSTrackLength::DivideByVelocity ( G4bool flg = true)

Definition at line 67 of file G4PSTrackLength.cc.

68{
69 divideByVelocity = flg;
70 // Default unit is set according to flags.
71 SetUnit("");
72}

◆ Initialize()

void G4PSTrackLength::Initialize ( G4HCofThisEvent * HCE)
overridevirtual

Reimplemented from G4VPrimitiveScorer.

Definition at line 90 of file G4PSTrackLength.cc.

91{
92 EvtMap = new G4THitsMap<G4double>(detector->GetName(), GetName());
93 if(HCID < 0)
94 {
95 HCID = GetCollectionID(0);
96 }
97 HCE->AddHitsCollection(HCID, (G4VHitsCollection*) EvtMap);
98}
void AddHitsCollection(G4int HCID, G4VHitsCollection *aHC)
G4String GetName() const
G4MultiFunctionalDetector * detector

◆ MultiplyKineticEnergy()

void G4PSTrackLength::MultiplyKineticEnergy ( G4bool flg = true)

Definition at line 60 of file G4PSTrackLength.cc.

61{
62 multiplyKinE = flg;
63 // Default unit is set according to flags.
64 SetUnit("");
65}

◆ PrintAll()

void G4PSTrackLength::PrintAll ( )
overridevirtual

Reimplemented from G4VPrimitiveScorer.

Definition at line 102 of file G4PSTrackLength.cc.

103{
104 G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
105 G4cout << " PrimitiveScorer " << GetName() << G4endl;
106 G4cout << " Number of entries " << EvtMap->entries() << G4endl;
107 for(const auto& [copy, length] : *(EvtMap->GetMap()))
108 {
109 G4cout << " copy no.: " << copy;
110 if(multiplyKinE)
111 {
112 if(divideByVelocity)
113 G4cout << " EnergyFlux: ";
114 else
115 G4cout << " EnergyFlow: ";
116 }
117 else
118 {
119 if(divideByVelocity)
120 G4cout << " Time: ";
121 else
122 G4cout << " Length: ";
123 }
124 G4cout << *(length) / GetUnitValue() << " [" << GetUnit() << "]";
125 G4cout << G4endl;
126 }
127}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
const G4String & GetUnit() const
G4double GetUnitValue() const
Map_t * GetMap() const
size_t entries() const
void copy(G4double dst[], const G4double src[], std::size_t size=G4FieldTrack::ncompSVEC)

◆ ProcessHits()

G4bool G4PSTrackLength::ProcessHits ( G4Step * aStep,
G4TouchableHistory *  )
overrideprotectedvirtual

Implements G4VPrimitiveScorer.

Definition at line 74 of file G4PSTrackLength.cc.

75{
76 G4double trklength = aStep->GetStepLength();
77 if(trklength == 0.)
78 return false;
79 if(weighted)
80 trklength *= aStep->GetPreStepPoint()->GetWeight();
81 if(multiplyKinE)
82 trklength *= aStep->GetPreStepPoint()->GetKineticEnergy();
83 if(divideByVelocity)
84 trklength /= aStep->GetPreStepPoint()->GetVelocity();
85 G4int index = GetIndex(aStep);
86 EvtMap->add(index, trklength);
87 return true;
88}
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
G4double GetVelocity() const
G4double GetKineticEnergy() const
G4double GetWeight() const
G4StepPoint * GetPreStepPoint() const
G4double GetStepLength() const
virtual G4int GetIndex(G4Step *)
size_t add(const G4int &key, U *&aHit) const

◆ SetUnit()

void G4PSTrackLength::SetUnit ( const G4String & unit)
virtual

Definition at line 129 of file G4PSTrackLength.cc.

130{
131 if(multiplyKinE)
132 {
133 if(divideByVelocity)
134 {
135 if(unit.empty())
136 {
137 CheckAndSetUnit("MeV_second", "EnergyFlux");
138 }
139 else
140 {
141 CheckAndSetUnit(unit, "EnergyFlux");
142 }
143 }
144 else
145 {
146 if(unit.empty())
147 {
148 CheckAndSetUnit("MeV_mm", "EnergyFlow");
149 }
150 else
151 {
152 CheckAndSetUnit(unit, "EnergyFlow");
153 }
154 }
155 }
156 else
157 {
158 if(divideByVelocity)
159 {
160 if(unit.empty())
161 {
162 CheckAndSetUnit("second", "Time");
163 }
164 else
165 {
166 CheckAndSetUnit(unit, "Time");
167 }
168 }
169 else
170 {
171 if(unit.empty())
172 {
173 CheckAndSetUnit("mm", "Length");
174 }
175 else
176 {
177 CheckAndSetUnit(unit, "Length");
178 }
179 }
180 }
181}
void CheckAndSetUnit(const G4String &unit, const G4String &category)

Referenced by DivideByVelocity(), G4PSTrackLength(), G4PSTrackLength3D::G4PSTrackLength3D(), and MultiplyKineticEnergy().

◆ Weighted()

void G4PSTrackLength::Weighted ( G4bool flg = true)
inline

Definition at line 55 of file G4PSTrackLength.hh.

55{ weighted = flg; }

Referenced by G4ScoreQuantityMessenger::SetNewValue().


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