EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EicRootSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EicRootSubsystem.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 //
6 // The parameters have no units, they need to be converted in the ConstructMe() method
7 //____________________________________________________________________________..
8 //
9 
10 #include <phparameter/PHParameters.h>
11 
14 
15 #include <phool/PHCompositeNode.h>
16 #include <phool/PHIODataNode.h>
17 #include <phool/PHNode.h>
18 #include <phool/PHNodeIterator.h>
19 #include <phool/PHObject.h>
20 #include <phool/getClass.h>
21 
22 #include "EicRootSubsystem.h"
23 #include "EicRootDetector.h"
24 #include "EicRootSteppingAction.h"
25 
26 using namespace std;
27 
28 // ---------------------------------------------------------------------------------------
29 
31  : PHG4DetectorSubsystem(name)
32  , m_Detector(nullptr)
33  , m_SteppingAction(nullptr)
34 {
35  // Avoid all the complications with "G4HIT_VST_[i]" hit collection names, etc;
36  // as long as one can distinguish the layers via detector ID encoded in the
37  // hit class instance in the stepping call, this only gives one a performance
38  // gain (potentially), but forces one to play dirty games trying to assign
39  // layer resolutions based on the index ID, etc; just create more than one
40  // instance of this subsystem if e.g. spatial resolution of the inner and
41  // outer silicon layer is supposed to be different (and pass it as such
42  // to the Kalman filter);
43  SuperDetector(name);
44 
45  m_G4HitName = "G4HIT_" + name;
46 
47  // Call the base class method which will set up parameter infrastructure
48  // and call our SetDefaultParameters() method internally;
50 } // EicRootSubsystem::EicRootSubsystem()
51 
52 // ---------------------------------------------------------------------------------------
53 
55 {
56  PHNodeIterator iter(topNode);
57  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
58 
59  // Create detector;
60  m_Detector = new EicRootDetector(this, topNode, Name());
62 
63  // fun4all black magic around G4 hit container creation;
64  if (GetParams()->get_int_param("active")) {
65  auto DetNode = new PHCompositeNode(SuperDetector());
66 
67  dstNode->addNode(DetNode);
68 
70  DetNode->addNode(new PHIODataNode<PHObject>(m_Detector->get_hitcontainer(), GetG4HitName(), "PHObject"));
72  } //if
73 
74  return 0;
75 } // EicRootSubsystem::InitRunSubsystem()
76 
77 // ---------------------------------------------------------------------------------------
78 
80 {
81  // pass top node to stepping action so that it gets
82  // relevant nodes needed internally
84 
85  return 0;
86 } // EicRootSubsystem::process_event()
87 
88 // ---------------------------------------------------------------------------------------
89 
90 void EicRootSubsystem::Print(const string &what) const
91 {
92  if (m_Detector) m_Detector->Print(what);
93 } // EicRootSubsystem::Print()
94 
95 // ---------------------------------------------------------------------------------------
96 
98 {
99  return m_Detector;
100 } // EicRootSubsystem::GetDetector()
101 
102 // ---------------------------------------------------------------------------------------
103 
105 {
106  // sizes are in cm
107  // angles are in deg
108  // units should be converted to G4 units when used
109  set_default_double_param("place_x", 0.);
110  set_default_double_param("place_y", 0.);
111  set_default_double_param("place_z", 0.);
112  set_default_double_param("rot_x", 0.);
113  set_default_double_param("rot_y", 0.);
114  set_default_double_param("rot_z", 0.);
115 
116  // One custom parameter;
117  set_default_string_param("MotherVolume", "DefaultParameters-Invalid");
118 } // EicRootSubsystem::SetDefaultParameters()
119 
120 // ---------------------------------------------------------------------------------------