25 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalTPGBadTTHandler")) {
26 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"EcalTPGTowerStatus Source handler constructor.";
43 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"Started GetNewObjects!!!";
45 unsigned int max_since = 0;
46 max_since =
static_cast<unsigned int>(
tagInfo().lastInterval.since);
47 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"max_since : " << max_since;
48 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"retrieved last payload ";
51 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"Retrieving run list from ONLINE DB ... ";
53 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"Making connection...";
58 std::cout <<
" connection parameters " << m_sid <<
"/" << m_user << std::endl;
73 readFromFile(
"last_tpg_badTT_settings.txt");
77 if (m_firstRun < m_i_run_number) {
78 min_run = m_i_run_number + 1;
82 if (min_run < max_since) {
83 min_run = max_since + 1;
86 std::cout <<
"m_i_run_number" << m_i_run_number <<
"m_firstRun " << m_firstRun <<
"max_since " << max_since
89 unsigned int max_run = m_lastRun;
90 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"min_run= " << min_run <<
"max_run= " << max_run;
94 my_list =
econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run,
my_locdef);
96 std::vector<RunIOV> run_vec = my_list.
getRuns();
97 size_t num_runs = run_vec.size();
99 std::cout <<
"number of runs is : " << num_runs << std::endl;
103 unsigned int irun = 0;
106 std::vector<EcalLogicID> my_TTEcalLogicId_EE;
107 my_TTEcalLogicId_EE =
econn->getEcalLogicIDSetOrdered(
109 std::cout <<
" GOT the logic ID for the EE trigger towers " << std::endl;
111 for (
size_t kr = 0; kr < run_vec.size(); kr++) {
112 irun =
static_cast<unsigned int>(run_vec[kr].getRunNumber());
115 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
119 int the_config_version = 0;
121 std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
137 if ((the_config_tag != m_i_tag || the_config_version != m_i_version) &&
nr > 0) {
138 std::cout <<
" run= " << irun <<
" tag " << the_config_tag <<
" version=" << the_config_version << std::endl;
139 std::cout <<
"the tag is different from last transferred run ... retrieving last config set from DB" 147 econn->fetchConfigSet(&fe_main_info);
150 int badttId = fe_main_info.
getBttId();
152 if (badttId != m_i_badTT) {
154 fe_badTT_info.
setId(badttId);
156 econn->fetchConfigSet(&fe_badTT_info);
158 std::vector<FEConfigBadTTDat> dataset_TpgBadTT;
160 econn->fetchConfigDataSet(&dataset_TpgBadTT, &fe_badTT_info);
163 typedef std::vector<FEConfigBadTTDat>::const_iterator CIfeped;
170 for (
int ito = 1; ito <= 68; ito++) {
171 int tow_eta = (ito - 1) / 4;
172 int tow_phi = ((ito - 1) - tow_eta * 4);
173 int axt = (tow_eta * 5) * 20 + tow_phi * 5 + 1;
176 int tower_status = 0;
181 for (
size_t itower = 0; itower < my_TTEcalLogicId_EE.size(); itower++) {
182 int towid = my_TTEcalLogicId_EE[itower].getLogicID();
183 int tower_status = 0;
184 towerStatus->
setValue(towid, tower_status);
189 for (CIfeped
p = dataset_TpgBadTT.begin();
p != dataset_TpgBadTT.end();
p++) {
193 int tt_num = rd_badTT.
getTTId();
195 std::cout <<
" tcc/tt" << tcc_num <<
"/" << tt_num << std::endl;
197 if (tcc_num > 36 && tcc_num <= 72) {
199 int smid = tcc_num - 54;
203 int towerid = tt_num;
205 int tow_eta = (towerid - 1) / 4;
206 int tow_phi = ((towerid - 1) - tow_eta * 4);
207 int axt = (tow_eta * 5) * 20 + tow_phi * 5 + 1;
220 int towerid = tt_num;
222 bool set_the_tower =
false;
224 for (
size_t itower = 0; itower < my_TTEcalLogicId_EE.size(); itower++) {
225 if (!set_the_tower) {
226 if (my_TTEcalLogicId_EE[itower].getID1() == tccid &&
227 my_TTEcalLogicId_EE[itower].getID2() == towerid) {
228 towid = my_TTEcalLogicId_EE[itower].getLogicID();
229 set_the_tower =
true;
239 std::cout <<
" these may be the additional towers TCC/TT " << tccid <<
"/" << towerid << std::endl;
246 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"Finished badTT reading.";
252 m_i_run_number = irun;
253 m_i_tag = the_config_tag;
254 m_i_version = the_config_version;
257 writeFile(
"last_tpg_badTT_settings.txt");
260 m_i_run_number = irun;
261 m_i_tag = the_config_tag;
262 m_i_version = the_config_version;
264 writeFile(
"last_tpg_badTT_settings.txt");
272 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag <<
" version=" << the_config_version
275 m_i_run_number = irun;
278 }
else if (
nr == 0) {
279 m_i_run_number = irun;
282 m_i_run_number = irun;
283 m_i_tag = the_config_tag;
284 m_i_version = the_config_version;
286 writeFile(
"last_tpg_badTT_settings.txt");
293 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"Ecal - > end of getNewObjects -----------";
313 std::ostringstream
str;
315 fgets(
line, 255, inpFile);
317 str <<
"gen tag " << m_i_tag << std::endl;
319 fgets(
line, 255, inpFile);
320 m_i_version = atoi(
line);
321 str <<
"version= " << m_i_version << std::endl;
323 fgets(
line, 255, inpFile);
324 m_i_run_number = atoi(
line);
325 str <<
"run_number= " << m_i_run_number << std::endl;
327 fgets(
line, 255, inpFile);
328 m_i_badTT = atoi(
line);
329 str <<
"badTT_config= " << m_i_badTT << std::endl;
337 std::ofstream myfile;
339 myfile << m_i_tag << std::endl;
340 myfile << m_i_version << std::endl;
341 myfile << m_i_run_number << std::endl;
342 myfile << m_i_badTT << std::endl;
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
T getParameter(std::string const &) const
std::string to_string(const V &value)
Log< level::Error, false > LogError
std::string m_locationsource
~EcalTPGBadTTHandler() override
void getNewObjects() override
void writeFile(const char *inputFile)
void setLocationDef(const LocationDef &locDef)
Log< level::Info, false > LogInfo
constexpr uint32_t rawId() const
get the raw id
void readFromFile(const char *inputFile)
std::string getConfigTag() const
void setConfigTag(std::string x)
void setValue(const uint32_t &id, const uint16_t &val)
void setGeneralTag(std::string tag)
static const int SMCRYSTALMODE
int ism(int ieta, int iphi)
EcalTPGBadTTHandler(edm::ParameterSet const &)