Geant4-11
Public Types | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes
G4RTRun Class Reference

#include <G4RTRun.hh>

Inheritance diagram for G4RTRun:
G4Run

Public Types

using ProfilerConfig = G4ProfilerConfig< G4ProfileType::Run >
 

Public Member Functions

 G4RTRun ()
 
const G4DCtableGetDCtable () const
 
const std::vector< const G4Event * > * GetEventVector () const
 
const G4HCtableGetHCtable () const
 
G4THitsMap< G4Colour > * GetMap () const
 
G4int GetNumberOfEvent () const
 
G4int GetNumberOfEventToBeProcessed () const
 
const G4StringGetRandomNumberStatus () const
 
G4int GetRunID () const
 
virtual void Merge (const G4Run *)
 
virtual void RecordEvent (const G4Event *)
 
void SetDCtable (G4DCtable *DCtbl)
 
void SetHCtable (G4HCtable *HCtbl)
 
void SetNumberOfEventToBeProcessed (G4int n_ev)
 
void SetRandomNumberStatus (G4String &st)
 
void SetRunID (G4int id)
 
void StoreEvent (G4Event *evt)
 
virtual ~G4RTRun ()
 

Protected Attributes

G4DCtableDCtable = nullptr
 
std::vector< const G4Event * > * eventVector = nullptr
 
G4HCtableHCtable = nullptr
 
G4int numberOfEvent = 0
 
G4int numberOfEventToBeProcessed = 0
 
G4String randomNumberStatus = ""
 
G4int runID = 0
 

Private Member Functions

G4Colour Attenuate (G4RayTrajectoryPoint *, G4Colour)
 
G4Colour GetMixedColour (G4Colour, G4Colour, G4double)
 
G4Colour GetSurfaceColour (G4RayTrajectoryPoint *)
 
G4bool ValidColour (const G4VisAttributes *)
 

Private Attributes

G4double attenuationLength
 
G4Colour backgroundColour
 
G4THitsMap< G4Colour > * colorMap
 
G4ThreeVector lightDirection
 

Detailed Description

Definition at line 50 of file G4RTRun.hh.

Member Typedef Documentation

◆ ProfilerConfig

Definition at line 52 of file G4Run.hh.

Constructor & Destructor Documentation

◆ G4RTRun()

G4RTRun::G4RTRun ( )

◆ ~G4RTRun()

G4RTRun::~G4RTRun ( )
virtual

Definition at line 55 of file G4RTRun.cc.

56{
57 colorMap->clear();
58 delete colorMap;
59}
void clear()
Definition: G4THitsMap.hh:524

References G4VTHitsMap< T, Map_t >::clear(), and colorMap.

Member Function Documentation

◆ Attenuate()

G4Colour G4RTRun::Attenuate ( G4RayTrajectoryPoint point,
G4Colour  sourceCol 
)
private

Definition at line 152 of file G4RTRun.cc.

153{
154 const G4VisAttributes* preAtt = point->GetPreStepAtt();
155
156 G4bool visible = ValidColour(preAtt);
157 if(!visible) return sourceCol;
158
159 G4Colour objCol = preAtt->GetColour();
160 G4double stepRed = objCol.GetRed();
161 G4double stepGreen = objCol.GetGreen();
162 G4double stepBlue = objCol.GetBlue();
163 G4double stepAlpha = objCol.GetAlpha();
164 G4double stepLength = point->GetStepLength();
165
166 G4double attenuationFuctor;
167 if(stepAlpha > 0.9999999){ stepAlpha = 0.9999999; } // patch to the next line
168 attenuationFuctor = -stepAlpha/(1.0-stepAlpha)*stepLength/attenuationLength;
169
170 G4double KtRed = std::exp((1.0-stepRed)*attenuationFuctor);
171 G4double KtGreen = std::exp((1.0-stepGreen)*attenuationFuctor);
172 G4double KtBlue = std::exp((1.0-stepBlue)*attenuationFuctor);
173 if(KtRed>1.0){KtRed=1.0;}
174 if(KtGreen>1.0){KtGreen=1.0;}
175 if(KtBlue>1.0){KtBlue=1.0;}
176 return G4Colour(sourceCol.GetRed()*KtRed,
177 sourceCol.GetGreen()*KtGreen,sourceCol.GetBlue()*KtBlue);
178}
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
G4double GetBlue() const
Definition: G4Colour.hh:154
G4double GetAlpha() const
Definition: G4Colour.hh:155
G4double GetRed() const
Definition: G4Colour.hh:152
G4double GetGreen() const
Definition: G4Colour.hh:153
G4bool ValidColour(const G4VisAttributes *)
Definition: G4RTRun.cc:180
G4double GetStepLength() const
const G4VisAttributes * GetPreStepAtt() const
const G4Colour & GetColour() const

