-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More messenger commands for physics lists #254
base: main
Are you sure you want to change the base?
Conversation
Any idea why my new macro command isn't picked up by |
That would be a very curious case, as the CI also just runs |
src/RMGHardwareMessenger.cc
Outdated
step_limit->SetGuidance("The maximum step limit"); | ||
step_limit->SetDefaultValue(1 * CLHEP::mm); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is also a way to have parameters with units, that would be nicer. Or, at least mention the unit this is in. Currently this just renders as "default value - 1" without any unit information in the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am working on it, but I had to change this into two macro commands
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now this is done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to split it in two commands... I have some example code how to use G4UIcmdWithADoubleAndUnit with extra parameters:
diff --git a/include/RMGHardwareMessenger.hh b/include/RMGHardwareMessenger.hh
index 8ee2873..bcceed3 100644
--- a/include/RMGHardwareMessenger.hh
+++ b/include/RMGHardwareMessenger.hh
@@ -17,6 +17,7 @@
#define _RMG_HARDWARE_MESSENGER_HH_
#include "G4UImessenger.hh"
+#include "G4UIcmdWithADoubleAndUnit.hh"
class RMGHardware;
class RMGHardwareMessenger : public G4UImessenger {
@@ -31,7 +32,7 @@ class RMGHardwareMessenger : public G4UImessenger {
private:
RMGHardware* fHardware;
- G4UIcommand* fRegisterCmd;
+ G4UIcmdWithADoubleAndUnit* fRegisterCmd;
void RegisterDetectorCmd(const std::string& parameters);
};
diff --git a/src/RMGHardwareMessenger.cc b/src/RMGHardwareMessenger.cc
index aa200af..1a4bdd8 100644
--- a/src/RMGHardwareMessenger.cc
+++ b/src/RMGHardwareMessenger.cc
@@ -17,14 +17,19 @@
#include "G4Tokenizer.hh"
#include "G4UIcommand.hh"
+#include "G4UIcmdWithADoubleAndUnit.hh"
#include "RMGHardware.hh"
#include "RMGTools.hh"
RMGHardwareMessenger::RMGHardwareMessenger(RMGHardware* hw) : fHardware(hw) {
- fRegisterCmd = new G4UIcommand("/RMG/Geometry/RegisterDetector", this);
+ fRegisterCmd = new G4UIcmdWithADoubleAndUnit("/RMG/Geometry/RegisterDetector", this);
fRegisterCmd->SetGuidance("register a sensitive detector");
+ fRegisterCmd->SetParameterName("test", false);
+ fRegisterCmd->SetDefaultValue(5);
+ fRegisterCmd->SetUnitCategory("Length");
+
auto p_type = new G4UIparameter("type", 's', false);
p_type->SetParameterCandidates(RMGTools::GetCandidates<RMGDetectorType>().c_str());
p_type->SetGuidance("Detector type");
@@ -59,9 +64,15 @@ void RMGHardwareMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
}
void RMGHardwareMessenger::RegisterDetectorCmd(const std::string& parameters) {
+ RMGLog::Out(RMGLog::error, "params ", parameters);
G4Tokenizer next(parameters);
+ auto x = next();
+ auto y = next();
+ auto num = G4UIcmdWithADoubleAndUnit::GetNewDoubleValue((x + " " + y).c_str());
+
auto type_str = next();
+ RMGLog::Out(RMGLog::fatal, " num ", num);
auto type = RMGTools::ToEnum<RMGDetectorType>(std::string(type_str), "detector type");
auto pv_name = next();
const int uid = std::stoi(next());
Seems good to me. |
I would wait until its more tested to merge. |
I need to test it