23 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalTPGLinConstHandler")) {
24 edm::LogInfo(
"EcalTPGLinConstHandler") <<
"EcalTPGLinConst Source handler constructor";
41 edm::LogInfo(
"EcalTPGLinConstHandler") <<
"Started getNewObjects";
45 std::cout <<
"got offlineInfo = " << std::endl;
49 std::cout <<
" First object for this tag " << std::endl;
52 unsigned int max_since = 0;
53 max_since =
static_cast<unsigned int>(
tagInfo().lastInterval.since);
54 edm::LogInfo(
"EcalTPGLinConstHandler") <<
"max_since = " << max_since;
55 edm::LogInfo(
"EcalTPGLinConstHandler") <<
"Retrieved last payload ";
58 edm::LogInfo(
"EcalTPGLinConstHandler") <<
"Retrieving run list from ONLINE DB ... " << std::endl;
60 edm::LogInfo(
"EcalTPGLinConstHandler") <<
"Making connection..." << std::flush;
62 edm::LogInfo(
"EcalTPGLinConstHandler") <<
"Done." << std::endl;
65 std::cout <<
" connection parameters " << m_sid <<
"/" << m_user << std::endl;
81 readFromFile(
"last_tpg_lin_settings.txt");
85 if (m_firstRun < m_i_run_number) {
86 min_run = m_i_run_number + 1;
91 if (min_run < max_since) {
92 min_run = max_since + 1;
95 std::cout <<
"m_i_run_number" << m_i_run_number <<
"m_firstRun " << m_firstRun <<
"max_since " << max_since
98 unsigned int max_run = m_lastRun;
99 edm::LogInfo(
"EcalTPGLinConstHandler") <<
"min_run= " << min_run <<
"max_run = " << max_run;
102 my_list =
econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run,
my_locdef);
105 std::vector<RunIOV> run_vec = my_list.
getRuns();
106 size_t num_runs = run_vec.size();
108 std::cout <<
"number of runs is : " << num_runs << std::endl;
110 unsigned int irun = 0;
112 for (
size_t kr = 0; kr < run_vec.size(); kr++) {
113 irun =
static_cast<unsigned int>(run_vec[kr].getRunNumber());
114 std::cout <<
" **************** " << std::endl;
115 std::cout <<
" **************** " << std::endl;
116 std::cout <<
" run= " << irun << std::endl;
119 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
123 int the_config_version = 0;
125 std::map<EcalLogicID, RunTPGConfigDat>::const_iterator
it;
139 std::cout <<
" run= " << irun <<
" tag " << the_config_tag <<
" version=" << the_config_version << std::endl;
143 if ((the_config_tag != m_i_tag || the_config_version != m_i_version) &&
nr > 0) {
144 std::cout <<
"the tag is different from last transferred run ... retrieving last config set from DB" 152 std::cout <<
" before fetch config set" << std::endl;
153 econn->fetchConfigSet(&fe_main_info);
154 std::cout <<
" after fetch config set" << std::endl;
157 int linId = fe_main_info.
getLinId();
159 if (linId != m_i_lin) {
161 fe_lin_info.
setId(linId);
162 econn->fetchConfigSet(&fe_lin_info);
163 std::map<EcalLogicID, FEConfigLinDat> dataset_TpgLin;
164 econn->fetchDataSet(&dataset_TpgLin, &fe_lin_info);
167 typedef std::map<EcalLogicID, FEConfigLinDat>::const_iterator CIfelin;
171 for (CIfelin
p = dataset_TpgLin.begin();
p != dataset_TpgLin.end();
p++) {
177 if (ecid_name ==
"EB_crystal_number") {
178 int sm_num = ecid_xt.
getID1();
179 int xt_num = ecid_xt.
getID2();
214 m_i_run_number = irun;
215 m_i_tag = the_config_tag;
216 m_i_version = the_config_version;
219 writeFile(
"last_tpg_lin_settings.txt");
222 m_i_run_number = irun;
223 m_i_tag = the_config_tag;
224 m_i_version = the_config_version;
226 writeFile(
"last_tpg_lin_settings.txt");
228 std::cout <<
" even if the tag/version is not the same, the linearization constants id is the same -> no " 233 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag <<
" version=" << the_config_version
236 m_i_run_number = irun;
238 std::cout <<
" **************** " << std::endl;
240 }
else if (
nr == 0) {
241 m_i_run_number = irun;
242 std::cout <<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
243 std::cout <<
" **************** " << std::endl;
245 m_i_run_number = irun;
246 m_i_tag = the_config_tag;
247 m_i_version = the_config_version;
248 std::cout <<
" the tag/version is the same -> no transfer needed " << std::endl;
249 std::cout <<
" **************** " << std::endl;
250 writeFile(
"last_tpg_lin_settings.txt");
257 edm::LogInfo(
"EcalTPGLinConstHandler") <<
"Ecal - > end of getNewObjects -----------";
277 std::ostringstream
str;
279 fgets(
line, 255, inpFile);
281 str <<
"gen tag " << m_i_tag << std::endl;
283 fgets(
line, 255, inpFile);
284 m_i_version = atoi(
line);
285 str <<
"version= " << m_i_version << std::endl;
287 fgets(
line, 255, inpFile);
288 m_i_run_number = atoi(
line);
289 str <<
"run_number= " << m_i_run_number << std::endl;
291 fgets(
line, 255, inpFile);
292 m_i_lin = atoi(
line);
293 str <<
"lin_config= " << m_i_lin << std::endl;
301 std::ofstream myfile;
303 myfile << m_i_tag << std::endl;
304 myfile << m_i_version << std::endl;
305 myfile << m_i_run_number << std::endl;
306 myfile << m_i_lin << std::endl;
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
T getParameter(std::string const &) const
std::string getName() const
Log< level::Error, false > LogError
void getNewObjects() override
static std::string to_string(const XMLCh *ch)
void setLocationDef(const LocationDef &locDef)
void insert(std::pair< uint32_t, Item > const &a)
Log< level::Info, false > LogInfo
void readFromFile(const char *inputFile)
EcalTPGLinConstHandler(edm::ParameterSet const &)
constexpr uint32_t rawId() const
get the raw id
std::string m_locationsource
std::string getConfigTag() const
void setConfigTag(std::string x)
void writeFile(const char *inputFile)
void setGeneralTag(std::string tag)
static const int SMCRYSTALMODE
~EcalTPGLinConstHandler() override
EcalTPGLinearizationConstMap EcalTPGLinearizationConst