File indexing completed on 2025-08-06 08:18:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #define TRKSINJETQABASEMANAGER_CC
0012
0013 #include "TrksInJetQABaseManager.h"
0014
0015
0016
0017
0018
0019
0020 TrksInJetQABaseManager::TrksInJetQABaseManager(TrksInJetQAConfig& config,
0021 TrksInJetQAHist& hist)
0022 : m_config(config)
0023 , m_hist(hist)
0024 {};
0025
0026
0027
0028
0029 TrksInJetQABaseManager::~TrksInJetQABaseManager() {};
0030
0031
0032
0033
0034
0035
0036 void TrksInJetQABaseManager::MakeHistograms(const std::string& prefix,
0037 const std::string& suffix)
0038 {
0039 DefineHistograms();
0040 BuildHistograms(prefix, suffix);
0041 }
0042
0043
0044
0045
0046
0047
0048
0049 void TrksInJetQABaseManager::SaveHistograms(TDirectory* topDir, const std::string& outDirName)
0050 {
0051 TDirectory* outDir = topDir->mkdir(outDirName.c_str());
0052 if (!outDir)
0053 {
0054 std::cerr << PHWHERE << ": PANIC: unable to make output directory!" << std::endl;
0055 exit(1);
0056 }
0057
0058 outDir->cd();
0059 for (const auto& hist1D : m_mapHist1D)
0060 {
0061 hist1D.second->Write();
0062 }
0063 for (const auto& hist2D : m_mapHist2D)
0064 {
0065 hist2D.second->Write();
0066 }
0067 }
0068
0069
0070
0071
0072 void TrksInJetQABaseManager::GrabHistograms(std::vector<TH1D*>& vecOutHist1D,
0073 std::vector<TH2D*>& vecOutHist2D)
0074 {
0075 for (const auto& hist1D : m_mapHist1D)
0076 {
0077 vecOutHist1D.push_back(hist1D.second);
0078 }
0079 for (const auto& hist2D : m_mapHist2D)
0080 {
0081 vecOutHist2D.push_back(hist2D.second);
0082 }
0083 }
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093 void TrksInJetQABaseManager::BuildHistograms(const std::string& prefix,
0094 const std::string& suffix)
0095 {
0096
0097 for (const auto& histType : m_mapHistTypes)
0098 {
0099 for (const auto& histDef1D : m_mapHistDef1D)
0100 {
0101
0102 std::string sHistName(prefix + "_");
0103 sHistName += histType.second;
0104 sHistName += std::get<0>(histDef1D.second);
0105 sHistName += "_";
0106 sHistName += suffix;
0107
0108
0109 std::transform(sHistName.begin(),
0110 sHistName.end(),
0111 sHistName.begin(),
0112 ::tolower);
0113 std::regex_replace(
0114 sHistName,
0115 std::regex("__"),
0116 "_");
0117
0118
0119 m_mapHist1D.emplace(Index(histType.first, histDef1D.first),
0120 new TH1D(sHistName.data(),
0121 "",
0122 std::get<1>(histDef1D.second).first,
0123 std::get<1>(histDef1D.second).second.first,
0124 std::get<1>(histDef1D.second).second.second));
0125 }
0126
0127
0128 for (const auto& histDef2D : m_mapHistDef2D)
0129 {
0130
0131 std::string sHistName(prefix + "_");
0132 sHistName += histType.second;
0133 sHistName += std::get<0>(histDef2D.second);
0134 sHistName += "_";
0135 sHistName += suffix;
0136
0137
0138 std::transform(sHistName.begin(),
0139 sHistName.end(),
0140 sHistName.begin(),
0141 ::tolower);
0142 std::regex_replace(
0143 sHistName,
0144 std::regex("__"),
0145 "_");
0146
0147
0148 m_mapHist2D.emplace(Index(histType.first, histDef2D.first),
0149 new TH2D(sHistName.data(),
0150 "",
0151 std::get<1>(histDef2D.second).first,
0152 std::get<1>(histDef2D.second).second.first,
0153 std::get<1>(histDef2D.second).second.second,
0154 std::get<2>(histDef2D.second).first,
0155 std::get<2>(histDef2D.second).second.first,
0156 std::get<2>(histDef2D.second).second.second));
0157 }
0158 }
0159 }
0160
0161
0162
0163
0164
0165
0166 bool TrksInJetQABaseManager::IsInMvtx(const uint16_t layer) const
0167 {
0168 return (layer < m_config.nMvtxLayer);
0169 }
0170
0171
0172
0173
0174 bool TrksInJetQABaseManager::IsInIntt(const uint16_t layer) const
0175 {
0176 return ((layer >= m_config.nMvtxLayer) &&
0177 (layer < m_config.nInttLayer + m_config.nMvtxLayer));
0178 }
0179
0180
0181
0182
0183 bool TrksInJetQABaseManager::IsInTpc(const uint16_t layer) const
0184 {
0185 return (layer >= m_config.nMvtxLayer + m_config.nInttLayer);
0186 }
0187
0188
0189
0190
0191 int TrksInJetQABaseManager::Index(const int type, const int hist) const
0192 {
0193 return (100 * type) + hist;
0194 }
0195
0196