25 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalTPGBadXTHandler")) {
26 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"EcalTPGBadXT Source handler constructor.";
43 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"Started GetNewObjects!!!";
45 unsigned int max_since = 0;
46 max_since =
static_cast<unsigned int>(
tagInfo().lastInterval.since);
47 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"max_since : " << max_since;
48 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"retrieved last payload ";
51 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"Retrieving run list from ONLINE DB ... ";
53 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"Making connection...";
58 std::cout <<
" connection parameters " << m_sid <<
"/" << m_user << std::endl;
74 readFromFile(
"last_tpg_badXT_settings.txt");
78 if (m_firstRun < m_i_run_number) {
79 min_run = m_i_run_number + 1;
83 if (min_run < max_since) {
84 min_run = max_since + 1;
87 std::cout <<
"m_i_run_number" << m_i_run_number <<
"m_firstRun " << m_firstRun <<
"max_since " << max_since
90 unsigned int max_run = m_lastRun;
91 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"min_run= " << min_run <<
"max_run= " << max_run;
94 my_list =
econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run,
my_locdef);
97 std::vector<RunIOV> run_vec = my_list.
getRuns();
98 size_t num_runs = run_vec.size();
100 std::cout <<
"number of runs is : " << num_runs << std::endl;
102 std::vector<EcalLogicID> my_EcalLogicId;
103 std::vector<EcalLogicID> my_EcalLogicId_EE;
105 unsigned int irun = 0;
107 my_EcalLogicId =
econn->getEcalLogicIDSetOrdered(
108 "ECAL_crystal_number_fedccuxt", 610, 650, 1, 100, 0, 100,
"EB_crystal_number", 123);
110 my_EcalLogicId_EE =
econn->getEcalLogicIDSetOrdered(
111 "ECAL_crystal_number_fedccuxt", 600, 700, 1, 100, 0, 100,
"EE_crystal_number", 123);
113 for (
size_t kr = 0; kr < run_vec.size(); kr++) {
114 std::cout <<
"here we are in run " << kr << std::endl;
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;
142 std::cout <<
" run= " << irun <<
" tag " << the_config_tag <<
" version=" << the_config_version << std::endl;
146 if ((the_config_tag != m_i_tag || the_config_version != m_i_version) &&
nr > 0) {
147 std::cout <<
"the tag is different from last transferred run ... retrieving last config set from DB" 156 std::cout <<
" before fetch config set" << std::endl;
157 econn->fetchConfigSet(&fe_main_info);
158 std::cout <<
" after fetch config set" << std::endl;
161 int badxtId = fe_main_info.
getBxtId();
163 if (badxtId != m_i_badXT && badxtId != 0) {
165 fe_badXt_info.
setId(badxtId);
166 econn->fetchConfigSet(&fe_badXt_info);
167 std::vector<FEConfigBadXTDat> dataset_TpgBadXT;
168 econn->fetchConfigDataSet(&dataset_TpgBadXT, &fe_badXt_info);
173 badXt = produceEcalTrgChannelStatus();
175 typedef std::vector<FEConfigBadXTDat>::const_iterator CIfeped;
179 for (CIfeped
p = dataset_TpgBadXT.begin();
p != dataset_TpgBadXT.end();
p++) {
184 int tt_id = rd_badXt.
getTTId();
185 int xt_id = rd_badXt.
getXTId();
188 if (fed_id >= 610 && fed_id <= 645) {
193 sm_num = fed_id - 609 + 18;
195 sm_num = fed_id - 627;
200 for (
size_t ixt = 0; ixt < my_EcalLogicId.size(); ixt++) {
201 if (my_EcalLogicId[ixt].getID1() == fed_id && my_EcalLogicId[ixt].getID2() == tt_id &&
202 my_EcalLogicId[ixt].getID3() == xt_id) {
204 int ecid = my_EcalLogicId[ixt].getLogicID();
205 xt_num = (ecid) - (101100 + sm_num) * 10000;
209 std::cout <<
" masking crystal " << sm_num <<
"/" << xt_num <<
" from fed/tt/xt" << fed_id <<
"/" 210 << tt_id <<
"/" << xt_id << std::endl;
211 if (sm_num == 0 && xt_num == 0) {
212 std::cout <<
" ERROR FOR crystal from fed/tt/xt" << fed_id <<
"/" << tt_id <<
"/" << xt_id
225 for (
size_t ixt = 0; ixt < my_EcalLogicId_EE.size(); ixt++) {
226 if (my_EcalLogicId_EE[ixt].getID1() == fed_id && my_EcalLogicId_EE[ixt].getID2() == tt_id &&
227 my_EcalLogicId_EE[ixt].getID3() == xt_id) {
228 long ecid = (long)my_EcalLogicId_EE[ixt].getLogicID();
230 y = ecid - ((long)(ecid / 1000)) * 1000;
231 x = (ecid -
y) / 1000;
232 x =
x - ((long)(
x / 1000)) * 1000;
233 z = (ecid -
y -
x * 1000) / 1000000 - 2010;
241 if (
x == 0 &&
y == 0 &&
z == 0) {
242 std::cout <<
" ERROR FOR crystal from fed/tt/xt" << fed_id <<
"/" << tt_id <<
"/" << xt_id
250 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"Finished badXT reading";
255 m_i_run_number = irun;
256 m_i_tag = the_config_tag;
257 m_i_version = the_config_version;
260 writeFile(
"last_tpg_badXT_settings.txt");
263 m_i_run_number = irun;
264 m_i_tag = the_config_tag;
265 m_i_version = the_config_version;
267 writeFile(
"last_tpg_badXT_settings.txt");
269 std::cout <<
" even if the tag/version is not the same, the badXT id is the same -> no transfer needed " 276 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag <<
" version=" << the_config_version
279 m_i_run_number = irun;
281 std::cout <<
" **************** " << std::endl;
283 }
else if (
nr == 0) {
284 m_i_run_number = irun;
285 std::cout <<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
286 std::cout <<
" **************** " << std::endl;
288 m_i_run_number = irun;
289 m_i_tag = the_config_tag;
290 m_i_version = the_config_version;
291 std::cout <<
" the tag/version is the same -> no transfer needed " << std::endl;
292 std::cout <<
" **************** " << std::endl;
293 writeFile(
"last_tpg_badXT_settings.txt");
301 edm::LogInfo(
"EcalTPGBadXTHandler") <<
"Ecal - > end of getNewObjects -----------";
321 std::ostringstream
str;
323 fgets(
line, 255, inpFile);
325 str <<
"gen tag " << m_i_tag << std::endl;
327 fgets(
line, 255, inpFile);
328 m_i_version = atoi(
line);
329 str <<
"version= " << m_i_version << std::endl;
331 fgets(
line, 255, inpFile);
332 m_i_run_number = atoi(
line);
333 str <<
"run_number= " << m_i_run_number << std::endl;
335 fgets(
line, 255, inpFile);
336 m_i_badXT = atoi(
line);
337 str <<
"badXT_config= " << m_i_badXT << std::endl;
345 std::ofstream myfile;
347 myfile << m_i_tag << std::endl;
348 myfile << m_i_version << std::endl;
349 myfile << m_i_run_number << std::endl;
350 myfile << m_i_badXT << std::endl;
377 EEDetId eedetidneg(iX, iY, -1);
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
T getParameter(std::string const &) const
static const int MIN_IPHI
void writeFile(const char *inputFile)
void getNewObjects() override
Log< level::Error, false > LogError
static std::string to_string(const XMLCh *ch)
static bool validDetId(int i, int j)
check if a valid index combination
void setValue(const uint32_t id, const Item &item)
EcalTPGCrystalStatusMap EcalTPGCrystalStatus
void setLocationDef(const LocationDef &locDef)
EcalTPGCrystalStatus * produceEcalTrgChannelStatus()
EcalTPGBadXTHandler(edm::ParameterSet const &)
Log< level::Info, false > LogInfo
static const int MAX_IPHI
constexpr uint32_t rawId() const
get the raw id
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
static const int MAX_IETA
~EcalTPGBadXTHandler() override
std::string getConfigTag() const
void setConfigTag(std::string x)
std::string m_locationsource
void setGeneralTag(std::string tag)
static const int SMCRYSTALMODE
void readFromFile(const char *inputFile)