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

#include <G4TheMTRayTracer.hh>

+ Inheritance diagram for G4TheMTRayTracer:

Public Member Functions

 G4TheMTRayTracer (G4VFigureFileMaker *figMaker=0, G4VRTScanner *scanner=0)
 
virtual ~G4TheMTRayTracer ()
 
virtual void Trace (const G4String &fileName)
 
- Public Member Functions inherited from G4TheRayTracer
 G4TheRayTracer (G4VFigureFileMaker *figMaker=0, G4VRTScanner *scanner=0)
 
virtual ~G4TheRayTracer ()
 
virtual void Trace (const G4String &fileName)
 
void SetFigureFileMaker (G4VFigureFileMaker *figMaker)
 
G4VFigureFileMakerGetFigureFileMaker ()
 
void SetScanner (G4VRTScanner *scanner)
 
G4VRTScannerGetScanner ()
 
void SetNColumn (G4int val)
 
G4int GetNColumn () const
 
void SetNRow (G4int val)
 
G4int GetNRow () const
 
void SetEyePosition (const G4ThreeVector &val)
 
G4ThreeVector GetEyePosition () const
 
void SetTargetPosition (const G4ThreeVector &val)
 
G4ThreeVector GetTargetPosition () const
 
void SetLightDirection (const G4ThreeVector &val)
 
G4ThreeVector GetLightDirection () const
 
void SetUpVector (const G4ThreeVector &val)
 
G4ThreeVector GetUpVector () const
 
void SetHeadAngle (G4double val)
 
G4double GetHeadAngle () const
 
void SetViewSpan (G4double val)
 
G4double GetViewSpan () const
 
void SetAttenuationLength (G4double val)
 
G4double GetAttenuationLength () const
 
void SetDistortion (G4bool val)
 
G4bool GetDistortion () const
 
void SetBackgroundColour (const G4Colour &val)
 
G4Colour GetBackgroundColour () const
 

Protected Member Functions

virtual G4bool CreateBitMap ()
 
virtual void StoreUserActions ()
 
virtual void RestoreUserActions ()
 
- Protected Member Functions inherited from G4TheRayTracer
virtual G4bool CreateBitMap ()
 
void CreateFigureFile (const G4String &fileName)
 
G4bool GenerateColour (G4Event *anEvent)
 
virtual void StoreUserActions ()
 
virtual void RestoreUserActions ()
 
G4Colour GetSurfaceColour (G4RayTrajectoryPoint *point)
 
G4Colour GetMixedColour (const G4Colour &surfCol, const G4Colour &transCol, G4double weight=0.5)
 
G4Colour Attenuate (G4RayTrajectoryPoint *point, const G4Colour &sourceCol)
 
G4bool ValidColour (const G4VisAttributes *visAtt)
 

Protected Attributes

const G4UserWorkerInitializationtheUserWorkerInitialization
 
G4RTWorkerInitializationtheRTWorkerInitialization
 
const G4UserRunActiontheUserRunAction
 
G4RTRunActiontheRTRunAction
 
- Protected Attributes inherited from G4TheRayTracer
G4RayShootertheRayShooter
 
G4VFigureFileMakertheFigMaker
 
G4RTMessengertheMessenger
 
G4VRTScannertheScanner
 
G4EventManagertheEventManager
 
G4UserEventActiontheUserEventAction
 
G4UserStackingActiontheUserStackingAction
 
G4UserTrackingActiontheUserTrackingAction
 
G4UserSteppingActiontheUserSteppingAction
 
G4UserEventActiontheRayTracerEventAction
 
G4UserStackingActiontheRayTracerStackingAction
 
G4RTTrackingActiontheRayTracerTrackingAction
 
G4RTSteppingActiontheRayTracerSteppingAction
 
unsigned char * colorR
 
unsigned char * colorG
 
unsigned char * colorB
 
G4int nColumn
 
G4int nRow
 
G4ThreeVector eyePosition
 
G4ThreeVector targetPosition
 
G4ThreeVector eyeDirection
 
G4ThreeVector lightDirection
 
G4ThreeVector up
 
G4double headAngle
 
G4double viewSpan
 
G4double attenuationLength
 
G4bool distortionOn
 
G4bool antialiasingOn
 
G4Colour rayColour
 
G4Colour backgroundColour
 

Friends

class G4RTPrimaryGeneratorAction
 
class G4RTRun
 
class G4RayTracerViewer
 

Detailed Description

Definition at line 70 of file G4TheMTRayTracer.hh.

Constructor & Destructor Documentation

◆ G4TheMTRayTracer()

G4TheMTRayTracer::G4TheMTRayTracer ( G4VFigureFileMaker figMaker = 0,
G4VRTScanner scanner = 0 
)

