EDepSimComponentBuilder.hh
Go to the documentation of this file.
1 #ifndef EDepSim_ComponentBuilder_hh_seen
2 #define EDepSim_ComponentBuilder_hh_seen
3 // $Id: EDepSim::ComponentBuilder.hh,v 1.7 2009/02/12 17:16:40 mcgrew Exp $
4 //
5 
6 #include <G4ThreeVector.hh>
7 class G4LogicalVolume;
8 
9 #include "EDepSimBuilder.hh"
10 #include "EDepSimSDFactory.hh"
11 #include "EDepSimSegmentSD.hh"
12 
13 class G4VSensitiveDetector;
14 
15 /// Construct a component to be used by a EDepSim::ModuleBuilder to build a
16 /// component.
17 namespace EDepSim {class ComponentBuilder;}
19 public:
21  : EDepSim::Builder(n,c), fLength(0.0),
22  fMaximumWidth(0.0), fMaximumHeight(0.0) {}
24  : EDepSim::Builder(n,p), fLength(0.0),
25  fMaximumWidth(0.0), fMaximumHeight(0.0) {}
26  virtual ~ComponentBuilder() {;};
27 
28  /// Set the width of the component. This is the X dimension of the space
29  /// available for the component and may be relative to the outside geometry.
30  /// The width is set by the EDepSim::ModuleBuilder object which will
31  /// contain this component, so it should not be directly set in user code.
32  /// The actual constructed component width must be less than the width set
33  /// by the owning EDepSim::ModuleBuilder.
34  virtual void SetWidth(double w) {fWidth = w;}
35 
36  /// Get the width of the component. This is the X dimension of the space
37  /// available for the component and may be relative to the outside geometry.
38  /// The width is set by the EDepSim::ModuleBuilder object which will
39  /// contain this component. The actual constructed component width must
40  /// be less than the width set by the owning EDepSim::ModuleBuilder.
41  virtual double GetWidth(void) {return fWidth;}
42 
43  /// Set the physical width of the component, this may be smaller than the
44  /// available width set in SetWidth. This is the X dimension of the
45  /// component.
46  virtual void SetMaximumWidth(double w) {fMaximumWidth = w;}
47 
48  /// Set the height of the component. This is the Y dimension of the space
49  /// available for the component and may be relative to the outside
50  /// geometry. The height is set by the EDepSim::ModuleBuilder object
51  /// which will contain this component, so it should not be directly set in
52  /// user code. The actual constructed component height must be less than
53  /// the height set by the owning EDepSim::ModuleBuilder.
54  virtual void SetHeight(double w) {fHeight = w;}
55 
56  /// Get the height of the component. This is the Y dimension of the space
57  /// available for the component and may be relative to the outside
58  /// geometry. The actual constructed component height must be less than
59  /// the height set by the owning EDepSim::ModuleBuilder.
60  virtual double GetHeight(void) {return fHeight;}
61 
62  /// Get the length of the component.
63  virtual double GetLength(void) {return fLength;}
64 
65  /// Set the length of the component.
66  virtual void SetLength(double t) {fLength = t;}
67 
68  /// Set the physical height of the component, this must be less than or
69  /// equal to the available height set in SetHeight (by the parent
70  /// EDepSim::ModuleBuilder object). This is the Y dimension of the
71  /// component.
72  virtual void SetMaximumHeight(double h) {fMaximumHeight = h;}
73 
74  /// This is the width of the component that will be actually constructed.
75  /// This can be used in GetPiece() to find the size of the bounding box.
76  virtual double GetPhysicalWidth() {
77  double w = fWidth;
79  return w;
80  }
81 
82  /// This is the height of the component that will be actually constructed.
83  /// This can be used in GetPiece() to find the size of the bounding box.
84  virtual double GetPhysicalHeight() {
85  double h = fHeight;
87  return h;
88  }
89 
90 protected:
91  /// Increment the length of the component. This is the distance the
92  /// component stretchs along the Z axis of the detector.
93  virtual void AddLength(double t) {fLength += t;};
94 
95 private:
96  /// The available width of the component in the X direction.
97  double fWidth;
98 
99  /// The available height of the component in the Y direction.
100  double fHeight;
101 
102  /// The length of the component along the Z axis.
103  double fLength;
104 
105  /// The maximum physical width of the constructed component. This must be
106  /// less than the available width.
108 
109  /// The maximum physical height of the constructed component. This must be
110  /// less than the available height.
112 };
113 
114 namespace EDepSim {class ComponentBuilderMessenger;}
116 private:
118  G4UIcmdWithADoubleAndUnit* fWidthCMD;
119  G4UIcmdWithADoubleAndUnit* fHeightCMD;
120  G4UIcmdWithADoubleAndUnit* fMaxWidthCMD;
121  G4UIcmdWithADoubleAndUnit* fMaxHeightCMD;
122 
123 public:
125  const char* guide)
126  : EDepSim::BuilderMessenger(c,guide),
127  fBuilder(c) {
128 
129  fWidthCMD = new G4UIcmdWithADoubleAndUnit(CommandName("width"),this);
130  fWidthCMD->SetGuidance("Set the width of the component.");
131  fWidthCMD->SetParameterName("Width",false);
132  fWidthCMD->SetUnitCategory("Length");
133 
134  fHeightCMD = new G4UIcmdWithADoubleAndUnit(CommandName("height"),this);
135  fHeightCMD->SetGuidance("Set the height of the component.");
136  fHeightCMD->SetParameterName("Height",false);
137  fHeightCMD->SetUnitCategory("Length");
138 
139  fMaxWidthCMD
140  = new G4UIcmdWithADoubleAndUnit(CommandName("maxWidth"),this);
141  fMaxWidthCMD->SetGuidance("Set the maximum width of the component.");
142  fMaxWidthCMD->SetParameterName("Width",false);
143  fMaxWidthCMD->SetUnitCategory("Length");
144 
145  fMaxHeightCMD
146  = new G4UIcmdWithADoubleAndUnit(CommandName("maxHeight"),this);
147  fMaxHeightCMD->SetGuidance("Set the maximum height of the component.");
148  fMaxHeightCMD->SetParameterName("Height",false);
149  fMaxHeightCMD->SetUnitCategory("Length");
150 
151  };
152 
154  delete fWidthCMD;
155  delete fHeightCMD;
156  delete fMaxWidthCMD;
157  delete fMaxHeightCMD;
158  };
159 
160  void SetNewValue(G4UIcommand *cmd, G4String val) {
161  if (cmd==fWidthCMD) {
162  fBuilder->SetWidth(fWidthCMD->GetNewDoubleValue(val));
163  }
164  else if (cmd==fHeightCMD) {
165  fBuilder->SetHeight(fHeightCMD->GetNewDoubleValue(val));
166  }
167  else if (cmd==fMaxWidthCMD) {
168  fBuilder->
169  SetMaximumWidth(fMaxWidthCMD->GetNewDoubleValue(val));
170  }
171  else if (cmd==fMaxHeightCMD) {
172  fBuilder->
173  SetMaximumHeight(fMaxHeightCMD->GetNewDoubleValue(val));
174  }
175  else {
177  }
178  };
179 };
180 #endif
void SetNewValue(G4UIcommand *cmd, G4String val)
virtual void SetHeight(double w)
Construct a module from components.
Definition: TG4HitSegment.h:10
std::void_t< T > n
ComponentBuilder(G4String n, EDepSim::Builder *p)
p
Definition: test.py:223
virtual void SetLength(double t)
Set the length of the component.
virtual void SetMaximumHeight(double h)
G4UIcmdWithADoubleAndUnit * fMaxHeightCMD
double fWidth
The available width of the component in the X direction.
double fLength
The length of the component along the Z axis.
void SetNewValue(G4UIcommand *cmd, G4String val)
ComponentBuilderMessenger(EDepSim::ComponentBuilder *c, const char *guide)
list cmd
Definition: getreco.py:22
ComponentBuilder(G4String n, EDepSim::UserDetectorConstruction *c)
virtual void AddLength(double t)
virtual void SetMaximumWidth(double w)
virtual void SetWidth(double w)
virtual double GetLength(void)
Get the length of the component.
double fHeight
The available height of the component in the Y direction.
G4UIcmdWithADoubleAndUnit * fMaxWidthCMD