G4ScoreQuantityMessenger Class Reference

#include <G4ScoreQuantityMessenger.hh>

Inheritance diagram for G4ScoreQuantityMessenger:

G4UImessenger

Public Member Functions

 G4ScoreQuantityMessenger (G4ScoringManager *SManager)
 ~G4ScoreQuantityMessenger ()
void SetNewValue (G4UIcommand *command, G4String newValues)
G4String GetCurrentValue (G4UIcommand *)

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)

Detailed Description

Definition at line 59 of file G4ScoreQuantityMessenger.hh.


Constructor & Destructor Documentation

G4ScoreQuantityMessenger::G4ScoreQuantityMessenger ( G4ScoringManager SManager  ) 

Definition at line 88 of file G4ScoreQuantityMessenger.cc.

00089 :fSMan(SManager)
00090 {
00091   QuantityCommands();
00092   FilterCommands();
00093 }

G4ScoreQuantityMessenger::~G4ScoreQuantityMessenger (  ) 

Definition at line 171 of file G4ScoreQuantityMessenger.cc.

00172 {
00173     delete         quantityDir;
00174     delete         qTouchCmd;
00175     delete         qGetUnitCmd;
00176     delete         qSetUnitCmd;
00177 
00178     //
00179     delete    qCellChgCmd;
00180     delete    qCellFluxCmd;
00181     delete    qPassCellFluxCmd;
00182     delete    qeDepCmd;
00183     delete    qdoseDepCmd;
00184     delete    qnOfStepCmd;
00185     delete    qnOfSecondaryCmd;
00186     //
00187     delete          qTrackLengthCmd;
00188     delete          qPassCellCurrCmd;
00189     delete          qPassTrackLengthCmd;
00190     delete          qFlatSurfCurrCmd;
00191     delete          qFlatSurfFluxCmd;
00192 //    delete          qSphereSurfCurrCmd;
00193 //    delete          qSphereSurfFluxCmd;
00194 //    delete          qCylSurfCurrCmd;
00195 //    delete          qCylSurfFluxCmd;
00196     delete          qNofCollisionCmd;
00197     delete          qPopulationCmd;
00198     delete          qTrackCountCmd;
00199     delete          qTerminationCmd;
00200     delete          qMinKinEAtGeneCmd;
00201     //
00202     delete          qStepCheckerCmd;
00203     //
00204     delete   filterDir;
00205     delete   fchargedCmd;
00206     delete   fneutralCmd;
00207     delete   fkinECmd;
00208     delete   fparticleCmd;
00209     delete   fparticleKinECmd;
00210 }


Member Function Documentation

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

Definition at line 533 of file G4ScoreQuantityMessenger.cc.

References G4VScoringMesh::FindPrimitiveScorer(), G4cout, G4endl, G4UIcommand::GetCommandPath(), and G4VScoringMesh::SetNullToCurrentPrimitiveScorer().

Referenced by SetNewValue().

00533                                                                                   {
00534     if(!mesh->FindPrimitiveScorer(psname)) {
00535         return true;
00536     } else {
00537         G4cout << "WARNING[" << qTouchCmd->GetCommandPath()
00538                << "] : Quantity name, \"" << psname << "\", is already existing." << G4endl;
00539         mesh->SetNullToCurrentPrimitiveScorer();
00540         return false;
00541     }
00542 }

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

Definition at line 495 of file G4ScoreQuantityMessenger.cc.

Referenced by SetNewValue().

00495                                                                                 {
00496 
00497     G4Tokenizer next(newValues);
00498     G4String val;
00499     while ( !(val = next()).isNull() ) {
00500         token.push_back(val);
00501     }
00502 }

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

Definition at line 505 of file G4ScoreQuantityMessenger.cc.

References G4VScoringMesh::SetFilter().

Referenced by SetNewValue().

00505                                                                                       {
00506     //
00507     // Filter name
00508     G4String name = token[0];
00509     //
00510     // particle list
00511     std::vector<G4String> pnames;
00512     for ( G4int i = 1; i<(G4int)token.size(); i++){
00513         pnames.push_back(token[i]);
00514     }
00515     //
00516     // Attach Filter
00517     mesh->SetFilter(new G4SDParticleFilter(name,pnames));
00518 }    

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

Definition at line 520 of file G4ScoreQuantityMessenger.cc.

