diff --git a/NPAnalysis/TAMU/Analysis b/NPAnalysis/TAMU/Analysis index 51b49831b4f26db0704d1cf57f594d163074da92..75ed53918899a83d526933e8f84c214ac2f4d90a 100755 Binary files a/NPAnalysis/TAMU/Analysis and b/NPAnalysis/TAMU/Analysis differ diff --git a/NPAnalysis/TAMU/Analysis.o b/NPAnalysis/TAMU/Analysis.o index 862bc1a8688665f0eed43491fc185c9ccceed7fa..0ca4757a1d2984729ca5c47d44d264bce87c9da8 100644 Binary files a/NPAnalysis/TAMU/Analysis.o and b/NPAnalysis/TAMU/Analysis.o differ diff --git a/NPSimulation/icons/aperture.png b/NPSimulation/icons/aperture.png new file mode 100644 index 0000000000000000000000000000000000000000..90fe9b3dc1bf40a8144bf91bd7d7a3a583942249 Binary files /dev/null and b/NPSimulation/icons/aperture.png differ diff --git a/NPSimulation/icons/bolt.png b/NPSimulation/icons/bolt.png new file mode 100644 index 0000000000000000000000000000000000000000..3b6ad4b0fa419857f8f65c19fe5a39ee2b2329c1 Binary files /dev/null and b/NPSimulation/icons/bolt.png differ diff --git a/NPSimulation/include/PrimaryGeneratorAction.hh b/NPSimulation/include/PrimaryGeneratorAction.hh index e067501e96dcb7eead6def085b2883b2d19bc222..b0fceae9042073e4406c1a790e99d64981840d3e 100644 --- a/NPSimulation/include/PrimaryGeneratorAction.hh +++ b/NPSimulation/include/PrimaryGeneratorAction.hh @@ -32,6 +32,7 @@ // NPTool headers #include "VEventGenerator.hh" #include "DetectorConstruction.hh" +#include "PrimaryGeneratorActionMessenger.hh" using namespace std; using namespace CLHEP; @@ -47,6 +48,7 @@ class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction{ public: void ReadEventGeneratorFile(string Path); + void ClearEventGenerator(); public: void SetTarget(); @@ -54,6 +56,7 @@ class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction{ private: DetectorConstruction* m_detector; vector<VEventGenerator*> m_EventGenerator; + PrimaryGeneratorActionMessenger* m_Messenger; }; #endif diff --git a/NPSimulation/include/PrimaryGeneratorActionMessenger.hh b/NPSimulation/include/PrimaryGeneratorActionMessenger.hh new file mode 100644 index 0000000000000000000000000000000000000000..fcec08fb1efad282c28c726d0c8d57d1622e976e --- /dev/null +++ b/NPSimulation/include/PrimaryGeneratorActionMessenger.hh @@ -0,0 +1,58 @@ +#ifndef PrimaryGeneratorActionMessenger_h +#define PrimaryGeneratorActionMessenger_h 1 +/***************************************************************************** + * Copyright (C) 2009-2013 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Adrien MATTA contact address: a.matta@surrey.ac.uk * + * * + * Creation Date : November 2014 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe the PrimaryGeneratorAction Messenger * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ +///....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "globals.hh" +#include "G4UImessenger.hh" + +class PrimaryGeneratorAction; +class G4UIdirectory; +class G4UICommand; +class G4UIcmdWithAString; +class G4UIcmdWithAnInteger; +class G4UIcmdWithADoubleAndUnit; +class G4UIcmdWithoutParameter; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +class PrimaryGeneratorActionMessenger: public G4UImessenger{ + public: + PrimaryGeneratorActionMessenger(PrimaryGeneratorAction* ); + ~PrimaryGeneratorActionMessenger(); + + void SetNewValue(G4UIcommand*, G4String); + + private: + PrimaryGeneratorAction* PGA; + + G4UIdirectory* GenDir; + G4UIcmdWithoutParameter* UpdateCmd; + G4UIcmdWithAString* OpenCmd; + +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#endif + diff --git a/NPSimulation/macro/gui.mac b/NPSimulation/macro/gui.mac index 00a720e85f0f0fa648b71823e1f921d8fde3d854..443e2618904e9b845980c9f8adf5cee0d14d9854 100644 --- a/NPSimulation/macro/gui.mac +++ b/NPSimulation/macro/gui.mac @@ -23,6 +23,8 @@ /gui/addIcon "nptool" user_icon "/gui/system {gui_nptool}" icons/NPToolLogo.png /gui/addIcon "Exit" user_icon "{gui_exit}" icons/power.png /gui/addIcon "Update geometry" user_icon "{gui_update}" icons/recycle.png +/gui/addIcon "Update generator" user_icon "/gen/update" icons/bolt.png +/gui/addIcon "Open generator" user_icon "/gen/open" icons/folder.png /gui/addIcon "There is nothing here" user_icon "{gui_empty}" icons/empty.png /gui/addIcon "Run beam on" user_icon "/run/beamOn" icons/rocket.png /gui/addIcon "One event" user_icon "{gui_beamon}" icons/play.png diff --git a/NPSimulation/src/PrimaryGeneratorAction.cc b/NPSimulation/src/PrimaryGeneratorAction.cc index c9bab29311e574e49f43dda2243b459d0a3f5231..f2569cba89eabe396fa816c97059fdb165e1ee40 100644 --- a/NPSimulation/src/PrimaryGeneratorAction.cc +++ b/NPSimulation/src/PrimaryGeneratorAction.cc @@ -58,7 +58,7 @@ PrimaryGeneratorAction::~PrimaryGeneratorAction(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* det): m_detector(det){ - + m_Messenger = new PrimaryGeneratorActionMessenger(this); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -180,6 +180,16 @@ void PrimaryGeneratorAction::ReadEventGeneratorFile(string Path){ EventGeneratorFile.close(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void PrimaryGeneratorAction::ClearEventGenerator(){ + unsigned int mysize = m_EventGenerator.size(); + for (unsigned int i = 0 ; i < mysize; i++) { + delete m_EventGenerator[i]; + } + + m_EventGenerator.clear(); + +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void PrimaryGeneratorAction::SetTarget(){ for (unsigned int i = 0 ; i < m_EventGenerator.size(); i++) { m_EventGenerator[i]->SetTarget(m_detector->GetTarget()); diff --git a/NPSimulation/src/PrimaryGeneratorActionMessenger.cc b/NPSimulation/src/PrimaryGeneratorActionMessenger.cc new file mode 100644 index 0000000000000000000000000000000000000000..9c0284d3c1c617ab62d9eae033eb791904d3b753 --- /dev/null +++ b/NPSimulation/src/PrimaryGeneratorActionMessenger.cc @@ -0,0 +1,91 @@ +/***************************************************************************** + * Copyright (C) 2009-2013 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Adrien MATTA contact address: a.matta@surrey.ac.uk * + * * + * Creation Date : November 2014 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe the PrimaryGeneratorAction Messenger * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ +///....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +#include "PrimaryGeneratorActionMessenger.hh" + +#include "PrimaryGeneratorAction.hh" +#include "G4UIparameter.hh" +#include "G4UIcommand.hh" +#include "G4UIdirectory.hh" +#include "G4UIcmdWithAString.hh" +#include "G4UIcmdWithoutParameter.hh" + +#include "NPOptionManager.h" +#include <dirent.h> + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +PrimaryGeneratorActionMessenger::PrimaryGeneratorActionMessenger(PrimaryGeneratorAction* Gen):PGA(Gen){ + GenDir = new G4UIdirectory("/gen/"); + GenDir->SetGuidance("event generator control"); + + UpdateCmd = new G4UIcmdWithoutParameter("/gen/update",this); + UpdateCmd->SetGuidance("Update the event generator"); + UpdateCmd->SetGuidance("Apply this command after editing your event generator file "); + UpdateCmd->AvailableForStates(G4State_Idle); + + DIR *dir; + struct dirent *ent; + string path = getenv("NPTOOL"); + path += "/Inputs/EventGenerator/"; + string choices; + if ((dir = opendir (path.c_str())) != NULL) { + /* print all the files and directories within directory */ + while ((ent = readdir (dir)) != NULL) { + choices += ent->d_name ; + choices += " " ; + } + closedir (dir); + } + + OpenCmd = new G4UIcmdWithAString("/gen/open",this); + OpenCmd->SetGuidance("Open a new event generator"); + OpenCmd->SetCandidates(choices.c_str()); + OpenCmd->AvailableForStates(G4State_Idle); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +PrimaryGeneratorActionMessenger::~PrimaryGeneratorActionMessenger(){ + delete UpdateCmd; + delete OpenCmd; + delete GenDir; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void PrimaryGeneratorActionMessenger::SetNewValue(G4UIcommand* command,G4String newValue){ + if( command == UpdateCmd ){ + PGA->ClearEventGenerator(); + PGA->ReadEventGeneratorFile(NPOptionManager::getInstance()->GetReactionFile()); + } + + else if( command == OpenCmd ){ + PGA->ClearEventGenerator(); + NPOptionManager::getInstance()->SetReactionFile(newValue); + PGA->ReadEventGeneratorFile(NPOptionManager::getInstance()->GetReactionFile()); + } + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......