File indexing completed on 2025-08-05 08:18:18
0001 #include "PHG4TpcSubsystem.h"
0002 #include "PHG4TpcDetector.h"
0003 #include "PHG4TpcDisplayAction.h"
0004 #include "PHG4TpcSteppingAction.h"
0005
0006 #include <g4detectors/PHG4DetectorSubsystem.h> // for PHG4DetectorSubsystem
0007
0008 #include <phparameter/PHParameters.h>
0009
0010 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
0011 #include <g4main/PHG4HitContainer.h>
0012 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
0013
0014 #include <phool/PHCompositeNode.h>
0015 #include <phool/PHIODataNode.h> // for PHIODataNode
0016 #include <phool/PHNode.h> // for PHNode
0017 #include <phool/PHNodeIterator.h> // for PHNodeIterator
0018 #include <phool/PHObject.h> // for PHObject
0019 #include <phool/getClass.h>
0020
0021 #include <iostream> // for operator<<, basic_ost...
0022 #include <set>
0023
0024 class PHG4Detector;
0025
0026
0027 PHG4TpcSubsystem::PHG4TpcSubsystem(const std::string &name, const int lyr)
0028 : PHG4DetectorSubsystem(name, lyr)
0029 {
0030 InitializeParameters();
0031 }
0032
0033
0034 PHG4TpcSubsystem::~PHG4TpcSubsystem()
0035 {
0036 delete m_DisplayAction;
0037 }
0038
0039
0040 int PHG4TpcSubsystem::InitRunSubsystem(PHCompositeNode *topNode)
0041 {
0042 PHNodeIterator iter(topNode);
0043 PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
0044
0045
0046 m_DisplayAction = new PHG4TpcDisplayAction(Name());
0047
0048 m_Detector = new PHG4TpcDetector(this, topNode, GetParams(), Name());
0049 m_Detector->SuperDetector(SuperDetector());
0050 m_Detector->OverlapCheck(CheckOverlap());
0051 std::set<std::string> nodes;
0052 if (GetParams()->get_int_param("active"))
0053 {
0054 PHNodeIterator dstIter(dstNode);
0055 PHCompositeNode *DetNode = dstNode;
0056 if (SuperDetector() != "NONE" && !SuperDetector().empty())
0057 {
0058 PHNodeIterator iter_dst(dstNode);
0059 DetNode = dynamic_cast<PHCompositeNode *>(iter_dst.findFirst("PHCompositeNode", SuperDetector()));
0060 if (!DetNode)
0061 {
0062 DetNode = new PHCompositeNode(SuperDetector());
0063 dstNode->addNode(DetNode);
0064 }
0065 }
0066 std::string detector_suffix = SuperDetector();
0067 if (detector_suffix == "NONE" || detector_suffix.empty())
0068 {
0069 detector_suffix = Name();
0070 }
0071 m_HitNodeName = "G4HIT_" + detector_suffix;
0072 nodes.insert(m_HitNodeName);
0073 m_AbsorberNodeName = "G4HIT_ABSORBER_" + detector_suffix;
0074 if (GetParams()->get_int_param("absorberactive"))
0075 {
0076 nodes.insert(m_AbsorberNodeName);
0077 }
0078 for (const auto &nodename : nodes)
0079 {
0080 PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
0081 if (!g4_hits)
0082 {
0083 g4_hits = new PHG4HitContainer(nodename);
0084 DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, nodename, "PHObject"));
0085 }
0086 }
0087
0088
0089 m_SteppingAction = new PHG4TpcSteppingAction(m_Detector, GetParams());
0090 m_SteppingAction->SetHitNodeName("G4HIT", m_HitNodeName);
0091 m_SteppingAction->SetHitNodeName("G4HIT_ABSORBER", m_AbsorberNodeName);
0092 }
0093 else
0094 {
0095
0096 if (GetParams()->get_int_param("blackhole"))
0097 {
0098 m_SteppingAction = new PHG4TpcSteppingAction(m_Detector, GetParams());
0099 }
0100 }
0101 return 0;
0102 }
0103
0104
0105 int PHG4TpcSubsystem::process_event(PHCompositeNode *topNode)
0106 {
0107
0108
0109 if (m_SteppingAction)
0110 {
0111 m_SteppingAction->SetInterfacePointers(topNode);
0112 }
0113 return 0;
0114 }
0115
0116 void PHG4TpcSubsystem::Print(const std::string &what) const
0117 {
0118 std::cout << Name() << " Parameters: " << std::endl;
0119 GetParams()->Print();
0120 if (m_Detector)
0121 {
0122 m_Detector->Print(what);
0123 }
0124 if (m_SteppingAction)
0125 {
0126 m_SteppingAction->Print(what);
0127 }
0128
0129 return;
0130 }
0131
0132
0133 PHG4Detector *PHG4TpcSubsystem::GetDetector() const
0134 {
0135 return m_Detector;
0136 }
0137
0138 void PHG4TpcSubsystem::SetDefaultParameters()
0139 {
0140 set_default_double_param("gas_inner_radius", 21.6);
0141 set_default_double_param("gas_outer_radius", 76.4);
0142 set_default_double_param("place_x", 0.);
0143 set_default_double_param("place_y", 0.);
0144 set_default_double_param("place_z", 0.);
0145 set_default_double_param("rot_x", 0.);
0146 set_default_double_param("rot_y", 0.);
0147 set_default_double_param("rot_z", 0.);
0148 set_default_double_param("tpc_length", 211.);
0149
0150 set_default_double_param("steplimits", 1);
0151
0152
0153
0154
0155
0156
0157 set_default_string_param("cage_layer_1_material", "G4_Cu");
0158 set_default_double_param("cage_layer_1_thickness", 0.00347 / 2.);
0159
0160 set_default_string_param("cage_layer_2_material", "FR4");
0161 set_default_double_param("cage_layer_2_thickness", 0.025);
0162
0163 set_default_string_param("cage_layer_3_material", "NOMEX");
0164 set_default_double_param("cage_layer_3_thickness", 0.5 * 2.54);
0165
0166 set_default_string_param("cage_layer_4_material", "G4_Cu");
0167 set_default_double_param("cage_layer_4_thickness", 0.00347 / 2.);
0168
0169 set_default_string_param("cage_layer_5_material", "FR4");
0170 set_default_double_param("cage_layer_5_thickness", 0.025);
0171
0172 set_default_string_param("cage_layer_6_material", "G4_KAPTON");
0173 set_default_double_param("cage_layer_6_thickness", 0.2286);
0174
0175 set_default_string_param("cage_layer_7_material", "G4_Cu");
0176 set_default_double_param("cage_layer_7_thickness", 0.00347 / 2.);
0177
0178 set_default_string_param("cage_layer_8_material", "G4_KAPTON");
0179 set_default_double_param("cage_layer_8_thickness", 0.05);
0180
0181 set_default_string_param("cage_layer_9_material", "G4_Cu");
0182 set_default_double_param("cage_layer_9_thickness", 0.00347 / 2.);
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192 set_default_string_param("window_core_material", "ROHACELL_FOAM_51");
0193 set_default_double_param("window_thickness", 0.56);
0194
0195
0196 set_default_string_param("window_surface1_material", "G4_Cu");
0197 set_default_double_param("window_surface1_thickness", 8.9e-4);
0198
0199 set_default_string_param("window_surface2_material", "FR4");
0200 set_default_double_param("window_surface2_thickness", 0.0127);
0201
0202
0203 set_default_double_param("drift_velocity", 0.008);
0204
0205 set_default_int_param("ntpc_layers_inner", 16);
0206 set_default_int_param("ntpc_layers_mid", 16);
0207 set_default_int_param("ntpc_layers_outer", 16);
0208 set_default_int_param("tpc_minlayer_inner", 7);
0209
0210 set_default_double_param("tpc_minradius_inner", 31.105);
0211 set_default_double_param("tpc_minradius_mid", 41.153);
0212 set_default_double_param("tpc_minradius_outer", 58.367);
0213
0214 set_default_double_param("tpc_maxradius_inner", 40.249);
0215 set_default_double_param("tpc_maxradius_mid", 57.475);
0216 set_default_double_param("tpc_maxradius_outer", 75.911);
0217
0218 set_default_double_param("maxdriftlength", 105.5);
0219 set_default_double_param("extended_readout_time", 0.0);
0220 set_default_double_param("tpc_adc_clock", 53.326184);
0221
0222 set_default_double_param("tpc_sector_phi_inner", 0.5024);
0223 set_default_double_param("tpc_sector_phi_mid", 0.5087);
0224 set_default_double_param("tpc_sector_phi_outer", 0.5097);
0225
0226 set_default_int_param("ntpc_phibins_inner", 1128);
0227 set_default_int_param("ntpc_phibins_mid", 1536);
0228 set_default_int_param("ntpc_phibins_outer", 2304);
0229
0230 set_default_double_param("TPC_gas_temperature", 15.0);
0231 set_default_double_param("TPC_gas_pressure", 1.0);
0232 set_default_double_param("Ne_frac", 0.00);
0233 set_default_double_param("Ar_frac", 0.75);
0234 set_default_double_param("CF4_frac", 0.20);
0235 set_default_double_param("N2_frac", 0.00);
0236 set_default_double_param("isobutane_frac", 0.05);
0237 }