Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #include "PHG4Prototype2InnerHcalSubsystem.h"
0002 #include "PHG4Prototype2InnerHcalDetector.h"
0003 #include "PHG4Prototype2InnerHcalSteppingAction.h"
0004 #include "PHG4PrototypeHcalDefs.h"
0005 
0006 #include <phparameter/PHParameters.h>
0007 
0008 #include <g4detectors/PHG4DetectorSubsystem.h>  // for PHG4DetectorSubsy...
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 PHG4Prototype2InnerHcalSubsystem::PHG4Prototype2InnerHcalSubsystem(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 PHG4Prototype2InnerHcalSubsystem::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 PHG4Prototype2InnerHcalDetector(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"))
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 (SuperDetector() != "NONE")
0063     {
0064       nodename << "G4HIT_" << SuperDetector();
0065     }
0066     else
0067     {
0068       nodename << "G4HIT_" << Name();
0069     }
0070     nodes.insert(nodename.str());
0071     if (GetParams()->get_int_param("absorberactive"))
0072     {
0073       nodename.str("");
0074       if (SuperDetector() != "NONE")
0075       {
0076         nodename << "G4HIT_ABSORBER_" << SuperDetector();
0077       }
0078       else
0079       {
0080         nodename << "G4HIT_ABSORBER_" << Name();
0081       }
0082       nodes.insert(nodename.str());
0083     }
0084     BOOST_FOREACH (string node, nodes)
0085     {
0086       PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(topNode, node.c_str());
0087       if (!g4_hits)
0088       {
0089         g4_hits = new PHG4HitContainer(node);
0090         DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, node.c_str(), "PHObject"));
0091       }
0092     }
0093 
0094     // create stepping action
0095     m_SteppingAction = new PHG4Prototype2InnerHcalSteppingAction(m_Detector, GetParams());
0096   }
0097   else
0098   {
0099     // if this is a black hole it does not have to be active
0100     if (GetParams()->get_int_param("blackhole"))
0101     {
0102       m_SteppingAction = new PHG4Prototype2InnerHcalSteppingAction(m_Detector, GetParams());
0103     }
0104   }
0105   return 0;
0106 }
0107 
0108 //_______________________________________________________________________
0109 int PHG4Prototype2InnerHcalSubsystem::process_event(PHCompositeNode *topNode)
0110 {
0111   // pass top node to stepping action so that it gets
0112   // relevant nodes needed internally
0113   if (m_SteppingAction)
0114   {
0115     m_SteppingAction->SetInterfacePointers(topNode);
0116   }
0117   return 0;
0118 }
0119 
0120 void PHG4Prototype2InnerHcalSubsystem::Print(const string &what) const
0121 {
0122   cout << Name() << " Parameters: " << endl;
0123   GetParams()->Print();
0124   if (m_Detector)
0125   {
0126     m_Detector->Print(what);
0127   }
0128   if (m_SteppingAction)
0129   {
0130     m_SteppingAction->Print(what);
0131   }
0132   return;
0133 }
0134 
0135 //_______________________________________________________________________
0136 PHG4Detector *PHG4Prototype2InnerHcalSubsystem::GetDetector(void) const
0137 {
0138   return m_Detector;
0139 }
0140 
0141 void PHG4Prototype2InnerHcalSubsystem::SetDefaultParameters()
0142 {
0143   // all in cm
0144   set_default_double_param("light_balance_inner_corr", NAN);
0145   set_default_double_param("light_balance_inner_radius", NAN);
0146   set_default_double_param("light_balance_outer_corr", NAN);
0147   set_default_double_param("light_balance_outer_radius", NAN);
0148   set_default_double_param("place_x", 0.);
0149   set_default_double_param("place_y", 0.);
0150   set_default_double_param("place_z", 0.);
0151   set_default_double_param("rot_x", 0.);
0152   set_default_double_param("rot_y", 0.);
0153   set_default_double_param("rot_z", 0.);
0154   set_default_double_param("steplimits", NAN);
0155 
0156   set_default_int_param("hi_eta", 0);
0157   set_default_int_param("light_scint_model", 1);
0158   set_default_int_param(PHG4PrototypeHcalDefs::scipertwr, 5);
0159 }
0160 
0161 void PHG4Prototype2InnerHcalSubsystem::SetLightCorrection(const double inner_radius, const double inner_corr, const double outer_radius, const double outer_corr)
0162 {
0163   set_double_param("light_balance_inner_corr", inner_corr);
0164   set_double_param("light_balance_inner_radius", inner_radius);
0165   set_double_param("light_balance_outer_corr", outer_corr);
0166   set_double_param("light_balance_outer_radius", outer_radius);
0167   return;
0168 }