ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EICG4BwdSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EICG4BwdSubsystem.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 // EICG4B0Detector::ConstructMe() method
8 // but the convention is as mentioned cm and deg
9 //____________________________________________________________________________..
10 //
11 #include "EICG4BwdSubsystem.h"
12 
13 #include "EICG4BwdDetector.h"
14 #include "EICG4BwdSteppingAction.h"
15 
16 #include <phparameter/PHParameters.h>
17 
20 
21 #include <phool/PHCompositeNode.h>
22 #include <phool/PHIODataNode.h>
23 #include <phool/PHNode.h>
24 #include <phool/PHNodeIterator.h>
25 #include <phool/PHObject.h>
26 #include <phool/getClass.h>
27 
28 using namespace std;
29 
30 //_______________________________________________________________________
31 EICG4BwdSubsystem::EICG4BwdSubsystem(const std::string &name, const int lyr)
32  : PHG4DetectorSubsystem(name, lyr)
33  , m_Detector(nullptr)
34  , m_SteppingAction(nullptr)
35  , mappingfile_("")
36 {
37  // call base class method which will set up parameter infrastructure
38  // and call our SetDefaultParameters() method
40 }
41 //_______________________________________________________________________
43 {
44  // create detector
45  m_Detector = new EICG4BwdDetector(this, topNode, GetParams(), Name(), GetLayer());
49 
50  if (GetParams()->get_int_param("active"))
51  {
52  PHNodeIterator iter(topNode);
53  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
54 
55  string nodename;
56  string geonode;
57  std::cout<<"BWD ECAL: "<<SuperDetector()<<std::endl;
58  if (SuperDetector() != "NONE")
59  {
60  // create super detector subnodes
61  PHNodeIterator iter_dst(dstNode);
62  PHCompositeNode *superSubNode = dynamic_cast<PHCompositeNode *>(iter_dst.findFirst("PHCompositeNode", SuperDetector()));
63  if (!superSubNode)
64  {
65  superSubNode = new PHCompositeNode(SuperDetector());
66  dstNode->addNode(superSubNode);
67  }
68  dstNode = superSubNode;
69 
70  nodename = "G4HIT_" + SuperDetector();
71  }
72 
73  else
74  {
75  nodename = "G4HIT_" + Name();
76  }
77  PHG4HitContainer *bwd_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
78  if (!bwd_hits)
79  {
80  dstNode->addNode(new PHIODataNode<PHObject>(bwd_hits = new PHG4HitContainer(nodename), nodename, "PHObject"));
81  }
82  bwd_hits->AddLayer(GetLayer());
83  auto *tmp = new EICG4BwdSteppingAction(this, m_Detector, GetParams());
84  tmp->HitNodeName(nodename);
86  }
87  else if (GetParams()->get_int_param("blackhole"))
88  {
90  }
91  if (m_SteppingAction)
92  {
93  (dynamic_cast<EICG4BwdSteppingAction *>(m_SteppingAction))->SaveAllHits(m_SaveAllHitsFlag);
94  }
95  return 0;
96 }
97 //_______________________________________________________________________
99 {
100  // pass top node to stepping action so that it gets
101  // relevant nodes needed internally
102  if (m_SteppingAction)
103  {
105  }
106  return 0;
107 }
108 //_______________________________________________________________________
109 void EICG4BwdSubsystem::Print(const string &what) const
110 {
111  if (m_Detector)
112  {
113  m_Detector->Print(what);
114  }
115  return;
116 }
117 
118 //_______________________________________________________________________
120 {
121  return m_Detector;
122 }
123 
124 //_______________________________________________________________________
126 {
127  // sizes are in cm
128  // angles are in deg
129  // units should be converted to G4 units when used
130  //implement your own here//
131  set_default_double_param("place_x", 0.); //subdetector position
132  set_default_double_param("place_y", 0.); //subdetector position
133  set_default_double_param("place_z", 0.); //subdetector position
134 // set_default_double_param("pipe_ir", 2.8); //beam pipe inner radius (for future implementation)
135 // set_default_double_param("pipe_or", 3.05); //beam pipe outer raidus (for future implementation)
136 // set_default_double_param("pipe_hole_r", 3.5); //beam pipe cut off radius in the detector volume
137 // set_default_double_param("pipe_hole", 1.0); //beam pipe cut off rectangle in the detector volume
138 // set_default_double_param("cable_hole", 2.0); //beam pipe cut off radius in the detector volume
139 // set_default_double_param("cable_x", -17.0); //cable hole position
140 // set_default_double_param("cable_y", 0.); // position
141 // set_default_double_param("cable_z", 0.); // position
142 // set_default_double_param("pipe_x", -3.4); //beam pipe position
143 // set_default_double_param("pipe_y", 0.); //beam pipe position
144 // set_default_double_param("pipe_z", 0.); //beam pipe position
145  set_default_double_param("rot_y", 0.); //subdetector rotation
146 // set_default_double_param("outer_radius", 2.); //detector outer radiues
147 // set_default_double_param("d_radius", 5.); //packman cutoff size
148  set_default_double_param("length", 20.); //detector length
149  set_default_double_param("width", 20.); //detector length
150  set_default_double_param("height", 20.); //detector length
151 // set_default_double_param("startAngle", 0.); //start Angle for packman cutoff
152 // set_default_double_param("spanningAngle", 360.); //spanning Angle of the detector (for packman cutoff)
153  set_default_double_param("detid", 0.); //detector id
154 // set_default_int_param("ispipe", 0); //pipe or detector (for future implementation)
155  set_default_int_param("lightyield", 1);
156  set_default_int_param("use_g4steps", 0);
157  set_default_double_param("tower_size", 2.);
158  set_default_double_param("global_x", 0);
159  set_default_double_param("global_y", 0);
160  set_default_double_param("global_z", 0);
161  set_default_double_param("readout_size", 2.);
162  set_default_double_param("tmin", NAN);
163  set_default_double_param("tmax", NAN);
164  set_default_string_param("material", "G4_PbWO4"); //detector material
165 }
166 
168 {
170 }