25 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalTPGWeightIdMapHandler")) {
27 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"EcalTPGWeightIdMap Source handler constructor";
56 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"Started GetNewObjects!!!";
68 unsigned int max_since=0;
70 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"max_since : " << max_since;
73 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"retrieved last payload ";
76 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"Retrieving run list from ONLINE DB ... ";
78 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"Making connection...";
112 if(min_run<max_since) {
119 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"min_run= " << min_run <<
"max_run= " << max_run;
125 std::vector<RunIOV> run_vec= my_list.
getRuns();
126 size_t num_runs=run_vec.size();
127 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"number of Mon runs is : "<< num_runs;
131 for(
size_t kr=0; kr<run_vec.size(); kr++){
133 irun=
static_cast<unsigned int>(run_vec[kr].getRunNumber());
138 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
142 int the_config_version=0;
144 std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
147 for( it=dataset.begin(); it!=dataset.end(); it++ )
160 edm::LogInfo(
" run= ")<<irun<<
" tag "<<the_config_tag<<
" version="<<the_config_version;
166 edm::LogInfo(
"the tag is different from last transferred run ... retrieving last config set from DB");
173 econn-> fetchConfigSet(&fe_main_info);
177 int weightId=fe_main_info.
getWeiId();
182 fe_weight_info.
setId(weightId);
183 econn-> fetchConfigSet(&fe_weight_info);
184 std::map<EcalLogicID, FEConfigWeightGroupDat> dataset_TpgWeight;
186 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"Got object!";
188 typedef std::map<EcalLogicID, FEConfigWeightGroupDat>::const_iterator CIfeweight;
193 for (CIfeweight
p = dataset_TpgWeight.begin();
p != dataset_TpgWeight.end();
p++) {
198 unsigned int weight0 =
static_cast<unsigned int>(rd_w.
getWeight4());
199 unsigned int weight1 =
static_cast<unsigned int>(rd_w.
getWeight3());
200 unsigned int weight2 =
static_cast<unsigned int>(rd_w.
getWeight2());
201 unsigned int weight3 =
static_cast<unsigned int>(rd_w.
getWeight1()- 0x80);
202 unsigned int weight4 =
static_cast<unsigned int>(rd_w.
getWeight0());
204 w.
setValues(weight0,weight1,weight2,weight3,weight4);
210 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"found " << igroups <<
"Weight groups";
220 writeFile(
"last_tpg_weightIdMap_settings.txt");
228 writeFile(
"last_tpg_weightIdMap_settings.txt");
230 edm::LogInfo(
" even if the tag/version is not the same, the weightIdMap id is the same -> no transfer needed ");
235 edm::LogInfo(
"ERROR: THIS CONFIG DOES NOT EXIST: tag=") <<the_config_tag
236 <<
" version="<<the_config_version;
244 edm::LogInfo(
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor, no transfer needed ");
249 edm::LogInfo(
" the tag/version is the same, no transfer needed ");
250 writeFile(
"last_tpg_weightIdMap_settings.txt");
258 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"Ecal - > end of getNewObjects -----------";
262 std::ifstream fInput;
264 if(!fInput.is_open()) {
268 unsigned int wloc[5];
272 for (
int ifirst = 0; ifirst < 2; ifirst++) {
273 for (
int isecond = 0; isecond < 5; isecond++)
274 fInput >> wloc[isecond];
275 w.
setValues(wloc[0], wloc[1], wloc[2], wloc[3], wloc[4]);
279 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"found " << igroups <<
"Weight groups";
284 edm::LogInfo(
"EcalTPGWeightIdMapHandler::readtxtFile error : ") << e.what() << std::endl;
292 if(!fxml.is_open()) {
297 unsigned int wloc[5];
300 int ngroups, igroups;
301 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"found " << igroups <<
"Weight groups";
302 for(
int i = 0;
i < 5;
i++) std::getline(fxml, dummyLine);
305 std::istringstream
sc(stt);
308 edm::LogInfo(
" line : ") << bid <<
" ngroups " << ngroups;
311 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
313 stt = bid.substr(7, 1);
314 std::istringstream sg1(stt);
317 edm::LogInfo(
" group 1: ") << bid <<
" igroups " << igroups;
320 for(
int i = 0;
i < 2;
i++) std::getline(fxml, dummyLine);
321 for(
int i = 0;
i < 5;
i++) {
323 std::size_t
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]);
331 for(
int i = 0;
i < 4;
i++) std::getline(fxml, dummyLine);
333 stt = bid.substr(7, 1);
334 std::istringstream sg2(stt);
337 edm::LogInfo(
" group 2 : ") << bid <<
" igroups " << igroups;
340 for(
int i = 0;
i < 2;
i++) std::getline(fxml, dummyLine);
341 for(
int i = 0;
i < 5;
i++) {
343 std::size_t
found = bid.find(
"</");
344 stt = bid.substr(5, found - 5);
345 std::istringstream
w(stt);
348 w.
setValues(wloc[0], wloc[1], wloc[2], wloc[3], wloc[4]);
354 edm::LogInfo(
"EcalTPGWeightIdMapHandler::readxmlFile error : ") << e.what();
367 inpFile = fopen(inputFile,
"r");
375 std::ostringstream
str;
377 fgets(line,255,inpFile);
379 str <<
"gen tag " <<
m_i_tag << std::endl ;
381 fgets(line,255,inpFile);
385 fgets(line,255,inpFile);
389 fgets(line,255,inpFile);
402 std::ofstream myfile;
403 myfile.open (inputFile);
~EcalTPGWeightIdMapHandler() override
T getParameter(std::string const &) const
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
edm::Ref< Container > Ref
RunList fetchGlobalRunListByLocation(const RunTag &tag, int min_run, int max_run, const LocationDef &locDef) noexcept(false)
std::string getConfigTag() const
void readFromFile(const char *inputFile)
void getNewObjects() override
void writeFile(const char *inputFile)
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov) noexcept(false)
int getWeightGroupId() const
OldContainer m_to_transfer
cond::ValidityInterval lastInterval
std::string to_string(char value[])
void setLocationDef(const LocationDef &locDef)
EcalCondDBInterface * econn
void setValue(const uint32_t &id, const EcalTPGWeights &value)
EcalTPGWeightIdMapHandler(edm::ParameterSet const &)
unsigned int m_i_run_number
void setRunType(std::string runtype)
void setConfigTag(std::string x)
void setLocation(std::string loc)
void setGeneralTag(std::string tag)
void setValues(const uint32_t &w0, const uint32_t &w1, const uint32_t &w2, const uint32_t &w3, const uint32_t &w4)
std::string m_locationsource
cond::TagInfo_t const & tagInfo() const