Public Member Functions | Protected Member Functions | Private Attributes | List of all members
EDepSim::Builder Class Referenceabstract

#include <EDepSimBuilder.hh>

Inheritance diagram for EDepSim::Builder:
CaptCryostatBuilder CaptDriftRegionBuilder CaptExposedBuilder CaptImmersedBuilder CaptPMTBuilder CaptWirePlaneBuilder CaptWorldBuilder EDepSim::ComponentBuilder EDepSim::ModuleBuilder MiniCaptExposedBuilder MiniCaptImmersedBuilder

Public Member Functions

 Builder (G4String n, EDepSim::UserDetectorConstruction *c)
 
 Builder (G4String n, EDepSim::Builder *parent)
 
virtual ~Builder ()
 
virtual G4LogicalVolume * GetPiece (void)=0
 
G4String GetName (void)
 Return the base name of the object that this builds. More...
 
G4String GetLocalName (void)
 Return the base name of the object that this builds. More...
 
void SetLocalName (const G4String &name)
 Set the base name of the logical volume that this builds. More...
 
void SetOpacity (double v)
 Set the relative opacity of the constructed object. More...
 
double GetOpacity (void) const
 Get the relative opacity of the constructed object. More...
 
void SetDaughterOpacity (double v)
 Set the relative opacity of the object daughters. More...
 
EDepSim::UserDetectorConstructionGetConstruction (void)
 Return the detector construction that is building this piece. More...
 
virtual void SetSensitiveDetector (G4VSensitiveDetector *s)
 Set the sensitive detector for this component. More...
 
virtual G4VSensitiveDetector * GetSensitiveDetector (void)
 Get the sensitive detector for this component. More...
 
virtual void SetSensitiveDetector (G4String name, G4String type)
 Set the sensitive detector for this component by name. More...
 
virtual void SetMaximumHitSagitta (double sagitta)
 
virtual void SetMaximumHitLength (double length)
 Set the maximum length of a single hit segment. More...
 
G4UImessenger * GetMessenger (void)
 Return the messenger for this constructor. More...
 
void SetMessenger (G4UImessenger *m)
 Set the messenger for this constructor. More...
 
void AddBuilder (EDepSim::Builder *c)
 
template<class T >
T & Get (G4String n)
 
template<class T >
T * Find (G4String n)
 
bool Check ()
 
void SetCheck (bool v)
 Set the check value. More...
 

Protected Member Functions

G4Material * FindMaterial (G4String m)
 
G4VisAttributes GetColor (G4LogicalVolume *volume, double opacity=0.0)
 
G4VisAttributes GetColor (G4Material *volume, double opacity=0.0)
 

Private Attributes

G4String fLocalName
 The short local name of the constructor. More...
 
G4String fName
 The name of the constructor. More...
 
EDepSim::UserDetectorConstructionfConstruction
 The G4VUserDetectorConstruction class that this is cooperating with. More...
 
EDepSim::BuilderfParent
 The parent of this constructor. More...
 
G4UImessenger * fMessenger
 The user interface messenger that will provide values for this class. More...
 
G4VSensitiveDetector * fSensitiveDetector
 The sensitive detector for this tracking component. More...
 
double fOpacity
 The relative opacity of the constructed object. More...
 
bool fCheck
 If this is true, then check the constructed object for overlaps. More...
 
std::map< G4String, EDepSim::Builder * > fSubBuilders
 The sub constructors that might be used in this class. More...
 

Detailed Description

Definition at line 46 of file EDepSimBuilder.hh.

Constructor & Destructor Documentation

EDepSim::Builder::Builder ( G4String  n,
EDepSim::UserDetectorConstruction c 
)

Definition at line 11 of file EDepSimBuilder.cc.

13  : fLocalName(n), fName(n), fConstruction(c), fParent(NULL),
14  fMessenger(NULL), fSensitiveDetector(NULL),
15  fOpacity(0.0), fCheck(false) {
17 }
G4String fLocalName
The short local name of the constructor.
G4UImessenger * fMessenger
The user interface messenger that will provide values for this class.
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.
double fOpacity
The relative opacity of the constructed object.
std::void_t< T > n
EDepSim::Builder * fParent
The parent of this constructor.
G4VSensitiveDetector * fSensitiveDetector
The sensitive detector for this tracking component.
EDepSim::Builder::Builder ( G4String  n,
EDepSim::Builder parent 
)

