23 : m_name(ps.getUntrackedParameter<std::
string>(
"name",
"EcalTPGFineGrainEBIdMapHandler")) {
25 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"EcalTPGFineGrainEBIdMap Source handler constructor.";
47 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"Started GetNewObjects!!!";
52 std::cout <<
"got offlineInfo = " << std::endl;
56 std::cout <<
" First object for this tag " << std::endl;
60 unsigned int max_since=0;
61 max_since=
static_cast<unsigned int>(
tagInfo().lastInterval.first);
62 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"max_since : " << max_since;
63 Ref fgrIdMap_db = lastPayload();
65 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"retrieved last payload ";
67 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"WOW: we just retrieved the last valid record from DB ";
72 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"Retrieving run list from ONLINE DB ... ";
74 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"Making connection...";
76 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"Done.";
80 std::cout <<
" connection parameters " <<m_sid <<
"/"<<m_user<<std::endl;
97 readFromFile(
"last_tpg_fgrIdMap_settings.txt");
100 unsigned int min_run=m_i_run_number+1;
102 if(m_firstRun<m_i_run_number) {
103 min_run=m_i_run_number+1;
107 if(min_run<max_since) {
111 std::cout<<
"m_i_run_number"<< m_i_run_number <<
"m_firstRun "<<m_firstRun<<
"max_since " <<max_since<< std::endl;
113 unsigned int max_run=m_lastRun;
114 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"min_run= " << min_run <<
"max_run= " << max_run;
117 my_list=econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
119 printf (
"after fetchRunList\n");fflush(stdout);
121 std::vector<RunIOV> run_vec= my_list.
getRuns();
122 size_t num_runs=run_vec.size();
124 std::cout <<
"number of runs is : "<< num_runs<< std::endl;
129 for(
size_t kr=0; kr<run_vec.size(); kr++){
131 irun=
static_cast<unsigned int>(run_vec[kr].getRunNumber());
133 std::cout<<
" **************** "<<std::endl;
134 std::cout<<
" **************** "<<std::endl;
138 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
139 econn->fetchDataSet(&dataset, &run_vec[kr]);
142 int the_config_version=0;
144 std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
147 for( it=dataset.begin(); it!=dataset.end(); it++ )
159 std::cout<<
" run= "<<irun<<
" tag "<<the_config_tag<<
" version="<<the_config_version <<std::endl;
164 if((the_config_tag != m_i_tag || the_config_version != m_i_version ) && nr>0 ) {
165 std::cout<<
"the tag is different from last transferred run ... retrieving last config set from DB"<<std::endl;
172 std::cout <<
" before fetch config set" << std::endl;
173 econn-> fetchConfigSet(&fe_main_info);
174 std::cout <<
" after fetch config set" << std::endl;
178 if( fgrId != m_i_fgrIdMap ) {
181 fe_fgr_info.
setId(fgrId);
182 econn-> fetchConfigSet(&fe_fgr_info);
183 std::map<EcalLogicID, FEConfigFgrGroupDat> dataset_TpgFineGrainEB;
184 econn->fetchDataSet(&dataset_TpgFineGrainEB, &fe_fgr_info);
185 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"Got object!";
187 typedef std::map<EcalLogicID, FEConfigFgrGroupDat>::const_iterator CIfefgr;
192 for (CIfefgr
p = dataset_TpgFineGrainEB.begin();
p != dataset_TpgFineGrainEB.end();
p++)
200 unsigned int ThrL = (
unsigned int)rd_fgr.
getThreshLow();
202 unsigned int RatioL = (
unsigned int)rd_fgr.
getRatioLow();
203 unsigned int RatioH = (
unsigned int)rd_fgr.
getRatioHigh();
204 unsigned int LutConfId = (
unsigned int)rd_fgr.
getLUTValue();
206 f.
setValues(RatioL,RatioH, ThrL,ThrH,LutConfId);
215 m_i_tag=the_config_tag;
216 m_i_version=the_config_version;
219 writeFile(
"last_tpg_fgrIdMap_settings.txt");
224 m_i_tag=the_config_tag;
225 m_i_version=the_config_version;
227 writeFile(
"last_tpg_fgrIdMap_settings.txt");
229 std::cout<<
" even if the tag/version is not the same, the fgrIdMap is the same -> no transfer needed "<< std::endl;
236 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" <<the_config_tag
237 <<
" version="<<the_config_version<< std::endl;
242 std::cout<<
" **************** "<<std::endl;
246 std::cout<<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed "<< std::endl;
247 std::cout<<
" **************** "<<std::endl;
250 m_i_tag=the_config_tag;
251 m_i_version=the_config_version;
252 std::cout<<
" the tag/version is the same -> no transfer needed "<< std::endl;
253 std::cout<<
" **************** "<<std::endl;
254 writeFile(
"last_tpg_fgrIdMap_settings.txt");
261 edm::LogInfo(
"EcalTPGFineGrainEBIdMapHandler") <<
"Ecal - > end of getNewObjects -----------";
273 inpFile = fopen(inputFile,
"r");
281 std::ostringstream str;
283 fgets(line,255,inpFile);
285 str <<
"gen tag " << m_i_tag << std::endl ;
287 fgets(line,255,inpFile);
288 m_i_version=atoi(line);
289 str <<
"version= " << m_i_version << std::endl ;
291 fgets(line,255,inpFile);
292 m_i_run_number=atoi(line);
293 str <<
"run_number= " << m_i_run_number << std::endl ;
295 fgets(line,255,inpFile);
296 m_i_fgrIdMap=atoi(line);
297 str <<
"fgrIdMap_config= " << m_i_fgrIdMap << std::endl ;
308 std::ofstream myfile;
309 myfile.open (inputFile);
310 myfile << m_i_tag <<std::endl;
311 myfile << m_i_version <<std::endl;
312 myfile << m_i_run_number <<std::endl;
313 myfile << m_i_fgrIdMap <<std::endl;
T getParameter(std::string const &) const
void setRunTypeDef(const RunTypeDef &runTypeDef)
void setValue(const uint32_t &id, const EcalTPGFineGrainConstEB &value)
~EcalTPGFineGrainEBIdMapHandler()
std::vector< RunIOV > getRuns()
edm::Ref< Container > Ref
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)
void writeFile(const char *inputFile)
std::string to_string(const T &t)
std::string getName() const
void readFromFile(const char *inputFile)
int getFgrGroupId() const
std::string m_locationsource
float getRatioLow() const
void setLocationDef(const LocationDef &locDef)
float getThreshLow() const
float getRatioHigh() const
void setRunType(std::string runtype)
void setConfigTag(std::string x)
void setLocation(std::string loc)
float getThreshHigh() const
void setGeneralTag(std::string tag)
tuple size
Write out results.