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

#include <G4ScoreQuantityMessenger.hh>

+ Inheritance diagram for G4ScoreQuantityMessenger:

Public Member Functions

 G4ScoreQuantityMessenger (G4ScoringManager *SManager)
 
 ~G4ScoreQuantityMessenger ()
 
void SetNewValue (G4UIcommand *command, G4String newValues)
 
G4String GetCurrentValue (G4UIcommand *)
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 

Protected Member Functions

void FillTokenVec (G4String newValues, G4TokenVec &token)
 
void FParticleCommand (G4VScoringMesh *mesh, G4TokenVec &token)
 
void FParticleWithEnergyCommand (G4VScoringMesh *mesh, G4TokenVec &token)
 
G4bool CheckMeshPS (G4VScoringMesh *mesh, G4String &psname)
 
- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 

Additional Inherited Members

- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir
 
G4String baseDirName
 

Detailed Description

Definition at line 59 of file G4ScoreQuantityMessenger.hh.

Constructor & Destructor Documentation

◆ G4ScoreQuantityMessenger()

G4ScoreQuantityMessenger::G4ScoreQuantityMessenger ( G4ScoringManager SManager)

Definition at line 88 of file G4ScoreQuantityMessenger.cc.

89:fSMan(SManager)
90{
91 QuantityCommands();
92 FilterCommands();
93}

◆ ~G4ScoreQuantityMessenger()

G4ScoreQuantityMessenger::~G4ScoreQuantityMessenger ( )

Definition at line 171 of file G4ScoreQuantityMessenger.cc.

172{
173 delete quantityDir;
174 delete qTouchCmd;
175 delete qGetUnitCmd;
176 delete qSetUnitCmd;
177
178 //
179 delete qCellChgCmd;
180 delete qCellFluxCmd;
181 delete qPassCellFluxCmd;
182 delete qeDepCmd;
183 delete qdoseDepCmd;
184 delete qnOfStepCmd;
185 delete qnOfSecondaryCmd;
186 //
187 delete qTrackLengthCmd;
188 delete qPassCellCurrCmd;
189 delete qPassTrackLengthCmd;
190 delete qFlatSurfCurrCmd;
191 delete qFlatSurfFluxCmd;
192// delete qSphereSurfCurrCmd;
193// delete qSphereSurfFluxCmd;
194// delete qCylSurfCurrCmd;
195// delete qCylSurfFluxCmd;
196 delete qNofCollisionCmd;
197 delete qPopulationCmd;
198 delete qTrackCountCmd;
199 delete qTerminationCmd;
200 delete qMinKinEAtGeneCmd;
201 //
202 delete qStepCheckerCmd;
203 //
204 delete filterDir;
205 delete fchargedCmd;
206 delete fneutralCmd;
207 delete fkinECmd;
208 delete fparticleCmd;
209 delete fparticleKinECmd;
210}

Member Function Documentation

◆ CheckMeshPS()

G4bool G4ScoreQuantityMessenger::CheckMeshPS ( G4VScoringMesh mesh,
G4String psname 
)
protected

Definition at line 533 of file G4ScoreQuantityMessenger.cc.

533 {
534 if(!mesh->FindPrimitiveScorer(psname)) {
535 return true;
536 } else {
537 G4cout << "WARNING[" << qTouchCmd->GetCommandPath()
538 << "] : Quantity name, \"" << psname << "\", is already existing." << G4endl;
540 return false;
541 }
542}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:134
void SetNullToCurrentPrimitiveScorer()
G4bool FindPrimitiveScorer(const G4String &psname)

Referenced by SetNewValue().

◆ FillTokenVec()

void G4ScoreQuantityMessenger::FillTokenVec ( G4String  newValues,
G4TokenVec token 
)
protected

Definition at line 495 of file G4ScoreQuantityMessenger.cc.

495 {
496
497 G4Tokenizer next(newValues);
498 G4String val;
499 while ( !(val = next()).isNull() ) {
500 token.push_back(val);
501 }
502}

Referenced by SetNewValue().

◆ FParticleCommand()

void G4ScoreQuantityMessenger::FParticleCommand ( G4VScoringMesh mesh,
G4TokenVec token 
)
protected

Definition at line 505 of file G4ScoreQuantityMessenger.cc.

