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;
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;
127 econn->fetchDataSet(&dataset, &run_vec[kr]);
130 int the_config_version = 0;
132 std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
135 for (it = dataset.begin(); it != dataset.end(); 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++) {
184 unsigned int ThrL = (
unsigned int)rd_fgr.
getThreshLow();
186 unsigned int RatioL = (
unsigned int)rd_fgr.
getRatioLow();
187 unsigned int RatioH = (
unsigned int)rd_fgr.
getRatioHigh();
188 unsigned int LutConfId = (
unsigned int)rd_fgr.
getLUTValue();
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 -----------";
254 inpFile = fopen(inputFile,
"r");
262 std::ostringstream
str;
264 fgets(line, 255, inpFile);
265 m_i_tag = to_string(line);
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;
287 myfile.open(inputFile);
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()
std::string getConfigTag() const
EcalTPGFineGrainEBIdMapHandler(edm::ParameterSet const &)
void setValues(const uint32_t &ThresholdETLow, const uint32_t &ThresholdETHigh, const uint32_t &RatioLow, const uint32_t &RatioHigh, const uint32_t &LUT)
Log< level::Error, false > LogError
void writeFile(const char *inputFile)
void readFromFile(CaloCluster &c, FILE *file)
std::string getName() const
void readFromFile(const char *inputFile)
int getFgrGroupId() const
void getNewObjects() override
std::string m_locationsource
~EcalTPGFineGrainEBIdMapHandler() override
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
float getRatioLow() const
void setLocationDef(const LocationDef &locDef)
Log< level::Info, false > LogInfo
float getThreshLow() const
float getRatioHigh() const
void setRunType(std::string runtype)
T getParameter(std::string const &) const
static std::vector< std::string > checklist dat
std::unique_ptr< EcalTPGFineGrainEBIdMap > Ref
void setConfigTag(std::string x)
void setLocation(std::string loc)
float getThreshHigh() const
void setGeneralTag(std::string tag)
tuple size
Write out results.