Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:11:58

0001 
0002 double no_overlapp = 0.0001; // added to radii to avoid overlapping volumes
0003 bool overlapcheck = false; // set to true if you want to check for overlaps
0004 
0005 void G4Init(bool do_magnet = true,
0006             bool do_pipe = true,
0007             bool do_ExtendedIR = true
0008             ) {
0009 
0010   // load detector/material macros and execute Init() function
0011   if (do_pipe)
0012     {
0013       gROOT->LoadMacro("G4_Pipe.C");
0014       PipeInit();
0015     }
0016 
0017   if (do_magnet)
0018     {
0019       gROOT->LoadMacro("G4_Magnet.C");
0020       MagnetInit();
0021     }
0022 
0023   if (do_ExtendedIR)
0024     {
0025       gROOT->LoadMacro("G4_IR_EIC.C");
0026       IRInit();
0027     }
0028 
0029 }
0030 
0031 
0032 int G4Setup(const int absorberactive = 0,
0033             const string &field ="1.5",
0034             const EDecayType decayType = TPythia6Decayer::kAll,
0035             const bool do_magnet = true,
0036             const bool do_pipe = true,
0037             const bool do_ExtendedIR = true,
0038             const float magfield_rescale = 1.0) {
0039 
0040   //---------------
0041   // Load libraries
0042   //---------------
0043 
0044   gSystem->Load("libg4detectors.so");
0045   gSystem->Load("libg4testbench.so");
0046 
0047   //---------------
0048   // Fun4All server
0049   //---------------
0050 
0051   Fun4AllServer *se = Fun4AllServer::instance();
0052 
0053   PHG4Reco* g4Reco = new PHG4Reco();
0054   g4Reco->set_rapidity_coverage(1.1); // according to drawings
0055 
0056   /* Set World Volume material to G4Galactic for beam line studies
0057    * (beam would be inside vacuum tubes) */
0058   g4Reco->SetWorldMaterial("G4_Galactic");
0059 
0060   if (decayType != TPythia6Decayer::kAll) {
0061     g4Reco->set_force_decay(decayType);
0062   }
0063 
0064   double fieldstrength;
0065   istringstream stringline(field);
0066   stringline >> fieldstrength;
0067   if (stringline.fail()) { // conversion to double fails -> we have a string
0068 
0069     if (field.find("sPHENIX.root") != string::npos) {
0070       g4Reco->set_field_map(field, 1);
0071     } else {
0072       g4Reco->set_field_map(field, 2);
0073     }
0074   } else {
0075     g4Reco->set_field(fieldstrength); // use const soleniodal field
0076   }
0077   g4Reco->set_field_rescale(magfield_rescale);
0078 
0079   double radius = 0.;
0080 
0081   //----------------------------------------
0082   // PIPE
0083   if (do_pipe) radius = Pipe(g4Reco, radius, absorberactive);
0084 
0085   //----------------------------------------
0086   // MAGNET
0087 
0088   if (do_magnet) radius = Magnet(g4Reco, radius, 0, absorberactive);
0089 
0090   //----------------------------------------
0091   // Extended IR
0092   if ( do_ExtendedIR )
0093     IRSetup(g4Reco);
0094 
0095 
0096   // discs to track very forward protons
0097   PHG4CylinderSubsystem *fwd_disc;
0098   for ( unsigned i = 0; i < 900; i++ )
0099     {
0100       fwd_disc = new PHG4CylinderSubsystem("FWDDISC", i);
0101       fwd_disc->set_int_param("lengthviarapidity",0);
0102       fwd_disc->set_double_param("length",1);
0103       fwd_disc->set_double_param("radius",0);
0104       fwd_disc->set_double_param("thickness",200.0);
0105       fwd_disc->set_double_param("place_z",450+i*10.0); // cm
0106       fwd_disc->set_string_param("material","G4_Galactic");
0107       fwd_disc->SetActive(true);
0108       fwd_disc->SuperDetector("FWDDISC");
0109       fwd_disc->OverlapCheck(overlapcheck);
0110       g4Reco->registerSubsystem(fwd_disc);
0111     }
0112 
0113   /* Add truth system */
0114   PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
0115   g4Reco->registerSubsystem(truth);
0116 
0117   /* add reco to server */
0118   se->registerSubsystem( g4Reco );
0119 }