Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef MACRO_G4PIPE_C
0002 #define MACRO_G4PIPE_C
0003 
0004 #include <GlobalVariables.C>
0005 
0006 #include <g4detectors/PHG4ConeSubsystem.h>
0007 #include <g4detectors/PHG4CylinderSubsystem.h>
0008 
0009 #include <g4main/PHG4Reco.h>
0010 
0011 R__LOAD_LIBRARY(libg4detectors.so)
0012 
0013 namespace Enable
0014 {
0015   bool PIPE = false;
0016   bool PIPE_ABSORBER = false;
0017   bool PIPE_OVERLAPCHECK = false;
0018   int PIPE_VERBOSITY = 0;
0019   bool PIPE_MISALIGNMENT = false;
0020 }  // namespace Enable
0021 
0022 namespace G4PIPE
0023 {
0024   // STAR Beampipe for sPHENIX - based on STAR DWG 30006
0025   double be_pipe_radius = 2.00025;       // 4.0005 cm inner diameter
0026   double be_pipe_thickness = 0.0762;     // 0.762 mm
0027   double be_pipe_length = 120.015;       // 120 cm or 47.25"
0028   double be_pipe_zshift = -41.1639;      // amount Be pipe is shifted south
0029 
0030   double al_pipe_radius = 2.00025;       // same as Be pipe
0031   double al_pipe_thickness = 0.1397;     // 1.397 mm or 0.055"
0032   double al_pipe_south_length = 101.486; // Al extension south (from Dan's drawing, slight diff from STAR drawing)
0033   double al_pipe_north_length = 61.51;   // Al extension north (from Dan's drawing, slight diff from STAR drawing)
0034   double al_pipe_north_ext_length = 123.393;  // additional north extension
0035 
0036   double flange_thickness = 6.934/2 - (al_pipe_radius + al_pipe_thickness); // Atlas 2.75" flange, radial thickness
0037   double flange_length = 1.2825;                                                // Atlas 2.75" flange
0038 
0039   double outer_pipe_precone_length = 22.86;
0040   double outer_pipe_precone_radius = 2.00025;       // same as Be pipe
0041   double outer_pipe_thickness = 0.1397;             // 1.397 mm or 0.055"
0042   double outer_pipe_cone_length = 38.1;
0043   double outer_pipe_ext_radius = 3.81;    // past the cone
0044 //  double outer_pipe_ext_length = 67.087;    // extension beyond conical part
0045   double outer_pipe_ext_length = 100.;    // extension beyond conical part through epd
0046 
0047   // maximum extent of the central part of beampipe (the forward regions are implemented in G4_Beamline.C)
0048   double max_z = be_pipe_zshift + be_pipe_length / 2. + al_pipe_north_length + al_pipe_north_ext_length +
0049     outer_pipe_precone_length + outer_pipe_cone_length + outer_pipe_ext_length;
0050 
0051   // Shifts of beam pipe (2024)
0052   double pipe_xshift = (5.161786 + 0.2) * 0.1; // 5.161786 + 0.2 mm
0053   double pipe_yshift = 0.0 * 0.1; // 0.0 mm
0054   double pipe_zshift = 0.751524 * 0.1; // 0.751524 mm
0055 
0056 }  // namespace G4PIPE
0057 
0058 void PipeInit()
0059 {
0060   BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, G4PIPE::outer_pipe_ext_radius + G4PIPE::outer_pipe_thickness);
0061   BlackHoleGeometry::max_z = std::max(BlackHoleGeometry::max_z, G4PIPE::max_z + no_overlapp );
0062   BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, -(G4PIPE::max_z + no_overlapp) );
0063 }
0064 
0065 double Pipe(PHG4Reco* g4Reco, double radius)
0066 {
0067   bool AbsorberActive = Enable::ABSORBER || Enable::PIPE_ABSORBER;
0068   bool OverlapCheck = Enable::OVERLAPCHECK || Enable::PIPE_OVERLAPCHECK;
0069   int verbosity = std::max(Enable::VERBOSITY, Enable::PIPE_VERBOSITY);
0070 
0071   if (radius > G4PIPE::be_pipe_radius)
0072   {
0073     cout << "inconsistency: radius: " << radius
0074          << " larger than pipe inner radius: " << G4PIPE::be_pipe_radius << endl;
0075     gSystem->Exit(-1);
0076   }
0077 
0078   cout << "PHG4Reco::Registering Pipe Subsystems, PIPE_MISALIGNMENT = " << Enable::PIPE_MISALIGNMENT << endl << " pipe is shifted by (x,y,z) = (" << G4PIPE::pipe_xshift << ", " << G4PIPE::pipe_yshift << ", " << G4PIPE::pipe_zshift << ") cm" << endl;
0079 
0080   int ilayer = 0;
0081 
0082   // mid-rapidity beryllium pipe
0083   PHG4CylinderSubsystem* cyl = new PHG4CylinderSubsystem("VAC_BE_PIPE", ilayer++);
0084   if (Enable::PIPE_MISALIGNMENT)
0085   {
0086     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0087     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0088     cyl->set_double_param("place_z", G4PIPE::be_pipe_zshift + G4PIPE::pipe_zshift);
0089   }
0090   else
0091   {
0092     cyl->set_double_param("place_z", G4PIPE::be_pipe_zshift);
0093   }
0094   cyl->set_double_param("radius", 0.0);
0095   cyl->set_int_param("lengthviarapidity", 0);
0096   cyl->set_double_param("length", G4PIPE::be_pipe_length);
0097   cyl->set_string_param("material", "G4_Galactic");
0098   cyl->set_double_param("thickness", G4PIPE::be_pipe_radius);
0099   cyl->SuperDetector("PIPE");
0100   if (AbsorberActive) cyl->SetActive();
0101   cyl->OverlapCheck(OverlapCheck);
0102   g4Reco->registerSubsystem(cyl);
0103 
0104   cyl = new PHG4CylinderSubsystem("BE_PIPE", ilayer++);
0105   if (Enable::PIPE_MISALIGNMENT)
0106   {
0107     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0108     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0109     cyl->set_double_param("place_z", G4PIPE::be_pipe_zshift + G4PIPE::pipe_zshift);
0110   }
0111   else
0112   {
0113     cyl->set_double_param("place_z", G4PIPE::be_pipe_zshift);
0114   }
0115   cyl->set_double_param("radius", G4PIPE::be_pipe_radius);  // inner radius
0116   cyl->set_int_param("lengthviarapidity", 0);
0117   cyl->set_double_param("length", G4PIPE::be_pipe_length);
0118   cyl->set_string_param("material", "G4_Be");
0119   cyl->set_double_param("thickness", G4PIPE::be_pipe_thickness);
0120   cyl->SuperDetector("PIPE");
0121   if (AbsorberActive) cyl->SetActive();
0122   cyl->OverlapCheck(OverlapCheck);
0123   g4Reco->registerSubsystem(cyl);
0124 
0125   // north aluminum pipe
0126   double north_pipe_place_z = G4PIPE::be_pipe_zshift + 0.5 * G4PIPE::be_pipe_length + 0.5 * (G4PIPE::al_pipe_north_length + G4PIPE::al_pipe_north_ext_length);
0127   cyl = new PHG4CylinderSubsystem("VAC_N_AL_PIPE", ilayer++);
0128   if (Enable::PIPE_MISALIGNMENT)
0129   {
0130     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0131     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0132     cyl->set_double_param("place_z", north_pipe_place_z + no_overlapp + G4PIPE::pipe_zshift);
0133   }
0134   else
0135   {
0136     cyl->set_double_param("place_z", north_pipe_place_z + no_overlapp);
0137   }
0138   cyl->set_double_param("radius", 0.0);
0139   cyl->set_int_param("lengthviarapidity", 0);
0140   cyl->set_double_param("length", G4PIPE::al_pipe_north_length + G4PIPE::al_pipe_north_ext_length);
0141   cyl->set_string_param("material", "G4_Galactic");
0142   cyl->set_double_param("thickness", G4PIPE::al_pipe_radius);
0143   cyl->SuperDetector("PIPE");
0144   if (AbsorberActive) cyl->SetActive();
0145   cyl->OverlapCheck(OverlapCheck);
0146   g4Reco->registerSubsystem(cyl);
0147 
0148   cyl = new PHG4CylinderSubsystem("N_AL_PIPE", ilayer++);
0149   if (Enable::PIPE_MISALIGNMENT)
0150   {
0151     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0152     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0153     cyl->set_double_param("place_z", north_pipe_place_z + no_overlapp + G4PIPE::pipe_zshift);
0154   }
0155   else
0156   {
0157     cyl->set_double_param("place_z", north_pipe_place_z + no_overlapp);
0158   }
0159   cyl->set_double_param("radius", G4PIPE::al_pipe_radius);
0160   cyl->set_int_param("lengthviarapidity", 0);
0161   cyl->set_double_param("length", G4PIPE::al_pipe_north_length + G4PIPE::al_pipe_north_ext_length);
0162   cyl->set_string_param("material", "G4_Al");
0163   cyl->set_double_param("thickness", G4PIPE::al_pipe_thickness);
0164   cyl->SuperDetector("PIPE");
0165   if (AbsorberActive) cyl->SetActive();
0166   cyl->OverlapCheck(OverlapCheck);
0167   g4Reco->registerSubsystem(cyl);
0168 
0169   // north flange 1A
0170   double flange_place_z = G4PIPE::be_pipe_zshift + 0.5 * G4PIPE::be_pipe_length + G4PIPE::al_pipe_north_length; // center of flange coupling
0171   // Al half, towards IP
0172   cyl = new PHG4CylinderSubsystem("N_FLANGE_1A_AL", ilayer++);
0173   if (Enable::PIPE_MISALIGNMENT)
0174   {
0175     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0176     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0177     cyl->set_double_param("place_z", flange_place_z - 0.75*G4PIPE::flange_length + G4PIPE::pipe_zshift);
0178   }
0179   else
0180   {
0181     cyl->set_double_param("place_z", flange_place_z - 0.75*G4PIPE::flange_length);
0182   }
0183   cyl->set_double_param("radius", G4PIPE::al_pipe_radius + G4PIPE::al_pipe_thickness);
0184   cyl->set_int_param("lengthviarapidity", 0);
0185   cyl->set_double_param("length", G4PIPE::flange_length/2);
0186   cyl->set_string_param("material", "G4_Al");
0187   cyl->set_double_param("thickness", G4PIPE::flange_thickness);
0188   cyl->SuperDetector("PIPE");
0189   if (AbsorberActive) cyl->SetActive();
0190   cyl->OverlapCheck(OverlapCheck);
0191   g4Reco->registerSubsystem(cyl);
0192 
0193   // SS half, away from IP
0194   cyl = new PHG4CylinderSubsystem("N_FLANGE_1A_SS", ilayer++);
0195   if (Enable::PIPE_MISALIGNMENT)
0196   {
0197     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0198     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0199     cyl->set_double_param("place_z", flange_place_z - 0.25*G4PIPE::flange_length + G4PIPE::pipe_zshift);
0200   }
0201   else
0202   {
0203     cyl->set_double_param("place_z", flange_place_z - 0.25*G4PIPE::flange_length);
0204   }
0205   cyl->set_double_param("radius", G4PIPE::al_pipe_radius + G4PIPE::al_pipe_thickness);
0206   cyl->set_int_param("lengthviarapidity", 0);
0207   cyl->set_double_param("length", G4PIPE::flange_length/2);
0208   cyl->set_string_param("material", "G4_STAINLESS-STEEL");
0209   cyl->set_double_param("thickness", G4PIPE::flange_thickness);
0210   cyl->SuperDetector("PIPE");
0211   if (AbsorberActive) cyl->SetActive();
0212   cyl->OverlapCheck(OverlapCheck);
0213   g4Reco->registerSubsystem(cyl);
0214 
0215   // north flange 1B
0216   // SS half, towards IP
0217   cyl = new PHG4CylinderSubsystem("N_FLANGE_1B_SS", ilayer++);
0218   if (Enable::PIPE_MISALIGNMENT)
0219   {
0220     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0221     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0222     cyl->set_double_param("place_z", flange_place_z + 0.25*G4PIPE::flange_length + G4PIPE::pipe_zshift);
0223   }
0224   else
0225   { 
0226     cyl->set_double_param("place_z", flange_place_z + 0.25*G4PIPE::flange_length);
0227   }
0228   cyl->set_double_param("radius", G4PIPE::al_pipe_radius + G4PIPE::al_pipe_thickness);
0229   cyl->set_int_param("lengthviarapidity", 0);
0230   cyl->set_double_param("length", G4PIPE::flange_length/2);
0231   cyl->set_string_param("material", "G4_STAINLESS-STEEL");
0232   cyl->set_double_param("thickness", G4PIPE::flange_thickness);
0233   cyl->SuperDetector("PIPE");
0234   if (AbsorberActive) cyl->SetActive();
0235   cyl->OverlapCheck(OverlapCheck);
0236   g4Reco->registerSubsystem(cyl);
0237 
0238   // Al half, away from IP
0239   cyl = new PHG4CylinderSubsystem("N_FLANGE_1B_Al", ilayer++);
0240   if (Enable::PIPE_MISALIGNMENT)
0241   {
0242     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0243     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0244     cyl->set_double_param("place_z", flange_place_z + 0.75*G4PIPE::flange_length + G4PIPE::pipe_zshift);
0245   }
0246   else
0247   {
0248     cyl->set_double_param("place_z", flange_place_z + 0.75*G4PIPE::flange_length);
0249   }
0250   cyl->set_double_param("radius", G4PIPE::al_pipe_radius + G4PIPE::al_pipe_thickness);
0251   cyl->set_int_param("lengthviarapidity", 0);
0252   cyl->set_double_param("length", G4PIPE::flange_length/2);
0253   cyl->set_string_param("material", "G4_Al");
0254   cyl->set_double_param("thickness", G4PIPE::flange_thickness);
0255   cyl->SuperDetector("PIPE");
0256   if (AbsorberActive) cyl->SetActive();
0257   cyl->OverlapCheck(OverlapCheck);
0258   g4Reco->registerSubsystem(cyl);
0259  
0260   // north flange 2A
0261   flange_place_z = G4PIPE::be_pipe_zshift + 0.5 * G4PIPE::be_pipe_length + G4PIPE::al_pipe_north_length + G4PIPE::al_pipe_north_ext_length;
0262   // Al half, towards IP
0263   cyl = new PHG4CylinderSubsystem("N_FLANGE_2A_Al", ilayer++);
0264   if (Enable::PIPE_MISALIGNMENT)
0265   {
0266     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0267     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0268     cyl->set_double_param("place_z", flange_place_z - 0.75*G4PIPE::flange_length + G4PIPE::pipe_zshift);
0269   }
0270   else
0271   {
0272     cyl->set_double_param("place_z", flange_place_z - 0.75*G4PIPE::flange_length);
0273   }
0274   cyl->set_double_param("radius", G4PIPE::al_pipe_radius + G4PIPE::al_pipe_thickness);
0275   cyl->set_int_param("lengthviarapidity", 0);
0276   cyl->set_double_param("length", G4PIPE::flange_length/2);
0277   cyl->set_string_param("material", "G4_Al");
0278   cyl->set_double_param("thickness", G4PIPE::flange_thickness);
0279   cyl->SuperDetector("PIPE");
0280   if (AbsorberActive) cyl->SetActive();
0281   cyl->OverlapCheck(OverlapCheck);
0282   g4Reco->registerSubsystem(cyl);
0283 
0284   // SS half, away from IP
0285   cyl = new PHG4CylinderSubsystem("N_FLANGE_2A_SS", ilayer++);
0286   if (Enable::PIPE_MISALIGNMENT)
0287   {
0288     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0289     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0290     cyl->set_double_param("place_z", flange_place_z - 0.25*G4PIPE::flange_length + G4PIPE::pipe_zshift);
0291   }
0292   else
0293   {
0294     cyl->set_double_param("place_z", flange_place_z - 0.25*G4PIPE::flange_length);
0295   }
0296   cyl->set_double_param("radius", G4PIPE::al_pipe_radius + G4PIPE::al_pipe_thickness);
0297   cyl->set_int_param("lengthviarapidity", 0);
0298   cyl->set_double_param("length", G4PIPE::flange_length/2);
0299   cyl->set_string_param("material", "G4_STAINLESS-STEEL");
0300   cyl->set_double_param("thickness", G4PIPE::flange_thickness);
0301   cyl->SuperDetector("PIPE");
0302   if (AbsorberActive) cyl->SetActive();
0303   cyl->OverlapCheck(OverlapCheck);
0304   g4Reco->registerSubsystem(cyl);
0305 
0306   // north flange 2B
0307   // SS half, towards IP
0308   cyl = new PHG4CylinderSubsystem("N_FLANGE_2B_SS", ilayer++);
0309   if (Enable::PIPE_MISALIGNMENT)
0310   {
0311     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0312     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0313     cyl->set_double_param("place_z", flange_place_z + 0.25*G4PIPE::flange_length + G4PIPE::pipe_zshift);
0314   }
0315   else
0316   {
0317     cyl->set_double_param("place_z", flange_place_z + 0.25*G4PIPE::flange_length);
0318   }
0319   cyl->set_double_param("radius", G4PIPE::al_pipe_radius + G4PIPE::al_pipe_thickness);
0320   cyl->set_int_param("lengthviarapidity", 0);
0321   cyl->set_double_param("length", G4PIPE::flange_length/2);
0322   cyl->set_string_param("material", "G4_STAINLESS-STEEL");
0323   cyl->set_double_param("thickness", G4PIPE::flange_thickness);
0324   cyl->SuperDetector("PIPE");
0325   if (AbsorberActive) cyl->SetActive();
0326   cyl->OverlapCheck(OverlapCheck);
0327   g4Reco->registerSubsystem(cyl);
0328 
0329   // Al half, away from IP
0330   cyl = new PHG4CylinderSubsystem("N_FLANGE_2B_Al", ilayer++);
0331   if (Enable::PIPE_MISALIGNMENT)
0332   {
0333     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0334     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0335     cyl->set_double_param("place_z", flange_place_z + 0.75*G4PIPE::flange_length + G4PIPE::pipe_zshift);
0336   }
0337   else
0338   {
0339     cyl->set_double_param("place_z", flange_place_z + 0.75*G4PIPE::flange_length);
0340   }
0341   cyl->set_double_param("radius", G4PIPE::al_pipe_radius + G4PIPE::al_pipe_thickness);
0342   cyl->set_int_param("lengthviarapidity", 0);
0343   cyl->set_double_param("length", G4PIPE::flange_length/2);
0344   cyl->set_string_param("material", "G4_Al");
0345   cyl->set_double_param("thickness", G4PIPE::flange_thickness);
0346   cyl->SuperDetector("PIPE");
0347   if (AbsorberActive) cyl->SetActive();
0348   cyl->OverlapCheck(OverlapCheck);
0349   g4Reco->registerSubsystem(cyl);
0350 
0351   // south aluminum pipe
0352   double south_pipe_place_z = G4PIPE::be_pipe_zshift - 0.5 * G4PIPE::be_pipe_length - 0.5 * G4PIPE::al_pipe_south_length;
0353   cyl = new PHG4CylinderSubsystem("VAC_S_AL_PIPE", ilayer++);
0354   if (Enable::PIPE_MISALIGNMENT)
0355   {
0356     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0357     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0358     cyl->set_double_param("place_z", south_pipe_place_z - no_overlapp + G4PIPE::pipe_zshift);
0359   }
0360   else
0361   {
0362     cyl->set_double_param("place_z", south_pipe_place_z - no_overlapp);
0363   }
0364   cyl->set_double_param("radius", 0.0);
0365   cyl->set_int_param("lengthviarapidity", 0);
0366   cyl->set_double_param("length", G4PIPE::al_pipe_south_length);
0367   cyl->set_string_param("material", "G4_Galactic");
0368   cyl->set_double_param("thickness", G4PIPE::al_pipe_radius);
0369   cyl->SuperDetector("PIPE");
0370   if (AbsorberActive) cyl->SetActive();
0371   cyl->OverlapCheck(OverlapCheck);
0372   g4Reco->registerSubsystem(cyl);
0373 
0374   cyl = new PHG4CylinderSubsystem("S_AL_PIPE", ilayer++);
0375   if (Enable::PIPE_MISALIGNMENT)
0376   {
0377     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0378     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0379     cyl->set_double_param("place_z", south_pipe_place_z - no_overlapp + G4PIPE::pipe_zshift);
0380   }
0381   else
0382   {
0383     cyl->set_double_param("place_z", south_pipe_place_z - no_overlapp);
0384   }
0385   cyl->set_double_param("radius", G4PIPE::al_pipe_radius);
0386   cyl->set_int_param("lengthviarapidity", 0);
0387   cyl->set_double_param("length", G4PIPE::al_pipe_south_length);
0388   cyl->set_string_param("material", "G4_Al");
0389   cyl->set_double_param("thickness", G4PIPE::al_pipe_thickness);
0390   cyl->SuperDetector("PIPE");
0391   if (AbsorberActive) cyl->SetActive();
0392   cyl->OverlapCheck(OverlapCheck);
0393   g4Reco->registerSubsystem(cyl);
0394 
0395   // south flange 1A
0396   flange_place_z = G4PIPE::be_pipe_zshift - 0.5 * G4PIPE::be_pipe_length - G4PIPE::al_pipe_south_length;
0397   // Al half, towards IP
0398   cyl = new PHG4CylinderSubsystem("S_FLANGE_1A_Al", ilayer++);
0399   if (Enable::PIPE_MISALIGNMENT)
0400   {
0401     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0402     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0403     cyl->set_double_param("place_z", flange_place_z + 0.75*G4PIPE::flange_length + G4PIPE::pipe_zshift);
0404   }
0405   else 
0406   {
0407     cyl->set_double_param("place_z", flange_place_z + 0.75*G4PIPE::flange_length);
0408   }
0409   cyl->set_double_param("radius", G4PIPE::al_pipe_radius + G4PIPE::al_pipe_thickness);
0410   cyl->set_int_param("lengthviarapidity", 0);
0411   cyl->set_double_param("length", G4PIPE::flange_length/2);
0412   cyl->set_string_param("material", "G4_Al");
0413   cyl->set_double_param("thickness", G4PIPE::flange_thickness);
0414   cyl->SuperDetector("PIPE");
0415   if (AbsorberActive) cyl->SetActive();
0416   cyl->OverlapCheck(OverlapCheck);
0417   g4Reco->registerSubsystem(cyl);
0418 
0419   // SS half, away from IP
0420   cyl = new PHG4CylinderSubsystem("S_FLANGE_1A_SS", ilayer++);
0421   if (Enable::PIPE_MISALIGNMENT)
0422   {
0423     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0424     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0425     cyl->set_double_param("place_z", flange_place_z + 0.25*G4PIPE::flange_length + G4PIPE::pipe_zshift);
0426   }
0427   else
0428   {
0429     cyl->set_double_param("place_z", flange_place_z + 0.25*G4PIPE::flange_length);
0430   } 
0431   cyl->set_double_param("radius", G4PIPE::al_pipe_radius + G4PIPE::al_pipe_thickness);
0432   cyl->set_int_param("lengthviarapidity", 0);
0433   cyl->set_double_param("length", G4PIPE::flange_length/2);
0434   cyl->set_string_param("material", "G4_STAINLESS-STEEL");
0435   cyl->set_double_param("thickness", G4PIPE::flange_thickness);
0436   cyl->SuperDetector("PIPE");
0437   if (AbsorberActive) cyl->SetActive();
0438   cyl->OverlapCheck(OverlapCheck);
0439   g4Reco->registerSubsystem(cyl);
0440 
0441   // south flange 1B
0442   // SS half, towards IP
0443   cyl = new PHG4CylinderSubsystem("S_FLANGE_1B_SS", ilayer++);
0444   if (Enable::PIPE_MISALIGNMENT)
0445   {
0446     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0447     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0448     cyl->set_double_param("place_z", flange_place_z - 0.25*G4PIPE::flange_length + G4PIPE::pipe_zshift);
0449   }
0450   else
0451   {
0452     cyl->set_double_param("place_z", flange_place_z - 0.25*G4PIPE::flange_length);
0453   }
0454   cyl->set_double_param("radius", G4PIPE::al_pipe_radius + G4PIPE::al_pipe_thickness);
0455   cyl->set_int_param("lengthviarapidity", 0);
0456   cyl->set_double_param("length", G4PIPE::flange_length/2);
0457   cyl->set_string_param("material", "G4_STAINLESS-STEEL");
0458   cyl->set_double_param("thickness", G4PIPE::flange_thickness);
0459   cyl->SuperDetector("PIPE");
0460   if (AbsorberActive) cyl->SetActive();
0461   cyl->OverlapCheck(OverlapCheck);
0462   g4Reco->registerSubsystem(cyl);
0463 
0464   // Al half, away from IP
0465   cyl = new PHG4CylinderSubsystem("S_FLANGE_1B_AL", ilayer++);
0466   if (Enable::PIPE_MISALIGNMENT)
0467   {
0468     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0469     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0470     cyl->set_double_param("place_z", flange_place_z - 0.75*G4PIPE::flange_length + G4PIPE::pipe_zshift);
0471   }
0472   else
0473   {
0474     cyl->set_double_param("place_z", flange_place_z - 0.75*G4PIPE::flange_length);
0475   }
0476   cyl->set_double_param("radius", G4PIPE::al_pipe_radius + G4PIPE::al_pipe_thickness);
0477   cyl->set_int_param("lengthviarapidity", 0);
0478   cyl->set_double_param("length", G4PIPE::flange_length/2);
0479   cyl->set_string_param("material", "G4_Al");
0480   cyl->set_double_param("thickness", G4PIPE::flange_thickness);
0481   cyl->SuperDetector("PIPE");
0482   if (AbsorberActive) cyl->SetActive();
0483   cyl->OverlapCheck(OverlapCheck);
0484   g4Reco->registerSubsystem(cyl);
0485 
0486   /* north outermost pipe (extension) [vacuum] */
0487   north_pipe_place_z += 0.5 * (G4PIPE::al_pipe_north_length + G4PIPE::al_pipe_north_ext_length) + 0.5 * G4PIPE::outer_pipe_precone_length;
0488   cyl = new PHG4CylinderSubsystem("VAC_N_OUTER_PIPE_PRECONE", ilayer++);
0489   if (Enable::PIPE_MISALIGNMENT)
0490   {
0491     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0492     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0493     cyl->set_double_param("place_z", north_pipe_place_z + no_overlapp + G4PIPE::pipe_zshift);
0494   }
0495   else
0496   {
0497     cyl->set_double_param("place_z", north_pipe_place_z + no_overlapp);
0498   }
0499   cyl->set_double_param("radius", 0.);
0500   cyl->set_int_param("lengthviarapidity", 0);
0501   cyl->set_double_param("length", G4PIPE::outer_pipe_precone_length);
0502   cyl->set_string_param("material", "G4_Galactic");
0503   cyl->set_double_param("thickness", G4PIPE::outer_pipe_precone_radius);
0504   cyl->SuperDetector("PIPE");
0505   if (AbsorberActive) cyl->SetActive();
0506   cyl->OverlapCheck(OverlapCheck);
0507   g4Reco->registerSubsystem(cyl);
0508 
0509   /* north outermost pipe (pre-conical part) */
0510   cyl = new PHG4CylinderSubsystem("N_OUTER_PIPE_PRECONE", ilayer++);
0511   if (Enable::PIPE_MISALIGNMENT)
0512   {
0513     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0514     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0515     cyl->set_double_param("place_z", north_pipe_place_z + no_overlapp + G4PIPE::pipe_zshift);
0516   }
0517   else
0518   {
0519     cyl->set_double_param("place_z", north_pipe_place_z + no_overlapp);
0520   }
0521   cyl->set_double_param("radius", G4PIPE::outer_pipe_precone_radius);
0522   cyl->set_int_param("lengthviarapidity", 0);
0523   cyl->set_double_param("length", G4PIPE::outer_pipe_precone_length);
0524   cyl->set_string_param("material", "G4_Al");
0525   cyl->set_double_param("thickness", G4PIPE::outer_pipe_thickness);
0526   cyl->SuperDetector("PIPE");
0527   if (AbsorberActive) cyl->SetActive();
0528   cyl->OverlapCheck(OverlapCheck);
0529   g4Reco->registerSubsystem(cyl);
0530 
0531   PHG4ConeSubsystem* cone = nullptr;
0532 
0533   /* north outermost pipe (conical part) [vacuum] */
0534   north_pipe_place_z += 0.5 * G4PIPE::outer_pipe_precone_length + 0.5 * G4PIPE::outer_pipe_cone_length;
0535   cone = new PHG4ConeSubsystem("VAC_N_OUTER_PIPE_CONE", ilayer++);
0536   cone->SetR1(0., G4PIPE::outer_pipe_precone_radius);
0537   cone->SetR2(0., G4PIPE::outer_pipe_ext_radius);
0538   cone->SetZlength(G4PIPE::outer_pipe_cone_length / 2);
0539   if (Enable::PIPE_MISALIGNMENT)
0540   {
0541     cone->SetPlace(G4PIPE::pipe_xshift, G4PIPE::pipe_yshift, north_pipe_place_z + no_overlapp + G4PIPE::pipe_zshift);
0542   }
0543   else
0544   {
0545     cone->SetPlaceZ(north_pipe_place_z + no_overlapp);
0546   }
0547   cone->SetMaterial("G4_Galactic");
0548   cone->SuperDetector("PIPE");
0549   if (AbsorberActive) cone->SetActive();
0550   cone->OverlapCheck(OverlapCheck);
0551   g4Reco->registerSubsystem(cone);
0552 
0553   /* north outermost pipe (conical part) */
0554   cone = new PHG4ConeSubsystem("N_OUTER_PIPE_CONE", ilayer++);
0555   cone->SetR1(G4PIPE::outer_pipe_precone_radius, G4PIPE::outer_pipe_precone_radius + G4PIPE::outer_pipe_thickness);
0556   cone->SetR2(G4PIPE::outer_pipe_ext_radius, G4PIPE::outer_pipe_ext_radius + G4PIPE::outer_pipe_thickness);
0557   cone->SetZlength(G4PIPE::outer_pipe_cone_length / 2);
0558   if (Enable::PIPE_MISALIGNMENT)
0559   {
0560     cone->SetPlace(G4PIPE::pipe_xshift, G4PIPE::pipe_yshift, north_pipe_place_z + no_overlapp + G4PIPE::pipe_zshift);
0561   }
0562   else
0563   {
0564     cone->SetPlaceZ(north_pipe_place_z + no_overlapp);
0565   }
0566   cone->SetMaterial("G4_Al");
0567   cone->SuperDetector("PIPE");
0568   if (AbsorberActive) cone->SetActive();
0569   cone->OverlapCheck(OverlapCheck);
0570   g4Reco->registerSubsystem(cone);
0571 
0572   /* north outermost pipe (extension) [vacuum] */
0573   north_pipe_place_z += 0.5 * G4PIPE::outer_pipe_cone_length + 0.5 * G4PIPE::outer_pipe_ext_length;
0574   cyl = new PHG4CylinderSubsystem("VAC_N_OUTER_PIPE_EXT", ilayer++);
0575   if (Enable::PIPE_MISALIGNMENT)
0576   {
0577     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0578     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0579     cyl->set_double_param("place_z", north_pipe_place_z + no_overlapp + G4PIPE::pipe_zshift);
0580   }
0581   else
0582   {
0583     cyl->set_double_param("place_z", north_pipe_place_z + no_overlapp);
0584   }
0585   cyl->set_double_param("radius", 0.);
0586   cyl->set_int_param("lengthviarapidity", 0);
0587   cyl->set_double_param("length", G4PIPE::outer_pipe_ext_length);
0588   cyl->set_string_param("material", "G4_Galactic");
0589   cyl->set_double_param("thickness", G4PIPE::outer_pipe_ext_radius);
0590   cyl->SuperDetector("PIPE");
0591   if (AbsorberActive) cyl->SetActive();
0592   cyl->OverlapCheck(OverlapCheck);
0593   g4Reco->registerSubsystem(cyl);
0594 
0595   /* north outermost pipe (extension) */
0596   cyl = new PHG4CylinderSubsystem("N_OUTER_PIPE_EXT", ilayer++);
0597   if (Enable::PIPE_MISALIGNMENT)
0598   {
0599     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0600     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0601     cyl->set_double_param("place_z", north_pipe_place_z + no_overlapp + G4PIPE::pipe_zshift);
0602   }
0603   else
0604   {
0605     cyl->set_double_param("place_z", north_pipe_place_z + no_overlapp);
0606   }
0607   cyl->set_double_param("radius", G4PIPE::outer_pipe_ext_radius);
0608   cyl->set_int_param("lengthviarapidity", 0);
0609   cyl->set_double_param("length", G4PIPE::outer_pipe_ext_length);
0610   cyl->set_string_param("material", "G4_Al");
0611   cyl->set_double_param("thickness", G4PIPE::outer_pipe_thickness);
0612   cyl->SuperDetector("PIPE");
0613   if (AbsorberActive) cyl->SetActive();
0614   cyl->OverlapCheck(OverlapCheck);
0615   g4Reco->registerSubsystem(cyl);
0616 
0617   /* south outermost pipe (pre-conical part) [vacuum] */
0618   south_pipe_place_z -= (0.5 * G4PIPE::al_pipe_south_length + 0.5 * G4PIPE::outer_pipe_precone_length);
0619   cyl = new PHG4CylinderSubsystem("VAC_S_OUTER_PIPE_PRECONE", ilayer++);
0620   if (Enable::PIPE_MISALIGNMENT)
0621   {
0622     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0623     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0624     cyl->set_double_param("place_z", south_pipe_place_z - no_overlapp + G4PIPE::pipe_zshift);
0625   }
0626   else
0627   {
0628     cyl->set_double_param("place_z", south_pipe_place_z - no_overlapp);
0629   }
0630   cyl->set_double_param("radius", 0.);
0631   cyl->set_int_param("lengthviarapidity", 0);
0632   cyl->set_double_param("length", G4PIPE::outer_pipe_precone_length);
0633   cyl->set_string_param("material", "G4_Galactic");
0634   cyl->set_double_param("thickness", G4PIPE::outer_pipe_precone_radius);
0635   cyl->SuperDetector("PIPE");
0636   if (AbsorberActive) cyl->SetActive();
0637   cyl->OverlapCheck(OverlapCheck);
0638   g4Reco->registerSubsystem(cyl);
0639 
0640   /* south outermost pipe (pre-conical part) */
0641   cyl = new PHG4CylinderSubsystem("S_OUTER_PIPE_PRECONE", ilayer++);
0642   if (Enable::PIPE_MISALIGNMENT)
0643   {
0644     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0645     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0646     cyl->set_double_param("place_z", south_pipe_place_z - no_overlapp + G4PIPE::pipe_zshift);
0647   }
0648   else
0649   {
0650     cyl->set_double_param("place_z", south_pipe_place_z - no_overlapp);
0651   }
0652   cyl->set_double_param("radius", G4PIPE::outer_pipe_precone_radius);
0653   cyl->set_int_param("lengthviarapidity", 0);
0654   cyl->set_double_param("length", G4PIPE::outer_pipe_precone_length);
0655   cyl->set_string_param("material", "G4_Al");
0656   cyl->set_double_param("thickness", G4PIPE::outer_pipe_thickness);
0657   cyl->SuperDetector("PIPE");
0658   if (AbsorberActive) cyl->SetActive();
0659   cyl->OverlapCheck(OverlapCheck);
0660   g4Reco->registerSubsystem(cyl);
0661 
0662   /* south outermost pipe (conical part) [vacuum] */
0663   south_pipe_place_z -= (0.5 * G4PIPE::outer_pipe_precone_length + 0.5 * G4PIPE::outer_pipe_cone_length);
0664   cone = new PHG4ConeSubsystem("VAC_S_AL_PIPE_CONE", ilayer++);
0665   cone->SetR1(0., G4PIPE::outer_pipe_ext_radius);
0666   cone->SetR2(0., G4PIPE::outer_pipe_precone_radius);
0667   cone->SetZlength(G4PIPE::outer_pipe_cone_length / 2);
0668   if (Enable::PIPE_MISALIGNMENT)
0669   {
0670     cone->SetPlace(G4PIPE::pipe_xshift, G4PIPE::pipe_yshift, south_pipe_place_z - no_overlapp + G4PIPE::pipe_zshift);
0671   }
0672   else
0673   {
0674     cone->SetPlaceZ(south_pipe_place_z - no_overlapp);
0675   }
0676   cone->SetMaterial("G4_Galactic");
0677   cone->SuperDetector("PIPE");
0678   if (AbsorberActive) cone->SetActive();
0679   cone->OverlapCheck(OverlapCheck);
0680   g4Reco->registerSubsystem(cone);
0681 
0682   /* south outermost pipe (conical part) */
0683   cone = new PHG4ConeSubsystem("S_OUTER_PIPE_CONE", ilayer++);
0684   cone->SetR1(G4PIPE::outer_pipe_ext_radius, G4PIPE::outer_pipe_ext_radius + G4PIPE::outer_pipe_thickness);
0685   cone->SetR2(G4PIPE::outer_pipe_precone_radius, G4PIPE::outer_pipe_precone_radius + G4PIPE::outer_pipe_thickness);
0686   cone->SetZlength(G4PIPE::outer_pipe_cone_length / 2);
0687   if (Enable::PIPE_MISALIGNMENT)
0688   {
0689     cone->SetPlace(G4PIPE::pipe_xshift, G4PIPE::pipe_yshift, south_pipe_place_z - no_overlapp + G4PIPE::pipe_zshift);
0690   }
0691   else
0692   {
0693     cone->SetPlaceZ(south_pipe_place_z - no_overlapp);
0694   }
0695   cone->SetMaterial("G4_Al");
0696   cone->SuperDetector("PIPE");
0697   if (AbsorberActive) cone->SetActive();
0698   cone->OverlapCheck(OverlapCheck);
0699   g4Reco->registerSubsystem(cone);
0700 
0701   /* south outermost pipe (extension) [vacuum] */
0702   south_pipe_place_z -= (0.5 * G4PIPE::outer_pipe_cone_length + 0.5 * G4PIPE::outer_pipe_ext_length);
0703   cyl = new PHG4CylinderSubsystem("VAC_S_OUTER_PIPE_EXT", ilayer++);
0704   if (Enable::PIPE_MISALIGNMENT)
0705   {
0706     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0707     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0708     cyl->set_double_param("place_z", south_pipe_place_z - no_overlapp + G4PIPE::pipe_zshift);
0709   }
0710   else
0711   {
0712     cyl->set_double_param("place_z", south_pipe_place_z - no_overlapp);
0713   }
0714   cyl->set_double_param("radius", 0.);
0715   cyl->set_int_param("lengthviarapidity", 0);
0716   cyl->set_double_param("length", G4PIPE::outer_pipe_ext_length);
0717   cyl->set_string_param("material", "G4_Galactic");
0718   cyl->set_double_param("thickness", G4PIPE::outer_pipe_ext_radius);
0719   cyl->SuperDetector("PIPE");
0720   if (AbsorberActive) cyl->SetActive();
0721   cyl->OverlapCheck(OverlapCheck);
0722   g4Reco->registerSubsystem(cyl);
0723 
0724   /* south outermost pipe (extension) */
0725   cyl = new PHG4CylinderSubsystem("S_OUTER_PIPE_EXT", ilayer++);
0726   if (Enable::PIPE_MISALIGNMENT)
0727   {
0728     cyl->set_double_param("place_x", G4PIPE::pipe_xshift);
0729     cyl->set_double_param("place_y", G4PIPE::pipe_yshift);
0730     cyl->set_double_param("place_z", south_pipe_place_z - no_overlapp + G4PIPE::pipe_zshift);
0731   }
0732   else
0733   {
0734     cyl->set_double_param("place_z", south_pipe_place_z - no_overlapp);
0735   }
0736   cyl->set_double_param("radius", G4PIPE::outer_pipe_ext_radius);
0737   cyl->set_int_param("lengthviarapidity", 0);
0738   cyl->set_double_param("length", G4PIPE::outer_pipe_ext_length);
0739   cyl->set_string_param("material", "G4_Al");
0740   cyl->set_double_param("thickness", G4PIPE::outer_pipe_thickness);
0741   cyl->SuperDetector("PIPE");
0742   if (AbsorberActive) cyl->SetActive();
0743   cyl->OverlapCheck(OverlapCheck);
0744   g4Reco->registerSubsystem(cyl);
0745 
0746   radius = G4PIPE::outer_pipe_ext_radius + G4PIPE::outer_pipe_thickness;
0747 
0748   if (verbosity > 0)
0749   {
0750     cout << "=========================== G4_Pipe.C::Pipe() =============================" << endl;
0751     cout << " PIPE Material Description:" << endl;
0752     cout << "  inner radius = " << G4PIPE::be_pipe_radius << " cm" << endl;
0753     cout << "  thickness = " << G4PIPE::be_pipe_thickness << " cm" << endl;
0754     cout << "  outer radius = " << G4PIPE::be_pipe_radius + G4PIPE::be_pipe_thickness << " cm" << endl;
0755     cout << "  length = " << G4PIPE::be_pipe_length << " cm" << endl;
0756     cout << "===========================================================================" << endl;
0757   }
0758 
0759   radius += no_overlapp;
0760 
0761   return radius;
0762 }
0763 #endif