Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4EnvelopeDetector.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4EnvelopeDetector.cc
1 #include "PHG4EnvelopeDetector.h"
2 
3 #include <g4main/PHG4Detector.h> // for PHG4Detector
4 
5 #include <Geant4/G4Colour.hh>
6 #include <Geant4/G4Cons.hh>
7 #include <Geant4/G4LogicalVolume.hh>
8 #include <Geant4/G4PVPlacement.hh>
9 #include <Geant4/G4RotationMatrix.hh> // for G4RotationMatrix
10 #include <Geant4/G4String.hh> // for G4String
11 #include <Geant4/G4SystemOfUnits.hh> // for mm, m
12 #include <Geant4/G4ThreeVector.hh> // for G4ThreeVector
13 #include <Geant4/G4Transform3D.hh> // for G4Transform3D
14 #include <Geant4/G4Tubs.hh>
15 #include <Geant4/G4Types.hh> // for G4double
16 #include <Geant4/G4VPhysicalVolume.hh> // for G4VPhysicalVolume
17 #include <Geant4/G4VisAttributes.hh>
18 
19 #include <cmath> // for M_PI
20 #include <iostream>
21 
22 class G4Material;
23 class G4VSolid;
24 class PHCompositeNode;
25 
26 //___________________________________________________________________________________
28  : PHG4Detector(subsys, Node, dnam)
29  , _placeInX(0.0 * mm)
30  , _placeInY(0.0 * mm)
31  , _placeInZ(2.0 * m)
32  , _innerRadius(0.0 * m)
33  , _outerRadius(1.0 * m)
34  , _dZ(1.0 * mm)
35  , _dZ_cyl(2.0 * m)
36  , _sPhi(0)
37  , _dPhi(2 * M_PI)
38  , _materialCrystal("G4_PbWO4")
39  , _active(1)
40  , _layer(0)
41  , _superdetector("NONE")
42 {
43 }
44 
45 //_______________________________________________________________________________________
47 {
48  if (volume->GetName().find("arbage") != std::string::npos)
49  {
50  return true;
51  }
52  else
53  {
54  return false;
55  }
56 }
57 
58 void PHG4EnvelopeDetector::ConstructMe(G4LogicalVolume* logicWorld)
59 {
60  //***************
61  // Backward Endcap
62  //***************
63 
64  G4double placeInZ = _placeInZ;
65  G4double placeInY = _placeInY;
66  G4double placeInX = _placeInX;
67 
68  G4double rMin1 = _innerRadius;
69  G4double rMax1 = _outerRadius;
70  G4double rMin2 = rMin1;
71  G4double rMax2 = rMax1;
72  G4double dZ = _dZ;
73  G4double sPhi = _sPhi;
74  G4double dPhi = _dPhi;
75 
76  G4Material* material_crystal = GetDetectorMaterial("G4_PbWO4");
77 
78  G4VSolid* GarbageCollector_solid = new G4Cons("GarbageCollector_solid",
79  rMin1, rMax1,
80  rMin2, rMax2,
81  dZ / 2.,
82  sPhi, dPhi);
83 
84  G4LogicalVolume* GarbageCollector_logical = new G4LogicalVolume(GarbageCollector_solid, material_crystal, G4String("GarbageCollector"), nullptr, nullptr, nullptr);
85 
86  G4VisAttributes* ecalVisAtt = new G4VisAttributes();
87  ecalVisAtt->SetVisibility(true);
88  ecalVisAtt->SetForceSolid(false);
89  ecalVisAtt->SetColour(G4Colour::Magenta());
90  GarbageCollector_logical->SetVisAttributes(ecalVisAtt);
91 
92  G4RotationMatrix ecal_rotm;
93  ecal_rotm.rotateX(0);
94  ecal_rotm.rotateY(0);
95  ecal_rotm.rotateZ(0);
96 
97  new G4PVPlacement(G4Transform3D(ecal_rotm, G4ThreeVector(placeInX, placeInY, placeInZ)),
98  GarbageCollector_logical,
99  "GarbageCollector",
100  logicWorld,
101  false,
102  false,
103  OverlapCheck());
104 
105  //**************
106  // Forward Endcap
107  //**************
108 
109  new G4PVPlacement(G4Transform3D(ecal_rotm, G4ThreeVector(placeInX, placeInY, -1 * placeInZ)),
110  GarbageCollector_logical,
111  "GarbageCollector_front",
112  logicWorld,
113  false,
114  false,
115  OverlapCheck());
116 
117  //*****************************
118  // Cylinder Surrounding Detector
119  //*****************************
120 
121  G4double cyl_place = 0 * mm;
122  G4double r_min = _outerRadius + (1) * mm;
123  G4double r_max = r_min + 1 * mm;
124  G4double dZ_cyl = _dZ_cyl;
125 
126  G4VSolid* GarbageCollector_cyl_solid = new G4Tubs("GarbageCollector_cyl_solid",
127  r_min,
128  r_max,
129  dZ_cyl,
130  sPhi,
131  dPhi);
132 
133  G4LogicalVolume* GarbageCollector_cyl_logical = new G4LogicalVolume(GarbageCollector_cyl_solid,
134  material_crystal,
135  G4String("GarbageCollector_cyl"),
136  nullptr,
137  nullptr,
138  nullptr);
139 
140  GarbageCollector_cyl_logical->SetVisAttributes(ecalVisAtt);
141 
142  new G4PVPlacement(G4Transform3D(ecal_rotm, G4ThreeVector(0, 0, cyl_place)),
143  GarbageCollector_cyl_logical,
144  "GarbageCollector_cyl",
145  logicWorld,
146  false,
147  false,
148  OverlapCheck());
149 }