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

#include <G4PSCylinderSurfaceCurrent.hh>

+ Inheritance diagram for G4PSCylinderSurfaceCurrent:

Public Member Functions

 G4PSCylinderSurfaceCurrent (G4String name, G4int direction, G4int depth=0)
 
 G4PSCylinderSurfaceCurrent (G4String name, G4int direction, const G4String &unit, G4int depth=0)
 
 ~G4PSCylinderSurfaceCurrent () override=default
 
void Weighted (G4bool flg=true)
 
void DivideByArea (G4bool flg=true)
 
void Initialize (G4HCofThisEvent *) override
 
void clear () override
 
void PrintAll () override
 
virtual void SetUnit (const G4String &unit)
 
- Public Member Functions inherited from G4VPrimitivePlotter
 ~G4VPrimitivePlotter () override=default
 
void Plot (G4int copyNo, G4int histID)
 
G4int GetNumberOfHist () const
 
 G4VPrimitiveScorer (G4String name, G4int depth=0)
 
- 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
 
G4int IsSelectedSurface (G4Step *, G4Tubs *)
 
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 G4VPrimitivePlotter
std::map< G4int, G4inthitIDMap
 
- 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 60 of file G4PSCylinderSurfaceCurrent.hh.

Constructor & Destructor Documentation

◆ G4PSCylinderSurfaceCurrent() [1/2]

G4PSCylinderSurfaceCurrent::G4PSCylinderSurfaceCurrent ( G4String name,
G4int direction,
G4int depth = 0 )

Definition at line 59 of file G4PSCylinderSurfaceCurrent.cc.

62 : G4PSCylinderSurfaceCurrent(name, direction, "percm2", depth)
63{}
G4PSCylinderSurfaceCurrent(G4String name, G4int direction, G4int depth=0)

◆ G4PSCylinderSurfaceCurrent() [2/2]

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

Definition at line 65 of file G4PSCylinderSurfaceCurrent.cc.

69 : G4VPrimitivePlotter(name, depth)
70 , HCID(-1)
71 , fDirection(direction)
72 , EvtMap(nullptr)
73 , weighted(true)
74 , divideByArea(true)
75{
77 SetUnit(unit);
78}
virtual void SetUnit(const G4String &unit)

◆ ~G4PSCylinderSurfaceCurrent()

G4PSCylinderSurfaceCurrent::~G4PSCylinderSurfaceCurrent ( )
overridedefault

Member Function Documentation

◆ clear()

void G4PSCylinderSurfaceCurrent::clear ( )
overridevirtual

Reimplemented from G4VPrimitiveScorer.

Definition at line 190 of file G4PSCylinderSurfaceCurrent.cc.

190{ EvtMap->clear(); }

◆ DefineUnitAndCategory()

void G4PSCylinderSurfaceCurrent::DefineUnitAndCategory ( )
protectedvirtual

Definition at line 235 of file G4PSCylinderSurfaceCurrent.cc.

236{
237 // Per Unit Surface
238 new G4UnitDefinition("percentimeter2", "percm2", "Per Unit Surface",
239 (1. / cm2));
240 new G4UnitDefinition("permillimeter2", "permm2", "Per Unit Surface",
241 (1. / mm2));
242 new G4UnitDefinition("permeter2", "perm2", "Per Unit Surface", (1. / m2));
243}

Referenced by G4PSCylinderSurfaceCurrent().

◆ DivideByArea()

void G4PSCylinderSurfaceCurrent::DivideByArea ( G4bool flg = true)
inline

Definition at line 71 of file G4PSCylinderSurfaceCurrent.hh.

71{ divideByArea = flg; }

◆ Initialize()

void G4PSCylinderSurfaceCurrent::Initialize ( G4HCofThisEvent * HCE)
overridevirtual

Reimplemented from G4VPrimitiveScorer.

Definition at line 182 of file G4PSCylinderSurfaceCurrent.cc.

183{
184 EvtMap = new G4THitsMap<G4double>(detector->GetName(), GetName());
185 if(HCID < 0)
186 HCID = GetCollectionID(0);
187 HCE->AddHitsCollection(HCID, (G4VHitsCollection*) EvtMap);
188}
void AddHitsCollection(G4int HCID, G4VHitsCollection *aHC)
G4String GetName() const
G4MultiFunctionalDetector * detector

◆ IsSelectedSurface()

G4int G4PSCylinderSurfaceCurrent::IsSelectedSurface ( G4Step * aStep,
G4Tubs * tubsSolid )
protected

Definition at line 131 of file G4PSCylinderSurfaceCurrent.cc.

