Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // This is the subsystem code (cc file) for the hcal prototype detector
0002 // created on 1/27/2014, Liang, HeXC
0003 //
0004 #include "PHG4HcalPrototypeSubsystem.h"
0005 #include "PHG4HcalPrototypeDetector.h"
0006 #include "PHG4HcalPrototypeSteppingAction.h"
0007 
0008 #include <g4detectors/PHG4EventActionClearZeroEdep.h>
0009 
0010 #include <g4main/PHG4HitContainer.h>
0011 #include <g4main/PHG4Subsystem.h>  // for PHG4Subsystem
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 <Geant4/G4SystemOfUnits.hh>  // for cm
0021 #include <Geant4/G4Types.hh>          // for G4double
0022 
0023 #include <sstream>
0024 
0025 using namespace std;
0026 
0027 //_______________________________________________________________________
0028 PHG4HcalPrototypeSubsystem::PHG4HcalPrototypeSubsystem(const std::string& name, const int lyr)
0029   : PHG4Subsystem(name)
0030   , detector_(0)
0031   , steppingAction_(nullptr)
0032   , eventAction_(nullptr)
0033   , rot_in_y(0)
0034   , rot_in_z(0)
0035   , material("G4_AIR")
0036   ,  // default - almost nothing
0037   active(0)
0038   , absorberactive(0)
0039   , layer(lyr)
0040   , blackhole(0)
0041   , detector_type(name)
0042   , superdetector("NONE")
0043 {
0044   // put the layer into the name so we get unique names
0045   // for multiple layers
0046   ostringstream nam;
0047   nam << name << "_" << lyr;
0048   Name(nam.str().c_str());
0049   for (int i = 0; i < 3; i++)
0050   {
0051     dimension[i] = 100.0 * cm;
0052   }
0053 }
0054 
0055 //_______________________________________________________________________
0056 int PHG4HcalPrototypeSubsystem::Init(PHCompositeNode* topNode)
0057 {
0058   PHNodeIterator iter(topNode);
0059   PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
0060 
0061   // create detector
0062   detector_ = new PHG4HcalPrototypeDetector(this, topNode, Name(), layer);
0063   detector_->SetYRot(rot_in_y);
0064   detector_->SetZRot(rot_in_z);
0065   detector_->SetActive(active);
0066   detector_->SetAbsorberActive(absorberactive);
0067   detector_->BlackHole(blackhole);
0068   detector_->SuperDetector(superdetector);
0069   detector_->OverlapCheck(CheckOverlap());
0070   if (active)
0071   {
0072     ostringstream nodename;
0073     if (superdetector != "NONE")
0074     {
0075       nodename << "G4HIT_" << superdetector;
0076     }
0077     else
0078     {
0079       nodename << "G4HIT_" << detector_type << "_" << layer;
0080     }
0081     // create hit list
0082     PHG4HitContainer* block_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str().c_str());
0083     if (!block_hits)
0084     {
0085       dstNode->addNode(new PHIODataNode<PHObject>(block_hits = new PHG4HitContainer(nodename.str()), nodename.str().c_str(), "PHObject"));
0086     }
0087     if (absorberactive)
0088     {
0089       nodename.str("");
0090       if (superdetector != "NONE")
0091       {
0092         nodename << "G4HIT_ABSORBER_" << superdetector;
0093       }
0094       else
0095       {
0096         nodename << "G4HIT_ABSORBER_" << detector_type << "_" << layer;
0097       }
0098     }
0099     block_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str().c_str());
0100     if (!block_hits)
0101     {
0102       dstNode->addNode(new PHIODataNode<PHObject>(block_hits = new PHG4HitContainer(nodename.str()), nodename.str().c_str(), "PHObject"));
0103     }
0104     // create stepping action
0105     steppingAction_ = new PHG4HcalPrototypeSteppingAction(detector_);
0106 
0107     eventAction_ = new PHG4EventActionClearZeroEdep(topNode, nodename.str());
0108   }
0109   if (blackhole && !active)
0110   {
0111     steppingAction_ = new PHG4HcalPrototypeSteppingAction(detector_);
0112   }
0113   return 0;
0114 }
0115 
0116 //_______________________________________________________________________
0117 int PHG4HcalPrototypeSubsystem::process_event(PHCompositeNode* topNode)
0118 {
0119   // pass top node to stepping action so that it gets
0120   // relevant nodes needed internally
0121   if (steppingAction_)
0122   {
0123     steppingAction_->SetInterfacePointers(topNode);
0124   }
0125   return 0;
0126 }
0127 
0128 //_______________________________________________________________________
0129 PHG4Detector* PHG4HcalPrototypeSubsystem::GetDetector(void) const
0130 {
0131   return detector_;
0132 }
0133 
0134 //_______________________________________________________________________
0135 PHG4SteppingAction* PHG4HcalPrototypeSubsystem::GetSteppingAction(void) const
0136 {
0137   return steppingAction_;
0138 }