Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
EDepSim::ModuleBuilder Class Reference

#include <EDepSimModuleBuilder.hh>

Inheritance diagram for EDepSim::ModuleBuilder:
EDepSim::Builder

Public Member Functions

 ModuleBuilder (G4String n, EDepSim::UserDetectorConstruction *c)
 
 ModuleBuilder (G4String n, EDepSim::Builder *p)
 
virtual ~ModuleBuilder ()
 
virtual G4LogicalVolume * GetPiece (void)
 
void SetWidth (double w)
 Set the width of the module. This is the X dimension of the module. More...
 
double GetWidth (void)
 Get the width of the module. More...
 
void SetHeight (double w)
 Set the height of the module. This is the Y dimension of the module. More...
 
double GetHeight (void)
 Get the height of the module. More...
 
double GetLength (void)
 Get the length of the module. More...
 
void ClearComponentList (void)
 Clear the list of components to be added to the FG tracker. More...
 
void AddComponent (G4String m)
 
void SetRepetitions (int r, int c)
 
void SetModuleCompTrans (int m, int cPerM, int c, double transX, double transY)
 
void SetTargetLength (double w)
 
double GetTargetLength (void)
 Get the target length of the module bounding box. More...
 
void SetFixLength (bool f)
 Set flag to accept the TargetLength as the actual module length. More...
 
bool GetFixLength (void)
 Get flag to accept the TargetLength as the actual module length. More...
 
void SetXPosition (double x)
 Set x position at which components are positioned inside the module. More...
 
double GetXPosition ()
 Get x position at which components are positioned inside the module. More...
 
void SetYPosition (double y)
 Set y position at which components are positioned inside the module. More...
 
double GetYPosition ()
 Get y position at which components are positioned inside the module. More...
 
double GetXmaxTranslation ()
 Get the maximum positive x translation parameter among the modules. More...
 
double GetXminTranslation ()
 Get the minimum negative x translation parameter among the modules. More...
 
double GetYmaxTranslation ()
 Get the maximum positive y translation parameter among the modules. More...
 
double GetYminTranslation ()
 Get the minimum negative y translation parameter among the modules. More...
 
- Public Member Functions inherited from EDepSim::Builder
 Builder (G4String n, EDepSim::UserDetectorConstruction *c)
 
 Builder (G4String n, EDepSim::Builder *parent)
 
virtual ~Builder ()
 
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...
 

Private Types

typedef std::vector< EDepSim::ComponentBuilder * > PartsList
 A vector of ComponentBuilders that will be added to the module. More...
 
typedef std::vector< std::pair< double, double > > TransList
 

Private Member Functions

void Init (void)
 

Private Attributes

double fWidth
 The width of the module. More...
 
double fHeight
 The height of the module. More...
 
double fLength
 The length of the module. More...
 
double fTargetLength
 
bool fFixLength
 Logical flag to accept the target length as the module length. More...
 
double xPosition
 The x position at which components are positioned inside the module. More...
 
double yPosition
 The y position at which components are positioned inside the module. More...
 
std::pair< double, double > fPair
 Default pair of translation constants. More...
 
PartsListfPartsList
 
TransListfTransList
 
G4double xmax
 Collect the minimum and maximum of translations in x and y. More...
 
G4double xmin
 
G4double ymax
 
G4double ymin
 

Additional Inherited Members

- Protected Member Functions inherited from EDepSim::Builder
G4Material * FindMaterial (G4String m)
 
G4VisAttributes GetColor (G4LogicalVolume *volume, double opacity=0.0)
 
G4VisAttributes GetColor (G4Material *volume, double opacity=0.0)
 

Detailed Description

Definition at line 16 of file EDepSimModuleBuilder.hh.

Member Typedef Documentation

A vector of ComponentBuilders that will be added to the module.

Definition at line 128 of file EDepSimModuleBuilder.hh.

typedef std::vector<std::pair<double, double> > EDepSim::ModuleBuilder::TransList
private

A vector of translation parameters in x and y for each component in the module. Used in parallel with fPartsList (same number of entries as fPartsList)

