15 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalTPGPhysicsConstHandler")) {
16 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"EcalTPGPhysicsConst Source handler constructor.";
33 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"Started GetNewObjects!!!";
38 std::cout <<
"got offlineInfo = " << std::endl;
42 std::cout <<
" First object for this tag " << std::endl;
45 unsigned int max_since = 0;
46 max_since =
static_cast<unsigned int>(
tagInfo().lastInterval.since);
47 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"max_since : " << max_since;
48 Ref physC_db = lastPayload();
50 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"retrieved last payload ";
53 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"Retrieving run list from ONLINE DB ... ";
55 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"Making connection...";
60 std::cout <<
" connection parameters " << m_sid <<
"/" << m_user << std::endl;
76 readFromFile(
"last_tpg_physC_settings.txt");
80 if (m_firstRun < m_i_run_number) {
81 min_run = m_i_run_number + 1;
86 std::cout <<
"m_i_run_number" << m_i_run_number <<
"m_firstRun " << m_firstRun <<
"max_since " << max_since
89 if (min_run < max_since) {
90 min_run = max_since + 1;
93 unsigned int max_run = m_lastRun;
94 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"min_run= " << min_run <<
"max_run= " << max_run;
97 my_list =
econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run,
my_locdef);
100 std::vector<RunIOV> run_vec = my_list.
getRuns();
101 size_t num_runs = run_vec.size();
103 std::cout <<
"number of runs is : " << num_runs << std::endl;
107 for (
size_t kr = 0; kr < run_vec.size(); kr++) {
108 irun =
static_cast<unsigned int>(run_vec[kr].getRunNumber());
110 std::cout <<
" **************** " << std::endl;
111 std::cout <<
" **************** " << std::endl;
112 std::cout <<
" run= " << irun << std::endl;
115 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
119 int the_config_version = 0;
121 std::map<EcalLogicID, RunTPGConfigDat>::const_iterator
it;
134 std::cout <<
" run= " << irun <<
" tag " << the_config_tag <<
" version=" << the_config_version << std::endl;
138 if ((the_config_tag != m_i_tag || the_config_version != m_i_version) &&
nr > 0) {
139 std::cout <<
"the tag is different from last transferred run ... retrieving last config set from DB" 147 std::cout <<
" before fetch config set" << std::endl;
148 econn->fetchConfigSet(&fe_main_info);
149 std::cout <<
" after fetch config set" << std::endl;
152 int linId = fe_main_info.
getLinId();
153 int fgrId = fe_main_info.
getFgrId();
154 int lutId = fe_main_info.
getLUTId();
156 if ((linId != m_i_physClin) || (fgrId != m_i_physCfgr) || (lutId != m_i_physClut)) {
157 std::cout <<
"one of the parameters: linId, LutId or fgrId is different from" << std::endl;
158 std::cout <<
"last transferred run ..." << std::endl;
163 fe_physLin_info.
setId(linId);
164 fe_physFgr_info.
setId(fgrId);
165 fe_physLut_info.
setId(lutId);
167 econn->fetchConfigSet(&fe_physLin_info);
168 econn->fetchConfigSet(&fe_physFgr_info);
169 econn->fetchConfigSet(&fe_physLut_info);
170 std::map<EcalLogicID, FEConfigLinParamDat> dataset_TpgPhysicsLin;
171 std::map<EcalLogicID, FEConfigLUTParamDat> dataset_TpgPhysicsLut;
172 std::map<EcalLogicID, FEConfigFgrParamDat> dataset_TpgPhysicsFgr;
174 econn->fetchDataSet(&dataset_TpgPhysicsLin, &fe_physLin_info);
175 econn->fetchDataSet(&dataset_TpgPhysicsLut, &fe_physLut_info);
176 econn->fetchDataSet(&dataset_TpgPhysicsFgr, &fe_physFgr_info);
179 typedef std::map<EcalLogicID, FEConfigLinParamDat>::const_iterator CIfeLin;
180 typedef std::map<EcalLogicID, FEConfigLUTParamDat>::const_iterator CIfeLUT;
181 typedef std::map<EcalLogicID, FEConfigFgrParamDat>::const_iterator CIfeFgr;
190 std::map<int, float> EtSatLinEB;
191 std::map<int, float> EtSatLinEE;
192 typedef std::map<int, float>::const_iterator itEtSat;
194 std::map<int, EcalTPGPhysicsConst::Item> temporaryMapEB;
195 std::map<int, EcalTPGPhysicsConst::Item> temporaryMapEE;
196 typedef std::map<int, EcalTPGPhysicsConst::Item>::iterator iterEB;
197 typedef std::map<int, EcalTPGPhysicsConst::Item>::iterator iterEE;
199 for (CIfeLin p0 = dataset_TpgPhysicsLin.begin(); p0 != dataset_TpgPhysicsLin.end(); p0++) {
200 ecidLin_xt = p0->first;
201 rd_physLin = p0->second;
205 if (ecid_nameLin ==
"EB") {
207 EtSatLinEB.insert(std::make_pair(eb.
rawId(), rd_physLin.
getETSat()));
208 }
else if (ecid_nameLin ==
"EE") {
210 EtSatLinEE.insert(std::make_pair(ee.
rawId(), rd_physLin.
getETSat()));
214 for (CIfeLUT
p1 = dataset_TpgPhysicsLut.begin();
p1 != dataset_TpgPhysicsLut.end();
p1++) {
215 ecidLut_xt =
p1->first;
216 rd_physLut =
p1->second;
221 if (ecid_nameLut ==
"EB") {
224 for (itEtSat it1 = EtSatLinEB.begin(); it1 != EtSatLinEB.end(); it1++) {
225 if (it1->first == (
int)eb.
rawId()) {
226 float ETSatLin = it1->second;
228 if (rd_physLut.
getETSat() == ETSatLin) {
233 item.FG_lowThreshold = 0;
234 item.FG_highThreshold = 0;
235 item.FG_lowRatio = 0;
236 item.FG_highRatio = 0;
237 temporaryMapEB.insert(std::make_pair(eb.
rawId(),
item));
239 throw cms::Exception(
"The values of the ETSatLin and ETSatLut are different.");
243 }
else if (ecid_nameLut ==
"EE") {
248 for (itEtSat it2 = EtSatLinEE.begin(); it2 != EtSatLinEE.end(); it2++) {
249 if (it2->first == (
int)ee.
rawId()) {
250 float ETSatLin = it2->second;
252 if (rd_physLut.
getETSat() == ETSatLin) {
257 item.FG_lowThreshold = 0;
258 item.FG_highThreshold = 0;
259 item.FG_lowRatio = 0;
260 item.FG_highRatio = 0;
261 temporaryMapEE.insert(std::make_pair(ee.
rawId(),
item));
263 throw cms::Exception(
"The values of the ETSatLin and ETSatLut are different.");
269 for (CIfeFgr
p2 = dataset_TpgPhysicsFgr.begin();
p2 != dataset_TpgPhysicsFgr.end();
p2++) {
270 ecidFgr_xt =
p2->first;
271 rd_physFgr =
p2->second;
276 if (ecid_nameFgr ==
"EB") {
279 for (iterEB itt = temporaryMapEB.begin(); itt != temporaryMapEB.end(); itt++) {
280 if (itt->first == (
int)eb.
rawId()) {
290 }
else if (ecid_nameFgr ==
"EE") {
295 for (iterEE itEE = temporaryMapEE.begin(); itEE != temporaryMapEE.end(); itEE++) {
296 if (itEE->first == (
int)ee.
rawId()) {
313 m_i_run_number = irun;
314 m_i_tag = the_config_tag;
315 m_i_version = the_config_version;
316 m_i_physClin = linId;
317 m_i_physClut = lutId;
318 m_i_physCfgr = fgrId;
320 writeFile(
"last_tpg_physC_settings.txt");
323 m_i_run_number = irun;
324 m_i_tag = the_config_tag;
325 m_i_version = the_config_version;
327 writeFile(
"last_tpg_physC_settings.txt");
329 std::cout <<
" even if the tag/version is not the same, the physics constants id is the same -> no " 337 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag <<
" version=" << the_config_version
340 m_i_run_number = irun;
342 std::cout <<
" **************** " << std::endl;
344 }
else if (
nr == 0) {
345 m_i_run_number = irun;
346 std::cout <<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
347 std::cout <<
" **************** " << std::endl;
349 m_i_run_number = irun;
350 m_i_tag = the_config_tag;
351 m_i_version = the_config_version;
352 std::cout <<
" the tag/version is the same -> no transfer needed " << std::endl;
353 std::cout <<
" **************** " << std::endl;
354 writeFile(
"last_tpg_physC_settings.txt");
360 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"Ecal - > end of getNewObjects -----------";
382 std::ostringstream
str;
384 fgets(
line, 255, inpFile);
386 str <<
"gen tag " << m_i_tag << std::endl;
388 fgets(
line, 255, inpFile);
389 m_i_version = atoi(
line);
390 str <<
"version= " << m_i_version << std::endl;
392 fgets(
line, 255, inpFile);
393 m_i_run_number = atoi(
line);
394 str <<
"run_number= " << m_i_run_number << std::endl;
396 fgets(
line, 255, inpFile);
397 m_i_physClin = atoi(
line);
398 str <<
"physClin_config= " << m_i_physClin << std::endl;
400 fgets(
line, 255, inpFile);
401 m_i_physClut = atoi(
line);
402 str <<
"physClut_config= " << m_i_physClut << std::endl;
404 fgets(
line, 255, inpFile);
405 m_i_physCfgr = atoi(
line);
406 str <<
"physCfgr_config= " << m_i_physCfgr << std::endl;
414 std::ofstream myfile;
416 myfile << m_i_tag << std::endl;
417 myfile << m_i_version << std::endl;
418 myfile << m_i_run_number << std::endl;
419 myfile << m_i_physClin << std::endl;
420 myfile << m_i_physClut << std::endl;
421 myfile << m_i_physCfgr << std::endl;
void setValue(const uint32_t &id, const Item &value)
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
T getParameter(std::string const &) const
float getTTThreshlow() const
std::string getName() const
float getTTThreshhigh() const
EcalTPGPhysicsConstHandler(edm::ParameterSet const &)
std::string m_locationsource
Log< level::Error, false > LogError
static std::string to_string(const XMLCh *ch)
float getFGhighratio() const
~EcalTPGPhysicsConstHandler() override
void getNewObjects() override
void writeFile(const char *inputFile)
void setLocationDef(const LocationDef &locDef)
Log< level::Info, false > LogInfo
constexpr uint32_t rawId() const
get the raw id
void readFromFile(const char *inputFile)
std::string getConfigTag() const
std::unique_ptr< EcalTPGPhysicsConst > Ref
void setConfigTag(std::string x)
float getFGlowthresh() const
void setGeneralTag(std::string tag)
float getFGlowratio() const
float getFGhighthresh() const