File indexing completed on 2025-08-05 08:19:51
0001 #ifndef MACRO_G4SETUPSPHENIX_C
0002 #define MACRO_G4SETUPSPHENIX_C
0003
0004 #include <GlobalVariables.C>
0005
0006 #include <G4_BeamLine.C>
0007 #include <G4_BlackHole.C>
0008 #include <G4_CEmc_Albedo.C>
0009 #include <G4_CEmc_Spacal.C>
0010 #include <G4_EPD.C>
0011 #include <G4_HcalIn_ref.C>
0012 #include <G4_HcalOut_ref.C>
0013 #include <G4_Magnet.C>
0014 #include <G4_Mbd.C>
0015 #include <G4_PSTOF.C>
0016 #include <G4_Pipe.C>
0017 #include <G4_PlugDoor.C>
0018 #include <G4_TrkrSimulation.C>
0019 #include <G4_User.C>
0020 #include <G4_World.C>
0021 #include <G4_ZDC.C>
0022
0023 #include <g4detectors/PHG4CylinderSubsystem.h>
0024
0025 #include <g4eval/PHG4DstCompressReco.h>
0026
0027 #include <g4main/PHG4Reco.h>
0028 #include <g4main/PHG4TruthSubsystem.h>
0029
0030 #include <phfield/PHFieldConfig.h>
0031
0032 #include <g4decayer/EDecayType.hh>
0033
0034 #include <fun4all/Fun4AllDstOutputManager.h>
0035 #include <fun4all/Fun4AllServer.h>
0036
0037 #include <sstream>
0038
0039 R__LOAD_LIBRARY(libg4decayer.so)
0040 R__LOAD_LIBRARY(libg4detectors.so)
0041
0042 void G4Init()
0043 {
0044
0045 if (Enable::CEMC && Enable::CEMCALBEDO)
0046 {
0047 std::cout << "Enable::CEMCALBEDO and Enable::CEMC cannot be set simultanously" << std::endl;
0048 gSystem->Exit(1);
0049 }
0050
0051
0052 if (Enable::PIPE) PipeInit();
0053 if (Enable::MVTX) MvtxInit();
0054 if (Enable::INTT) InttInit();
0055 if (Enable::TPC) TPCInit();
0056 if (Enable::MICROMEGAS) MicromegasInit();
0057 if (Enable::MBD) MbdInit();
0058 if (Enable::CEMCALBEDO) CEmcAlbedoInit();
0059 if (Enable::CEMC) CEmcInit();
0060 if (Enable::HCALIN) HCalInnerInit();
0061 if (Enable::MAGNET) MagnetInit();
0062 MagnetFieldInit();
0063 if (Enable::HCALOUT) HCalOuterInit();
0064 if (Enable::PLUGDOOR) PlugDoorInit();
0065 if (Enable::EPD) EPDInit();
0066 if (Enable::BEAMLINE)
0067 {
0068 BeamLineInit();
0069 if (Enable::ZDC)
0070 {
0071 ZDCInit();
0072 }
0073 }
0074 if (Enable::USER) UserInit();
0075 if (Enable::BLACKHOLE) BlackHoleInit();
0076 }
0077
0078 int G4Setup()
0079 {
0080
0081
0082
0083
0084 Fun4AllServer *se = Fun4AllServer::instance();
0085
0086 PHG4Reco *g4Reco = new PHG4Reco();
0087 g4Reco->set_rapidity_coverage(1.1);
0088 WorldInit(g4Reco);
0089
0090 if (G4P6DECAYER::decayType != EDecayType::kAll)
0091 {
0092 g4Reco->set_force_decay(G4P6DECAYER::decayType);
0093 }
0094
0095 g4Reco->CustomizeEvtGenDecay(EVTGENDECAYER::DecayFile);
0096
0097 double fieldstrength;
0098 std::istringstream stringline(G4MAGNET::magfield);
0099 stringline >> fieldstrength;
0100 if (stringline.fail())
0101 {
0102
0103 if (G4MAGNET::magfield.find("sphenix3dbigmapxyz") != std::string::npos ||
0104 G4MAGNET::magfield.find(".root") == std::string::npos)
0105 {
0106 g4Reco->set_field_map(G4MAGNET::magfield, PHFieldConfig::Field3DCartesian);
0107 }
0108 else
0109 {
0110 g4Reco->set_field_map(G4MAGNET::magfield, PHFieldConfig::kField2D);
0111 }
0112 }
0113 else
0114 {
0115 g4Reco->set_field(fieldstrength);
0116 G4MAGNET::magfield_tracking = G4MAGNET::magfield;
0117 }
0118 g4Reco->set_field_rescale(G4MAGNET::magfield_rescale);
0119
0120
0121
0122 double radius = 0.;
0123
0124 if (Enable::PIPE) radius = Pipe(g4Reco, radius);
0125 if (Enable::MVTX) radius = Mvtx(g4Reco, radius);
0126 if (Enable::INTT) radius = Intt(g4Reco, radius);
0127 if (Enable::TPC) radius = TPC(g4Reco, radius);
0128 if (Enable::MICROMEGAS) Micromegas(g4Reco);
0129 if (Enable::MBD) Mbd(g4Reco);
0130 if (Enable::CEMCALBEDO) CEmcAlbedo(g4Reco);
0131 if (Enable::CEMC) radius = CEmc(g4Reco, radius, 8);
0132 if (Enable::HCALIN) radius = HCalInner(g4Reco, radius, 4);
0133 if (Enable::MAGNET) radius = Magnet(g4Reco, radius);
0134 if (Enable::HCALOUT) radius = HCalOuter(g4Reco, radius, 4);
0135 if (Enable::PLUGDOOR) PlugDoor(g4Reco);
0136 if (Enable::EPD) EPD(g4Reco);
0137 if (Enable::BEAMLINE)
0138 {
0139 BeamLineDefineMagnets(g4Reco);
0140 BeamLineDefineBeamPipe(g4Reco);
0141 if (Enable::ZDC)
0142 {
0143 ZDCSetup(g4Reco);
0144 }
0145 }
0146 if (Enable::USER) UserDetector(g4Reco);
0147
0148
0149
0150
0151 if (Enable::BLACKHOLE) BlackHole(g4Reco, radius);
0152
0153 PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
0154 g4Reco->registerSubsystem(truth);
0155
0156
0157 WorldSize(g4Reco, radius);
0158
0159 se->registerSubsystem(g4Reco);
0160 return 0;
0161 }
0162
0163 void ShowerCompress(int verbosity = 0)
0164 {
0165 Fun4AllServer *se = Fun4AllServer::instance();
0166
0167 PHG4DstCompressReco *compress = new PHG4DstCompressReco("PHG4DstCompressReco");
0168 compress->AddHitContainer("G4HIT_PIPE");
0169 compress->AddHitContainer("G4HIT_SVTXSUPPORT");
0170 compress->AddHitContainer("G4HIT_CEMC_ELECTRONICS");
0171 compress->AddHitContainer("G4HIT_CEMC");
0172 compress->AddHitContainer("G4HIT_ABSORBER_CEMC");
0173 compress->AddHitContainer("G4HIT_CEMC_SPT");
0174 compress->AddHitContainer("G4HIT_ABSORBER_HCALIN");
0175 compress->AddHitContainer("G4HIT_HCALIN");
0176 compress->AddHitContainer("G4HIT_HCALIN_SPT");
0177 compress->AddHitContainer("G4HIT_MAGNET");
0178 compress->AddHitContainer("G4HIT_ABSORBER_HCALOUT");
0179 compress->AddHitContainer("G4HIT_HCALOUT");
0180 compress->AddHitContainer("G4HIT_BH_1");
0181 compress->AddHitContainer("G4HIT_BH_FORWARD_PLUS");
0182 compress->AddHitContainer("G4HIT_BH_FORWARD_NEG");
0183 compress->AddHitContainer("G4HIT_BBC");
0184 compress->AddCellContainer("G4CELL_CEMC");
0185 compress->AddCellContainer("G4CELL_HCALIN");
0186 compress->AddCellContainer("G4CELL_HCALOUT");
0187 compress->AddTowerContainer("TOWER_SIM_CEMC");
0188 compress->AddTowerContainer("TOWER_RAW_CEMC");
0189 compress->AddTowerContainer("TOWER_CALIB_CEMC");
0190 compress->AddTowerContainer("TOWER_SIM_HCALIN");
0191 compress->AddTowerContainer("TOWER_RAW_HCALIN");
0192 compress->AddTowerContainer("TOWER_CALIB_HCALIN");
0193 compress->AddTowerContainer("TOWER_SIM_HCALOUT");
0194 compress->AddTowerContainer("TOWER_RAW_HCALOUT");
0195 compress->AddTowerContainer("TOWER_CALIB_HCALOUT");
0196 se->registerSubsystem(compress);
0197
0198 return;
0199 }
0200
0201 void DstCompress(Fun4AllDstOutputManager *out)
0202 {
0203 if (out)
0204 {
0205 out->StripNode("G4HIT_PIPE");
0206 out->StripNode("G4HIT_SVTXSUPPORT");
0207 out->StripNode("G4HIT_CEMC_ELECTRONICS");
0208 out->StripNode("G4HIT_CEMC");
0209 out->StripNode("G4HIT_ABSORBER_CEMC");
0210 out->StripNode("G4HIT_CEMC_SPT");
0211 out->StripNode("G4HIT_ABSORBER_HCALIN");
0212 out->StripNode("G4HIT_HCALIN");
0213 out->StripNode("G4HIT_HCALIN_SPT");
0214 out->StripNode("G4HIT_MAGNET");
0215 out->StripNode("G4HIT_ABSORBER_HCALOUT");
0216 out->StripNode("G4HIT_HCALOUT");
0217 out->StripNode("G4HIT_BH_1");
0218 out->StripNode("G4HIT_BH_FORWARD_PLUS");
0219 out->StripNode("G4HIT_BH_FORWARD_NEG");
0220 out->StripNode("G4HIT_BBC");
0221 out->StripNode("G4CELL_CEMC");
0222 out->StripNode("G4CELL_HCALIN");
0223 out->StripNode("G4CELL_HCALOUT");
0224 }
0225 }
0226 #endif