23 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalTPGOddWeightIdMapHandler")) {
24 edm::LogInfo(
"EcalTPGOddWeightIdMapHandler") <<
"EcalTPGOddWeightIdMap Source handler constructor";
43 if (m_file_type ==
"txt") {
45 }
else if (m_file_type ==
"xml") {
48 edm::LogInfo(
"EcalTPGOddWeightIdMapHandler") <<
"Started GetNewObjects!!!";
53 std::cout <<
"got offlineInfo = " << std::endl;
57 std::cout <<
" First object for this tag " << std::endl;
60 unsigned int max_since = 0;
61 max_since = static_cast<unsigned int>(
tagInfo().lastInterval.since);
62 edm::LogInfo(
"EcalTPGOddWeightIdMapHandler") <<
"max_since : " << max_since;
65 edm::LogInfo(
"EcalTPGOddWeightIdMapHandler") <<
"retrieved last payload ";
68 edm::LogInfo(
"EcalTPGOddWeightIdMapHandler") <<
"Retrieving run list from ONLINE DB ... ";
70 edm::LogInfo(
"EcalTPGOddWeightIdMapHandler") <<
"Making connection...";
75 std::cout <<
" connection parameters " << m_sid <<
"/" << m_user << std::endl;
93 unsigned int min_run = m_i_run_number + 1;
95 if (m_firstRun < m_i_run_number) {
96 min_run = m_i_run_number + 1;
101 if (min_run < max_since) {
102 min_run = max_since + 1;
105 std::cout <<
"m_i_run_number" << m_i_run_number <<
"m_firstRun " << m_firstRun <<
"max_since " << max_since
108 unsigned int max_run = m_lastRun;
109 edm::LogInfo(
"EcalTPGOddWeightIdMapHandler") <<
"min_run= " << min_run <<
"max_run= " << max_run;
112 my_list =
econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run,
my_locdef);
115 std::vector<RunIOV> run_vec = my_list.
getRuns();
116 size_t num_runs = run_vec.size();
117 edm::LogInfo(
"EcalTPGOddWeightIdMapHandler") <<
"number of Mon runs is : " << num_runs;
121 for (
size_t kr = 0; kr < run_vec.size(); kr++) {
122 irun = static_cast<unsigned int>(run_vec[kr].
getRunNumber());
124 std::cout <<
" **************** " << std::endl;
125 std::cout <<
" **************** " << std::endl;
126 std::cout <<
" run= " << irun << std::endl;
129 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
133 int the_config_version = 0;
135 std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
148 std::cout <<
" run= " << irun <<
" tag " << the_config_tag <<
" version=" << the_config_version << std::endl;
152 if ((the_config_tag != m_i_tag || the_config_version != m_i_version) &&
nr > 0) {
153 std::cout <<
"the tag is different from last transferred run ... retrieving last config set from DB"
161 std::cout <<
" before fetch config set" << std::endl;
162 econn->fetchConfigSet(&fe_main_info);
163 std::cout <<
" after fetch config set" << std::endl;
168 if (weightId != m_i_oddweightIdMap) {
170 fe_odd_weight_info.
setId(weightId);
171 econn->fetchConfigSet(&fe_odd_weight_info);
172 std::map<EcalLogicID, FEConfigOddWeightGroupDat> dataset_TpgWeight;
173 econn->fetchDataSet(&dataset_TpgWeight, &fe_odd_weight_info);
174 edm::LogInfo(
"EcalTPGOddWeightIdMapHandler") <<
"Got object!";
176 typedef std::map<EcalLogicID, FEConfigOddWeightGroupDat>::const_iterator CIfeweight;
181 for (CIfeweight
p = dataset_TpgWeight.begin();
p != dataset_TpgWeight.end();
p++) {
185 unsigned int weight0 = static_cast<unsigned int>(rd_w.
getWeight4());
186 unsigned int weight1 = static_cast<unsigned int>(rd_w.
getWeight3());
187 unsigned int weight2 = static_cast<unsigned int>(rd_w.
getWeight2());
188 unsigned int weight3 = static_cast<unsigned int>(rd_w.
getWeight1() - 0x80);
189 unsigned int weight4 = static_cast<unsigned int>(rd_w.
getWeight0());
191 w.setValues(weight0, weight1, weight2, weight3, weight4);
197 edm::LogInfo(
"EcalTPGOddWeightIdMapHandler") <<
"found " << igroups <<
"Weight groups";
202 m_i_run_number = irun;
203 m_i_tag = the_config_tag;
204 m_i_version = the_config_version;
205 m_i_oddweightIdMap = weightId;
207 writeFile(
"last_tpg_OddweightIdMap_settings.txt");
210 m_i_run_number = irun;
211 m_i_tag = the_config_tag;
212 m_i_version = the_config_version;
214 writeFile(
"last_tpg_OddweightIdMap_settings.txt");
217 <<
" even if the tag/version is not the same, the weightIdMap id is the same -> no transfer needed "
222 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag
223 <<
" version=" << the_config_version << std::endl;
225 m_i_run_number = irun;
227 std::cout <<
" **************** " << std::endl;
229 }
else if (
nr == 0) {
230 m_i_run_number = irun;
231 std::cout <<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
232 std::cout <<
" **************** " << std::endl;
234 m_i_run_number = irun;
235 m_i_tag = the_config_tag;
236 m_i_version = the_config_version;
237 std::cout <<
" the tag/version is the same -> no transfer needed " << std::endl;
238 std::cout <<
" **************** " << std::endl;
239 writeFile(
"last_tpg_OddweightIdMap_settings.txt");
246 edm::LogInfo(
"EcalTPGOddWeightIdMapHandler") <<
"Ecal - > end of getNewObjects -----------";
249 std::cout <<
" reading the input file " << m_file_name << std::endl;
250 std::ifstream fInput;
251 fInput.open(m_file_name);
252 if (!fInput.is_open()) {
253 std::cout <<
"ERROR : cannot open file " << m_file_name << std::endl;
256 unsigned int wloc[5];
261 while (!fInput.eof()) {
262 getline(fInput,
line);
264 std::stringstream
ss;
266 ss >> wloc[0] >> wloc[1] >> wloc[2] >> wloc[3] >> wloc[4];
268 w.setValues(wloc[0], wloc[1], wloc[2], wloc[3], wloc[4]);
273 edm::LogInfo(
"EcalTPGOddWeightIdMapHandler") <<
"found " << igroups <<
" Weight groups";
278 std::cout <<
"EcalTPGOddWeightIdMapHandler::readtxtFile error : " <<
e.what() << std::endl;
280 std::cout <<
" **************** " << std::endl;
284 std::cout <<
" reading the input file " << m_file_name << std::endl;
286 fxml.open(m_file_name);
287 if (!fxml.is_open()) {
288 std::cout <<
"ERROR : cannot open file " << m_file_name << std::endl;
292 unsigned int wloc[5];
295 int ngroups, igroups;
296 for (
int i = 0;
i < 5;
i++)
297 std::getline(fxml, dummyLine);
301 std::istringstream sc(stt);
303 edm::LogInfo(
"EcalTPGOddWeightIdMapHandler") <<
"found " << ngroups <<
" Weight groups";
304 for (
int i = 0;
i < 2;
i++)
305 std::getline(fxml, dummyLine);
307 for (
int i = 0;
i < ngroups;
i++) {
308 std::getline(fxml, dummyLine);
311 std::size_t
found = bid.find(
"</");
312 stt = bid.substr(7,
found - 7);
313 std::istringstream sg1(stt);
316 std::cout <<
" group " <<
i <<
": " << bid <<
" igroups " << igroups << std::endl;
319 for (
int i = 0;
i < 2;
i++)
320 std::getline(fxml, dummyLine);
321 for (
int i = 0;
i < 5;
i++) {
323 found = bid.find(
"</");
324 stt = bid.substr(5,
found - 5);
325 std::istringstream
w(stt);
328 w.setValues(wloc[0], wloc[1], wloc[2], wloc[3], wloc[4]);
330 for (
int i = 0;
i < 3;
i++)
331 std::getline(fxml, dummyLine);
338 std::cout <<
"EcalTPGOddWeightIdMapHandler::readxmlFile error : " <<
e.what() << std::endl;
340 std::cout <<
" **************** " << std::endl;
349 m_i_oddweightIdMap = 0;
360 std::ostringstream
str;
362 fgets(
line, 255, inpFile);
363 m_i_tag = to_string(
line);
364 str <<
"gen tag " << m_i_tag << std::endl;
366 fgets(
line, 255, inpFile);
367 m_i_version = atoi(
line);
368 str <<
"version= " << m_i_version << std::endl;
370 fgets(
line, 255, inpFile);
371 m_i_run_number = atoi(
line);
372 str <<
"run_number= " << m_i_run_number << std::endl;
374 fgets(
line, 255, inpFile);
375 m_i_oddweightIdMap = atoi(
line);
376 str <<
"weightIdMap_config= " << m_i_oddweightIdMap << std::endl;
384 std::ofstream myfile;
386 myfile << m_i_tag << std::endl;
387 myfile << m_i_version << std::endl;
388 myfile << m_i_run_number << std::endl;
389 myfile << m_i_oddweightIdMap << std::endl;