6 #include <TSQLServer.h>
7 #include <TSQLStatement.h>
8 #include <TGraphErrors.h>
24 for (LineList::iterator it = lines.begin(); it != lines.end(); it++) {
30 if (! (iss >> det >> ele >> lvl >> center >> width))
continue;
31 Add(det, ele, lvl, center, width);
40 for (List_t::iterator it = m_list.begin(); it != m_list.end(); it++) {
41 os << it->det_name <<
"\t" << it->ele <<
"\t" << it->lvl <<
"\t"
42 << it->center <<
"\t" << it->width <<
"\n";
51 oss <<
"select det_name, det, ele, lvl, center, width from " <<
MapTableName();
52 TSQLStatement* stmt = db.
Process(oss.str());
53 while (stmt->NextResultRow()) {
54 string det_name = stmt->GetString(0);
55 short det = stmt->GetInt (1);
56 short ele = stmt->GetInt (2);
57 short lvl = stmt->GetInt (3);
58 double center = stmt->GetDouble(4);
59 double width = stmt->GetDouble(5);
60 Add(det_name, det, ele, lvl, center, width);
69 const char* list_var [] = {
"det_name",
"det",
"ele",
"lvl",
"center",
"width" };
70 const char* list_type[] = {
"VARCHAR(32)",
"SMALLINT",
"SMALLINT",
"SMALLINT",
"DOUBLE",
"DOUBLE" };
72 db.
CreateTable(name_table, n_var, list_var, list_type);
75 oss <<
"insert into " << name_table <<
"(det_name, det, ele, lvl, center, width) values";
76 for (List_t::iterator it = m_list.begin(); it != m_list.end(); it++) {
77 oss <<
" ('" << it->det_name <<
"', " << it->det <<
", " << it->ele <<
", " << it->lvl <<
", "
78 << it->center <<
", " << it->width <<
"),";
80 string query = oss.str();
81 query.erase(query.length()-1, 1);
82 if (! db.
Con()->Exec(query.c_str())) {
83 cerr <<
"!!ERROR!! CalibParamInTimeV1495::WriteToDB(): in insert. Abort." << endl;
89 const std::string det,
const short ele,
const short lvl,
90 const double center,
const double width)
96 if (det ==
"STOP" ) { det_id = 1000; }
97 else if (det ==
"L1PXtp") { det_id = 1001; }
98 else if (det ==
"L1PXtn") { det_id = 1002; }
99 else if (det ==
"L1PXbp") { det_id = 1003; }
100 else if (det ==
"L1PXbn") { det_id = 1004; }
105 Add(det, det_id, ele, lvl, center, width);
107 if (ele_new != ele) {
108 cout <<
"!WARNING! CalibParamInTimeV1495::Add(): The GeomSvc conversion changed element ID unexpectedly:\n"
109 <<
" From det = " << det <<
", ele = " << ele <<
"\n"
110 <<
" To det = " << det_new <<
"(id = " << det_id <<
"), ele = " << ele_new <<
"\n"
111 <<
" The mapping result will be incorrect!!" << endl;
116 const std::string det_name,
const short det_id,
const short ele,
const short lvl,
117 const double center,
const double width)
120 item.det_name = det_name;
124 item.center = center;
126 m_list.push_back(item);
127 m_map[DetEleLvl_t(det_id, ele, lvl)] = CenterWidth_t(center, width);
132 DetEleLvl_t key(det, ele, lvl);
133 if (m_map.find(key) != m_map.end()) {
134 CenterWidth_t* val = &m_map[key];
138 }
else if (ele != 0) {
139 return Find(det, 0, lvl, center, width);
148 for (List_t::iterator it = m_list.begin(); it != m_list.end(); it++) {
149 os << it->det_name <<
"\t" << it->det <<
"\t" << it->ele <<
"\t" << it->lvl <<
"\t"
150 << it->center <<
"\t" << it->width <<
"\n";
153 cout <<
" n = " << n_ent << endl;
void Print(std::ostream &os)
int ReadFileCont(LineList &lines)
void ReadDbTable(DbSvc &db)
bool Find(const short det, const short ele, const short lvl, double ¢er, double &width)
void Add(const std::string det, const short ele, const short lvl, const double center, const double width)
void WriteDbTable(DbSvc &db)
int WriteFileCont(std::ostream &os)
Standard interface with SQL database.
TSQLStatement * Process(const char *query)
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)
User interface class about the geometry of detector planes.
int getDetectorID(const std::string &detectorName) const
Get the plane position.
static GeomSvc * instance()
singlton instance
void toLocalDetectorName(std::string &detectorName, int &eID)
Convert the official detectorName to local detectorName.
std::vector< std::string > LineList
std::string MapTableName()