File indexing completed on 2025-08-06 08:13:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef SCORRELATORQAMAKER_SBASEQAPLUGIN_H
0011 #define SCORRELATORQAMAKER_SBASEQAPLUGIN_H
0012
0013
0014 #include <string>
0015
0016 #include <TFile.h>
0017 #include <TSystem.h>
0018 #include <TDirectory.h>
0019
0020 using namespace std;
0021
0022
0023
0024 namespace SColdQcdCorrelatorAnalysis {
0025
0026
0027
0028 template <class Config> class SBaseQAPlugin {
0029
0030 public:
0031
0032
0033 SBaseQAPlugin() {};
0034 ~SBaseQAPlugin() {};
0035
0036
0037 void SetDebug(const bool debug) {m_isDebugOn = debug;}
0038 void SetOutFile(const string file) {m_outFileName = file;}
0039 void SetOutDir(const string name) {m_outDirName = name;}
0040 void SetVerbosity(const uint16_t verb) {m_verbosity = verb;}
0041 void SetConfig(const Config& cfg) {m_config = cfg;}
0042
0043
0044 TFile* GetOutFile() {return m_outFile;}
0045 TDirectory* GetOutDir() {return m_outDir;}
0046
0047 protected:
0048
0049 void InitOutput() {
0050
0051
0052
0053 const bool doesFileExist = gSystem -> AccessPathName(m_outFileName.data());
0054 if (!doesFileExist) {
0055 m_outFile = new TFile(m_outFileName.data(), "recreate");
0056 } else {
0057 m_outFile = new TFile(m_outFileName.data(), "update");
0058 }
0059
0060
0061 const bool doesDirExist = m_outFile -> cd(m_outDirName.data());
0062 if (!doesDirExist) {
0063 m_outDir = (TDirectory*) m_outFile -> mkdir(m_outDirName.data());
0064 } else {
0065 m_outDir = (TDirectory*) m_outFile -> GetDirectory(m_outDirName.data());
0066 }
0067 return;
0068 };
0069
0070 void CloseOutput() {
0071
0072
0073
0074 const bool isFileOpen = m_outFile -> IsOpen();
0075 if (isFileOpen) {
0076 m_outFile -> cd();
0077 m_outFile -> Close();
0078 }
0079 return;
0080
0081 };
0082
0083
0084 TFile* m_outFile = NULL;
0085 TDirectory* m_outDir = NULL;
0086
0087
0088 bool m_isDebugOn = false;
0089 string m_outFileName = "";
0090 string m_outDirName = "";
0091 uint16_t m_verbosity = 0;
0092
0093
0094 Config m_config;
0095
0096 };
0097
0098 }
0099
0100 #endif
0101
0102