References attenuationLength, G4Colour::GetAlpha(), G4Colour::GetBlue(), G4VisAttributes::GetColour(), G4Colour::GetGreen(), G4RayTrajectoryPoint::GetPreStepAtt(), G4Colour::GetRed(), G4RayTrajectoryPoint::GetStepLength(), and ValidColour().

Referenced by RecordEvent().

◆ GetDCtable()

const G4DCtable * G4Run::GetDCtable ( ) const
inlineinherited

Definition at line 89 of file G4Run.hh.

89{ return DCtable; }
G4DCtable * DCtable
Definition: G4Run.hh:117

References G4Run::DCtable.

◆ GetEventVector()

const std::vector< const G4Event * > * G4Run::GetEventVector ( ) const
inlineinherited

Definition at line 96 of file G4Run.hh.

97 {
98 return eventVector;
99 }
std::vector< const G4Event * > * eventVector
Definition: G4Run.hh:119

References G4Run::eventVector.

Referenced by G4VisManager::EndOfEvent(), G4VisManager::EndOfRun(), G4VisCommandSceneAddEventID::EventID::operator()(), and G4VisCommandSceneEndOfEventAction::SetNewValue().

◆ GetHCtable()

const G4HCtable * G4Run::GetHCtable ( ) const
inlineinherited

Definition at line 87 of file G4Run.hh.

87{ return HCtable; }
G4HCtable * HCtable
Definition: G4Run.hh:116

References G4Run::HCtable.

◆ GetMap()

G4THitsMap< G4Colour > * G4RTRun::GetMap ( ) const
inline

Definition at line 63 of file G4RTRun.hh.

63{ return colorMap; }

References colorMap.

Referenced by G4TheMTRayTracer::CreateBitMap().

◆ GetMixedColour()

G4Colour G4RTRun::GetMixedColour ( G4Colour  surfCol,
G4Colour  transCol,
G4double  weight 
)
private

Definition at line 143 of file G4RTRun.cc.

144{
145 G4double red = weight*surfCol.GetRed() + (1.-weight)*transCol.GetRed();
146 G4double green = weight*surfCol.GetGreen() + (1.-weight)*transCol.GetGreen();
147 G4double blue = weight*surfCol.GetBlue() + (1.-weight)*transCol.GetBlue();
148 G4double alpha = weight*surfCol.GetAlpha() + (1.-weight)*transCol.GetAlpha();
149 return G4Colour(red,green,blue,alpha);
150}
static const G4double alpha

References alpha, G4Colour::GetAlpha(), G4Colour::GetBlue(), G4Colour::GetGreen(), and G4Colour::GetRed().

Referenced by GetSurfaceColour(), and RecordEvent().

◆ GetNumberOfEvent()

G4int G4Run::GetNumberOfEvent ( ) const
inlineinherited

Definition at line 80 of file G4Run.hh.

80{ return numberOfEvent; }
G4int numberOfEvent
Definition: G4Run.hh:114

References G4Run::numberOfEvent.

Referenced by export_G4Run().

◆ GetNumberOfEventToBeProcessed()

G4int G4Run::GetNumberOfEventToBeProcessed ( ) const
inlineinherited

Definition at line 83 of file G4Run.hh.

84 {
86 }
G4int numberOfEventToBeProcessed
Definition: G4Run.hh:115

References G4Run::numberOfEventToBeProcessed.

Referenced by export_G4Run(), and G4VisCommandSceneAddEventID::EventID::operator()().

◆ GetRandomNumberStatus()

const G4String & G4Run::GetRandomNumberStatus ( ) const
inlineinherited

Definition at line 91 of file G4Run.hh.

92 {
93 return randomNumberStatus;
94 }
G4String randomNumberStatus
Definition: G4Run.hh:118

References G4Run::randomNumberStatus.

◆ GetRunID()

G4int G4Run::GetRunID ( ) const
inlineinherited

◆ GetSurfaceColour()

G4Colour G4RTRun::GetSurfaceColour ( G4RayTrajectoryPoint point)
private

Definition at line 95 of file G4RTRun.cc.

