Geant4  10.02.p03
G4RTRun Class Reference

#include <G4RTRun.hh>

Inheritance diagram for G4RTRun:
Collaboration diagram for G4RTRun:

Public Member Functions

 G4RTRun ()
 
virtual ~G4RTRun ()
 
virtual void RecordEvent (const G4Event *)
 
virtual void Merge (const G4Run *)
 
G4THitsMap< G4Colour > * GetMap () const
 
- Public Member Functions inherited from G4Run
 G4Run ()
 
virtual ~G4Run ()
 
G4int GetRunID () const
 
G4int GetNumberOfEvent () const
 
G4int GetNumberOfEventToBeProcessed () const
 
const G4HCtable * GetHCtable () const
 
const G4DCtable * GetDCtable () const
 
const G4String & GetRandomNumberStatus () const
 
void SetRunID (G4int id)
 
void SetNumberOfEventToBeProcessed (G4int n_ev)
 
void SetHCtable (G4HCtable *HCtbl)
 
void SetDCtable (G4DCtable *DCtbl)
 
void SetRandomNumberStatus (G4String &st)
 
void StoreEvent (G4Event *evt)
 
const std::vector< const G4Event * > * GetEventVector () const
 

Private Member Functions

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

Private Attributes

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

Additional Inherited Members

- Protected Attributes inherited from G4Run
G4int runID
 
G4int numberOfEvent
 
G4int numberOfEventToBeProcessed
 
G4HCtable * HCtable
 
G4DCtable * DCtable
 
G4String randomNumberStatus
 
std::vector< const G4Event * > * eventVector
 

Detailed Description

Definition at line 51 of file G4RTRun.hh.

Constructor & Destructor Documentation

◆ G4RTRun()

G4RTRun::G4RTRun ( )

Definition at line 48 of file G4RTRun.cc.

49 {
50  colorMap = new G4THitsMap<G4Colour>("G4RTRun","ColorMap");
51 
55 }
G4THitsMap< G4Colour > * colorMap
Definition: G4RTRun.hh:61
G4ThreeVector lightDirection
G4ThreeVector lightDirection
Definition: G4RTRun.hh:68
G4Colour backgroundColour
Definition: G4RTRun.hh:67
G4double attenuationLength
Definition: G4RTRun.hh:69
static G4TheMTRayTracer * theInstance
G4Colour backgroundColour
G4double attenuationLength

◆ ~G4RTRun()

G4RTRun::~G4RTRun ( )
virtual

Definition at line 57 of file G4RTRun.cc.

58 {
59  colorMap->clear();
60  delete colorMap;
61 }
void clear()
Definition: G4THitsMap.hh:209
G4THitsMap< G4Colour > * colorMap
Definition: G4RTRun.hh:61
Here is the call graph for this function:

Member Function Documentation

◆ Attenuate()

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

Definition at line 154 of file G4RTRun.cc.

155 {
156  const G4VisAttributes* preAtt = point->GetPreStepAtt();
157 
158  G4bool visible = ValidColour(preAtt);
159  if(!visible) return sourceCol;
160 
161  G4Colour objCol = preAtt->GetColour();
162  G4double stepRed = objCol.GetRed();
163  G4double stepGreen = objCol.GetGreen();
164  G4double stepBlue = objCol.GetBlue();
165  G4double stepAlpha = objCol.GetAlpha();
166  G4double stepLength = point->GetStepLength();
167 
168  G4double attenuationFuctor;
169  if(stepAlpha > 0.9999999){ stepAlpha = 0.9999999; } // patch to the next line
170  attenuationFuctor = -stepAlpha/(1.0-stepAlpha)*stepLength/attenuationLength;
171 
172  G4double KtRed = std::exp((1.0-stepRed)*attenuationFuctor);
173  G4double KtGreen = std::exp((1.0-stepGreen)*attenuationFuctor);
174  G4double KtBlue = std::exp((1.0-stepBlue)*attenuationFuctor);
175  if(KtRed>1.0){KtRed=1.0;}
176  if(KtGreen>1.0){KtGreen=1.0;}
177  if(KtBlue>1.0){KtBlue=1.0;}
178  return G4Colour(sourceCol.GetRed()*KtRed,
179  sourceCol.GetGreen()*KtGreen,sourceCol.GetBlue()*KtBlue);
180 }
G4double GetAlpha() const
Definition: G4Colour.hh:142
const G4VisAttributes * GetPreStepAtt() const
G4double GetGreen() const
Definition: G4Colour.hh:140
G4double GetRed() const
Definition: G4Colour.hh:139
G4bool ValidColour(const G4VisAttributes *)
Definition: G4RTRun.cc:182
G4double GetBlue() const
Definition: G4Colour.hh:141
bool G4bool
Definition: G4Types.hh:79
G4double GetStepLength() const
G4double attenuationLength
Definition: G4RTRun.hh:69
double G4double
Definition: G4Types.hh:76
const G4Colour & GetColour() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMap()

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

