CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
popcon::EcalTPGBadStripHandler Class Reference

#include <EcalTPGBadStripHandler.h>

Inheritance diagram for popcon::EcalTPGBadStripHandler:
popcon::PopConSourceHandler< EcalTPGStripStatus >

Public Member Functions

 EcalTPGBadStripHandler (edm::ParameterSet const &)
 
void getNewObjects () override
 
std::string id () const override
 
std::map< std::string, int > makeTTEEDetId ()
 
void readFromFile (const char *inputFile)
 
void writeFile (const char *inputFile)
 
 ~EcalTPGBadStripHandler () override
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalTPGStripStatus >
void convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
void initialize (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry_t const & logDBEntry () const
 
std::pair< Container const *, std::string const > operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
void sort ()
 
cond::TagInfo_t const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Public Attributes

EcalCondDBInterfaceeconn
 

Private Member Functions

std::string to_string (char value[])
 

Private Attributes

unsigned int m_firstRun
 
std::string m_gentag
 
int m_i_badStrip
 
unsigned int m_i_run_number
 
std::string m_i_tag
 
int m_i_version
 
unsigned int m_lastRun
 
std::string m_location
 
std::string m_locationsource
 
std::string m_name
 
std::string m_pass
 
unsigned int m_runnr
 
std::string m_runtype
 
std::string m_sid
 
std::string m_user
 
std::map< std::string, int > mapDetEEId
 
const EcalTPGStripStatusmystripStat
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< EcalTPGStripStatus >
typedef std::vector< Triplet > Container
 
typedef std::vector< std::pair< EcalTPGStripStatus *, cond::Time_t > > OldContainer
 
typedef PopConSourceHandler< EcalTPGStripStatusself
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef EcalTPGStripStatus value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< EcalTPGStripStatus >
int add (value_type *payload, Summary *summary, Time_t time)
 
cond::persistency::SessiondbSession () const
 
- Protected Attributes inherited from popcon::PopConSourceHandler< EcalTPGStripStatus >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 49 of file EcalTPGBadStripHandler.h.

Constructor & Destructor Documentation

popcon::EcalTPGBadStripHandler::EcalTPGBadStripHandler ( edm::ParameterSet const &  )

Definition at line 25 of file EcalTPGBadStripHandler.cc.

References edm::ParameterSet::getParameter(), m_firstRun, m_gentag, m_lastRun, m_location, m_locationsource, m_pass, m_runtype, m_sid, m_user, and AlCaHLTBitMon_QueryRunRegistry::string.

26  : m_name(ps.getUntrackedParameter<std::string>("name","EcalTPGBadStripHandler")) {
27 
28  edm::LogInfo("EcalTPGBadStripHandler") << "EcalTPGStripStatus Source handler constructor.";
29  m_firstRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("firstRun").c_str()));
30  m_lastRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("lastRun").c_str()));
31  m_sid= ps.getParameter<std::string>("OnlineDBSID");
32  m_user= ps.getParameter<std::string>("OnlineDBUser");
33  m_pass= ps.getParameter<std::string>("OnlineDBPassword");
34  m_locationsource= ps.getParameter<std::string>("LocationSource");
35  m_location=ps.getParameter<std::string>("Location");
36  m_gentag=ps.getParameter<std::string>("GenTag");
37  m_runtype=ps.getParameter<std::string>("RunType");
38 
39  edm::LogInfo("EcalTPGBadStripHandler") << m_sid<<"/"<<m_user<<"/"<<m_location<<"/"<<m_gentag;
40 
41 }
popcon::EcalTPGBadStripHandler::~EcalTPGBadStripHandler ( )
override

Definition at line 43 of file EcalTPGBadStripHandler.cc.

44 {
45 }

Member Function Documentation

void popcon::EcalTPGBadStripHandler::getNewObjects ( )
overridevirtual

Implements popcon::PopConSourceHandler< EcalTPGStripStatus >.

Definition at line 48 of file EcalTPGBadStripHandler.cc.

