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;
176 for (CIfefgr
p = dataset_TpgFineGrainEB.begin();
p != dataset_TpgFineGrainEB.end();
p++) {
189 f.setValues(RatioL, RatioH, ThrL, ThrH, LutConfId);
196 m_i_run_number = irun;
197 m_i_tag = the_config_tag;
198 m_i_version = the_config_version;
199 m_i_fgrIdMap = fgrId;
201 writeFile(
"last_tpg_fgrIdMap_settings.txt");
204 m_i_run_number = irun;
205 m_i_tag = the_config_tag;
206 m_i_version = the_config_version;
208 writeFile(
"last_tpg_fgrIdMap_settings.txt");
210 std::cout <<
" even if the tag/version is not the same, the fgrIdMap is the same -> no transfer needed " 217 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag <<
" version=" << the_config_version
220 m_i_run_number = irun;
222 std::cout <<
" **************** " << std::endl;
224 }
else if (
nr == 0) {
225 m_i_run_number = irun;
226 std::cout <<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
227 std::cout <<
" **************** " << std::endl;
229 m_i_run_number = irun;
230 m_i_tag = the_config_tag;
231 m_i_version = the_config_version;
232 std::cout <<
" the tag/version is the same -> no transfer needed " << std::endl;
233 std::cout <<
" **************** " << std::endl;
234 writeFile(
"last_tpg_fgrIdMap_settings.txt");
240 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"Ecal - > end of getNewObjects -----------";
260 std::ostringstream
str;
262 fgets(
line, 255, inpFile);
264 str <<
"gen tag " << m_i_tag << std::endl;
266 fgets(
line, 255, inpFile);
267 m_i_version = atoi(
line);
268 str <<
"version= " << m_i_version << std::endl;
270 fgets(
line, 255, inpFile);
271 m_i_run_number = atoi(
line);
272 str <<
"run_number= " << m_i_run_number << std::endl;
274 fgets(
line, 255, inpFile);
275 m_i_fgrIdMap = atoi(
line);
276 str <<
"fgrIdMap_config= " << m_i_fgrIdMap << std::endl;
284 std::ofstream myfile;
286 myfile << m_i_tag << std::endl;
287 myfile << m_i_version << std::endl;
288 myfile << m_i_run_number << std::endl;
289 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 &)
Log< level::Error, false > LogError
void writeFile(const char *inputFile)
static std::string to_string(const XMLCh *ch)
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)