22 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalTPGFineGrainEBIdMapHandler")) {
23 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"EcalTPGFineGrainEBIdMap Source handler constructor.";
40 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"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(
"EcalTPGFineGrainEBIdMapHandler") <<
"max_since : " << max_since;
55 Ref fgrIdMap_db = lastPayload();
57 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"retrieved last payload ";
59 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"WOW: we just retrieved the last valid record from DB ";
63 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"Retrieving run list from ONLINE DB ... ";
65 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"Making connection...";
67 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"Done.";
70 std::cout <<
" connection parameters " << m_sid <<
"/" << m_user << std::endl;
86 readFromFile(
"last_tpg_fgrIdMap_settings.txt");
90 if (m_firstRun < m_i_run_number) {
91 min_run = m_i_run_number + 1;
95 if (min_run < max_since) {
96 min_run = max_since + 1;
99 std::cout <<
"m_i_run_number" << m_i_run_number <<
"m_firstRun " << m_firstRun <<
"max_since " << max_since
102 unsigned int max_run = m_lastRun;
103 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"min_run= " << min_run <<
"max_run= " << max_run;
106 my_list =
econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run,
my_locdef);
108 printf(
"after fetchRunList\n");
111 std::vector<RunIOV> run_vec = my_list.
getRuns();
112 size_t num_runs = run_vec.size();
114 std::cout <<
"number of runs is : " << num_runs << std::endl;
118 for (
size_t kr = 0; kr < run_vec.size(); kr++) {
119 irun =
static_cast<unsigned int>(run_vec[kr].getRunNumber());
121 std::cout <<
" **************** " << std::endl;
122 std::cout <<
" **************** " << std::endl;
123 std::cout <<
" run= " << irun << std::endl;
126 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
130 int the_config_version = 0;
132 std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
145 std::cout <<
" run= " << irun <<
" tag " << the_config_tag <<
" version=" << the_config_version << std::endl;
149 if ((the_config_tag != m_i_tag || the_config_version != m_i_version) &&
nr > 0) {
150 std::cout <<
"the tag is different from last transferred run ... retrieving last config set from DB" 158 std::cout <<
" before fetch config set" << std::endl;
159 econn->fetchConfigSet(&fe_main_info);
160 std::cout <<
" after fetch config set" << std::endl;
163 int fgrId = fe_main_info.
getFgrId();
164 if (fgrId != m_i_fgrIdMap) {
166 fe_fgr_info.
setId(fgrId);
167 econn->fetchConfigSet(&fe_fgr_info);
168 std::map<EcalLogicID, FEConfigFgrGroupDat> dataset_TpgFineGrainEB;
169 econn->fetchDataSet(&dataset_TpgFineGrainEB, &fe_fgr_info);
170 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"Got object!";
172 typedef std::map<EcalLogicID, FEConfigFgrGroupDat>::const_iterator CIfefgr;
177 for (CIfefgr
p = dataset_TpgFineGrainEB.begin();
p != dataset_TpgFineGrainEB.end();
p++) {
190 f.setValues(RatioL, RatioH, ThrL, ThrH, LutConfId);
198 m_i_run_number = irun;
199 m_i_tag = the_config_tag;
200 m_i_version = the_config_version;
201 m_i_fgrIdMap = fgrId;
203 writeFile(
"last_tpg_fgrIdMap_settings.txt");
206 m_i_run_number = irun;
207 m_i_tag = the_config_tag;
208 m_i_version = the_config_version;
210 writeFile(
"last_tpg_fgrIdMap_settings.txt");
212 std::cout <<
" even if the tag/version is not the same, the fgrIdMap is the same -> no transfer needed " 219 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag <<
" version=" << the_config_version
222 m_i_run_number = irun;
224 std::cout <<
" **************** " << std::endl;
226 }
else if (
nr == 0) {
227 m_i_run_number = irun;
228 std::cout <<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
229 std::cout <<
" **************** " << std::endl;
231 m_i_run_number = irun;
232 m_i_tag = the_config_tag;
233 m_i_version = the_config_version;
234 std::cout <<
" the tag/version is the same -> no transfer needed " << std::endl;
235 std::cout <<
" **************** " << std::endl;
236 writeFile(
"last_tpg_fgrIdMap_settings.txt");
242 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"Ecal - > end of getNewObjects -----------";
262 std::ostringstream
str;
264 fgets(
line, 255, inpFile);
266 str <<
"gen tag " << m_i_tag << std::endl;
268 fgets(
line, 255, inpFile);
269 m_i_version = atoi(
line);
270 str <<
"version= " << m_i_version << std::endl;
272 fgets(
line, 255, inpFile);
273 m_i_run_number = atoi(
line);
274 str <<
"run_number= " << m_i_run_number << std::endl;
276 fgets(
line, 255, inpFile);
277 m_i_fgrIdMap = atoi(
line);
278 str <<
"fgrIdMap_config= " << m_i_fgrIdMap << std::endl;
286 std::ofstream myfile;
288 myfile << m_i_tag << std::endl;
289 myfile << m_i_version << std::endl;
290 myfile << m_i_run_number << std::endl;
291 myfile << m_i_fgrIdMap << std::endl;
void setRunTypeDef(const RunTypeDef &runTypeDef)
void setValue(const uint32_t &id, const EcalTPGFineGrainConstEB &value)
std::vector< RunIOV > getRuns()
T getParameter(std::string const &) const
std::string getName() const
int getFgrGroupId() const
float getRatioHigh() const
EcalTPGFineGrainEBIdMapHandler(edm::ParameterSet const &)
std::string to_string(const V &value)
Log< level::Error, false > LogError
void writeFile(const char *inputFile)
void readFromFile(const char *inputFile)
float getRatioLow() const
void getNewObjects() override
std::string m_locationsource
float getThreshHigh() const
~EcalTPGFineGrainEBIdMapHandler() override
void setLocationDef(const LocationDef &locDef)
Log< level::Info, false > LogInfo
std::string getConfigTag() const
std::unique_ptr< EcalTPGFineGrainEBIdMap > Ref
void setConfigTag(std::string x)
float getThreshLow() const
void setGeneralTag(std::string tag)