References G4SDParticleWithEnergyFilter::add(), G4UnitDefinition::GetValueOf(), G4VScoringMesh::SetFilter(), and G4UImessenger::StoD().

Referenced by SetNewValue().

00520                                                                                                {
00521     G4String& name = token[0];
00522     G4double  elow = StoD(token[1]);
00523     G4double  ehigh= StoD(token[2]);
00524     G4double  unitVal = G4UnitDefinition::GetValueOf(token[3]);
00525     G4SDParticleWithEnergyFilter* filter = 
00526         new G4SDParticleWithEnergyFilter(name,elow*unitVal,ehigh*unitVal);
00527     for ( G4int i = 4; i < (G4int)token.size(); i++){
00528         filter->add(token[i]);
00529     }
00530     mesh->SetFilter(filter);
00531 }

G4String G4ScoreQuantityMessenger::GetCurrentValue ( G4UIcommand  )  [virtual]

Reimplemented from G4UImessenger.

Definition at line 488 of file G4ScoreQuantityMessenger.cc.

00489 {
00490   G4String val;
00491 
00492   return val;
00493 }

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

Reimplemented from G4UImessenger.

Definition at line 212 of file G4ScoreQuantityMessenger.cc.

References boxMesh, CheckMeshPS(), cylinderMesh, G4PSFlatSurfaceFlux::DivideByArea(), G4PSFlatSurfaceCurrent::DivideByArea(), G4PSTrackLength::DivideByVelocity(), FillTokenVec(), FParticleCommand(), FParticleWithEnergyCommand(), G4cerr, G4cout, G4endl, G4UIcommand::GetCommandPath(), G4ScoringManager::GetCurrentMesh(), G4VScoringMesh::GetCurrentPSUnit(), G4VScoringMesh::IsCurrentPrimitiveScorerNull(), G4PSTrackLength::MultiplyKineticEnergy(), G4VScoringMesh::SetCurrentPrimitiveScorer(), G4VScoringMesh::SetCurrentPSUnit(), G4VScoringMesh::SetFilter(), G4PSMinKinEAtGeneration::SetUnit(), G4PSFlatSurfaceFlux::SetUnit(), G4PSFlatSurfaceCurrent::SetUnit(), G4PSTrackLength::SetUnit(), G4PSEnergyDeposit::SetUnit(), G4PSCellCharge::SetUnit(), G4UImessenger::StoB(), G4UImessenger::StoD(), G4UImessenger::StoI(), G4PSTermination::Weighted(), G4PSPopulation::Weighted(), G4PSNofCollision::Weighted(), G4PSFlatSurfaceFlux::Weighted(), G4PSFlatSurfaceCurrent::Weighted(), G4PSPassageTrackLength::Weighted(), G4PSPassageCellCurrent::Weighted(), and G4PSTrackLength::Weighted().

