41 {
42
43
44 char stmt1[1024];
45 int run_No = std::abs(
runNo );
46 sprintf( stmt1,
"select EQM_fileid,EMCGain from RunParams where run_number = %d", run_No );
47
48 DatabaseRecordVector results;
50 int rowNumber = m_dbsvc->query( "run", stmt1, results );
51 if ( rowNumber <= 0 )
52 {
53 std::cout << "ERROR Read EQM_fileid from the Database, exit." << endmsg;
54 exit( 1 );
55 }
56
57 int fileid = std::atoi( ( *results[0] )["EQM_fileid"] );
58
59 string gainnum( ( *results[0] )["EMCGain"] );
60
62 "select "
63 "OID,Position,Channel1,Channel2,Channel3,Channel4,Channel5,Channel6,Channel7,"
64 "Channel8,Channel9,Channel10,Channel11,"
65 "Channel12,Channel13,Channel14,Channel15,Channel16,Channel17,Channel18,Channel19,"
66 "Channel20,Channel21,Channel22,Channel23,"
67 "Channel24,Channel25,Channel26,Channel27,Channel28,Channel29,Channel30,Channel31,"
68 "Channel32 from EQM where FileId=%d",
69 fileid );
70
72 rowNumber = m_dbsvc->query( "run", stmt1, results );
73 if ( rowNumber <= 0 )
74 {
75 std::cout << "ERROR Read EQM from the Database, exit." << endmsg;
76 exit( 1 );
77 }
78
79 std::map<std::string, std::vector<std::string>> map_EQM;
80 map_EQM.clear();
81 for ( int i = 0; i < rowNumber; i++ )
82 {
83 for ( int j = 2; j < 34; j++ )
84 {
85 std::vector<std::string> vec_tmp;
86 vec_tmp.clear();
88 vec_tmp.push_back( ( *results[i] )["OID"] );
89 vec_tmp.push_back( ( *results[i] )["Position"] );
90 typedef pair<std::string, std::vector<std::string>> vpair;
91 map_EQM.insert(
92 vpair( ( *results[i] )[
"Channel" +
toString<int>( j - 1 )], vec_tmp ) );
93 }
94 }
95
96 vector<string>
id =
split( ids,
",",
"<null>" );
97 id_num = id.size();
98
99 for ( unsigned int m = 0; m < id.size(); m++ )
100 {
101 if ( id[m] == "0" )
102 {
103 std::cout << " error: No." << m + 1 << " id=0,please delete it! " << std::endl;
104 break;
105 }
106 if ( id[m] == "NULL" )
107 {
108 std::cout << " end of loop! " << std::endl;
109 break;
110 }
111 string channelnum, oid, modu;
112 bool if_found = false;
113 for ( std::map<std::string, std::vector<std::string>>::iterator
iter = map_EQM.begin();
115 {
116 if (
iter->first ==
id[m] )
117 {
118 if_found = true;
119 channelnum =
iter->second[0];
120 oid =
iter->second[1];
121 modu =
iter->second[2];
122 }
123 }
124
125 if ( !if_found )
126 {
127 std::cout << "can not find id " << id[m] << " in EQM, exit." << std::endl;
128 exit( 1 );
129 }
130
131 string b = "AAAA";
132 string trgcratenum;
133 for ( int i = 0; i < 4; i++ ) { b[i] = oid[i + 4]; }
134
135
136 string a[16][2] = {
137 { "E3_1", "96" }, { "E2_0", "97" }, { "E2_1", "98" }, { "E1_0", "99" },
138 { "E1_1", "100" }, { "E3_0", "101" }, { "E2_2", "102" }, { "E3_2", "103" },
139 { "W3_1", "112" }, { "W2_0", "113" }, { "W2_1", "114" }, { "W1_0", "115" },
140 { "W1_1", "116" }, { "W3_0", "117" }, { "W2_2", "118" }, { "W3_2", "119" } };
141 string trgCrate[16] = { "0x60", "0x61", "0x62", "0x63", "0x64", "0x65", "0x66", "0x67",
142 "0x70", "0x71", "0x72", "0x73", "0x74", "0x75", "0x76", "0x77" };
143
144 for ( int i = 0; i < 16; i++ )
145 {
146 if ( b.compare( a[i][0] ) ) continue;
147 else { trgcratenum = trgCrate[i]; }
148 }
149
150 std::string query_name = "select gain from EMC_Gain where run_id=" + gainnum +
151 " and ppc_id=\"" + trgcratenum + "\" and Qmodule_no=" + modu +
152 " and Qchannel_no=" + channelnum;
154 rowNumber = m_dbsvc->query( "run", query_name.c_str(), results );
155 if ( rowNumber <= 0 )
156 {
157 std::cout << "ERROR Read gain from EMC_Gain Database, exit." << endmsg;
158 exit( 1 );
159 }
160
161
162
163
164 trgGain[m] = new std::string( ( *results[0] )["gain"] );
165
166 }
167 return true;
168 }
sprintf(cut, "kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_" "pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
std::vector< std::string > split(const std::string &src, std::string delimit, std::string null_subst="")
std::string toString(type obj)