Definition at line 64 of file G4RTRun.hh.

64 { return colorMap; }
G4THitsMap< G4Colour > * colorMap
Definition: G4RTRun.hh:61
Here is the caller graph for this function:

◆ GetMixedColour()

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

Definition at line 145 of file G4RTRun.cc.

146 {
147  G4double red = weight*surfCol.GetRed() + (1.-weight)*transCol.GetRed();
148  G4double green = weight*surfCol.GetGreen() + (1.-weight)*transCol.GetGreen();
149  G4double blue = weight*surfCol.GetBlue() + (1.-weight)*transCol.GetBlue();
150  G4double alpha = weight*surfCol.GetAlpha() + (1.-weight)*transCol.GetAlpha();
151  return G4Colour(red,green,blue,alpha);
152 }
Definition: test07.cc:36
G4double GetAlpha() const
Definition: G4Colour.hh:142
G4double GetGreen() const
Definition: G4Colour.hh:140
double weight
Definition: plottest35.C:25
Definition: test07.cc:36
G4double GetRed() const
Definition: G4Colour.hh:139
G4double GetBlue() const
Definition: G4Colour.hh:141
double G4double
Definition: G4Types.hh:76
static const G4double alpha
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSurfaceColour()

G4Colour G4RTRun::GetSurfaceColour ( G4RayTrajectoryPoint *  point)
private

Definition at line 97 of file G4RTRun.cc.

98 {
99  const G4VisAttributes* preAtt = point->GetPreStepAtt();
100  const G4VisAttributes* postAtt = point->GetPostStepAtt();
101 
102  G4bool preVis = ValidColour(preAtt);
103  G4bool postVis = ValidColour(postAtt);
104 
105  G4Colour transparent(1.,1.,1.,0.);
106 
107  if(!preVis&&!postVis) return transparent;
108 
110 
111  G4Colour preCol(1.,1.,1.);
112  G4Colour postCol(1.,1.,1.);
113 
114  if(preVis)
115  {
116  G4double brill = (1.0-(-lightDirection).dot(normal))/2.0;
117  G4double red = preAtt->GetColour().GetRed();
118  G4double green = preAtt->GetColour().GetGreen();
119  G4double blue = preAtt->GetColour().GetBlue();
120  preCol = G4Colour
121  (red*brill,green*brill,blue*brill,preAtt->GetColour().GetAlpha());
122  }
123  else
124  { preCol = transparent; }
125 
126  if(postVis)
127  {
128  G4double brill = (1.0-(-lightDirection).dot(-normal))/2.0;
129  G4double red = postAtt->GetColour().GetRed();
130  G4double green = postAtt->GetColour().GetGreen();
131  G4double blue = postAtt->GetColour().GetBlue();
132  postCol = G4Colour
133  (red*brill,green*brill,blue*brill,postAtt->GetColour().GetAlpha());
134  }
135  else
136  { postCol = transparent; }
137 
138  if(!preVis) return postCol;
139  if(!postVis) return preCol;
140 
141  G4double weight = 0.5;
142  return GetMixedColour(preCol,postCol,weight);
143 }
G4ThreeVector GetSurfaceNormal() const
Definition: test07.cc:36
G4double GetAlpha() const
Definition: G4Colour.hh:142
const G4VisAttributes * GetPreStepAtt() const
G4double GetGreen() const
Definition: G4Colour.hh:140
double weight
Definition: plottest35.C:25
Definition: test07.cc:36
G4Colour GetMixedColour(G4Colour, G4Colour, G4double)
Definition: G4RTRun.cc:145
G4double GetRed() const
Definition: G4Colour.hh:139
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:77
G4ThreeVector lightDirection
Definition: G4RTRun.hh:68
G4bool ValidColour(const G4VisAttributes *)
Definition: G4RTRun.cc:182
G4double GetBlue() const
Definition: G4Colour.hh:141
bool G4bool
Definition: G4Types.hh:79
const G4VisAttributes * GetPostStepAtt() const
double G4double
Definition: G4Types.hh:76
const G4Colour & GetColour() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Merge()