505 {
506 //
507 // Filter name
508 G4String name = token[0];
509 //
510 // particle list
511 std::vector<G4String> pnames;
512 for ( G4int i = 1; i<(G4int)token.size(); i++){
513 pnames.push_back(token[i]);
514 }
515 //
516 // Attach Filter
517 mesh->SetFilter(new G4SDParticleFilter(name,pnames));
518}
int G4int
Definition: G4Types.hh:66
void SetFilter(G4VSDFilter *filter)

Referenced by SetNewValue().

◆ FParticleWithEnergyCommand()

void G4ScoreQuantityMessenger::FParticleWithEnergyCommand ( G4VScoringMesh mesh,
G4TokenVec token 
)
protected

Definition at line 520 of file G4ScoreQuantityMessenger.cc.

520 {
521 G4String& name = token[0];
522 G4double elow = StoD(token[1]);
523 G4double ehigh= StoD(token[2]);
524 G4double unitVal = G4UnitDefinition::GetValueOf(token[3]);
526 new G4SDParticleWithEnergyFilter(name,elow*unitVal,ehigh*unitVal);
527 for ( G4int i = 4; i < (G4int)token.size(); i++){
528 filter->add(token[i]);
529 }
530 mesh->SetFilter(filter);
531}
double G4double
Definition: G4Types.hh:64
void add(const G4String &particleName)
G4double StoD(G4String s)
static G4double GetValueOf(const G4String &)

Referenced by SetNewValue().

◆ GetCurrentValue()

G4String G4ScoreQuantityMessenger::GetCurrentValue ( G4UIcommand )
virtual

Reimplemented from G4UImessenger.

Definition at line 488 of file G4ScoreQuantityMessenger.cc.

489{
490 G4String val;
491
492 return val;
493}

◆ SetNewValue()

