4 #include <TSQLServer.h>
13 , m_flush_has_error(false)
21 m_spill_id = spill_id;
28 for (
int roc = 0; roc < N_ROC; roc++) {
30 m_n_err_tdc[roc][err].clear();
38 if (m_flush_has_error) m_n_evt_ng++;
43 m_n_err_tdc[roc][type].push_back(event);
44 cout <<
"AddTdcError: " <<
event <<
" " << roc <<
" " << type <<
"." << endl;
45 m_flush_has_error =
true;
58 os <<
"DecoError::PrintData(): " << m_run_id <<
" " << m_spill_id <<
"\n";
59 for (
int roc = 0; roc < N_ROC; roc++) {
61 int n_evt = m_n_err_tdc[roc][err].size();
62 if (n_evt == 0)
continue;
63 os <<
" ROC " << setw(2) << roc <<
", type " << setw(2) << err <<
": n=" << n_evt;
64 if (n_evt > 100) n_evt = 100;
65 for (
int i_evt = 0; i_evt < n_evt; i_evt++) {
66 if (i_evt % 10 == 0) os <<
"\n ";
67 os <<
" " << m_n_err_tdc[roc][err].at(i_evt);
75 void DecoError::UpdateDbInfo(
DbSvc* db)
77 const char* table_name =
"deco_error_info";
81 list.
Add(
"run_id" ,
"INT",
true);
82 list.
Add(
"spill_id" ,
"INT");
83 list.
Add(
"utime" ,
"INT");
84 list.
Add(
"n_evt_all",
"INT");
85 list.
Add(
"n_evt_ng" ,
"INT");
90 oss <<
"delete from " << table_name <<
" where run_id = " << m_run_id;
91 if (! db->
Con()->Exec(oss.str().c_str())) {
92 cerr <<
"!!ERROR!! DecoError::UpdateDbInfo(): delete." << endl;
96 oss <<
"insert into " << table_name <<
" values (" << m_run_id <<
", " << m_spill_id <<
", " << time(0) <<
", " << m_n_evt_all <<
", " << m_n_evt_ng <<
")";
97 if (! db->
Con()->Exec(oss.str().c_str())) {
98 cerr <<
"!!ERROR!! DecoError::UpdateDbInfo(): insert." << endl;
102 void DecoError::UpdateDbTdc(
DbSvc* db)
104 const char* table_name =
"deco_error_tdc";
108 list.
Add(
"run_id" ,
"INT",
true);
109 list.
Add(
"roc_id" ,
"INT",
true);
110 list.
Add(
"error_id" ,
"INT",
true);
111 list.
Add(
"error_count" ,
"INT");
112 list.
Add(
"event_id_min",
"INT");
113 list.
Add(
"event_id_max",
"INT");
118 oss <<
"delete from " << table_name <<
" where run_id = " << m_run_id;
119 if (! db->
Con()->Exec(oss.str().c_str())) {
120 cerr <<
"!!ERROR!! DecoError::UpdateDbTdc(): delete." << endl;
126 oss <<
"insert into " << table_name <<
" values";
127 for (
int roc = 0; roc < N_ROC; roc++) {
129 if (m_n_err_tdc[roc][err].size() == 0)
continue;
130 oss <<
" (" << m_run_id
133 <<
", " << m_n_err_tdc[roc][err].size()
134 <<
", " << m_n_err_tdc[roc][err].at(0)
135 <<
", " << m_n_err_tdc[roc][err].back()
141 oss.seekp(-1, oss.cur);
143 if (! db->
Con()->Exec(oss.str().c_str())) {
144 cerr <<
"!!ERROR!! DecoError::UpdateDbTdc()." << endl;
void Add(const std::string name, const std::string type, const bool is_key=false)
Standard interface with SQL database.
void UseSchema(const char *name, const bool do_create=false, const bool do_drop=false)
void CreateTable(const std::string name, const std::vector< std::string > list_var, const std::vector< std::string > list_type, const std::vector< std::string > list_key)
bool HasTable(const char *name, const bool exit_on_false=false)
void PrintData(std::ostream &os=std::cout)
void AddTdcError(const int event, const int roc, const TdcError_t type)
void SetID(const int run_id, const int spill_id)
static std::string GetSchemaMainDaq()