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