Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:21:20

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