6 #include <TSQLServer.h> 
    7 #include <TSQLStatement.h> 
   23   for (LineList::iterator it = lines.begin(); it != lines.end(); it++) {
 
   27     short  ele, roc, board, chan;
 
   28     if (! (iss >> det >> ele >> roc >> board >> chan)) 
continue;
 
   29     Add(roc, board, chan, det, ele);
 
   38   for (List_t::iterator it = m_list.begin(); it != m_list.end(); it++) {
 
   39     os << it->det_name << 
"\t" << it->ele << 
"\t" 
   40        << it->roc << 
"\t" << it->board << 
"\t" << it->chan << 
"\n";
 
   49   oss << 
"select roc, board, chan, det_name, det, ele from " << 
MapTableName();
 
   50   TSQLStatement* stmt = db.
Process(oss.str());
 
   51   while (stmt->NextResultRow()) {
 
   52     short  roc      = stmt->GetInt   (0);
 
   53     short  board    = stmt->GetInt   (1);
 
   54     short  chan     = stmt->GetInt   (2);
 
   55     string det_name = stmt->GetString(3);
 
   56     short  det      = stmt->GetInt   (4);
 
   57     short  ele      = stmt->GetInt   (5);
 
   58     Add(roc, board, chan, det_name, det, ele);
 
   67   const char* list_var [] = {      
"roc",    
"board",     
"chan",    
"det_name",      
"det",      
"ele" };
 
   68   const char* list_type[] = { 
"SMALLINT", 
"SMALLINT", 
"SMALLINT", 
"VARCHAR(32)", 
"SMALLINT", 
"SMALLINT" };
 
   70   db.
CreateTable(name_table, n_var, list_var, list_type);
 
   73   oss << 
"insert into " << name_table << 
"(roc, board, chan, det_name, det, ele) values";
 
   74   for (List_t::iterator it = m_list.begin(); it != m_list.end(); it++) {
 
   75     oss << 
" (" << it->roc << 
", " << it->board << 
", " << it->chan
 
   76         << 
", '" << it->det_name << 
"', " << it->det << 
", " << it->ele << 
"),";
 
   78   string query = oss.str();
 
   79   query.erase(query.length()-1, 1); 
 
   80   if (! db.
Con()->Exec(query.c_str())) {
 
   81     cerr << 
"!!ERROR!!  ChanMapTaiwan::WriteToDB():  in insert.  Abort." << endl;
 
   87   const short roc, 
const short board, 
const short chan, 
 
   88   const std::string det, 
const short ele)
 
   95   Add(roc, board, chan, det, det_id, ele);
 
   98     cout << 
"!WARNING!  ChanMapTaiwan::Add():  The GeomSvc conversion changed element ID unexpectedly:\n" 
   99          << 
"  From det = " << det << 
", ele = " << ele << 
"\n" 
  100          << 
"  To   det = " << det_new << 
"(id = " << det_id << 
"), ele = " << ele_new << 
"\n" 
  101          << 
"  The mapping result will be incorrect!!" << endl;
 
  106   const short roc, 
const short board, 
const short chan, 
 
  107   const std::string det_name, 
const short det_id, 
const short ele)
 
  113   item.det_name = det_name;
 
  116   m_list.push_back(item);
 
  137   if (m_map.find(key) != m_map.end()) {
 
  138     DetEle_t* det_ele = &m_map[key];
 
  139     det = det_ele->first;
 
  140     ele = det_ele->second;
 
  151   for (List_t::iterator it = m_list.begin(); it != m_list.end(); it++) {
 
  152     os << it->det_name << 
"\t" << it->det << 
"\t" << it->ele << 
"\t" 
  153        << it->roc << 
"\t" << it->board << 
"\t" << it->chan << 
"\n";
 
  156   cout << 
"  n = " << n_ent << endl;
 
std::tuple< short, short, short > RocBoardChan_t
void WriteDbTable(DbSvc &db)
void ReadDbTable(DbSvc &db)
int ReadFileCont(LineList &lines)
int WriteFileCont(std::ostream &os)
void Add(const short roc, const short board, const short chan, const std::string det, const short ele)
void Print(std::ostream &os)
bool Find(const short roc, const short board, const short chan, short &det, short &ele)
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()