Definition at line 51 of file G4TheMTRayTracer.cc.

53: G4TheRayTracer(figMaker,scanner)
54{
55 if(!theInstance)
56 { theInstance = this; }
57 else
58 { G4Exception("G4TheMTRayTracer::G4TheMTRayTracer","VisRayTracer00100",
59 FatalException,"G4TheMTRayTracer has to be a singleton.");}
64}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
G4RTWorkerInitialization * theRTWorkerInitialization
const G4UserWorkerInitialization * theUserWorkerInitialization
const G4UserRunAction * theUserRunAction
G4RTRunAction * theRTRunAction

◆ ~G4TheMTRayTracer()

G4TheMTRayTracer::~G4TheMTRayTracer ( )
virtual

Definition at line 66 of file G4TheMTRayTracer.cc.

67{
69 {
72 }
74 {
75 delete theRTRunAction;
77 }
78}

Member Function Documentation

◆ CreateBitMap()

G4bool G4TheMTRayTracer::CreateBitMap ( )
protectedvirtual

Reimplemented from G4TheRayTracer.

Definition at line 153 of file G4TheMTRayTracer.cc.

154{
156 visMan->IgnoreStateChanges(true);
158
160
161 // Keep, then switch off any printing requests
162 auto runVerbosity = mrm->GetVerboseLevel();
163 auto runPrintProgress = mrm->GetPrintProgress();
164 G4UImanager::GetUIpointer()->ApplyCommand("/run/verbose 0");
165 G4UImanager::GetUIpointer()->ApplyCommand("/run/printProgress 0");
166
167 // Event loop
168 G4int nEvent = nRow*nColumn;
169//// mrm->BeamOn(nEvent);
170//// Temporary work-around until direct invokation of G4RunManager::BeamOn() works.
171 G4String str = "/run/beamOn " + G4UIcommand::ConvertToString(nEvent);
173
174 // Restore printing requests
175 str = "/run/verbose " + G4UIcommand::ConvertToString(runVerbosity);
177 str = "/run/printProgress " + G4UIcommand::ConvertToString(runPrintProgress);
179
181 visMan->IgnoreStateChanges(false);
182
183 const G4RTRun* theRun = static_cast<const G4RTRun*>(mrm->GetCurrentRun());
184 if(!theRun) return false;
185
186 G4THitsMap<G4Colour>* colMap = theRun->GetMap();
187 auto itr = colMap->GetMap()->cbegin();
188 for(;itr!=colMap->GetMap()->cend();++itr)
189 {
190 G4int key = itr->first;
191 G4Colour* col = itr->second;
192 colorR[key] = (unsigned char)(G4int(255*col->GetRed()));
193 colorG[key] = (unsigned char)(G4int(255*col->GetGreen()));
194 colorB[key] = (unsigned char)(G4int(255*col->GetBlue()));
195 }
196
198 G4int iRow, iColumn;
199 while (theScanner->Coords(iRow,iColumn))
200 {
201 G4int iCoord = iRow * nColumn + iColumn;
202 theScanner->Draw(colorR[iCoord],colorG[iCoord],colorB[iCoord]);
203 }
204
205 return true;
206}
int G4int
Definition: G4Types.hh:85
G4double GetBlue() const
Definition: G4Colour.hh:152
G4double GetRed() const
Definition: G4Colour.hh:150
G4double GetGreen() const
Definition: G4Colour.hh:151
G4THitsMap< G4Colour > * GetMap() const
Definition: G4RTRun.hh:63
static G4MTRunManager * GetMTMasterRunManager()
const G4Run * GetCurrentRun() const
G4int GetPrintProgress()
G4int GetVerboseLevel() const
virtual void StoreUserActions()
virtual void RestoreUserActions()
unsigned char * colorG
unsigned char * colorR
G4VRTScanner * theScanner
unsigned char * colorB
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:430
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
virtual void Initialize(G4int nRow, G4int nColumn)=0
virtual void Draw(unsigned char red, unsigned char green, unsigned char blue)
Definition: G4VRTScanner.hh:70
virtual G4bool Coords(G4int &iRow, G4int &iColumn)=0
Map_t * GetMap() const
Definition: G4THitsMap.hh:151
virtual void IgnoreStateChanges(G4bool)
static G4VVisManager * GetConcreteInstance()

Referenced by Trace().

◆ RestoreUserActions()

void G4TheMTRayTracer::RestoreUserActions ( )
protectedvirtual

Reimplemented from G4TheRayTracer.

Definition at line 145 of file G4TheMTRayTracer.cc.

