Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:19:25

0001 #ifndef CDBOBJECTS_CDBTTREE_H
0002 #define CDBOBJECTS_CDBTTREE_H
0003 
0004 #include <cstdint>
0005 #include <map>
0006 #include <string>
0007 
0008 class TTree;
0009 
0010 class CDBTTree
0011 {
0012  public:
0013   CDBTTree() = default;
0014   explicit CDBTTree(const std::string &fname);
0015   ~CDBTTree();
0016   static void SetVerbosity(int v) { verbosity = v; }
0017   void SetFloatValue(int channel, const std::string &name, float value);
0018   void SetDoubleValue(int channel, const std::string &name, double value);
0019   void SetIntValue(int channel, const std::string &name, int value);
0020   void SetUInt64Value(int channel, const std::string &name, uint64_t value);
0021   void Commit();
0022   void SetSingleFloatValue(const std::string &name, float value);
0023   void SetSingleDoubleValue(const std::string &name, double value);
0024   void SetSingleIntValue(const std::string &name, int value);
0025   void SetSingleUInt64Value(const std::string &name, uint64_t value);
0026   void CommitSingle();
0027   void WriteCDBTTree();
0028   void WriteSingleCDBTTree();
0029   void WriteMultipleCDBTTree();
0030   void Print();
0031   void SetFilename(const std::string &fname) { m_Filename = fname; }
0032   void LoadCalibrations();
0033   float GetSingleFloatValue(const std::string &name, int verbose = 0);
0034   float GetFloatValue(int channel, const std::string &name, int verbose = 0);
0035   double GetSingleDoubleValue(const std::string &name, int verbose = 0);
0036   double GetDoubleValue(int channel, const std::string &name, int verbose = 0);
0037   int GetSingleIntValue(const std::string &name, int verbose = 0);
0038   int GetIntValue(int channel, const std::string &name, int verbose = 0);
0039   uint64_t GetSingleUInt64Value(const std::string &name, int verbose = 0);
0040   uint64_t GetUInt64Value(int channel, const std::string &name, int verbose = 0);
0041 
0042   const auto &GetFloatEntryMap() const { return m_FloatEntryMap; }
0043   const auto &GetDoubleEntryMap() const { return m_DoubleEntryMap; }
0044   const auto &GetIntEntryMap() const { return m_IntEntryMap; }
0045   const auto &GetUInt64EntryMap() const { return m_UInt64EntryMap; }
0046 
0047   const auto &GetSingleFloatEntryMap() const { return m_SingleFloatEntryMap; }
0048   const auto &GetSingleDoubleEntryMap() const { return m_SingleDoubleEntryMap; }
0049   const auto &GetSingleIntEntryMap() const { return m_SingleIntEntryMap; }
0050   const auto &GetSingleUInt64EntryMap() const { return m_SingleUInt64EntryMap; }
0051 
0052  private:
0053   enum
0054   {
0055     SingleEntries = 0,
0056     MultipleEntries = 1
0057   };
0058   const std::string m_TTreeName[2] = {"Single", "Multiple"};
0059   TTree *m_TTree[2] = {nullptr};
0060   static int verbosity;
0061   bool m_Locked[2] = {false};
0062 
0063   std::string m_Filename;
0064   std::map<int, std::map<std::string, float>> m_FloatEntryMap;
0065   std::map<std::string, float> m_SingleFloatEntryMap;
0066   std::map<int, std::map<std::string, double>> m_DoubleEntryMap;
0067   std::map<std::string, double> m_SingleDoubleEntryMap;
0068   std::map<int, std::map<std::string, int>> m_IntEntryMap;
0069   std::map<std::string, int> m_SingleIntEntryMap;
0070   std::map<int, std::map<std::string, uint64_t>> m_UInt64EntryMap;
0071   std::map<std::string, uint64_t> m_SingleUInt64EntryMap;
0072 };
0073 
0074 #endif