Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:44

0001 /// ===========================================================================
0002 /*! \file   TrksInJetQABaseFiller.cc
0003  *  \author Derek Anderson
0004  *  \date   04.11.2024
0005  *
0006  *  A submodule for the TrksInJetQA F4A module to produce
0007  *  QA histograms for tracks and more in jets
0008  */
0009 /// ===========================================================================
0010 
0011 #define TRKSINJETQABASEFILLER_CC
0012 
0013 #include "TrksInJetQABaseFiller.h"
0014 
0015 // ctor/dtor ==================================================================
0016 
0017 // ----------------------------------------------------------------------------
0018 //! Default ctor
0019 // ----------------------------------------------------------------------------
0020 TrksInJetQABaseFiller::TrksInJetQABaseFiller(const TrksInJetQAConfig& config,
0021                                              TrksInJetQAHist& hist)
0022   : m_config(config)
0023   , m_hist(hist)
0024 {
0025   // initialize managers
0026   if (m_config.doHitQA)
0027   {
0028     m_hitManager = std::make_unique<TrksInJetQAHitManager>(m_config, m_hist);
0029   }
0030   if (m_config.doClustQA)
0031   {
0032     m_clustManager = std::make_unique<TrksInJetQAClustManager>(m_config, m_hist);
0033   }
0034   if (m_config.doTrackQA)
0035   {
0036     m_trackManager = std::make_unique<TrksInJetQATrkManager>(m_config, m_hist);
0037   }
0038   if (m_config.doJetQA)
0039   {
0040     m_jetManager = std::make_unique<TrksInJetQAJetManager>(m_config, m_hist);
0041   }
0042 }  // end ctor()'
0043 
0044 // public methods =============================================================
0045 
0046 // ----------------------------------------------------------------------------
0047 //! Generate histograms for each type
0048 // ----------------------------------------------------------------------------
0049 void TrksInJetQABaseFiller::MakeHistograms(const std::string& prefix,
0050                                            const std::string& suffix)
0051 {
0052   // initialize relevant submodules
0053   if (m_config.doHitQA)
0054   {
0055     m_hitManager->MakeHistograms(prefix, suffix);
0056   }
0057   if (m_config.doClustQA)
0058   {
0059     m_clustManager->MakeHistograms(prefix, suffix);
0060   }
0061   if (m_config.doTrackQA)
0062   {
0063     m_trackManager->MakeHistograms(prefix, suffix);
0064   }
0065   if (m_config.doJetQA)
0066   {
0067     m_jetManager->MakeHistograms(prefix, suffix);
0068   }
0069 }  // end 'MakeHistograms(std::string)'
0070 
0071 // ----------------------------------------------------------------------------
0072 //! Save histograms to output file
0073 // ----------------------------------------------------------------------------
0074 /*! Note that this only relevant if output
0075  *  mode is OutMode::File.
0076  */
0077 void TrksInJetQABaseFiller::SaveHistograms(TFile* outFile, const std::string& outDirName)
0078 {
0079   TDirectory* outDir = outFile->mkdir(outDirName.c_str());
0080   if (!outDir)
0081   {
0082     std::cerr << PHWHERE << ": PANIC: unable to make output directory!" << std::endl;
0083     assert(outDir);
0084   }
0085 
0086   if (m_config.doHitQA)
0087   {
0088     m_hitManager->SaveHistograms(outDir, m_config.hitOutDir);
0089   }
0090   if (m_config.doClustQA)
0091   {
0092     m_clustManager->SaveHistograms(outDir, m_config.clustOutDir);
0093   }
0094   if (m_config.doTrackQA)
0095   {
0096     m_trackManager->SaveHistograms(outDir, m_config.trackOutDir);
0097   }
0098   if (m_config.doJetQA)
0099   {
0100     m_jetManager->SaveHistograms(outDir, m_config.jetOutDir);
0101   }
0102 }  // end 'SaveHistograms(TFile*, std::string)'
0103 
0104 // ----------------------------------------------------------------------------
0105 //! Grab histograms from managers
0106 // ----------------------------------------------------------------------------
0107 void TrksInJetQABaseFiller::GrabHistograms(std::vector<TH1D*>& vecOutHist1D,
0108                                            std::vector<TH2D*>& vecOutHist2D)
0109 {
0110   if (m_config.doHitQA)
0111   {
0112     m_hitManager->GrabHistograms(vecOutHist1D, vecOutHist2D);
0113   }
0114   if (m_config.doClustQA)
0115   {
0116     m_clustManager->GrabHistograms(vecOutHist1D, vecOutHist2D);
0117   }
0118   if (m_config.doTrackQA)
0119   {
0120     m_trackManager->GrabHistograms(vecOutHist1D, vecOutHist2D);
0121   }
0122   if (m_config.doJetQA)
0123   {
0124     m_jetManager->GrabHistograms(vecOutHist1D, vecOutHist2D);
0125   }
0126 }  // end 'GrabHistograms(std::vector<TH1D*>&, std::vector<TH2D*>&)'
0127 
0128 // private methods ============================================================
0129 
0130 // ----------------------------------------------------------------------------
0131 //! Grab relevant input nodes
0132 // ----------------------------------------------------------------------------
0133 void TrksInJetQABaseFiller::GetNodes(PHCompositeNode* topNode)
0134 {
0135   // grab necessary jet nodes
0136   if (m_config.doJetQA)
0137   {
0138     m_jetMap = findNode::getClass<JetContainer>(topNode, m_config.jetInNode);
0139     if (!m_jetMap)
0140     {
0141       std::cerr << PHWHERE << ": PANIC: couldn't grab jet map from node tree!" << std::endl;
0142       assert(m_jetMap);
0143     }
0144   }
0145 
0146   // grab necessary track nodes
0147   if (m_config.doTrackQA)
0148   {
0149     m_trkMap = findNode::getClass<SvtxTrackMap>(topNode, m_config.trkInNode);
0150     if (!m_trkMap)
0151     {
0152       std::cerr << PHWHERE << ": PANIC: couldn't grab track map from node tree!" << std::endl;
0153       assert(m_trkMap);
0154     }
0155   }
0156 
0157   // grab necessary cluster nodes
0158   if (m_config.doClustQA)
0159   {
0160     m_actsGeom = findNode::getClass<ActsGeometry>(topNode, "ActsGeometry");
0161     if (!m_actsGeom)
0162     {
0163       std::cerr << PHWHERE << ": PANIC: couldn't grab ACTS geometry from node tree!" << std::endl;
0164       assert(m_actsGeom);
0165     }
0166 
0167     m_clustMap = findNode::getClass<TrkrClusterContainer>(topNode, m_config.clustInNode);
0168     if (!m_clustMap)
0169     {
0170       std::cerr << PHWHERE << ": PANIC: couldn't grab cluster map from node tree!" << std::endl;
0171       assert(m_clustMap);
0172     }
0173   }
0174 
0175   // grab necessary hit nodes
0176   if (m_config.doHitQA)
0177   {
0178     m_hitMap = findNode::getClass<TrkrHitSetContainer>(topNode, m_config.hitInNode);
0179     if (!m_hitMap)
0180     {
0181       std::cerr << PHWHERE << ": PANIC: couldn't grab hit map from node tree!" << std::endl;
0182       assert(m_hitMap);
0183     }
0184   }
0185 }  // end 'GetNodes(PHCompositeNode*)'
0186 
0187 // end ========================================================================