Definition at line 134 of file EDepSimModuleBuilder.hh.

Constructor & Destructor Documentation

EDepSim::ModuleBuilder::ModuleBuilder ( G4String  n,
EDepSim::UserDetectorConstruction c 
)
inline

Definition at line 20 of file EDepSimModuleBuilder.hh.

EDepSim::ModuleBuilder::ModuleBuilder ( G4String  n,
EDepSim::Builder p 
)
inline

Definition at line 23 of file EDepSimModuleBuilder.hh.

24  : EDepSim::Builder(n,p) {
25  Init();};
std::void_t< T > n
EDepSim::ModuleBuilder::~ModuleBuilder ( )
virtual

Definition at line 19 of file EDepSimModuleBuilder.cc.

19  {
20  if (fPartsList != 0) {
21  fPartsList->clear();
22  delete fPartsList;
23  }
24  if (fTransList != 0) {
25  fTransList->clear();
26  delete fTransList;
27  }
28 }

Member Function Documentation

void EDepSim::ModuleBuilder::AddComponent ( G4String  m)

Add a new component name to the FG tracker. Components are added from upstream (-Z) to downstream (+Z).

Definition at line 136 of file EDepSimModuleBuilder.cc.

136  {
137  EDepSim::ComponentBuilder* fBuilder
138  = &Get<EDepSim::ComponentBuilder>(name);
139  fPartsList->push_back(fBuilder);
140 
141  // Run parallel with fPartsList.
142  fTransList->push_back(fPair);
143 }
static QCString name
Definition: declinfo.cpp:673
std::pair< double, double > fPair
Default pair of translation constants.
void EDepSim::ModuleBuilder::ClearComponentList ( void  )

Clear the list of components to be added to the FG tracker.

Definition at line 132 of file EDepSimModuleBuilder.cc.

132  {
133  fPartsList->clear();
134 }
bool EDepSim::ModuleBuilder::GetFixLength ( void  )
inline

Get flag to accept the TargetLength as the actual module length.

Definition at line 79 of file EDepSimModuleBuilder.hh.

79 {return fFixLength;}
bool fFixLength
Logical flag to accept the target length as the module length.
double EDepSim::ModuleBuilder::GetHeight ( void  )
inline

Get the height of the module.

Definition at line 43 of file EDepSimModuleBuilder.hh.

43 {return fHeight;}
double fHeight
The height of the module.
double EDepSim::ModuleBuilder::GetLength ( void  )
inline

Get the length of the module.

Definition at line 46 of file EDepSimModuleBuilder.hh.

46 {return fLength;};
double fLength
The length of the module.
G4LogicalVolume * EDepSim::ModuleBuilder::GetPiece ( void  )
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.

Position all of the sub volumes.

Create the volume for the envelope.

Implements EDepSim::Builder.

Definition at line 51 of file EDepSimModuleBuilder.cc.

