38 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalTPGLutGroupHandler")) {
39 edm::LogInfo(
"EcalTPGLutGroupHandler") <<
"EcalTPGLutGroup Source handler constructor";
59 edm::LogInfo(
"EcalTPGLutGroupHandler") <<
"Started GetNewObjects!!!";
84 std::cout <<
"got offlineInfo = " << std::endl;
88 std::cout <<
" First object for this tag " << std::endl;
91 unsigned int max_since = 0;
92 max_since =
static_cast<unsigned int>(
tagInfo().lastInterval.since);
93 edm::LogInfo(
"EcalTPGLutGroupHandler") <<
"max_since : " << max_since;
94 edm::LogInfo(
"EcalTPGLutGroupHandler") <<
"retrieved last payload ";
97 edm::LogInfo(
"EcalTPGLutGroupHandler") <<
"Retrieving run list from ONLINE DB ... ";
99 edm::LogInfo(
"EcalTPGLutGroupHandler") <<
"Making connection...";
104 std::cout <<
" connection parameters " << m_sid <<
"/" << m_user << std::endl;
122 unsigned int min_run;
124 if (m_firstRun < m_i_run_number) {
125 min_run = m_i_run_number + 1;
127 min_run = m_firstRun;
130 if (min_run < max_since) {
131 min_run = max_since + 1;
134 std::cout <<
"m_i_run_number" << m_i_run_number <<
"m_firstRun " << m_firstRun <<
"max_since " << max_since
137 unsigned int max_run = m_lastRun;
138 edm::LogInfo(
"EcalTPGLutGroupHandler") <<
"min_run= " << min_run <<
" max_run= " << max_run;
141 my_list =
econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run,
my_locdef);
144 std::vector<RunIOV> run_vec = my_list.
getRuns();
145 size_t num_runs = run_vec.size();
147 std::cout <<
"number of runs is : " << num_runs << std::endl;
154 std::vector<EcalLogicID> my_TTEcalLogicId_EE;
155 my_TTEcalLogicId_EE =
econn->getEcalLogicIDSetOrdered(
157 std::cout <<
" GOT the logic ID for the EE trigger towers " << std::endl;
159 for (
size_t kr = 0; kr < run_vec.size(); kr++) {
160 irun =
static_cast<unsigned int>(run_vec[kr].getRunNumber());
162 std::cout <<
" **************** " << std::endl;
163 std::cout <<
" run= " << irun << std::endl;
166 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
170 int the_config_version = 0;
172 std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
186 std::cout <<
" run= " << irun <<
" tag " << the_config_tag <<
" version=" << the_config_version << std::endl;
190 if ((the_config_tag != m_i_tag || the_config_version != m_i_version) &&
nr > 0) {
191 std::cout <<
"the tag is different from last transferred run ... retrieving last config set from DB" 199 std::cout <<
" before fetch config set" << std::endl;
200 econn->fetchConfigSet(&fe_main_info);
201 std::cout <<
" after fetch config set" << std::endl;
204 int lutId = fe_main_info.
getLUTId();
206 if (lutId != m_i_lutGroup) {
208 fe_lut_info.
setId(lutId);
209 econn->fetchConfigSet(&fe_lut_info);
210 std::map<EcalLogicID, FEConfigLUTDat> dataset_TpgLut;
211 econn->fetchDataSet(&dataset_TpgLut, &fe_lut_info);
214 typedef std::map<EcalLogicID, FEConfigLUTDat>::const_iterator CIfelut;
219 for (CIfelut
p = dataset_TpgLut.begin();
p != dataset_TpgLut.end();
p++) {
225 if (ecid_name ==
"EB_trigger_tower") {
227 int smid = ecid_xt.
getID1();
229 int towerid = ecid_xt.
getID2();
231 int tow_eta = (towerid - 1) / 4;
232 int tow_phi = ((towerid - 1) - tow_eta * 4);
234 int axt = (tow_eta * 5) * 20 + tow_phi * 5 + 1;
251 }
else if (ecid_name ==
"EE_trigger_tower") {
254 int tccid = ecid_xt.
getID1();
256 int towerid = ecid_xt.
getID2();
258 bool set_the_tower =
false;
260 for (
size_t itower = 0; itower < my_TTEcalLogicId_EE.size(); itower++) {
261 if (!set_the_tower) {
262 if (my_TTEcalLogicId_EE[itower].getID1() == tccid &&
263 my_TTEcalLogicId_EE[itower].getID2() == towerid) {
264 towid = my_TTEcalLogicId_EE[itower].getLogicID();
265 set_the_tower =
true;
274 std::cout <<
" these may be the additional towers TCC/TT " << tccid <<
"/" << towerid << std::endl;
285 m_i_run_number = irun;
286 m_i_tag = the_config_tag;
287 m_i_version = the_config_version;
288 m_i_lutGroup = lutId;
290 writeFile(
"last_tpg_lutGroup_settings.txt");
293 m_i_run_number = irun;
294 m_i_tag = the_config_tag;
295 m_i_version = the_config_version;
297 writeFile(
"last_tpg_lutGroup_settings.txt");
299 std::cout <<
" even if the tag/version is not the same, the lutGroup id is the same -> no transfer needed " 306 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag <<
" version=" << the_config_version
309 m_i_run_number = irun;
311 std::cout <<
" **************** " << std::endl;
313 }
else if (
nr == 0) {
314 m_i_run_number = irun;
315 std::cout <<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
316 std::cout <<
" **************** " << std::endl;
318 m_i_run_number = irun;
319 m_i_tag = the_config_tag;
320 m_i_version = the_config_version;
321 std::cout <<
" the tag/version is the same -> no transfer needed " << std::endl;
322 std::cout <<
" **************** " << std::endl;
323 writeFile(
"last_tpg_lutGroup_settings.txt");
330 edm::LogInfo(
"EcalTPGLutGroupHandler") <<
"Ecal - > end of getNewObjects -----------";
350 std::ostringstream
str;
352 fgets(
line, 255, inpFile);
354 str <<
"gen tag " << m_i_tag << std::endl;
356 fgets(
line, 255, inpFile);
357 m_i_version = atoi(
line);
358 str <<
"version= " << m_i_version << std::endl;
360 fgets(
line, 255, inpFile);
361 m_i_run_number = atoi(
line);
362 str <<
"run_number= " << m_i_run_number << std::endl;
364 fgets(
line, 255, inpFile);
365 m_i_lutGroup = atoi(
line);
366 str <<
"lutGroup_config= " << m_i_lutGroup << std::endl;
374 std::ofstream myfile;
376 myfile << m_i_tag << std::endl;
377 myfile << m_i_version << std::endl;
378 myfile << m_i_run_number << std::endl;
379 myfile << m_i_lutGroup << std::endl;
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
int getLUTGroupId() const
T getParameter(std::string const &) const
void readFromFile(const char *inputFile)
std::string getName() const
~EcalTPGLutGroupHandler() override
std::string to_string(const V &value)
Log< level::Error, false > LogError
void readFromFile(CaloCluster &c, FILE *file)
void writeFile(const char *inputFile)
void setValue(const uint32_t &rawId, const uint32_t &ObjectId)
void setLocationDef(const LocationDef &locDef)
void getNewObjects() override
Log< level::Info, false > LogInfo
constexpr uint32_t rawId() const
get the raw id
std::string getConfigTag() const
std::string m_locationsource
void setConfigTag(std::string x)
void setGeneralTag(std::string tag)
static const int SMCRYSTALMODE
EcalTPGLutGroupHandler(edm::ParameterSet const &)