Illegal application state for Carbon geometry setup

Hi all,

I am working on the hadrontherapy example in Geant4-10.06. I would like to change the geometry from proton beam to carbon beam, so I am using the following command in the Idle> state:

/geometrySetup/selectGeometry Carbon

But I am getting the following error:
illegal application state–command refused

Could you please help me on how to fix this problem? I would also like to let you know that I am new in Geant4. Also, I was trying to find a way to go to the PreInit> state in order to set the same command there, but I do not know how to do this, and if it is possible. I saw in G4 manual that the application starts being in the PreInit> state, but I never had this state. Not sure if this is related but I wanted to point it out hoping that it could help.

Thank you so much in advance!

1 Like

By default the hadrontherapy loads proton. So, after loading the geometry I think it can’t change the geometry. So, I suggest you use carbon_beamline.mac by directly implementing: ./hadrontherapy carbon_beamline.mac
You can change this macro and visulaization to get the desired results.
Regards,
Ananta

Hi,

thank you for your answer! Well when I am running the carbon_beamline.mac again I get the error message illegal application state–command refused, since the macro has inside the command /geometrySetup/selectGeometry Carbon. I am not sure what is going wrong since this command based on the G4 manual suppose to change the geometry from proton to carbon…
Any help would be very appreciated, thank you again!

Hi,
It’s strange. Did you directly type ./hadrontherapy carbon_beamline.mac ?
Regards,
Ananta

Hi,

yes! I typed ./hadrontherapy carbon_beamline.mac, it gives me the following error:

ERROR: Can not open a macro file <carbon_beamline.mac>.Set macro path with “/control/macroPath” if needed.

Then, I did ./hadrontherapy /control/macroPath macro, but says error:cannot open a macro file <control/macroPath>.Set macro path with “/control/macroPath” if needed.

Please let me know if you have any ideas on how to solve this. Thank you again!

norm

It is looking for the file named carbon_beamline.mac in your current working directory (the same directory that hadrontherapy is in). If the macro file is not there, then you need to include the directory path to find that file in your command line. For example

./hadrontherapy ../some/path/somewhere/to/find/carbon_beamline.mac

Your second attempt at invocation, which you wrote as

./hadrontherapy /control/macroPath

says that you are telling the executable to look for a macro named “macroPath” found in the top-most level subdirectory “/control” on your filesystem (like /usr, /var, etc.). I presume your system doesn’t have a /control top-level directory, hence the error.

Hi,

thank you so much for your answer and clarification. I directly run
./hadrontherapy …/pathtofind/carbon_beamline.mac
and it worked perfectly! So, please correct me if I am wrong, but I understood that I have to modify the macro file according to my needs and follow this procedure every time that I want to have carbon setup. Therefore, by using /geometrySetup/selectGeometry Carbon in the Idle> state does not effectively change the geometry from proton to carbon.

1 Like