EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4JLeicDIRCDetector.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4JLeicDIRCDetector.cc
1 #include "G4JLeicDIRCDetector.h"
2 
3 #include <g4main/PHG4Detector.h> // for PHG4Detector
4 
5 #include <Geant4/G4Box.hh>
6 #include <Geant4/G4Color.hh>
7 #include <Geant4/G4LogicalVolume.hh>
8 #include <Geant4/G4Material.hh>
9 #include <Geant4/G4PVPlacement.hh>
10 #include <Geant4/G4RotationMatrix.hh> // for G4RotationMatrix
11 #include <Geant4/G4String.hh> // for G4String
12 #include <Geant4/G4SystemOfUnits.hh>
13 #include <Geant4/G4ThreeVector.hh> // for G4ThreeVector
14 #include <Geant4/G4Transform3D.hh> // for G4Transform3D
15 #include <Geant4/G4VisAttributes.hh>
16 
17 #include <cmath>
18 #include <iostream> // for operator<<, endl, bas...
19 
20 class G4VSolid;
21 class PHCompositeNode;
22 
23 using namespace std;
24 
25 G4JLeicDIRCDetector::G4JLeicDIRCDetector(PHG4Subsystem *subsys, PHCompositeNode *Node, PHParameters *params, const std::string &dnam)
26  : PHG4Detector(subsys, Node, dnam)
27  , m_Params(params)
28 {
29 }
30 
31 //_______________________________________________________________
32 //_______________________________________________________________
33 int G4JLeicDIRCDetector::IsInDIRC(G4VPhysicalVolume *volume) const
34 {
35  set<G4VPhysicalVolume *>::const_iterator iter = m_PhysicalVolumesSet.find(volume);
36 
37  if (iter != m_PhysicalVolumesSet.end())
38  {
39  return 1;
40  }
41 
42  return 0;
43 }
44 
45 void G4JLeicDIRCDetector::ConstructMe(G4LogicalVolume *logicWorld)
46 {
47  cout << "constructing DIRC" << endl;
48  double cb_DIRC_bars_DZ = 340 * cm;
49  double cb_DIRC_bars_DY = 42. * cm;
50  double cb_DIRC_bars_DX = 1.7 * cm;
51  double dR = 83.65 * cm;
52  double myL = 2 * M_PI * dR;
53  int NUM = myL / cb_DIRC_bars_DY;
54  double cb_DIRC_bars_deltaphi = 2 * M_PI / NUM;
55  string solidname = "cb_DIRC_bars_Solid";
56  G4VSolid *solid = new G4Box(solidname, cb_DIRC_bars_DX / 2., cb_DIRC_bars_DY / 2., cb_DIRC_bars_DZ / 2.);
57  string logicname = "cb_DIRC_bars_Logic";
58  G4LogicalVolume *logical = new G4LogicalVolume(solid, G4Material::GetMaterial("Quartz"), logicname);
59  G4VisAttributes *vis = new G4VisAttributes(G4Color(0., 1., 0., 1.0));
60  vis->SetForceSolid(true);
61  logical->SetVisAttributes(vis);
62  for (int ia = 0; ia < NUM; ia++)
63  {
64  double phi = (ia * (cb_DIRC_bars_deltaphi));
65  double x = -dR * cos(phi);
66  double y = -dR * sin(phi);
67  G4RotationMatrix rot;
68  rot.rotateZ(cb_DIRC_bars_deltaphi * ia);
69  string physname = "cb_DIRC_bars_Phys_" + to_string(ia);
70  G4VPhysicalVolume *phy = new G4PVPlacement(G4Transform3D(rot, G4ThreeVector(x, y, 0)),
71  logical, physname,
72  logicWorld, ia, false, OverlapCheck());
73  m_PhysicalVolumesSet.insert(phy);
74  }
75  return;
76 }
77 
78 void G4JLeicDIRCDetector::Print(const std::string &what) const
79 {
80  cout << "JLeic DIRC Detector:" << endl;
81  if (what == "ALL" || what == "VOLUME")
82  {
83  cout << "Version 0.1" << endl;
84  }
85  return;
86 }