133{
134 G4TouchableHandle theTouchable =
138
140 {
141 // Entering Geometry
142 G4ThreeVector stppos1 = aStep->GetPreStepPoint()->GetPosition();
143 G4ThreeVector localpos1 =
144 theTouchable->GetHistory()->GetTopTransform().TransformPoint(stppos1);
145 if(std::fabs(localpos1.z()) > tubsSolid->GetZHalfLength())
146 return -1;
147 G4double localR2 =
148 localpos1.x() * localpos1.x() + localpos1.y() * localpos1.y();
149 G4double InsideRadius = tubsSolid->GetInnerRadius();
150 if(localR2 >
151 (InsideRadius - kCarTolerance) * (InsideRadius - kCarTolerance) &&
152 localR2 <
153 (InsideRadius + kCarTolerance) * (InsideRadius + kCarTolerance))
154 {
155 return fCurrent_In;
156 }
157 }
158
160 {
161 // Exiting Geometry
162 G4ThreeVector stppos2 = aStep->GetPostStepPoint()->GetPosition();
163 G4ThreeVector localpos2 =
164 theTouchable->GetHistory()->GetTopTransform().TransformPoint(stppos2);
165 if(std::fabs(localpos2.z()) > tubsSolid->GetZHalfLength())
166 return -1;
167 G4double localR2 =
168 localpos2.x() * localpos2.x() + localpos2.y() * localpos2.y();
169 G4double InsideRadius = tubsSolid->GetInnerRadius();
170 if(localR2 >
171 (InsideRadius - kCarTolerance) * (InsideRadius - kCarTolerance) &&
172 localR2 <
173 (InsideRadius + kCarTolerance) * (InsideRadius + kCarTolerance))
174 {
175 return fCurrent_Out;
176 }
177 }
178
179 return -1;
180}
const G4double kCarTolerance
@ fCurrent_Out
@ fCurrent_In
@ fGeomBoundary
double G4double
Definition G4Types.hh:83
double z() const
double x() const
double y() const
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
const G4AffineTransform & GetTopTransform() const
G4StepStatus GetStepStatus() const
const G4ThreeVector & GetPosition() const
const G4TouchableHandle & GetTouchableHandle() const
G4StepPoint * GetPreStepPoint() const
G4StepPoint * GetPostStepPoint() const
virtual const G4NavigationHistory * GetHistory() const
G4double GetZHalfLength() const
G4double GetInnerRadius() const

Referenced by ProcessHits().

◆ PrintAll()

void G4PSCylinderSurfaceCurrent::PrintAll ( )
overridevirtual

Reimplemented from G4VPrimitiveScorer.

Definition at line 192 of file G4PSCylinderSurfaceCurrent.cc.

193{
194 G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
195 G4cout << " PrimitiveScorer " << GetName() << G4endl;
196 G4cout << " Number of entries " << EvtMap->entries() << G4endl;
197 for(const auto& [copy, current] : *(EvtMap->GetMap()))
198 {
199 G4cout << " copy no.: " << copy << " current : ";
200 if(divideByArea)
201 {
202 G4cout << *(current) / GetUnitValue() << " [" << GetUnit() << "]";
203 }
204 else
205 {
206 G4cout << *(current) << " [tracks]";
207 }
208 G4cout << G4endl;
209 }
210}
#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 G4PSCylinderSurfaceCurrent::ProcessHits ( G4Step * aStep,
G4TouchableHistory *  )
overrideprotectedvirtual

Implements G4VPrimitiveScorer.

Definition at line 80 of file G4PSCylinderSurfaceCurrent.cc.

82{
83 G4StepPoint* preStep = aStep->GetPreStepPoint();
84 G4VSolid* solid = ComputeCurrentSolid(aStep);
85 auto tubsSolid = static_cast<G4Tubs*>(solid);
86
87 G4int dirFlag = IsSelectedSurface(aStep, tubsSolid);
88 // G4cout << " pos " << preStep->GetPosition() <<" dirFlag " << G4endl;
89 if(dirFlag > 0)
90 {
91 if(fDirection == fCurrent_InOut || fDirection == dirFlag)
92 {
93 G4TouchableHandle theTouchable = preStep->GetTouchableHandle();
94 //
95 G4double current = 1.0;
96 if(weighted)
97 current = preStep->GetWeight(); // Current (Particle Weight)
98 //
99 if(divideByArea)
100 {
101 G4double square = 2. * tubsSolid->GetZHalfLength() *
102 tubsSolid->GetInnerRadius() *
103 tubsSolid->GetDeltaPhiAngle() / radian;
104 current = current / square; // Current normalized by Area
105 }
106
107 G4int index = GetIndex(aStep);
108 EvtMap->add(index, current);
109
110 if(!hitIDMap.empty() && hitIDMap.find(index) != hitIDMap.cend())
111 {
112 auto filler = G4VScoreHistFiller::Instance();
113 if(filler == nullptr)
114 {
115 G4Exception("G4PSCylinderSurfaceCurrent::ProcessHits", "SCORER0123",
117 "G4TScoreHistFiller is not instantiated!! Histogram is "
118 "not filled.");
119 }
120 else
121 {
122 filler->FillH1(hitIDMap[index], preStep->GetKineticEnergy(), current);
123 }
124 }
125 }
126 }
127
128 return true;
129}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
@ fCurrent_InOut
int G4int
Definition G4Types.hh:85
G4int IsSelectedSurface(G4Step *, G4Tubs *)
G4double GetKineticEnergy() const
G4double GetWeight() const
std::map< G4int, G4int > hitIDMap
virtual G4int GetIndex(G4Step *)
G4VSolid * ComputeCurrentSolid(G4Step *aStep)
static G4VScoreHistFiller * Instance()
size_t add(const G4int &key, U *&aHit) const

◆ SetUnit()

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

Definition at line 212 of file G4PSCylinderSurfaceCurrent.cc.

213{
214 if(divideByArea)
215 {
216 CheckAndSetUnit(unit, "Per Unit Surface");
217 }
218 else
219 {
220 if(unit.empty())
221 {
222 unitName = unit;
223 unitValue = 1.0;
224 }
225 else
226 {
227 G4String msg = "Invalid unit [" + unit + "] (Current unit is [" +
228 GetUnit() + "] ) for " + GetName();
229 G4Exception("G4PSCylinderSurfaceCurrent::SetUnit", "DetPS0002",
230 JustWarning, msg);
231 }
232 }
233}
void CheckAndSetUnit(const G4String &unit, const G4String &category)

Referenced by G4PSCylinderSurfaceCurrent(), and G4PSCylinderSurfaceCurrent3D::G4PSCylinderSurfaceCurrent3D().

◆ Weighted()

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

Definition at line 68 of file G4PSCylinderSurfaceCurrent.hh.

68{ weighted = flg; }

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