26 : m_name(ps.getUntrackedParameter<std::
string>(
"name",
"EcalTPGBadTTHandler")) {
28 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"EcalTPGTowerStatus Source handler constructor.";
50 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"Started GetNewObjects!!!";
52 unsigned int max_since=0;
53 max_since=
static_cast<unsigned int>(
tagInfo().lastInterval.first);
54 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"max_since : " << max_since;
55 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"retrieved last payload ";
58 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"Retrieving run list from ONLINE DB ... ";
60 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"Making connection...";
66 std::cout <<
" connection parameters " <<m_sid <<
"/"<<m_user<<std::endl;
81 readFromFile(
"last_tpg_badTT_settings.txt");
84 unsigned int min_run=m_i_run_number+1;
86 if(m_firstRun<m_i_run_number) {
87 min_run=m_i_run_number+1;
91 if(min_run<max_since) {
95 std::cout<<
"m_i_run_number"<< m_i_run_number <<
"m_firstRun "<<m_firstRun<<
"max_since " <<max_since<< std::endl;
97 unsigned int max_run=m_lastRun;
98 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"min_run= " << min_run <<
"max_run= " << max_run;
102 my_list=econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
104 std::vector<RunIOV> run_vec= my_list.
getRuns();
105 size_t num_runs=run_vec.size();
107 std::cout <<
"number of runs is : "<< num_runs<< std::endl;
116 std::vector<EcalLogicID> my_TTEcalLogicId_EE;
117 my_TTEcalLogicId_EE = econn->getEcalLogicIDSetOrdered(
"EE_trigger_tower",
121 "EE_offline_towerid",12 );
122 std::cout <<
" GOT the logic ID for the EE trigger towers "<< std::endl;
126 for(
size_t kr=0; kr<run_vec.size(); kr++){
128 irun=
static_cast<unsigned int>(run_vec[kr].getRunNumber());
131 std::map<EcalLogicID, RunTPGConfigDat>
dataset;
132 econn->fetchDataSet(&dataset, &run_vec[kr]);
135 int the_config_version=0;
137 std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
140 for( it=dataset.begin(); it!=dataset.end(); it++ )
156 if((the_config_tag != m_i_tag || the_config_version != m_i_version ) && nr>0 ) {
157 std::cout<<
" run= "<<irun<<
" tag "<<the_config_tag<<
" version="<<the_config_version <<std::endl;
158 std::cout<<
"the tag is different from last transferred run ... retrieving last config set from DB"<<std::endl;
166 econn-> fetchConfigSet(&fe_main_info);
169 int badttId=fe_main_info.
getBttId();
171 if( badttId != m_i_badTT ) {
174 fe_badTT_info.
setId(badttId);
176 econn-> fetchConfigSet(&fe_badTT_info);
178 std::vector< FEConfigBadTTDat > dataset_TpgBadTT;
180 econn->fetchConfigDataSet(&dataset_TpgBadTT, &fe_badTT_info);
183 typedef std::vector<FEConfigBadTTDat>::const_iterator CIfeped;
190 for(
int ito=1; ito<=68; ito++) {
191 int tow_eta=(ito-1)/4;
192 int tow_phi=((ito-1)-tow_eta*4);
193 int axt=(tow_eta*5)*20 + tow_phi*5 +1 ;
201 for (
size_t itower=0; itower<my_TTEcalLogicId_EE.size(); itower++) {
202 int towid =my_TTEcalLogicId_EE[itower].getLogicID();
204 towerStatus->
setValue(towid,tower_status);
209 for (CIfeped
p = dataset_TpgBadTT.begin();
p != dataset_TpgBadTT.end();
p++) {
215 std::cout<<
" tcc/tt"<< tcc_num<<
"/"<<tt_num<< std::endl;
217 if(tcc_num>36 && tcc_num<=72) {
220 if(tcc_num<55) smid=tcc_num-18;
224 int tow_eta=(towerid-1)/4;
225 int tow_phi=((towerid-1)-tow_eta*4);
226 int axt=(tow_eta*5)*20 + tow_phi*5 +1 ;
241 bool set_the_tower=
false;
243 for (
size_t itower=0; itower<my_TTEcalLogicId_EE.size(); itower++) {
247 if(my_TTEcalLogicId_EE[itower].getID1()==tccid && my_TTEcalLogicId_EE[itower].getID2()==towerid){
248 towid =my_TTEcalLogicId_EE[itower].getLogicID();
262 std::cout <<
" these may be the additional towers TCC/TT "
263 << tccid<<
"/"<<towerid<<std::endl;
276 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"Finished badTT reading.";
283 m_i_tag=the_config_tag;
284 m_i_version=the_config_version;
287 writeFile(
"last_tpg_badTT_settings.txt");
292 m_i_tag=the_config_tag;
293 m_i_version=the_config_version;
295 writeFile(
"last_tpg_badTT_settings.txt");
304 std::cout <<
"ERROR: THIS CONFIG DOES NOT EXIST: tag=" <<the_config_tag
305 <<
" version="<<the_config_version<< std::endl;
317 m_i_tag=the_config_tag;
318 m_i_version=the_config_version;
320 writeFile(
"last_tpg_badTT_settings.txt");
327 edm::LogInfo(
"EcalTPGBadTTHandler") <<
"Ecal - > end of getNewObjects -----------";
340 inpFile = fopen(inputFile,
"r");
348 std::ostringstream str;
350 fgets(line,255,inpFile);
351 m_i_tag=to_string(line);
352 str <<
"gen tag " << m_i_tag << std::endl ;
354 fgets(line,255,inpFile);
355 m_i_version=atoi(line);
356 str <<
"version= " << m_i_version << std::endl ;
358 fgets(line,255,inpFile);
359 m_i_run_number=atoi(line);
360 str <<
"run_number= " << m_i_run_number << std::endl ;
362 fgets(line,255,inpFile);
363 m_i_badTT=atoi(line);
364 str <<
"badTT_config= " << m_i_badTT << std::endl ;
375 std::ofstream myfile;
376 myfile.open (inputFile);
377 myfile << m_i_tag <<std::endl;
378 myfile << m_i_version <<std::endl;
379 myfile << m_i_run_number <<std::endl;
380 myfile << m_i_badTT <<std::endl;
T getParameter(std::string const &) const
void setRunTypeDef(const RunTypeDef &runTypeDef)
std::vector< RunIOV > getRuns()
std::string getConfigTag() const
std::string m_locationsource
uint32_t rawId() const
get the raw id
void writeFile(const char *inputFile)
void setLocationDef(const LocationDef &locDef)
void setRunType(std::string runtype)
void readFromFile(const char *inputFile)
void setConfigTag(std::string x)
void setLocation(std::string loc)
void setValue(const uint32_t &id, const uint16_t &val)
void setGeneralTag(std::string tag)
static const int SMCRYSTALMODE
int ism(int ieta, int iphi)
EcalTPGBadTTHandler(edm::ParameterSet const &)