ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4CrystalCalorimeterSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4CrystalCalorimeterSubsystem.cc
6 
7 #include <phparameter/PHParameters.h>
8 
9 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
11 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
12 #include <g4main/PHG4Subsystem.h> // for PHG4Subsystem
13 
14 #include <phool/PHCompositeNode.h>
15 #include <phool/PHIODataNode.h> // for PHIODataNode
16 #include <phool/PHNode.h> // for PHNode
17 #include <phool/PHNodeIterator.h> // for PHNodeIterator
18 #include <phool/PHObject.h> // for PHObject
19 #include <phool/getClass.h>
20 
21 #include <iostream> // for operator<<, ostrin...
22 #include <sstream>
23 
24 class PHG4Detector;
25 
26 using namespace std;
27 
28 //_______________________________________________________________________
30  : PHG4DetectorSubsystem(name, lyr)
31 {
33 }
34 
35 //_______________________________________________________________________
37 {
38  delete m_DisplayAction;
39 }
40 
41 //_______________________________________________________________________
43 {
44  // create display settings before detector
46  // create detector
47  if (get_int_param("projective") == 1)
48  {
49  if (Verbosity() > 1)
50  {
51  cout << "PHG4CrystalCalorimeterSubsystem::InitRun - use PHG4ProjCrystalCalorimeterDetector" << endl;
52  }
54  }
55  else
56  {
57  if (Verbosity() > 1)
58  {
59  cout << "PHG4CrystalCalorimeterSubsystem::InitRun - use PHG4CrystalCalorimeterDetector" << endl;
60  }
61  m_Detector = new PHG4CrystalCalorimeterDetector(this, topNode, GetParams(), Name());
62  }
63 
67 
68  if (GetParams()->get_int_param("active"))
69  {
70  PHNodeIterator iter(topNode);
71  PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
72 
73  // create hit output node
74  string nodename = "G4HIT_";
75  if (SuperDetector() != "NONE")
76  {
77  PHNodeIterator iter_dst(dstNode);
78  PHCompositeNode* superSubNode = dynamic_cast<PHCompositeNode*>(iter_dst.findFirst("PHCompositeNode", SuperDetector()));
79  if (!superSubNode)
80  {
81  superSubNode = new PHCompositeNode(SuperDetector());
82  dstNode->addNode(superSubNode);
83  }
84  dstNode = superSubNode;
85  nodename += SuperDetector();
86  }
87  else
88  {
89  nodename += Name();
90  }
91 
92  PHG4HitContainer* crystal_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
93  if (!crystal_hits)
94  {
95  crystal_hits = new PHG4HitContainer(nodename);
96  PHIODataNode<PHObject>* hitNode = new PHIODataNode<PHObject>(crystal_hits, nodename, "PHObject");
97  dstNode->addNode(hitNode);
98  }
99 
100  if (GetParams()->get_int_param("absorberactive"))
101  {
102  string absnodename = "G4HIT_ABSORBER_";
103  if (SuperDetector() != "NONE")
104  {
105  absnodename += SuperDetector();
106  }
107  else
108  {
109  absnodename += Name();
110  }
111 
112  PHG4HitContainer* absorber_hits = findNode::getClass<PHG4HitContainer>(topNode, absnodename);
113  if (!absorber_hits)
114  {
115  absorber_hits = new PHG4HitContainer(absnodename);
116  PHIODataNode<PHObject>* abshitNode = new PHIODataNode<PHObject>(absorber_hits, absnodename, "PHObject");
117  dstNode->addNode(abshitNode);
118  }
119  }
120  // create stepping action
122  }
123  return 0;
124 }
125 
126 //_______________________________________________________________________
128 {
129  // pass top node to stepping action so that it gets
130  // relevant nodes needed internally
131  if (m_SteppingAction)
132  {
134  }
135  return 0;
136 }
137 
138 //_______________________________________________________________________
140 {
141  return m_Detector;
142 }
143 
145 {
146  // values in cm and degrees
147  set_default_int_param("projective", 0);
148 
149  set_default_double_param("crystal_dx", 2.);
150  set_default_double_param("crystal_dy", 2.);
151  set_default_double_param("crystal_dz", 18.);
152  set_default_double_param("dz", 18.);
153  set_default_double_param("place_x", 0.);
154  set_default_double_param("place_y", 0.);
155  set_default_double_param("place_z", -108.);
156  set_default_double_param("rMin1", 2.2);
157  set_default_double_param("rMax1", 65.6);
158  set_default_double_param("rMin2", 2.6);
159  set_default_double_param("rMax2", 77.5);
160  set_default_double_param("rot_x", 0.);
161  set_default_double_param("rot_y", 180.);
162  set_default_double_param("rot_z", 0.);
163 
164  set_default_string_param("material", "G4_PbWO4");
165  set_default_string_param("mappingtower", "");
166  set_default_string_param("mapping4x4", "");
167  return;
168 }
169 
171 {
172  set_string_param("mappingtower", filename);
173 }
174 
175 void PHG4CrystalCalorimeterSubsystem::SetProjectiveGeometry(const std::string& filename1, const std::string& filename2)
176 {
177  set_string_param("mappingtower", filename1);
178  set_string_param("mapping4x4", filename2);
179  set_int_param("projective", 1);
180 }