Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PHG4CollimatorDetector.cc
Go to the documentation of this file.
2 
3 #include <phparameter/PHParameters.h>
4 
5 #include <g4main/PHG4Utils.h>
6 
7 
9 #include <phool/PHIODataNode.h>
10 #include <phool/getClass.h>
11 
12 #include <Geant4/G4Box.hh>
13 #include <Geant4/G4SubtractionSolid.hh>
14 #include <Geant4/G4Colour.hh>
15 #include <Geant4/G4LogicalVolume.hh>
16 #include <Geant4/G4Material.hh>
17 #include <Geant4/G4PVPlacement.hh>
18 #include <Geant4/G4SystemOfUnits.hh>
19 #include <Geant4/G4UserLimits.hh>
20 #include <Geant4/G4VisAttributes.hh>
21 
22 #include <sstream>
23 
24 using namespace std;
25 
26 //_______________________________________________________________
27 PHG4CollimatorDetector::PHG4CollimatorDetector( PHCompositeNode *Node, PHParameters *parameters, const std::string &dnam, const int lyr):
28  PHG4Detector(Node, dnam),
29  params(parameters),
30  block_physi(nullptr),
31  layer(lyr)
32 {}
33 
34 //_______________________________________________________________
35 bool PHG4CollimatorDetector::IsInBlock(G4VPhysicalVolume * volume) const
36 {
37  if (volume == block_physi)
38  {
39  return true;
40  }
41  return false;
42 }
43 
44 namespace {
45  bool PlaceLayeredBox(
46  G4LogicalVolume *mother,
47  G4UserLimits *g4userlimits,
48  bool overlapcheck,
49  const std::string& name,
50  G4Material *mat_inner,
51  double x_inner,
52  double y_inner,
53  double z_inner,
54  G4ThreeVector d_inner,
55  G4Material *mat_outer,
56  double x_outer,
57  double y_outer,
58  double z_outer,
59  G4ThreeVector d_outer
60  )
61  {
62  G4VSolid *all_solid = new G4Box((name+"_all").c_str(),
63  x_outer/2,
64  y_outer/2,
65  z_outer/2);
66 
67  G4VSolid *inner_solid = new G4Box((name+"_inner").c_str(),
68  x_inner/2,
69  y_inner/2,
70  z_inner/2+0.1*cm);
71 
72  G4VSolid * outer_solid = new G4SubtractionSolid((name+"_outer").c_str(),
73  all_solid,
74  inner_solid,
75  0,
76  d_inner - d_outer
77  );
78 
79  G4VisAttributes *vis_outer = new G4VisAttributes();
80  PHG4Utils::SetColour(vis_outer, mat_outer->GetName());
81  vis_outer->SetVisibility(true);
82  vis_outer->SetForceSolid(true);
83 
84  G4LogicalVolume *outer_logic = new G4LogicalVolume(outer_solid,
85  mat_outer,
86  (name+"_outer").c_str(),
87  nullptr, nullptr, g4userlimits);
88 
89  outer_logic->SetVisAttributes(vis_outer);
90 
91  new G4PVPlacement(
92  0,
93  d_outer,
94  outer_logic,
95  (name+"_outer").c_str(),
96  mother, 0, false, overlapcheck);
97 
98  G4VisAttributes *vis_inner = new G4VisAttributes();
99  PHG4Utils::SetColour(vis_inner, mat_inner->GetName());
100  vis_inner->SetVisibility(false);
101  vis_inner->SetForceSolid(false);
102 
103  G4LogicalVolume *inner_logic = new G4LogicalVolume(inner_solid,
104  mat_inner,
105  (name+"_inner").c_str(),
106  nullptr, nullptr, g4userlimits);
107 
108  inner_logic->SetVisAttributes(vis_inner);
109 
110  new G4PVPlacement(
111  0,
112  d_inner,
113  inner_logic,
114  (name+"_inner").c_str(),
115  mother, 0, false, overlapcheck);
116 
117  return true;
118  }
119 
120  bool PlaceHollowdBox(
121  G4LogicalVolume *mother,
122  G4UserLimits *g4userlimits,
123  bool overlapcheck,
124  const std::string& name,
125  G4Material *mat_inner,
126  double x_inner,
127  double y_inner,
128  double z_inner,
129  G4ThreeVector d_inner,
130  G4Material *mat_outer,
131  double x_outer,
132  double y_outer,
133  double z_outer,
134  G4ThreeVector d_outer
135  )
136  {
137  G4VSolid *all_solid = new G4Box((name+"_all").c_str(),
138  x_outer/2,
139  y_outer/2,
140  z_outer/2);
141 
142  G4VSolid *inner_solid = new G4Box((name+"_inner").c_str(),
143  x_inner/2,
144  y_inner/2,
145  z_inner/2+0.1*cm);
146 
147  G4VSolid * outer_solid = new G4SubtractionSolid((name+"_outer").c_str(),
148  all_solid,
149  inner_solid,
150  0,
151  d_inner - d_outer
152  );
153 
154  G4VisAttributes *vis_outer = new G4VisAttributes();
155  PHG4Utils::SetColour(vis_outer, mat_outer->GetName());
156  vis_outer->SetVisibility(true);
157  vis_outer->SetForceSolid(true);
158 
159  G4LogicalVolume *outer_logic = new G4LogicalVolume(outer_solid,
160  mat_outer,
161  (name+"_outer").c_str(),
162  nullptr, nullptr, g4userlimits);
163 
164  outer_logic->SetVisAttributes(vis_outer);
165 
166  new G4PVPlacement(
167  0,
168  d_outer,
169  outer_logic,
170  (name+"_outer").c_str(),
171  mother, 0, false, overlapcheck);
172 
173  return true;
174  }
175 }
176 //_______________________________________________________________
177 void PHG4CollimatorDetector::Construct( G4LogicalVolume* logicWorld )
178 {
179  double inch = 2.54*cm;
180 
181  double z = params->get_double_param("size_z")*cm;
182 
183  double x1 = 3.08*inch;
184  double y1 = 1.37*inch;
185  double x2 = 5.00*inch;
186  double y2 = 3.81*inch;
187  double x3 = 18.00*inch;
188  double y3 = 16.78*inch;
189 
190  double dy3 = (4.28-8.688)/2*inch;
191  double dz3 = params->get_double_param("place_z")*cm;
192 
193 
194  G4VSolid *block_solid = new G4Box(G4String(GetName().c_str()),
195  x3/2.,
196  y3/2.,
197  z/2.);
198 
199  double steplimits = params->get_double_param("steplimits") * cm;
200  G4UserLimits *g4userlimits = nullptr;
201  if (isfinite(steplimits))
202  {
203  g4userlimits = new G4UserLimits(steplimits);
204  }
205 
206  G4LogicalVolume *block_logic = new G4LogicalVolume(block_solid,
207  G4Material::GetMaterial("G4_Galactic"),
208  G4String(GetName().c_str()),
209  nullptr,nullptr,g4userlimits);
210 
211  G4VisAttributes* matVis = new G4VisAttributes();
212  PHG4Utils::SetColour(matVis, "G4_Galactic");
213  matVis->SetVisibility(false);
214  matVis->SetForceSolid(false);
215  block_logic->SetVisAttributes(matVis);
216 
217  G4RotationMatrix *rotm = new G4RotationMatrix();
218  rotm->rotateZ(params->get_double_param("rot_z")*deg);
219  block_physi = new G4PVPlacement(
220  rotm,
221  G4ThreeVector(0.,dy3,dz3),
222  block_logic,
223  G4String(GetName().c_str()),
224  logicWorld, 0, false, overlapcheck);
225 
226  PlaceHollowdBox(
227  block_logic,
228  g4userlimits,
229  overlapcheck,
230  "OuterEnv",
231  0,
232  x2, y2, z, G4ThreeVector(0.,-dy3,0.),
233  G4Material::GetMaterial("G4_Fe"),
234  x3, y3, z, G4ThreeVector(0.,0,0.)
235  );
236 
237  PlaceLayeredBox(
238  block_logic,
239  g4userlimits,
240  overlapcheck,
241  "InnerEnv",
242  G4Material::GetMaterial("G4_Galactic"),
243  x1, y1, z, G4ThreeVector(0.,-dy3,0.),
244  G4Material::GetMaterial("G4_Cu"),
245  x2, y2, z, G4ThreeVector(0.,-dy3,0.)
246  );
247 }
248 
249 
250 
251 
252 
253 
254 
255 
256 
257 
258 
259 
260 
261 
262 
263 
264 
265 
266 
267 
268 
269 
270 
271 
272 
273 
274 
275 
virtual void Construct(G4LogicalVolume *world)
construct
double get_double_param(const std::string &name) const
PHG4CollimatorDetector(PHCompositeNode *Node, PHParameters *parameters, const std::string &dnam="BLOCK", const int lyr=0)
constructor
static void SetColour(G4VisAttributes *att, const std::string &mat)
Definition: PHG4Utils.cc:75
bool IsInBlock(G4VPhysicalVolume *) const
base class for phenix detector creation
Definition: PHG4Detector.h:13
virtual std::string GetName() const
Definition: PHG4Detector.h:51