EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4LmonDetector.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4LmonDetector.cc
1 #include "G4LmonDetector.h"
2 #include "ExitWindowV2.h"
3 #include "Cell.h"
4 #include "CompCal.h"
5 #include "Collimator.h"
6 #include "Magnet.h"
7 #include "OpDet.h"
8 #include "RootOut.h"
9 
10 #include <g4main/PHG4Detector.h> // for PHG4Detector
11 
12 #include <Geant4/G4Box.hh>
13 #include <Geant4/G4Color.hh>
14 #include <Geant4/G4LogicalVolume.hh>
15 #include <Geant4/G4NistManager.hh>
16 #include <Geant4/G4Material.hh>
17 #include <Geant4/G4PVPlacement.hh>
18 #include <Geant4/G4SubtractionSolid.hh>
19 #include <Geant4/G4SystemOfUnits.hh>
20 #include <Geant4/G4Tubs.hh>
21 #include <Geant4/G4UnionSolid.hh>
22 #include <Geant4/G4VisAttributes.hh>
23 
24 #include <cmath>
25 #include <iostream> // for operator<<, endl, bas...
26 
27 class G4VSolid;
28 class PHCompositeNode;
29 
30 using namespace std;
31 
32 G4LmonDetector::G4LmonDetector(PHG4Subsystem *subsys, PHCompositeNode *Node, const std::string &dnam)
33  : PHG4Detector(subsys, Node, dnam)
34 {
35 }
36 
37 //_______________________________________________________________
38 //_______________________________________________________________
39 int G4LmonDetector::IsInDetector(G4VPhysicalVolume *volume) const
40 {
41  set<G4VPhysicalVolume *>::const_iterator iter = m_PhysicalVolumesSet.find(volume);
42  if (iter != m_PhysicalVolumesSet.end())
43  {
44  return 1;
45  }
46 
47  return 0;
48 }
49 
50 void G4LmonDetector::ConstructMe(G4LogicalVolume *logicWorld)
51 {
52  G4Material* top_m = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic");
53  G4VSolid *top_s = new G4Box("top_s", 2*meter, 2*meter, 3500*cm);
54  G4LogicalVolume *top_l = new G4LogicalVolume(top_s, top_m, "top_l");
55  new G4PVPlacement(nullptr, G4ThreeVector(0,0,0), top_l, "top_p", logicWorld, false, 0);
56  ExitWindowV2 *ew = new ExitWindowV2("ew", -20.75*meter, top_l);
57  m_ExitWindowV2Vector.push_back(ew);
59  new Collimator(-22.1*meter, top_l);
60  new Magnet(-22.5*meter, top_l);
61  //detectors
62  G4double dpos = -3135*cm;
63  CompCal *cmpcal = new CompCal("phot", dpos-50*cm, 0, top_l, rootoutput);
64  cmpcal->CreateOutput(rootoutput->GetTree());
65  m_CompCalVector.push_back(cmpcal);
66  cmpcal = new CompCal("up", dpos, 4.2*cm, top_l,rootoutput );
67  cmpcal->CreateOutput(rootoutput->GetTree());
68  m_CompCalVector.push_back(cmpcal);
69  cmpcal = new CompCal("down", dpos, -4.2*cm, top_l, rootoutput);
70  cmpcal->CreateOutput(rootoutput->GetTree());
71  m_CompCalVector.push_back(cmpcal);
72  return;
73 }
74 
75 bool G4LmonDetector::ExecuteSteppingActions(const G4Step* aStep)
76 {
77  bool bret = false;
78 
79  for (auto iter=m_CellVector.begin(); iter != m_CellVector.end(); ++iter)
80  {
81  bret |= (*iter)->ProcessHits(aStep, nullptr);
82  }
83  for (auto iter=m_ExitWindowV2Vector.begin(); iter != m_ExitWindowV2Vector.end(); ++iter)
84  {
85  bret |= (*iter)->ProcessHits(aStep, nullptr);
86  }
87  for (auto iter=m_OpDetVector.begin(); iter != m_OpDetVector.end(); ++iter)
88  {
89  bret |= (*iter)->ProcessHits(aStep, nullptr);
90  }
91  return bret;
92 }
93 
95 {
96  for (auto iter=m_CellVector.begin(); iter != m_CellVector.end(); ++iter)
97  {
98  (*iter)->ClearEvent();
99  }
100  for (auto iter=m_ExitWindowV2Vector.begin(); iter != m_ExitWindowV2Vector.end(); ++iter)
101  {
102  (*iter)->ClearEvent();
103  }
104  for (auto iter=m_OpDetVector.begin(); iter != m_OpDetVector.end(); ++iter)
105  {
106  (*iter)->ClearEvent();
107  }
108  return;
109 }
110 
112 {
113  for (auto iter=m_CompCalVector.begin(); iter != m_CompCalVector.end(); ++iter)
114  {
115  (*iter)->FinishEvent();
116  }
117  for (auto iter=m_ExitWindowV2Vector.begin(); iter != m_ExitWindowV2Vector.end(); ++iter)
118  {
119  (*iter)->FinishEvent();
120  }
121  for (auto iter=m_OpDetVector.begin(); iter != m_OpDetVector.end(); ++iter)
122  {
123  (*iter)->FinishEvent();
124  }
125  return;
126 }
127 
128 void G4LmonDetector::Print(const std::string &what) const
129 {
130  cout << "Luminosity Monitor Detector:" << endl;
131  if (what == "ALL" || what == "VOLUME")
132  {
133  cout << "Version 0.1" << endl;
134  }
135  return;
136 }