Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4HcalPrototypeSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4HcalPrototypeSubsystem.cc
1 // This is the subsystem code (cc file) for the hcal prototype detector
2 // created on 1/27/2014, Liang, HeXC
3 //
7 
9 
11 #include <g4main/PHG4Subsystem.h> // for PHG4Subsystem
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 <Geant4/G4SystemOfUnits.hh> // for cm
21 #include <Geant4/G4Types.hh> // for G4double
22 
23 #include <sstream>
24 
25 using namespace std;
26 
27 //_______________________________________________________________________
29  : PHG4Subsystem(name)
30  , detector_(0)
31  , steppingAction_(nullptr)
32  , eventAction_(nullptr)
33  , rot_in_y(0)
34  , rot_in_z(0)
35  , material("G4_AIR")
36  , // default - almost nothing
37  active(0)
38  , absorberactive(0)
39  , layer(lyr)
40  , blackhole(0)
41  , detector_type(name)
42  , superdetector("NONE")
43 {
44  // put the layer into the name so we get unique names
45  // for multiple layers
46  ostringstream nam;
47  nam << name << "_" << lyr;
48  Name(nam.str().c_str());
49  for (int i = 0; i < 3; i++)
50  {
51  dimension[i] = 100.0 * cm;
52  }
53 }
54 
55 //_______________________________________________________________________
57 {
58  PHNodeIterator iter(topNode);
59  PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
60 
61  // create detector
62  detector_ = new PHG4HcalPrototypeDetector(this, topNode, Name(), layer);
70  if (active)
71  {
72  ostringstream nodename;
73  if (superdetector != "NONE")
74  {
75  nodename << "G4HIT_" << superdetector;
76  }
77  else
78  {
79  nodename << "G4HIT_" << detector_type << "_" << layer;
80  }
81  // create hit list
82  PHG4HitContainer* block_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str().c_str());
83  if (!block_hits)
84  {
85  dstNode->addNode(new PHIODataNode<PHObject>(block_hits = new PHG4HitContainer(nodename.str()), nodename.str().c_str(), "PHObject"));
86  }
87  if (absorberactive)
88  {
89  nodename.str("");
90  if (superdetector != "NONE")
91  {
92  nodename << "G4HIT_ABSORBER_" << superdetector;
93  }
94  else
95  {
96  nodename << "G4HIT_ABSORBER_" << detector_type << "_" << layer;
97  }
98  }
99  block_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str().c_str());
100  if (!block_hits)
101  {
102  dstNode->addNode(new PHIODataNode<PHObject>(block_hits = new PHG4HitContainer(nodename.str()), nodename.str().c_str(), "PHObject"));
103  }
104  // create stepping action
106 
107  eventAction_ = new PHG4EventActionClearZeroEdep(topNode, nodename.str());
108  }
109  if (blackhole && !active)
110  {
112  }
113  return 0;
114 }
115 
116 //_______________________________________________________________________
118 {
119  // pass top node to stepping action so that it gets
120  // relevant nodes needed internally
121  if (steppingAction_)
122  {
124  }
125  return 0;
126 }
127 
128 //_______________________________________________________________________
130 {
131  return detector_;
132 }
133 
134 //_______________________________________________________________________
136 {
137  return steppingAction_;
138 }