Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:24

0001 #ifndef MACRO_G4BLACKHOLE_C
0002 #define MACRO_G4BLACKHOLE_C
0003 
0004 #include <GlobalVariables.C>
0005 
0006 #include <g4detectors/PHG4CylinderSubsystem.h>
0007 #include <g4main/PHG4Reco.h>
0008 
0009 R__LOAD_LIBRARY(libg4detectors.so)
0010 
0011 namespace Enable
0012 {
0013   bool BLACKHOLE = false;
0014   bool BLACKHOLE_SAVEHITS = true;
0015   bool BLACKHOLE_FORWARD_SAVEHITS = true;
0016 }  // namespace Enable
0017 
0018 void BlackHoleInit() {}
0019 
0020 void BlackHole(PHG4Reco *g4Reco, double radius)
0021 {
0022   // swallow all particles coming out of our detector
0023   if (radius < BlackHoleGeometry::max_radius)
0024   {
0025     radius = BlackHoleGeometry::max_radius;
0026   }
0027   double blackhole_length = (BlackHoleGeometry::max_z - BlackHoleGeometry::min_z) + 2 * BlackHoleGeometry::gap;
0028   double blackhole_zpos = BlackHoleGeometry::min_z - BlackHoleGeometry::gap + blackhole_length / 2.;
0029   double blackhole_radius = radius + BlackHoleGeometry::gap;  // make the black hole slightly larger than the radius
0030   PHG4CylinderSubsystem *blackhole = new PHG4CylinderSubsystem("BH", 1);
0031   blackhole->set_double_param("radius", blackhole_radius);
0032   blackhole->set_double_param("length", blackhole_length);  // make it cover the world in length
0033   blackhole->set_double_param("place_z", blackhole_zpos);
0034   blackhole->set_double_param("thickness", BlackHoleGeometry::gap / 2.);  // it needs some thickness
0035   if (BlackHoleGeometry::visible)
0036   {
0037     blackhole->set_color(1, 0, 0, 0.7);
0038   }
0039   blackhole->BlackHole();
0040   if (Enable::BLACKHOLE_SAVEHITS)
0041   {
0042     blackhole->SetActive();  // see what leaks out
0043   }
0044   blackhole->OverlapCheck(true);
0045   g4Reco->registerSubsystem(blackhole);
0046 
0047   //----------------------------------------
0048   // FORWARD/BACKWARD BLACKHOLEs (thin disks, thickness is radius, length is thickness)
0049   // +Z
0050   // if min/max z is not symmetric, the cylinder is not centered around z=0
0051   // to find the offset we start with the middle of the barrel at blackhole_zpos, then add its length/2. which
0052   // gets us to the end of the cylinder, then we add another gap so the endcap does not overlap
0053   // the endcap itself is BlackHoleGeometry::gap/2 thick, leaving BlackHoleGeometry::gap/4 on each side of the
0054   // center. Basically we have a gap of BlackHoleGeometry::gap/4 between the barrel and the endplates
0055   // therefore we add BlackHoleGeometry::gap to the radius of the endcap so particles trying to go through
0056   // the tiny gap between barren and endplate will hit the endplate
0057   double blackhole_forward_zpos = blackhole_zpos + blackhole_length / 2. + BlackHoleGeometry::gap / 2.;
0058   blackhole = new PHG4CylinderSubsystem("BH_FORWARD_PLUS", 1);
0059   blackhole->SuperDetector("BH_FORWARD_PLUS");
0060   blackhole->set_double_param("radius", 0.);
0061   blackhole->set_double_param("thickness", blackhole_radius + BlackHoleGeometry::gap);  // add a bit so we cover the microscopic gap (BlackHoleGeometry::gap) between barrel and endplate
0062   blackhole->set_double_param("length", BlackHoleGeometry::gap / 2.);                   // it needs some thickness but not go outside world
0063   blackhole->set_double_param("place_z", blackhole_forward_zpos);                       // put at the end of the world
0064   if (BlackHoleGeometry::visible)
0065   {
0066     blackhole->set_color(1, 0, 0, 0.7);
0067   }
0068   blackhole->BlackHole();
0069   if (Enable::BLACKHOLE_SAVEHITS && Enable::BLACKHOLE_FORWARD_SAVEHITS)
0070   {
0071     blackhole->SetActive();  // see what leaks out
0072   }
0073   blackhole->OverlapCheck(true);
0074   g4Reco->registerSubsystem(blackhole);
0075 
0076   // -Z
0077   double blackhole_backward_zpos = blackhole_zpos - (blackhole_length / 2. + BlackHoleGeometry::gap / 2.);
0078 
0079   blackhole = new PHG4CylinderSubsystem("BH_FORWARD_NEG", 1);
0080   blackhole->SuperDetector("BH_FORWARD_NEG");
0081   blackhole->set_double_param("radius", 0);                                             // add 10 cm
0082   blackhole->set_double_param("thickness", blackhole_radius + BlackHoleGeometry::gap);  // add a bit so we cover the microscopic gap (BlackHoleGeometry::gap) between barrel and endplate
0083   blackhole->set_double_param("length", BlackHoleGeometry::gap / 2.);                   // it needs some thickness but not go outside world
0084   blackhole->set_double_param("place_z", blackhole_backward_zpos);
0085   if (BlackHoleGeometry::visible)
0086   {
0087     blackhole->set_color(1, 0, 0, 0.7);
0088   }
0089   blackhole->BlackHole();
0090   if (Enable::BLACKHOLE_SAVEHITS && Enable::BLACKHOLE_FORWARD_SAVEHITS)
0091   {
0092     blackhole->SetActive();  // always see what leaks out
0093   }
0094   blackhole->OverlapCheck(true);
0095   g4Reco->registerSubsystem(blackhole);
0096   return;
0097 }
0098 #endif