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