EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AllSi_Al_support_Detector.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AllSi_Al_support_Detector.cc
2 #include <phparameter/PHParameters.h>
3 #include <g4main/PHG4Detector.h>
4 #include <Geant4/G4Box.hh>
5 #include <Geant4/G4Polycone.hh>
6 #include <Geant4/G4Color.hh>
7 #include <Geant4/G4LogicalVolume.hh>
8 #include <Geant4/G4Material.hh>
9 #include <Geant4/G4PVPlacement.hh>
10 #include <Geant4/G4SystemOfUnits.hh>
11 #include <Geant4/G4VisAttributes.hh>
12 #include <cmath>
13 #include <iostream>
14 
15 class G4VSolid;
16 class PHCompositeNode;
17 using namespace std;
18 //____________________________________________________________________________..
20  PHCompositeNode *Node,
22  const std::string &dnam)
23  : PHG4Detector(subsys, Node, dnam)
24  , m_Params(parameters)
25 {
26 }
27 //_______________________________________________________________
28 int AllSi_Al_support_Detector::IsInDetector(G4VPhysicalVolume *volume) const
29 {
30  set<G4VPhysicalVolume *>::const_iterator iter = m_PhysicalVolumesSet.find(volume);
31  if (iter != m_PhysicalVolumesSet.end())
32  {
33  return 1;
34  }
35  return 0;
36 }
37 //_______________________________________________________________
38 void AllSi_Al_support_Detector::ConstructMe(G4LogicalVolume *logicWorld)
39 {
40  //begin implement your own here://
41  // Do not forget to multiply the parameters with their respective CLHEP/G4 unit !
42  addDetectorSection( logicWorld , "Al_pos_z" , 1. );
43  addDetectorSection( logicWorld , "Al_neg_z" , -1. );
44  //end implement your own here://
45  return;
46 }
47 // ======================================================================================================
48 void AllSi_Al_support_Detector::Print(const std::string &what) const
49 {
50  cout << "AllSi_Al_support_ Detector:" << endl;
51  if (what == "ALL" || what == "VOLUME")
52  {
53  cout << "Version 0.1" << endl;
54  cout << "Parameters:" << endl;
55  m_Params->Print();
56  }
57  return;
58 }
59 // ======================================================================================================
60 void AllSi_Al_support_Detector::addDetectorSection( G4LogicalVolume *logicWorld , std::string name , double sign){
61 
62  double z_det[3] = {20.,43.23*25./18.5, 121.};
63  double rin [3] = {18.5 * 20.0 / 25.0,43.23,43.23};
64  double rout [3] = {0};
65  const int nzplanes = sizeof(z_det)/sizeof(*z_det);
66  for(int i = 0 ; i < nzplanes ; i++){
67  rout[i] = rin[i] + 0.5;
68  z_det[i] *= 10.*sign/abs(sign);
69  rin [i] *= 10.;
70  rout [i] *= 10.;
71  }
72 
73  G4Material * G4_mat = GetDetectorMaterial("G4_Al");
74 
75  G4RotationMatrix *rotm = new G4RotationMatrix();
76  rotm->rotateX(0);
77  rotm->rotateY(0);
78  rotm->rotateZ(0);
79 
80  G4Color G4_color = G4Color(G4Colour::Yellow());
81 
82  G4VSolid *G4_polycone = new G4Polycone(name,0,360*degree,nzplanes,z_det,rin,rout);
83  G4LogicalVolume *logical = new G4LogicalVolume(G4_polycone,G4_mat, "AllSi_Al_support_Logical");
84  G4VisAttributes *vis_1 = new G4VisAttributes(G4_color);
85  vis_1->SetForceSolid(true);
86  logical->SetVisAttributes(vis_1);
87 
88  G4VPhysicalVolume *phy_1 = new G4PVPlacement(rotm, G4ThreeVector(0,0,0), logical , "AllSi_Al_support_", logicWorld, 0, false, OverlapCheck());
89 
90  // add it to the list of placed volumes so the IsInDetector method picks them up
91  m_PhysicalVolumesSet.insert(phy_1);
92 }