ECCE @ EIC 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 using namespace std;
27 
28 //___________________________________________________________________________________
30  : PHG4Detector(subsys, Node, dnam)
31  , _placeInX(0.0 * mm)
32  , _placeInY(0.0 * mm)
33  , _placeInZ(2.0 * m)
34  , _innerRadius(0.0 * m)
35  , _outerRadius(1.0 * m)
36  , _dZ(1.0 * mm)
37  , _dZ_cyl(2.0 * m)
38  , _sPhi(0)
39  , _dPhi(2 * M_PI)
40  , _materialCrystal("G4_PbWO4")
41  , _active(1)
42  , _layer(0)
43  , _superdetector("NONE")
44 {
45 }
46 
47 //_______________________________________________________________________________________
49 {
50  if (volume->GetName().find("arbage") != string::npos)
51  {
52  return true;
53  }
54  else
55  {
56  return false;
57  }
58 }
59 
61 {
62  //***************
63  //Backward Endcap
64  //***************
65 
66  G4double placeInZ = _placeInZ;
67  G4double placeInY = _placeInY;
68  G4double placeInX = _placeInX;
69 
70  G4double rMin1 = _innerRadius;
71  G4double rMax1 = _outerRadius;
72  G4double rMin2 = rMin1;
73  G4double rMax2 = rMax1;
74  G4double dZ = _dZ;
75  G4double sPhi = _sPhi;
76  G4double dPhi = _dPhi;
77 
78  G4Material* material_crystal = GetDetectorMaterial("G4_PbWO4");
79 
80  G4VSolid* GarbageCollector_solid = new G4Cons("GarbageCollector_solid",
81  rMin1, rMax1,
82  rMin2, rMax2,
83  dZ / 2.,
84  sPhi, dPhi);
85 
86  G4LogicalVolume* GarbageCollector_logical = new G4LogicalVolume(GarbageCollector_solid, material_crystal, G4String("GarbageCollector"), 0, 0, 0);
87 
88  G4VisAttributes* ecalVisAtt = new G4VisAttributes();
89  ecalVisAtt->SetVisibility(true);
90  ecalVisAtt->SetForceSolid(false);
91  ecalVisAtt->SetColour(G4Colour::Magenta());
92  GarbageCollector_logical->SetVisAttributes(ecalVisAtt);
93 
94  G4RotationMatrix ecal_rotm;
95  ecal_rotm.rotateX(0);
96  ecal_rotm.rotateY(0);
97  ecal_rotm.rotateZ(0);
98 
99  new G4PVPlacement(G4Transform3D(ecal_rotm, G4ThreeVector(placeInX, placeInY, placeInZ)),
100  GarbageCollector_logical,
101  "GarbageCollector",
102  logicWorld,
103  0,
104  false,
105  OverlapCheck());
106 
107  //**************
108  //Forward Endcap
109  //**************
110 
111  new G4PVPlacement(G4Transform3D(ecal_rotm, G4ThreeVector(placeInX, placeInY, -1 * placeInZ)),
112  GarbageCollector_logical,
113  "GarbageCollector_front",
114  logicWorld,
115  0,
116  false,
117  OverlapCheck());
118 
119  //*****************************
120  //Cylinder Surrounding Detector
121  //*****************************
122 
123  G4double cyl_place = 0 * mm;
124  G4double r_min = _outerRadius + (1) * mm;
125  G4double r_max = r_min + 1 * mm;
126  G4double dZ_cyl = _dZ_cyl;
127 
128  G4VSolid* GarbageCollector_cyl_solid = new G4Tubs("GarbageCollector_cyl_solid",
129  r_min,
130  r_max,
131  dZ_cyl,
132  sPhi,
133  dPhi);
134 
135  G4LogicalVolume* GarbageCollector_cyl_logical = new G4LogicalVolume(GarbageCollector_cyl_solid,
136  material_crystal,
137  G4String("GarbageCollector_cyl"),
138  0,
139  0,
140  0);
141 
142  GarbageCollector_cyl_logical->SetVisAttributes(ecalVisAtt);
143 
144  new G4PVPlacement(G4Transform3D(ecal_rotm, G4ThreeVector(0, 0, cyl_place)),
145  GarbageCollector_cyl_logical,
146  "GarbageCollector_cyl",
147  logicWorld,
148  0,
149  false,
150  OverlapCheck());
151 }