GGS(GenericGEANT4Simulation)Software  2.7.0
 All Data Structures Namespaces Files Functions Variables Typedefs Macros
GGSScoringManagerMessenger.cpp
Go to the documentation of this file.
1 /*
2  * GGSScoringManagerMessenger.cpp
3  *
4  * Created on: 02 Aug2013
5  * Author: Nicola Mori
6  */
7 
12 
13 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
14 
16  : _cmdsDirName("/GGS/scoring/"), _cmdBaseName("/GGS/scoring/") {
17 
18  _cmdBaseName.append("add");
19  _cmdsDir = new G4UIdirectory(_cmdsDirName);
20 }
21 
22 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
23 
25 
26  for (unsigned int iCmd = 0; iCmd < _commands.size(); iCmd++)
27  delete _commands[iCmd];
28 }
29 
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 
32 void GGSScoringManagerMessenger::CreateAddCommand(const G4String &sdClassName) {
33 
34  // Check if the command already exists
35  G4String cmdName(_cmdBaseName);
36  cmdName.append(sdClassName);
37  for (unsigned int iCmd = 0; iCmd < _commands.size(); iCmd++) {
38  if (_commands[iCmd]->GetCommandName() == cmdName)
39  return;
40  }
41 
42  // Create the command
43  G4UIcmdWithAString *newCmd = new G4UIcmdWithAString(cmdName, this);
44  newCmd->SetGuidance(
45  G4String("Add a sensitive detector of type ").append(sdClassName).append(" to the specified logical volume"));
46  newCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
47  _commands.push_back(newCmd);
48 }
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51 
52 void GGSScoringManagerMessenger::SetNewValue(G4UIcommand *command, G4String logVolName) {
53 
54  for (unsigned int iCmd = 0; iCmd < _commands.size(); iCmd++) {
55  if (command == _commands[iCmd]) {
56  G4String sdClassName = command->GetCommandName().substr(3); // Remove "add" prefix
57  GGSScoringManager::GetInstance().AddSDToLogVol(sdClassName, logVolName);
58  }
59  }
60 }
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static GGSScoringManager & GetInstance()
Singleton getter.
void SetNewValue(G4UIcommand *command, G4String logVolName)
Concrete implementation of the SetNewValue method of base class.
void CreateAddCommand(const G4String &sdClassName)
Creates the command to add the specified sensitive detector class to logical volumes.
void AddSDToLogVol(const G4String &sdClassName, const G4String &logVolNameAndParams)
Adds a sensitive detector to a logical volume (class factory approach).