-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add command /RMG/Geometry/RegisterDetector
- Loading branch information
Showing
5 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (C) 2022 Luigi Pertoldi <[email protected]> | ||
// | ||
// This program is free software: you can redistribute it and/or modify it under | ||
// the terms of the GNU Lesser General Public License as published by the Free | ||
// Software Foundation, either version 3 of the License, or (at your option) any | ||
// later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, but WITHOUT | ||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
// details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
#ifndef _RMG_HARDWARE_MESSENGER_HH_ | ||
#define _RMG_HARDWARE_MESSENGER_HH_ | ||
|
||
#include "G4UImessenger.hh" | ||
|
||
class RMGHardware; | ||
class RMGHardwareMessenger : public G4UImessenger { | ||
|
||
public: | ||
|
||
RMGHardwareMessenger(RMGHardware* hw); | ||
~RMGHardwareMessenger(); | ||
|
||
void SetNewValue(G4UIcommand* command, G4String newValues); | ||
|
||
private: | ||
|
||
RMGHardware* fHardware; | ||
G4UIcommand* fRegisterCmd; | ||
}; | ||
|
||
#endif | ||
|
||
// vim: tabstop=2 shiftwidth=2 expandtab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (C) 2022 Luigi Pertoldi <[email protected]> | ||
// | ||
// This program is free software: you can redistribute it and/or modify it under | ||
// the terms of the GNU Lesser General Public License as published by the Free | ||
// Software Foundation, either version 3 of the License, or (at your option) any | ||
// later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, but WITHOUT | ||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
// details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
#include "RMGHardwareMessenger.hh" | ||
|
||
#include "RMGHardware.hh" | ||
|
||
#ifndef FMT_HEADER_ONLY | ||
#define FMT_HEADER_ONLY | ||
#endif | ||
#include "fmt/core.h" | ||
#include "magic_enum/magic_enum.hpp" | ||
|
||
RMGHardwareMessenger::RMGHardwareMessenger(RMGHardware* hw) : fHardware(hw) { | ||
auto detector_types = magic_enum::enum_names<RMGHardware::DetectorType>(); | ||
auto options = fmt::format("{}", fmt::join(detector_types, "|")); | ||
|
||
fRegisterCmd = new G4UIcommand("/RMG/Geometry/RegisterDetector", this); | ||
fRegisterCmd->SetGuidance("register a sensitive detector"); | ||
fRegisterCmd->SetGuidance("[usage] /RMG/Geometry/RegisterDetector T PV ID [C]"); | ||
fRegisterCmd->SetGuidance(fmt::format(" T:(str) {}", options).c_str()); | ||
fRegisterCmd->SetGuidance(" PV:(s) physvol"); | ||
fRegisterCmd->SetGuidance(" ID:(int) unique detector id"); | ||
fRegisterCmd->SetGuidance(" C:(int) copy nr (default 0)"); | ||
|
||
fRegisterCmd->SetParameter(new G4UIparameter("type", 's', false)); | ||
fRegisterCmd->SetParameter(new G4UIparameter("pv_name", 's', false)); | ||
fRegisterCmd->SetParameter(new G4UIparameter("uid", 'i', false)); | ||
fRegisterCmd->SetParameter(new G4UIparameter("copy_nr", 'i', true)); | ||
|
||
fRegisterCmd->AvailableForStates(G4State_PreInit); | ||
} | ||
|
||
RMGHardwareMessenger::~RMGHardwareMessenger() { delete fRegisterCmd; } | ||
|
||
void RMGHardwareMessenger::SetNewValue(G4UIcommand* command, G4String newValues) { | ||
if (command == fRegisterCmd) fHardware->RegisterDetectorCmd(newValues); | ||
} | ||
|
||
// vim: tabstop=2 shiftwidth=2 expandtab |