]> git.uio.no Git - u/mrichter/AliRoot.git/blame - AliGeant4/AliDetSwitchVectorMessenger.cxx
added function for drawing histograms one by one; added function for loading histogra...
[u/mrichter/AliRoot.git] / AliGeant4 / AliDetSwitchVectorMessenger.cxx
CommitLineData
2f310734 1// $Id$
2// Category: geometry
3//
4// Author: I. Hrivnacova
5//
6// Class AliDetSwitchVectorMessenger
7// ------------------------------------
8// See the class description in the header file.
9
10#include "AliDetSwitchVectorMessenger.h"
11#include "AliDetSwitchVector.h"
12#include "AliGlobals.h"
13
14#include <G4UIdirectory.hh>
15#include <G4UIcmdWithAString.hh>
16#include <G4UIcmdWithoutParameter.hh>
17
18//_____________________________________________________________________________
19AliDetSwitchVectorMessenger::AliDetSwitchVectorMessenger(
20 AliDetSwitchVector* switchVector)
21 : fDetSwitchVector(switchVector)
22{
23//
24 fSwitchOnCmd = new G4UIcmdWithAString("/aliDet/switchOn", this);
25 fSwitchOnCmd->SetGuidance("Define the module to be built.");
26 fSwitchOnCmd->SetGuidance("Available modules:");
27 G4String listAvailableDets = "NONE, ALL, ";
28 listAvailableDets
29 = listAvailableDets + fDetSwitchVector->GetAvailableDetsListWithCommas();
30 fSwitchOnCmd->SetGuidance(listAvailableDets);
31 fSwitchOnCmd->SetParameterName("module", false);
32 fSwitchOnCmd->AvailableForStates(PreInit);;
33
34 fSwitchOffCmd = new G4UIcmdWithAString("/aliDet/switchOff", this);
35 fSwitchOffCmd->SetGuidance("Define the module not to be built.");
36 fSwitchOffCmd->SetGuidance("Available modules:");
37 G4String listDetsNames = "ALL, ";
38 listDetsNames
39 = listDetsNames + fDetSwitchVector->GetDetNamesListWithCommas();
40 fSwitchOffCmd->SetGuidance(listDetsNames);
41 fSwitchOffCmd->SetParameterName("module", false);
42 fSwitchOffCmd->AvailableForStates(PreInit);;
43
44 fListCmd
45 = new G4UIcmdWithoutParameter("/aliDet/list", this);
46 fListCmd->SetGuidance("List the currently switched modules.");
47 fListCmd
48 ->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc);
49
50 fListAvailableCmd
51 = new G4UIcmdWithoutParameter("/aliDet/listAvailable", this);
52 fListAvailableCmd->SetGuidance("List all available modules.");
53 fListAvailableCmd
54 ->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc);
55
56 // set candidates list
57 SetCandidates();
58
59 // set default values to a detector
60 fDetSwitchVector->SwitchDetOn("NONE");
61}
62
63//_____________________________________________________________________________
64AliDetSwitchVectorMessenger::AliDetSwitchVectorMessenger() {
65//
66}
67
68//_____________________________________________________________________________
69AliDetSwitchVectorMessenger::AliDetSwitchVectorMessenger(
70 const AliDetSwitchVectorMessenger& right)
71{
72//
73 AliGlobals::Exception(
74 "AliDetSwitchVectorMessenger is protected from copying.");
75}
76
77//_____________________________________________________________________________
78AliDetSwitchVectorMessenger::~AliDetSwitchVectorMessenger() {
79//
80 delete fSwitchOnCmd;
81 delete fSwitchOffCmd;
82 delete fListCmd;
83 delete fListAvailableCmd;
84}
85
86// operators
87
88//_____________________________________________________________________________
89AliDetSwitchVectorMessenger&
90AliDetSwitchVectorMessenger::operator=(const AliDetSwitchVectorMessenger& right)
91{
92 // check assignement to self
93 if (this == &right) return *this;
94
95 AliGlobals::Exception(
96 "AliDetSwitchVectorMessenger is protected from assigning.");
97
98 return *this;
99}
100
101// public methods
102
103//_____________________________________________________________________________
104void AliDetSwitchVectorMessenger::SetNewValue(G4UIcommand* command,
105 G4String newValues)
106{
107// Applies command to the associated object.
108// ---
109
110 if (command == fSwitchOnCmd) {
111 fDetSwitchVector->SwitchDetOn(newValues);
112 }
113 else if (command == fSwitchOffCmd) {
114 fDetSwitchVector->SwitchDetOff(newValues);
115 }
116 else if (command == fListCmd) {
117 fDetSwitchVector->PrintSwitchedDets();
118 }
119 else if (command == fListAvailableCmd) {
120 fDetSwitchVector->PrintAvailableDets();
121 }
122}
123
124//_____________________________________________________________________________
125void AliDetSwitchVectorMessenger::SetCandidates()
126{
127// Builds candidates list.
128// ---
129
130 G4String candidatesList = "NONE ALL ";
131 candidatesList += fDetSwitchVector->GetDetNamesList();;
132 candidatesList += fDetSwitchVector->GetAvailableDetsList();
133 fSwitchOnCmd->SetCandidates(candidatesList);
134
135 candidatesList = "ALL ";
136 candidatesList += fDetSwitchVector->GetDetNamesList();;
137 fSwitchOffCmd->SetCandidates(candidatesList);
138}