Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4EICMvtxSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4EICMvtxSubsystem.cc
1 #include "PHG4EICMvtxSubsystem.h"
2 
3 #include "PHG4EICMvtxDetector.h"
5 #include "PHG4MvtxDefs.h"
7 
8 #include <phparameter/PHParameters.h>
9 #include <phparameter/PHParametersContainer.h>
10 
11 #include <g4detectors/PHG4DetectorGroupSubsystem.h> // for PHG4DetectorGrou...
12 
13 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
15 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
16 
17 #include <phool/PHCompositeNode.h>
18 #include <phool/PHIODataNode.h> // for PHIODataNode
19 #include <phool/PHNode.h> // for PHNode
20 #include <phool/PHNodeIterator.h> // for PHNodeIterator
21 #include <phool/PHObject.h> // for PHObject
22 #include <phool/getClass.h>
23 #include <phool/phool.h> // for PHWHERE
24 
25 #include <mvtx/SegmentationAlpide.h> // for Alpide constants
26 
27 #include <iostream> // for operator<<, basi...
28 #include <set> // for _Rb_tree_const_i...
29 #include <sstream>
30 #include <utility> // for pair
31 
32 class PHG4Detector;
33 
34 using namespace std;
35 using namespace PHG4MvtxDefs;
36 
37 //_______________________________________________________________________
40  , m_Detector(nullptr)
41  , steppingAction_(nullptr)
42  , m_DisplayAction(nullptr)
43  , n_layers(_n_layers)
44  , detector_type(name)
45 {
46  for (unsigned int iLyr = 0; iLyr < n_layers; ++iLyr)
47  {
48  AddDetId(iLyr);
49  }
50 
52 
53  // put the layers into name so we get unique names
54  // for multiple layers
55  Name(name);
56  SuperDetector(name);
57 }
58 
59 //_______________________________________________________________________
61 {
62  delete m_DisplayAction;
63 }
64 
65 //_______________________________________________________________________
67 {
68  if (Verbosity() > 0)
69  {
70  cout << "PHG4EICMvtxSubsystem::Init started" << endl;
71  }
72 
73  PHNodeIterator iter(topNode);
74  PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
75 
76  // create display settings before detector (detector adds its volumes to it)
78  // create detector
79  // These values are set from the calling macro using the setters defined in the .h file
80  if (Verbosity())
81  {
82  cout << " create Mvtx detector with " << n_layers << " layers." << endl;
83  }
84  m_Detector = new PHG4EICMvtxDetector(this, topNode, GetParamsContainer(), Name());
89  if (Verbosity())
90  {
91  cout << " ------ created detector " << Name() << endl;
93  }
94  // loop all layer to find atleast one active layer
95  int active = 0;
96  // for now not absorber are implemnented yet
97  int absorberactive = 0;
98  int blackhole = 0;
99  for (set<int>::const_iterator parContainerIter = GetDetIds().first; parContainerIter != GetDetIds().second; ++parContainerIter)
100  {
101  if (active || GetParamsContainer()->GetParameters(*parContainerIter)->get_int_param("active"))
102  {
103  active = 1;
104  }
105  if (absorberactive || GetParamsContainer()->GetParameters(*parContainerIter)->get_int_param("absorberactive"))
106  {
107  absorberactive = 1;
108  }
109  if (blackhole || GetParamsContainer()->GetParameters(*parContainerIter)->get_int_param("blackhole"))
110  {
111  blackhole = 1;
112  }
113  }
114  if (active)
115  {
116  PHNodeIterator dstIter(dstNode);
117  PHCompositeNode* detNode = dynamic_cast<PHCompositeNode*>(dstIter.findFirst("PHCompositeNode", SuperDetector()));
118  if (!detNode)
119  {
120  detNode = new PHCompositeNode(SuperDetector());
121  dstNode->addNode(detNode);
122  }
123  ostringstream nodename;
124  if (SuperDetector() != "NONE")
125  {
126  nodename << "G4HIT_" << SuperDetector();
127  }
128  else
129  {
130  nodename << "G4HIT_" << detector_type;
131  }
132  // create hit list
133  PHG4HitContainer* block_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str());
134  if (!block_hits)
135  {
136  detNode->addNode(new PHIODataNode<PHObject>(block_hits = new PHG4HitContainer(nodename.str()), nodename.str(), "PHObject"));
137  }
138  if (Verbosity())
139  {
140  cout << PHWHERE << "creating hits node " << nodename.str() << endl;
141  }
142 
143  if (absorberactive)
144  {
145  nodename.str("");
146  if (SuperDetector() != "NONE")
147  {
148  nodename << "G4HIT_ABSORBER_" << SuperDetector();
149  }
150  else
151  {
152  nodename << "G4HIT_ABSORBER_" << detector_type;
153  }
154  block_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str());
155  if (!block_hits)
156  {
157  detNode->addNode(new PHIODataNode<PHObject>(block_hits = new PHG4HitContainer(nodename.str()), nodename.str(), "PHObject"));
158  }
159  if (Verbosity())
160  {
161  cout << PHWHERE << "creating hits node " << nodename.str() << endl;
162  }
163  }
164 
165  // create stepping action
168  }
169  else
170  {
171  if (blackhole)
172  {
174  }
175  }
176  return 0;
177 }
178 
179 //_______________________________________________________________________
181 {
182  // pass top node to stepping action so that it gets
183  // relevant nodes needed internally
184  if (steppingAction_)
185  {
187  }
188  return 0;
189 }
190 
191 //_______________________________________________________________________
193 {
194  return m_Detector;
195 }
196 
197 //_______________________________________________________________________
199 {
200  return steppingAction_;
201 }
202 
203 //_______________________________________________________________________
205 {
206  for (set<int>::const_iterator lyr_it = GetDetIds().first; lyr_it != GetDetIds().second; ++lyr_it)
207  {
208  const int& ilyr = *lyr_it;
209  const double rLr = mvtxdat[ilyr][kRmd];
210  double turbo = radii2Turbo(mvtxdat[ilyr][kRmn], rLr, mvtxdat[ilyr][kRmx], SegmentationAlpide::SensorSizeRows * 10.);
211 
212  set_default_int_param(ilyr, "active", 1); // non-automatic initialization in PHG4DetectorGroupSubsystem
213  set_default_int_param(ilyr, "layer", ilyr);
214  set_default_int_param(ilyr, "N_staves", mvtxdat[ilyr][kNStave]);
215 
216  set_default_double_param(ilyr, "layer_nominal_radius", rLr);
217  set_default_double_param(ilyr, "phitilt", turbo);
218  set_default_double_param(ilyr, "phi0", mvtxdat[ilyr][kPhi0]);
219  set_default_string_param(ilyr, "material", "G4_AIR"); // default - almost nothing
220  }
221 
222  set_default_string_param(GLOBAL, "stave_geometry_file", "ITS.gdml"); // default - almost nothing
223  /*
224  set_default_double_param(PHG4MvtxDefs::ALPIDE_SEGMENTATION, "pixel_x", NAN);
225  set_default_double_param(PHG4MvtxDefs::ALPIDE_SEGMENTATION, "pixel_z", NAN);
226  set_default_double_param(PHG4MvtxDefs::ALPIDE_SEGMENTATION, "pixel_thickness", NAN);
227  */
228 }