Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:20:45

0001 #include "PHG4Prototype3InnerHcalSubsystem.h"
0002 #include "PHG4Prototype3InnerHcalDetector.h"
0003 #include "PHG4Prototype3InnerHcalSteppingAction.h"
0004 #include "PHG4PrototypeHcalDefs.h"
0005 
0006 #include <phparameter/PHParameters.h>
0007 
0008 #include <phparameter/PHParameters.h>
0009 
0010 #include <g4main/PHG4HitContainer.h>
0011 #include <g4main/PHG4SteppingAction.h>  // for PHG4SteppingAction
0012 
0013 #include <phool/PHCompositeNode.h>
0014 #include <phool/PHIODataNode.h>    // for PHIODataNode
0015 #include <phool/PHNode.h>          // for PHNode
0016 #include <phool/PHNodeIterator.h>  // for PHNodeIterator
0017 #include <phool/PHObject.h>        // for PHObject
0018 #include <phool/getClass.h>
0019 
0020 #include <boost/foreach.hpp>
0021 
0022 #include <cmath>     // for NAN
0023 #include <iostream>  // for operator<<, basic...
0024 #include <set>
0025 #include <sstream>
0026 
0027 class PHG4Detector;
0028 
0029 using namespace std;
0030 
0031 //_______________________________________________________________________
0032 PHG4Prototype3InnerHcalSubsystem::PHG4Prototype3InnerHcalSubsystem(const std::string &name, const int lyr)
0033   : PHG4DetectorSubsystem(name, lyr)
0034   , m_Detector(nullptr)
0035   , m_SteppingAction(nullptr)
0036 {
0037   InitializeParameters();
0038 }
0039 
0040 //_______________________________________________________________________
0041 int PHG4Prototype3InnerHcalSubsystem::InitRunSubsystem(PHCompositeNode *topNode)
0042 {
0043   PHNodeIterator iter(topNode);
0044   PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
0045 
0046   // create detector
0047   m_Detector = new PHG4Prototype3InnerHcalDetector(this, topNode, GetParams(), Name());
0048   m_Detector->SuperDetector(SuperDetector());
0049   m_Detector->OverlapCheck(CheckOverlap());
0050   set<string> nodes;
0051   if (GetParams()->get_int_param("active") || GetParams()->get_int_param("absorberactive"))
0052   {
0053     PHNodeIterator dstiter(dstNode);
0054     PHCompositeNode *DetNode = dynamic_cast<PHCompositeNode *>(dstiter.findFirst("PHCompositeNode", SuperDetector()));
0055     if (!DetNode)
0056     {
0057       DetNode = new PHCompositeNode(SuperDetector());
0058       dstNode->addNode(DetNode);
0059     }
0060 
0061     ostringstream nodename;
0062     if (GetParams()->get_int_param("active"))
0063     {
0064       if (SuperDetector() != "NONE")
0065       {
0066         nodename << "G4HIT_" << SuperDetector();
0067       }
0068       else
0069       {
0070         nodename << "G4HIT_" << Name();
0071       }
0072       nodes.insert(nodename.str());
0073     }
0074     if (GetParams()->get_int_param("absorberactive"))
0075     {
0076       nodename.str("");
0077       if (SuperDetector() != "NONE")
0078       {
0079         nodename << "G4HIT_ABSORBER_" << SuperDetector();
0080       }
0081       else
0082       {
0083         nodename << "G4HIT_ABSORBER_" << Name();
0084       }
0085       nodes.insert(nodename.str());
0086     }
0087     BOOST_FOREACH (string node, nodes)
0088     {
0089       PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(topNode, node.c_str());
0090       if (!g4_hits)
0091       {
0092         g4_hits = new PHG4HitContainer(node);
0093         DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, node.c_str(), "PHObject"));
0094       }
0095     }
0096 
0097     // create stepping action
0098     m_SteppingAction = new PHG4Prototype3InnerHcalSteppingAction(m_Detector, GetParams());
0099   }
0100   else
0101   {
0102     // if this is a black hole it does not have to be active
0103     if (GetParams()->get_int_param("blackhole"))
0104     {
0105       m_SteppingAction = new PHG4Prototype3InnerHcalSteppingAction(m_Detector, GetParams());
0106     }
0107   }
0108   return 0;
0109 }
0110 
0111 //_______________________________________________________________________
0112 int PHG4Prototype3InnerHcalSubsystem::process_event(PHCompositeNode *topNode)
0113 {
0114   // pass top node to stepping action so that it gets
0115   // relevant nodes needed internally
0116   if (m_SteppingAction)
0117   {
0118     m_SteppingAction->SetInterfacePointers(topNode);
0119   }
0120   return 0;
0121 }
0122 
0123 void PHG4Prototype3InnerHcalSubsystem::Print(const string &what) const
0124 {
0125   cout << Name() << " Parameters: " << endl;
0126   GetParams()->Print();
0127   if (m_Detector)
0128   {
0129     m_Detector->Print(what);
0130   }
0131   if (m_SteppingAction)
0132   {
0133     m_SteppingAction->Print(what);
0134   }
0135   return;
0136 }
0137 
0138 //_______________________________________________________________________
0139 PHG4Detector *PHG4Prototype3InnerHcalSubsystem::GetDetector(void) const
0140 {
0141   return m_Detector;
0142 }
0143 
0144 void PHG4Prototype3InnerHcalSubsystem::SetDefaultParameters()
0145 {
0146   // all in cm
0147   set_default_double_param("light_balance_inner_corr", NAN);
0148   set_default_double_param("light_balance_inner_radius", NAN);
0149   set_default_double_param("light_balance_outer_corr", NAN);
0150   set_default_double_param("light_balance_outer_radius", NAN);
0151   set_default_double_param("place_x", 0.);
0152   set_default_double_param("place_y", 0.);
0153   set_default_double_param("place_z", 0.);
0154   set_default_double_param("rot_x", 0.);
0155   set_default_double_param("rot_y", 0.);
0156   set_default_double_param("rot_z", 0.);
0157   set_default_double_param("steplimits", NAN);
0158 
0159   set_default_int_param("hi_eta", 1);
0160   set_default_int_param("light_scint_model", 1);
0161   set_default_int_param(PHG4PrototypeHcalDefs::scipertwr, 4);
0162   set_default_int_param("scintillators", 1);
0163 
0164   set_default_string_param("material", "Steel_A36");
0165 }
0166 
0167 void PHG4Prototype3InnerHcalSubsystem::SetLightCorrection(const double inner_radius, const double inner_corr, const double outer_radius, const double outer_corr)
0168 {
0169   set_double_param("light_balance_inner_corr", inner_corr);
0170   set_double_param("light_balance_inner_radius", inner_radius);
0171   set_double_param("light_balance_outer_corr", outer_corr);
0172   set_double_param("light_balance_outer_radius", outer_radius);
0173   return;
0174 }