ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EICG4ZDCDetector.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EICG4ZDCDetector.cc
1 //____________________________________________________________________________..
2 //
3 // This is a working template for the G4 Construct() method which needs to be implemented
4 // We wedge a method between the G4 Construct() to enable volume hierarchies on the macro
5 // so here it is called ConstructMe() but there is no functional difference
6 // Currently this installs a simple G4Box solid, creates a logical volume from it
7 // and places it. Put your own detector in place (just make sure all active volumes
8 // get inserted into the m_PhysicalVolumesSet)
9 //
10 // Rather than using hardcoded values you should consider using the parameter class
11 // Parameter names and defaults are set in EICG4ZDCSubsystem::SetDefaultParameters()
12 // Only parameters defined there can be used (also to override in the macro)
13 // to avoids typos.
14 // IMPORTANT: parameters have no inherent units, there is a convention (cm/deg)
15 // but in any case you need to multiply them here with the correct CLHEP/G4 unit
16 //
17 // The place where you put your own detector is marked with
18 // //begin implement your own here://
19 // //end implement your own here://
20 // Do not forget to include the G4 includes for your volumes
21 //____________________________________________________________________________..
22 //
23 // -1/June/2021 First ZDC design (Crystal + FoCal style) Shima Shimizu
24 // Provides volume info for TTree/Ntuple production
25 // -14/Dec/2021 Second ZDC design (1 layer Crystal)
26 // modifications for: Absorber info, Digitization,
27 //
28 #include "EICG4ZDCDetector.h"
29 #include "EICG4ZDCStructure.h"
30 
31 #include <phparameter/PHParameters.h>
32 
33 #include <g4main/PHG4Detector.h>
34 
35 #include <Geant4/G4Box.hh>
36 #include <Geant4/G4Color.hh>
37 #include <Geant4/G4LogicalVolume.hh>
38 #include <Geant4/G4Material.hh>
39 #include <Geant4/G4PVPlacement.hh>
40 #include <Geant4/G4SystemOfUnits.hh>
41 #include <Geant4/G4VisAttributes.hh>
42 #include <Geant4/G4NistManager.hh>
43 #include <Geant4/G4Material.hh>
44 
45 #include <cmath>
46 #include <iostream>
47 
48 class G4VSolid;
49 class PHCompositeNode;
50 
51 using namespace std;
52 
53 //____________________________________________________________________________..
55  PHCompositeNode *Node,
57  const std::string &dnam)
58  : PHG4Detector(subsys, Node, dnam)
59  , m_Params(parameters)
60 {
61 }
62 
63 //_______________________________________________________________
65 {
66 
67  G4LogicalVolume *lvolume = volume->GetLogicalVolume();
68  set<G4LogicalVolume *>::const_iterator iter_active
69  = m_ActiveLogicalVolumesSet.find(lvolume);
70  if (iter_active != m_ActiveLogicalVolumesSet.end()) return 1;
71  set<G4LogicalVolume *>::const_iterator iter_absorber
72  = m_AbsorberLogicalVolumesSet.find(lvolume);
73  if (iter_absorber != m_AbsorberLogicalVolumesSet.end()) return -1;
74 
75  return 0;
76 }
77 
79 
80  G4LogicalVolume *lvolume = volume->GetLogicalVolume();
81  int lvinfo = m_ActiveLogicalVolumeInfoMap[lvolume];
82  return lvinfo;
83 }
84 
86 
87  G4LogicalVolume *lvolume = volume->GetLogicalVolume();
88  int lvinfo = m_AbsorberLogicalVolumeInfoMap[lvolume];
89  return lvinfo;
90 }
91 
92 //_______________________________________________________________
94 {
95  //begin implement your own here://
96  // Do not forget to multiply the parameters with their respective CLHEP/G4 unit !
97  double xdim = m_Params->get_double_param("size_x") * cm;
98  double ydim = m_Params->get_double_param("size_y") * cm;
99  double zdim = m_Params->get_double_param("size_z") * cm;
100  G4VSolid *solidbox = new G4Box("ZDCSolid", xdim / 2., ydim / 2., zdim / 2.);
101  G4LogicalVolume *logical = new G4LogicalVolume(solidbox, GetDetectorMaterial("G4_Galactic"), "ZDCLogical");
102 
104  G4RotationMatrix *rotm = new G4RotationMatrix();
105  rotm->rotateX(m_Params->get_double_param("rot_x") * rad);
106  rotm->rotateY(m_Params->get_double_param("rot_y") * rad);
107  rotm->rotateZ(m_Params->get_double_param("rot_z") * rad);
108 
109  G4VPhysicalVolume *gPhy = new G4PVPlacement(
110  rotm,
112  m_Params->get_double_param("place_y") * cm,
113  m_Params->get_double_param("place_z") * cm),
114  logical, "ZDC", logicWorld, 0, false, OverlapCheck());
115 
117  double endz = -zdim/2.;
118 
119  endz = mzs->ConstructCrystalTowers(-xdim/2.,-ydim/2.,-zdim/2.,
120  xdim/2., ydim/2., zdim/2., gPhy);
121 
122  endz = mzs->ConstructEMLayers(-xdim *0.5, -ydim*0.5, endz,
123  xdim*0.5, ydim*0.5, zdim*0.5, gPhy);
124 
125  endz = mzs->ConstructHCSiliconLayers(-xdim *0.5, -ydim*0.5, endz + 20.*mm,
126  xdim*0.5, ydim*0.5, zdim*0.5, gPhy);
127 
128  endz = mzs->ConstructHCSciLayers(-xdim *0.5, -ydim*0.5, endz + 20.*mm,
129  xdim*0.5, ydim*0.5, zdim*0.5, gPhy);
130 
131  mzs->ProvideLogicalVolumesSets(m_ActiveLogicalVolumesSet,
133  mzs->ProvideLogicalVolumeInfoMap(m_ActiveLogicalVolumeInfoMap,
135 
136  // mzs->PrintTowerMap("Crystal");
137  // mzs->PrintTowerMap("SiPixel");
138  // mzs->PrintTowerMap("SiPad");
139  // mzs->PrintTowerMap("Sci");
140 
141  //end implement your own here://
142  return;
143 }
144 
145 //_______________________________________________________________
146 void EICG4ZDCDetector::Print(const std::string &what) const
147 {
148  std::cout << "EICG4ZDC Detector:" << std::endl;
149  if (what == "ALL" || what == "VOLUME")
150  {
151  std::cout << "Version 1.1" << std::endl;
152  std::cout << "Parameters:" << std::endl;
153  m_Params->Print();
154  }
155  return;
156 }