96{
97 const G4VisAttributes* preAtt = point->GetPreStepAtt();
98 const G4VisAttributes* postAtt = point->GetPostStepAtt();
99
100 G4bool preVis = ValidColour(preAtt);
101 G4bool postVis = ValidColour(postAtt);
102
103 G4Colour transparent(1.,1.,1.,0.);
104
105 if(!preVis&&!postVis) return transparent;
106
108
109 G4Colour preCol(1.,1.,1.);
110 G4Colour postCol(1.,1.,1.);
111
112 if(preVis)
113 {
114 G4double brill = (1.0-(-lightDirection).dot(normal))/2.0;
115 G4double red = preAtt->GetColour().GetRed();
116 G4double green = preAtt->GetColour().GetGreen();
117 G4double blue = preAtt->GetColour().GetBlue();
118 preCol = G4Colour
119 (red*brill,green*brill,blue*brill,preAtt->GetColour().GetAlpha());
120 }
121 else
122 { preCol = transparent; }
123
124 if(postVis)
125 {
126 G4double brill = (1.0-(-lightDirection).dot(-normal))/2.0;
127 G4double red = postAtt->GetColour().GetRed();
128 G4double green = postAtt->GetColour().GetGreen();
129 G4double blue = postAtt->GetColour().GetBlue();
130 postCol = G4Colour
131 (red*brill,green*brill,blue*brill,postAtt->GetColour().GetAlpha());
132 }
133 else
134 { postCol = transparent; }
135
136 if(!preVis) return postCol;
137 if(!postVis) return preCol;
138
139 G4double weight = 0.5;
140 return GetMixedColour(preCol,postCol,weight);
141}
G4Colour GetMixedColour(G4Colour, G4Colour, G4double)
Definition: G4RTRun.cc:143
G4ThreeVector GetSurfaceNormal() const
const G4VisAttributes * GetPostStepAtt() const
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:79

References G4Colour::GetAlpha(), G4Colour::GetBlue(), G4VisAttributes::GetColour(), G4Colour::GetGreen(), GetMixedColour(), G4RayTrajectoryPoint::GetPostStepAtt(), G4RayTrajectoryPoint::GetPreStepAtt(), G4Colour::GetRed(), G4RayTrajectoryPoint::GetSurfaceNormal(), lightDirection, CLHEP::normal(), and ValidColour().

Referenced by RecordEvent().

◆ Merge()

void G4RTRun::Merge ( const G4Run aLocalRun)
virtual

Reimplemented from G4Run.

Definition at line 88 of file G4RTRun.cc.

89{
90 const G4RTRun* theLocalRun = static_cast<const G4RTRun*>(aLocalRun);
91 if(theLocalRun) *(colorMap) += *(theLocalRun->colorMap);
92 G4Run::Merge(aLocalRun);
93}
virtual void Merge(const G4Run *)
Definition: G4Run.cc:67

References colorMap, and G4Run::Merge().

◆ RecordEvent()

void G4RTRun::RecordEvent ( const G4Event evt)
virtual

Reimplemented from G4Run.

Definition at line 61 of file G4RTRun.cc.

62{
63 G4TrajectoryContainer * trajectoryContainer = evt->GetTrajectoryContainer();
64 if(!trajectoryContainer) return;
65 G4RayTrajectory* trajectory = static_cast<G4RayTrajectory*>( (*trajectoryContainer)[0] );
66 if(!trajectory) return;
67
68 G4int nPoint = trajectory->GetPointEntries();
69 if(nPoint==0) return;
70
71 G4int evId = evt->GetEventID();
72 G4Colour initialCol(backgroundColour);
73 if( trajectory->GetPointC(nPoint-1)->GetPostStepAtt() )
74 { initialCol = GetSurfaceColour(trajectory->GetPointC(nPoint-1)); }
75 G4Colour rayColour = Attenuate(trajectory->GetPointC(nPoint-1),initialCol);
76
77 for(int i=nPoint-2;i>=0;i--)
78 {
79 G4Colour surfaceCol = GetSurfaceColour(trajectory->GetPointC(i));
80 G4double weight = 1.0 - surfaceCol.GetAlpha();
81 G4Colour mixedCol = GetMixedColour(rayColour,surfaceCol,weight);
82 rayColour = Attenuate(trajectory->GetPointC(i),mixedCol);
83 }
84
85 colorMap->add(evId,rayColour);
86}
int G4int
Definition: G4Types.hh:85
G4TrajectoryContainer * GetTrajectoryContainer() const
Definition: G4Event.hh:160
G4int GetEventID() const
Definition: G4Event.hh:118
G4Colour GetSurfaceColour(G4RayTrajectoryPoint *)
Definition: G4RTRun.cc:95
G4Colour Attenuate(G4RayTrajectoryPoint *, G4Colour)
Definition: G4RTRun.cc:152
virtual int GetPointEntries() const
G4RayTrajectoryPoint * GetPointC(G4int i) const
size_t add(const G4int &key, U *&aHit) const
Definition: G4THitsMap.hh:177

