Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:17:49

0001 #include "PHG4InnerHcalSubsystem.h"
0002 
0003 #include "PHG4HcalDefs.h"
0004 #include "PHG4InnerHcalDetector.h"
0005 #include "PHG4InnerHcalDisplayAction.h"
0006 #include "PHG4InnerHcalSteppingAction.h"
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 <cmath>     // for NAN
0022 #include <iostream>  // for operator<<, basic_ostream
0023 #include <set>
0024 #include <sstream>
0025 
0026 class PHG4Detector;
0027 
0028 //_______________________________________________________________________
0029 PHG4InnerHcalSubsystem::PHG4InnerHcalSubsystem(const std::string &name, const int lyr)
0030   : PHG4DetectorSubsystem(name, lyr)
0031 {
0032   InitializeParameters();
0033 }
0034 
0035 //_______________________________________________________________________
0036 PHG4InnerHcalSubsystem::~PHG4InnerHcalSubsystem()
0037 {
0038   delete m_DisplayAction;
0039 }
0040 
0041 //_______________________________________________________________________
0042 int PHG4InnerHcalSubsystem::InitRunSubsystem(PHCompositeNode *topNode)
0043 {
0044   PHNodeIterator iter(topNode);
0045   PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
0046 
0047   // create display settings before detector
0048   m_DisplayAction = new PHG4InnerHcalDisplayAction(Name());
0049 
0050   // create detector
0051   m_Detector = new PHG4InnerHcalDetector(this, topNode, GetParams(), Name());
0052   m_Detector->SuperDetector(SuperDetector());
0053   m_Detector->OverlapCheck(CheckOverlap());
0054 
0055   if (GetParams()->get_int_param("active"))
0056   {
0057     std::set<std::string> nodes;
0058     PHNodeIterator dstIter(dstNode);
0059     PHCompositeNode *DetNode = dynamic_cast<PHCompositeNode *>(dstIter.findFirst("PHCompositeNode", SuperDetector()));
0060     if (!DetNode)
0061     {
0062       DetNode = new PHCompositeNode(SuperDetector());
0063       dstNode->addNode(DetNode);
0064     }
0065 
0066     std::ostringstream nodename;
0067     if (SuperDetector() != "NONE")
0068     {
0069       nodename << "G4HIT_" << SuperDetector();
0070     }
0071     else
0072     {
0073       nodename << "G4HIT_" << Name();
0074     }
0075     nodes.insert(nodename.str());
0076     if (GetParams()->get_int_param("absorberactive"))
0077     {
0078       nodename.str("");
0079       if (SuperDetector() != "NONE")
0080       {
0081         nodename << "G4HIT_ABSORBER_" << SuperDetector();
0082       }
0083       else
0084       {
0085         nodename << "G4HIT_ABSORBER_" << Name();
0086       }
0087       nodes.insert(nodename.str());
0088     }
0089     for (auto &node : nodes)
0090     {
0091       PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(topNode, node);
0092       if (!g4_hits)
0093       {
0094         g4_hits = new PHG4HitContainer(node);
0095         DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, node, "PHObject"));
0096       }
0097     }
0098 
0099     // create stepping action
0100     m_SteppingAction = new PHG4InnerHcalSteppingAction(m_Detector, GetParams());
0101     m_SteppingAction->InitWithNode(topNode);
0102   }
0103   else
0104   {
0105     // if this is a black hole it does not have to be active
0106     if (GetParams()->get_int_param("blackhole"))
0107     {
0108       m_SteppingAction = new PHG4InnerHcalSteppingAction(m_Detector, GetParams());
0109       m_SteppingAction->InitWithNode(topNode);
0110     }
0111   }
0112   return 0;
0113 }
0114 
0115 //_______________________________________________________________________
0116 int PHG4InnerHcalSubsystem::process_event(PHCompositeNode *topNode)
0117 {
0118   // pass top node to stepping action so that it gets
0119   // relevant nodes needed internally
0120   if (m_SteppingAction)
0121   {
0122     m_SteppingAction->SetInterfacePointers(topNode);
0123   }
0124   return 0;
0125 }
0126 
0127 void PHG4InnerHcalSubsystem::Print(const std::string &what) const
0128 {
0129   std::cout << Name() << " Parameters: " << std::endl;
0130   GetParams()->Print();
0131   if (m_Detector)
0132   {
0133     m_Detector->Print(what);
0134   }
0135   if (m_SteppingAction)
0136   {
0137     m_SteppingAction->Print(what);
0138   }
0139 
0140   return;
0141 }
0142 
0143 //_______________________________________________________________________
0144 PHG4Detector *PHG4InnerHcalSubsystem::GetDetector() const
0145 {
0146   return m_Detector;
0147 }
0148 
0149 void PHG4InnerHcalSubsystem::SetDefaultParameters()
0150 {
0151   set_default_double_param(PHG4HcalDefs::innerrad, 117.27);
0152   set_default_double_param("light_balance_inner_corr", NAN);
0153   set_default_double_param("light_balance_inner_radius", NAN);
0154   set_default_double_param("light_balance_outer_corr", NAN);
0155   set_default_double_param("light_balance_outer_radius", NAN);
0156   set_default_double_param("phistart", NAN);
0157   set_default_double_param(PHG4HcalDefs::outerrad, 134.42);
0158   set_default_double_param("place_x", 0.);
0159   set_default_double_param("place_y", 0.);
0160   set_default_double_param("place_z", 0.);
0161   set_default_double_param("rot_x", 0.);
0162   set_default_double_param("rot_y", 0.);
0163   set_default_double_param("rot_z", 0.);
0164   set_default_double_param("scinti_eta_coverage", 1.1);
0165   set_default_double_param("scinti_eta_coverage_pos", 1.1);
0166   set_default_double_param("scinti_eta_coverage_neg", 1.1);
0167   set_default_double_param("scinti_gap_neighbor", 0.1);
0168   set_default_double_param("scinti_inner_gap", 0.85);
0169   set_default_double_param("scinti_outer_gap", 1.22 * (5.0 / 4.0));
0170   set_default_double_param("tmin", -20.);
0171   set_default_double_param("tmax", 60.);
0172   set_default_double_param("dt", 100.);
0173   // some math issue in the code subtracts 0.4mm so the scintillator
0174   // does not end at 133.09 as per drawing but at 133.05
0175   // adding 0.4mm compensates for this (so 133.13 gives the desired 133.09
0176   set_default_double_param("scinti_outer_radius", 133.13);
0177   set_default_double_param("scinti_tile_thickness", 0.7);
0178   set_default_double_param("size_z", 175.94 * 2);
0179   set_default_double_param("steplimits", NAN);
0180   set_default_double_param("tilt_angle", 36.15);  // engineering drawing
0181                                                   // corresponds very closely to 4 crossinge (35.5497 deg)
0182 
0183   set_default_int_param("light_scint_model", 1);
0184   // if ncross is set (and tilt_angle is NAN) tilt_angle is calculated
0185   // from number of crossings
0186   set_default_int_param("ncross", 0);
0187   set_default_int_param(PHG4HcalDefs::n_towers, 64);
0188   set_default_int_param(PHG4HcalDefs::scipertwr, 4);
0189   set_default_int_param(PHG4HcalDefs::n_scinti_tiles, 12);
0190   set_default_int_param(PHG4HcalDefs::n_scinti_tiles_pos, 12);
0191   set_default_int_param(PHG4HcalDefs::n_scinti_tiles_neg, 12);
0192   set_default_int_param("etabins", 24);
0193   set_default_int_param("saveg4hit", 1);
0194 
0195   set_default_string_param("material", "G4_Al");
0196   std::string defaultmapfilename;
0197   const char *Calibroot = getenv("CALIBRATIONROOT");
0198   if (Calibroot)
0199   {
0200     defaultmapfilename = Calibroot;
0201     defaultmapfilename += "/HCALIN/tilemap/iHCALMapsNorm020922.root";
0202   }
0203   set_default_string_param("MapFileName", defaultmapfilename);
0204   set_default_string_param("MapHistoName", "ihcalmapcombined");
0205 }
0206 
0207 void PHG4InnerHcalSubsystem::SetLightCorrection(const double inner_radius, const double inner_corr, const double outer_radius, const double outer_corr)
0208 {
0209   set_double_param("light_balance_inner_corr", inner_corr);
0210   set_double_param("light_balance_inner_radius", inner_radius);
0211   set_double_param("light_balance_outer_corr", outer_corr);
0212   set_double_param("light_balance_outer_radius", outer_radius);
0213   return;
0214 }