Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:24:00

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