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