13 : fLocalName(n), fName(n), fConstruction(c), fParent(NULL),
14 fMessenger(NULL), fSensitiveDetector(NULL),
15 fOpacity(0.0), fCheck(false) {
33 EDepSimThrow(
"EDepSim::Builder::GetPiece(): Not implemented");
38 G4Material*
material = G4Material::GetMaterial(name,
true);
59 <<
" from " <<
fOpacity <<
" to " << v);
70 (*p).second->SetOpacity(v);
71 (*p).second->SetDaughterOpacity(v);
79 fDirectory =
new G4UIdirectory(fDirName);
81 fDirectory->SetGuidance(guide);
85 fDirectory->SetGuidance(guidance.c_str());
88 fOpacityCMD =
new G4UIcmdWithADouble(CommandName(
"opacity"),
this);
89 fOpacityCMD->SetGuidance(
"Set the log of the relative opacity." 90 " Useful values are between [-0.5, 0.5], and" 91 " +/-10 makes the object opague or transparent." 92 " A value of 0 leaves the opacity unchanged.");
93 fOpacityCMD->SetParameterName(
"opacity",
false);
95 fDaughterOpacityCMD =
new G4UIcmdWithADouble(
96 CommandName(
"daughterOpacity"),
this);
97 fDaughterOpacityCMD->SetGuidance(
98 "Set the log of the relative opacity of the daughters.");
99 fDaughterOpacityCMD->SetParameterName(
"opacity",
false);
101 fCheckCMD =
new G4UIcmdWithABool(CommandName(
"check"),
this);
102 fCheckCMD->SetGuidance(
"If this is true then check for overlaps");
103 fCheckCMD->SetParameterName(
"check",
false);
105 fSensitiveCMD =
new G4UIcommand(CommandName(
"sensitive"),
this);
106 fSensitiveCMD->SetGuidance(
"Set the name of the sensitive detector");
107 G4UIparameter* nameParam =
new G4UIparameter(
's');
108 nameParam->SetParameterName(
"Name");
109 fSensitiveCMD->SetParameter(nameParam);
110 G4UIparameter* typeParam =
new G4UIparameter(
's');
111 typeParam->SetParameterName(
"Type");
112 fSensitiveCMD->SetParameter(typeParam);
114 fMaximumHitSagittaCMD
115 =
new G4UIcmdWithADoubleAndUnit(CommandName(
"maxHitSagitta"),
this);
116 fMaximumHitSagittaCMD->SetGuidance(
"Set the maximum sagitta for a hit.");
117 fMaximumHitSagittaCMD->SetParameterName(
"Sagitta",
false);
118 fMaximumHitSagittaCMD->SetUnitCategory(
"Length");
121 =
new G4UIcmdWithADoubleAndUnit(CommandName(
"maxHitLength"),
this);
122 fMaximumHitLengthCMD->SetGuidance(
"Set the maximum length for a hit.");
123 fMaximumHitLengthCMD->SetParameterName(
"HitLength",
false);
124 fMaximumHitLengthCMD->SetUnitCategory(
"Length");
128 if (cmd == fOpacityCMD) {
129 fBuilder->SetOpacity(fOpacityCMD->GetNewDoubleValue(val));
131 else if (cmd == fDaughterOpacityCMD) {
132 fBuilder->SetDaughterOpacity(
133 fDaughterOpacityCMD->GetNewDoubleValue(val));
135 else if (cmd == fCheckCMD) {
136 fBuilder->SetCheck(fCheckCMD->GetNewBoolValue(val));
138 else if (cmd==fSensitiveCMD) {
139 std::istringstream buf(val.c_str());
143 fBuilder->SetSensitiveDetector(name,type);
145 else if (cmd==fMaximumHitSagittaCMD) {
148 fMaximumHitSagittaCMD->GetNewDoubleValue(val));
150 else if (cmd==fMaximumHitLengthCMD) {
153 fMaximumHitLengthCMD->GetNewDoubleValue(val));
160 delete fDaughterOpacityCMD;
162 delete fSensitiveCMD;
163 delete fMaximumHitSagittaCMD;
164 delete fMaximumHitLengthCMD;
170 if (
fOpacity < -9.9)
return G4VisAttributes::Invisible;
172 if (opacity < -9.9)
return G4VisAttributes::Invisible;
174 double red = color.GetRed();
175 double green = color.GetGreen();
176 double blue = color.GetBlue();
178 if (opacity > 9.9) alpha = 1.0;
179 else if (
fOpacity > 9.9) alpha = 1.0;
180 else alpha =
std::min(1.0, alpha*std::exp(opacity));
181 return G4VisAttributes(G4Color(red,green,blue,alpha));
185 G4Material* mat = vol->GetMaterial();
197 EDepSimError(
"Maximum hit sagitta must be set after the sensitive" 198 " detector is defined.");
199 EDepSimThrow(
"Builder does not have sensitive detector defined");
204 EDepSimThrow(
"Sensitive detector not derived from EDepSim::SegmentSD");
212 EDepSimError(
"Maximum hit length must be set after the sensitive" 213 " detector is defined.");
214 EDepSimThrow(
"Builder does not have sensitive detector defined");
219 EDepSimThrow(
"Sensitive detector not derived from EDepSim::SegmentSD");
#define EDepSimLog(outStream)
EDepSim::UserDetectorConstruction * GetConstruction(void)
Return the detector construction that is building this piece.
G4String GetName(void)
Return the base name of the object that this builds.
G4String fLocalName
The short local name of the constructor.
virtual ~BuilderMessenger()
void SetNewValue(G4UIcommand *cmd, G4String val)
G4UImessenger * fMessenger
The user interface messenger that will provide values for this class.
virtual void SetMaximumHitLength(double length)
Set the maximum length of a single hit segment.
G4Color GetG4Color(G4Material *material)
bool fCheck
If this is true, then check the constructed object for overlaps.
virtual EDepSim::DetectorMessenger * GetMessenger(void)
Return the detector construction messenger.
EDepSim::UserDetectorConstruction * fConstruction
The G4VUserDetectorConstruction class that this is cooperating with.
G4String fName
The name of the constructor.
G4Material * FindMaterial(G4String m)
void SetMaximumHitLength(double length)
void SetLocalName(const G4String &name)
Set the base name of the logical volume that this builds.
#define EDepSimThrow(message)
Print an error message, and then throw an exception.
double fOpacity
The relative opacity of the constructed object.
virtual G4LogicalVolume * GetPiece(void)=0
virtual void SetMaximumHitSagitta(double sagitta)
G4VSensitiveDetector * MakeSD(G4String name)
BuilderMessenger(EDepSim::Builder *c, const char *guide=NULL)
Builder(G4String n, EDepSim::UserDetectorConstruction *c)
void SetOpacity(double v)
Set the relative opacity of the constructed object.
EDepSim::Builder * fParent
The parent of this constructor.
G4VSensitiveDetector * fSensitiveDetector
The sensitive detector for this tracking component.
static int max(int a, int b)
std::size_t color(std::string const &procname)
#define EDepSimError(outStream)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
virtual void SetSensitiveDetector(G4VSensitiveDetector *s)
Set the sensitive detector for this component.
std::map< G4String, EDepSim::Builder * > fSubBuilders
The sub constructors that might be used in this class.
G4VisAttributes GetColor(G4LogicalVolume *volume, double opacity=0.0)
void SetMaximumHitSagitta(double sagitta)
void SetDaughterOpacity(double v)
Set the relative opacity of the object daughters.
G4UImessenger * GetMessenger(void)
Return the messenger for this constructor.
static EDepSim::RootGeometryManager * Get(void)
If a persistency manager has not been created, create one.