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

#include <G4PSVolumeFlux.hh>

+ Inheritance diagram for G4PSVolumeFlux:

Public Member Functions

 G4PSVolumeFlux (G4String name, G4int direction=1, G4int depth=0)
 
virtual ~G4PSVolumeFlux ()
 
virtual void Initialize (G4HCofThisEvent *)
 
virtual void EndOfEvent (G4HCofThisEvent *)
 
virtual void clear ()
 
virtual void DrawAll ()
 
virtual void PrintAll ()
 
void SetDivAre (G4bool val)
 
void SetDivCos (G4bool val)
 
- Public Member Functions inherited from G4VPrimitivePlotter
 G4VPrimitivePlotter (G4String name, G4int depth=0)
 
virtual ~G4VPrimitivePlotter ()
 
void Plot (G4int copyNo, G4int histID)
 
G4int GetNumberOfHist () const
 
- Public Member Functions inherited from G4VPrimitiveScorer
 G4VPrimitiveScorer (G4String name, G4int depth=0)
 
virtual ~G4VPrimitiveScorer ()
 
G4int GetCollectionID (G4int)
 
virtual void Initialize (G4HCofThisEvent *)
 
virtual void EndOfEvent (G4HCofThisEvent *)
 
virtual void clear ()
 
virtual void DrawAll ()
 
virtual void PrintAll ()
 
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

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

Additional Inherited Members

- Protected Attributes inherited from G4VPrimitivePlotter
std::map< G4int, G4inthitIDMap
 
- Protected Attributes inherited from G4VPrimitiveScorer
G4String primitiveName
 
G4MultiFunctionalDetectordetector
 
G4VSDFilterfilter
 
G4int verboseLevel
 
G4int indexDepth
 
G4String unitName
 
G4double unitValue
 
G4int fNi
 
G4int fNj
 
G4int fNk
 

Detailed Description

Definition at line 43 of file G4PSVolumeFlux.hh.

Constructor & Destructor Documentation

◆ G4PSVolumeFlux()

G4PSVolumeFlux::G4PSVolumeFlux ( G4String  name,
G4int  direction = 1,
G4int  depth = 0 
)

Definition at line 49 of file G4PSVolumeFlux.cc.

50: G4VPrimitivePlotter(name,depth),HCID(-1),fDirection(direction),EvtMap(nullptr)
51{;}

◆ ~G4PSVolumeFlux()

G4PSVolumeFlux::~G4PSVolumeFlux ( )
virtual

Definition at line 53 of file G4PSVolumeFlux.cc.

54{;}

Member Function Documentation

◆ clear()

void G4PSVolumeFlux::clear ( )
virtual

Reimplemented from G4VPrimitiveScorer.

Definition at line 140 of file G4PSVolumeFlux.cc.

140 {
141 EvtMap->clear();
142}
void clear()
Definition: G4THitsMap.hh:537

◆ DrawAll()

void G4PSVolumeFlux::DrawAll ( )
virtual

Reimplemented from G4VPrimitiveScorer.

Definition at line 144 of file G4PSVolumeFlux.cc.

145{;}

◆ EndOfEvent()

void G4PSVolumeFlux::EndOfEvent ( G4HCofThisEvent )
virtual

Reimplemented from G4VPrimitiveScorer.

Definition at line 137 of file G4PSVolumeFlux.cc.

138{;}

◆ Initialize()

void G4PSVolumeFlux::Initialize ( G4HCofThisEvent HCE)
virtual

Reimplemented from G4VPrimitiveScorer.

Definition at line 130 of file G4PSVolumeFlux.cc.

131{
132 if ( HCID < 0 ) HCID = GetCollectionID(0);
134 HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
135}
void AddHitsCollection(G4int HCID, G4VHitsCollection *aHC)
G4String GetName() const
G4MultiFunctionalDetector * GetMultiFunctionalDetector() const
G4int GetCollectionID(G4int)

◆ PrintAll()

void G4PSVolumeFlux::PrintAll ( )
virtual

Reimplemented from G4VPrimitiveScorer.

Definition at line 147 of file G4PSVolumeFlux.cc.

148{
149 G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
150 G4cout << " PrimitiveScorer" << GetName() <<G4endl;
151 G4cout << " Number of entries " << EvtMap->entries() << G4endl;
152 std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
153 for(; itr != EvtMap->GetMap()->end(); itr++) {
154 G4cout << " copy no.: " << itr->first
155 << " flux : " << *(itr->second)
156 << G4endl;
157 }
158}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4MultiFunctionalDetector * detector
Map_t * GetMap() const
Definition: G4THitsMap.hh:151
size_t entries() const
Definition: G4THitsMap.hh:155

◆ ProcessHits()

G4bool G4PSVolumeFlux::ProcessHits ( G4Step aStep,
G4TouchableHistory  
)
protectedvirtual

