24 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalTPGLutIdMapHandler")) {
25 edm::LogInfo(
"EcalTPGLutIdMapHandler") <<
"EcalTPGLutIdMap Source handler constructor";
42 edm::LogInfo(
"EcalTPGLutIdMapHandler") <<
"Started GetNewObjects!!!";
47 std::cout <<
"got offlineInfo = " << std::endl;
51 std::cout <<
" First object for this tag " << std::endl;
54 unsigned int max_since = 0;
55 max_since =
static_cast<unsigned int>(
tagInfo().lastInterval.since);
56 edm::LogInfo(
"EcalTPGLutIdMapHandler") <<
"max_since : " << max_since;
57 edm::LogInfo(
"EcalTPGLutIdMapHandler") <<
"retrieved last payload ";
60 edm::LogInfo(
"EcalTPGLutIdMapHandler") <<
"Retrieving run list from ONLINE DB ... ";
62 edm::LogInfo(
"EcalTPGLutIdMapHandler") <<
"Making connection...";
67 std::cout <<
" connection parameters " << m_sid <<
"/" << m_user << std::endl;
83 readFromFile(
"last_tpg_lutIdMap_settings.txt");
87 if (m_firstRun < m_i_run_number) {
88 min_run = m_i_run_number + 1;
93 if (min_run < max_since) {
94 min_run = max_since + 1;
97 std::cout <<
"m_i_run_number" << m_i_run_number <<
"m_firstRun " << m_firstRun <<
"max_since " << max_since
100 unsigned int max_run = m_lastRun;
101 edm::LogInfo(
"EcalTPGLutIdMapHandler") <<
"min_run= " << min_run <<
"max_run= " << max_run;
104 my_list =
econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run,
my_locdef);
107 std::vector<RunIOV> run_vec = my_list.
getRuns();
108 size_t num_runs = run_vec.size();
110 std::cout <<
"number of runs is : " << num_runs << std::endl;
114 for (
size_t kr = 0; kr < run_vec.size(); kr++) {
115 irun =
static_cast<unsigned int>(run_vec[kr].getRunNumber());
117 std::cout <<
" **************** " << std::endl;
118 std::cout <<
" **************** " << std::endl;
119 std::cout <<
" run= " << irun << std::endl;
122 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
126 int the_config_version = 0;
128 std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
141 std::cout <<
" run= " << irun <<
" tag " << the_config_tag <<
" version=" << the_config_version << std::endl;
145 if ((the_config_tag != m_i_tag || the_config_version != m_i_version) &&
nr > 0) {
146 std::cout <<
"the tag is different from last transferred run ... retrieving last config set from DB" 154 std::cout <<
" before fetch config set" << std::endl;
155 econn->fetchConfigSet(&fe_main_info);
156 std::cout <<
" after fetch config set" << std::endl;
159 int lutId = fe_main_info.
getLUTId();
161 if (lutId != m_i_lutIdMap) {
163 fe_lut_info.
setId(lutId);
164 econn->fetchConfigSet(&fe_lut_info);
165 std::map<EcalLogicID, FEConfigLUTGroupDat> dataset_TpgLut;
167 econn->fetchDataSet(&dataset_TpgLut, &fe_lut_info);
168 edm::LogInfo(
"EcalTPGLutIdMapHandler") <<
"Got object!";
172 typedef std::map<EcalLogicID, FEConfigLUTGroupDat>::const_iterator CIfelut;
176 for (CIfelut
p = dataset_TpgLut.begin();
p != dataset_TpgLut.end();
p++) {
182 unsigned int lutArray[1024];
183 for (
int ilut = 0; ilut < 1024; ++ilut) {
194 m_to_transfer.push_back(std::make_pair((
EcalTPGLutIdMap*)lutMap, snc));
196 m_i_run_number = irun;
197 m_i_tag = the_config_tag;
198 m_i_version = the_config_version;
199 m_i_lutIdMap = lutId;
201 writeFile(
"last_tpg_lutIdMap_settings.txt");
204 m_i_run_number = irun;
205 m_i_tag = the_config_tag;
206 m_i_version = the_config_version;
208 writeFile(
"last_tpg_lutIdMap_settings.txt");
210 std::cout <<
" even if the tag/version is not the same, the lutIdMap id is the same -> no transfer needed " 217 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag <<
" version=" << the_config_version
220 m_i_run_number = irun;
222 std::cout <<
" **************** " << std::endl;
224 }
else if (
nr == 0) {
225 m_i_run_number = irun;
226 std::cout <<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
227 std::cout <<
" **************** " << std::endl;
229 m_i_run_number = irun;
230 m_i_tag = the_config_tag;
231 m_i_version = the_config_version;
232 std::cout <<
" the tag/version is the same -> no transfer needed " << std::endl;
233 std::cout <<
" **************** " << std::endl;
234 writeFile(
"last_tpg_lutIdMap_settings.txt");
241 edm::LogInfo(
"EcalTPGLutIdMapHandler") <<
"Ecal - > end of getNewObjects -----------";
261 std::ostringstream
str;
263 fgets(
line, 255, inpFile);
265 str <<
"gen tag " << m_i_tag << std::endl;
267 fgets(
line, 255, inpFile);
268 m_i_version = atoi(
line);
269 str <<
"version= " << m_i_version << std::endl;
271 fgets(
line, 255, inpFile);
272 m_i_run_number = atoi(
line);
273 str <<
"run_number= " << m_i_run_number << std::endl;
275 fgets(
line, 255, inpFile);
276 m_i_lutIdMap = atoi(
line);
277 str <<
"lutIdMap_config= " << m_i_lutIdMap << std::endl;
285 std::ofstream myfile;
287 myfile << m_i_tag << std::endl;
288 myfile << m_i_version << std::endl;
289 myfile << m_i_run_number << std::endl;
290 myfile << m_i_lutIdMap << std::endl;
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
T getParameter(std::string const &) const
void getNewObjects() override
int getLUTValue(int i) const
int getLUTGroupId() const
void writeFile(const char *inputFile)
EcalTPGLutIdMapHandler(edm::ParameterSet const &)
Log< level::Error, false > LogError
void setLut(const unsigned int *lut)
static std::string to_string(const XMLCh *ch)
~EcalTPGLutIdMapHandler() override
void setValue(const uint32_t &id, const EcalTPGLut &value)
void setLocationDef(const LocationDef &locDef)
Log< level::Info, false > LogInfo
void readFromFile(const char *inputFile)
std::string getConfigTag() const
void setConfigTag(std::string x)
std::string m_locationsource
void setGeneralTag(std::string tag)