References gather_cfg::cout, createfilelist::dataset, MillePedeFileConverter_cfg::e, econn, cppFunctionSkipper::exception, Exception, EcalCondDBInterface::fetchConfigDataSet(), EcalCondDBInterface::fetchDataSet(), EcalCondDBInterface::fetchGlobalRunListByLocation(), FEConfigMainInfo::getBstId(), RunTPGConfigDat::getConfigTag(), EcalCondDBInterface::getEcalLogicIDSetOrdered(), RunList::getRuns(), FEConfigBadStripDat::getStatus(), FEConfigBadStripDat::getStripId(), FEConfigBadStripDat::getTCCId(), FEConfigBadStripDat::getTTId(), RunTPGConfigDat::getVersion(), cond::TagInfo_t::lastInterval, m_firstRun, m_gentag, m_i_badStrip, m_i_run_number, m_i_tag, m_i_version, m_lastRun, m_location, m_pass, m_runtype, m_sid, popcon::PopConSourceHandler< EcalTPGStripStatus >::m_to_transfer, m_user, AlCaHLTBitMon_ParallelJobs::p, readFromFile(), IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigBadStripInfo::setId(), LocationDef::setLocation(), RunTag::setLocationDef(), RunTypeDef::setRunType(), RunTag::setRunTypeDef(), EcalTPGStripStatus::setValue(), FEConfigMainInfo::setVersion(), str, AlCaHLTBitMon_QueryRunRegistry::string, popcon::PopConSourceHandler< EcalTPGStripStatus >::tagInfo(), and writeFile().