void G4RTRun::Merge ( const G4Run *  aLocalRun)
virtual

Reimplemented from G4Run.

Definition at line 90 of file G4RTRun.cc.

91 {
92  const G4RTRun* theLocalRun = static_cast<const G4RTRun*>(aLocalRun);
93  if(theLocalRun) *(colorMap) += *(theLocalRun->colorMap);
94  G4Run::Merge(aLocalRun);
95 }
virtual void Merge(const G4Run *)
Definition: G4Run.cc:54
G4THitsMap< G4Colour > * colorMap
Definition: G4RTRun.hh:61
Here is the call graph for this function:

◆ RecordEvent()

void G4RTRun::RecordEvent ( const G4Event *  evt)
virtual

Reimplemented from G4Run.

Definition at line 63 of file G4RTRun.cc.

64 {
65  G4TrajectoryContainer * trajectoryContainer = evt->GetTrajectoryContainer();
66  if(!trajectoryContainer) return;
67  G4RayTrajectory* trajectory = static_cast<G4RayTrajectory*>( (*trajectoryContainer)[0] );
68  if(!trajectory) return;
69 
70  G4int nPoint = trajectory->GetPointEntries();
71  if(nPoint==0) return;
72 
73  G4int evId = evt->GetEventID();
74  G4Colour initialCol(backgroundColour);
75  if( trajectory->GetPointC(nPoint-1)->GetPostStepAtt() )
76  { initialCol = GetSurfaceColour(trajectory->GetPointC(nPoint-1)); }
77  G4Colour rayColour = Attenuate(trajectory->GetPointC(nPoint-1),initialCol);
78 
79  for(int i=nPoint-2;i>=0;i--)
80  {
81  G4Colour surfaceCol = GetSurfaceColour(trajectory->GetPointC(i));
82  G4double weight = 1.0 - surfaceCol.GetAlpha();
83  G4Colour mixedCol = GetMixedColour(rayColour,surfaceCol,weight);
84  rayColour = Attenuate(trajectory->GetPointC(i),mixedCol);
85  }
86 
87  colorMap->add(evId,rayColour);
88 }
G4THitsMap< G4Colour > * colorMap
Definition: G4RTRun.hh:61
G4int add(const G4int &key, T *&aHit) const
Definition: G4THitsMap.hh:138
G4double GetAlpha() const
Definition: G4Colour.hh:142
double weight
Definition: plottest35.C:25
int G4int
Definition: G4Types.hh:78
G4Colour GetMixedColour(G4Colour, G4Colour, G4double)
Definition: G4RTRun.cc:145
G4Colour Attenuate(G4RayTrajectoryPoint *, G4Colour)
Definition: G4RTRun.cc:154
const G4VisAttributes * GetPostStepAtt() const
G4TrajectoryContainer * GetTrajectoryContainer() const
Definition: G4Event.hh:189
G4Colour backgroundColour
Definition: G4RTRun.hh:67
G4int GetEventID() const
Definition: G4Event.hh:151
G4RayTrajectoryPoint * GetPointC(G4int i) const
double G4double
Definition: G4Types.hh:76
virtual int GetPointEntries() const
G4Colour GetSurfaceColour(G4RayTrajectoryPoint *)
Definition: G4RTRun.cc:97
Here is the call graph for this function:

◆ ValidColour()

G4bool G4RTRun::ValidColour ( const G4VisAttributes *  visAtt)
private

Definition at line 182 of file G4RTRun.cc.

183 {
184  G4bool val = true;
185  if(!visAtt)
186  { val = false; }
187  else if(!(visAtt->IsVisible()))
188  { val = false; }
189  else if(visAtt->IsForceDrawingStyle()
191  { val = false; }
192  return val;
193 }
ForcedDrawingStyle GetForcedDrawingStyle() const
G4bool IsForceDrawingStyle() const
bool G4bool
Definition: G4Types.hh:79
G4bool IsVisible() const
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ attenuationLength

G4double G4RTRun::attenuationLength
private

Definition at line 69 of file G4RTRun.hh.

◆ backgroundColour

G4Colour G4RTRun::backgroundColour
private

Definition at line 67 of file G4RTRun.hh.

◆ colorMap

G4THitsMap<G4Colour>* G4RTRun::colorMap
private

Definition at line 61 of file G4RTRun.hh.

◆ lightDirection

G4ThreeVector G4RTRun::lightDirection
private

Definition at line 68 of file G4RTRun.hh.


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