51  {
52 
53  // Build the logical volumes.
54 
55  for (PartsList::iterator e = fPartsList->begin();
56  e != fPartsList->end(); ++e) {
57  (*e)->SetWidth(GetWidth());
58  (*e)->SetHeight(GetHeight());
59  }
60 
61  // Calculate the length
62  fLength = 0.0;
63  for (PartsList::iterator e = fPartsList->begin();
64  e != fPartsList->end();++e) {
65  double componentLength = (*e)->GetLength();
66  if (componentLength < 0.0) {
67  EDepSimWarn("%%%%%%% Negative Component Length ");
68  EDepSimWarn("%% " << (*e)->GetName());
69  continue;
70  }
71  fLength += componentLength;
72  }
73 
74  if (fLength<0.10*CLHEP::mm) return NULL;
75 
76  if (GetLength()>GetTargetLength()) {
78  EDepSimError(" Is " << GetLength()/CLHEP::cm << " cm long with "
79  << GetTargetLength()/CLHEP::cm << " cm available");
80  EDepSimThrow("EDepSim::ModuleBuilder::GetPiece(): Volume too long");
81  }
82 
83  /// Position all of the sub volumes.
84  double zPosition = -fLength/2.;
85 
87 
88  // Construct the envelope.
89  G4VSolid *solid = new G4Box(GetName(),
90  GetWidth()/2,
91  GetHeight()/2,
92  GetLength()/2);
93 
94  /// Create the volume for the envelope.
95  G4LogicalVolume *logVolume
96  = new G4LogicalVolume(solid,
97  FindMaterial("Air"),
98  GetName());
99 
100  int i = 0;
101  for (PartsList::iterator e = fPartsList->begin();
102  e != fPartsList->end(); ++e) {
103  zPosition += (*e)->GetLength()/2;
104 
105  // Add translation parameters from fTransList in the placement, called
106  // by the index i.
107 
108  G4double xpos = fTransList->at(i).first;
109  G4double ypos = fTransList->at(i).second;
110 
111  if(xpos>xmax)xmax=xpos;
112  if(xpos<xmin)xmin=xpos;
113  if(ypos>ymax)ymax=ypos;
114  if(ypos<ymin)ymin=ypos;
115 
116  new G4PVPlacement(0,
117  G4ThreeVector(xPosition+xpos,
118  yPosition+ypos,
119  zPosition),
120  (*e)->GetPiece(),
121  (*e)->GetName(),
122  logVolume,
123  false,
124  i);
125  zPosition += (*e)->GetLength()/2;
126  i++;
127  }
128 
129  return logVolume;
130 }
static constexpr double cm
Definition: Units.h:68
intermediate_table::iterator iterator
G4String GetName(void)
Return the base name of the object that this builds.
TH3F * xpos
Definition: doAna.cpp:29
double fLength
The length of the module.
G4Material * FindMaterial(G4String m)
#define EDepSimThrow(message)
Print an error message, and then throw an exception.
double yPosition
The y position at which components are positioned inside the module.
TH3F * ypos
Definition: doAna.cpp:30
double GetTargetLength(void)
Get the target length of the module bounding box.
bool fFixLength
Logical flag to accept the target length as the module length.
const double e
double GetLength(void)
Get the length of the module.
double GetWidth(void)
Get the width of the module.
double xPosition
The x position at which components are positioned inside the module.
#define EDepSimError(outStream)
Definition: EDepSimLog.hh:503
G4double xmax
Collect the minimum and maximum of translations in x and y.
#define EDepSimWarn(outStream)
Definition: EDepSimLog.hh:576
static constexpr double mm
Definition: Units.h:65
double GetHeight(void)
Get the height of the module.
double EDepSim::ModuleBuilder::GetTargetLength ( void  )
inline

Get the target length of the module bounding box.

Definition at line 74 of file EDepSimModuleBuilder.hh.

double EDepSim::ModuleBuilder::GetWidth ( void  )
inline

Get the width of the module.

Definition at line 38 of file EDepSimModuleBuilder.hh.

38 {return fWidth;}
double fWidth
The width of the module.
double EDepSim::ModuleBuilder::GetXmaxTranslation ( )
inline

Get the maximum positive x translation parameter among the modules.

Definition at line 92 of file EDepSimModuleBuilder.hh.

92 {return xmax;}
G4double xmax
Collect the minimum and maximum of translations in x and y.
double EDepSim::ModuleBuilder::GetXminTranslation ( )
inline

Get the minimum negative x translation parameter among the modules.

Definition at line 94 of file EDepSimModuleBuilder.hh.

94 {return xmin;}
double EDepSim::ModuleBuilder::GetXPosition ( )
inline

Get x position at which components are positioned inside the module.

Definition at line 84 of file EDepSimModuleBuilder.hh.

84 {return xPosition;}
double xPosition
The x position at which components are positioned inside the module.
double EDepSim::ModuleBuilder::GetYmaxTranslation ( )
inline

Get the maximum positive y translation parameter among the modules.

Definition at line 96 of file EDepSimModuleBuilder.hh.

