EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4ConeDetector.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4ConeDetector.cc
1 #include "PHG4ConeDetector.h"
3 
4 #include <phparameter/PHParameters.h>
5 
6 #include <g4main/PHG4Detector.h> // for PHG4Detector
7 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
8 #include <g4main/PHG4Subsystem.h>
9 
10 #include <Geant4/G4Cons.hh>
11 #include <Geant4/G4LogicalVolume.hh>
12 #include <Geant4/G4PVPlacement.hh>
13 #include <Geant4/G4RotationMatrix.hh> // for G4RotationMatrix
14 #include <Geant4/G4String.hh> // for G4String
15 #include <Geant4/G4SystemOfUnits.hh> // for cm
16 #include <Geant4/G4ThreeVector.hh> // for G4ThreeVector
17 
18 #include <iostream> // for operator<<, endl, basic_ostream
19 #include <sstream>
20 
21 class G4Material;
22 class G4VSolid;
23 
24 //_______________________________________________________________
25 //note this inactive thickness is ~1.5% of a radiation length
26 PHG4ConeDetector::PHG4ConeDetector(PHG4Subsystem *subsys, PHCompositeNode *Node, PHParameters *parameters, const std::string &dnam, const int lyr)
27  : PHG4Detector(subsys, Node, dnam)
28  , m_Params(parameters)
29  , m_DisplayAction(dynamic_cast<PHG4ConeDisplayAction *>(subsys->GetDisplayAction()))
30  , layer(lyr)
31 {
32 }
33 
34 //_______________________________________________________________
35 //_______________________________________________________________
36 bool PHG4ConeDetector::IsInConeActive(G4VPhysicalVolume *volume)
37 {
38  if (volume == m_ConePhysVol)
39  {
40  return true;
41  }
42  return false;
43 }
44 
45 //_______________________________________________________________
46 void PHG4ConeDetector::ConstructMe(G4LogicalVolume *logicWorld)
47 {
48  G4Material *TrackerMaterial = GetDetectorMaterial(m_Params->get_string_param("material"));
49 
50  G4VSolid *cone_solid = new G4Cons((GetName() + "_SOLID"),
51  m_Params->get_double_param("rmin1") * cm,
52  m_Params->get_double_param("rmax1") * cm,
53  m_Params->get_double_param("rmin2") * cm,
54  m_Params->get_double_param("rmax2") * cm,
55  m_Params->get_double_param("length") * cm,
56  m_Params->get_double_param("sphi") * deg,
57  m_Params->get_double_param("dphi") * deg);
58 
59  G4LogicalVolume *cone_logic = new G4LogicalVolume(cone_solid,
60  TrackerMaterial,
61  GetName() + "_LOGIC",
62  0, 0, 0);
63  PHG4Subsystem *mysys = GetMySubsystem();
64  mysys->SetLogicalVolume(cone_logic);
65 
66  G4RotationMatrix *rotm = new G4RotationMatrix();
67 
68  int nRotation(0);
69  if (m_Params->get_double_param("rot_x") !=0 )
70  {
71  ++ nRotation;
72  rotm->rotateX(m_Params->get_double_param("rot_x") * deg);
73  }
74  if (m_Params->get_double_param("rot_y") !=0 )
75  {
76  ++ nRotation;
77  rotm->rotateY(m_Params->get_double_param("rot_y") * deg);
78  }
79  if (m_Params->get_double_param("rot_z") !=0 )
80  {
81  ++ nRotation;
82  rotm->rotateZ(m_Params->get_double_param("rot_z") * deg);
83  }
84 
85  if (nRotation>=2)
86  {
87  std::cout <<__PRETTY_FUNCTION__<<": Warning : " <<GetName()<<" is configured with more than one of the x-y-z rotations of "
88  <<"("<<m_Params->get_double_param("rot_x")<<", "
89  <<m_Params->get_double_param("rot_x")<<", "
90  <<m_Params->get_double_param("rot_x")<<") degrees. "
91  <<"The rotation is instruction is ambiguous and they are performed in the order of X->Y->Z rotations with result rotation matrix of:";
92  rotm->print(std::cout);
93  }
94 
95  m_ConePhysVol = new G4PVPlacement(rotm,
96  G4ThreeVector(m_Params->get_double_param("place_x") * cm,
97  m_Params->get_double_param("place_y") * cm,
98  m_Params->get_double_param("place_z") * cm),
99  cone_logic,
100  GetName(),
101  logicWorld, 0, false, OverlapCheck());
102  m_DisplayAction->SetMyVolume(cone_logic);
103 }