25 : m_name(ps.getUntrackedParameter<std::string>(
"name",
"EcalTPGWeightIdMapHandler")) {
27 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"EcalTPGWeightIdMap Source handler constructor";
50 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"Started GetNewObjects!!!";
55 std::cout <<
"got offlineInfo = " << std::endl;
56 std::cout <<
"tag name = " << tagInfo().name << std::endl;
57 std::cout <<
"size = " << tagInfo().size << std::endl;
59 std::cout <<
" First object for this tag " << std::endl;
62 unsigned int max_since=0;
63 max_since=
static_cast<unsigned int>(tagInfo().lastInterval.first);
64 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"max_since : " << max_since;
65 Ref weightIdMap_db = lastPayload();
67 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"retrieved last payload ";
70 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"Retrieving run list from ONLINE DB ... ";
72 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"Making connection...";
78 std::cout <<
" connection parameters " <<m_sid <<
"/"<<m_user<<std::endl;
95 readFromFile(
"last_tpg_weightIdMap_settings.txt");
98 unsigned int min_run=m_i_run_number+1;
100 if(m_firstRun<m_i_run_number) {
101 min_run=m_i_run_number+1;
106 if(min_run<max_since) {
110 std::cout<<
"m_i_run_number"<< m_i_run_number <<
"m_firstRun "<<m_firstRun<<
"max_since " <<max_since<< std::endl;
112 unsigned int max_run=m_lastRun;
113 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"min_run= " << min_run <<
"max_run= " << max_run;
116 my_list=econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
119 std::vector<RunIOV> run_vec= my_list.
getRuns();
120 size_t num_runs=run_vec.size();
121 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"number of Mon runs is : "<< num_runs;
125 for(
size_t kr=0; kr<run_vec.size(); kr++){
127 irun=
static_cast<unsigned int>(run_vec[kr].getRunNumber());
129 std::cout<<
" **************** "<<std::endl;
130 std::cout<<
" **************** "<<std::endl;
134 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
135 econn->fetchDataSet(&dataset, &run_vec[kr]);
137 std::string the_config_tag=
"";
138 int the_config_version=0;
140 std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
143 for( it=dataset.begin(); it!=dataset.end(); it++ )
156 std::cout<<
" run= "<<irun<<
" tag "<<the_config_tag<<
" version="<<the_config_version <<std::endl;
161 if((the_config_tag != m_i_tag || the_config_version != m_i_version ) && nr>0 ) {
162 std::cout<<
"the tag is different from last transferred run ... retrieving last config set from DB"<<std::endl;
169 std::cout <<
" before fetch config set" << std::endl;
170 econn-> fetchConfigSet(&fe_main_info);
171 std::cout <<
" after fetch config set" << std::endl;
175 int weightId=fe_main_info.
getWeiId();
177 if( weightId != m_i_weightIdMap ) {
180 fe_weight_info.
setId(weightId);
181 econn-> fetchConfigSet(&fe_weight_info);
182 std::map<EcalLogicID, FEConfigWeightGroupDat> dataset_TpgWeight;
183 econn->fetchDataSet(&dataset_TpgWeight, &fe_weight_info);
184 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"Got object!";
186 typedef std::map<EcalLogicID, FEConfigWeightGroupDat>::const_iterator CIfeweight;
191 for (CIfeweight
p = dataset_TpgWeight.begin();
p != dataset_TpgWeight.end();
p++) {
196 unsigned int weight0 =
static_cast<unsigned int>(rd_w.
getWeight4());
197 unsigned int weight1 =
static_cast<unsigned int>(rd_w.
getWeight3());
198 unsigned int weight2 =
static_cast<unsigned int>(rd_w.
getWeight2());
199 unsigned int weight3 =
static_cast<unsigned int>(rd_w.
getWeight1()- 0x80);
200 unsigned int weight4 =
static_cast<unsigned int>(rd_w.
getWeight0());
202 w.
setValues(weight0,weight1,weight2,weight3,weight4);
208 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"found " << igroups <<
"Weight groups";
214 m_i_tag=the_config_tag;
215 m_i_version=the_config_version;
216 m_i_weightIdMap=weightId;
218 writeFile(
"last_tpg_weightIdMap_settings.txt");
223 m_i_tag=the_config_tag;
224 m_i_version=the_config_version;
226 writeFile(
"last_tpg_weightIdMap_settings.txt");
228 std::cout<<
" even if the tag/version is not the same, the weightIdMap id is the same -> no transfer needed "<< std::endl;
233 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" <<the_config_tag
234 <<
" version="<<the_config_version<< std::endl;
239 std::cout<<
" **************** "<<std::endl;
243 std::cout<<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed "<< std::endl;
244 std::cout<<
" **************** "<<std::endl;
247 m_i_tag=the_config_tag;
248 m_i_version=the_config_version;
249 std::cout<<
" the tag/version is the same -> no transfer needed "<< std::endl;
250 std::cout<<
" **************** "<<std::endl;
251 writeFile(
"last_tpg_weightIdMap_settings.txt");
259 edm::LogInfo(
"EcalTPGWeightIdMapHandler") <<
"Ecal - > end of getNewObjects -----------";
272 inpFile = fopen(inputFile,
"r");
279 std::ostringstream str;
281 fgets(line,255,inpFile);
283 str <<
"gen tag " << m_i_tag << std::endl ;
285 fgets(line,255,inpFile);
286 m_i_version=atoi(line);
287 str <<
"version= " << m_i_version << std::endl ;
289 fgets(line,255,inpFile);
290 m_i_run_number=atoi(line);
291 str <<
"run_number= " << m_i_run_number << std::endl ;
293 fgets(line,255,inpFile);
294 m_i_weightIdMap=atoi(line);
295 str <<
"weightIdMap_config= " << m_i_weightIdMap << std::endl ;
306 std::ofstream myfile;
307 myfile.open (inputFile);
308 myfile << m_i_tag <<std::endl;
309 myfile << m_i_version <<std::endl;
310 myfile << m_i_run_number <<std::endl;
311 myfile << m_i_weightIdMap <<std::endl;
T getParameter(std::string const &) const
std::vector< RunIOV > getRuns()
edm::Ref< Container > Ref
void setLocationDef(const LocationDef locDef)
std::string getConfigTag() const
void readFromFile(const char *inputFile)
void writeFile(const char *inputFile)
int getWeightGroupId() const
std::string to_string(const T &t)
unsigned long long Time_t
void setRunTypeDef(const RunTypeDef runTypeDef)
void setValue(const uint32_t &id, const EcalTPGWeights &value)
~EcalTPGWeightIdMapHandler()
EcalTPGWeightIdMapHandler(edm::ParameterSet const &)
void setRunType(std::string runtype)
void setConfigTag(std::string x)
void setLocation(std::string loc)
void setGeneralTag(std::string tag)
void setValues(const uint32_t &w0, const uint32_t &w1, const uint32_t &w2, const uint32_t &w3, const uint32_t &w4)
std::string m_locationsource
tuple size
Write out results.