49 {
50  edm::LogInfo("EcalTPGBadStripHandler") << "Started GetNewObjects!!!";
51 
52  unsigned int max_since=0;
53  max_since=static_cast<unsigned int>(tagInfo().lastInterval.first);
54  edm::LogInfo("EcalTPGBadStripHandler") << "max_since : " << max_since;
55  edm::LogInfo("EcalTPGBadStripHandler") << "retrieved last payload ";
56 
57  // here we retrieve all the runs after the last from online DB
58  edm::LogInfo("EcalTPGBadStripHandler") << "Retrieving run list from ONLINE DB ... ";
59 
60  edm::LogInfo("EcalTPGBadStripHandler") << "Making connection...";
62  edm::LogInfo("EcalTPGBadStripHandler") << "Done.";
63 
64  if (!econn)
65  {
66  std::cout << " connection parameters " <<m_sid <<"/"<<m_user<<std::endl;
67  throw cms::Exception("OMDS not available");
68  }
69 
70  LocationDef my_locdef;
71  my_locdef.setLocation(m_location);
72 
73  RunTypeDef my_rundef;
74  my_rundef.setRunType(m_runtype);
75 
76  RunTag my_runtag;
77  my_runtag.setLocationDef( my_locdef );
78  my_runtag.setRunTypeDef( my_rundef );
79  my_runtag.setGeneralTag(m_gentag);
80 
81  readFromFile("last_tpg_badStrip_settings.txt");
82 
83 
84  unsigned int min_run=m_i_run_number+1;
85 
87  min_run=m_i_run_number+1;
88  } else {
89  min_run=m_firstRun;
90  }
91  if(min_run<max_since) {
92  min_run= max_since+1; // we have to add 1 to the last transferred one
93  }
94 
95  std::cout<<"m_i_run_number"<< m_i_run_number <<"m_firstRun "<<m_firstRun<< "max_since " <<max_since<< std::endl;
96 
97  unsigned int max_run=m_lastRun;
98  edm::LogInfo("EcalTPGBadStripHandler") << "min_run= " << min_run << "max_run= " << max_run;
99 
100  RunList my_list;
101  my_list=econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
102  //my_list=econn->fetchRunListByLocation(my_runtag, min_run, max_run, my_locdef);
103 
104 
105  std::vector<RunIOV> run_vec= my_list.getRuns();
106  size_t num_runs=run_vec.size();
107 
108  std::cout <<"number of runs is : "<< num_runs<< std::endl;
109 
110  std::string str="";
111 
112  unsigned int irun=0;
113 
114  if(num_runs>0){
115 
116  // going to query the ecal logic id
117  std::vector<EcalLogicID> my_StripEcalLogicId_EE;
118  my_StripEcalLogicId_EE = econn->getEcalLogicIDSetOrdered("EE_trigger_strip",
119  1, 1000, //"TCC"
120  1, 100, //tower
121  0, 5, //strip
122  "EE_offline_stripid",123 );
123 
124  std::cout <<" GOT the logic ID for the EE trigger strips "<< std::endl;
125 
126 
127  for(size_t kr=0; kr<run_vec.size(); kr++){
128 
129  irun=static_cast<unsigned int>(run_vec[kr].getRunNumber());
130 
131  std::cout<<" **************** "<<std::endl;
132  std::cout<<" **************** "<<std::endl;
133  std::cout<<" run= "<<irun<<std::endl;
134 
135  // retrieve the data :
136  std::map<EcalLogicID, RunTPGConfigDat> dataset;
137  econn->fetchDataSet(&dataset, &run_vec[kr]);
138 
139  std::string the_config_tag="";
140  int the_config_version=0;
141 
142  std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
143 
144  int nr=0;
145  for( it=dataset.begin(); it!=dataset.end(); it++ )
146  {
147  ++nr;
148  //EcalLogicID ecalid = it->first;
149 
150  RunTPGConfigDat dat = it->second;
151  the_config_tag=dat.getConfigTag();
152  the_config_version=dat.getVersion();
153  }
154 
155  // it is all the same for all SM... get the last one
156 
157  std::cout<<" run= "<<irun<<" tag "<<the_config_tag<<" version="<<the_config_version <<std::endl;
158 
159  // here we should check if it is the same as previous run.
160 
161  if((the_config_tag != m_i_tag || the_config_version != m_i_version ) && nr>0 ) {
162  std::cout<<" run= "<<irun<<" tag "<<the_config_tag<<" version="<<the_config_version <<std::endl;
163  std::cout<<"the tag is different from last transferred run ... retrieving last config set from DB"<<std::endl;
164 
165  FEConfigMainInfo fe_main_info;
166  fe_main_info.setConfigTag(the_config_tag);
167  fe_main_info.setVersion(the_config_version);
168 
169  try{
170 
171  econn-> fetchConfigSet(&fe_main_info);
172 
173  // now get TPGStripStatus
174  int badstripId=fe_main_info.getBstId();
175 
176  if( badstripId != m_i_badStrip ) {
177 
178  FEConfigBadStripInfo fe_badStrip_info;
179  fe_badStrip_info.setId(badstripId);
180 
181  econn-> fetchConfigSet(&fe_badStrip_info);
182 
183  std::vector< FEConfigBadStripDat > dataset_TpgBadStrip;
184 
185  econn->fetchConfigDataSet(&dataset_TpgBadStrip, &fe_badStrip_info);
186 
187  EcalTPGStripStatus* stripStatus = new EcalTPGStripStatus;
188  typedef std::vector<FEConfigBadStripDat>::const_iterator CIfeped;
189 
190  FEConfigBadStripDat rd_badStrip;
191  //unsigned int rd_stripStatus;
192 
193 
194  // put at 1 the strip that are bad
195  int icells=0;
196  int icellsFound=0;
197  for (CIfeped p = dataset_TpgBadStrip.begin(); p != dataset_TpgBadStrip.end(); p++) {
198 
199  rd_badStrip = *p;
200 
201  //int fed_num=rd_badStrip.getFedId();
202  int tcc_num=rd_badStrip.getTCCId();
203  int tt_num=rd_badStrip.getTTId();
204  int strip_num=rd_badStrip.getStripId();
205 
206  //std::cout << fed_num << " " << tcc_num << " " << tt_num << " " << strip_num << std::endl;
207 
208  // EE data
209  int stripid;
210 
211  bool set_the_strip=false;
212  for (size_t istrip=0; istrip<my_StripEcalLogicId_EE.size(); istrip++) {
213 
214  if(!set_the_strip){
215 
216  if(my_StripEcalLogicId_EE[istrip].getID1()==tcc_num
217  && my_StripEcalLogicId_EE[istrip].getID2()==tt_num
218  && my_StripEcalLogicId_EE[istrip].getID3()==strip_num
219  ){
220  stripid =my_StripEcalLogicId_EE[istrip].getLogicID();
221 
222  set_the_strip=true;
223  ++icellsFound;
224  break;
225  }
226 
227  }
228  }
229 
230 
231  if(set_the_strip){
232  stripStatus->setValue(stripid, (unsigned int)rd_badStrip.getStatus());
233  }
234 
235  ++icells;
236  }
237 
238  // std::cout << " icells = " << icells << std::endl;
239 
240  edm::LogInfo("EcalTPGBadStripHandler") << "Finished badStrip reading.";
241 
242  Time_t snc= (Time_t) irun ;
243 
244  m_to_transfer.push_back(std::make_pair((EcalTPGStripStatus*)stripStatus,snc));
245 
246  m_i_run_number=irun;
247  m_i_tag=the_config_tag;
248  m_i_version=the_config_version;
249  m_i_badStrip=badstripId;
250 
251  writeFile("last_tpg_badStrip_settings.txt");
252 
253  } else {
254 
255  m_i_run_number=irun;
256  m_i_tag=the_config_tag;
257  m_i_version=the_config_version;
258 
259  writeFile("last_tpg_badStrip_settings.txt");
260 
261  // std::cout<< " even if the tag/version is not the same, the badStrip id is the same -> no transfer needed "<< std::endl;
262 
263  }
264 
265  }
266 
267  catch (std::exception &e) {
268  std::cout << "ERROR: THIS CONFIG DOES NOT EXIST: tag=" <<the_config_tag
269  <<" version="<<the_config_version<< std::endl;
270  std::cout << e.what() << std::endl;
271  m_i_run_number=irun;
272 
273  }
274 
275 
276  } else if(nr==0) {
277  m_i_run_number=irun;
278  // std::cout<< " no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed "<< std::endl;
279  } else {
280  m_i_run_number=irun;
281  m_i_tag=the_config_tag;
282  m_i_version=the_config_version;
283 
284  writeFile("last_tpg_badStrip_settings.txt");
285  }
286  }
287  }
288 
289  delete econn;
290 
291  edm::LogInfo("EcalTPGBadStripHandler") << "Ecal - > end of getNewObjects -----------";
292 }
void setRunTypeDef(const RunTypeDef &runTypeDef)
Definition: RunTag.cc:70
std::vector< RunIOV > getRuns()
Definition: RunList.cc:35
RunList fetchGlobalRunListByLocation(const RunTag &tag, int min_run, int max_run, const LocationDef &locDef) noexcept(false)
std::string getConfigTag() const
void writeFile(const char *inputFile)
int getVersion() const
Definition: RunTag.h:13
void setVersion(int id)
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov) noexcept(false)
cond::ValidityInterval lastInterval
Definition: Types.h:75
std::vector< EcalLogicID > getEcalLogicIDSetOrdered(std::string name, int fromId1, int toId1, int fromId2=EcalLogicID::NULLID, int toId2=EcalLogicID::NULLID, int fromId3=EcalLogicID::NULLID, int toId3=EcalLogicID::NULLID, std::string mapsTo="", int orderedBy=EcalLogicID::NULLID) noexcept(false)
void setLocationDef(const LocationDef &locDef)
Definition: RunTag.cc:53
void readFromFile(const char *inputFile)
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:33
void setConfigTag(std::string x)
Definition: IODConfig.h:31
int getBstId() const
void setLocation(std::string loc)
Definition: LocationDef.cc:33
void fetchConfigDataSet(std::vector< DATT > *fillMap, ICONF *iconf) noexcept(false)
void setGeneralTag(std::string tag)
Definition: RunTag.cc:36
#define str(s)
void setValue(const uint32_t &id, const uint16_t &val)
std::string popcon::EcalTPGBadStripHandler::id ( ) const
inlineoverridevirtual
std::map<std::string, int> popcon::EcalTPGBadStripHandler::makeTTEEDetId ( )
void popcon::EcalTPGBadStripHandler::readFromFile ( const char *  inputFile)

