ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4mRICHSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4mRICHSubsystem.cc
1 /*===============================================================*
2  * March 2nd 2017 *
3  * mRICH Subsystem created by Cheuk-Ping Wong @GSU *
4  *===============================================================*/
5 #include "PHG4mRICHSubsystem.h"
6 #include "PHG4mRICHDetector.h"
8 
9 #include <phparameter/PHParameters.h>
10 
12 #include <g4main/PHG4EventAction.h> // for PHG4EventAction
14 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
15 
16 #include <phool/PHCompositeNode.h>
17 #include <phool/PHIODataNode.h> // for PHIODataNode
18 #include <phool/PHNode.h> // for PHNode
19 #include <phool/PHNodeIterator.h> // for PHNodeIterator
20 #include <phool/PHObject.h> // for PHObject
21 #include <phool/getClass.h>
22 
23 #include <boost/foreach.hpp>
24 
25 #include <set> // for set
26 #include <sstream>
27 
28 class PHG4Detector;
29 
30 //_______________________________________________________________________
31 PHG4mRICHSubsystem::PHG4mRICHSubsystem(const std::string& name, const int lyr)
32  : PHG4DetectorSubsystem(name, lyr)
33  , _detector(nullptr)
34  , _detectorName(name)
35  , _steppingAction(nullptr)
36  , _eventAction(nullptr)
37 {
39 }
40 
41 //_______________________________________________________________________
43 {
44  // kludge until the phg4parameters are sorted out (adding layers)
45  GetParams()->set_name(Name());
46  GetParams()->set_int_param("active", 1);
47  GetParams()->set_int_param("absorberactive", 1);
48  GetParams()->set_int_param("blackhole", 0);
49  GetParams()->set_string_param("superdetector", "NONE");
50  GetParams()->set_string_param("detectorname", "mRICH");
51  return 0;
52 }
53 
54 //_______________________________________________________________________
56 {
57  PHNodeIterator iter(topNode);
58  PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
59 
60  //---------------------------------
61  // create detector
62  //---------------------------------
63  _detector = new PHG4mRICHDetector(this, topNode, GetParams(), Name(), GetLayer());
67  _detector->SetAbsorberActive(GetParams()->get_int_param("absorberactive"));
68 
69  //---------------------------------
70  // create hit node and stepping action
71  //---------------------------------
72  if (GetParams()->get_int_param("active"))
73  {
74  std::set<std::string> nodes;
75 
76  // create hit output node
77  std::ostringstream nodename;
78  nodename << "G4HIT_" << GetParams()->get_string_param("detectorname");
79 
80  PHG4HitContainer* mRICH_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str().c_str());
81  if (!mRICH_hits)
82  {
83  mRICH_hits = new PHG4HitContainer(nodename.str());
84  PHIODataNode<PHObject>* hitNode = new PHIODataNode<PHObject>(mRICH_hits, nodename.str().c_str(), "PHObject");
85  dstNode->addNode(hitNode);
86  nodes.insert(nodename.str());
87  }
88 
89  std::ostringstream absnodename;
90  absnodename << "G4HIT_ABSORBER_" << GetParams()->get_string_param("detectorname");
91 
92  PHG4HitContainer* absorber_hits = findNode::getClass<PHG4HitContainer>(topNode, absnodename.str().c_str());
93  if (!absorber_hits)
94  {
95  absorber_hits = new PHG4HitContainer(absnodename.str());
96  PHIODataNode<PHObject>* abshitNode = new PHIODataNode<PHObject>(absorber_hits, absnodename.str().c_str(), "PHObject");
97  dstNode->addNode(abshitNode);
98  nodes.insert(nodename.str());
99  }
100 
101  // create stepping action
103 
104  // event actions
105  BOOST_FOREACH (std::string node, nodes)
106  {
107  if (!_eventAction)
108  _eventAction = new PHG4EventActionClearZeroEdep(topNode, node);
109  else
110  {
112  evtact->AddNode(node);
113  }
114  }
115  }
116 
117  return 0;
118 }
119 
120 //_______________________________________________________________________
122 {
123  // pass top node to stepping action so that it gets
124  // relevant nodes needed internally
126  return 0;
127 }
128 
129 //_______________________________________________________________________
132 {
133  return _detector;
134 }
135 //_______________________________________________________________________
137 {
138  set_default_int_param("detectorSetup", 1); //1 for full setup
139  //0 for skeleton setup: detector box, aerogel, and sensor for quick check
140 
141  set_default_int_param("subsystemSetup", 0); //-1: single module
142  //0 : build hemispheric wall
143  //>0: mRICH wall as sector. "subsystemSetup" becomes num. of sector (max is 8)
144 
145  set_default_double_param("r_inner", 3); //inner radius of mRICH wall, default=3m;
146  set_default_double_param("eta_min", 1.1); //limits of rapidity
147  set_default_double_param("eta_max", 1.9);
148 
149  set_default_int_param("use_g4steps", 0); //for stepping function
150 }