Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:13:21

0001 /// ---------------------------------------------------------------------------
0002 /*! \file   ParTools.cc
0003  *  \author Derek Anderson
0004  *  \file   03.06.2024
0005  *
0006  *  Particle-related interfaces.
0007  */
0008 /// ---------------------------------------------------------------------------
0009 
0010 #define SCORRELATORUTILITIES_PARINTERFACES_CC
0011 
0012 // namespace definition
0013 #include "ParInterfaces.h"
0014 
0015 // make common namespaces implicit
0016 using namespace std;
0017 using namespace findNode;
0018 
0019 
0020 
0021 // particle interfaces ========================================================
0022 
0023 namespace SColdQcdCorrelatorAnalysis {
0024 
0025   // --------------------------------------------------------------------------
0026   //! Get PHG4Particle container
0027   // --------------------------------------------------------------------------
0028   PHG4TruthInfoContainer* Interfaces::GetTruthContainer(PHCompositeNode* topNode) {
0029 
0030     PHG4TruthInfoContainer* container = getClass<PHG4TruthInfoContainer>(topNode, "G4TruthInfo");
0031     if (!container) {
0032       cerr << PHWHERE
0033            << "PANIC: G4 truth info container node is missing!"
0034            << endl;
0035       assert(container);
0036     }
0037     return container;
0038 
0039   }  // end 'GetTruthContainer(PHCompositeNode*)'
0040 
0041 
0042 
0043   // --------------------------------------------------------------------------
0044   //! Get primary particles from PHG4Particle container
0045   // --------------------------------------------------------------------------
0046   PHG4TruthInfoContainer::ConstRange Interfaces::GetPrimaries(PHCompositeNode* topNode) {
0047 
0048     PHG4TruthInfoContainer* particles = GetTruthContainer(topNode);
0049     return particles -> GetPrimaryParticleRange();
0050 
0051   }  // end 'GetPrimaries(PHCompositeNode*)'
0052 
0053 
0054 
0055   // --------------------------------------------------------------------------
0056   //! Get map of HepMC events
0057   // --------------------------------------------------------------------------
0058   PHHepMCGenEventMap* Interfaces::GetMcEventMap(PHCompositeNode* topNode) {
0059 
0060     PHHepMCGenEventMap* mapMcEvts = getClass<PHHepMCGenEventMap>(topNode, "PHHepMCGenEventMap");
0061     if (!mapMcEvts) {
0062       cerr << PHWHERE
0063            << "PANIC: HepMC event map node is missing!"
0064            << endl;
0065       assert(mapMcEvts);
0066     }
0067     return mapMcEvts;
0068 
0069   }  // end 'GetMcEventMap(PHCompositeNode*)'
0070 
0071 
0072 
0073   // --------------------------------------------------------------------------
0074   //! Get a specific HepMC event
0075   // --------------------------------------------------------------------------
0076   PHHepMCGenEvent* Interfaces::GetMcEvent(PHCompositeNode* topNode, const int iEvtToGrab) {
0077 
0078     PHHepMCGenEventMap* mcEvtMap = GetMcEventMap(topNode);
0079     PHHepMCGenEvent*    mcEvt    = mcEvtMap -> get(iEvtToGrab);
0080     if (!mcEvt) {
0081       cerr << PHWHERE
0082            << "PANIC: Couldn't grab mc event!"
0083            << endl;
0084       assert(mcEvt);
0085     }
0086     return mcEvt;
0087 
0088   }  // end 'GetMcEvent(PHCompositeNode*, int)'
0089 
0090 
0091 
0092   // --------------------------------------------------------------------------
0093   //! Get the corresponding GenEvt object from a specific HepMC event
0094   // --------------------------------------------------------------------------
0095   HepMC::GenEvent* Interfaces::GetGenEvent(PHCompositeNode* topNode, const int iEvtToGrab) {
0096 
0097     PHHepMCGenEvent* mcEvt  = GetMcEvent(topNode, iEvtToGrab);
0098     HepMC::GenEvent* genEvt = mcEvt -> getEvent();
0099     if (!genEvt) {
0100       cerr << PHWHERE
0101            << "PANIC: Couldn't grab HepMC event!"
0102            << endl;
0103       assert(mcEvt);
0104     }
0105     return genEvt;
0106 
0107   }  // end 'GetGenEvent(PHCompositeNode*, int)'
0108 
0109 }  // end SColdQcdCorrealtorAnalysis namespace
0110 
0111 // end ------------------------------------------------------------------------