15 : m_name(ps.getUntrackedParameter<std::
string>(
"name",
"EcalTPGPhysicsConstHandler")) {
17 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"EcalTPGPhysicsConst Source handler constructor.";
40 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"Started GetNewObjects!!!";
45 std::cout <<
"got offlineInfo = " << std::endl;
46 std::cout <<
"tag name = " << tagInfo().name << std::endl;
47 std::cout <<
"size = " << tagInfo().size << 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.first);
54 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"max_since : " << max_since;
55 Ref physC_db = lastPayload();
57 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"retrieved last payload ";
60 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"Retrieving run list from ONLINE DB ... ";
62 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"Making connection...";
68 std::cout <<
" connection parameters " <<m_sid <<
"/"<<m_user<<std::endl;
86 readFromFile(
"last_tpg_physC_settings.txt");
88 unsigned int min_run=m_i_run_number+1;
90 if(m_firstRun<m_i_run_number) {
91 min_run=m_i_run_number+1;
96 std::cout<<
"m_i_run_number"<< m_i_run_number <<
"m_firstRun "<<m_firstRun<<
"max_since " <<max_since<< std::endl;
98 if(min_run<max_since) {
102 unsigned int max_run=m_lastRun;
103 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"min_run= " << min_run <<
"max_run= " << max_run;
106 my_list=econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
110 std::vector<RunIOV> run_vec= my_list.
getRuns();
111 size_t num_runs=run_vec.size();
113 std::cout <<
"number of runs is : "<< num_runs<< std::endl;
118 for(
size_t kr=0; kr<run_vec.size(); kr++){
120 irun=
static_cast<unsigned int>(run_vec[kr].getRunNumber());
122 std::cout<<
" **************** "<<std::endl;
123 std::cout<<
" **************** "<<std::endl;
127 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
128 econn->fetchDataSet(&dataset, &run_vec[kr]);
131 int the_config_version=0;
133 std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
136 for( it=dataset.begin(); it!=dataset.end(); it++ )
149 std::cout<<
" run= "<<irun<<
" tag "<<the_config_tag<<
" version="<<the_config_version <<std::endl;
154 if((the_config_tag != m_i_tag || the_config_version != m_i_version ) && nr>0 ) {
155 std::cout<<
"the tag is different from last transferred run ... retrieving last config set from DB"<<std::endl;
162 std::cout <<
" before fetch config set" << std::endl;
163 econn-> fetchConfigSet(&fe_main_info);
164 std::cout <<
" after fetch config set" << std::endl;
172 if ((linId != m_i_physClin) || (fgrId != m_i_physCfgr) || (lutId != m_i_physClut) ) {
174 std::cout<<
"one of the parameters: linId, LutId or fgrId is different from" <<std::endl;
175 std::cout<<
"last transferred run ..."<<std::endl;
180 fe_physLin_info.
setId(linId);
181 fe_physFgr_info.
setId(fgrId);
182 fe_physLut_info.
setId(lutId);
184 econn-> fetchConfigSet(&fe_physLin_info);
185 econn-> fetchConfigSet(&fe_physFgr_info);
186 econn-> fetchConfigSet(&fe_physLut_info);
187 std::map<EcalLogicID, FEConfigLinParamDat> dataset_TpgPhysicsLin;
188 std::map<EcalLogicID, FEConfigLUTParamDat> dataset_TpgPhysicsLut;
189 std::map<EcalLogicID, FEConfigFgrParamDat> dataset_TpgPhysicsFgr;
191 econn->fetchDataSet(&dataset_TpgPhysicsLin, &fe_physLin_info);
192 econn->fetchDataSet(&dataset_TpgPhysicsLut, &fe_physLut_info);
193 econn->fetchDataSet(&dataset_TpgPhysicsFgr, &fe_physFgr_info);
196 typedef std::map<EcalLogicID, FEConfigLinParamDat>::const_iterator CIfeLin;
197 typedef std::map<EcalLogicID, FEConfigLUTParamDat>::const_iterator CIfeLUT;
198 typedef std::map<EcalLogicID, FEConfigFgrParamDat>::const_iterator CIfeFgr;
207 std::map<int,float> EtSatLinEB;
208 std::map<int,float> EtSatLinEE;
209 typedef std::map<int,float>::const_iterator itEtSat;
211 std::map<int,EcalTPGPhysicsConst::Item> temporaryMapEB;
212 std::map<int,EcalTPGPhysicsConst::Item> temporaryMapEE;
213 typedef std::map<int,EcalTPGPhysicsConst::Item>::iterator iterEB;
214 typedef std::map<int,EcalTPGPhysicsConst::Item>::iterator iterEE;
217 for (CIfeLin p0 = dataset_TpgPhysicsLin.begin(); p0 != dataset_TpgPhysicsLin.end(); p0++)
219 ecidLin_xt = p0->first;
220 rd_physLin = p0->second;
224 if(ecid_nameLin==
"EB") {
226 EtSatLinEB.insert(std::make_pair(eb.
rawId(),rd_physLin.
getETSat()));
228 else if (ecid_nameLin==
"EE"){
230 EtSatLinEE.insert(std::make_pair(ee.
rawId(),rd_physLin.
getETSat()));
236 for (CIfeLUT
p1 = dataset_TpgPhysicsLut.begin();
p1 != dataset_TpgPhysicsLut.end();
p1++)
238 ecidLut_xt =
p1->first;
239 rd_physLut =
p1->second;
244 if(ecid_nameLut==
"EB") {
248 for (itEtSat it1 = EtSatLinEB.begin() ; it1 != EtSatLinEB.end(); it1++){
250 if (it1->first == (
int)eb.
rawId()){
251 float ETSatLin = it1->second;
253 if (rd_physLut.
getETSat() == ETSatLin) {
262 temporaryMapEB.insert(std::make_pair(eb.
rawId(),item));
264 else throw cms::Exception(
"The values of the ETSatLin and ETSatLut are different.");
272 else if (ecid_nameLut==
"EE") {
277 for (itEtSat it2 = EtSatLinEE.begin(); it2 != EtSatLinEE.end(); it2++){
279 if (it2->first == (
int)ee.
rawId()){
280 float ETSatLin = it2->second;
282 if (rd_physLut.
getETSat() == ETSatLin) {
291 temporaryMapEE.insert( std::make_pair(ee.
rawId(),item) );
293 else throw cms::Exception(
"The values of the ETSatLin and ETSatLut are different.");
304 for (CIfeFgr
p2 = dataset_TpgPhysicsFgr.begin();
p2 != dataset_TpgPhysicsFgr.end();
p2++)
306 ecidFgr_xt =
p2->first;
307 rd_physFgr =
p2->second;
312 if(ecid_nameFgr==
"EB") {
317 for ( iterEB itt=temporaryMapEB.begin() ; itt != temporaryMapEB.end() ; itt++ ){
319 if (itt->first == (
int)eb.
rawId()){
336 else if (ecid_nameFgr==
"EE") {
342 for ( iterEE itEE=temporaryMapEE.begin() ; itEE != temporaryMapEE.end() ; itEE++ ){
344 if (itEE->first == (
int)ee.
rawId()){
369 m_i_tag=the_config_tag;
370 m_i_version=the_config_version;
375 writeFile(
"last_tpg_physC_settings.txt");
380 m_i_tag=the_config_tag;
381 m_i_version=the_config_version;
383 writeFile(
"last_tpg_physC_settings.txt");
385 std::cout<<
" even if the tag/version is not the same, the physics constants id is the same -> no transfer needed "<< std::endl;
394 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" <<the_config_tag
395 <<
" version="<<the_config_version<< std::endl;
400 std::cout<<
" **************** "<<std::endl;
404 std::cout<<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed "<< std::endl;
405 std::cout<<
" **************** "<<std::endl;
408 m_i_tag=the_config_tag;
409 m_i_version=the_config_version;
410 std::cout<<
" the tag/version is the same -> no transfer needed "<< std::endl;
411 std::cout<<
" **************** "<<std::endl;
412 writeFile(
"last_tpg_physC_settings.txt");
418 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"Ecal - > end of getNewObjects -----------";
434 inpFile = fopen(inputFile,
"r");
441 std::ostringstream str;
443 fgets(line,255,inpFile);
445 str <<
"gen tag " << m_i_tag << std::endl ;
447 fgets(line,255,inpFile);
448 m_i_version=atoi(line);
449 str <<
"version= " << m_i_version << std::endl ;
451 fgets(line,255,inpFile);
452 m_i_run_number=atoi(line);
453 str <<
"run_number= " << m_i_run_number << std::endl ;
455 fgets(line,255,inpFile);
456 m_i_physClin=atoi(line);
457 str <<
"physClin_config= " << m_i_physClin << std::endl ;
459 fgets(line,255,inpFile);
460 m_i_physClut=atoi(line);
461 str <<
"physClut_config= " << m_i_physClut << std::endl ;
463 fgets(line,255,inpFile);
464 m_i_physCfgr=atoi(line);
465 str <<
"physCfgr_config= " << m_i_physCfgr << std::endl ;
475 std::ofstream myfile;
476 myfile.open (inputFile);
477 myfile << m_i_tag <<std::endl;
478 myfile << m_i_version <<std::endl;
479 myfile << m_i_run_number <<std::endl;
480 myfile << m_i_physClin <<std::endl;
481 myfile << m_i_physClut <<std::endl;
482 myfile << m_i_physCfgr <<std::endl;
void setValue(const uint32_t &id, const Item &value)
T getParameter(std::string const &) const
void setRunTypeDef(const RunTypeDef &runTypeDef)
float getFGlowthresh() const
std::vector< RunIOV > getRuns()
edm::Ref< Container > Ref
std::string getConfigTag() const
float getFGhighthresh() const
EcalTPGPhysicsConstHandler(edm::ParameterSet const &)
std::string m_locationsource
float getFGhighratio() const
float getTTThreshhigh() const
uint32_t rawId() const
get the raw id
std::string to_string(const T &t)
std::string getName() const
~EcalTPGPhysicsConstHandler()
float getTTThreshlow() const
void writeFile(const char *inputFile)
void setLocationDef(const LocationDef &locDef)
void setRunType(std::string runtype)
void readFromFile(const char *inputFile)
float getFGlowratio() const
double ttf_threshold_High
void setConfigTag(std::string x)
void setLocation(std::string loc)
void setGeneralTag(std::string tag)
tuple size
Write out results.