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);
188 for (CIfeped
p = dataset_TpgBadTT.begin();
p != dataset_TpgBadTT.end();
p++) {
192 int tt_num = rd_badTT.
getTTId();
194 std::cout <<
" tcc/tt" << tcc_num <<
"/" << tt_num << std::endl;
196 if (tcc_num > 36 && tcc_num <= 72) {
198 int smid = tcc_num - 54;
202 int towerid = tt_num;
204 int tow_eta = (towerid - 1) / 4;
205 int tow_phi = ((towerid - 1) - tow_eta * 4);
206 int axt = (tow_eta * 5) * 20 + tow_phi * 5 + 1;
218 int towerid = tt_num;
220 bool set_the_tower =
false;
222 for (
size_t itower = 0; itower < my_TTEcalLogicId_EE.size(); itower++) {
223 if (!set_the_tower) {
224 if (my_TTEcalLogicId_EE[itower].getID1() == tccid &&
225 my_TTEcalLogicId_EE[itower].getID2() == towerid) {
226 towid = my_TTEcalLogicId_EE[itower].getLogicID();
227 set_the_tower =
true;
237 std::cout <<
" these may be the additional towers TCC/TT " << tccid <<
"/" << towerid << std::endl;
242 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"Finished badTT reading.";
248 m_i_run_number = irun;
249 m_i_tag = the_config_tag;
250 m_i_version = the_config_version;
253 writeFile(
"last_tpg_badTT_settings.txt");
256 m_i_run_number = irun;
257 m_i_tag = the_config_tag;
258 m_i_version = the_config_version;
260 writeFile(
"last_tpg_badTT_settings.txt");
268 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag <<
" version=" << the_config_version
271 m_i_run_number = irun;
274 }
else if (
nr == 0) {
275 m_i_run_number = irun;
278 m_i_run_number = irun;
279 m_i_tag = the_config_tag;
280 m_i_version = the_config_version;
282 writeFile(
"last_tpg_badTT_settings.txt");
289 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"Ecal - > end of getNewObjects -----------";
309 std::ostringstream
str;
311 fgets(
line, 255, inpFile);
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_badTT = atoi(
line);
325 str <<
"badTT_config= " << m_i_badTT << 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_badTT << std::endl;
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
T getParameter(std::string const &) const
Log< level::Error, false > LogError
static std::string to_string(const XMLCh *ch)
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 &)