Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4Prototype2InnerHcalDetector.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4Prototype2InnerHcalDetector.cc
2 
3 #include <phparameter/PHParameters.h>
4 
5 #include <g4main/PHG4Detector.h> // for PHG4Detector
6 
7 #include <Geant4/G4AssemblyVolume.hh>
8 #include <Geant4/G4Box.hh>
9 #include <Geant4/G4Colour.hh>
10 #include <Geant4/G4ExtrudedSolid.hh>
11 #include <Geant4/G4LogicalVolume.hh>
12 #include <Geant4/G4Material.hh>
13 #include <Geant4/G4PVPlacement.hh>
14 #include <Geant4/G4RotationMatrix.hh>
15 #include <Geant4/G4String.hh> // for G4String
16 #include <Geant4/G4SystemOfUnits.hh>
17 #include <Geant4/G4ThreeVector.hh> // for G4ThreeVector
18 #include <Geant4/G4TwoVector.hh>
19 #include <Geant4/G4VPhysicalVolume.hh> // for G4VPhysicalVolume
20 #include <Geant4/G4VSolid.hh> // for G4VSolid
21 #include <Geant4/G4VisAttributes.hh>
22 
23 #include <boost/format.hpp>
24 
25 #include <cmath>
26 #include <iostream> // for operator<<, endl
27 #include <sstream>
28 #include <utility> // for pair, make_pair
29 #include <vector> // for vector, vector<>::...
30 
31 class PHCompositeNode;
32 
33 using namespace std;
34 
35 static const string scintimothername = "InnerHcalScintiMother";
36 static const string steelplatename = "InnerHcalSteelPlate";
37 
39  : PHG4Detector(subsys, Node, dnam)
40  , m_Params(parameters)
41  , m_InnerHcalSteelPlate(nullptr)
42  , m_InnerHcalAssembly(nullptr)
43  , m_SteelPlateCornerUpperLeft(1157.5 * mm, -151.44 * mm)
44  , m_SteelPlateCornerUpperRight(1308.5 * mm, -286.96 * mm)
45  , m_SteelPlateCornerLowerRight(1298.8 * mm, -297.39 * mm)
46  , m_SteelPlateCornerLowerLeft(1155.8 * mm, -163.92 * mm)
47  ,
48 
49  m_ScintiUoneFrontSize(105.9 * mm)
50  , m_ScintiUoneCornerUpperLeft(0 * mm, 0 * mm)
51  , m_ScintiUoneCornerUpperRight(198.1 * mm, 0 * mm)
52  , m_ScintiUoneCornerLowerRight(198.1 * mm, -121.3 * mm)
53  , m_ScintiUoneCornerLowerLeft(0 * mm, -m_ScintiUoneFrontSize)
54  ,
55 
56  m_ScintiU2CornerUpperLeft(0 * mm, 0 * mm)
57  , m_ScintiU2CornerUpperRight(198.1 * mm, -15.4 * mm)
58  , m_ScintiU2CornerLowerRight(198.1 * mm, -141.5 * mm)
59  , m_ScintiU2CornerLowerLeft(0 * mm, -110.59 * mm)
60  ,
61 
62  m_ScintiT9DistanceToCorner(26.44 * mm)
63  , m_ScintiT9FrontSize(140.3 * mm)
64  , m_ScintiT9CornerUpperLeft(0 * mm, 0 * mm)
65  , m_ScintiT9CornerUpperRight(198.1 * mm, -134.4 * mm)
66  , m_ScintiT9CornerLowerRight(198.1 * mm, -198.1 * mm / tan(52.02 / 180. * M_PI) - m_ScintiT9FrontSize)
67  , m_ScintiT9CornerLowerLeft(0 * mm, -m_ScintiT9FrontSize)
68  ,
69 
70  m_ScintiT10FrontSize(149.2 * mm)
71  , m_ScintiT10CornerUpperLeft(0 * mm, 0 * mm)
72  , m_ScintiT10CornerUpperRight(198.1 * mm, -154.6 * mm)
73  , m_ScintiT10CornerLowerRight(198.1 * mm, -198.1 * mm / tan(48.34 / 180. * M_PI) - m_ScintiT10FrontSize)
74  , m_ScintiT10CornerLowerLeft(0 * mm, -m_ScintiT10FrontSize)
75  ,
76 
77  m_ScintiT11FrontSize(144.3 * mm)
78  , m_ScintiT11CornerUpperLeft(0 * mm, 0 * mm)
79  , m_ScintiT11CornerUpperRight(198.1 * mm, -176.2 * mm)
80  , m_ScintiT11CornerLowerRight(198.1 * mm, -198.1 * mm / tan(45.14 / 180. * M_PI) - m_ScintiT11FrontSize)
81  , m_ScintiT11CornerLowerLeft(0 * mm, -m_ScintiT11FrontSize)
82  ,
83 
84  m_ScintiT12FrontSize(186.6 * mm)
85  , m_ScintiT12CornerUpperLeft(0 * mm, 0 * mm)
86  , m_ScintiT12CornerUpperRight(198.1 * mm, -197.11 * mm)
87  , m_ScintiT12CornerLowerRight(198.1 * mm, -198.1 * mm / tan(41.47 / 180. * M_PI) - m_ScintiT12FrontSize)
88  , m_ScintiT12CornerLowerLeft(0 * mm, -m_ScintiT12FrontSize)
89  ,
90 
91  m_ScintiX(198.1)
92  , m_SteelZ(901.7 * mm)
93  , m_SizeZ(m_SteelZ)
94  , m_ScintiTileZ(m_SteelZ)
95  , m_ScintiTileThickness(7 * mm)
96  , m_ScintiBoxSmaller(0.02 * mm)
97  , // blargh - off by 20 microns bc scinti tilt angle, need to revisit at some point
98  m_GapBetweenTiles(1 * mm)
99  , m_ScintiGap(8.5 * mm)
100  , m_DeltaPhi(2 * M_PI / 320.)
101  , m_VolumeSteel(NAN)
102  , m_VolumeScintillator(NAN)
103  , m_NScintiPlates(20)
104  , m_NSteelPlates(m_NScintiPlates + 1)
105  , m_ActiveFlag(m_Params->get_int_param("active"))
106  , m_AbsorberActiveFlag(m_Params->get_int_param("absorberactive"))
107  , m_Layer(0)
108 {
109 }
110 
112 {
113  delete m_InnerHcalAssembly;
114 }
115 
116 //_______________________________________________________________
117 //_______________________________________________________________
119 {
120  G4LogicalVolume* logvol = volume->GetLogicalVolume();
122  {
123  return -1;
124  }
125  if (m_ActiveFlag && m_ActiveVolumeSet.find(logvol) != m_ActiveVolumeSet.end())
126  {
127  return 1;
128  }
129  return 0;
130 }
131 
132 G4LogicalVolume*
134 {
136  {
137  G4VSolid* steel_plate;
138  std::vector<G4TwoVector> vertexes;
139  vertexes.push_back(m_SteelPlateCornerUpperLeft);
140  vertexes.push_back(m_SteelPlateCornerUpperRight);
141  vertexes.push_back(m_SteelPlateCornerLowerRight);
142  vertexes.push_back(m_SteelPlateCornerLowerLeft);
143  G4TwoVector zero(0, 0);
144  steel_plate = new G4ExtrudedSolid("InnerHcalSteelPlateSolid",
145  vertexes,
146  m_SizeZ / 2.0,
147  zero, 1.0,
148  zero, 1.0);
149 
150  m_VolumeSteel = steel_plate->GetCubicVolume() * m_NSteelPlates;
151  m_InnerHcalSteelPlate = new G4LogicalVolume(steel_plate, G4Material::GetMaterial("Steel_A36"), steelplatename, 0, 0, 0);
152  G4VisAttributes visattchk;
153  visattchk.SetVisibility(true);
154  visattchk.SetForceSolid(false);
155  visattchk.SetColour(G4Colour::Blue());
156  m_InnerHcalSteelPlate->SetVisAttributes(visattchk);
157  }
158  return m_InnerHcalSteelPlate;
159 }
160 
161 G4LogicalVolume*
163 {
164  int copynum = 0;
165  G4VSolid* scintiboxsolid = new G4Box(scintimothername, m_ScintiX / 2., (m_ScintiGap - m_ScintiBoxSmaller) / 2., m_ScintiTileZ / 2.);
166  // DisplayVolume(scintiboxsolid,hcalenvelope);
167 
168  G4LogicalVolume* scintiboxlogical = new G4LogicalVolume(scintiboxsolid, G4Material::GetMaterial("G4_AIR"), scintimothername, 0, 0, 0);
169  G4VisAttributes hcalVisAtt;
170  hcalVisAtt.SetVisibility(true);
171  hcalVisAtt.SetForceSolid(false);
172  hcalVisAtt.SetColour(G4Colour::Magenta());
173  G4LogicalVolume* scintit9_logic = ConstructScintiTile9(hcalenvelope);
174  scintit9_logic->SetVisAttributes(hcalVisAtt);
175 
176  double distance_to_corner = -m_SizeZ / 2. + m_ScintiT9DistanceToCorner;
177  G4RotationMatrix* Rot;
178  Rot = new G4RotationMatrix();
179  Rot->rotateX(90 * deg);
180  new G4PVPlacement(Rot, G4ThreeVector(-m_ScintiX / 2., 0, distance_to_corner), scintit9_logic, (boost::format("InnerScinti_%d") % copynum).str(), scintiboxlogical, false, copynum, OverlapCheck());
181 
182  hcalVisAtt.SetVisibility(true);
183  hcalVisAtt.SetForceSolid(false);
184  hcalVisAtt.SetColour(G4Colour::Blue());
185  G4LogicalVolume* scintit10_logic = ConstructScintiTile10(hcalenvelope);
186  scintit10_logic->SetVisAttributes(hcalVisAtt);
187 
188  distance_to_corner += m_ScintiT9FrontSize + m_GapBetweenTiles;
189  Rot = new G4RotationMatrix();
190  Rot->rotateX(90 * deg);
191  copynum++;
192  new G4PVPlacement(Rot, G4ThreeVector(-m_ScintiX / 2., 0, distance_to_corner), scintit10_logic, (boost::format("InnerScinti_%d") % copynum).str(), scintiboxlogical, false, copynum, OverlapCheck());
193 
194  hcalVisAtt.SetVisibility(true);
195  hcalVisAtt.SetForceSolid(false);
196  hcalVisAtt.SetColour(G4Colour::Yellow());
197  G4LogicalVolume* scintit11_logic = ConstructScintiTile11(hcalenvelope);
198  scintit11_logic->SetVisAttributes(hcalVisAtt);
199 
200  distance_to_corner += m_ScintiT10FrontSize + m_GapBetweenTiles;
201  Rot = new G4RotationMatrix();
202  Rot->rotateX(90 * deg);
203  copynum++;
204  new G4PVPlacement(Rot, G4ThreeVector(-m_ScintiX / 2., 0, distance_to_corner), scintit11_logic, (boost::format("InnerScinti_%d") % copynum).str(), scintiboxlogical, false, copynum, OverlapCheck());
205 
206  hcalVisAtt.SetVisibility(true);
207  hcalVisAtt.SetForceSolid(false);
208  hcalVisAtt.SetColour(G4Colour::Cyan());
209  G4LogicalVolume* scintit12_logic = ConstructScintiTile12(hcalenvelope);
210  scintit12_logic->SetVisAttributes(hcalVisAtt);
211 
212  distance_to_corner += m_ScintiT11FrontSize + m_GapBetweenTiles;
213  Rot = new G4RotationMatrix();
214  Rot->rotateX(90 * deg);
215  copynum++;
216  new G4PVPlacement(Rot, G4ThreeVector(-m_ScintiX / 2., 0, distance_to_corner), scintit12_logic, (boost::format("InnerScinti_%d") % copynum).str(), scintiboxlogical, false, copynum, OverlapCheck());
217 
218  // DisplayVolume(scintiboxlogical,hcalenvelope);
219  return scintiboxlogical;
220 }
221 
222 G4LogicalVolume*
224 {
225  int copynum = 0;
226  G4VSolid* scintiboxsolid = new G4Box(scintimothername, m_ScintiX / 2., (m_ScintiGap - m_ScintiBoxSmaller) / 2., m_ScintiTileZ / 2.);
227  // DisplayVolume(scintiboxsolid,hcalenvelope);
228  G4LogicalVolume* scintiboxlogical = new G4LogicalVolume(scintiboxsolid, G4Material::GetMaterial("G4_AIR"), scintimothername, 0, 0, 0);
229  G4VisAttributes hcalVisAtt;
230  hcalVisAtt.SetVisibility(true);
231  hcalVisAtt.SetForceSolid(false);
232  hcalVisAtt.SetColour(G4Colour::Red());
233  G4LogicalVolume* scintiu1_logic = ConstructScintiTileU1(hcalenvelope);
234  scintiu1_logic->SetVisAttributes(hcalVisAtt);
235 
236  hcalVisAtt.SetVisibility(true);
237  hcalVisAtt.SetForceSolid(false);
238  hcalVisAtt.SetColour(G4Colour::Cyan());
239  G4LogicalVolume* scintiu2_logic = ConstructScintiTileU2(hcalenvelope);
240  scintiu2_logic->SetVisAttributes(hcalVisAtt);
241  G4RotationMatrix* Rot;
242  Rot = new G4RotationMatrix();
243  Rot->rotateX(-90 * deg);
244  new G4PVPlacement(Rot, G4ThreeVector(-m_ScintiX / 2., 0, -m_ScintiUoneFrontSize - m_GapBetweenTiles / 2. - m_GapBetweenTiles), scintiu2_logic, (boost::format("InnerScinti_%d") % copynum).str(), scintiboxlogical, false, copynum, OverlapCheck());
245 
246  Rot = new G4RotationMatrix();
247  Rot->rotateX(-90 * deg);
248  copynum++;
249  new G4PVPlacement(Rot, G4ThreeVector(-m_ScintiX / 2., 0, -m_GapBetweenTiles / 2.), scintiu1_logic, (boost::format("InnerScinti_%d") % copynum).str(), scintiboxlogical, false, copynum, OverlapCheck());
250 
251  Rot = new G4RotationMatrix();
252  Rot->rotateX(90 * deg);
253  copynum++;
254  new G4PVPlacement(Rot, G4ThreeVector(-m_ScintiX / 2., 0, m_GapBetweenTiles / 2.), scintiu1_logic, (boost::format("InnerScinti_%d") % copynum).str(), scintiboxlogical, false, copynum, OverlapCheck());
255 
256  Rot = new G4RotationMatrix();
257  Rot->rotateX(90 * deg);
258  copynum++;
259  new G4PVPlacement(Rot, G4ThreeVector(-m_ScintiX / 2., 0, m_ScintiUoneFrontSize + m_GapBetweenTiles / 2. + m_GapBetweenTiles), scintiu2_logic, (boost::format("InnerScinti_%d") % copynum).str(), scintiboxlogical, false, copynum, OverlapCheck());
260  // DisplayVolume(scintiboxlogical,hcalenvelope);
261  return scintiboxlogical;
262 }
263 
264 G4LogicalVolume*
266 {
267  std::vector<G4TwoVector> vertexes;
268  vertexes.push_back(m_ScintiUoneCornerUpperLeft);
269  vertexes.push_back(m_ScintiUoneCornerUpperRight);
270  vertexes.push_back(m_ScintiUoneCornerLowerRight);
271  vertexes.push_back(m_ScintiUoneCornerLowerLeft);
272  G4TwoVector zero(0, 0);
273  G4VSolid* scintiu1 = new G4ExtrudedSolid("InnerHcalScintiU1",
274  vertexes,
275  m_ScintiTileThickness / 2.0,
276  zero, 1.0,
277  zero, 1.0);
278 
279  G4LogicalVolume* scintiu1_logic = new G4LogicalVolume(scintiu1, G4Material::GetMaterial("G4_POLYSTYRENE"), "InnerHcalScintiU1", nullptr, nullptr, nullptr);
280  // DisplayVolume(scintiu1,hcalenvelope);
281  m_ActiveVolumeSet.insert(scintiu1_logic);
282  return scintiu1_logic;
283 }
284 
285 G4LogicalVolume*
287 {
288  std::vector<G4TwoVector> vertexes;
289  vertexes.push_back(m_ScintiU2CornerUpperLeft);
290  vertexes.push_back(m_ScintiU2CornerUpperRight);
291  vertexes.push_back(m_ScintiU2CornerLowerRight);
292  vertexes.push_back(m_ScintiU2CornerLowerLeft);
293  G4TwoVector zero(0, 0);
294  G4VSolid* scintiu2 = new G4ExtrudedSolid("InnerHcalScintiU2",
295  vertexes,
296  m_ScintiTileThickness / 2.0,
297  zero, 1.0,
298  zero, 1.0);
299 
300  G4LogicalVolume* scintiu2_logic = new G4LogicalVolume(scintiu2, G4Material::GetMaterial("G4_POLYSTYRENE"), "InnerHcalScintiU2", nullptr, nullptr, nullptr);
301  // DisplayVolume(scintiu2,hcalenvelope);
302  m_ActiveVolumeSet.insert(scintiu2_logic);
303  return scintiu2_logic;
304 }
305 
306 G4LogicalVolume*
308 {
309  std::vector<G4TwoVector> vertexes;
310  vertexes.push_back(m_ScintiT9CornerUpperLeft);
311  vertexes.push_back(m_ScintiT9CornerUpperRight);
312  vertexes.push_back(m_ScintiT9CornerLowerRight);
313  vertexes.push_back(m_ScintiT9CornerLowerLeft);
314  G4TwoVector zero(0, 0);
315  G4VSolid* scintit9 = new G4ExtrudedSolid("InnerHcalScintiT9",
316  vertexes,
317  m_ScintiTileThickness / 2.0,
318  zero, 1.0,
319  zero, 1.0);
320 
321  G4LogicalVolume* scintit9_logic = new G4LogicalVolume(scintit9, G4Material::GetMaterial("G4_POLYSTYRENE"), "InnerHcalScintiT9", nullptr, nullptr, nullptr);
322  // DisplayVolume(scintit9,hcalenvelope);
323  m_ActiveVolumeSet.insert(scintit9_logic);
324  return scintit9_logic;
325 }
326 
327 G4LogicalVolume*
329 {
330  std::vector<G4TwoVector> vertexes;
331  vertexes.push_back(m_ScintiT10CornerUpperLeft);
332  vertexes.push_back(m_ScintiT10CornerUpperRight);
333  vertexes.push_back(m_ScintiT10CornerLowerRight);
334  vertexes.push_back(m_ScintiT10CornerLowerLeft);
335  G4TwoVector zero(0, 0);
336  G4VSolid* scintit10 = new G4ExtrudedSolid("InnerHcalScintiT10",
337  vertexes,
338  m_ScintiTileThickness / 2.0,
339  zero, 1.0,
340  zero, 1.0);
341 
342  G4LogicalVolume* scintit10_logic = new G4LogicalVolume(scintit10, G4Material::GetMaterial("G4_POLYSTYRENE"), "InnerHcalScintiT10", nullptr, nullptr, nullptr);
343  // DisplayVolume(scintit10,hcalenvelope);
344  m_ActiveVolumeSet.insert(scintit10_logic);
345  return scintit10_logic;
346 }
347 
348 G4LogicalVolume*
350 {
351  std::vector<G4TwoVector> vertexes;
352  vertexes.push_back(m_ScintiT11CornerUpperLeft);
353  vertexes.push_back(m_ScintiT11CornerUpperRight);
354  vertexes.push_back(m_ScintiT11CornerLowerRight);
355  vertexes.push_back(m_ScintiT11CornerLowerLeft);
356  G4TwoVector zero(0, 0);
357  G4VSolid* scintit11 = new G4ExtrudedSolid("InnerHcalScintiT11",
358  vertexes,
359  m_ScintiTileThickness / 2.0,
360  zero, 1.0,
361  zero, 1.0);
362 
363  G4LogicalVolume* scintit11_logic = new G4LogicalVolume(scintit11, G4Material::GetMaterial("G4_POLYSTYRENE"), "InnerHcalScintiT11", nullptr, nullptr, nullptr);
364  // DisplayVolume(scintit11,hcalenvelope);
365  m_ActiveVolumeSet.insert(scintit11_logic);
366  return scintit11_logic;
367 }
368 
369 G4LogicalVolume*
371 {
372  std::vector<G4TwoVector> vertexes;
373  vertexes.push_back(m_ScintiT12CornerUpperLeft);
374  vertexes.push_back(m_ScintiT12CornerUpperRight);
375  vertexes.push_back(m_ScintiT12CornerLowerRight);
376  vertexes.push_back(m_ScintiT12CornerLowerLeft);
377  G4TwoVector zero(0, 0);
378  G4VSolid* scintit12 = new G4ExtrudedSolid("InnerHcalScintiT12",
379  vertexes,
380  m_ScintiTileThickness / 2.0,
381  zero, 1.0,
382  zero, 1.0);
383 
384  G4LogicalVolume* scintit12_logic = new G4LogicalVolume(scintit12, G4Material::GetMaterial("G4_POLYSTYRENE"), "InnerHcalScintiT12", nullptr, nullptr, nullptr);
385  // DisplayVolume(scintit12,hcalenvelope);
386  m_ActiveVolumeSet.insert(scintit12_logic);
387  return scintit12_logic;
388 }
389 
390 // Construct the envelope and the call the
391 // actual inner hcal construction
392 void PHG4Prototype2InnerHcalDetector::ConstructMe(G4LogicalVolume* logicWorld)
393 {
394  G4ThreeVector g4vec(m_Params->get_double_param("place_x") * cm,
395  m_Params->get_double_param("place_y") * cm,
396  m_Params->get_double_param("place_z") * cm);
397  G4RotationMatrix Rot;
398  Rot.rotateX(m_Params->get_double_param("rot_x") * deg);
399  Rot.rotateY(m_Params->get_double_param("rot_y") * deg);
400  Rot.rotateZ(m_Params->get_double_param("rot_z") * deg);
401  // ConstructScintiTile9(logicWorld);
402  // ConstructScintillatorBoxHiEta(logicWorld);
403  //ConstructScintillatorBox(logicWorld);
404  // return;
405  m_InnerHcalAssembly = new G4AssemblyVolume();
406  //ConstructSteelPlate(hcal_envelope_log);
407  // return;
408  ConstructInnerHcal(logicWorld);
409  m_InnerHcalAssembly->MakeImprint(logicWorld, g4vec, &Rot, 0, OverlapCheck());
410  // this is rather pathetic - there is no way to extract the name when a volume is added
411  // to the assembly. The only thing we can do is get an iterator over the placed volumes
412  // in the order in which they were placed. Since this code does not install the scintillators
413  // for the Al version, parsing the volume names to get the id does not work since it changes
414  // So now we loop over all volumes and store them in a map for fast lookup of the row
415  int isteel = 0;
416  int iscinti = 0;
417  vector<G4VPhysicalVolume*>::iterator it = m_InnerHcalAssembly->GetVolumesIterator();
418  for (unsigned int i = 0; i < m_InnerHcalAssembly->TotalImprintedVolumes(); i++)
419  {
420  string volname = (*it)->GetName();
421  if (volname.find(steelplatename) != string::npos)
422  {
423  m_SteelPlateIdMap.insert(make_pair(volname, isteel));
424  ++isteel;
425  }
426  else if (volname.find(scintimothername) != string::npos)
427  {
428  m_ScintillatorIdMap.insert(make_pair(volname, iscinti));
429  ++iscinti;
430  }
431  ++it;
432  }
433  // print out volume names and their assigned id
434  // map<string,int>::const_iterator iter;
435  // for (iter = m_SteelPlateIdMap.begin(); iter != m_SteelPlateIdMap.end(); ++iter)
436  // {
437  // cout << iter->first << ", " << iter->second << endl;
438  // }
439  // for (iter = m_ScintillatorIdMap.begin(); iter != m_ScintillatorIdMap.end(); ++iter)
440  // {
441  // cout << iter->first << ", " << iter->second << endl;
442  // }
443  return;
444 }
445 
446 int PHG4Prototype2InnerHcalDetector::ConstructInnerHcal(G4LogicalVolume* hcalenvelope)
447 {
448  G4LogicalVolume* steel_plate = ConstructSteelPlate(hcalenvelope); // bottom steel plate
449  G4LogicalVolume* scintibox = nullptr;
450  if (m_Params->get_int_param("hi_eta"))
451  {
452  scintibox = ConstructScintillatorBoxHiEta(hcalenvelope);
453  }
454  else
455  {
456  scintibox = ConstructScintillatorBox(hcalenvelope);
457  }
458  double phi = 0.;
459  double phislat = 0.;
460  // the coordinate of the center of the bottom of the bottom steel plate
461  // to get the radius of the circle which is the center of the scintillator box
462  double bottom_xmiddle_steel_tile = (m_SteelPlateCornerLowerRight.x() + m_SteelPlateCornerLowerLeft.x()) / 2.;
463  double bottom_ymiddle_steel_tile = (m_SteelPlateCornerLowerLeft.y() + m_SteelPlateCornerLowerRight.y()) / 2.;
464  double middlerad = sqrt(bottom_xmiddle_steel_tile * bottom_xmiddle_steel_tile + bottom_ymiddle_steel_tile * bottom_ymiddle_steel_tile);
465  double philow = atan((bottom_ymiddle_steel_tile - m_ScintiGap / 2. - 0.87 * mm) / bottom_xmiddle_steel_tile);
466  double scintiangle = GetScintiAngle();
467  for (int i = 0; i < m_NSteelPlates; i++)
468  {
469  G4RotationMatrix Rot;
470  Rot.rotateZ(phi * rad);
471  G4ThreeVector g4vec(0, 0, 0);
472  m_InnerHcalAssembly->AddPlacedVolume(steel_plate, g4vec, &Rot);
473  if (i > 0)
474  {
475  double ypos = sin(phi + philow) * middlerad;
476  double xpos = cos(phi + philow) * middlerad;
477  G4RotationMatrix Rot1;
478  Rot1.rotateZ(scintiangle + phislat);
479  G4ThreeVector g4vecsc(xpos, ypos, 0);
480  m_InnerHcalAssembly->AddPlacedVolume(scintibox, g4vecsc, &Rot1);
481  phislat += m_DeltaPhi;
482  }
483  phi += m_DeltaPhi;
484  }
485  return 0;
486 }
487 
488 // calculate the angle of the bottom scintillator. It is the angle of the top edge
489 // of the steel plate
490 double
492 {
495  double angle = atan(ylen / xlen);
496  return angle;
497 }
498 
499 void PHG4Prototype2InnerHcalDetector::Print(const string& what) const
500 {
501  cout << "Inner Hcal Detector:" << endl;
502  if (what == "ALL" || what == "VOLUME")
503  {
504  cout << "Volume Steel: " << m_VolumeSteel / cm3 << " cm^3" << endl;
505  cout << "Volume Scintillator: " << m_VolumeScintillator / cm3 << " cm^3" << endl;
506  }
507  return;
508 }
510 {
511  int id = -9999;
512  auto it = m_ScintillatorIdMap.find(volname);
513  if (it != m_ScintillatorIdMap.end())
514  {
515  id = it->second;
516  }
517  else
518  {
519  cout << "unknown scintillator volume name: " << volname << endl;
520  }
521 
522  return id;
523 }
524 
526 {
527  int id = -9999;
528  auto it = m_SteelPlateIdMap.find(volname);
529  if (it != m_SteelPlateIdMap.end())
530  {
531  id = it->second;
532  }
533  else
534  {
535  cout << "unknown steel volume name: " << volname << endl;
536  }
537  return id;
538 }