Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:21:35

0001 #ifndef MACRO_G4SETUPEICDETECTOR_C
0002 #define MACRO_G4SETUPEICDETECTOR_C
0003 
0004 #include <GlobalVariables.C>
0005 
0006 #include <G4_Aerogel.C>
0007 #include <G4_Barrel_EIC.C>
0008 #include <G4_Bbc.C>
0009 #include <G4_BlackHole.C>
0010 #include <G4_CEmc_EIC.C>
0011 #include <G4_DIRC.C>
0012 #include <G4_EEMC.C>
0013 #include <G4_FEMC_EIC.C>
0014 #include <G4_FHCAL.C>
0015 #include <G4_FST_EIC.C>
0016 #include <G4_GEM_EIC.C>
0017 #include <G4_HcalIn_ref.C>
0018 #include <G4_HcalOut_ref.C>
0019 #include <G4_Input.C>
0020 #include <G4_Magnet.C>
0021 #include <G4_Mvtx_EIC.C>
0022 #include <G4_Pipe_EIC.C>
0023 #include <G4_PlugDoor_EIC.C>
0024 #include <G4_RICH.C>
0025 #include <G4_TPC_EIC.C>
0026 #include <G4_Tracking_EIC.C>
0027 #include <G4_User.C>
0028 #include <G4_World.C>
0029 #include <G4_hFarFwdBeamLine_EIC.C>
0030 
0031 #include <g4detectors/PHG4CylinderSubsystem.h>
0032 
0033 #include <g4eval/PHG4DstCompressReco.h>
0034 
0035 #include <g4main/PHG4Reco.h>
0036 #include <g4main/PHG4TruthSubsystem.h>
0037 
0038 #include <phfield/PHFieldConfig.h>
0039 
0040 #include <g4decayer/EDecayType.hh>
0041 
0042 #include <fun4all/Fun4AllDstOutputManager.h>
0043 #include <fun4all/Fun4AllServer.h>
0044 
0045 R__LOAD_LIBRARY(libg4decayer.so)
0046 R__LOAD_LIBRARY(libg4detectors.so)
0047 
0048 void G4Init()
0049 {
0050   // First some check for subsystems which do not go together
0051 
0052   if (Enable::TPC && Enable::FST && !G4FST::SETTING::FST_TPC)
0053   {
0054     cout << "FST setup cannot fit in the TPC" << endl;
0055     gSystem->Exit(1);
0056   }
0057   else if (Enable::MVTX && Enable::BARREL)
0058   {
0059     cout << "MVTX and BARREL cannot be enabled together" << endl;
0060     gSystem->Exit(1);
0061   }
0062   else if (Enable::TPC && Enable::BARREL && !G4BARREL::SETTING::BARRELV6) {
0063     cout << "Barrel setup cannot fit in the TPC" << endl;
0064     gSystem->Exit(1);
0065   }
0066 
0067   if(Enable::FGEM_ORIG && Enable::FST)
0068   {
0069     cout << "FST cannot be enabled with 5 FGEM setup" << endl;
0070     gSystem->Exit(1);
0071   }
0072 
0073   if(Enable::FGEM_ORIG && Enable::FST)
0074   {
0075     cout << "FST cannot be enabled with 5 FGEM setup" << endl;
0076     gSystem->Exit(1);
0077   }
0078 
0079   // load detector/material macros and execute Init() function
0080   if (Enable::PIPE) PipeInit();
0081   if (Enable::HFARFWD_MAGNETS_IP6 || Enable::HFARFWD_MAGNETS_IP8) hFarFwdBeamLineInit();
0082   if (Enable::PLUGDOOR) PlugDoorInit();
0083   if (Enable::EGEM) EGEM_Init();
0084   if (Enable::FGEM || Enable::FGEM_ORIG) FGEM_Init();
0085   if (Enable::FST) FST_Init();
0086   if (Enable::BARREL) BarrelInit();
0087   if (Enable::MVTX) MvtxInit();
0088   if (Enable::TPC) TPCInit();
0089   if (Enable::TRACKING) TrackingInit();
0090   if (Enable::BBC) BbcInit();
0091   if (Enable::CEMC) CEmcInit(72);  // make it 2*2*2*3*3 so we can try other combinations
0092   if (Enable::HCALIN) HCalInnerInit(1);
0093   if (Enable::MAGNET) MagnetInit();
0094   MagnetFieldInit(); // We want the field - even if the magnet volume is disabled
0095   if (Enable::HCALOUT) HCalOuterInit();
0096   if (Enable::FEMC) FEMCInit();
0097   if (Enable::FHCAL) FHCALInit();
0098   if (Enable::EEMC) EEMCInit();
0099   if (Enable::DIRC) DIRCInit();
0100   if (Enable::RICH) RICHInit();
0101   if (Enable::AEROGEL) AerogelInit();
0102   if (Enable::USER) UserInit();
0103   if (Enable::BLACKHOLE) BlackHoleInit();
0104 }
0105 
0106 int G4Setup()
0107 {
0108   //---------------
0109   // Fun4All server
0110   //---------------
0111 
0112   Fun4AllServer *se = Fun4AllServer::instance();
0113 
0114   PHG4Reco *g4Reco = new PHG4Reco();
0115 
0116   WorldInit(g4Reco);
0117 
0118   g4Reco->set_rapidity_coverage(1.1);  // according to drawings
0119                                        // uncomment to set QGSP_BERT_HP physics list for productions
0120                                        // (default is QGSP_BERT for speed)
0121   //  g4Reco->SetPhysicsList("QGSP_BERT_HP");
0122 
0123   if (G4P6DECAYER::decayType != EDecayType::kAll)
0124   {
0125     g4Reco->set_force_decay(G4P6DECAYER::decayType);
0126   }
0127 
0128   double fieldstrength;
0129   istringstream stringline(G4MAGNET::magfield);
0130   stringline >> fieldstrength;
0131   if (stringline.fail())
0132   {  // conversion to double fails -> we have a string
0133 
0134     if (G4MAGNET::magfield.find("sPHENIX.root") != string::npos)
0135     {
0136       g4Reco->set_field_map(G4MAGNET::magfield, PHFieldConfig::Field3DCartesian);
0137     }
0138     else
0139     {
0140       g4Reco->set_field_map(G4MAGNET::magfield, PHFieldConfig::kField2D);
0141     }
0142   }
0143   else
0144   {
0145     g4Reco->set_field(fieldstrength);  // use const soleniodal field
0146   }
0147   g4Reco->set_field_rescale(G4MAGNET::magfield_rescale);
0148 
0149 // the radius is an older protection against overlaps, it is not
0150 // clear how well this works nowadays but it doesn't hurt either
0151   double radius = 0.;
0152 
0153   if (Enable::PIPE) radius = Pipe(g4Reco, radius);
0154   if (Enable::HFARFWD_MAGNETS_IP6 || Enable::HFARFWD_MAGNETS_IP8) hFarFwdDefineMagnets(g4Reco);
0155   if (Enable::HFARFWD_VIRTUAL_DETECTORS_IP6) hFarFwdDefineDetectorsIP6(g4Reco);
0156   if (Enable::HFARFWD_VIRTUAL_DETECTORS_IP8) hFarFwdDefineDetectorsIP8(g4Reco);
0157   if (Enable::EGEM) EGEMSetup(g4Reco);
0158   if (Enable::FGEM || Enable::FGEM_ORIG) FGEMSetup(g4Reco);
0159   if (Enable::FST) FSTSetup(g4Reco);
0160   if (Enable::BARREL) Barrel(g4Reco, radius);
0161   if (Enable::MVTX) radius = Mvtx(g4Reco, radius);
0162   if (Enable::TPC) radius = TPC(g4Reco, radius);
0163   if (Enable::BBC) Bbc(g4Reco);
0164   if (Enable::CEMC) radius = CEmc(g4Reco, radius);
0165   if (Enable::HCALIN) radius = HCalInner(g4Reco, radius, 4);
0166   if (Enable::MAGNET) radius = Magnet(g4Reco, radius);
0167   if (Enable::HCALOUT) radius = HCalOuter(g4Reco, radius, 4);
0168   if (Enable::FEMC) FEMCSetup(g4Reco);
0169   if (Enable::FHCAL) FHCALSetup(g4Reco);
0170   if (Enable::EEMC) EEMCSetup(g4Reco);
0171 
0172   //----------------------------------------
0173   // PID
0174 
0175   if (Enable::DIRC) DIRCSetup(g4Reco);
0176   if (Enable::RICH) RICHSetup(g4Reco);
0177   if (Enable::AEROGEL) AerogelSetup(g4Reco);
0178 
0179   //----------------------------------------
0180   // sPHENIX forward flux return door
0181   if (Enable::PLUGDOOR) PlugDoor(g4Reco);
0182 
0183   if (Enable::USER) UserDetector(g4Reco);
0184   
0185   //----------------------------------------
0186   // BLACKHOLE if enabled, needs info from all previous sub detectors for dimensions
0187   if (Enable::BLACKHOLE) BlackHole(g4Reco, radius);
0188 
0189   PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
0190   g4Reco->registerSubsystem(truth);
0191   // finally adjust the world size in case the default is too small
0192   WorldSize(g4Reco, radius);
0193 
0194   se->registerSubsystem(g4Reco);
0195   return 0;
0196 }
0197 
0198 void ShowerCompress()
0199 {
0200   Fun4AllServer *se = Fun4AllServer::instance();
0201 
0202   PHG4DstCompressReco *compress = new PHG4DstCompressReco("PHG4DstCompressReco");
0203   compress->AddHitContainer("G4HIT_PIPE");
0204   compress->AddHitContainer("G4HIT_ZDC");
0205   compress->AddHitContainer("G4HIT_RomanPots");
0206   compress->AddHitContainer("G4HIT_B0detector");
0207   compress->AddHitContainer("G4HIT_FIELDCAGE");
0208   compress->AddHitContainer("G4HIT_CEMC_ELECTRONICS");
0209   compress->AddHitContainer("G4HIT_CEMC");
0210   compress->AddHitContainer("G4HIT_ABSORBER_CEMC");
0211   compress->AddHitContainer("G4HIT_CEMC_SPT");
0212   compress->AddHitContainer("G4HIT_ABSORBER_HCALIN");
0213   compress->AddHitContainer("G4HIT_HCALIN");
0214   compress->AddHitContainer("G4HIT_HCALIN_SPT");
0215   compress->AddHitContainer("G4HIT_MAGNET");
0216   compress->AddHitContainer("G4HIT_ABSORBER_HCALOUT");
0217   compress->AddHitContainer("G4HIT_HCALOUT");
0218   compress->AddHitContainer("G4HIT_BH_1");
0219   compress->AddHitContainer("G4HIT_BH_FORWARD_PLUS");
0220   compress->AddHitContainer("G4HIT_BH_FORWARD_NEG");
0221   compress->AddCellContainer("G4CELL_CEMC");
0222   compress->AddCellContainer("G4CELL_HCALIN");
0223   compress->AddCellContainer("G4CELL_HCALOUT");
0224   compress->AddTowerContainer("TOWER_SIM_CEMC");
0225   compress->AddTowerContainer("TOWER_RAW_CEMC");
0226   compress->AddTowerContainer("TOWER_CALIB_CEMC");
0227   compress->AddTowerContainer("TOWER_SIM_HCALIN");
0228   compress->AddTowerContainer("TOWER_RAW_HCALIN");
0229   compress->AddTowerContainer("TOWER_CALIB_HCALIN");
0230   compress->AddTowerContainer("TOWER_SIM_HCALOUT");
0231   compress->AddTowerContainer("TOWER_RAW_HCALOUT");
0232   compress->AddTowerContainer("TOWER_CALIB_HCALOUT");
0233 
0234   compress->AddHitContainer("G4HIT_FEMC");
0235   compress->AddHitContainer("G4HIT_ABSORBER_FEMC");
0236   compress->AddHitContainer("G4HIT_FHCAL");
0237   compress->AddHitContainer("G4HIT_ABSORBER_FHCAL");
0238   compress->AddCellContainer("G4CELL_FEMC");
0239   compress->AddCellContainer("G4CELL_FHCAL");
0240   compress->AddTowerContainer("TOWER_SIM_FEMC");
0241   compress->AddTowerContainer("TOWER_RAW_FEMC");
0242   compress->AddTowerContainer("TOWER_CALIB_FEMC");
0243   compress->AddTowerContainer("TOWER_SIM_FHCAL");
0244   compress->AddTowerContainer("TOWER_RAW_FHCAL");
0245   compress->AddTowerContainer("TOWER_CALIB_FHCAL");
0246 
0247   compress->AddHitContainer("G4HIT_EEMC");
0248   compress->AddHitContainer("G4HIT_ABSORBER_EEMC");
0249   compress->AddCellContainer("G4CELL_EEMC");
0250   compress->AddTowerContainer("TOWER_SIM_EEMC");
0251   compress->AddTowerContainer("TOWER_RAW_EEMC");
0252   compress->AddTowerContainer("TOWER_CALIB_EEMC");
0253 
0254   se->registerSubsystem(compress);
0255 
0256   return;
0257 }
0258 
0259 void DstCompress(Fun4AllDstOutputManager *out)
0260 {
0261   if (out)
0262   {
0263     out->StripNode("G4HIT_PIPE");
0264     out->StripNode("G4HIT_ZDC");
0265     out->StripNode("G4HIT_RomanPots");
0266     out->StripNode("G4HIT_B0detectors");
0267     out->StripNode("G4HIT_SVTXSUPPORT");
0268     out->StripNode("G4HIT_CEMC_ELECTRONICS");
0269     out->StripNode("G4HIT_CEMC");
0270     out->StripNode("G4HIT_ABSORBER_CEMC");
0271     out->StripNode("G4HIT_CEMC_SPT");
0272     out->StripNode("G4HIT_ABSORBER_HCALIN");
0273     out->StripNode("G4HIT_HCALIN");
0274     out->StripNode("G4HIT_HCALIN_SPT");
0275     out->StripNode("G4HIT_MAGNET");
0276     out->StripNode("G4HIT_ABSORBER_HCALOUT");
0277     out->StripNode("G4HIT_HCALOUT");
0278     out->StripNode("G4HIT_BH_1");
0279     out->StripNode("G4HIT_BH_FORWARD_PLUS");
0280     out->StripNode("G4HIT_BH_FORWARD_NEG");
0281     out->StripNode("G4CELL_CEMC");
0282     out->StripNode("G4CELL_HCALIN");
0283     out->StripNode("G4CELL_HCALOUT");
0284 
0285     out->StripNode("G4HIT_FEMC");
0286     out->StripNode("G4HIT_ABSORBER_FEMC");
0287     out->StripNode("G4HIT_FHCAL");
0288     out->StripNode("G4HIT_ABSORBER_FHCAL");
0289     out->StripNode("G4CELL_FEMC");
0290     out->StripNode("G4CELL_FHCAL");
0291 
0292     out->StripNode("G4HIT_EEMC");
0293     out->StripNode("G4HIT_ABSORBER_EEMC");
0294     out->StripNode("G4CELL_EEMC");
0295   }
0296 }
0297 #endif