Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4SpacalSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4SpacalSubsystem.cc
1 
8 #include "PHG4SpacalSubsystem.h"
9 
10 #include "PHG4CylinderGeom_Spacalv1.h" // for PHG4CylinderGeom_Spacalv1
13 #include "PHG4SpacalDetector.h"
16 
17 #include <phparameter/PHParameters.h>
18 
19 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
21 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
22 
23 #include <phool/PHCompositeNode.h>
24 #include <phool/PHIODataNode.h> // for PHIODataNode
25 #include <phool/PHNode.h> // for PHNode
26 #include <phool/PHNodeIterator.h> // for PHNodeIterator
27 #include <phool/PHObject.h> // for PHObject
28 #include <phool/getClass.h>
29 
30 #include <TSystem.h>
31 
32 #include <cstdlib>
33 #include <iostream> // for operator<<, basic_ostream
34 #include <sstream>
35 #include <cassert>
36 
37 class PHG4Detector;
38 
39 //_______________________________________________________________________
41  : PHG4DetectorSubsystem(na, lyr)
42 {
44 }
45 
46 //_______________________________________________________________________
48 {
49  delete m_DisplayAction;
50 }
51 
52 //_______________________________________________________________________
54 {
55  // create hit list only for active layers
56  PHNodeIterator iter(topNode);
57  PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
58  // create detector
59  // _geom.set_layer( layer );
60  // if (lengthViaRapidityCoverage)
61  // {
62  // const double half_length = PHG4Utils::GetLengthForRapidityCoverage(_geom.get_max_radius());
63  // _geom.set_zmin(-half_length);
64  // _geom.set_zmax(+half_length);
65  // }
66  // create display settings before detector (detector adds its volumes to it)
68  switch (GetParams()->get_int_param("config"))
69  {
71  if (Verbosity() > 0) std::cout << "PHG4SpacalSubsystem::InitRun - use PHG4SpacalDetector" << std::endl;
72  detector_ = new PHG4SpacalDetector(this, topNode, Name(), GetParams(), GetLayer());
73  break;
74 
77  if (Verbosity() > 0) std::cout << "PHG4SpacalSubsystem::InitRun - use PHG4FullProjSpacalDetector" << std::endl;
78  detector_ = new PHG4FullProjSpacalDetector(this, topNode, Name(), GetParams(), GetLayer());
79  break;
80 
83  if (Verbosity() > 0) std::cout << "PHG4SpacalSubsystem::InitRun - use PHG4FullProjTiltedSpacalDetector" << std::endl;
85  break;
86 
87  default:
88  std::cout << "PHG4SpacalSubsystem::InitRun - unknown option exiting" << std::endl;
89  gSystem->Exit(1);
90  break;
91  }
92 
94  detector_->SetAbsorberActive(GetParams()->get_int_param("absorberactive"));
98  // the geometry object is set during detector construction, we need it for the
99  // display to extract the visibility setting for logical volumes
101  DispAct->SetGeom(detector_->get_geom());
102 
103  if (GetParams()->get_int_param("active"))
104  {
105  std::set<std::string> nodes;
106  PHNodeIterator dstIter(dstNode);
107  PHCompositeNode* DetNode = dstNode;
108  if (SuperDetector() != "NONE" && !SuperDetector().empty())
109  {
110  PHNodeIterator iter_dst(dstNode);
111  DetNode = dynamic_cast<PHCompositeNode*>(iter_dst.findFirst("PHCompositeNode", SuperDetector()));
112  if (!DetNode)
113  {
114  DetNode = new PHCompositeNode(SuperDetector());
115  dstNode->addNode(DetNode);
116  }
117  }
118  std::string detector_suffix = SuperDetector();
119  if (detector_suffix == "NONE" || detector_suffix.empty())
120  {
121  detector_suffix = Name();
122  }
123 
124  m_HitNodeName = "G4HIT_" + detector_suffix;
125  nodes.insert(m_HitNodeName);
126  m_AbsorberNodeName = "G4HIT_ABSORBER_" + detector_suffix;
127  if (GetParams()->get_int_param("absorberactive"))
128  {
129  nodes.insert(m_AbsorberNodeName);
130  }
131  for (const auto& nodename : nodes)
132  {
133  PHG4HitContainer* g4_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
134  if (!g4_hits)
135  {
136  g4_hits = new PHG4HitContainer(nodename);
137  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, nodename, "PHObject"));
138  }
139  g4_hits->AddLayer(GetLayer());
140  }
141 
143  steppingAction_->InitWithNode(topNode);
144  const char* calibrationRoot = getenv("CALIBRATIONROOT");
145  assert(calibrationRoot != nullptr && "Environment variable CALIBRATIONROOT is not set");
146  std::string filePath = std::string(calibrationRoot) + "/CEMC/LightCollection/Prototype3Module.xml";
148  filePath, "data_grid_light_guide_efficiency", "data_grid_fiber_trans");
151  }
152  return 0;
153 }
154 
155 //_______________________________________________________________________
157 {
158  // pass top node to stepping action so that it gets
159  // relevant nodes needed internally
160  if (steppingAction_)
161  {
162 
164  }
165  return 0;
166 }
167 
168 //_______________________________________________________________________
170 {
171  return detector_;
172 }
173 
174 //_______________________________________________________________________
176 {
177  detector_->Print(what);
178  return;
179 }
180 
182 {
183  set_default_double_param("xpos", 0.); // translation in 3D
184  set_default_double_param("ypos", 0.); // translation in 3D
185  set_default_double_param("zpos", 0.); // translation in 3D
186 
187  set_default_double_param("thickness", 21.00000);
188  set_default_double_param("radius", 90.);
189  set_default_double_param("zmin", -149.470000);
190  set_default_double_param("zmax", 149.470000);
191  set_default_double_param("tmin", -20.);
192  set_default_double_param("tmax", 60.);
193  set_default_double_param("dt", 100.);
194  set_default_int_param("azimuthal_n_sec", 256);
195 
196  set_default_int_param("construction_verbose", 0.);
197  set_default_int_param("azimuthal_seg_visible", 0.);
198  set_default_int_param("virualize_fiber", 0.);
200  set_default_int_param("saveg4hit", 1);
201 
202  set_default_double_param("divider_width", 0); // radial size of the divider between blocks. <=0 means no dividers
203  set_default_string_param("divider_mat", "G4_AIR"); // materials of the divider. G4_AIR is equivalent to not installing one in the term of material distribution
204 
205  return;
206 }