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;
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") {
316 for ( iterEB itt=temporaryMapEB.begin() ; itt != temporaryMapEB.end() ; itt++ ){
318 if (itt->first == (
int)eb.
rawId()){
333 else if (ecid_nameFgr==
"EE") {
339 for ( iterEE itEE=temporaryMapEE.begin() ; itEE != temporaryMapEE.end() ; itEE++ ){
341 if (itEE->first == (
int)ee.
rawId()){
366 m_i_tag=the_config_tag;
367 m_i_version=the_config_version;
372 writeFile(
"last_tpg_physC_settings.txt");
377 m_i_tag=the_config_tag;
378 m_i_version=the_config_version;
380 writeFile(
"last_tpg_physC_settings.txt");
382 std::cout<<
" even if the tag/version is not the same, the physics constants id is the same -> no transfer needed "<< std::endl;
391 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" <<the_config_tag
392 <<
" version="<<the_config_version<< std::endl;
397 std::cout<<
" **************** "<<std::endl;
401 std::cout<<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed "<< std::endl;
402 std::cout<<
" **************** "<<std::endl;
405 m_i_tag=the_config_tag;
406 m_i_version=the_config_version;
407 std::cout<<
" the tag/version is the same -> no transfer needed "<< std::endl;
408 std::cout<<
" **************** "<<std::endl;
409 writeFile(
"last_tpg_physC_settings.txt");
415 edm::LogInfo(
"EcalTPGPhysicsConstHandler") <<
"Ecal - > end of getNewObjects -----------";
431 inpFile = fopen(inputFile,
"r");
439 std::ostringstream str;
441 fgets(line,255,inpFile);
442 m_i_tag=to_string(line);
443 str <<
"gen tag " << m_i_tag << std::endl ;
445 fgets(line,255,inpFile);
446 m_i_version=atoi(line);
447 str <<
"version= " << m_i_version << std::endl ;
449 fgets(line,255,inpFile);
450 m_i_run_number=atoi(line);
451 str <<
"run_number= " << m_i_run_number << std::endl ;
453 fgets(line,255,inpFile);
454 m_i_physClin=atoi(line);
455 str <<
"physClin_config= " << m_i_physClin << std::endl ;
457 fgets(line,255,inpFile);
458 m_i_physClut=atoi(line);
459 str <<
"physClut_config= " << m_i_physClut << std::endl ;
461 fgets(line,255,inpFile);
462 m_i_physCfgr=atoi(line);
463 str <<
"physCfgr_config= " << m_i_physCfgr << std::endl ;
473 std::ofstream myfile;
474 myfile.open (inputFile);
475 myfile << m_i_tag <<std::endl;
476 myfile << m_i_version <<std::endl;
477 myfile << m_i_run_number <<std::endl;
478 myfile << m_i_physClin <<std::endl;
479 myfile << m_i_physClut <<std::endl;
480 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 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.