146{
151}
virtual void SetUserAction(G4UserRunAction *userAction)
virtual void SetUserInitialization(G4VUserPhysicsList *userPL)

Referenced by CreateBitMap().

◆ StoreUserActions()

void G4TheMTRayTracer::StoreUserActions ( )
protectedvirtual

◆ Trace()

void G4TheMTRayTracer::Trace ( const G4String fileName)
virtual

Reimplemented from G4TheRayTracer.

Definition at line 80 of file G4TheMTRayTracer.cc.

81{
83 G4ApplicationState currentState = theStateMan->GetCurrentState();
84 if(currentState!=G4State_Idle)
85 {
86 G4cerr << "Illegal application state <" << theStateMan->GetStateString(currentState)
87 << "> - Trace() ignored. " << G4endl;
88 return;
89 }
90
91 if(!theFigMaker)
92 {
93 G4cerr << "Figure file maker class is not specified - Trace() ignored." << G4endl;
94 return;
95 }
96
98 G4int storeTrajectory = UI->GetCurrentIntValue("/tracking/storeTrajectory");
99 UI->ApplyCommand("/tracking/storeTrajectory 1");
100
102 eyeDirection = tmpVec.unit();
103 G4int nPixel = nColumn*nRow;
104 colorR = new unsigned char[nPixel];
105 colorG = new unsigned char[nPixel];
106 colorB = new unsigned char[nPixel];
107 unsigned char defR = (unsigned char)(G4int(255*backgroundColour.GetRed()));
108 unsigned char defG = (unsigned char)(G4int(255*backgroundColour.GetGreen()));
109 unsigned char defB = (unsigned char)(G4int(255*backgroundColour.GetBlue()));
110 for(G4int ii=0;ii<nPixel;++ii)
111 {
112 colorR[ii] = defR;
113 colorG[ii] = defG;
114 colorB[ii] = defB;
115 }
116
117 G4bool succeeded = CreateBitMap();
118 if(succeeded)
119 { CreateFigureFile(fileName); }
120 else
121 { G4cerr << "Could not create figure file" << G4endl;
122 G4cerr << "You might set the eye position outside of the world volume" << G4endl; }
123
124 G4String str = "/tracking/storeTrajectory " + G4UIcommand::ConvertToString(storeTrajectory);
125 UI->ApplyCommand(str);
126
127 delete [] colorR;
128 delete [] colorG;
129 delete [] colorB;
130}
G4ApplicationState
@ G4State_Idle
bool G4bool
Definition: G4Types.hh:86
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
Hep3Vector unit() const
const G4ApplicationState & GetCurrentState() const
G4String GetStateString(const G4ApplicationState &aState) const
static G4StateManager * GetStateManager()
virtual G4bool CreateBitMap()
G4ThreeVector eyeDirection
G4Colour backgroundColour
G4ThreeVector targetPosition
void CreateFigureFile(const G4String &fileName)
G4VFigureFileMaker * theFigMaker
G4ThreeVector eyePosition
G4int GetCurrentIntValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:231

Friends And Related Function Documentation

◆ G4RayTracerViewer

friend class G4RayTracerViewer
friend

Definition at line 74 of file G4TheMTRayTracer.hh.

◆ G4RTPrimaryGeneratorAction

friend class G4RTPrimaryGeneratorAction
friend

Definition at line 72 of file G4TheMTRayTracer.hh.

◆ G4RTRun

friend class G4RTRun
friend

Definition at line 73 of file G4TheMTRayTracer.hh.

Member Data Documentation

◆ theRTRunAction

G4RTRunAction* G4TheMTRayTracer::theRTRunAction
protected

Definition at line 112 of file G4TheMTRayTracer.hh.

Referenced by G4TheMTRayTracer(), StoreUserActions(), and ~G4TheMTRayTracer().

◆ theRTWorkerInitialization

G4RTWorkerInitialization* G4TheMTRayTracer::theRTWorkerInitialization
protected

Definition at line 110 of file G4TheMTRayTracer.hh.

Referenced by G4TheMTRayTracer(), StoreUserActions(), and ~G4TheMTRayTracer().

◆ theUserRunAction

const G4UserRunAction* G4TheMTRayTracer::theUserRunAction
protected

Definition at line 111 of file G4TheMTRayTracer.hh.

Referenced by G4TheMTRayTracer(), RestoreUserActions(), and StoreUserActions().

◆ theUserWorkerInitialization

const G4UserWorkerInitialization* G4TheMTRayTracer::theUserWorkerInitialization
protected

Definition at line 109 of file G4TheMTRayTracer.hh.

Referenced by G4TheMTRayTracer(), RestoreUserActions(), and StoreUserActions().


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