EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4BarrelEcalSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4BarrelEcalSubsystem.cc
5 
6 #include <phparameter/PHParameters.h>
7 
8 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
10 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
11 #include <g4main/PHG4Utils.h>
12 
13 #include <phool/PHCompositeNode.h>
14 #include <phool/PHIODataNode.h> // for PHIODataNode
15 #include <phool/PHNode.h> // for PHNode
16 #include <phool/PHNodeIterator.h> // for PHNodeIterator
17 #include <phool/PHObject.h> // for PHObject
18 #include <phool/getClass.h>
19 
20 #include <TSystem.h>
21 
22 #include <cstdlib> // for getenv
23 #include <set> // for set
24 #include <sstream>
25 
26 class PHG4Detector;
27 
28 //_______________________________________________________________________
29 PHG4BarrelEcalSubsystem::PHG4BarrelEcalSubsystem(const std::string& name, const int lyr)
30  : PHG4DetectorSubsystem(name, lyr)
31 {
33 }
34 
35 //_______________________________________________________________________
37 {
38  delete m_DisplayAction;
39 }
40 
41 //_______________________________________________________________________
43 {
44  PHNodeIterator iter(topNode);
45  PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
46 
47  // create display settings before detector
49  // create detector
50  m_Detector = new PHG4BarrelEcalDetector(this, topNode, GetParams(), Name());
54 
55  std::set<std::string> nodes;
56 
57  if (GetParams()->get_int_param("active"))
58  {
59  PHNodeIterator dstIter(dstNode);
60  PHCompositeNode* DetNode = dstNode;
61  if (SuperDetector() != "NONE")
62  {
63  DetNode = dynamic_cast<PHCompositeNode*>(dstIter.findFirst("PHCompositeNode", SuperDetector()));
64  if (!DetNode)
65  {
66  DetNode = new PHCompositeNode(SuperDetector());
67  dstNode->addNode(DetNode);
68  }
69  }
70  // create hit output nodes
71  std::string detector_suffix = SuperDetector();
72  if (detector_suffix == "NONE")
73  {
74  detector_suffix = Name();
75  }
76  m_HitNodeName = "G4HIT_" + detector_suffix;
77  nodes.insert(m_HitNodeName);
78  m_AbsorberNodeName = "G4HIT_ABSORBER_" + detector_suffix;
79  if (GetParams()->get_int_param("absorberactive"))
80  {
81  nodes.insert(m_AbsorberNodeName);
82  }
83  m_SupportNodeName = "G4HIT_SUPPORT_" + detector_suffix;
84  if (GetParams()->get_int_param("supportactive"))
85  {
86  nodes.insert(m_SupportNodeName);
87  }
88  for (auto thisnode : nodes)
89  {
90  PHG4HitContainer* g4_hits = findNode::getClass<PHG4HitContainer>(topNode, thisnode);
91  if (!g4_hits)
92  {
93  g4_hits = new PHG4HitContainer(thisnode);
94  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, thisnode, "PHObject"));
95  }
96  }
97  // create stepping action
102  m_SteppingAction = tmp;
103  }
104  return 0;
105 }
106 
107 //_______________________________________________________________________
109 {
110  // pass top node to stepping action so that it gets
111  // relevant nodes needed internally
112  if (m_SteppingAction)
113  {
115  }
116  return 0;
117 }
118 
119 //_______________________________________________________________________
121 {
122  return m_Detector;
123 }
124 
126 {
127  std::ostringstream mappingfilename;
128  const char* calibroot = getenv("CALIBRATIONROOT");
129  if (calibroot)
130  {
131  mappingfilename << calibroot;
132  }
133  else
134  {
135  std::cout << "no CALIBRATIONROOT environment variable" << std::endl;
136  gSystem->Exit(1);
137  }
138  mappingfilename << "BarrelEcal/mapping/towerMap_BEMC_v001.txt";
139  set_default_string_param("mapping_file", mappingfilename.str());
140  set_default_double_param("radius", 85.);
141  set_default_double_param("max_radius", 138.);
142  set_default_double_param("CenterZ_Shift", -41.);
143  set_default_double_param("tower_length", 45.5);
144  set_default_double_param("cone1_h", 30.);
145  set_default_double_param("cone1_dz", 24.);
146  set_default_double_param("cone2_h", 20.5);
147  set_default_double_param("cone2_dz", 25.5);
148  set_default_double_param("thickness_wall", 0.1);
149  set_default_double_param("silicon_width_half", 0.05);
150  set_default_double_param("kapton_width_half", 0.05);
151  set_default_double_param("SIO2_width_half", 0.05);
152  set_default_double_param("Carbon_width_half", 1.);
153  set_default_double_param("support_length", 1.5);
154 
155  return;
156 }
157 
159 {
160  set_string_param("mapping_file", filename);
161 }
162 
163 void PHG4BarrelEcalSubsystem::Print(const std::string& what) const
164 {
165  std::cout << Name() << " Parameters: " << std::endl;
166  if (!BeginRunExecuted())
167  {
168  std::cout << "Need to execute BeginRun() before parameter printout is meaningful" << std::endl;
169  std::cout << "To do so either run one or more events or on the command line execute: " << std::endl;
170  std::cout << "Fun4AllServer *se = Fun4AllServer::instance();" << std::endl;
171  std::cout << "PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco(\"PHG4RECO\");" << std::endl;
172  std::cout << "g4->InitRun(se->topNode());" << std::endl;
173  std::cout << "PHG4BarrelEcalSubsystem *fhcal = (PHG4BarrelEcalSubsystem *) g4->getSubsystem(\"" << Name() << "\");" << std::endl;
174  std::cout << "fhcal->Print()" << std::endl;
175  return;
176  }
177  GetParams()->Print();
178  if (m_SteppingAction)
179  {
180  m_SteppingAction->Print(what);
181  }
182  return;
183 }