Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:16:39

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   void SetFloatValue(int channel, const std::string &name, float value);
0017   void SetDoubleValue(int channel, const std::string &name, double value);
0018   void SetIntValue(int channel, const std::string &name, int value);
0019   void SetUInt64Value(int channel, const std::string &name, uint64_t value);
0020   void Commit();
0021   void SetSingleFloatValue(const std::string &name, float value);
0022   void SetSingleDoubleValue(const std::string &name, double value);
0023   void SetSingleIntValue(const std::string &name, int value);
0024   void SetSingleUInt64Value(const std::string &name, uint64_t value);
0025   void CommitSingle();
0026   void WriteCDBTTree();
0027   void WriteSingleCDBTTree();
0028   void WriteMultipleCDBTTree();
0029   void Print();
0030   void SetFilename(const std::string &fname) {m_Filename = fname;}
0031   void LoadCalibrations();
0032   float GetSingleFloatValue(const std::string &name, int verbose = 1);
0033   float GetFloatValue(int channel, const std::string &name, int verbose = 1);
0034   double GetSingleDoubleValue(const std::string &name, int verbose = 1);
0035   double GetDoubleValue(int channel, const std::string &name, int verbose = 1);
0036   int GetSingleIntValue(const std::string &name, int verbose = 1);
0037   int GetIntValue(int channel, const std::string &name, int verbose = 1);
0038   uint64_t GetSingleUInt64Value(const std::string &name, int verbose = 1);
0039   uint64_t GetUInt64Value(int channel, const std::string &name, int verbose = 1);
0040 
0041  private:
0042   enum
0043   {
0044     SingleEntries = 0,
0045     MultipleEntries = 1
0046   };
0047   const std::string m_TTreeName[2] = {"Single", "Multiple"};
0048   TTree *m_TTree[2] = {nullptr};
0049   bool m_Locked[2] = {false};
0050 
0051   std::string m_Filename;
0052   std::map<int, std::map<std::string, float>> m_FloatEntryMap;
0053   std::map<std::string, float> m_SingleFloatEntryMap;
0054   std::map<int, std::map<std::string, double>> m_DoubleEntryMap;
0055   std::map<std::string, double> m_SingleDoubleEntryMap;
0056   std::map<int, std::map<std::string, int>> m_IntEntryMap;
0057   std::map<std::string, int> m_SingleIntEntryMap;
0058   std::map<int, std::map<std::string, uint64_t>> m_UInt64EntryMap;
0059   std::map<std::string, uint64_t> m_SingleUInt64EntryMap;
0060 };
0061 
0062 #endif