Definition at line 295 of file EcalTPGBadStripHandler.cc.

References analyzePatCleaning_cfg::inputFile, mps_splice::line, m_i_badStrip, m_i_run_number, m_i_tag, m_i_version, str, and to_string().

Referenced by getNewObjects().

295  {
296  //-------------------------------------------------------------
297 
298  m_i_tag="";
299  m_i_version=0;
300  m_i_run_number=0;
301  m_i_badStrip=0;
302 
303  FILE *inpFile; // input file
304  inpFile = fopen(inputFile,"r");
305  if(!inpFile) {
306  edm::LogError("EcalTPGBadStripHandler")<<"*** Can not open file: "<<inputFile;
307  return;
308  }
309 
310  char line[256];
311 
312  std::ostringstream str;
313 
314  fgets(line,255,inpFile);
315  m_i_tag=to_string(line);
316  str << "gen tag " << m_i_tag << std::endl ; // should I use this?
317 
318  fgets(line,255,inpFile);
319  m_i_version=atoi(line);
320  str << "version= " << m_i_version << std::endl ;
321 
322  fgets(line,255,inpFile);
323  m_i_run_number=atoi(line);
324  str << "run_number= " << m_i_run_number << std::endl ;
325 
326  fgets(line,255,inpFile);
327  m_i_badStrip=atoi(line);
328  str << "badTT_config= " << m_i_badStrip << std::endl ;
329 
330 
331  fclose(inpFile); // close inp. file
332 
333 }
std::string to_string(char value[])
#define str(s)
std::string popcon::EcalTPGBadStripHandler::to_string ( char  value[])
inlineprivate

