ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EICG4LumiSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EICG4LumiSubsystem.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 // EICG4LumiDetector::ConstructMe() method
8 // but the convention is as mentioned cm and deg
9 //____________________________________________________________________________..
10 //
11 #include "EICG4LumiSubsystem.h"
12 
13 #include "EICG4LumiDetector.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 EICG4LumiSubsystem::EICG4LumiSubsystem(const std::string &name, const int lyr)
32  : PHG4DetectorSubsystem(name, lyr)
33  , m_Detector(nullptr)
34  , m_SteppingAction(nullptr)
35 {
36  // call base class method which will set up parameter infrastructure
37  // and call our SetDefaultParameters() method
39 }
40 
41 //_______________________________________________________________________
43 {
44  // create detector
45  m_Detector = new EICG4LumiDetector(this, topNode, GetParams(), Name(), GetLayer());
48 
49  if (GetParams()->get_int_param("active"))
50  {
51  PHNodeIterator iter(topNode);
52  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
53 
54  std::string nodename_prefix;
55  std::string nodename_CAL;
56  std::string nodename_tracking;
57  std::string nodename_virt;
58 
59  if (SuperDetector() != "NONE")
60  {
61  // create super detector subnodes
62  PHNodeIterator iter_dst(dstNode);
63  PHCompositeNode *superSubNode = dynamic_cast<PHCompositeNode *>(iter_dst.findFirst("PHCompositeNode", SuperDetector()));
64 
65  if (!superSubNode)
66  {
67  superSubNode = new PHCompositeNode(SuperDetector());
68  dstNode->addNode(superSubNode);
69  }
70  dstNode = superSubNode;
71 
72  nodename_prefix = "G4HIT_" + SuperDetector();
73  }
74  else
75  {
76  nodename_prefix = "G4HIT_" + Name();
77  }
78 
79  nodename_CAL = nodename_prefix + "_CAL";
80  nodename_tracking = nodename_prefix + "_tracking";
81  nodename_virt = nodename_prefix + "_virt";
82 
83  // Grab hit container if it exists
84  PHG4HitContainer *CAL_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename_CAL);
85  PHG4HitContainer *Tracking_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename_tracking);
86  PHG4HitContainer *Virt_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename_virt);
87  // Create it if it doesn't exist
88  if( ! CAL_hits )
89  {
90  dstNode->addNode( new PHIODataNode<PHObject>( CAL_hits = new PHG4HitContainer(nodename_CAL), nodename_CAL, "PHObject"));
91  }
92  if( ! Tracking_hits )
93  {
94  dstNode->addNode( new PHIODataNode<PHObject>( Tracking_hits = new PHG4HitContainer(nodename_tracking), nodename_tracking, "PHObject"));
95  }
96  if( ! Virt_hits )
97  {
98  dstNode->addNode( new PHIODataNode<PHObject>( Virt_hits = new PHG4HitContainer(nodename_virt), nodename_virt, "PHObject"));
99  }
100 
101  CAL_hits->AddLayer( GetLayer() );
102  Tracking_hits->AddLayer( GetLayer() );
103  Virt_hits->AddLayer( GetLayer() );
104 
105  // Create stepping action
106  auto *tmp = new EICG4LumiSteppingAction( this, m_Detector, GetParams() );
107  tmp->HitNodeNameCAL( nodename_CAL );
108  tmp->HitNodeNameTracking( nodename_tracking );
109  tmp->HitNodeNameVirt( nodename_virt);
110 
112 
113  }
114  else if (GetParams()->get_int_param("blackhole"))
115  {
117  }
118 
119  if (m_SteppingAction)
120  {
121  (dynamic_cast<EICG4LumiSteppingAction *>(m_SteppingAction))->SaveAllHits(m_SaveAllHitsFlag);
122  }
123 
124  return 0;
125 }
126 //_______________________________________________________________________
128 {
129  // pass top node to stepping action so that it gets
130  // relevant nodes needed internally
131  if (m_SteppingAction)
132  {
134  }
135  return 0;
136 }
137 //_______________________________________________________________________
138 void EICG4LumiSubsystem::Print(const string &what) const
139 {
140  if (m_Detector)
141  {
142  m_Detector->Print(what);
143  }
144  return;
145 }
146 
147 //_______________________________________________________________________
149 {
150  return m_Detector;
151 }
152 
153 //_______________________________________________________________________
155 {
156 
157  // defaults are in cm and rad
158  set_default_double_param("FBenclosure_center", 0.);
159  set_default_string_param("parameter_file", "");
160  set_default_int_param("layerNumber", 1);
161  set_default_double_param("detid", 0.); //detector id
162  set_default_int_param("lightyield", 1);
163  set_default_int_param("use_g4steps", 0);
164  set_default_double_param("tmin", NAN);
165  set_default_double_param("tmax", NAN);
166 
167  set_default_int_param("Version", 1);
168 
169  set_default_double_param("LumiWin_X", 0.);
170  set_default_double_param("LumiWin_Y", 0.);
171  set_default_double_param("LumiWin_Z", -1850);
172  set_default_double_param("LumiWin_Tilt", 0.25);
173  set_default_double_param("LumiWin_Thickness", 0.26);
174  set_default_double_param("LumiWin_Height", 7.4);
175  set_default_double_param("LumiWin_Length", 29);
176  set_default_string_param("LumiWin_Material", "G4_Al");
177 
178  set_default_double_param("LumiMag_Z", -2820);
179  set_default_double_param("LumiMag_innerR", 10);
180  set_default_double_param("LumiMag_outerR", 16);
181  set_default_double_param("LumiMag_DZ", 60);
182  set_default_double_param("LumiMag_B", 0.37);
183  set_default_string_param("LumiMag_VesselMaterial", "G4_Fe");
184 
185  set_default_double_param("LumiSpec_Z", -3640);
186  set_default_double_param("LumiSpec_XY", 20);
187  set_default_double_param("LumiSpec_DZ", 35);
188  set_default_double_param("LumiSpec_YS", 6);
189 
190  set_default_double_param("LumiPhotonCAL_Z", -3700);
191  set_default_double_param("LumiPhotonCAL_XY", 16);
192  set_default_double_param("LumiPhotonCAL_DZ", 35);
193 
194  set_default_double_param("LumiTracker2_XY", 0.06);
195  set_default_double_param("LumiTracker2_DZ", 20);
196 
197  set_default_double_param("LumiTracker1Gap", 2.0);
198 
199  set_default_double_param("LumiSpecTower_XY", 2.5);
200  set_default_double_param("LumiSpecTower_DZ", 17);
201  set_default_int_param("TotalLumiSpecTower", 8);
202 }
203 
204 //_______________________________________________________________________
206 {
207  set_string_param("parameter_file", filename );
208 
209  std::ifstream infile;
210  std::string line;
211 
212  std::string paramFile = filename;
213  infile.open( paramFile );
214 
215  if(!infile.is_open()) {
216  std::cout << PHWHERE << "ERROR in EICG4LumiSubsystem: Failed to open parameter file " << paramFile << std::endl;
217  gSystem->Exit(1);
218  }
219 
220  while( std::getline(infile, line) ) {
221 
222  std::string name;
223  std::string value;
224 
225  std::istringstream iss( line );
226 
227  // skip comment lines
228  if( line.find("#") != std::string::npos ) { continue; }
229  if( line.empty() == true ) { continue; }
230 
231  // grab the line
232  if( !(iss >> name >> value) ) {
233  std::cout << PHWHERE << " Lumi parameters: could not decode " << line << std::endl;
234  gSystem->Exit(1);
235  }
236 
237  auto *params = GetParams(); // Get handle for PHParameter class
238 
239  if( params->exist_string_param( name ) ) {
240  set_string_param(name, value);
241  }
242  else if( params->exist_double_param( name ) ) {
243  set_double_param(name, std::stod(value) );
244  }
245  else if( params->exist_int_param( name ) ) {
246  set_int_param(name, std::stoi(value) );
247  }
248  else {
249  std::cout << PHWHERE << " Lumi parameters: parameter doesn't exist " << line << std::endl;
250  gSystem->Exit(1);
251  }
252 
253  }
254 
255  infile.close();
256 
257 }