GGS(GenericGEANT4Simulation)Software  2.6.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 
23 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
24 
26 
27  for (unsigned int iCmd = 0; iCmd < _commands.size(); iCmd++)
28  delete _commands[iCmd];
29 
30 }
31 
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 void GGSScoringManagerMessenger::CreateAddCommand(const G4String &sdClassName) {
35 
36  // Check if the command already exists
37  G4String cmdName(_cmdBaseName);
38  cmdName.append(sdClassName);
39  for (unsigned int iCmd = 0; iCmd < _commands.size(); iCmd++) {
40  if (_commands[iCmd]->GetCommandName() == cmdName)
41  return;
42  }
43 
44  // Create the command
45  G4UIcmdWithAString *newCmd = new G4UIcmdWithAString(cmdName, this);
46  newCmd->SetGuidance(
47  G4String("Add a sensitive detector of type ").append(sdClassName).append(" to the specified logical volume"));
48  newCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
49  _commands.push_back(newCmd);
50 
51 }
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
55 void GGSScoringManagerMessenger::SetNewValue(G4UIcommand *command, G4String logVolName) {
56 
57  for (unsigned int iCmd = 0; iCmd < _commands.size(); iCmd++) {
58  if (command == _commands[iCmd]) {
59  G4String sdClassName = command->GetCommandName().substr(3); // Remove "add" prefix
60  GGSScoringManager::GetInstance().AddSDToLogVol(sdClassName, logVolName);
61  }
62  }
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
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).