00213 {
00214       //
00215       // Get Current Mesh
00216       //
00217       G4VScoringMesh* mesh = fSMan->GetCurrentMesh();
00218       if(!mesh)
00219       {
00220         G4cerr << "ERROR : No mesh is currently open. Open/create a mesh first. Command ignored." << G4endl;
00221         return;
00222       }
00223       // Tokens
00224       G4TokenVec token;
00225       FillTokenVec(newVal,token);
00226       //
00227       // Commands for Current Mesh
00228       if(command==qTouchCmd) {
00229               mesh->SetCurrentPrimitiveScorer(newVal);
00230       } else if(command == qGetUnitCmd ){
00231           G4cout << "Unit:  "<< mesh->GetCurrentPSUnit() <<G4endl;
00232       } else if(command == qSetUnitCmd ){
00233           mesh->SetCurrentPSUnit(newVal);
00234       } else if(command== qCellChgCmd) {
00235           if ( CheckMeshPS(mesh,token[0]) ){
00236               G4PSCellCharge3D* ps = new G4PSCellCharge3D(token[0]);
00237               ps->SetUnit(token[1]);
00238               mesh->SetPrimitiveScorer(ps);
00239           }
00240       } else if(command== qCellFluxCmd) {
00241           if ( CheckMeshPS(mesh,token[0]) ){
00242             if( mesh->GetShape()==boxMesh ) {
00243               G4PSCellFlux3D* ps = new G4PSCellFlux3D(token[0]);
00244               ps->SetUnit(token[1]);
00245               mesh->SetPrimitiveScorer(ps);
00246             } else if( mesh->GetShape()==cylinderMesh ) {
00247               G4PSCellFluxForCylinder3D* ps = 
00248                 new G4PSCellFluxForCylinder3D(token[0]);
00249               ps->SetUnit(token[1]);
00250               G4ThreeVector msize = mesh->GetSize(); // gevin in R Z N/A
00251               ps->SetCylinderSize(msize[0],msize[1]); // given in dr dz
00252               G4int nSeg[3];
00253               mesh->GetNumberOfSegments(nSeg);
00254               ps->SetNumberOfSegments(nSeg);
00255               mesh->SetPrimitiveScorer(ps);
00256             }
00257           }
00258       } else if(command== qPassCellFluxCmd) {
00259           if ( CheckMeshPS(mesh,token[0]) ){
00260             if( mesh->GetShape()==boxMesh ) {
00261               G4PSPassageCellFlux3D* ps = new G4PSPassageCellFlux3D(token[0]);
00262               ps->SetUnit(token[1]);
00263               mesh->SetPrimitiveScorer(ps);
00264             } else if( mesh->GetShape()==cylinderMesh ) {
00265               G4PSPassageCellFluxForCylinder3D* ps = 
00266                 new G4PSPassageCellFluxForCylinder3D(token[0]);
00267               ps->SetUnit(token[1]);
00268               G4ThreeVector msize = mesh->GetSize();  // gevin in R Z N/A
00269               ps->SetCylinderSize(msize[0],msize[1]); // given in dr dz
00270               G4int nSeg[3];
00271               mesh->GetNumberOfSegments(nSeg);
00272               ps->SetNumberOfSegments(nSeg);
00273               mesh->SetPrimitiveScorer(ps);
00274             }
00275           }
00276       } else if(command==qeDepCmd) {
00277           if ( CheckMeshPS(mesh,token[0]) ){
00278               G4PSEnergyDeposit3D* ps =new G4PSEnergyDeposit3D(token[0]);
00279               ps->SetUnit(token[1]);
00280               mesh->SetPrimitiveScorer(ps);
00281           }
00282       } else if(command== qdoseDepCmd) {
00283           if ( CheckMeshPS(mesh,token[0]) ){
00284             if( mesh->GetShape()==boxMesh ) {
00285               G4PSDoseDeposit3D* ps = new G4PSDoseDeposit3D(token[0]);
00286               ps->SetUnit(token[1]);
00287               mesh->SetPrimitiveScorer(ps);
00288             } else if( mesh->GetShape()==cylinderMesh ) {
00289               G4PSDoseDepositForCylinder3D* ps = 
00290                 new G4PSDoseDepositForCylinder3D(token[0]);
00291               ps->SetUnit(token[1]);
00292               G4ThreeVector msize = mesh->GetSize(); // gevin in R Z N/A
00293               ps->SetCylinderSize(msize[0],msize[1]); // given in dr dz
00294               G4int nSeg[3];
00295               mesh->GetNumberOfSegments(nSeg);
00296               ps->SetNumberOfSegments(nSeg);
00297               mesh->SetPrimitiveScorer(ps);
00298             }
00299           }
00300       } else if(command== qnOfStepCmd) {
00301           if ( CheckMeshPS(mesh,token[0]) ){
00302               G4PSNofStep3D* ps = new G4PSNofStep3D(token[0]);
00303               mesh->SetPrimitiveScorer(ps);
00304           }
00305       } else if(command== qnOfSecondaryCmd) {
00306           if ( CheckMeshPS(mesh,token[0]) ){
00307               G4PSNofSecondary3D* ps =new G4PSNofSecondary3D(token[0]);
00308               mesh->SetPrimitiveScorer(ps);
00309           }
00310       } else if(command== qTrackLengthCmd) {
00311           if ( CheckMeshPS(mesh,token[0]) ){
00312               G4PSTrackLength3D* ps = new G4PSTrackLength3D(token[0]);
00313               ps->Weighted(StoB(token[1]));
00314               ps->MultiplyKineticEnergy(StoB(token[2]));
00315               ps->DivideByVelocity(StoB(token[3]));
00316               ps->SetUnit(token[4]);
00317               mesh->SetPrimitiveScorer(ps);
00318           }
00319       } else if(command== qPassCellCurrCmd){
00320           if( CheckMeshPS(mesh,token[0]) ) {
00321               G4PSPassageCellCurrent* ps = new G4PSPassageCellCurrent3D(token[0]);
00322               ps->Weighted(StoB(token[1]));
00323               //ps->SetUnit(token[2]);
00324               mesh->SetPrimitiveScorer(ps);
00325           }
00326       } else if(command== qPassTrackLengthCmd){
00327           if( CheckMeshPS(mesh,token[0]) ) {
00328               G4PSPassageTrackLength* ps = new G4PSPassageTrackLength3D(token[0]);
00329               ps->Weighted(StoB(token[1]));
00330               mesh->SetPrimitiveScorer(ps);
00331           }
00332       } else if(command== qFlatSurfCurrCmd){
00333           if( CheckMeshPS(mesh,token[0])) {
00334               G4PSFlatSurfaceCurrent3D* ps = 
00335                 new G4PSFlatSurfaceCurrent3D(token[0],StoI(token[1]));
00336               ps->Weighted(StoB(token[2]));
00337               ps->DivideByArea(StoB(token[3]));
00338               if ( StoB(token[3]) ){
00339                 ps->SetUnit(token[4]);
00340               }else{
00341                 ps->SetUnit("");
00342               }
00343               mesh->SetPrimitiveScorer(ps);
00344           }
00345       } else if(command== qFlatSurfFluxCmd){
00346           if( CheckMeshPS(mesh, token[0] )) {
00347               G4PSFlatSurfaceFlux3D* ps = new G4PSFlatSurfaceFlux3D(token[0],StoI(token[1]));
00348               ps->Weighted(StoB(token[2]));
00349               ps->DivideByArea(StoB(token[3]));
00350               if ( StoB(token[3]) ){
00351                 ps->SetUnit(token[4]);
00352               }else{
00353                 ps->SetUnit("");
00354               }
00355               mesh->SetPrimitiveScorer(ps);
00356           }
00357 //    } else if(command== qSphereSurfCurrCmd){
00358 //        if( CheckMeshPS(mesh, token[0] )) {
00359 //            G4PSSphereSurfaceCurrent3D* ps = 
00360 //              new G4PSSphereSurfaceCurrent3D(token[0],StoI(token[1]));
00361 //            ps->Weighted(StoB(token[2]));
00362 //            ps->DivideByArea(StoB(token[3]));
00363 //            if ( StoB(token[3]) ){
00364 //              ps->SetUnit(token[4]);
00365 //            }else{
00366 //              ps->SetUnit("");
00367 //            }
00368 //            mesh->SetPrimitiveScorer(ps);
00369 //        }
00370 //   } else if(command== qSphereSurfFluxCmd){
00371 //        if( CheckMeshPS(mesh,token[0])) {
00372 //            G4PSSphereSurfaceFlux3D* ps = new G4PSSphereSurfaceFlux3D(token[0], StoI(token[1]));
00373 //            ps->Weighted(StoB(token[2]));
00374 //            ps->DivideByArea(StoB(token[3]));
00375 //            if ( StoB(token[3]) ){
00376 //              ps->SetUnit(token[4]);
00377 //            }else{
00378 //              ps->SetUnit("");
00379 //            }
00380 //            mesh->SetPrimitiveScorer(ps);
00381 //        }
00382 //   } else if(command== qCylSurfCurrCmd){
00383 //        if( CheckMeshPS(mesh, token[0] ) ) {
00384 //            G4PSCylinderSurfaceCurrent3D* ps = 
00385 //              new G4PSCylinderSurfaceCurrent3D(token[0],StoI(token[1]));
00386 //            ps->Weighted(StoB(token[2]));
00387 //            ps->DivideByArea(StoB(token[3]));
00388 //            if ( StoB(token[3]) ){
00389 //              ps->SetUnit(token[4]);
00390 //            }else{
00391 //              ps->SetUnit("");
00392 //            }
00393 //            ps->SetUnit(token[4]);
00394 //            mesh->SetPrimitiveScorer(ps);
00395 //        }
00396 //   } else if(command== qCylSurfFluxCmd){
00397 //        if( CheckMeshPS(mesh, token[0] ) {
00398 //            G4PSCylinerSurfaceFlux3D* ps =new G4PSCylinderSurfaceFlux3D(token[0], StoI(token[1]));
00399 //            ps->Weighted(StoB(token[2]));
00400 //            ps->DivideByArea(StoB(token[3]));
00401 //            if ( StoB(token[3]) ){
00402 //              ps->SetUnit(token[4]);
00403 //            }else{
00404 //              ps->SetUnit("");
00405 //            }
00406 //            mesh->SetPrimitiveScorer(ps);
00407 //        }
00408       } else if(command== qNofCollisionCmd){
00409           if( CheckMeshPS(mesh,token[0])) {
00410               G4PSNofCollision3D* ps =new G4PSNofCollision3D(token[0]); 
00411               ps->Weighted(StoB(token[1]));
00412               mesh->SetPrimitiveScorer(ps);
00413           }
00414       } else if(command== qPopulationCmd){
00415           if( CheckMeshPS(mesh,token[0]) ) {
00416               G4PSPopulation3D* ps =new G4PSPopulation3D(token[0]); 
00417               ps->Weighted(StoB(token[1]));
00418               mesh->SetPrimitiveScorer(ps);
00419           }
00420       } else if(command== qTrackCountCmd){
00421           if( CheckMeshPS(mesh,token[0])) {
00422               G4PSTrackCounter3D* ps =new G4PSTrackCounter3D(token[0],StoI(token[1])); 
00423               mesh->SetPrimitiveScorer(ps);
00424           }
00425       } else if(command== qTerminationCmd){
00426           if( CheckMeshPS(mesh,token[0])) {
00427               G4PSTermination3D* ps =new G4PSTermination3D(token[0]); 
00428               ps->Weighted(StoB(token[1]));
00429               mesh->SetPrimitiveScorer(ps);
00430           }
00431 
00432       } else if(command== qMinKinEAtGeneCmd){
00433           if( CheckMeshPS(mesh,token[0]) ){
00434               G4PSMinKinEAtGeneration3D* ps =new G4PSMinKinEAtGeneration3D(token[0]); 
00435               ps->SetUnit(token[1]);
00436               mesh->SetPrimitiveScorer(ps);
00437           }
00438       } else if(command== qStepCheckerCmd){
00439           if( CheckMeshPS(mesh,token[0]) ){
00440               G4PSStepChecker3D* ps =new G4PSStepChecker3D(token[0]); 
00441               mesh->SetPrimitiveScorer(ps);
00442           }
00443 
00444             //
00445             // Filters 
00446             // 
00447       }else if(command== fchargedCmd){
00448             if(!mesh->IsCurrentPrimitiveScorerNull()) {
00449               mesh->SetFilter(new G4SDChargedFilter(token[0])); 
00450             } else {
00451               G4cout << "WARNING[" << fchargedCmd->GetCommandPath()
00452                      << "] : Current quantity is not set. Set or touch a quantity first." << G4endl;
00453             }
00454       }else if(command== fneutralCmd){
00455             if(!mesh->IsCurrentPrimitiveScorerNull()) {
00456               mesh->SetFilter(new G4SDNeutralFilter(token[0])); 
00457             } else {
00458               G4cout << "WARNING[" << fneutralCmd->GetCommandPath()
00459                      << "] : Current quantity is not set. Set or touch a quantity first." << G4endl;
00460             }
00461       }else if(command== fkinECmd){
00462             if(!mesh->IsCurrentPrimitiveScorerNull()) {
00463               G4String& name = token[0];
00464               G4double elow  = StoD(token[1]);
00465               G4double ehigh = StoD(token[2]);
00466               mesh->SetFilter(new G4SDKineticEnergyFilter(name,elow,ehigh));
00467             } else {
00468               G4cout << "WARNING[" << fkinECmd->GetCommandPath()
00469                      << "] : Current quantity is not set. Set or touch a quantity first." << G4endl;
00470             }
00471       }else if(command== fparticleKinECmd){
00472             if(!mesh->IsCurrentPrimitiveScorerNull()) {
00473               FParticleWithEnergyCommand(mesh,token); 
00474             } else {
00475               G4cout << "WARNING[" << fparticleKinECmd->GetCommandPath()
00476                      << "] : Current quantity is not set. Set or touch a quantity first." << G4endl;
00477             }
00478       } else if(command==fparticleCmd) {
00479             if(!mesh->IsCurrentPrimitiveScorerNull()) {
00480               FParticleCommand(mesh,token);
00481             } else {
00482               G4cout << "WARNING[" << fparticleCmd->GetCommandPath()
00483                      << "] : Current quantity is not set. Set or touch a quantity first." << G4endl;
00484             }
00485       }
00486 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:20 2013 for Geant4 by  doxygen 1.4.7