Definition at line 19 of file EDepSimBuilder.cc.

20  : fLocalName(n), fName(n), fConstruction(NULL), fParent(p),
21  fMessenger(NULL), fSensitiveDetector(NULL),
22  fOpacity(0.0), fCheck(false) {
23  fName = fParent->GetName() + "/" + fLocalName;
25  // Provide a reasonable default. This will (hopefully) be overridden in
26  // Init().
28 }
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.
G4UImessenger * fMessenger
The user interface messenger that will provide values for this class.
bool fCheck
If this is true, then check the constructed object for overlaps.
EDepSim::UserDetectorConstruction * fConstruction
The G4VUserDetectorConstruction class that this is cooperating with.
G4String fName
The name of the constructor.
double fOpacity
The relative opacity of the constructed object.
std::void_t< T > n
p
Definition: test.py:223
EDepSim::Builder * fParent
The parent of this constructor.
G4VSensitiveDetector * fSensitiveDetector
The sensitive detector for this tracking component.
G4UImessenger * GetMessenger(void)
Return the messenger for this constructor.
EDepSim::Builder::~Builder ( )
virtual

Definition at line 30 of file EDepSimBuilder.cc.

30 {;}

Member Function Documentation

void EDepSim::Builder::AddBuilder ( EDepSim::Builder c)
inline

Add a new sub constructor to the current geometry constructor. This should be done in the derived class ctor. All geometry constructors that will be used by the derived class should be added using this method.

Definition at line 113 of file EDepSimBuilder.hh.

113  {
114  if (fSubBuilders.find(c->GetLocalName())
115  != fSubBuilders.end()) {
116  std::cout << "Multiply defined constructor name "
117  << c->GetName()
118  << std::endl;
119  EDepSimThrow("EDepSim::Builder::AddBuilder(): Multiple defines");
120  }
121  fSubBuilders[c->GetLocalName()] = c;
122  }
G4String GetName(void)
Return the base name of the object that this builds.
G4String GetLocalName(void)
Return the base name of the object that this builds.
#define EDepSimThrow(message)
Print an error message, and then throw an exception.
std::map< G4String, EDepSim::Builder * > fSubBuilders
The sub constructors that might be used in this class.
QTextStream & endl(QTextStream &s)
bool EDepSim::Builder::Check ( )
inline

This returns true if the interior objects should be checked for overlaps.

Definition at line 166 of file EDepSimBuilder.hh.

166 {return fCheck;}
bool fCheck
If this is true, then check the constructed object for overlaps.
template<class T >
T* EDepSim::Builder::Find ( G4String  n)
inline

Find a sub constructor by name and do the dynamic cast. This returns a pointer that will be NULL if you request an undefined name.

Definition at line 156 of file EDepSimBuilder.hh.

156  {
158  = fSubBuilders.find(n);
159  if (p==fSubBuilders.end()) return NULL;
160  T* c = dynamic_cast<T*>((*p).second);
161  return c;
162  }
intermediate_table::iterator iterator
std::void_t< T > n
p
Definition: test.py:223
std::map< G4String, EDepSim::Builder * > fSubBuilders
The sub constructors that might be used in this class.
G4Material * EDepSim::Builder::FindMaterial ( G4String  m)
protected

Definition at line 37 of file EDepSimBuilder.cc.

37  {
38  G4Material* material = G4Material::GetMaterial(name,true);
39  return material;
40 }
static QCString name
Definition: declinfo.cpp:673
template<class T >
T& EDepSim::Builder::Get ( G4String  n)
inline

Get a sub constructor by name and do the dynamic cast. This will abort with an error message if you request an undefined name.

Definition at line 126 of file EDepSimBuilder.hh.

