Geant4 11.2.2
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 ()
 
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
 

Static Public Member Functions

static G4TheMTRayTracerInstance ()
 
static G4TheMTRayTracerInstance (G4VFigureFileMaker *figMaker, G4VRTScanner *scanner)
 

Protected Member Functions

virtual G4bool CreateBitMap ()
 
virtual void StoreUserActions ()
 
virtual void RestoreUserActions ()
 
- Protected Member Functions inherited from G4TheRayTracer
void CreateFigureFile (const G4String &fileName)
 
G4bool GenerateColour (G4Event *anEvent)
 
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
 
G4RTMessengertheMessenger
 
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
 

Additional Inherited Members

- Static Protected Attributes inherited from G4TheRayTracer
static G4VFigureFileMakertheFigMaker = 0
 
static G4VRTScannertheScanner = 0
 

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 53 of file G4TheMTRayTracer.cc.

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

Referenced by Instance(), and Instance().

◆ ~G4TheMTRayTracer()

G4TheMTRayTracer::~G4TheMTRayTracer ( )
virtual

Definition at line 85 of file G4TheMTRayTracer.cc.

86{
88 {
91 }
93 {
94 delete theRTRunAction;
96 }
97}

Member Function Documentation

◆ CreateBitMap()

G4bool G4TheMTRayTracer::CreateBitMap ( )
protectedvirtual

Reimplemented from G4TheRayTracer.

Definition at line 172 of file G4TheMTRayTracer.cc.

173{
175 visMan->IgnoreStateChanges(true);
177
179
180 // Keep, then switch off any printing requests
181 auto runVerbosity = mrm->GetVerboseLevel();
182 auto runPrintProgress = mrm->GetPrintProgress();
183 G4UImanager::GetUIpointer()->ApplyCommand("/run/verbose 0");
184 G4UImanager::GetUIpointer()->ApplyCommand("/run/printProgress 0");
185
186 // Event loop
187 G4int nEvent = nRow*nColumn;
188//// mrm->BeamOn(nEvent);
189//// Temporary work-around until direct invokation of G4RunManager::BeamOn() works.
190 G4String str = "/run/beamOn " + G4UIcommand::ConvertToString(nEvent);
192
193 // Restore printing requests
194 str = "/run/verbose " + G4UIcommand::ConvertToString(runVerbosity);
196 str = "/run/printProgress " + G4UIcommand::ConvertToString(runPrintProgress);
198
200 visMan->IgnoreStateChanges(false);
201
202 const G4RTRun* theRun = static_cast<const G4RTRun*>(mrm->GetCurrentRun());
203 if(!theRun) return false;
204
205 G4THitsMap<G4Colour>* colMap = theRun->GetMap();
206 auto itr = colMap->GetMap()->cbegin();
207 for(;itr!=colMap->GetMap()->cend();++itr)
208 {
209 G4int key = itr->first;
210 G4Colour* col = itr->second;
211 colorR[key] = (unsigned char)(G4int(255*col->GetRed()));
212 colorG[key] = (unsigned char)(G4int(255*col->GetGreen()));
213 colorB[key] = (unsigned char)(G4int(255*col->GetBlue()));
214 }
215
217 G4int iRow, iColumn;
218 while (theScanner->Coords(iRow,iColumn))
219 {
220 G4int iCoord = iRow * nColumn + iColumn;
221 theScanner->Draw(colorR[iCoord],colorG[iCoord],colorB[iCoord]);
222 }
223
224 return true;
225}
int G4int
Definition G4Types.hh:85
G4double GetBlue() const
Definition G4Colour.hh:154
G4double GetRed() const
Definition G4Colour.hh:152
G4double GetGreen() const
Definition G4Colour.hh:153
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()
static G4VRTScanner * theScanner
unsigned char * colorG
unsigned char * colorR
unsigned char * colorB
static G4String ConvertToString(G4bool boolVal)
G4int ApplyCommand(const char *aCommand)
static G4UImanager * GetUIpointer()
virtual void Initialize(G4int nRow, G4int nColumn)=0
virtual void Draw(unsigned char red, unsigned char green, unsigned char blue)
virtual G4bool Coords(G4int &iRow, G4int &iColumn)=0
Map_t * GetMap() const
virtual void IgnoreStateChanges(G4bool)
static G4VVisManager * GetConcreteInstance()

Referenced by Trace().

◆ Instance() [1/2]

G4TheMTRayTracer * G4TheMTRayTracer::Instance ( )
static

