EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BeastMagnetSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file BeastMagnetSubsystem.cc
1 //____________________________________________________________________________..
2 //
3 // This is the interface to the framework. You only need to define the parameters
4 // you use for your detector in the SetDefaultParameters() method here
5 // The place to do this is marked by //implement your own here//
6 // The parameters have no units, they need to be converted in the
7 // BeastMagnetDetector::ConstructMe() method
8 // but the convention is as mentioned cm and deg
9 //____________________________________________________________________________..
10 //
11 #include "BeastMagnetSubsystem.h"
12 
13 #include "BeastMagnetDetector.h"
16 
17 #include <phparameter/PHParameters.h>
18 
21 
22 #include <phool/PHCompositeNode.h>
23 #include <phool/PHIODataNode.h>
24 #include <phool/PHNode.h>
25 #include <phool/PHNodeIterator.h>
26 #include <phool/PHObject.h>
27 #include <phool/getClass.h>
28 
29 using namespace std;
30 
31 //_______________________________________________________________________
33  : PHG4DetectorSubsystem(name)
34  , m_Detector(nullptr)
35  , m_SteppingAction(nullptr)
36  , m_DisplayAction(nullptr)
37 {
38  // call base class method which will set up parameter infrastructure
39  // and call our SetDefaultParameters() method
41 }
42 
43 //_______________________________________________________________________
45 {
46  delete m_DisplayAction;
47 }
48 
49 //_______________________________________________________________________
51 {
52  PHNodeIterator iter(topNode);
53  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
54  // create display settings before detector
56 
57  // create detector
58  m_Detector = new BeastMagnetDetector(this, topNode, GetParams(), Name());
61 
62  PHNodeIterator dstIter(dstNode);
63  if (GetParams()->get_int_param("active"))
64  {
65  string name;
66  if (SuperDetector() != "NONE")
67  {
68  name = SuperDetector();
69  }
70  else
71  {
72  name = Name();
73  }
74  PHCompositeNode *DetNode = dynamic_cast<PHCompositeNode *>(dstIter.findFirst("PHCompositeNode", name));
75  if (!DetNode)
76  {
77  DetNode = new PHCompositeNode(name);
78  dstNode->addNode(DetNode);
79  }
80  string g4hitnodename = "G4HIT_" + name;
81  PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(DetNode, g4hitnodename);
82  if (!g4_hits)
83  {
84  g4_hits = new PHG4HitContainer(g4hitnodename);
85  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, g4hitnodename, "PHObject"));
86  }
88  }
89  return 0;
90 }
91 //_______________________________________________________________________
93 {
94  // pass top node to stepping action so that it gets
95  // relevant nodes needed internally
96  if (m_SteppingAction)
97  {
99  }
100  return 0;
101 }
102 //_______________________________________________________________________
103 void BeastMagnetSubsystem::Print(const string &what) const
104 {
105  if (m_Detector)
106  {
107  m_Detector->Print(what);
108  }
109  return;
110 }
111 
112 //_______________________________________________________________________
114 {
115  return m_Detector;
116 }
117 
118 //_______________________________________________________________________
120 {
121  // sizes are in cm
122  // angles are in deg
123  // units should be converted to G4 units when used
124  //implement your own here//
125  set_default_double_param("place_x", 0.);
126  set_default_double_param("place_y", 0.);
127  set_default_double_param("place_z", 0.);
128  set_default_double_param("rot_x", 0.);
129  set_default_double_param("rot_y", 0.);
130  set_default_double_param("rot_z", 0.);
131  set_default_double_param("size_x", 20.);
132  set_default_double_param("size_y", 20.);
133  set_default_double_param("size_z", 20.);
134 
135  set_default_string_param("GDMPath", "DefaultParameters-InvalidPath");
136  set_default_string_param("TopVolName", "DefaultParameters-InvalidVol");
137 }