Definition at line 68 of file EcalTPGBadStripHandler.h.

References relativeConstraints::value.

Referenced by readFromFile().

68  {
69  std::ostringstream streamOut;
70  streamOut << value;
71  return streamOut.str();
72  }
void popcon::EcalTPGBadStripHandler::writeFile ( const char *  inputFile)

Definition at line 336 of file EcalTPGBadStripHandler.cc.

References m_i_badStrip, m_i_run_number, m_i_tag, and m_i_version.

Referenced by getNewObjects(), and Vispa.Main.TabController.TabController::save().

336  {
337  //-------------------------------------------------------------
338 
339 
340  std::ofstream myfile;
341  myfile.open (inputFile);
342  myfile << m_i_tag <<std::endl;
343  myfile << m_i_version <<std::endl;
344  myfile << m_i_run_number <<std::endl;
345  myfile << m_i_badStrip <<std::endl;
346 
347  myfile.close();
348 
349 }

Member Data Documentation

EcalCondDBInterface* popcon::EcalTPGBadStripHandler::econn

Definition at line 65 of file EcalTPGBadStripHandler.h.

Referenced by getNewObjects().

unsigned int popcon::EcalTPGBadStripHandler::m_firstRun
private

Definition at line 76 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler(), and getNewObjects().

std::string popcon::EcalTPGBadStripHandler::m_gentag
private

Definition at line 81 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler(), and getNewObjects().

int popcon::EcalTPGBadStripHandler::m_i_badStrip
private

Definition at line 92 of file EcalTPGBadStripHandler.h.

Referenced by getNewObjects(), readFromFile(), and writeFile().

unsigned int popcon::EcalTPGBadStripHandler::m_i_run_number
private

Definition at line 91 of file EcalTPGBadStripHandler.h.

Referenced by getNewObjects(), readFromFile(), and writeFile().

std::string popcon::EcalTPGBadStripHandler::m_i_tag
private

Definition at line 89 of file EcalTPGBadStripHandler.h.

Referenced by getNewObjects(), readFromFile(), and writeFile().

int popcon::EcalTPGBadStripHandler::m_i_version
private

Definition at line 90 of file EcalTPGBadStripHandler.h.

Referenced by getNewObjects(), readFromFile(), and writeFile().

unsigned int popcon::EcalTPGBadStripHandler::m_lastRun
private

Definition at line 77 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler(), and getNewObjects().

std::string popcon::EcalTPGBadStripHandler::m_location
private

Definition at line 80 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler(), and getNewObjects().

std::string popcon::EcalTPGBadStripHandler::m_locationsource
private

Definition at line 85 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

std::string popcon::EcalTPGBadStripHandler::m_name
private

Definition at line 86 of file EcalTPGBadStripHandler.h.

std::string popcon::EcalTPGBadStripHandler::m_pass
private

Definition at line 84 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler(), and getNewObjects().

unsigned int popcon::EcalTPGBadStripHandler::m_runnr
private

Definition at line 87 of file EcalTPGBadStripHandler.h.

std::string popcon::EcalTPGBadStripHandler::m_runtype
private

Definition at line 88 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler(), and getNewObjects().

std::string popcon::EcalTPGBadStripHandler::m_sid
private

Definition at line 82 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler(), and getNewObjects().

std::string popcon::EcalTPGBadStripHandler::m_user
private

Definition at line 83 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler(), and getNewObjects().

std::map<std::string, int> popcon::EcalTPGBadStripHandler::mapDetEEId
private

Definition at line 78 of file EcalTPGBadStripHandler.h.

const EcalTPGStripStatus* popcon::EcalTPGBadStripHandler::mystripStat
private

Definition at line 74 of file EcalTPGBadStripHandler.h.