7 #include <G4Material.hh> 8 #include <G4LogicalVolume.hh> 9 #include <G4VPhysicalVolume.hh> 10 #include <G4PVPlacement.hh> 11 #include <G4VisAttributes.hh> 13 #include <G4SystemOfUnits.hh> 14 #include <G4PhysicalConstants.hh> 16 #include <G4Polyhedra.hh> 37 =
new G4UIcmdWithADoubleAndUnit(
CommandName(
"apothem"),
this);
38 fApothemCMD->SetGuidance(
"Set the apothem of the drift region.");
39 fApothemCMD->SetParameterName(
"apothem",
false);
40 fApothemCMD->SetUnitCategory(
"Length");
42 fSpacingCMD =
new G4UIcmdWithADoubleAndUnit(
44 fSpacingCMD->SetGuidance(
45 "Set the wire spacing.");
46 fSpacingCMD->SetParameterName(
"spacing",
false);
47 fSpacingCMD->SetUnitCategory(
"Length");
49 fMaxWireCountCMD =
new G4UIcmdWithAnInteger(
51 fMaxWireCountCMD->SetGuidance(
52 "Set the maximum number of wires in a plane.");
53 fMaxWireCountCMD->SetParameterName(
"count",
false);
64 if (cmd==fApothemCMD) {
65 fBuilder->
SetApothem(fApothemCMD->GetNewDoubleValue(val));
67 else if (cmd==fSpacingCMD) {
68 fBuilder->
SetSpacing(fSpacingCMD->GetNewDoubleValue(val));
70 else if (cmd==fMaxWireCountCMD) {
86 SetSensitiveDetector(
"drift",
"segment");
87 SetMaximumHitLength(1*
mm);
95 double rInner[] = {0.0, 0.0};
96 double rOuter[] = {GetApothem(), GetApothem()};
97 double zPlane[] = {-GetHeight()/2, GetHeight()/2};
99 G4LogicalVolume *logVolume
100 =
new G4LogicalVolume(
new G4Polyhedra(GetName(),
103 zPlane, rInner, rOuter),
104 FindMaterial(
"Argon_Liquid"),
106 logVolume->SetVisAttributes(GetColor(FindMaterial(
"Captain_Wire"), 0.2));
108 if (GetSensitiveDetector()) {
109 logVolume->SetSensitiveDetector(GetSensitiveDetector());
113 double maxLength = 2*GetApothem()/std::cos(30*
CLHEP::degree);
116 int wires =
int (2.0*GetApothem()/GetSpacing());
117 if (wires<1) wires = 1;
119 if (GetMaxWireCount()>0 && GetMaxWireCount()<wires) {
120 EDepSimLog(
"Reduce number of wires for " << GetName()
122 <<
" to " << GetMaxWireCount());
123 wires = GetMaxWireCount();
127 <<
" with " << wires <<
" wires" 128 <<
" (spacing: " << GetSpacing()/
CLHEP::mm <<
" mm)");
130 if (wires<GetMaxWireCount()) {
131 EDepSimWarn(GetName() <<
": Wire count is less than expected:" 133 <<
" < " << GetMaxWireCount());
136 G4RotationMatrix* wireRotation = NULL;
140 G4RotationMatrix* coreRotation =
new G4RotationMatrix();
144 double baseOffset = - 0.5*GetSpacing()*(wires-1);
145 for (
int wire = 0; wire<wires; ++wire) {
147 double wireOffset = baseOffset + wire*GetSpacing();
149 double wireDiameter =
std::min(GetHeight()/2, GetSpacing()/4);
155 G4LogicalVolume* logWire
156 =
new G4LogicalVolume(
new G4Box(GetName()+
"/Wire",
160 FindMaterial(
"Argon_Liquid"),
162 logWire->SetVisAttributes(G4VisAttributes::Invisible);
164 if (GetSensitiveDetector()) {
165 logWire->SetSensitiveDetector(GetSensitiveDetector());
168 new G4PVPlacement(wireRotation,
169 G4ThreeVector(wireOffset,0,0),
177 G4LogicalVolume* logCore
178 =
new G4LogicalVolume(
new G4Tubs(GetName()+
"/Wire/Core",
179 0.0, wireDiameter/2.0,
182 FindMaterial(
"Captain_Wire"),
183 GetName()+
"/Wire/Core");
185 logCore->SetVisAttributes(GetColor(logCore));
187 new G4PVPlacement(coreRotation,
188 G4ThreeVector(0,0,0),
#define EDepSimLog(outStream)
void SetNewValue(G4UIcommand *cmd, G4String val)
void SetNewValue(G4UIcommand *cmd, G4String val)
CaptWirePlaneBuilder * fBuilder
G4UIcmdWithADoubleAndUnit * fSpacingCMD
void SetMaxWireCount(int v)
void SetSpacing(double v)
virtual ~CaptWirePlaneBuilder()
virtual G4LogicalVolume * GetPiece(void)
Construct a module from components.
CaptWirePlaneMessenger(CaptWirePlaneBuilder *c)
BuilderMessenger(EDepSim::Builder *c, const char *guide=NULL)
virtual ~CaptWirePlaneMessenger()
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
#define EDepSimWarn(outStream)
G4UIcmdWithAnInteger * fMaxWireCountCMD
G4UIcmdWithADoubleAndUnit * fApothemCMD
void SetApothem(double v)
static constexpr double mm
static constexpr double degree
G4String CommandName(G4String cmd)
Build a command name with the directory prefix.