31 : m_name(ps.getUntrackedParameter<std::
string>(
"name",
"EcalTPGWeightGroupHandler")) {
33 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"EcalTPGWeightGroup Source handler constructor.";
54 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"Started GetNewObjects!!!";
59 std::cout <<
"got offlineInfo = " << std::endl;
60 std::cout <<
"tag name = " << tagInfo().name << std::endl;
61 std::cout <<
"size = " << tagInfo().size << std::endl;
63 std::cout <<
" First object for this tag " << std::endl;
66 unsigned int max_since=0;
67 max_since=
static_cast<unsigned int>(tagInfo().lastInterval.first);
68 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"max_since : " << max_since;
70 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"retrieved last payload ";
74 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"Retrieving run list from ONLINE DB ... ";
76 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"Making connection...";
82 std::cout <<
" connection parameters " <<m_sid <<
"/"<<m_user<<std::endl;
99 readFromFile(
"last_tpg_weightGroup_settings.txt");
101 unsigned int min_run=m_i_run_number+1;
103 if(m_firstRun<m_i_run_number) {
104 min_run=m_i_run_number+1;
109 if(min_run<max_since) {
113 std::cout<<
"m_i_run_number"<< m_i_run_number <<
"m_firstRun "<<m_firstRun<<
"max_since " <<max_since<< std::endl;
115 unsigned int max_run=m_lastRun;
116 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"min_run= " << min_run <<
" max_run= " << max_run;
119 my_list=econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
122 std::vector<RunIOV> run_vec= my_list.
getRuns();
123 size_t num_runs=run_vec.size();
125 std::cout <<
"number of runs is : "<< num_runs<< std::endl;
131 std::vector<EcalLogicID> my_StripEcalLogicId_EE;
132 my_StripEcalLogicId_EE = econn->getEcalLogicIDSetOrdered(
"ECAL_readout_strip",
136 "EE_offline_stripid",123 );
138 std::cout <<
" GOT the logic ID for the EE trigger strips "<< std::endl;
140 for(
size_t kr=0; kr<run_vec.size(); kr++){
142 irun=
static_cast<unsigned int>(run_vec[kr].getRunNumber());
144 std::cout<<
" **************** "<<std::endl;
145 std::cout<<
" **************** "<<std::endl;
149 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
150 econn->fetchDataSet(&dataset, &run_vec[kr]);
153 int the_config_version=0;
155 std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
158 for( it=dataset.begin(); it!=dataset.end(); it++ )
171 std::cout<<
" run= "<<irun<<
" tag "<<the_config_tag<<
" version="<<the_config_version <<std::endl;
176 if((the_config_tag != m_i_tag || the_config_version != m_i_version ) && nr>0 ) {
177 std::cout<<
"the tag is different from last transferred run ... retrieving last config set from DB"<<std::endl;
184 std::cout <<
" before fetch config set" << std::endl;
185 econn-> fetchConfigSet(&fe_main_info);
186 std::cout <<
" after fetch config set" << std::endl;
192 if( wId != m_i_weightGroup ) {
195 fe_w_info.
setId(wId);
196 econn-> fetchConfigSet(&fe_w_info);
197 std::map<EcalLogicID, FEConfigWeightDat> dataset_TpgW;
198 econn->fetchDataSet(&dataset_TpgW, &fe_w_info);
202 typedef std::map<EcalLogicID, FEConfigWeightDat>::const_iterator CIfesli;
207 std::map<std::string,int>
map;
210 for (CIfesli
p = dataset_TpgW.begin();
p != dataset_TpgW.end();
p++) {
212 weightGroup =
p->second.getWeightGroupId();
217 if (ecid_name==
"EB_VFE") {
220 int strip=ecid_xt.
getID3();
222 if(sm>18) tcc=sm+18 ;
226 unsigned int stripEBId = 303176+(tt-1)*64+(strip-1)*8+(tcc-37)*8192;
228 weightG->
setValue(stripEBId,weightGroup);
231 else if (ecid_name==
"ECAL_readout_strip"){
237 bool set_the_strip=
false;
239 for (
size_t istrip=0; istrip<my_StripEcalLogicId_EE.size(); istrip++) {
243 if(my_StripEcalLogicId_EE[istrip].getID1()==id1
244 && my_StripEcalLogicId_EE[istrip].getID2()==id2
245 && my_StripEcalLogicId_EE[istrip].getID3()==id3
247 stripEEId =my_StripEcalLogicId_EE[istrip].getLogicID();
257 weightG->
setValue(stripEEId,weightGroup);
260 std::cout <<
" these may be the additional towers TCC/TT "
261 << id1<<
"/"<<id2<<std::endl;
273 m_i_tag=the_config_tag;
274 m_i_version=the_config_version;
277 writeFile(
"last_tpg_weightGroup_settings.txt");
282 m_i_tag=the_config_tag;
283 m_i_version=the_config_version;
285 writeFile(
"last_tpg_weightGroup_settings.txt");
287 std::cout<<
" even if the tag/version is not the same, the weight group id is the same -> no transfer needed "<< std::endl;
294 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" <<the_config_tag
295 <<
" version="<<the_config_version<< std::endl;
300 std::cout<<
" **************** "<<std::endl;
304 std::cout<<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed "<< std::endl;
305 std::cout<<
" **************** "<<std::endl;
308 m_i_tag=the_config_tag;
309 m_i_version=the_config_version;
310 std::cout<<
" the tag/version is the same -> no transfer needed "<< std::endl;
311 std::cout<<
" **************** "<<std::endl;
312 writeFile(
"last_tpg_weightGroup_settings.txt");
320 edm::LogInfo(
"EcalTPGWeightGroupHandler") <<
"Ecal - > end of getNewObjects -----------";
333 inpFile = fopen(inputFile,
"r");
340 std::ostringstream str;
342 fgets(line,255,inpFile);
344 str <<
"gen tag " << m_i_tag << std::endl ;
346 fgets(line,255,inpFile);
347 m_i_version=atoi(line);
348 str <<
"version= " << m_i_version << std::endl ;
350 fgets(line,255,inpFile);
351 m_i_run_number=atoi(line);
352 str <<
"run_number= " << m_i_run_number << std::endl ;
354 fgets(line,255,inpFile);
355 m_i_weightGroup=atoi(line);
356 str <<
"weightGroup_config= " << m_i_weightGroup << std::endl ;
367 std::ofstream myfile;
368 myfile.open (inputFile);
369 myfile << m_i_tag <<std::endl;
370 myfile << m_i_version <<std::endl;
371 myfile << m_i_run_number <<std::endl;
372 myfile << m_i_weightGroup <<std::endl;
T getParameter(std::string const &) const
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
std::string getConfigTag() const
~EcalTPGWeightGroupHandler()
void readFromFile(const char *inputFile)
std::string to_string(const T &t)
std::string getName() const
EcalTPGWeightGroupHandler(edm::ParameterSet const &)
std::string m_locationsource
void setValue(const uint32_t &rawId, const uint32_t &ObjectId)
void setLocationDef(const LocationDef &locDef)
void setRunType(std::string runtype)
void setConfigTag(std::string x)
void setLocation(std::string loc)
void setGeneralTag(std::string tag)
tuple size
Write out results.
void writeFile(const char *inputFile)