CaptPMTBuilder.cc
Go to the documentation of this file.
1 #include "CaptPMTBuilder.hh"
2 #include "EDepSimBuilder.hh"
3 
4 #include "EDepSimLog.hh"
5 
6 #include <globals.hh>
7 #include <G4Material.hh>
8 #include <G4LogicalVolume.hh>
9 #include <G4VPhysicalVolume.hh>
10 #include <G4PVPlacement.hh>
11 #include <G4VisAttributes.hh>
12 
13 #include <G4SystemOfUnits.hh>
14 #include <G4PhysicalConstants.hh>
15 
16 #include <G4Polyhedra.hh>
17 #include <G4Box.hh>
18 #include <G4Tubs.hh>
19 
20 #include <cmath>
21 
23  : public EDepSim::BuilderMessenger {
24 private:
26  G4UIcmdWithADoubleAndUnit* fSizeCMD;
27  G4UIcmdWithADoubleAndUnit* fBaseLengthCMD;
28  G4UIcmdWithABool* fRoundCMD;
29 
30 public:
32  : EDepSim::BuilderMessenger(c,"Control the PMT construction."),
33  fBuilder(c) {
34 
35  fSizeCMD
36  = new G4UIcmdWithADoubleAndUnit(CommandName("size"),this);
37  fSizeCMD->SetGuidance("Set the PMT size.");
38  fSizeCMD->SetParameterName("size",false);
39  fSizeCMD->SetUnitCategory("Length");
40 
41  fBaseLengthCMD = new G4UIcmdWithADoubleAndUnit(
42  CommandName("baseLength"),this);
43  fBaseLengthCMD->SetGuidance("Set the PMT base length.");
44  fBaseLengthCMD->SetParameterName("length",false);
45  fBaseLengthCMD->SetUnitCategory("Length");
46 
47  fRoundCMD = new G4UIcmdWithABool(
48  CommandName("round"),this);
49  fRoundCMD->SetGuidance("Flag that the PMT is round.");
50  }
51 
52  virtual ~CaptPMTMessenger() {
53  delete fSizeCMD;
54  delete fBaseLengthCMD;
55  delete fRoundCMD;
56  }
57 
58  void SetNewValue(G4UIcommand *cmd, G4String val) {
59  if (cmd==fSizeCMD) {
60  fBuilder->SetSize(fSizeCMD->GetNewDoubleValue(val));
61  }
62  else if (cmd==fBaseLengthCMD) {
63  fBuilder->SetBaseLength(fBaseLengthCMD->GetNewDoubleValue(val));
64  }
65  else if (cmd==fRoundCMD) {
66  fBuilder->SetRound(fRoundCMD->GetNewBoolValue(val));
67  }
68  else {
70  }
71  }
72 
73 };
74 
76  SetMessenger(new CaptPMTMessenger(this));
77  SetSize(25*CLHEP::mm);
78  SetBaseLength(25*CLHEP::mm);
79 }
80 
82 
83 G4LogicalVolume *CaptPMTBuilder::GetPiece(void) {
84  const double glassThickness = 3*CLHEP::mm;
85 
86  G4LogicalVolume* logVolume
87  = new G4LogicalVolume(new G4Tubs(GetName(),
88  0.0, GetSize()/2.0,
89  GetBaseLength()/2,
91  FindMaterial("Glass"),
92  GetName());
93  logVolume->SetVisAttributes(GetColor(logVolume));
94 
95  // Construct the photo cathode volume.
96  std::string namePhotoCathode = GetName() + "/PhotoCathode";
97  G4LogicalVolume* logPhotoCathode
98  = new G4LogicalVolume(new G4Tubs(namePhotoCathode,
99  0.0, GetSize()/2.0,
100  glassThickness/2.0,
102  FindMaterial("Glass"),
103  namePhotoCathode);
104  logPhotoCathode->SetVisAttributes(GetColor(logPhotoCathode));
105 
106  // Place the vessel components.
107  new G4PVPlacement(NULL, // rotation.
108  G4ThreeVector(0,0,
109  GetBaseLength()/2.0 - glassThickness/2.0),
110  logPhotoCathode, // logical volume
111  logPhotoCathode->GetName(), // name
112  logVolume, // mother volume
113  false, // (not used)
114  0, // Copy number (zero)
115  Check()); // Check overlaps.
116 
117  // Construct the vacuum.
118  std::string namePMTVoid = GetName() + "/PMTVoid";
119  G4LogicalVolume* logPMTVoid
120  = new G4LogicalVolume(new G4Tubs(namePMTVoid,
121  0.0, GetSize()/2.0-glassThickness,
122  GetBaseLength()/2.0-glassThickness,
124  FindMaterial("Air"), // should be vacuum...
125  namePMTVoid);
126  logPMTVoid->SetVisAttributes(GetColor(logPMTVoid));
127 
128  // Place the vessel components.
129  new G4PVPlacement(NULL, // rotation.
130  G4ThreeVector(0,0,0),
131  logPMTVoid, // logical volume
132  logPMTVoid->GetName(), // name
133  logVolume, // mother volume
134  false, // (not used)
135  0, // Copy number (zero)
136  Check()); // Check overlaps.
137 
138  return logVolume;
139 }
void SetNewValue(G4UIcommand *cmd, G4String val)
void Init(void)
void SetNewValue(G4UIcommand *cmd, G4String val)
std::string string
Definition: nybbler.cc:12
G4UIcmdWithABool * fRoundCMD
void SetSize(double v)
void SetRound(bool v)
Set that the PMT is round.
Construct a module from components.
Definition: TG4HitSegment.h:10
BuilderMessenger(EDepSim::Builder *c, const char *guide=NULL)
virtual ~CaptPMTBuilder()
CaptPMTBuilder * fBuilder
virtual G4LogicalVolume * GetPiece(void)
static constexpr double mm
Definition: Units.h:65
void SetBaseLength(double v)
static constexpr double degree
Definition: Units.h:161
G4UIcmdWithADoubleAndUnit * fSizeCMD
list cmd
Definition: getreco.py:22
G4String CommandName(G4String cmd)
Build a command name with the directory prefix.
virtual ~CaptPMTMessenger()
G4UIcmdWithADoubleAndUnit * fBaseLengthCMD
CaptPMTMessenger(CaptPMTBuilder *c)