File indexing completed on 2025-08-06 08:14:22
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #define TRKSINJETQA_CC
0011
0012
0013 #include "TrksInJetQA.h"
0014
0015
0016
0017
0018
0019 TrksInJetQA::TrksInJetQA(const std::string& name) : SubsysReco(name) {
0020
0021
0022
0023 }
0024
0025
0026
0027 TrksInJetQA::~TrksInJetQA() {
0028
0029
0030 if (m_config.doDebug && (m_config.verbose > 4)) {
0031 std::cout << "TrksInJetQA::~TrksInJetQA() Calling dtor" << std::endl;
0032 }
0033
0034
0035
0036 if (m_outFile) {
0037 delete m_outFile;
0038 m_outFile = NULL;
0039 }
0040
0041 }
0042
0043
0044
0045
0046
0047 void TrksInJetQA::Configure(
0048 TrksInJetQAConfig config,
0049 std::optional<TrksInJetQAHist> hist
0050 ) {
0051
0052
0053 if (m_config.doDebug && (m_config.verbose > 3)) {
0054 std::cout << "TrksInJetQA::~TrksInJetQA() Calling dtor" << std::endl;
0055 }
0056
0057 m_config = config;
0058 if (hist.has_value()) {
0059 m_hist = hist.value();
0060 }
0061 return;
0062
0063 }
0064
0065
0066
0067
0068
0069 int TrksInJetQA::Init(PHCompositeNode* ) {
0070
0071
0072 if (m_config.doDebug && (m_config.verbose > 0)) {
0073 std::cout << "TrksInJetQA::Init(PHCompositeNode* /*topNode*/) Initializing" << std::endl;
0074 }
0075
0076
0077 InitOutput();
0078 InitHistograms();
0079
0080
0081 if (m_config.outMode == OutMode::QA) {
0082 RegisterHistograms();
0083 }
0084 return Fun4AllReturnCodes::EVENT_OK;
0085
0086 }
0087
0088
0089
0090 int TrksInJetQA::process_event(PHCompositeNode* topNode) {
0091
0092
0093 if (m_config.doDebug && (m_config.verbose > 2)) {
0094 std::cout << "TrksInJetQA::process_event(PHCompositeNode* topNode) Processing Event" << std::endl;
0095 }
0096
0097
0098 if (m_config.doInJet) m_inJet -> Fill(topNode);
0099 if (m_config.doInclusive) m_inclusive -> Fill(topNode);
0100 return Fun4AllReturnCodes::EVENT_OK;
0101
0102 }
0103
0104
0105
0106 int TrksInJetQA::End(PHCompositeNode* ) {
0107
0108
0109 if (m_config.doDebug && (m_config.verbose > 0)) {
0110 std::cout << "TrksInJetQA::End(PHCompositeNode* /*topNode*/) This is the End..." << std::endl;
0111 }
0112
0113
0114 if (m_config.outMode == OutMode::File) {
0115
0116
0117 if (m_config.doInJet) m_inJet -> SaveHistograms(m_outFile, "InJet");
0118 if (m_config.doInclusive) m_inclusive -> SaveHistograms(m_outFile, "Inclusive");
0119
0120
0121 m_outFile -> cd();
0122 m_outFile -> Close();
0123 }
0124 return Fun4AllReturnCodes::EVENT_OK;
0125
0126 }
0127
0128
0129
0130
0131
0132 void TrksInJetQA::InitOutput() {
0133
0134
0135 if (m_config.doDebug && (m_config.verbose > 1)) {
0136 std::cout << "TrksInJetQA::InitOutput() Initializing outputs..." << std::endl;
0137 }
0138
0139
0140 switch (m_config.outMode) {
0141
0142 case OutMode::File:
0143 m_outFile = new TFile(m_outFileName.data(), "RECREATE");
0144 if (!m_outFile) {
0145 std::cerr << PHWHERE << ": PANIC: couldn't create output file!" << std::endl;
0146 assert(m_outFile);
0147 }
0148 break;
0149
0150 case OutMode::QA:
0151 m_manager = QAHistManagerDef::getHistoManager();
0152 if (!m_manager) {
0153 std::cerr << PHWHERE << ": PANIC: couldn't grab histogram manager!" << std::endl;
0154 assert(m_manager);
0155 }
0156 break;
0157
0158 default:
0159 std::cerr << PHWHERE << ": PANIC: unknown output mode specified!\n"
0160 << " Please set .outMode = OutMode::File OR OutMode::QA!"
0161 << std::endl;
0162 assert((m_config.outMode == OutMode::File) || (m_config.outMode == OutMode::QA));
0163 break;
0164 }
0165 return;
0166
0167 }
0168
0169
0170
0171 void TrksInJetQA::InitHistograms() {
0172
0173
0174 if (m_config.doDebug && (m_config.verbose > 1)) {
0175 std::cout << "TrksInJetQA::InitHistograms() Initializing histograms..." << std::endl;
0176 }
0177
0178
0179 std::string inJetLabel = "InJet";
0180 std::string inclusiveLabel = "Inclusive";
0181 if (m_histSuffix.has_value()) {
0182 inJetLabel += "_";
0183 inJetLabel += m_histSuffix.value();
0184 inclusiveLabel += "_";
0185 inclusiveLabel += m_histSuffix.value();
0186 }
0187
0188
0189 if (m_config.doInJet) {
0190 m_inJet = std::make_unique<TrksInJetQAInJetFiller>(m_config, m_hist);
0191 m_inJet -> MakeHistograms(inJetLabel);
0192 }
0193 if (m_config.doInclusive) {
0194 m_inclusive = std::make_unique<TrksInJetQAInclusiveFiller>(m_config, m_hist);
0195 m_inclusive -> MakeHistograms(inclusiveLabel);
0196 }
0197 return;
0198
0199 }
0200
0201
0202
0203 void TrksInJetQA::RegisterHistograms() {
0204
0205
0206 if (m_config.doDebug && (m_config.verbose > 1)) {
0207 std::cout << "TrksInJetQA::RegisterHistograms() Registering histograms..." << std::endl;
0208 }
0209
0210 std::vector<TH1D*> vecHist1D;
0211 std::vector<TH2D*> vecHist2D;
0212 if (m_config.doInJet) m_inJet -> GrabHistograms(vecHist1D, vecHist2D);
0213 if (m_config.doInclusive) m_inclusive -> GrabHistograms(vecHist1D, vecHist2D);
0214
0215
0216 for (TH1D* hist1D : vecHist1D) {
0217 m_manager -> registerHisto(hist1D);
0218 }
0219 for (TH2D* hist2D : vecHist2D) {
0220 m_manager -> registerHisto(hist2D);
0221 }
0222 return;
0223
0224 }
0225
0226