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;
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;
146 econn->fetchDataSet(&dataset, &run_vec[kr]);
149 int the_config_version = 0;
151 std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
154 for (it = dataset.begin(); it != dataset.end(); 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;
198 std::map<std::string, int> map;
201 for (CIfesli
p = dataset_TpgW.begin();
p != dataset_TpgW.end();
p++) {
203 weightGroup =
p->second.getWeightGroupId();
208 if (ecid_name ==
"EB_VFE") {
209 int sm = ecid_xt.
getID1();
218 unsigned int stripEBId = 303176 + (tt - 1) * 64 + (strip - 1) * 8 + (tcc - 37) * 8192;
220 weightG->
setValue(stripEBId, weightGroup);
222 }
else if (ecid_name ==
"ECAL_readout_strip") {
224 int id1 = ecid_xt.
getID1();
225 int id2 = ecid_xt.
getID2();
226 int id3 = ecid_xt.
getID3();
228 bool set_the_strip =
false;
230 for (
size_t istrip = 0; istrip < my_StripEcalLogicId_EE.size(); istrip++) {
231 if (!set_the_strip) {
232 if (my_StripEcalLogicId_EE[istrip].getID1() == id1 &&
233 my_StripEcalLogicId_EE[istrip].getID2() == id2 &&
234 my_StripEcalLogicId_EE[istrip].getID3() == id3) {
235 stripEEId = my_StripEcalLogicId_EE[istrip].getLogicID();
236 set_the_strip =
true;
243 weightG->
setValue(stripEEId, weightGroup);
246 std::cout <<
" these may be the additional towers TCC/TT " << id1 <<
"/" << id2 << std::endl;
257 m_i_run_number = irun;
258 m_i_tag = the_config_tag;
259 m_i_version = the_config_version;
260 m_i_oddweightGroup = wId;
262 writeFile(
"last_tpg_OddweightGroup_settings.txt");
265 m_i_run_number = irun;
266 m_i_tag = the_config_tag;
267 m_i_version = the_config_version;
269 writeFile(
"last_tpg_OddweightGroup_settings.txt");
272 <<
" even if the tag/version is not the same, the weight group id is the same -> no transfer needed "
279 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag
280 <<
" version=" << the_config_version << std::endl;
282 m_i_run_number = irun;
284 std::cout <<
" **************** " << std::endl;
286 }
else if (nr == 0) {
287 m_i_run_number = irun;
288 std::cout <<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
289 std::cout <<
" **************** " << std::endl;
291 m_i_run_number = irun;
292 m_i_tag = the_config_tag;
293 m_i_version = the_config_version;
294 std::cout <<
" the tag/version is the same -> no transfer needed " << std::endl;
295 std::cout <<
" **************** " << std::endl;
296 writeFile(
"last_tpg_OddweightGroup_settings.txt");
303 edm::LogInfo(
"EcalTPGOddWeightGroupHandler") <<
"Ecal - > end of getNewObjects -----------";
307 std::cout <<
" reading the input file " << m_file_name << std::endl;
308 std::ifstream fInput;
309 fInput.open(m_file_name);
310 if (!fInput.is_open()) {
311 std::cout <<
"ERROR : cannot open file " << m_file_name << std::endl;
314 int weightGroup, stripEBId, stripEEId;
317 fInput >> stripEBId >> weightGroup;
318 weightG->
setValue(stripEBId, weightGroup);
321 fInput >> stripEEId >> weightGroup;
322 weightG->
setValue(stripEEId, weightGroup);
328 std::cout <<
"EcalTPGOddWeightGroupHandler::readtxtFile error : " << e.what() << std::endl;
330 std::cout <<
" **************** " << std::endl;
334 std::cout <<
" reading the input file " << m_file_name << std::endl;
336 fxml.open(m_file_name);
337 if (!fxml.is_open()) {
338 std::cout <<
"ERROR : cannot open file " << m_file_name << std::endl;
342 int weightGroup, stripEBId, stripEEId;
344 for (
int i = 0;
i < 6;
i++)
345 std::getline(fxml, dummyLine);
348 std::size_t
found = bid.find(
"</");
350 for (
int i = 0;
i < 2;
i++)
351 std::getline(fxml, dummyLine);
353 std::getline(fxml, dummyLine);
355 found = bid.find(
"</");
356 stt = bid.substr(7, found - 7);
357 std::istringstream sg1(stt);
359 std::getline(fxml, dummyLine);
361 found = bid.find(
"</");
362 stt = bid.substr(8, found - 8);
363 std::istringstream sg2(stt);
365 weightG->
setValue(stripEBId, weightGroup);
366 for (
int i = 0;
i < 2;
i++)
367 std::getline(fxml, dummyLine);
370 std::getline(fxml, dummyLine);
372 found = bid.find(
"</");
373 stt = bid.substr(7, found - 7);
374 std::istringstream sg1(stt);
376 std::getline(fxml, dummyLine);
378 found = bid.find(
"</");
379 stt = bid.substr(8, found - 8);
380 std::istringstream sg2(stt);
382 weightG->
setValue(stripEEId, weightGroup);
383 for (
int i = 0;
i < 2;
i++)
384 std::getline(fxml, dummyLine);
390 std::cout <<
"EcalTPGOddWeightGroupHandler::readtxtFile error : " << e.what() << std::endl;
392 std::cout <<
" **************** " << std::endl;
401 m_i_oddweightGroup = 0;
404 inpFile = fopen(inputFile,
"r");
412 std::ostringstream
str;
414 fgets(line, 255, inpFile);
415 m_i_tag = to_string(line);
416 str <<
"gen tag " << m_i_tag << std::endl;
418 fgets(line, 255, inpFile);
419 m_i_version = atoi(line);
420 str <<
"version= " << m_i_version << std::endl;
422 fgets(line, 255, inpFile);
423 m_i_run_number = atoi(line);
424 str <<
"run_number= " << m_i_run_number << std::endl;
426 fgets(line, 255, inpFile);
427 m_i_oddweightGroup = atoi(line);
428 str <<
"weightGroup_config= " << m_i_oddweightGroup << std::endl;
436 std::ofstream myfile;
437 myfile.open(inputFile);
438 myfile << m_i_tag << std::endl;
439 myfile << m_i_version << std::endl;
440 myfile << m_i_run_number << std::endl;
441 myfile << m_i_oddweightGroup << std::endl;
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
std::string getConfigTag() const
void getNewObjects() override
Log< level::Error, false > LogError
void readFromFile(CaloCluster &c, FILE *file)
std::string getName() const
~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
void setRunType(std::string runtype)
T getParameter(std::string const &) const
static std::vector< std::string > checklist dat
void setConfigTag(std::string x)
void readFromFile(const char *inputFile)
void setLocation(std::string loc)
void writeFile(const char *inputFile)
void setGeneralTag(std::string tag)
tuple size
Write out results.
EcalTPGOddWeightGroupHandler(edm::ParameterSet const &)