Message: adding a command in G4UserPhysicsListMessenger Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Idea adding a command in G4UserPhysicsListMessenger 

Forum: Run Management
Date: 21 Sep, 2009
From: Mathieu Trocmé <Mathieu Trocmé>

Hi there, 

I like playing with cuts for each of my particles and I'm a bit tired of creating a new PhysicsListMessenger each time. 
Could it be possible to add the following command to G4UserPhysicsListMessenger?
(I tested it by recompiling my g4.3.9.b01. No probs.)


G4UserPhysicsListMessenger::G4UserPhysicsListMessenger(G4VUserPhysicsList* pParticleList):thePhysicsList(pParticleList)
{
//...

// /run/setCutForAGivenParticle command
  setCutForAGivenParticleCmd = new G4UIcommand("/run/setCutForAGivenParticle",this) ;
  setCutForAGivenParticleCmd->SetGuidance("Set a cut value to a specific particle") ;
  setCutForAGivenParticleCmd->SetGuidance("Usage: /run/setCutForAGivenParticle  gamma  1. mm") ;
    param = new G4UIparameter("particleName",'s',false) ;
      param->SetGuidance("To get the list of available particles, you can type: /particle/list all") ;
      setCutForAGivenParticleCmd->SetParameter(param) ;
    param = new G4UIparameter("cut",'d',false) ;
      param->SetDefaultValue("1.") ;
      param->SetParameterRange("cut>0.0") ;
      setCutForAGivenParticleCmd->SetParameter(param) ;
    param = new G4UIparameter("unit",'s',false) ;
      param->SetDefaultValue("mm") ;
      setCutForAGivenParticleCmd->SetParameter(param) ;
  setCutForAGivenParticleCmd->AvailableForStates(G4State_PreInit,G4State_Idle);

//...
}


G4UserPhysicsListMessenger::~G4UserPhysicsListMessenger()
{
// ...
  delete setCutForAGivenParticleCmd;
// ...
}


void G4UserPhysicsListMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
{
// ...    
  } else if( command==setCutForAGivenParticleCmd ){
    G4String particleName, unit ; G4double cut ;
    std::istringstream str (newValue) ;
    str >> particleName >> cut >> unit ;
    if ( (G4ParticleTable::GetParticleTable())->FindParticle(particleName) == NULL ) {
      G4Exception( G4String("\n!!!\n!!! Error in /run/setCutForAGivenParticle: Particle '" + particleName + "' is not defined! \n!!!").c_str() ) ;
    } else { 
      thePhysicsList->SetCutValue(cut*G4UIcommand::ValueOf(unit), particleName) ; 
    }
  } // else if ...
}


Thanks, 
Mathieu

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: adding a command in G4UserPhysicsListMessenger   (Mathieu Trocmé - 29 Sep, 2009)
1 None: Re: adding a command in G4UserPhysicsListMessenger   (Mathieu Trocmé - 29 Sep, 2009)
2 Agree: Re: adding a command in G4UserPhysicsListMessenger   (Gumplinger Peter - 29 Oct, 2009)
1 None: Re: adding a command in G4UserPhysicsListMessenger   (Mathieu Trocmé - 29 Apr, 2010)
(_ Feedback: Re: adding a command in G4UserPhysicsListMessenger   (Hisaya Kurashige - 29 Apr, 2010)
(_ None: Re: adding a command in G4UserPhysicsListMessenger   (Mathieu Trocmé - 30 Apr, 2010)
(_ Note: Re: adding a command in G4UserPhysicsListMessenger   (Hisaya Kurashige - 30 Apr, 2010)
(_ None: Re: adding a command in G4UserPhysicsListMessenger   (Mathieu Trocmé - 01 May, 2010)
 Add Message Add Message
to: "adding a command in G4UserPhysicsListMessenger"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]