43 : m_name(ps.getUntrackedParameter<std::string>(
"name",
"EcalTPGLutGroupHandler")) {
45 edm::LogInfo(
"EcalTPGLutGroupHandler") <<
"EcalTPGLutGroup Source handler constructor";
71 edm::LogInfo(
"EcalTPGLutGroupHandler") <<
"Started GetNewObjects!!!";
99 std::cout <<
"got offlineInfo = " << std::endl;
100 std::cout <<
"tag name = " << tagInfo().name << std::endl;
101 std::cout <<
"size = " << tagInfo().size << std::endl;
103 std::cout <<
" First object for this tag " << std::endl;
106 unsigned int max_since=0;
107 max_since=
static_cast<unsigned int>(tagInfo().lastInterval.first);
108 edm::LogInfo(
"EcalTPGLutGroupHandler") <<
"max_since : " << max_since;
109 edm::LogInfo(
"EcalTPGLutGroupHandler") <<
"retrieved last payload ";
112 edm::LogInfo(
"EcalTPGLutGroupHandler") <<
"Retrieving run list from ONLINE DB ... ";
114 edm::LogInfo(
"EcalTPGLutGroupHandler") <<
"Making connection...";
120 std::cout <<
" connection parameters " <<m_sid <<
"/"<<m_user<<std::endl;
134 my_runtag.setRunTypeDef( my_rundef );
135 my_runtag.setGeneralTag(m_gentag);
138 readFromFile(
"last_tpg_lutGroup_settings.txt");
141 unsigned int min_run=m_i_run_number+1;
143 if(m_firstRun<m_i_run_number) {
144 min_run=m_i_run_number+1;
150 if(min_run<max_since) {
151 min_run= max_since+1;
154 std::cout<<
"m_i_run_number"<< m_i_run_number <<
"m_firstRun "<<m_firstRun<<
"max_since " <<max_since<< std::endl;
156 unsigned int max_run=m_lastRun;
157 edm::LogInfo(
"EcalTPGLutGroupHandler") <<
"min_run= " << min_run <<
" max_run= " << max_run;
160 my_list=econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
163 std::vector<RunIOV> run_vec= my_list.
getRuns();
164 size_t num_runs=run_vec.size();
166 std::cout <<
"number of runs is : "<< num_runs<< std::endl;
175 std::vector<EcalLogicID> my_TTEcalLogicId_EE;
176 my_TTEcalLogicId_EE = econn->getEcalLogicIDSetOrdered(
"EE_trigger_tower",
180 "EE_offline_towerid",12 );
181 std::cout <<
" GOT the logic ID for the EE trigger towers "<< std::endl;
183 for(
size_t kr=0; kr<run_vec.size(); kr++){
185 irun=
static_cast<unsigned int>(run_vec[kr].getRunNumber());
187 std::cout<<
" **************** "<<std::endl;
191 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
192 econn->fetchDataSet(&dataset, &run_vec[kr]);
194 std::string the_config_tag=
"";
195 int the_config_version=0;
197 std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
200 for( it=dataset.begin(); it!=dataset.end(); it++ )
214 std::cout<<
" run= "<<irun<<
" tag "<<the_config_tag<<
" version="<<the_config_version <<std::endl;
219 if((the_config_tag != m_i_tag || the_config_version != m_i_version ) && nr>0 ) {
220 std::cout<<
"the tag is different from last transferred run ... retrieving last config set from DB"<<std::endl;
227 std::cout <<
" before fetch config set" << std::endl;
228 econn-> fetchConfigSet(&fe_main_info);
229 std::cout <<
" after fetch config set" << std::endl;
235 if( lutId != m_i_lutGroup ) {
238 fe_lut_info.
setId(lutId);
239 econn-> fetchConfigSet(&fe_lut_info);
240 std::map<EcalLogicID, FEConfigLUTDat> dataset_TpgLut;
241 econn->fetchDataSet(&dataset_TpgLut, &fe_lut_info);
244 typedef std::map<EcalLogicID, FEConfigLUTDat>::const_iterator CIfelut;
249 for (CIfelut
p = dataset_TpgLut.begin();
p != dataset_TpgLut.end();
p++)
254 std::string ecid_name=ecid_xt.
getName();
256 if(ecid_name==
"EB_trigger_tower") {
258 int smid=ecid_xt.
getID1();
260 int towerid=ecid_xt.
getID2();
263 int tow_eta=(towerid-1)/4;
264 int tow_phi=((towerid-1)-tow_eta*4);
266 int axt=(tow_eta*5)*20 + tow_phi*5 +1 ;
285 else if (ecid_name==
"EE_trigger_tower") {
288 int tccid=ecid_xt.
getID1();
290 int towerid=ecid_xt.
getID2();
292 bool set_the_tower=
false;
294 for (
size_t itower=0; itower<my_TTEcalLogicId_EE.size(); itower++) {
298 if(my_TTEcalLogicId_EE[itower].getID1()==tccid && my_TTEcalLogicId_EE[itower].getID2()==towerid){
299 towid =my_TTEcalLogicId_EE[itower].getLogicID();
310 std::cout <<
" these may be the additional towers TCC/TT "
311 << tccid<<
"/"<<towerid<<std::endl;
324 m_i_tag=the_config_tag;
325 m_i_version=the_config_version;
328 writeFile(
"last_tpg_lutGroup_settings.txt");
333 m_i_tag=the_config_tag;
334 m_i_version=the_config_version;
336 writeFile(
"last_tpg_lutGroup_settings.txt");
338 std::cout<<
" even if the tag/version is not the same, the lutGroup id is the same -> no transfer needed "<< std::endl;
345 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" <<the_config_tag
346 <<
" version="<<the_config_version<< std::endl;
351 std::cout<<
" **************** "<<std::endl;
355 std::cout<<
" no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed "<< std::endl;
356 std::cout<<
" **************** "<<std::endl;
359 m_i_tag=the_config_tag;
360 m_i_version=the_config_version;
361 std::cout<<
" the tag/version is the same -> no transfer needed "<< std::endl;
362 std::cout<<
" **************** "<<std::endl;
363 writeFile(
"last_tpg_lutGroup_settings.txt");
370 edm::LogInfo(
"EcalTPGLutGroupHandler") <<
"Ecal - > end of getNewObjects -----------";
382 inpFile = fopen(inputFile,
"r");
389 std::ostringstream str;
391 fgets(line,255,inpFile);
393 str <<
"gen tag " << m_i_tag << std::endl ;
395 fgets(line,255,inpFile);
396 m_i_version=atoi(line);
397 str <<
"version= " << m_i_version << std::endl ;
399 fgets(line,255,inpFile);
400 m_i_run_number=atoi(line);
401 str <<
"run_number= " << m_i_run_number << std::endl ;
403 fgets(line,255,inpFile);
404 m_i_lutGroup=atoi(line);
405 str <<
"lutGroup_config= " << m_i_lutGroup << std::endl ;
416 std::ofstream myfile;
417 myfile.open (inputFile);
418 myfile << m_i_tag <<std::endl;
419 myfile << m_i_version <<std::endl;
420 myfile << m_i_run_number <<std::endl;
421 myfile << m_i_lutGroup <<std::endl;
T getParameter(std::string const &) const
std::vector< RunIOV > getRuns()
void setLocationDef(const LocationDef locDef)
void readFromFile(const char *inputFile)
std::string getConfigTag() const
~EcalTPGLutGroupHandler()
void writeFile(const char *inputFile)
uint32_t rawId() const
get the raw id
std::string to_string(const T &t)
std::string getName() const
unsigned long long Time_t
void setValue(const uint32_t &rawId, const uint32_t &ObjectId)
void setRunType(std::string runtype)
std::string m_locationsource
void setConfigTag(std::string x)
int getLUTGroupId() const
void setLocation(std::string loc)
static const int SMCRYSTALMODE
tuple size
Write out results.
EcalTPGLutGroupHandler(edm::ParameterSet const &)