10 #include <G4Material.hh> 11 #include <G4LogicalVolume.hh> 12 #include <G4VPhysicalVolume.hh> 13 #include <G4PVPlacement.hh> 14 #include <G4RotationMatrix.hh> 15 #include <G4VisAttributes.hh> 16 #include <G4UserLimits.hh> 17 #include <G4FieldManager.hh> 19 #include <G4SystemOfUnits.hh> 20 #include <G4PhysicalConstants.hh> 22 #include <G4Polyhedra.hh> 38 =
new G4UIcmdWithADoubleAndUnit(
CommandName(
"apothem"),
this);
39 fApothemCMD->SetGuidance(
"Set the apothem of the drift region.");
40 fApothemCMD->SetParameterName(
"apothem",
false);
41 fApothemCMD->SetUnitCategory(
"Length");
43 fDriftLengthCMD =
new G4UIcmdWithADoubleAndUnit(
45 fDriftLengthCMD->SetGuidance(
46 "Set the drift length from cathode to wires.");
47 fDriftLengthCMD->SetParameterName(
"drift",
false);
48 fDriftLengthCMD->SetUnitCategory(
"Length");
50 fWirePlaneSpacingCMD =
new G4UIcmdWithADoubleAndUnit(
52 fWirePlaneSpacingCMD->SetGuidance(
53 "Set spacing between the wires.");
54 fWirePlaneSpacingCMD->SetParameterName(
"space",
false);
55 fWirePlaneSpacingCMD->SetUnitCategory(
"Length");
65 if (cmd==fApothemCMD) {
66 fBuilder->
SetApothem(fApothemCMD->GetNewDoubleValue(val));
68 else if (cmd==fDriftLengthCMD) {
71 else if (cmd==fWirePlaneSpacingCMD) {
73 fWirePlaneSpacingCMD->GetNewDoubleValue(val));
83 SetApothem(1037.5*
mm);
84 SetDriftLength(1000*
mm);
85 SetWirePlaneSpacing(3.18*
mm);
86 SetSensitiveDetector(
"drift",
"segment");
87 SetMaximumHitLength(1.0*
mm);
88 SetMaximumHitSagitta(0.25*
mm);
101 return GetDriftLength() + GetGridPlaneOffset() + wires.
GetHeight();
105 double zOffset = GetHeight()/2.0;
106 zOffset -= GetGridPlaneOffset();
107 return G4ThreeVector(0.0, 0.0, zOffset);
112 return 0.0*GetWirePlaneSpacing() + wires.
GetHeight()/2;
117 return 1.0*GetWirePlaneSpacing() + wires.
GetHeight()/2;
122 return 2.0*GetWirePlaneSpacing() + wires.
GetHeight()/2;
127 return 3.0*GetWirePlaneSpacing() + wires.
GetHeight()/2;
132 return 4.0*GetWirePlaneSpacing() + wires.
GetHeight()/2;
137 double rInner[] = {0.0, 0.0};
138 double rOuter[] = {GetApothem(), GetApothem()};
139 double zPlane[] = {GetHeight()/2, -GetHeight()/2};
142 <<
" with " << GetHeight()/
mm <<
" mm height" 143 <<
" and " << GetDriftLength()/
mm <<
" mm drift");
145 G4LogicalVolume *logVolume
146 =
new G4LogicalVolume(
new G4Polyhedra(GetName(),
149 zPlane, rInner, rOuter),
150 FindMaterial(
"Argon_Liquid"),
152 logVolume->SetVisAttributes(GetColor(logVolume));
153 G4FieldManager* manager =
new G4FieldManager();
155 G4ThreeVector(0,0,0), G4ThreeVector(0.0,0.0,500.0*
volt/
cm));
160 throw std::runtime_error(
"Field not properly created");
162 logVolume->SetFieldManager(manager,
true);
163 if (GetSensitiveDetector()) {
164 logVolume->SetSensitiveDetector(GetSensitiveDetector());
165 logVolume->SetUserLimits(
new G4UserLimits(1.0*
mm));
171 G4RotationMatrix* xRotation =
new G4RotationMatrix();
172 xRotation->rotateX(180*
degree);
176 G4LogicalVolume *logX = xPlane.
GetPiece();
177 new G4PVPlacement(xRotation,
179 (GetHeight()/2 - GetXPlaneOffset())),
188 G4RotationMatrix* vRotation =
new G4RotationMatrix();
189 vRotation->rotateX(180*
degree);
190 vRotation->rotateZ(-60*
degree);
194 G4LogicalVolume *logV = vPlane.
GetPiece();
195 new G4PVPlacement(vRotation,
197 (GetHeight()/2 - GetVPlaneOffset())),
206 G4RotationMatrix* uRotation =
new G4RotationMatrix();
207 uRotation->rotateX(180*
degree);
208 uRotation->rotateZ(60*
degree);
212 G4LogicalVolume *logU = uPlane.
GetPiece();
213 new G4PVPlacement(uRotation,
215 (GetHeight()/2 - GetUPlaneOffset())),
225 G4LogicalVolume *logGrid = gridPlane.GetPiece();
226 new G4PVPlacement(xRotation,
228 (GetHeight()/2 - GetGridPlaneOffset())),
238 G4LogicalVolume *logGrnd = grndPlane.GetPiece();
239 new G4PVPlacement(xRotation,
241 (GetHeight()/2 - GetGroundPlaneOffset())),
static constexpr double cm
#define EDepSimLog(outStream)
double GetHeight()
Get the total height of the drift region.
double GetGridPlaneOffset()
Get the offset of the grid from the top of the drift region.
CaptDriftRegionMessenger(CaptDriftRegionBuilder *c)
void SetNewValue(G4UIcommand *cmd, G4String val)
virtual ~CaptDriftRegionBuilder()
G4UIcmdWithADoubleAndUnit * fApothemCMD
virtual ~CaptDriftRegionMessenger()
double GetXPlaneOffset()
Get the offset of the X plane from the top of the drift region.
void SetWirePlaneSpacing(double v)
Set the spacing between the wire planes.
G4UIcmdWithADoubleAndUnit * fWirePlaneSpacingCMD
G4UIcmdWithADoubleAndUnit * fDriftLengthCMD
virtual G4LogicalVolume * GetPiece(void)
double GetVPlaneOffset()
Get the offset of the X plane from the top of the drift region.
void SetApothem(double v)
Construct a module from components.
BuilderMessenger(EDepSim::Builder *c, const char *guide=NULL)
virtual G4LogicalVolume * GetPiece(void)
volt_as<> volt
Type of potential stored in volts, in double precision.
double GetGroundPlaneOffset()
double GetUPlaneOffset()
Get the offset of the X plane from the top of the drift region.
G4ThreeVector GetOffset()
#define EDepSimError(outStream)
CaptDriftRegionBuilder * fBuilder
void SetNewValue(G4UIcommand *cmd, G4String val)
void SetDriftLength(double v)
void SetApothem(double v)
static constexpr double mm
static constexpr double degree
G4String CommandName(G4String cmd)
Build a command name with the directory prefix.