Definition at line 68 of file G4TheMTRayTracer.cc.

69{
70 if (theInstance) return theInstance;
71 else return new G4TheMTRayTracer;
72}
G4TheMTRayTracer(G4VFigureFileMaker *figMaker=0, G4VRTScanner *scanner=0)

◆ Instance() [2/2]

G4TheMTRayTracer * G4TheMTRayTracer::Instance ( G4VFigureFileMaker * figMaker,
G4VRTScanner * scanner )
static

Definition at line 74 of file G4TheMTRayTracer.cc.

76{
77 if (theInstance) {
78 theFigMaker=figMaker;
79 theScanner=scanner;
80 return theInstance;
81 }
82 else return new G4TheMTRayTracer(figMaker,scanner);
83}
static G4VFigureFileMaker * theFigMaker

◆ RestoreUserActions()

void G4TheMTRayTracer::RestoreUserActions ( )
protectedvirtual

Reimplemented from G4TheRayTracer.

Definition at line 164 of file G4TheMTRayTracer.cc.

165{
170}
void SetUserAction(G4UserRunAction *userAction) override
void SetUserInitialization(G4VUserPhysicsList *userPL) override

Referenced by CreateBitMap().

◆ StoreUserActions()

void G4TheMTRayTracer::StoreUserActions ( )
protectedvirtual

◆ Trace()

void G4TheMTRayTracer::Trace ( const G4String & fileName)
virtual

Reimplemented from G4TheRayTracer.

Definition at line 99 of file G4TheMTRayTracer.cc.

100{
102 G4ApplicationState currentState = theStateMan->GetCurrentState();
103 if(currentState!=G4State_Idle)
104 {
105 G4warn << "Illegal application state <" << theStateMan->GetStateString(currentState)
106 << "> - Trace() ignored. " << G4endl;
107 return;
108 }
109
110 if(!theFigMaker)
111 {
112 G4warn << "Figure file maker class is not specified - Trace() ignored." << G4endl;
113 return;
114 }
115
117 G4int storeTrajectory = UI->GetCurrentIntValue("/tracking/storeTrajectory");
118 UI->ApplyCommand("/tracking/storeTrajectory 1");
119
121 eyeDirection = tmpVec.unit();
122 G4int nPixel = nColumn*nRow;
123 colorR = new unsigned char[nPixel];
124 colorG = new unsigned char[nPixel];
125 colorB = new unsigned char[nPixel];
126 unsigned char defR = (unsigned char)(G4int(255*backgroundColour.GetRed()));
127 unsigned char defG = (unsigned char)(G4int(255*backgroundColour.GetGreen()));
128 unsigned char defB = (unsigned char)(G4int(255*backgroundColour.GetBlue()));
129 for(G4int ii=0;ii<nPixel;++ii)
130 {
131 colorR[ii] = defR;
132 colorG[ii] = defG;
133 colorB[ii] = defB;
134 }
135
136 G4bool succeeded = CreateBitMap();
137 if(succeeded)
138 { CreateFigureFile(fileName); }
139 else
140 { G4warn << "Could not create figure file" << G4endl;
141 G4warn << "You might set the eye position outside of the world volume" << G4endl; }
142
143 G4String str = "/tracking/storeTrajectory " + G4UIcommand::ConvertToString(storeTrajectory);
144 UI->ApplyCommand(str);
145
146 delete [] colorR;
147 delete [] colorG;
148 delete [] colorB;
149}
G4ApplicationState
@ G4State_Idle
#define G4warn
Definition G4Scene.cc:41
bool G4bool
Definition G4Types.hh:86
#define G4endl
Definition G4ios.hh:67
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)
G4ThreeVector eyePosition
G4int GetCurrentIntValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)

Friends And Related Symbol 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 116 of file G4TheMTRayTracer.hh.

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

◆ theRTWorkerInitialization

G4RTWorkerInitialization* G4TheMTRayTracer::theRTWorkerInitialization
protected

Definition at line 114 of file G4TheMTRayTracer.hh.

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

◆ theUserRunAction

const G4UserRunAction* G4TheMTRayTracer::theUserRunAction
protected

Definition at line 115 of file G4TheMTRayTracer.hh.

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

◆ theUserWorkerInitialization

const G4UserWorkerInitialization* G4TheMTRayTracer::theUserWorkerInitialization
protected

Definition at line 113 of file G4TheMTRayTracer.hh.

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


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