31 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalTPGOddWeightGroupHandler")) {
32 edm::LogInfo(
"EcalTPGOddWeightGroupHandler") <<
"EcalTPGOddWeightGroup Source handler constructor.";
51 if (m_file_type ==
"txt") {
53 }
else if (m_file_type ==
"xml") {
56 edm::LogInfo(
"EcalTPGOddWeightGroupHandler") <<
"Started GetNewObjects!!!";
61 std::cout <<
"got offlineInfo = " << std::endl;
65 std::cout <<
" First object for this tag " << std::endl;
68 unsigned int max_since = 0;
69 max_since =
static_cast<unsigned int>(
tagInfo().lastInterval.since);
70 edm::LogInfo(
"EcalTPGOddWeightGroupHandler") <<
"max_since : " << max_since;
72 edm::LogInfo(
"EcalTPGOddWeightGroupHandler") <<
"retrieved last payload ";
76 edm::LogInfo(
"EcalTPGOddWeightGroupHandler") <<
"Retrieving run list from ONLINE DB ... ";
78 edm::LogInfo(
"EcalTPGOddWeightGroupHandler") <<
"Making connection...";
83 std::cout <<
" connection parameters " << m_sid <<
"/" << m_user << std::endl;
99 readFromFile(
"last_tpg_OddweightGroup_settings.txt");
101 unsigned int min_run;
103 if (m_firstRun < m_i_run_number) {
104 min_run = m_i_run_number + 1;
106 min_run = m_firstRun;
109 if (min_run < max_since) {
110 min_run = max_since + 1;
113 std::cout <<
"m_i_run_number" << m_i_run_number <<
"m_firstRun " << m_firstRun <<
"max_since " << max_since
116 unsigned int max_run = m_lastRun;
117 edm::LogInfo(
"EcalTPGOddWeightGroupHandler") <<
"min_run= " << min_run <<
" max_run= " << max_run;
120 my_list =
econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run,
my_locdef);
123 std::vector<RunIOV> run_vec = my_list.
getRuns();
124 size_t num_runs = run_vec.size();
126 std::cout <<
"number of runs is : " << num_runs << std::endl;
128 unsigned int irun = 0;
131 std::vector<EcalLogicID> my_StripEcalLogicId_EE;
132 my_StripEcalLogicId_EE =
133 econn->getEcalLogicIDSetOrdered(
"ECAL_readout_strip", 1, 2000, 1, 70, 0, 5,
"EE_offline_stripid", 123);
135 std::cout <<
" GOT the logic ID for the EE trigger strips " << std::endl;
137 for (
size_t kr = 0; kr < run_vec.size(); kr++) {
138 irun =
static_cast<unsigned int>(run_vec[kr].getRunNumber());
140 std::cout <<
" **************** " << std::endl;
141 std::cout <<
" **************** " << std::endl;
142 std::cout <<
" run= " << irun << std::endl;
145 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
149 int the_config_version = 0;
151 std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
165 std::cout <<
" run= " << irun <<
" tag " << the_config_tag <<
" version=" << the_config_version << std::endl;
169 if ((the_config_tag != m_i_tag || the_config_version != m_i_version) &&
nr > 0) {
170 std::cout <<
"the tag is different from last transferred run ... retrieving last config set from DB" 178 std::cout <<
" before fetch config set" << std::endl;
179 econn->fetchConfigSet(&fe_main_info);
180 std::cout <<
" after fetch config set" << std::endl;
185 if (wId != m_i_oddweightGroup) {
187 fe_oddw_info.
setId(wId);
188 econn->fetchConfigSet(&fe_oddw_info);
189 std::map<EcalLogicID, FEConfigOddWeightDat> dataset_TpgW;
190 econn->fetchDataSet(&dataset_TpgW, &fe_oddw_info);
193 typedef std::map<EcalLogicID, FEConfigOddWeightDat>::const_iterator CIfesli;
197 std::map<std::string, int>
map;
200 for (CIfesli
p = dataset_TpgW.begin();
p != dataset_TpgW.end();
p++) {
202 weightGroup =
p->second.getWeightGroupId();
207 if (ecid_name ==
"EB_VFE") {
208 int sm = ecid_xt.
getID1();
217 unsigned int stripEBId = 303176 + (
tt - 1) * 64 + (
strip - 1) * 8 + (tcc - 37) * 8192;
219 weightG->
setValue(stripEBId, weightGroup);
220 }
else if (ecid_name ==
"ECAL_readout_strip") {
224 int id3 = ecid_xt.
getID3();
226 bool set_the_strip =
false;
228 for (
size_t istrip = 0; istrip < my_StripEcalLogicId_EE.size(); istrip++) {
229 if (!set_the_strip) {
230 if (my_StripEcalLogicId_EE[istrip].getID1() ==
id1 &&
231 my_StripEcalLogicId_EE[istrip].getID2() ==
id2 &&
232 my_StripEcalLogicId_EE[istrip].getID3() == id3) {
233 stripEEId = my_StripEcalLogicId_EE[istrip].getLogicID();
234 set_the_strip =
true;
241 weightG->
setValue(stripEEId, weightGroup);
244 std::cout <<
" these may be the additional towers TCC/TT " <<
id1 <<
"/" <<
id2 << std::endl;
253 m_i_run_number = irun;
254 m_i_tag = the_config_tag;
255 m_i_version = the_config_version;
256 m_i_oddweightGroup = wId;
258 writeFile(
"last_tpg_OddweightGroup_settings.txt");
261 m_i_run_number = irun;
262 m_i_tag = the_config_tag;
263 m_i_version = the_config_version;
265 writeFile(
"last_tpg_OddweightGroup_settings.txt");
268 <<
" even if the tag/version is not the same, the weight group id is the same -> no transfer needed " 275 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag
276 <<
" version=" << the_config_version << std::endl;
278 m_i_run_number = irun;
280 std::cout <<
" **************** " << std::endl;
282 }
else if (
nr == 0) {
283 m_i_run_number = irun;
284 std::cout <<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
285 std::cout <<
" **************** " << std::endl;
287 m_i_run_number = irun;
288 m_i_tag = the_config_tag;
289 m_i_version = the_config_version;
290 std::cout <<
" the tag/version is the same -> no transfer needed " << std::endl;
291 std::cout <<
" **************** " << std::endl;
292 writeFile(
"last_tpg_OddweightGroup_settings.txt");
299 edm::LogInfo(
"EcalTPGOddWeightGroupHandler") <<
"Ecal - > end of getNewObjects -----------";
303 std::cout <<
" reading the input file " << m_file_name << std::endl;
304 std::ifstream fInput;
305 fInput.open(m_file_name);
306 if (!fInput.is_open()) {
307 std::cout <<
"ERROR : cannot open file " << m_file_name << std::endl;
310 int weightGroup, stripEBId, stripEEId;
313 fInput >> stripEBId >> weightGroup;
314 weightG->
setValue(stripEBId, weightGroup);
317 fInput >> stripEEId >> weightGroup;
318 weightG->
setValue(stripEEId, weightGroup);
324 std::cout <<
"EcalTPGOddWeightGroupHandler::readtxtFile error : " <<
e.what() << std::endl;
326 std::cout <<
" **************** " << std::endl;
330 std::cout <<
" reading the input file " << m_file_name << std::endl;
332 fxml.open(m_file_name);
333 if (!fxml.is_open()) {
334 std::cout <<
"ERROR : cannot open file " << m_file_name << std::endl;
338 int weightGroup, stripEBId, stripEEId;
340 for (
int i = 0;
i < 6;
i++)
341 std::getline(fxml, dummyLine);
344 std::size_t
found = bid.find(
"</");
346 for (
int i = 0;
i < 2;
i++)
347 std::getline(fxml, dummyLine);
349 std::getline(fxml, dummyLine);
351 found = bid.find(
"</");
352 stt = bid.substr(7,
found - 7);
353 std::istringstream sg1(stt);
355 std::getline(fxml, dummyLine);
357 found = bid.find(
"</");
358 stt = bid.substr(8,
found - 8);
359 std::istringstream sg2(stt);
361 weightG->
setValue(stripEBId, weightGroup);
362 for (
int i = 0;
i < 2;
i++)
363 std::getline(fxml, dummyLine);
366 std::getline(fxml, dummyLine);
368 found = bid.find(
"</");
369 stt = bid.substr(7,
found - 7);
370 std::istringstream sg1(stt);
372 std::getline(fxml, dummyLine);
374 found = bid.find(
"</");
375 stt = bid.substr(8,
found - 8);
376 std::istringstream sg2(stt);
378 weightG->
setValue(stripEEId, weightGroup);
379 for (
int i = 0;
i < 2;
i++)
380 std::getline(fxml, dummyLine);
386 std::cout <<
"EcalTPGOddWeightGroupHandler::readtxtFile error : " <<
e.what() << std::endl;
388 std::cout <<
" **************** " << std::endl;
397 m_i_oddweightGroup = 0;
408 std::ostringstream
str;
410 fgets(
line, 255, inpFile);
412 str <<
"gen tag " << m_i_tag << std::endl;
414 fgets(
line, 255, inpFile);
415 m_i_version = atoi(
line);
416 str <<
"version= " << m_i_version << std::endl;
418 fgets(
line, 255, inpFile);
419 m_i_run_number = atoi(
line);
420 str <<
"run_number= " << m_i_run_number << std::endl;
422 fgets(
line, 255, inpFile);
423 m_i_oddweightGroup = atoi(
line);
424 str <<
"weightGroup_config= " << m_i_oddweightGroup << std::endl;
432 std::ofstream myfile;
434 myfile << m_i_tag << std::endl;
435 myfile << m_i_version << std::endl;
436 myfile << m_i_run_number << std::endl;
437 myfile << m_i_oddweightGroup << std::endl;
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
T getParameter(std::string const &) const
std::string getName() const
void getNewObjects() override
Log< level::Error, false > LogError
static std::string to_string(const XMLCh *ch)
~EcalTPGOddWeightGroupHandler() override
void setValue(const uint32_t &rawId, const uint32_t &ObjectId)
void setLocationDef(const LocationDef &locDef)
Log< level::Info, false > LogInfo
std::string m_locationsource
std::string getConfigTag() const
void setConfigTag(std::string x)
void readFromFile(const char *inputFile)
void writeFile(const char *inputFile)
void setGeneralTag(std::string tag)
EcalTPGOddWeightGroupHandler(edm::ParameterSet const &)