File indexing completed on 2025-12-16 09:19:34
0001
0002
0003 #ifndef FUN4ALL_FUN4ALLHISTOMANAGER_H
0004 #define FUN4ALL_FUN4ALLHISTOMANAGER_H
0005
0006 #include "Fun4AllBase.h"
0007
0008 #include <map>
0009 #include <string>
0010
0011 class Fun4AllOutputManager;
0012 class TNamed;
0013
0014 class Fun4AllHistoManager : public Fun4AllBase
0015 {
0016 public:
0017 explicit Fun4AllHistoManager(const std::string &name);
0018 ~Fun4AllHistoManager() override;
0019
0020 void Print(const std::string &what = "ALL") const override;
0021
0022
0023
0024 bool registerHisto(const std::string &hname, TNamed *h1d, const int replace = 0);
0025
0026
0027
0028 bool registerHisto(TNamed *h1d, const int replace = 0);
0029
0030 template <typename T>
0031 T *makeHisto(T *t)
0032 {
0033 if (not registerHisto(t))
0034 {
0035 delete t;
0036 t = nullptr;
0037 }
0038 return t;
0039 }
0040 int isHistoRegistered(const std::string &name) const;
0041 TNamed *getHisto(const std::string &hname) const;
0042 TNamed *getHisto(const unsigned int ihisto) const;
0043 std::string getHistoName(const unsigned int ihisto) const;
0044 unsigned int nHistos() const { return Histo.size(); }
0045 void Reset();
0046 int RunAfterClosing();
0047 int dumpHistos(const std::string &filename = "", const std::string &openmode = "RECREATE");
0048 const std::string &OutFileName() { return m_outfilename; }
0049 void setOutfileName(const std::string &filename) { m_outfilename = filename; }
0050 void SetClosingScript(const std::string &script) { m_RunAfterClosingScript = script; }
0051 void SetClosingScriptArgs(const std::string &args) { m_ClosingArgs = args; }
0052 void segment(const int segment) { m_CurrentSegment = segment; }
0053 int GetEventNumberRollover() const { return m_EventRollover; }
0054 void SetEventNumberRollover(const int evtno) { m_EventRollover = evtno; }
0055 int LastEventNumber() const { return m_LastEventNumber; }
0056 void SetLastEventNumber(int ival) { m_LastEventNumber = ival; }
0057 void UpdateLastEvent() { m_LastEventNumber += m_EventRollover; }
0058 void InitializeLastEvent(int eventnumber);
0059 void StartSegment(int iseg) { m_CurrentSegment = iseg; }
0060 void UseFileRule(bool b = true) { m_UseFileRuleFlag = b; }
0061 bool ApplyFileRule() const { return m_UseFileRuleFlag; }
0062 void CopyRolloverSetting(const Fun4AllOutputManager *outman);
0063 const std::string &LastClosedFileName() const { return m_LastClosedFileName; }
0064 bool isEmpty() const;
0065
0066 private:
0067 bool m_LastEventInitializedFlag{false};
0068 bool m_UseFileRuleFlag{false};
0069 int m_CurrentSegment{0};
0070 int m_EventRollover{0};
0071 int m_LastEventNumber{std::numeric_limits<int>::max()};
0072
0073 std::string m_FileRule{"-%08d-%05d"};
0074 std::string m_outfilename;
0075 std::string m_RunAfterClosingScript;
0076 std::string m_ClosingArgs;
0077 std::string m_LastClosedFileName;
0078 std::map<const std::string, TNamed *> Histo;
0079 };
0080
0081 #endif