void G4ScoreQuantityMessenger::SetNewValue ( G4UIcommand command,
G4String  newValues 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 212 of file G4ScoreQuantityMessenger.cc.

213{
214 //
215 // Get Current Mesh
216 //
217 G4VScoringMesh* mesh = fSMan->GetCurrentMesh();
218 if(!mesh)
219 {
220 G4cerr << "ERROR : No mesh is currently open. Open/create a mesh first. Command ignored." << G4endl;
221 return;
222 }
223 // Tokens
224 G4TokenVec token;
225 FillTokenVec(newVal,token);
226 //
227 // Commands for Current Mesh
228 if(command==qTouchCmd) {
229 mesh->SetCurrentPrimitiveScorer(newVal);
230 } else if(command == qGetUnitCmd ){
231 G4cout << "Unit: "<< mesh->GetCurrentPSUnit() <<G4endl;
232 } else if(command == qSetUnitCmd ){
233 mesh->SetCurrentPSUnit(newVal);
234 } else if(command== qCellChgCmd) {
235 if ( CheckMeshPS(mesh,token[0]) ){
236 G4PSCellCharge3D* ps = new G4PSCellCharge3D(token[0]);
237 ps->SetUnit(token[1]);
238 mesh->SetPrimitiveScorer(ps);
239 }
240 } else if(command== qCellFluxCmd) {
241 if ( CheckMeshPS(mesh,token[0]) ){
242 if( mesh->GetShape()==boxMesh ) {
243 G4PSCellFlux3D* ps = new G4PSCellFlux3D(token[0]);
244 ps->SetUnit(token[1]);
245 mesh->SetPrimitiveScorer(ps);
246 } else if( mesh->GetShape()==cylinderMesh ) {
248 new G4PSCellFluxForCylinder3D(token[0]);
249 ps->SetUnit(token[1]);
250 G4ThreeVector msize = mesh->GetSize(); // gevin in R Z N/A
251 ps->SetCylinderSize(msize[0],msize[1]); // given in dr dz
252 G4int nSeg[3];
253 mesh->GetNumberOfSegments(nSeg);
254 ps->SetNumberOfSegments(nSeg);
255 mesh->SetPrimitiveScorer(ps);
256 }
257 }
258 } else if(command== qPassCellFluxCmd) {
259 if ( CheckMeshPS(mesh,token[0]) ){
260 if( mesh->GetShape()==boxMesh ) {
262 ps->SetUnit(token[1]);
263 mesh->SetPrimitiveScorer(ps);
264 } else if( mesh->GetShape()==cylinderMesh ) {
267 ps->SetUnit(token[1]);
268 G4ThreeVector msize = mesh->GetSize(); // gevin in R Z N/A
269 ps->SetCylinderSize(msize[0],msize[1]); // given in dr dz
270 G4int nSeg[3];
271 mesh->GetNumberOfSegments(nSeg);
272 ps->SetNumberOfSegments(nSeg);
273 mesh->SetPrimitiveScorer(ps);
274 }
275 }
276 } else if(command==qeDepCmd) {
277 if ( CheckMeshPS(mesh,token[0]) ){
278 G4PSEnergyDeposit3D* ps =new G4PSEnergyDeposit3D(token[0]);
279 ps->SetUnit(token[1]);
280 mesh->SetPrimitiveScorer(ps);
281 }
282 } else if(command== qdoseDepCmd) {
283 if ( CheckMeshPS(mesh,token[0]) ){
284 if( mesh->GetShape()==boxMesh ) {
285 G4PSDoseDeposit3D* ps = new G4PSDoseDeposit3D(token[0]);
286 ps->SetUnit(token[1]);
287 mesh->SetPrimitiveScorer(ps);
288 } else if( mesh->GetShape()==cylinderMesh ) {
290 new G4PSDoseDepositForCylinder3D(token[0]);
291 ps->SetUnit(token[1]);
292 G4ThreeVector msize = mesh->GetSize(); // gevin in R Z N/A
293 ps->SetCylinderSize(msize[0],msize[1]); // given in dr dz
294 G4int nSeg[3];
295 mesh->GetNumberOfSegments(nSeg);
296 ps->SetNumberOfSegments(nSeg);
297 mesh->SetPrimitiveScorer(ps);
298 }
299 }
300 } else if(command== qnOfStepCmd) {
301 if ( CheckMeshPS(mesh,token[0]) ){
302 G4PSNofStep3D* ps = new G4PSNofStep3D(token[0]);
303 mesh->SetPrimitiveScorer(ps);
304 }
305 } else if(command== qnOfSecondaryCmd) {
306 if ( CheckMeshPS(mesh,token[0]) ){
307 G4PSNofSecondary3D* ps =new G4PSNofSecondary3D(token[0]);
308 mesh->SetPrimitiveScorer(ps);
309 }
310 } else if(command== qTrackLengthCmd) {
311 if ( CheckMeshPS(mesh,token[0]) ){
312 G4PSTrackLength3D* ps = new G4PSTrackLength3D(token[0]);
313 ps->Weighted(StoB(token[1]));
314 ps->MultiplyKineticEnergy(StoB(token[2]));
315 ps->DivideByVelocity(StoB(token[3]));
316 ps->SetUnit(token[4]);
317 mesh->SetPrimitiveScorer(ps);
318 }
319 } else if(command== qPassCellCurrCmd){
320 if( CheckMeshPS(mesh,token[0]) ) {
322 ps->Weighted(StoB(token[1]));
323 //ps->SetUnit(token[2]);
324 mesh->SetPrimitiveScorer(ps);
325 }
326 } else if(command== qPassTrackLengthCmd){
327 if( CheckMeshPS(mesh,token[0]) ) {
329 ps->Weighted(StoB(token[1]));
330 mesh->SetPrimitiveScorer(ps);
331 }
332 } else if(command== qFlatSurfCurrCmd){
333 if( CheckMeshPS(mesh,token[0])) {
335 new G4PSFlatSurfaceCurrent3D(token[0],StoI(token[1]));
336 ps->Weighted(StoB(token[2]));
337 ps->DivideByArea(StoB(token[3]));
338 if ( StoB(token[3]) ){
339 ps->SetUnit(token[4]);
340 }else{
341 ps->SetUnit("");
342 }
343 mesh->SetPrimitiveScorer(ps);
344 }
345 } else if(command== qFlatSurfFluxCmd){
346 if( CheckMeshPS(mesh, token[0] )) {
347 G4PSFlatSurfaceFlux3D* ps = new G4PSFlatSurfaceFlux3D(token[0],StoI(token[1]));
348 ps->Weighted(StoB(token[2]));
349 ps->DivideByArea(StoB(token[3]));
350 if ( StoB(token[3]) ){
351 ps->SetUnit(token[4]);
352 }else{
353 ps->SetUnit("");
354 }
355 mesh->SetPrimitiveScorer(ps);
356 }
357// } else if(command== qSphereSurfCurrCmd){
358// if( CheckMeshPS(mesh, token[0] )) {
359// G4PSSphereSurfaceCurrent3D* ps =
360// new G4PSSphereSurfaceCurrent3D(token[0],StoI(token[1]));
361// ps->Weighted(StoB(token[2]));
362// ps->DivideByArea(StoB(token[3]));
363// if ( StoB(token[3]) ){
364// ps->SetUnit(token[4]);
365// }else{
366// ps->SetUnit("");
367// }
368// mesh->SetPrimitiveScorer(ps);
369// }
370// } else if(command== qSphereSurfFluxCmd){
371// if( CheckMeshPS(mesh,token[0])) {
372// G4PSSphereSurfaceFlux3D* ps = new G4PSSphereSurfaceFlux3D(token[0], StoI(token[1]));
373// ps->Weighted(StoB(token[2]));
374// ps->DivideByArea(StoB(token[3]));
375// if ( StoB(token[3]) ){
376// ps->SetUnit(token[4]);
377// }else{
378// ps->SetUnit("");
379// }
380// mesh->SetPrimitiveScorer(ps);
381// }
382// } else if(command== qCylSurfCurrCmd){
383// if( CheckMeshPS(mesh, token[0] ) ) {
384// G4PSCylinderSurfaceCurrent3D* ps =
385// new G4PSCylinderSurfaceCurrent3D(token[0],StoI(token[1]));
386// ps->Weighted(StoB(token[2]));
387// ps->DivideByArea(StoB(token[3]));
388// if ( StoB(token[3]) ){
389// ps->SetUnit(token[4]);
390// }else{
391// ps->SetUnit("");
392// }
393// ps->SetUnit(token[4]);
394// mesh->SetPrimitiveScorer(ps);
395// }
396// } else if(command== qCylSurfFluxCmd){
397// if( CheckMeshPS(mesh, token[0] ) {
398// G4PSCylinerSurfaceFlux3D* ps =new G4PSCylinderSurfaceFlux3D(token[0], StoI(token[1]));
399// ps->Weighted(StoB(token[2]));
400// ps->DivideByArea(StoB(token[3]));
401// if ( StoB(token[3]) ){
402// ps->SetUnit(token[4]);
403// }else{
404// ps->SetUnit("");
405// }
406// mesh->SetPrimitiveScorer(ps);
407// }
408 } else if(command== qNofCollisionCmd){
409 if( CheckMeshPS(mesh,token[0])) {
410 G4PSNofCollision3D* ps =new G4PSNofCollision3D(token[0]);
411 ps->Weighted(StoB(token[1]));
412 mesh->SetPrimitiveScorer(ps);
413 }
414 } else if(command== qPopulationCmd){
415 if( CheckMeshPS(mesh,token[0]) ) {
416 G4PSPopulation3D* ps =new G4PSPopulation3D(token[0]);
417 ps->Weighted(StoB(token[1]));
418 mesh->SetPrimitiveScorer(ps);
419 }
420 } else if(command== qTrackCountCmd){
421 if( CheckMeshPS(mesh,token[0])) {
422 G4PSTrackCounter3D* ps =new G4PSTrackCounter3D(token[0],StoI(token[1]));
423 mesh->SetPrimitiveScorer(ps);
424 }
425 } else if(command== qTerminationCmd){
426 if( CheckMeshPS(mesh,token[0])) {
427 G4PSTermination3D* ps =new G4PSTermination3D(token[0]);
428 ps->Weighted(StoB(token[1]));
429 mesh->SetPrimitiveScorer(ps);
430 }
431
432 } else if(command== qMinKinEAtGeneCmd){
433 if( CheckMeshPS(mesh,token[0]) ){
435 ps->SetUnit(token[1]);
436 mesh->SetPrimitiveScorer(ps);
437 }
438 } else if(command== qStepCheckerCmd){
439 if( CheckMeshPS(mesh,token[0]) ){
440 G4PSStepChecker3D* ps =new G4PSStepChecker3D(token[0]);
441 mesh->SetPrimitiveScorer(ps);
442 }
443
444 //
445 // Filters
446 //
447 }else if(command== fchargedCmd){
448 if(!mesh->IsCurrentPrimitiveScorerNull()) {
449 mesh->SetFilter(new G4SDChargedFilter(token[0]));
450 } else {
451 G4cout << "WARNING[" << fchargedCmd->GetCommandPath()
452 << "] : Current quantity is not set. Set or touch a quantity first." << G4endl;
453 }
454 }else if(command== fneutralCmd){
455 if(!mesh->IsCurrentPrimitiveScorerNull()) {
456 mesh->SetFilter(new G4SDNeutralFilter(token[0]));
457 } else {
458 G4cout << "WARNING[" << fneutralCmd->GetCommandPath()
459 << "] : Current quantity is not set. Set or touch a quantity first." << G4endl;
460 }
461 }else if(command== fkinECmd){
462 if(!mesh->IsCurrentPrimitiveScorerNull()) {
463 G4String& name = token[0];
464 G4double elow = StoD(token[1]);
465 G4double ehigh = StoD(token[2]);
466 mesh->SetFilter(new G4SDKineticEnergyFilter(name,elow,ehigh));
467 } else {
468 G4cout << "WARNING[" << fkinECmd->GetCommandPath()
469 << "] : Current quantity is not set. Set or touch a quantity first." << G4endl;
470 }
471 }else if(command== fparticleKinECmd){
472 if(!mesh->IsCurrentPrimitiveScorerNull()) {
473 FParticleWithEnergyCommand(mesh,token);
474 } else {
475 G4cout << "WARNING[" << fparticleKinECmd->GetCommandPath()
476 << "] : Current quantity is not set. Set or touch a quantity first." << G4endl;
477 }
478 } else if(command==fparticleCmd) {
479 if(!mesh->IsCurrentPrimitiveScorerNull()) {
480 FParticleCommand(mesh,token);
481 } else {
482 G4cout << "WARNING[" << fparticleCmd->GetCommandPath()
483 << "] : Current quantity is not set. Set or touch a quantity first." << G4endl;
484 }
485 }
486}
std::vector< G4String > G4TokenVec
@ boxMesh
@ cylinderMesh
G4DLLIMPORT std::ostream G4cerr
virtual void SetUnit(const G4String &unit)
void SetCylinderSize(G4double dr, G4double dz)
virtual void SetUnit(const G4String &unit)
void SetCylinderSize(G4double dr, G4double dz)
virtual void SetUnit(const G4String &unit)
virtual void SetUnit(const G4String &unit)
void DivideByArea(G4bool flg=true)
void Weighted(G4bool flg=true)
virtual void SetUnit(const G4String &unit)
void Weighted(G4bool flg=true)
void DivideByArea(G4bool flg=true)
virtual void SetUnit(const G4String &unit)
virtual void SetUnit(const G4String &unit)
void Weighted(G4bool flg=true)
void Weighted(G4bool flg=true)
void SetCylinderSize(G4double dr, G4double dz)
virtual void SetUnit(const G4String &unit)
void Weighted(G4bool flg=true)
void Weighted(G4bool flg=true)
void Weighted(G4bool flg=true)
virtual void SetUnit(const G4String &unit)
void MultiplyKineticEnergy(G4bool flg=true)
void Weighted(G4bool flg=true)
void DivideByVelocity(G4bool flg=true)
G4bool CheckMeshPS(G4VScoringMesh *mesh, G4String &psname)
void FParticleWithEnergyCommand(G4VScoringMesh *mesh, G4TokenVec &token)
void FillTokenVec(G4String newValues, G4TokenVec &token)
void FParticleCommand(G4VScoringMesh *mesh, G4TokenVec &token)
G4VScoringMesh * GetCurrentMesh() const
G4int StoI(G4String s)
G4bool StoB(G4String s)
G4ThreeVector GetSize() const
MeshShape GetShape() const
void GetNumberOfSegments(G4int nSegment[3])
void SetCurrentPSUnit(const G4String &unit)
void SetCurrentPrimitiveScorer(const G4String &name)
void SetPrimitiveScorer(G4VPrimitiveScorer *ps)
G4String GetCurrentPSUnit()
G4bool IsCurrentPrimitiveScorerNull()

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