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];
273 while (!fInput.eof()) {
274 getline (fInput, line);
276 std::stringstream ss;
278 ss >> wloc[0] >> wloc[1] >> wloc[2] >> wloc[3] >> wloc[4];
280 w.
setValues(wloc[0], wloc[1], wloc[2], wloc[3], wloc[4]);
285 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"found " << igroups <<
" Weight groups";
290 edm::LogInfo(
"EcalTPGWeightIdMapHandler::readtxtFile error : ") << e.what();
298 if(!fxml.is_open()) {
303 unsigned int wloc[5];
306 int ngroups, igroups;
307 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"found " << igroups <<
"Weight groups";
308 for(
int i = 0;
i < 5;
i++) std::getline(fxml, dummyLine);
312 std::istringstream
sc(stt);
314 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"found " << ngroups <<
" Weight groups";
315 for(
int i = 0;
i < 2;
i++) std::getline(fxml, dummyLine);
316 for(
int i = 0;
i < ngroups;
i++) {
317 std::getline(fxml, dummyLine);
320 std::size_t
found = bid.find(
"</");
321 stt = bid.substr(7, found - 7);
322 std::istringstream sg1(stt);
325 edm::LogInfo(
" group ") <<
i <<
": " << bid <<
" igroups " << igroups;
328 for(
int i = 0;
i < 2;
i++) std::getline(fxml, dummyLine);
329 for(
int i = 0;
i < 5;
i++) {
331 found = bid.find(
"</");
332 stt = bid.substr(5, found - 5);
333 std::istringstream
w(stt);
336 w.
setValues(wloc[0], wloc[1], wloc[2], wloc[3], wloc[4]);
338 for(
int i = 0;
i < 3;
i++) std::getline(fxml, dummyLine);
345 edm::LogInfo(
"EcalTPGWeightIdMapHandler::readxmlFile error : ") << e.what();
358 inpFile = fopen(inputFile,
"r");
366 std::ostringstream
str;
368 fgets(line,255,inpFile);
370 str <<
"gen tag " <<
m_i_tag << std::endl ;
372 fgets(line,255,inpFile);
376 fgets(line,255,inpFile);
380 fgets(line,255,inpFile);
393 std::ofstream myfile;
394 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