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_G4_BLACKHOLE_C
2 #define MACRO_G4_BLACKHOLE_C
3 
5 #include <g4main/PHG4Reco.h>
6 #include <string>
7 
8 R__LOAD_LIBRARY(libg4detectors.so)
9 
10 // ======================================================================================================================
11 void wrap_with_cylindrical_blackhole(PHG4Reco *g4Reco,double R,double zmin, double zmax, bool endcaps = true){
12  /*
13  This code creates a cylinder of radius R and range in z from zmin to zmax
14  and makes these cylinders blackholes so that when a particle reaches them, these
15  surfaces absorb them and don't let these particles loop back into the geometry.
16  The values R, zmin, and zmax must be in cm.
17  */
18 
19  double thinness = 0.1; // black hole thickness, needs to be taken into account for the z positions
20  double hole = 0; // If beampipe needs to be fed through a hole
21 
22  PHG4CylinderSubsystem * cyl_BH;
23 
24  cyl_BH = new PHG4CylinderSubsystem("BH_BARR",0);
25  cyl_BH->set_double_param("length" , zmax - zmin);
26  cyl_BH->set_double_param("radius" , R );
27  cyl_BH->set_double_param("thickness", thinness );
28  cyl_BH->set_string_param("material" , "G4_AIR" );
29  cyl_BH->SuperDetector("BH_BARR");
30  cyl_BH->BlackHole();
31  cyl_BH->set_color(0.9,0.5,1,0.5);
32  g4Reco->registerSubsystem(cyl_BH);
33 
34  if(endcaps){
35  cyl_BH = new PHG4CylinderSubsystem("BH_FOR",0);
36  cyl_BH->set_double_param("length" , thinness );
37  cyl_BH->set_double_param("radius" , hole );
38  cyl_BH->set_double_param("thickness", R - hole );
39  cyl_BH->set_string_param("material" , "G4_AIR" );
40  cyl_BH->set_double_param("place_z" , zmax+thinness/2.);
41  cyl_BH->SuperDetector("BH_FOR");
42  cyl_BH->BlackHole();
43  cyl_BH->set_color(0.9,0.5,1,0.5);
44  g4Reco->registerSubsystem(cyl_BH);
45 
46  cyl_BH = new PHG4CylinderSubsystem("BH_BACK",0);
47  cyl_BH->set_double_param("length" , thinness );
48  cyl_BH->set_double_param("radius" , hole );
49  cyl_BH->set_double_param("thickness", R - hole );
50  cyl_BH->set_string_param("material" , "G4_AIR" );
51  cyl_BH->set_double_param("place_z" , zmin-thinness/2.);
52  cyl_BH->SuperDetector("BH_BACK");
53  cyl_BH->BlackHole();
54  cyl_BH->set_color(0.9,0.5,1,0.5);
55  g4Reco->registerSubsystem(cyl_BH);
56  }
57 }
58 #endif