EIC 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 <iostream> // for operator<<, basic_ostream
33 #include <sstream>
34 
35 class PHG4Detector;
36 
37 //_______________________________________________________________________
38 PHG4SpacalSubsystem::PHG4SpacalSubsystem(const std::string& na, const int lyr)
39  : PHG4DetectorSubsystem(na, lyr)
40 {
42 }
43 
44 //_______________________________________________________________________
46 {
47  delete m_DisplayAction;
48 }
49 
50 //_______________________________________________________________________
52 {
53  // create hit list only for active layers
54  PHNodeIterator iter(topNode);
55  PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
56  // create detector
57  // _geom.set_layer( layer );
58  // if (lengthViaRapidityCoverage)
59  // {
60  // const double half_length = PHG4Utils::GetLengthForRapidityCoverage(_geom.get_max_radius());
61  // _geom.set_zmin(-half_length);
62  // _geom.set_zmax(+half_length);
63  // }
64  // create display settings before detector (detector adds its volumes to it)
66  switch (GetParams()->get_int_param("config"))
67  {
69  if (Verbosity() > 0) std::cout << "PHG4SpacalSubsystem::InitRun - use PHG4SpacalDetector" << std::endl;
70  detector_ = new PHG4SpacalDetector(this, topNode, Name(), GetParams(), GetLayer());
71  break;
72 
75  if (Verbosity() > 0) std::cout << "PHG4SpacalSubsystem::InitRun - use PHG4FullProjSpacalDetector" << std::endl;
76  detector_ = new PHG4FullProjSpacalDetector(this, topNode, Name(), GetParams(), GetLayer());
77  break;
78 
81  if (Verbosity() > 0) std::cout << "PHG4SpacalSubsystem::InitRun - use PHG4FullProjTiltedSpacalDetector" << std::endl;
83  break;
84 
85  default:
86  std::cout << "PHG4SpacalSubsystem::InitRun - unknown option exiting" << std::endl;
87  gSystem->Exit(1);
88  break;
89  }
90 
92  detector_->SetAbsorberActive(GetParams()->get_int_param("absorberactive"));
96  // the geometry object is set during detector construction, we need it for the
97  // display to extract the visibility setting for logical volumes
99  DispAct->SetGeom(detector_->get_geom());
100  if (GetParams()->get_int_param("active"))
101  {
102  std::ostringstream nodename;
103  if (SuperDetector() != "NONE")
104  {
105  nodename << "G4HIT_" << SuperDetector();
106  }
107  else
108  {
109  nodename << "G4HIT_" << Name() << "_" << GetLayer();
110  }
111  PHG4HitContainer* cylinder_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str());
112  if (!cylinder_hits)
113  {
114  dstNode->addNode(new PHIODataNode<PHObject>(cylinder_hits = new PHG4HitContainer(nodename.str()), nodename.str(), "PHObject"));
115  }
116  cylinder_hits->AddLayer(GetLayer());
117  if (GetParams()->get_int_param("absorberactive"))
118  {
119  nodename.str("");
120  if (SuperDetector() != "NONE")
121  {
122  nodename << "G4HIT_ABSORBER_" << SuperDetector();
123  }
124  else
125  {
126  nodename << "G4HIT_ABSORBER_" << Name() << "_" << GetLayer();
127  }
128  PHG4HitContainer* absorber_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str());
129  if (!absorber_hits)
130  {
131  dstNode->addNode(new PHIODataNode<PHObject>(absorber_hits = new PHG4HitContainer(nodename.str()), nodename.str(), "PHObject"));
132  }
133  absorber_hits->AddLayer(GetLayer());
134  }
136  }
137  return 0;
138 }
139 
140 //_______________________________________________________________________
142 {
143  // pass top node to stepping action so that it gets
144  // relevant nodes needed internally
145  if (steppingAction_)
146  {
148  }
149  return 0;
150 }
151 
152 //_______________________________________________________________________
154 {
155  return detector_;
156 }
157 
158 //_______________________________________________________________________
159 void PHG4SpacalSubsystem::Print(const std::string& what) const
160 {
161  detector_->Print(what);
162  return;
163 }
164 
166 {
167  set_default_double_param("xpos", 0.); // translation in 3D
168  set_default_double_param("ypos", 0.); // translation in 3D
169  set_default_double_param("zpos", 0.); // translation in 3D
170 
171  set_default_double_param("thickness", 21.00000);
172  set_default_double_param("radius", 90.);
173  set_default_double_param("zmin", -149.470000);
174  set_default_double_param("zmax", 149.470000);
175  set_default_int_param("azimuthal_n_sec", 256);
176 
177  set_default_int_param("construction_verbose", 0.);
178  set_default_int_param("azimuthal_seg_visible", 0.);
179  set_default_int_param("virualize_fiber", 0.);
181 
182  set_default_double_param("divider_width", 0); // radial size of the divider between blocks. <=0 means no dividers
183  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
184 
185  return;
186 }