Implements G4VPrimitiveScorer.

Definition at line 56 of file G4PSVolumeFlux.cc.

57{
58 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
59 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
60 G4StepPoint* thisStepPoint = nullptr;
61 if(fDirection==1) // Score only the inward particle
62 {
63 if(preStepPoint->GetStepStatus()==fGeomBoundary)
64 { thisStepPoint = preStepPoint; }
65 else
66 { return false; }
67 }
68 else if(fDirection==2) // Score only the outward particle
69 {
70 if(postStepPoint->GetStepStatus()==fGeomBoundary)
71 { thisStepPoint = postStepPoint; }
72 else
73 { return false; }
74 }
75
76 G4double flux = preStepPoint->GetWeight();
77
78 if(divare||divcos)
79 {
80 G4VPhysicalVolume* physVol = preStepPoint->GetPhysicalVolume();
81 G4VPVParameterisation* physParam = physVol->GetParameterisation();
82 G4VSolid * solid = nullptr;
83 if(physParam)
84 { // for parameterized volume
85 auto idx = ((G4TouchableHistory*)(preStepPoint->GetTouchable()))->GetReplicaNumber(indexDepth);
86 solid = physParam->ComputeSolid(idx, physVol);
87 solid->ComputeDimensions(physParam,idx,physVol);
88 }
89 else
90 { // for ordinary volume
91 solid = physVol->GetLogicalVolume()->GetSolid();
92 }
93
94 if(divare)
95 { flux /= solid->GetSurfaceArea(); }
96
97 if(divcos)
98 {
99 G4TouchableHandle theTouchable = thisStepPoint->GetTouchableHandle();
100 G4ThreeVector pdirection = thisStepPoint->GetMomentumDirection();
101 G4ThreeVector localdir = theTouchable->GetHistory()->GetTopTransform().TransformAxis(pdirection);
102 G4ThreeVector globalPos = thisStepPoint->GetPosition();
103 G4ThreeVector localPos = theTouchable->GetHistory()->GetTopTransform().TransformPoint(globalPos);
104 G4ThreeVector surfNormal = solid->SurfaceNormal(localPos);
105 G4double cosT = surfNormal.cosTheta(localdir);
106 if(cosT!=0.) flux /= std::abs(cosT);
107 }
108 }
109
110 G4int index = GetIndex(aStep);
111 EvtMap->add(index,flux);
112
113 if(hitIDMap.size()>0 && hitIDMap.find(index)!=hitIDMap.end())
114 {
115 auto filler = G4VScoreHistFiller::Instance();
116 if(!filler)
117 {
118 G4Exception("G4PSVolumeFlux::ProcessHits","SCORER0123",JustWarning,
119 "G4TScoreHistFiller is not instantiated!! Histogram is not filled.");
120 }
121 else
122 {
123 filler->FillH1(hitIDMap[index],thisStepPoint->GetKineticEnergy(),flux);
124 }
125 }
126
127 return true;
128}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
@ fGeomBoundary
Definition: G4StepStatus.hh:43
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
double cosTheta() const
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
G4ThreeVector TransformAxis(const G4ThreeVector &axis) const
G4VSolid * GetSolid() const
const G4AffineTransform & GetTopTransform() const
G4StepStatus GetStepStatus() const
const G4VTouchable * GetTouchable() const
const G4ThreeVector & GetPosition() const
const G4ThreeVector & GetMomentumDirection() const
const G4TouchableHandle & GetTouchableHandle() const
G4VPhysicalVolume * GetPhysicalVolume() const
G4double GetKineticEnergy() const
G4double GetWeight() const
G4StepPoint * GetPreStepPoint() const
G4StepPoint * GetPostStepPoint() const
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
G4LogicalVolume * GetLogicalVolume() const
virtual G4VPVParameterisation * GetParameterisation() const =0
std::map< G4int, G4int > hitIDMap
virtual G4int GetIndex(G4Step *)
static G4VScoreHistFiller * Instance()
virtual void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4VSolid.cc:125
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
virtual G4double GetSurfaceArea()
Definition: G4VSolid.cc:238
size_t add(const G4int &key, U *&aHit) const
Definition: G4THitsMap.hh:177
virtual const G4NavigationHistory * GetHistory() const
Definition: G4VTouchable.cc:83

◆ SetDivAre()

void G4PSVolumeFlux::SetDivAre ( G4bool  val)
inline

Definition at line 67 of file G4PSVolumeFlux.hh.

68 { divare = val; }

◆ SetDivCos()

void G4PSVolumeFlux::SetDivCos ( G4bool  val)
inline

Definition at line 69 of file G4PSVolumeFlux.hh.

70 { divcos = val; }

Referenced by G4ScoreQuantityMessenger::SetNewValue().


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