126  {
128  = fSubBuilders.find(n);
129  if (p==fSubBuilders.end()) {
130  std::cout << "Error in " << GetName() << std::endl;
131  std::cout << " Undefined constructor requested "
132  << n << std::endl;
133  std::cout << " The choices are: " << std::endl;
134  for (p = fSubBuilders.begin();
135  p != fSubBuilders.end();
136  ++p) {
137  std::cout << " \"" << (*p).first << "\""
138  << " for constructor: " << (*p).second->GetName()
139  << std::endl;
140  }
141  EDepSimThrow(" Undefined constructor");
142  }
143  T* c = dynamic_cast<T*>((*p).second);
144  if (!c) {
145  std::cout << "Error in " << GetName() << std::endl;
146  std::cout << " Cannot type cast " << n
147  << " to requested class" << std::endl;
148  EDepSimThrow("EDepSim::Builder::Get<>:"
149  " Bad typecast");
150  }
151  return *c;
152  }
intermediate_table::iterator iterator
G4String GetName(void)
Return the base name of the object that this builds.
#define EDepSimThrow(message)
Print an error message, and then throw an exception.
std::void_t< T > n
p
Definition: test.py:223
std::map< G4String, EDepSim::Builder * > fSubBuilders
The sub constructors that might be used in this class.
QTextStream & endl(QTextStream &s)
G4VisAttributes EDepSim::Builder::GetColor ( G4LogicalVolume *  volume,
double  opacity = 0.0 
)
protected

Takes logical volume and returns the visual attributes. The optional argument specifies the log of the relative opacity used for this specific set of attributes. If the relative opacity is 0, then the default alpha is used. If the relative opacity is positive, then the alpha is increased, and if it's negative, the alpha is decreased. If the relative opacity is 10, then the object will have an alpha of 1.0. If it's -10, then the object will have an alpha of zero (i.e. invisible).

Definition at line 184 of file EDepSimBuilder.cc.

184  {
185  G4Material* mat = vol->GetMaterial();
186  return GetColor(mat,opacity);
187 }
G4VisAttributes GetColor(G4LogicalVolume *volume, double opacity=0.0)
G4VisAttributes EDepSim::Builder::GetColor ( G4Material *  volume,
double  opacity = 0.0 
)
protected

Takes a material and returns the attributes. The optional argument specifies the log of the relative opacity used for this specific set of attributes. If the relative opacity is 0, then the default alpha is used. If the relative opacity is positive, then the alpha is increased, and if it's negative, the alpha is decreased. If the relative opacity is 10, then the object will have an alpha of 1.0. If it's -10, then the object will have an alpha of zero (i.e. invisible).

Definition at line 167 of file EDepSimBuilder.cc.

167  {
169  // Check if the opacity has been over-ruled by the macro...
170  if (fOpacity < -9.9) return G4VisAttributes::Invisible;
171  opacity += fOpacity;
172  if (opacity < -9.9) return G4VisAttributes::Invisible;
173  G4Color color = geoMan->GetG4Color(mat);
174  double red = color.GetRed();
175  double green = color.GetGreen();
176  double blue = color.GetBlue();
177  double alpha = std::max(0.0,color.GetAlpha());
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));
182 }
G4Color GetG4Color(G4Material *material)
double fOpacity
The relative opacity of the constructed object.
double alpha
Definition: doAna.cpp:15
static int max(int a, int b)
std::size_t color(std::string const &procname)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
static EDepSim::RootGeometryManager * Get(void)
If a persistency manager has not been created, create one.
EDepSim::UserDetectorConstruction* EDepSim::Builder::GetConstruction ( void  )
inline

Return the detector construction that is building this piece.

Definition at line 77 of file EDepSimBuilder.hh.

77  {
78  return fConstruction;
79  };
EDepSim::UserDetectorConstruction * fConstruction
The G4VUserDetectorConstruction class that this is cooperating with.
G4String EDepSim::Builder::GetLocalName ( void  )
inline

Return the base name of the object that this builds.

Definition at line 62 of file EDepSimBuilder.hh.

62 {return fLocalName;};
G4String fLocalName
The short local name of the constructor.
G4UImessenger* EDepSim::Builder::GetMessenger ( void  )
inline

Return the messenger for this constructor.

Definition at line 102 of file EDepSimBuilder.hh.

102 {return fMessenger;};
G4UImessenger * fMessenger
The user interface messenger that will provide values for this class.
G4String EDepSim::Builder::GetName ( void  )

