38 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalTPGSpikeThresholdHandler")) {
39 edm::LogInfo(
"EcalTPGSpikeThresholdHandler") <<
"EcalTPGSpike Source handler constructor";
59 edm::LogInfo(
"EcalTPGSpikeThresholdHandler") <<
"Started GetNewObjects!!!";
64 std::cout <<
"got offlineInfo = " << std::endl;
68 std::cout <<
" First object for this tag " << std::endl;
71 unsigned int max_since = 0;
72 max_since =
static_cast<unsigned int>(
tagInfo().lastInterval.since);
73 edm::LogInfo(
"EcalTPGSpikeThresholdHandler") <<
"max_since : " << max_since;
74 edm::LogInfo(
"EcalTPGSpikeThresholdHandler") <<
"retrieved last payload ";
77 edm::LogInfo(
"EcalTPGSpikeThresholdHandler") <<
"Retrieving run list from ONLINE DB ... ";
79 edm::LogInfo(
"EcalTPGSpikeThresholdHandler") <<
"Making connection...";
84 std::cout <<
" connection parameters " << m_sid <<
"/" << m_user << std::endl;
100 readFromFile(
"last_tpg_spikeThreshold_settings.txt");
102 unsigned int min_run;
104 if (m_firstRun < m_i_run_number) {
105 min_run = m_i_run_number + 1;
107 min_run = m_firstRun;
110 if (min_run < max_since) {
111 min_run = max_since + 1;
114 std::cout <<
"m_i_run_number" << m_i_run_number <<
"m_firstRun " << m_firstRun <<
"max_since " << max_since
117 unsigned int max_run = m_lastRun;
118 edm::LogInfo(
"EcalTPGSpikeThresholdHandler") <<
"min_run= " << min_run <<
" max_run= " << max_run;
121 my_list =
econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run,
my_locdef);
124 std::vector<RunIOV> run_vec = my_list.
getRuns();
125 size_t num_runs = run_vec.size();
127 std::cout <<
"number of runs is : " << num_runs << std::endl;
133 for (
size_t kr = 0; kr < run_vec.size(); kr++) {
134 irun =
static_cast<unsigned int>(run_vec[kr].getRunNumber());
136 std::cout <<
" **************** " << std::endl;
137 std::cout <<
" run= " << irun << std::endl;
140 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
144 int the_config_version = 0;
146 std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
160 std::cout <<
" run= " << irun <<
" tag " << the_config_tag <<
" version=" << the_config_version << std::endl;
164 if ((the_config_tag != m_i_tag || the_config_version != m_i_version) &&
nr > 0) {
165 std::cout <<
"the tag is different from last transferred run ... retrieving last config set from DB" 173 std::cout <<
" before fetch config set" << std::endl;
174 econn->fetchConfigSet(&fe_main_info);
175 std::cout <<
" after fetch config set" << std::endl;
178 int spikeId = fe_main_info.
getSpiId();
180 if (spikeId != m_i_spikeTh) {
182 fe_spike_info.
setId(spikeId);
183 econn->fetchConfigSet(&fe_spike_info);
184 std::map<EcalLogicID, FEConfigSpikeDat> dataset_TpgSpike;
185 econn->fetchDataSet(&dataset_TpgSpike, &fe_spike_info);
188 typedef std::map<EcalLogicID, FEConfigSpikeDat>::const_iterator CIfelut;
193 for (CIfelut
p = dataset_TpgSpike.begin();
p != dataset_TpgSpike.end();
p++) {
195 rd_spike =
p->second;
199 if (ecid_name ==
"EB_trigger_tower") {
201 int smid = ecid_xt.
getID1();
203 int towerid = ecid_xt.
getID2();
205 int tow_eta = (towerid - 1) / 4;
206 int tow_phi = ((towerid - 1) - tow_eta * 4);
208 int axt = (tow_eta * 5) * 20 + tow_phi * 5 + 1;
221 std::cout <<
" The number of towers is = " << itowers << std::endl;
225 m_to_transfer.push_back(std::make_pair((
EcalTPGSpike *)lut, snc));
227 m_i_run_number = irun;
228 m_i_tag = the_config_tag;
229 m_i_version = the_config_version;
230 m_i_spikeTh = spikeId;
232 writeFile(
"last_tpg_spikeThreshold_settings.txt");
235 m_i_run_number = irun;
236 m_i_tag = the_config_tag;
237 m_i_version = the_config_version;
239 writeFile(
"last_tpg_spikeThreshold_settings.txt");
241 std::cout <<
" even if the tag/version is not the same, the lutGroup id is the same -> no transfer needed " 248 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag <<
" version=" << the_config_version
251 m_i_run_number = irun;
253 std::cout <<
" **************** " << std::endl;
255 }
else if (
nr == 0) {
256 m_i_run_number = irun;
257 std::cout <<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
258 std::cout <<
" **************** " << std::endl;
260 m_i_run_number = irun;
261 m_i_tag = the_config_tag;
262 m_i_version = the_config_version;
263 std::cout <<
" the tag/version is the same -> no transfer needed " << std::endl;
264 std::cout <<
" **************** " << std::endl;
265 writeFile(
"last_tpg_spikeThreshold_settings.txt");
272 edm::LogInfo(
"EcalTPGSpikeThresholdHandler") <<
"Ecal - > end of getNewObjects -----------";
292 std::ostringstream
str;
294 fgets(
line, 255, inpFile);
296 str <<
"gen tag " << m_i_tag << std::endl;
298 fgets(
line, 255, inpFile);
299 m_i_version = atoi(
line);
300 str <<
"version= " << m_i_version << std::endl;
302 fgets(
line, 255, inpFile);
303 m_i_run_number = atoi(
line);
304 str <<
"run_number= " << m_i_run_number << std::endl;
306 fgets(
line, 255, inpFile);
307 m_i_spikeTh = atoi(
line);
308 str <<
"spikeTh_config= " << m_i_spikeTh << std::endl;
316 std::ofstream myfile;
318 myfile << m_i_tag << std::endl;
319 myfile << m_i_version << std::endl;
320 myfile << m_i_run_number << std::endl;
321 myfile << m_i_spikeTh << std::endl;
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
T getParameter(std::string const &) const
~EcalTPGSpikeThresholdHandler() override
std::string getName() const
void getNewObjects() override
void readFromFile(const char *inputFile)
std::string m_locationsource
EcalTPGSpikeThresholdHandler(edm::ParameterSet const &)
Log< level::Error, false > LogError
void setValue(const uint32_t &id, const uint16_t &val)
static std::string to_string(const XMLCh *ch)
int getSpikeThreshold() const
void setLocationDef(const LocationDef &locDef)
Log< level::Info, false > LogInfo
constexpr uint32_t rawId() const
get the raw id
void writeFile(const char *inputFile)
std::string getConfigTag() const
void setConfigTag(std::string x)
void setGeneralTag(std::string tag)
static const int SMCRYSTALMODE