96 {return ymax;}
double EDepSim::ModuleBuilder::GetYminTranslation ( )
inline

Get the minimum negative y translation parameter among the modules.

Definition at line 98 of file EDepSimModuleBuilder.hh.

98 {return ymin;}
double EDepSim::ModuleBuilder::GetYPosition ( )
inline

Get y position at which components are positioned inside the module.

Definition at line 89 of file EDepSimModuleBuilder.hh.

89 {return yPosition;}
double yPosition
The y position at which components are positioned inside the module.
void EDepSim::ModuleBuilder::Init ( void  )
private

Definition at line 30 of file EDepSimModuleBuilder.cc.

30  {
31  fWidth = 250*CLHEP::cm;
32  fHeight = 250*CLHEP::cm;
33  fLength = 0*CLHEP::cm;
35  fFixLength = false;
36  xPosition = 0*CLHEP::cm;
37  yPosition = 0*CLHEP::cm;
38 
39  // Set default translation parameters as 0.
40  fPair.first = 0.0*CLHEP::mm;
41  fPair.second = 0.0*CLHEP::mm;
42 
44 
45  fPartsList = new PartsList();
46  fTransList = new TransList();
47 
48  xmax = xmin = ymax = ymin = 0.0*CLHEP::mm;
49 }
static constexpr double cm
Definition: Units.h:68
std::pair< double, double > fPair
Default pair of translation constants.
std::vector< EDepSim::ComponentBuilder * > PartsList
A vector of ComponentBuilders that will be added to the module.
void SetMessenger(G4UImessenger *m)
Set the messenger for this constructor.
double fLength
The length of the module.
double yPosition
The y position at which components are positioned inside the module.
bool fFixLength
Logical flag to accept the target length as the module length.
double xPosition
The x position at which components are positioned inside the module.
double fHeight
The height of the module.
G4double xmax
Collect the minimum and maximum of translations in x and y.
double fWidth
The width of the module.
static constexpr double mm
Definition: Units.h:65
std::vector< std::pair< double, double > > TransList
void EDepSim::ModuleBuilder::SetFixLength ( bool  f)
inline

Set flag to accept the TargetLength as the actual module length.

Definition at line 77 of file EDepSimModuleBuilder.hh.

77 {fFixLength = f;}
bool fFixLength
Logical flag to accept the target length as the module length.
void EDepSim::ModuleBuilder::SetHeight ( double  w)
inline

Set the height of the module. This is the Y dimension of the module.

Definition at line 41 of file EDepSimModuleBuilder.hh.

41 {fHeight = w;}
double fHeight
The height of the module.
void EDepSim::ModuleBuilder::SetModuleCompTrans ( int  m,
int  cPerM,
int  c,
double  transX,
double  transY 
)

Translate some components inside the module in X/Y according to module number and total components in a module. This simulates misalignment in FGD layers.

Definition at line 183 of file EDepSimModuleBuilder.cc.

184  {
185  for (int i = 0; i < c; i++) {
186  fTransList->at(module*cPerM+i).first = transX;
187  fTransList->at(module*cPerM+i).second = transY;
188  }
189 }
void EDepSim::ModuleBuilder::SetRepetitions ( int  r,
int  c 
)

Set the number of repetitions for the last components added to the module. This counts the total repetitions of the last component, inclduing that component. So "1" repetition doesn't increase the number of components. This also controls the number of previous components to be part of the repetion.

Definition at line 145 of file EDepSimModuleBuilder.cc.

