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;
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;
145 econn->fetchDataSet(&dataset, &run_vec[kr]);
148 int the_config_version = 0;
150 std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
153 for (it = dataset.begin(); it != dataset.end(); 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;
196 std::map<std::string, int> map;
199 for (CIfesli
p = dataset_TpgW.begin();
p != dataset_TpgW.end();
p++) {
201 weightGroup =
p->second.getWeightGroupId();
206 if (ecid_name ==
"EB_VFE") {
207 int sm = ecid_xt.
getID1();
216 unsigned int stripEBId = 303176 + (tt - 1) * 64 + (strip - 1) * 8 + (tcc - 37) * 8192;
218 weightG->
setValue(stripEBId, weightGroup);
220 }
else if (ecid_name ==
"ECAL_readout_strip") {
222 int id1 = ecid_xt.
getID1();
223 int id2 = ecid_xt.
getID2();
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 edm::LogInfo(
" these may be the additional towers TCC/TT ") << id1 <<
"/" << id2;
255 m_i_run_number = irun;
256 m_i_tag = the_config_tag;
257 m_i_version = the_config_version;
258 m_i_weightGroup = wId;
260 writeFile(
"last_tpg_weightGroup_settings.txt");
263 m_i_run_number = irun;
264 m_i_tag = the_config_tag;
265 m_i_version = the_config_version;
267 writeFile(
"last_tpg_weightGroup_settings.txt");
270 " even if the tag/version is not the same, the weight group id is the same -> no transfer needed ");
277 << the_config_tag <<
" version=" << the_config_version;
279 m_i_run_number = irun;
283 }
else if (nr == 0) {
284 m_i_run_number = irun;
285 edm::LogInfo(
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed ");
288 m_i_run_number = irun;
289 m_i_tag = the_config_tag;
290 m_i_version = the_config_version;
291 edm::LogInfo(
" the tag/version is the same -> no transfer needed ");
293 writeFile(
"last_tpg_weightGroup_settings.txt");
300 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"Ecal - > end of getNewObjects -----------";
304 edm::LogInfo(
" reading the input file ") << m_file_name;
305 std::ifstream fInput;
306 fInput.open(m_file_name);
307 if (!fInput.is_open()) {
308 edm::LogInfo(
"ERROR : cannot open file ") << m_file_name;
311 int weightGroup, stripEBId, stripEEId;
314 fInput >> stripEBId >> weightGroup;
315 weightG->
setValue(stripEBId, weightGroup);
318 fInput >> stripEEId >> weightGroup;
319 weightG->
setValue(stripEEId, weightGroup);
325 edm::LogInfo(
"EcalTPGWeightGroupHandler::readtxtFile error : ") << e.what();
331 edm::LogInfo(
" reading the input file ") << m_file_name;
333 fxml.open(m_file_name);
334 if (!fxml.is_open()) {
335 edm::LogInfo(
"ERROR : cannot open file ") << m_file_name;
339 int weightGroup, stripEBId, stripEEId;
341 for (
int i = 0;
i < 6;
i++)
342 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 edm::LogInfo(
"EcalTPGWeightGroupHandler::readtxtFile error : ") << e.what();
400 inpFile = fopen(inputFile,
"r");
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_weightGroup = atoi(line);
424 str <<
"weightGroup_config= " << m_i_weightGroup << std::endl;
432 std::ofstream myfile;
433 myfile.open(inputFile);
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_weightGroup << std::endl;
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
void getNewObjects() override
std::string getConfigTag() const
std::string to_string(const V &value)
~EcalTPGWeightGroupHandler() override
Log< level::Error, false > LogError
void readFromFile(CaloCluster &c, FILE *file)
void readFromFile(const char *inputFile)
std::string getName() const
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
void setRunType(std::string runtype)
T getParameter(std::string const &) const
static std::vector< std::string > checklist dat
void setConfigTag(std::string x)
void setLocation(std::string loc)
void setGeneralTag(std::string tag)
tuple size
Write out results.
void writeFile(const char *inputFile)