6 #include <TSQLServer.h>
7 #include <TSQLStatement.h>
8 #include <TGraphErrors.h>
22 for (Map_t::iterator it = m_map_t2x .begin(); it != m_map_t2x .end(); it++)
delete it->second;
23 for (Map_t::iterator it = m_map_t2dx.begin(); it != m_map_t2dx.end(); it++)
delete it->second;
30 for (LineList::iterator it = lines.begin(); it != lines.end(); it++) {
35 if (! (iss >> det >> t >> x >> dx))
continue;
45 for (List_t::iterator it = m_list.begin(); it != m_list.end(); it++) {
46 os << it->det_name <<
"\t"
47 << it->t <<
"\t" << it->x <<
"\t" << it->dx <<
"\n";
56 oss <<
"select det_name, det, t, x, dx from " <<
MapTableName();
57 TSQLStatement* stmt = db.
Process(oss.str());
58 while (stmt->NextResultRow()) {
59 string det_name = stmt->GetString(0);
60 short det = stmt->GetInt (1);
61 double t = stmt->GetDouble(2);
62 double x = stmt->GetDouble(3);
63 double dx = stmt->GetDouble(4);
64 Add(det_name, det, t, x, dx);
73 const char* list_var [] = {
"det_name",
"det",
"t",
"x",
"dx" };
74 const char* list_type[] = {
"VARCHAR(32)",
"SMALLINT",
"DOUBLE",
"DOUBLE",
"DOUBLE" };
76 db.
CreateTable(name_table, n_var, list_var, list_type);
79 oss <<
"insert into " << name_table <<
"(det_name, det, t, x, dx) values";
80 for (List_t::iterator it = m_list.begin(); it != m_list.end(); it++) {
81 oss <<
" ('" << it->det_name <<
"', " << it->det <<
", "
82 << it->t <<
", " << it->x <<
", " << it->dx <<
"),";
84 string query = oss.str();
85 query.erase(query.length()-1, 1);
86 if (! db.
Con()->Exec(query.c_str())) {
87 cerr <<
"!!ERROR!! CalibParamXT::WriteToDB(): in insert. Abort." << endl;
93 const std::string det,
94 const double t,
const double x,
const double dx)
100 if (det[0] ==
'P' && det.length() == 3) {
101 Add(det +
"1f", t, x, dx);
102 Add(det +
"1b", t, x, dx);
108 string det_new = det;
112 Add(det, det_id, t, x, dx);
123 const std::string det_name,
const short det_id,
124 const double t,
const double x,
const double dx)
127 item.det_name = det_name;
132 m_list.push_back(item);
133 TGraphErrors* gr_t2x;
134 TGraphErrors* gr_t2dx;
135 if (m_map_t2x.find(det_id) == m_map_t2x.end()) {
136 m_map_t2x [det_id] = gr_t2x =
new TGraphErrors();
137 m_map_t2dx[det_id] = gr_t2dx =
new TGraphErrors();
139 gr_t2x = m_map_t2x [det_id];
140 gr_t2dx = m_map_t2dx[det_id];
142 int n_pt = gr_t2x->GetN();
143 gr_t2x ->SetPoint(n_pt, t, x);
144 gr_t2dx->SetPoint(n_pt, t, dx);
145 gr_t2x ->SetPointError(n_pt, 0, dx);
150 if (m_map_t2x.find(det) != m_map_t2x.end()) {
151 gr_t2x = m_map_t2x [det];
152 gr_t2dx = m_map_t2dx[det];
155 gr_t2x = gr_t2dx = 0;
std::string MapTableName()
void Print(std::ostream &os)
void WriteDbTable(DbSvc &db)
std::vector< std::string > LineList
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)
int ReadFileCont(LineList &lines)
static GeomSvc * instance()
singlton instance
void toLocalDetectorName(std::string &detectorName, int &eID)
Convert the official detectorName to local detectorName.
bool Find(const short det, TGraphErrors *&gr_t2x, TGraphErrors *&gr_t2dx)
int getDetectorID(const std::string &detectorName) const
Get the plane position.
int WriteFileCont(std::ostream &os)
void Add(const std::string det, const double t, const double x, const double dx)
void ReadDbTable(DbSvc &db)