31 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalTPGWeightGroupHandler")) {
32 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"EcalTPGWeightGroup Source handler constructor.";
51 if (m_file_type ==
"txt") {
53 }
else if (m_file_type ==
"xml") {
56 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"Started GetNewObjects!!!";
68 unsigned int max_since = 0;
69 max_since =
static_cast<unsigned int>(
tagInfo().lastInterval.since);
70 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"max_since : " << max_since;
72 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"retrieved last payload ";
76 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"Retrieving run list from ONLINE DB ... ";
78 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"Making connection...";
83 edm::LogInfo(
" connection parameters ") << m_sid <<
"/" << m_user;
99 readFromFile(
"last_tpg_weightGroup_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 edm::LogInfo(
"m_i_run_number") << m_i_run_number <<
"m_firstRun " << m_firstRun <<
"max_since " << max_since;
115 unsigned int max_run = m_lastRun;
116 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"min_run= " << min_run <<
" max_run= " << max_run;
119 my_list =
econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run,
my_locdef);
122 std::vector<RunIOV> run_vec = my_list.
getRuns();
123 size_t num_runs = run_vec.size();
127 unsigned int irun = 0;
130 std::vector<EcalLogicID> my_StripEcalLogicId_EE;
131 my_StripEcalLogicId_EE =
132 econn->getEcalLogicIDSetOrdered(
"ECAL_readout_strip", 1, 2000, 1, 70, 0, 5,
"EE_offline_stripid", 123);
134 edm::LogInfo(
" GOT the logic ID for the EE trigger strips ");
136 for (
size_t kr = 0; kr < run_vec.size(); kr++) {
137 irun =
static_cast<unsigned int>(run_vec[kr].getRunNumber());
144 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
148 int the_config_version = 0;
150 std::map<EcalLogicID, RunTPGConfigDat>::const_iterator
it;
164 edm::LogInfo(
" run= ") << irun <<
" tag " << the_config_tag <<
" version=" << the_config_version;
168 if ((the_config_tag != m_i_tag || the_config_version != m_i_version) &&
nr > 0) {
169 edm::LogInfo(
"the tag is different from last transferred run ... retrieving last config set from DB");
177 econn->fetchConfigSet(&fe_main_info);
183 if (wId != m_i_weightGroup) {
185 fe_w_info.
setId(wId);
186 econn->fetchConfigSet(&fe_w_info);
187 std::map<EcalLogicID, FEConfigWeightDat> dataset_TpgW;
188 econn->fetchDataSet(&dataset_TpgW, &fe_w_info);
191 typedef std::map<EcalLogicID, FEConfigWeightDat>::const_iterator CIfesli;
195 std::map<std::string, int>
map;
198 for (CIfesli
p = dataset_TpgW.begin();
p != dataset_TpgW.end();
p++) {
200 weightGroup =
p->second.getWeightGroupId();
205 if (ecid_name ==
"EB_VFE") {
215 unsigned int stripEBId = 303176 + (
tt - 1) * 64 + (
strip - 1) * 8 + (tcc - 37) * 8192;
217 weightG->
setValue(stripEBId, weightGroup);
218 }
else if (ecid_name ==
"ECAL_readout_strip") {
222 int id3 = ecid_xt.
getID3();
224 bool set_the_strip =
false;
226 for (
size_t istrip = 0; istrip < my_StripEcalLogicId_EE.size(); istrip++) {
227 if (!set_the_strip) {
228 if (my_StripEcalLogicId_EE[istrip].getID1() ==
id1 &&
229 my_StripEcalLogicId_EE[istrip].getID2() ==
id2 &&
230 my_StripEcalLogicId_EE[istrip].getID3() == id3) {
231 stripEEId = my_StripEcalLogicId_EE[istrip].getLogicID();
232 set_the_strip =
true;
239 weightG->
setValue(stripEEId, weightGroup);
251 m_i_run_number = irun;
252 m_i_tag = the_config_tag;
253 m_i_version = the_config_version;
254 m_i_weightGroup = wId;
256 writeFile(
"last_tpg_weightGroup_settings.txt");
259 m_i_run_number = irun;
260 m_i_tag = the_config_tag;
261 m_i_version = the_config_version;
263 writeFile(
"last_tpg_weightGroup_settings.txt");
266 " even if the tag/version is not the same, the weight group id is the same -> no transfer needed ");
273 << the_config_tag <<
" version=" << the_config_version;
275 m_i_run_number = irun;
279 }
else if (
nr == 0) {
280 m_i_run_number = irun;
281 edm::LogInfo(
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed ");
284 m_i_run_number = irun;
285 m_i_tag = the_config_tag;
286 m_i_version = the_config_version;
287 edm::LogInfo(
" the tag/version is the same -> no transfer needed ");
289 writeFile(
"last_tpg_weightGroup_settings.txt");
296 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"Ecal - > end of getNewObjects -----------";
300 edm::LogInfo(
" reading the input file ") << m_file_name;
301 std::ifstream fInput;
302 fInput.open(m_file_name);
303 if (!fInput.is_open()) {
304 edm::LogInfo(
"ERROR : cannot open file ") << m_file_name;
307 int weightGroup, stripEBId, stripEEId;
310 fInput >> stripEBId >> weightGroup;
311 weightG->
setValue(stripEBId, weightGroup);
314 fInput >> stripEEId >> weightGroup;
315 weightG->
setValue(stripEEId, weightGroup);
321 edm::LogInfo(
"EcalTPGWeightGroupHandler::readtxtFile error : ") <<
e.what();
327 edm::LogInfo(
" reading the input file ") << m_file_name;
329 fxml.open(m_file_name);
330 if (!fxml.is_open()) {
331 edm::LogInfo(
"ERROR : cannot open file ") << m_file_name;
335 int weightGroup, stripEBId, stripEEId;
337 for (
int i = 0;
i < 6;
i++)
338 std::getline(fxml, dummyLine);
340 std::size_t
found = bid.find(
"</");
342 for (
int i = 0;
i < 2;
i++)
343 std::getline(fxml, dummyLine);
345 std::getline(fxml, dummyLine);
347 found = bid.find(
"</");
348 stt = bid.substr(7,
found - 7);
349 std::istringstream sg1(stt);
351 std::getline(fxml, dummyLine);
353 found = bid.find(
"</");
354 stt = bid.substr(8,
found - 8);
355 std::istringstream sg2(stt);
357 weightG->
setValue(stripEBId, weightGroup);
358 for (
int i = 0;
i < 2;
i++)
359 std::getline(fxml, dummyLine);
362 std::getline(fxml, dummyLine);
364 found = bid.find(
"</");
365 stt = bid.substr(7,
found - 7);
366 std::istringstream sg1(stt);
368 std::getline(fxml, dummyLine);
370 found = bid.find(
"</");
371 stt = bid.substr(8,
found - 8);
372 std::istringstream sg2(stt);
374 weightG->
setValue(stripEEId, weightGroup);
375 for (
int i = 0;
i < 2;
i++)
376 std::getline(fxml, dummyLine);
382 edm::LogInfo(
"EcalTPGWeightGroupHandler::readtxtFile error : ") <<
e.what();
404 std::ostringstream
str;
406 fgets(
line, 255, inpFile);
408 str <<
"gen tag " << m_i_tag << std::endl;
410 fgets(
line, 255, inpFile);
411 m_i_version = atoi(
line);
412 str <<
"version= " << m_i_version << std::endl;
414 fgets(
line, 255, inpFile);
415 m_i_run_number = atoi(
line);
416 str <<
"run_number= " << m_i_run_number << std::endl;
418 fgets(
line, 255, inpFile);
419 m_i_weightGroup = atoi(
line);
420 str <<
"weightGroup_config= " << m_i_weightGroup << std::endl;
428 std::ofstream myfile;
430 myfile << m_i_tag << std::endl;
431 myfile << m_i_version << std::endl;
432 myfile << m_i_run_number << std::endl;
433 myfile << m_i_weightGroup << std::endl;
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
T getParameter(std::string const &) const
void getNewObjects() override
std::string getName() const
~EcalTPGWeightGroupHandler() override
Log< level::Error, false > LogError
void readFromFile(const char *inputFile)
static std::string to_string(const XMLCh *ch)
EcalTPGWeightGroupHandler(edm::ParameterSet const &)
std::string m_locationsource
void setValue(const uint32_t &rawId, const uint32_t &ObjectId)
void setLocationDef(const LocationDef &locDef)
Log< level::Info, false > LogInfo
std::string getConfigTag() const
void setConfigTag(std::string x)
ALPAKA_FN_ACC int sm(int ieta, int iphi)
void setGeneralTag(std::string tag)
void writeFile(const char *inputFile)