Return the base name of the object that this builds.

Definition at line 42 of file EDepSimBuilder.cc.

42  {
43  return fName;
44 }
G4String fName
The name of the constructor.
double EDepSim::Builder::GetOpacity ( void  ) const
inline

Get the relative opacity of the constructed object.

Definition at line 71 of file EDepSimBuilder.hh.

71 {return fOpacity;}
double fOpacity
The relative opacity of the constructed object.
G4LogicalVolume * EDepSim::Builder::GetPiece ( void  )
pure virtual

Construct and return a G4 volume for the object. This is a pure virtual function, which means it must be implemented by the inheriting classes. This returns an unplaced logical volume which faces along the Z axis.

Implemented in EDepSim::ModuleBuilder, CaptCryostatBuilder, CaptWirePlaneBuilder, CaptDriftRegionBuilder, CaptExposedBuilder, CaptImmersedBuilder, MiniCaptExposedBuilder, MiniCaptImmersedBuilder, CaptPMTBuilder, and CaptWorldBuilder.

Definition at line 32 of file EDepSimBuilder.cc.

32  {
33  EDepSimThrow("EDepSim::Builder::GetPiece(): Not implemented");
34  return NULL;
35 }
#define EDepSimThrow(message)
Print an error message, and then throw an exception.
virtual G4VSensitiveDetector* EDepSim::Builder::GetSensitiveDetector ( void  )
inlinevirtual

Get the sensitive detector for this component.

Definition at line 87 of file EDepSimBuilder.hh.

87  {
88  return fSensitiveDetector;
89  }
G4VSensitiveDetector * fSensitiveDetector
The sensitive detector for this tracking component.
void EDepSim::Builder::SetCheck ( bool  v)
inline

Set the check value.

Definition at line 169 of file EDepSimBuilder.hh.

169 {fCheck = v;}
bool fCheck
If this is true, then check the constructed object for overlaps.
void EDepSim::Builder::SetDaughterOpacity ( double  v)

Set the relative opacity of the object daughters.

Set the visibility of the constructed object.

Definition at line 65 of file EDepSimBuilder.cc.

65  {
67  = fSubBuilders.begin();
68  p!=fSubBuilders.end();
69  ++p) {
70  (*p).second->SetOpacity(v);
71  (*p).second->SetDaughterOpacity(v);
72  }
73 }
intermediate_table::iterator iterator
p
Definition: test.py:223
std::map< G4String, EDepSim::Builder * > fSubBuilders
The sub constructors that might be used in this class.
void EDepSim::Builder::SetLocalName ( const G4String &  name)

Set the base name of the logical volume that this builds.

Set the local name of the object to be built. The local name of the logical volume being set, and also sets the full name of the volume.

Definition at line 48 of file EDepSimBuilder.cc.

48  {
49  fLocalName = name;
50  fName = name;
51  if (fParent) fName = fParent->GetName() + "/" + fName;
52 }
static QCString name
Definition: declinfo.cpp:673
G4String GetName(void)
Return the base name of the object that this builds.
G4String fLocalName
The short local name of the constructor.
G4String fName
The name of the constructor.
EDepSim::Builder * fParent
The parent of this constructor.
void EDepSim::Builder::SetMaximumHitLength ( double  length)
virtual

Set the maximum length of a single hit segment.

Definition at line 210 of file EDepSimBuilder.cc.

210  {
211  if (!fSensitiveDetector) {
212  EDepSimError("Maximum hit length must be set after the sensitive"
213  " detector is defined.");
214  EDepSimThrow("Builder does not have sensitive detector defined");
215  return;
216  }
218  if (!segSD) {
219  EDepSimThrow("Sensitive detector not derived from EDepSim::SegmentSD");
220  return;
221  }
222  segSD->SetMaximumHitLength(length);
223 }
void SetMaximumHitLength(double length)
#define EDepSimThrow(message)
Print an error message, and then throw an exception.
G4VSensitiveDetector * fSensitiveDetector
The sensitive detector for this tracking component.
#define EDepSimError(outStream)
Definition: EDepSimLog.hh:503
void EDepSim::Builder::SetMaximumHitSagitta ( double  sagitta)
virtual

