EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EicRootDetector.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EicRootDetector.cc
1 
2 #include <Geant4/G4VPhysicalVolume.hh>
3 
4 #include <phparameter/PHParameters.h>
5 #include <g4main/PHG4Subsystem.h>
6 #include <phool/PHNodeIterator.h>
9 #include <phool/getClass.h>
10 
11 using namespace std;
12 
13 #include <EicToyModel.h>
14 #include "EicRootDetector.h"
15 #include "EicRootSubsystem.h"
16 
17 // ---------------------------------------------------------------------------------------
18 
20  const std::string &dnam)
21  : PHG4Detector(subsys, Node, dnam)
22  , m_HitContainer(0)
23 {
24 } // EicRootDetector::EicRootDetector()
25 
26 // ---------------------------------------------------------------------------------------
27 
28 int EicRootDetector::IsInDetector(G4VPhysicalVolume *volume) //const
29 {
30  auto subsys = dynamic_cast<EicRootSubsystem*>(GetMySubsystem());
31  auto svols = subsys->GetG4SensitiveVolumes();
32 
33  if (svols.find(volume) == svols.end()) return 0;
34 
35  // Well, this looks dumb, but I do not want to break the fun4all stepping code
36  // convention where 0 return code means "out of detector";
37  return svols[volume] + 1;
38 } // EicRootDetector::IsInDetector()
39 
40 // ---------------------------------------------------------------------------------------
41 
42 void EicRootDetector::ConstructMe(G4LogicalVolume *logicWorld)
43 {
44  // The subsystem; it is this class, which inherits from EicGeoParData;
45  auto subsys = dynamic_cast<EicRootSubsystem*>(GetMySubsystem());
46 
47  // Get pointer to the mother volume and place subdetector volumes into it;
48  std::string mvolume = subsys->GetParams()->get_string_param("MotherVolume");
49  if (mvolume == "DefaultParameters-Invalid")
50  subsys->PlaceG4Volume(logicWorld, true, 0, new G4ThreeVector(0, 0, 0));
51  else {
52  // EicToyModel singleton;
53  auto eic = EicToyModel::Instance();
54 
55  auto mid = eic->mid()->get(mvolume.c_str())->GetG4Volume();
56  subsys->PlaceG4Volume(mid->GetLogicalVolume(), true, 0, new G4ThreeVector(0, 0, 0));
57  } //if
58 
59  // Declare sensitive volumes;
60  //for(auto phy: subsys->GetG4SensitiveVolumes())
61  //m_PhysicalVolumesSet.insert(phy);
62 
63  return;
64 } // EicRootDetector::ConstructMe()
65 
66 // ---------------------------------------------------------------------------------------
67 
68 void EicRootDetector::Print(const std::string &what) const
69 {
70  // FIXME: need to implement this stuff;
71  cout << "EicRoot Detector:" << endl;
72  if (what == "ALL" || what == "VOLUME") {
73  cout << "Version 0.1" << endl;
74  cout << "Parameters:" << endl;
75  //m_Params->Print();
76  } //if
77 
78  return;
79 } // EicRootDetector::Print()
80 
81 // ---------------------------------------------------------------------------------------