References G4VTHitsMap< T, Map_t >::add(), Attenuate(), backgroundColour, colorMap, G4Colour::GetAlpha(), G4Event::GetEventID(), GetMixedColour(), G4RayTrajectory::GetPointC(), G4RayTrajectory::GetPointEntries(), G4RayTrajectoryPoint::GetPostStepAtt(), GetSurfaceColour(), and G4Event::GetTrajectoryContainer().

◆ SetDCtable()

void G4Run::SetDCtable ( G4DCtable DCtbl)
inlineinherited

◆ SetHCtable()

void G4Run::SetHCtable ( G4HCtable HCtbl)
inlineinherited

◆ SetNumberOfEventToBeProcessed()

void G4Run::SetNumberOfEventToBeProcessed ( G4int  n_ev)
inlineinherited

◆ SetRandomNumberStatus()

void G4Run::SetRandomNumberStatus ( G4String st)
inlineinherited

◆ SetRunID()

void G4Run::SetRunID ( G4int  id)
inlineinherited

◆ StoreEvent()

void G4Run::StoreEvent ( G4Event evt)
inherited

Definition at line 78 of file G4Run.cc.

79{
80 eventVector->push_back(evt);
81}

References G4Run::eventVector.

Referenced by G4RunManager::StackPreviousEvent().

◆ ValidColour()

G4bool G4RTRun::ValidColour ( const G4VisAttributes visAtt)
private

Definition at line 180 of file G4RTRun.cc.

181{
182 G4bool val = true;
183 if(!visAtt)
184 { val = false; }
185 else if(!(visAtt->IsVisible()))
186 { val = false; }
187 else if(visAtt->IsForceDrawingStyle()
189 { val = false; }
190 return val;
191}
G4bool IsVisible() const
ForcedDrawingStyle GetForcedDrawingStyle() const
G4bool IsForceDrawingStyle() const

References G4VisAttributes::GetForcedDrawingStyle(), G4VisAttributes::IsForceDrawingStyle(), G4VisAttributes::IsVisible(), and G4VisAttributes::wireframe.

Referenced by Attenuate(), and GetSurfaceColour().

Field Documentation

◆ attenuationLength

G4double G4RTRun::attenuationLength
private

Definition at line 68 of file G4RTRun.hh.

Referenced by Attenuate(), and G4RTRun().

◆ backgroundColour

G4Colour G4RTRun::backgroundColour
private

Definition at line 66 of file G4RTRun.hh.

Referenced by G4RTRun(), and RecordEvent().

◆ colorMap

G4THitsMap<G4Colour>* G4RTRun::colorMap
private

Definition at line 60 of file G4RTRun.hh.

Referenced by G4RTRun(), GetMap(), Merge(), RecordEvent(), and ~G4RTRun().

◆ DCtable

G4DCtable* G4Run::DCtable = nullptr
protectedinherited

Definition at line 117 of file G4Run.hh.

Referenced by G4Run::GetDCtable(), and G4Run::SetDCtable().

◆ eventVector

std::vector<const G4Event*>* G4Run::eventVector = nullptr
protectedinherited

◆ HCtable

G4HCtable* G4Run::HCtable = nullptr
protectedinherited

Definition at line 116 of file G4Run.hh.

Referenced by G4Run::GetHCtable(), and G4Run::SetHCtable().

◆ lightDirection

G4ThreeVector G4RTRun::lightDirection
private

Definition at line 67 of file G4RTRun.hh.

Referenced by G4RTRun(), and GetSurfaceColour().

◆ numberOfEvent

G4int G4Run::numberOfEvent = 0
protectedinherited

Definition at line 114 of file G4Run.hh.

Referenced by G4Run::GetNumberOfEvent(), G4Run::Merge(), and G4Run::RecordEvent().

◆ numberOfEventToBeProcessed

G4int G4Run::numberOfEventToBeProcessed = 0
protectedinherited

◆ randomNumberStatus

G4String G4Run::randomNumberStatus = ""
protectedinherited

Definition at line 118 of file G4Run.hh.

Referenced by G4Run::GetRandomNumberStatus(), and G4Run::SetRandomNumberStatus().

◆ runID

G4int G4Run::runID = 0
protectedinherited

Definition at line 113 of file G4Run.hh.

Referenced by G4Run::GetRunID(), and G4Run::SetRunID().


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