EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EICG4dRICHSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EICG4dRICHSubsystem.cc
1 //____________________________________________________________________________..
2 //
3 // This is the interface to the framework. You only need to define the
4 // parameters you use for your detector in the SetDefaultParameters() method
5 // here The place to do this is marked by //implement your own here// The
6 // parameters have no units, they need to be converted in the
7 // EICG4dRICHDetector::ConstructMe() method
8 // but the convention is as mentioned cm and deg
9 //____________________________________________________________________________..
10 //
11 #include "EICG4dRICHSubsystem.h"
12 #include "EICG4dRICHDetector.h"
14 
15 #include <phparameter/PHParameters.h>
16 
19 
20 #include <phool/PHCompositeNode.h>
21 #include <phool/PHIODataNode.h>
22 #include <phool/PHNode.h>
23 #include <phool/PHNodeIterator.h>
24 #include <phool/PHObject.h>
25 #include <phool/getClass.h>
26 
27 //_______________________________________________________________________
29  : PHG4DetectorSubsystem(name)
30  , m_Detector(nullptr)
31  , m_SteppingAction(nullptr)
32 {
33  // call base class method which will set up parameter infrastructure
34  // and call our SetDefaultParameters() method
36 }
37 //_______________________________________________________________________
39 {
40  PHNodeIterator iter(topNode);
41  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
42  PHNodeIterator dstIter(dstNode);
43  if (GetParams()->get_int_param("active"))
44  {
45  PHCompositeNode *DetNode = dynamic_cast<PHCompositeNode *>(dstIter.findFirst("PHCompositeNode", Name()));
46  if (!DetNode)
47  {
48  DetNode = new PHCompositeNode(Name());
49  dstNode->addNode(DetNode);
50  }
51  std::string g4hitnodename = "G4HIT_" + Name();
52  PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(DetNode, g4hitnodename);
53  if (!g4_hits)
54  {
55  g4_hits = new PHG4HitContainer(g4hitnodename);
56  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, g4hitnodename, "PHObject"));
57  }
58  }
59 
60  if (m_geoFile.empty())
61  {
62  std::cout << "ERROR in " << __FILE__ << ": No EICG4dRICH geometry file specified. Abort detector construction." << std::endl;
63  std::cout << "Please run SetGeometryFile(std::string filename) first." << std::endl;
64  exit(1);
65  }
66  set_string_param("mapping_file", m_geoFile);
68 
69  // create detector
70  m_Detector = new EICG4dRICHDetector(this, topNode, GetParams(), Name());
72  // create stepping action if detector is active
73  if (GetParams()->get_int_param("active"))
74  {
76  }
77  return 0;
78 }
79 //_______________________________________________________________________
81 {
82  // pass top node to stepping action so that it gets
83  // relevant nodes needed internally
84  if (m_SteppingAction)
85  {
87  }
88  return 0;
89 }
90 //_______________________________________________________________________
91 void EICG4dRICHSubsystem::Print(const std::string &what) const
92 {
93  if (m_Detector)
94  {
95  m_Detector->Print(what);
96  }
97  return;
98 }
99 
100 //_______________________________________________________________________
102 
103 //_______________________________________________________________________
105 {
106  //set_default_int_param("verbosity", 0);
107  // sizes are in cm
108  // angles are in deg
109  // units should be converted to G4 units when used
110  // implement your own here//
111 
112  set_default_double_param("place_x", 0.);
113  set_default_double_param("place_y", 0.);
114  set_default_double_param("place_z", 0.);
115  set_default_double_param("rot_x", 0.);
116  set_default_double_param("rot_y", 0.);
117  set_default_double_param("rot_z", 0.);
118  set_default_double_param("size_x", 20.);
119  set_default_double_param("size_y", 20.);
120  set_default_double_param("size_z", 20.);
121 
122  //set_default_string_param("material", "G4_Cu");
123 
124  set_default_string_param("mapping_file", m_geoFile.c_str());
125 }