EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
eASTDetectorComponentMessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file eASTDetectorComponentMessenger.cc
1 // ********************************************************************
2 //
3 // eASTDetectorComponentMessenger.cc
4 // A messenger class that handles geometry configuration.
5 //
6 // History
7 // May 8th, 2021 : first implementation
8 //
9 // ********************************************************************
10 
12 
14 #include "G4UIcommand.hh"
15 #include "G4UIparameter.hh"
16 #include "G4UIcmdWithAnInteger.hh"
17 #include "G4UIcmdWith3VectorAndUnit.hh"
18 #include "G4Tokenizer.hh"
19 
21  (eASTVDetectorComponent* dc, G4String compName)
22 : pDC(dc)
23 {
24  G4String comName = "/eAST/component/"+compName;
25  setupCmd = new G4UIcmdWithAnInteger(comName,this);
26  G4String msg = "Activate ";
27  msg += compName;
28  setupCmd->SetGuidance(msg);
29  setupCmd->SetParameterName("verboselevel",true);
30  setupCmd->SetDefaultValue(0);
31  setupCmd->SetRange("verboselevel>=0");
32  setupCmd->AvailableForStates(G4State_PreInit);
33  setupCmd->SetToBeBroadcasted(false);
34 }
35 
37 {
38  G4String com = comDir+"locate";
39  locCmd = new G4UIcmdWith3VectorAndUnit(com,this);
40  locCmd->SetGuidance("Locate the component in the global coordinate.");
41  locCmd->SetParameterName("x","y","z",false);
42  locCmd->SetDefaultUnit("mm");
43  locCmd->AvailableForStates(G4State_PreInit);
44  locCmd->SetToBeBroadcasted(false);
45 
46  com = comDir+"rotate";
47  rotCmd = new G4UIcommand(com,this);
48  rotCmd->SetGuidance("Rotate the component in the global coordinate.");
49  auto param = new G4UIparameter("axis",'s',false);
50  param->SetParameterCandidates("x y z");
51  rotCmd->SetParameter(param);
52  param = new G4UIparameter("angle",'d',false);
53  rotCmd->SetParameter(param);
54  param = new G4UIparameter("unit",'s',true);
55  param->SetDefaultUnit("deg");
56  rotCmd->SetParameter(param);
57  rotCmd->AvailableForStates(G4State_PreInit);
58  rotCmd->SetToBeBroadcasted(false);
59 }
60 
62 {
63  delete locCmd;
64  delete rotCmd;
65  delete setupCmd;
66 }
67 
68 void eASTDetectorComponentMessenger::SetNewValue(G4UIcommand* cmd, G4String val)
69 {
70  if(cmd==setupCmd)
71  { pDC->SetUpBase(setupCmd->GetNewIntValue(val)); }
72  else if(cmd==locCmd)
73  { pDC->SetLocation(locCmd->GetNew3VectorValue(val)); }
74  else if(cmd==rotCmd)
75  {
76  G4Tokenizer next(val);
77  G4String ax = next();
78  G4double ang = StoD(next()) * G4UIcommand::ValueOf(next());
79  pDC->SetRotation(ax,ang);
80  }
81 }
82 
84 {
85  G4String val("");
86  return val;
87 }
88 
89