24 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalTPGPedestalsHandler")) {
25 edm::LogInfo(
"EcalTPGPedestalsHandler") <<
"EcalTPGPedestals Source handler constructor";
42 edm::LogInfo(
"EcalTPGPedestalsHandler") <<
"Started getNewObjects";
47 std::cout <<
"got offlineInfo = " << std::endl;
51 std::cout <<
" First object for this tag " << std::endl;
54 unsigned int max_since = 0;
55 max_since =
static_cast<unsigned int>(
tagInfo().lastInterval.since);
56 edm::LogInfo(
"EcalTPGPedestalsHandler") <<
"max_since = " << max_since;
57 edm::LogInfo(
"EcalTPGPedestalsHandler") <<
"Retrieved last payload ";
60 edm::LogInfo(
"EcalTPGPedestalsHandler") <<
"Retrieving run list from ONLINE DB ... " << std::endl;
62 edm::LogInfo(
"EcalTPGPedestalsHandler") <<
"Making connection..." << std::flush;
64 edm::LogInfo(
"EcalTPGPedestalsHandler") <<
"Done." << std::endl;
67 std::cout <<
" Connection parameters " << m_sid <<
"/" << m_user << std::endl;
86 if (m_firstRun < m_i_run_number) {
87 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(
"EcalTPGPedestalsHandler") <<
"min_run= " << min_run <<
" max_run = " << max_run;
101 my_list =
econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run,
my_locdef);
104 std::vector<RunIOV> run_vec = my_list.
getRuns();
105 size_t num_runs = run_vec.size();
107 std::cout <<
"number of runs is : " << num_runs << std::endl;
109 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());
115 std::cout <<
" **************** " << std::endl;
116 std::cout <<
" **************** " << std::endl;
117 std::cout <<
" run= " << irun << std::endl;
120 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
124 int the_config_version = 0;
126 std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
140 std::cout <<
" run= " << irun <<
" tag " << the_config_tag <<
" version=" << the_config_version << std::endl;
144 if ((the_config_tag != m_i_tag || the_config_version != m_i_version) &&
nr > 0) {
145 std::cout <<
"the tag is different from last transferred run ... retrieving last config set from DB" 153 std::cout <<
" before fetch config set" << std::endl;
154 econn->fetchConfigSet(&fe_main_info);
155 std::cout <<
" after fetch config set" << std::endl;
158 int pedId = fe_main_info.
getPedId();
160 if (pedId != m_i_ped) {
162 fe_ped_info.
setId(pedId);
163 econn->fetchConfigSet(&fe_ped_info);
164 std::map<EcalLogicID, FEConfigPedDat> dataset_TpgPed;
165 econn->fetchDataSet(&dataset_TpgPed, &fe_ped_info);
169 typedef std::map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
173 for (CIfeped
p = dataset_TpgPed.begin();
p != dataset_TpgPed.end();
p++) {
180 if (ecid_name ==
"EB_crystal_number") {
183 <<
" icells = " << icells << std::endl;
184 int sm_num = ecid_xt.
getID1();
185 int xt_num = ecid_xt.
getID2();
195 }
else if (ecid_name ==
"EE_crystal_number") {
214 m_i_run_number = irun;
215 m_i_tag = the_config_tag;
216 m_i_version = the_config_version;
219 writeFile(
"last_tpg_ped_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_ped_settings.txt");
228 std::cout <<
" even if the tag/version is not the same, the pedestals id is the same -> no transfer needed " 235 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag <<
" version=" << the_config_version
238 m_i_run_number = irun;
240 std::cout <<
" **************** " << std::endl;
242 }
else if (
nr == 0) {
243 m_i_run_number = irun;
244 std::cout <<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
245 std::cout <<
" **************** " << std::endl;
247 m_i_run_number = irun;
248 m_i_tag = the_config_tag;
249 m_i_version = the_config_version;
250 std::cout <<
" the tag/version is the same -> no transfer needed " << std::endl;
251 std::cout <<
" **************** " << std::endl;
252 writeFile(
"last_tpg_ped_settings.txt");
259 edm::LogInfo(
"EcalTPGPedestalsHandler") <<
"Ecal - > end of getNewObjects -----------";
279 std::ostringstream
str;
281 fgets(
line, 255, inpFile);
283 str <<
"gen tag " << m_i_tag << std::endl;
285 fgets(
line, 255, inpFile);
286 m_i_version = atoi(
line);
287 str <<
"version= " << m_i_version << std::endl;
289 fgets(
line, 255, inpFile);
290 m_i_run_number = atoi(
line);
291 str <<
"run_number= " << m_i_run_number << std::endl;
293 fgets(
line, 255, inpFile);
294 m_i_ped = atoi(
line);
295 str <<
"ped_config= " << m_i_ped << std::endl;
303 std::ofstream myfile;
305 myfile << m_i_tag << std::endl;
306 myfile << m_i_version << std::endl;
307 myfile << m_i_run_number << std::endl;
308 myfile << m_i_ped << std::endl;
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
T getParameter(std::string const &) const
float getPedMeanG6() const
std::string getName() const
std::string to_string(const V &value)
Log< level::Error, false > LogError
void getNewObjects() override
~EcalTPGPedestalsHandler() override
void readFromFile(CaloCluster &c, FILE *file)
float getPedMeanG1() const
void writeFile(const char *inputFile)
std::string m_locationsource
void setLocationDef(const LocationDef &locDef)
void insert(std::pair< uint32_t, Item > const &a)
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)
EcalTPGPedestalsHandler(edm::ParameterSet const &)
void setGeneralTag(std::string tag)
static const int SMCRYSTALMODE
EcalTPGPedestalsMap EcalTPGPedestals
float getPedMeanG12() const