31 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalTPGSlidingWindowHandler")) {
32 edm::LogInfo(
"EcalTPGSlidingWindowHandler") <<
"EcalTPGSlidingWindow Source handler constructor";
49 edm::LogInfo(
"EcalTPGSlidingWindowHandler") <<
"Started GetNewObjects!!!";
54 std::cout <<
"got offlineInfo = " << std::endl;
58 std::cout <<
" First object for this tag " << std::endl;
61 unsigned int max_since = 0;
62 max_since = static_cast<unsigned int>(
tagInfo().lastInterval.since);
63 edm::LogInfo(
"EcalTPGSlidingWindowHandler") <<
"max_since : " << max_since;
64 edm::LogInfo(
"EcalTPGSlidingWindowHandler") <<
"retrieved last payload ";
68 edm::LogInfo(
"EcalTPGSlidingWindowHandler") <<
"Retrieving run list from ONLINE DB ... ";
70 edm::LogInfo(
"EcalTPGSlidingWindowHandler") <<
"Making connection...";
75 std::cout <<
" connection parameters " << m_sid <<
"/" << m_user << std::endl;
92 unsigned int min_run = m_i_run_number + 1;
93 if (m_firstRun < m_i_run_number) {
94 min_run = m_i_run_number + 1;
99 if (min_run < max_since) {
100 min_run = max_since + 1;
103 std::cout <<
"m_i_run_number" << m_i_run_number <<
"m_firstRun " << m_firstRun <<
"max_since " << max_since
106 unsigned int max_run = m_lastRun;
108 edm::LogInfo(
"EcalTPGSlidingWindowHandler") <<
"min_run= " << min_run <<
"max_run= " << max_run;
111 my_list =
econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run,
my_locdef);
114 std::vector<RunIOV> run_vec = my_list.
getRuns();
115 size_t num_runs = run_vec.size();
117 std::cout <<
"number of runs is : " << num_runs << std::endl;
119 unsigned int irun = 0;
122 std::vector<EcalLogicID> my_StripEcalLogicId_EE;
123 my_StripEcalLogicId_EE =
124 econn->getEcalLogicIDSetOrdered(
"ECAL_readout_strip", 1, 1000, 1, 70, 0, 5,
"EE_offline_stripid", 123);
125 std::cout <<
" GOT the logic ID for the EE trigger strips " << std::endl;
127 for (
size_t kr = 0; kr < run_vec.size(); kr++) {
128 irun = static_cast<unsigned int>(run_vec[kr].
getRunNumber());
130 std::cout <<
" **************** " << std::endl;
131 std::cout <<
" **************** " << std::endl;
132 std::cout <<
" run= " << irun << std::endl;
135 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
139 int the_config_version = 0;
141 std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
155 std::cout <<
" run= " << irun <<
" tag " << the_config_tag <<
" version=" << the_config_version << std::endl;
159 if ((the_config_tag != m_i_tag || the_config_version != m_i_version) &&
nr > 0) {
160 std::cout <<
"the tag is different from last transferred run ... retrieving last config set from DB"
168 std::cout <<
" before fetch config set" << std::endl;
169 econn->fetchConfigSet(&fe_main_info);
170 std::cout <<
" after fetch config set" << std::endl;
173 int slidingId = fe_main_info.
getSliId();
175 if (slidingId != m_i_sliding) {
177 fe_sli_info.
setId(slidingId);
178 econn->fetchConfigSet(&fe_sli_info);
179 std::map<EcalLogicID, FEConfigSlidingDat> dataset_TpgSli;
180 econn->fetchDataSet(&dataset_TpgSli, &fe_sli_info);
183 typedef std::map<EcalLogicID, FEConfigSlidingDat>::const_iterator CIfesli;
188 for (CIfesli
p = dataset_TpgSli.begin();
p != dataset_TpgSli.end();
p++) {
195 if (ecid_name ==
"EB_VFE") {
196 int sm = ecid_xt.
getID1();
205 unsigned int stripEBId = 303176 + (
tt - 1) * 64 + (
strip - 1) * 8 + (tcc - 37) * 8192;
210 }
else if (ecid_name ==
"ECAL_readout_strip") {
214 int id3 = ecid_xt.
getID3();
216 bool set_the_strip =
false;
218 for (
size_t istrip = 0; istrip < my_StripEcalLogicId_EE.size(); istrip++) {
219 if (!set_the_strip) {
220 if (my_StripEcalLogicId_EE[istrip].getID1() ==
id1 &&
221 my_StripEcalLogicId_EE[istrip].getID2() ==
id2 &&
222 my_StripEcalLogicId_EE[istrip].getID3() == id3) {
223 stripid = my_StripEcalLogicId_EE[istrip].getLogicID();
224 set_the_strip =
true;
234 std::cout <<
" these may be the additional towers TCC/TT " <<
id1 <<
"/" <<
id2 << std::endl;
244 m_i_run_number = irun;
245 m_i_tag = the_config_tag;
246 m_i_version = the_config_version;
247 m_i_sliding = slidingId;
249 writeFile(
"last_tpg_sliding_settings.txt");
252 m_i_run_number = irun;
253 m_i_tag = the_config_tag;
254 m_i_version = the_config_version;
256 writeFile(
"last_tpg_sliding_settings.txt");
259 <<
" even if the tag/version is not the same, the sliding windows id is the same -> no transfer needed "
263 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag <<
" version=" << the_config_version
267 m_i_run_number = irun;
270 std::cout <<
" **************** " << std::endl;
272 }
else if (
nr == 0) {
273 m_i_run_number = irun;
274 std::cout <<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
275 std::cout <<
" **************** " << std::endl;
277 m_i_run_number = irun;
278 m_i_tag = the_config_tag;
279 m_i_version = the_config_version;
280 std::cout <<
" the tag/version is the same -> no transfer needed " << std::endl;
281 std::cout <<
" **************** " << std::endl;
282 writeFile(
"last_tpg_sliding_settings.txt");
289 edm::LogInfo(
"EcalTPGSlidingWindowHandler") <<
"Ecal - > end of getNewObjects -----------";
309 std::ostringstream
str;
311 fgets(
line, 255, inpFile);
312 m_i_tag = to_string(
line);
313 str <<
"gen tag " << m_i_tag << std::endl;
315 fgets(
line, 255, inpFile);
316 m_i_version = atoi(
line);
317 str <<
"version= " << m_i_version << std::endl;
319 fgets(
line, 255, inpFile);
320 m_i_run_number = atoi(
line);
321 str <<
"run_number= " << m_i_run_number << std::endl;
323 fgets(
line, 255, inpFile);
324 m_i_sliding = atoi(
line);
325 str <<
"sliding_config= " << m_i_sliding << std::endl;
333 std::ofstream myfile;
335 myfile << m_i_tag << std::endl;
336 myfile << m_i_version << std::endl;
337 myfile << m_i_run_number << std::endl;
338 myfile << m_i_sliding << std::endl;