EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_BlackHole.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_BlackHole.C
1 #ifndef MACRO_G4BLACKHOLE_C
2 #define MACRO_G4BLACKHOLE_C
3 
4 #include <GlobalVariables.C>
5 
7 #include <g4main/PHG4Reco.h>
8 
9 R__LOAD_LIBRARY(libg4detectors.so)
10 
11 namespace Enable
12 {
13  bool BLACKHOLE = false;
14  bool BLACKHOLE_SAVEHITS = true;
16 } // namespace Enable
17 
18 void BlackHoleInit() {}
19 
20 void BlackHole(PHG4Reco *g4Reco, double radius)
21 {
22  // swallow all particles coming out of our detector
23  if (radius < BlackHoleGeometry::max_radius)
24  {
26  }
28  double blackhole_zpos = BlackHoleGeometry::min_z - BlackHoleGeometry::gap + blackhole_length / 2.;
29  double blackhole_radius = radius + BlackHoleGeometry::gap; // make the black hole slightly larger than the radius
30  PHG4CylinderSubsystem *blackhole = new PHG4CylinderSubsystem("BH", 1);
31  blackhole->set_double_param("radius", blackhole_radius);
32  blackhole->set_double_param("length", blackhole_length); // make it cover the world in length
33  blackhole->set_double_param("place_z", blackhole_zpos);
34  blackhole->set_double_param("thickness", BlackHoleGeometry::gap / 2.); // it needs some thickness
36  {
37  blackhole->set_color(1, 0, 0, 0.7);
38  }
39  blackhole->BlackHole();
41  {
42  blackhole->SetActive(); // see what leaks out
43  }
44  blackhole->OverlapCheck(true);
45  g4Reco->registerSubsystem(blackhole);
46 
47  //----------------------------------------
48  // FORWARD/BACKWARD BLACKHOLEs (thin disks, thickness is radius, length is thickness)
49  // +Z
50  // if min/max z is not symmetric, the cylinder is not centered around z=0
51  // to find the offset we start with the middle of the barrel at blackhole_zpos, then add its length/2. which
52  // gets us to the end of the cylinder, then we add another gap so the endcap does not overlap
53  // the endcap itself is BlackHoleGeometry::gap/2 thick, leaving BlackHoleGeometry::gap/4 on each side of the
54  // center. Basically we have a gap of BlackHoleGeometry::gap/4 between the barrel and the endplates
55  // therefore we add BlackHoleGeometry::gap to the radius of the endcap so particles trying to go through
56  // the tiny gap between barren and endplate will hit the endplate
57  double blackhole_forward_zpos = blackhole_zpos + blackhole_length / 2. + BlackHoleGeometry::gap / 2.;
58  blackhole = new PHG4CylinderSubsystem("BH_FORWARD_PLUS", 1);
59  blackhole->SuperDetector("BH_FORWARD_PLUS");
60  blackhole->set_double_param("radius", 0.);
61  blackhole->set_double_param("thickness", blackhole_radius + BlackHoleGeometry::gap); // add a bit so we cover the microscopic gap (BlackHoleGeometry::gap) between barrel and endplate
62  blackhole->set_double_param("length", BlackHoleGeometry::gap / 2.); // it needs some thickness but not go outside world
63  blackhole->set_double_param("place_z", blackhole_forward_zpos); // put at the end of the world
65  {
66  blackhole->set_color(1, 0, 0, 0.7);
67  }
68  blackhole->BlackHole();
70  {
71  blackhole->SetActive(); // see what leaks out
72  }
73  blackhole->OverlapCheck(true);
74  g4Reco->registerSubsystem(blackhole);
75 
76  // -Z
77  double blackhole_backward_zpos = blackhole_zpos - (blackhole_length / 2. + BlackHoleGeometry::gap / 2.);
78 
79  blackhole = new PHG4CylinderSubsystem("BH_FORWARD_NEG", 1);
80  blackhole->SuperDetector("BH_FORWARD_NEG");
81  blackhole->set_double_param("radius", 0); // add 10 cm
82  blackhole->set_double_param("thickness", blackhole_radius + BlackHoleGeometry::gap); // add a bit so we cover the microscopic gap (BlackHoleGeometry::gap) between barrel and endplate
83  blackhole->set_double_param("length", BlackHoleGeometry::gap / 2.); // it needs some thickness but not go outside world
84  blackhole->set_double_param("place_z", blackhole_backward_zpos);
86  {
87  blackhole->set_color(1, 0, 0, 0.7);
88  }
89  blackhole->BlackHole();
91  {
92  blackhole->SetActive(); // always see what leaks out
93  }
94  blackhole->OverlapCheck(true);
95  g4Reco->registerSubsystem(blackhole);
96  return;
97 }
98 #endif