145  {
146  if (r<1) {
147  EDepSimError("*** Repetition count must be greater than "
148  "or equal to one.");
149  }
150 
151  if (c<1) {
152  EDepSimError("*** Component count must be greater than "
153  "or equal to one.");
154  }
155 
156  if (fPartsList->size()<(unsigned) c) {
157  EDepSimError("Not enough parts to build module");
158  EDepSimError(" Parts supplied: " << fPartsList->size()
159  << " Parts required: " << c);
160  EDepSimError("Module construction failed.");
161  return;
162  }
163 
164  PartsList additions(fPartsList->end() - c, fPartsList->end());
165 
166  // Start the count from 1 since there is already one component on the list.
167  for (int i=1; i<r; ++i) {
169  fPartsList->insert(e,additions.begin(),additions.end());
170  }
171  for (int i = 0; i < r*c; i++)
172  {
173  fTransList->push_back(fPair);
174  }
175 }
intermediate_table::iterator iterator
std::pair< double, double > fPair
Default pair of translation constants.
std::vector< EDepSim::ComponentBuilder * > PartsList
A vector of ComponentBuilders that will be added to the module.
const double e
#define EDepSimError(outStream)
Definition: EDepSimLog.hh:503
void EDepSim::ModuleBuilder::SetTargetLength ( double  w)
inline

Set the target length of the module bounding box along the beam axis (the Z axis). The actual length must be shorter than this. Note that the beam goes down at at a few degrees, but the Z axis is horizontal.

Definition at line 72 of file EDepSimModuleBuilder.hh.

void EDepSim::ModuleBuilder::SetWidth ( double  w)
inline

Set the width of the module. This is the X dimension of the module.

Definition at line 36 of file EDepSimModuleBuilder.hh.

36 {fWidth = w;}
double fWidth
The width of the module.
void EDepSim::ModuleBuilder::SetXPosition ( double  x)
inline

Set x position at which components are positioned inside the module.

Definition at line 82 of file EDepSimModuleBuilder.hh.

82 {xPosition = x;}
double xPosition
The x position at which components are positioned inside the module.
list x
Definition: train.py:276
void EDepSim::ModuleBuilder::SetYPosition ( double  y)
inline

Set y position at which components are positioned inside the module.

Definition at line 87 of file EDepSimModuleBuilder.hh.

87 {yPosition = y;}
double yPosition
The y position at which components are positioned inside the module.

Member Data Documentation

bool EDepSim::ModuleBuilder::fFixLength
private

Logical flag to accept the target length as the module length.

Definition at line 116 of file EDepSimModuleBuilder.hh.

double EDepSim::ModuleBuilder::fHeight
private

The height of the module.

Definition at line 106 of file EDepSimModuleBuilder.hh.

double EDepSim::ModuleBuilder::fLength
private

The length of the module.

Definition at line 109 of file EDepSimModuleBuilder.hh.

std::pair<double, double> EDepSim::ModuleBuilder::fPair
private

Default pair of translation constants.

Definition at line 125 of file EDepSimModuleBuilder.hh.

PartsList* EDepSim::ModuleBuilder::fPartsList
private

Definition at line 129 of file EDepSimModuleBuilder.hh.

double EDepSim::ModuleBuilder::fTargetLength
private

The target length of module bounding box (parallel to the beam axis). The actual length must be shorter than this.

Definition at line 113 of file EDepSimModuleBuilder.hh.

TransList* EDepSim::ModuleBuilder::fTransList
private

Definition at line 135 of file EDepSimModuleBuilder.hh.

double EDepSim::ModuleBuilder::fWidth
private

The width of the module.

Definition at line 103 of file EDepSimModuleBuilder.hh.

G4double EDepSim::ModuleBuilder::xmax
private

Collect the minimum and maximum of translations in x and y.

Definition at line 138 of file EDepSimModuleBuilder.hh.

G4double EDepSim::ModuleBuilder::xmin
private

Definition at line 138 of file EDepSimModuleBuilder.hh.

double EDepSim::ModuleBuilder::xPosition
private

The x position at which components are positioned inside the module.

Definition at line 119 of file EDepSimModuleBuilder.hh.

G4double EDepSim::ModuleBuilder::ymax
private

Definition at line 138 of file EDepSimModuleBuilder.hh.

G4double EDepSim::ModuleBuilder::ymin
private

Definition at line 138 of file EDepSimModuleBuilder.hh.

double EDepSim::ModuleBuilder::yPosition
private

The y position at which components are positioned inside the module.

Definition at line 122 of file EDepSimModuleBuilder.hh.


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