Set the maximum sagitta for a track being added to a single hit segment.

Definition at line 195 of file EDepSimBuilder.cc.

195  {
196  if (!fSensitiveDetector) {
197  EDepSimError("Maximum hit sagitta must be set after the sensitive"
198  " detector is defined.");
199  EDepSimThrow("Builder does not have sensitive detector defined");
200  return;
201  }
203  if (!segSD) {
204  EDepSimThrow("Sensitive detector not derived from EDepSim::SegmentSD");
205  return;
206  }
207  segSD->SetMaximumHitSagitta(sagitta);
208 }
#define EDepSimThrow(message)
Print an error message, and then throw an exception.
G4VSensitiveDetector * fSensitiveDetector
The sensitive detector for this tracking component.
#define EDepSimError(outStream)
Definition: EDepSimLog.hh:503
void SetMaximumHitSagitta(double sagitta)
void EDepSim::Builder::SetMessenger ( G4UImessenger *  m)
inline

Set the messenger for this constructor.

Definition at line 105 of file EDepSimBuilder.hh.

105  {
106  fMessenger = m;
107  };
G4UImessenger * fMessenger
The user interface messenger that will provide values for this class.
void EDepSim::Builder::SetOpacity ( double  v)

Set the relative opacity of the constructed object.

Set the visibility of the constructed object.

Definition at line 56 of file EDepSimBuilder.cc.

56  {
57  if (fOpacity != v) {
58  EDepSimLog("Set relative opacity for " << GetName()
59  << " from " << fOpacity << " to " << v);
60  }
61  fOpacity = v;
62 }
#define EDepSimLog(outStream)
Definition: EDepSimLog.hh:717
G4String GetName(void)
Return the base name of the object that this builds.
double fOpacity
The relative opacity of the constructed object.
virtual void EDepSim::Builder::SetSensitiveDetector ( G4VSensitiveDetector *  s)
inlinevirtual

Set the sensitive detector for this component.

Definition at line 82 of file EDepSimBuilder.hh.

82  {
84  }
G4VSensitiveDetector * fSensitiveDetector
The sensitive detector for this tracking component.
static QCString * s
Definition: config.cpp:1042
void EDepSim::Builder::SetSensitiveDetector ( G4String  name,
G4String  type 
)
virtual

Set the sensitive detector for this component by name.

Definition at line 190 of file EDepSimBuilder.cc.

190  {
191  EDepSim::SDFactory factory(type);
192  SetSensitiveDetector(factory.MakeSD(name));
193 }
static QCString name
Definition: declinfo.cpp:673
virtual void SetSensitiveDetector(G4VSensitiveDetector *s)
Set the sensitive detector for this component.

Member Data Documentation

bool EDepSim::Builder::fCheck
private

If this is true, then check the constructed object for overlaps.

Definition at line 216 of file EDepSimBuilder.hh.

EDepSim::UserDetectorConstruction* EDepSim::Builder::fConstruction
private

The G4VUserDetectorConstruction class that this is cooperating with.

Definition at line 201 of file EDepSimBuilder.hh.

G4String EDepSim::Builder::fLocalName
private

The short local name of the constructor.

Definition at line 195 of file EDepSimBuilder.hh.

G4UImessenger* EDepSim::Builder::fMessenger
private

The user interface messenger that will provide values for this class.

Definition at line 207 of file EDepSimBuilder.hh.

G4String EDepSim::Builder::fName
private

The name of the constructor.

Definition at line 198 of file EDepSimBuilder.hh.

double EDepSim::Builder::fOpacity
private

The relative opacity of the constructed object.

Definition at line 213 of file EDepSimBuilder.hh.

EDepSim::Builder* EDepSim::Builder::fParent
private

The parent of this constructor.

Definition at line 204 of file EDepSimBuilder.hh.

G4VSensitiveDetector* EDepSim::Builder::fSensitiveDetector
private

The sensitive detector for this tracking component.

Definition at line 210 of file EDepSimBuilder.hh.

std::map<G4String,EDepSim::Builder*> EDepSim::Builder::fSubBuilders
private

The sub constructors that might be used in this class.

Definition at line 219 of file EDepSimBuilder.hh.


The documentation for this class was generated from the following files: