CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
std::string id () const
 
std::map< std::string, int > makeTTEEDetId ()
 
void readFromFile (const char *inputFile)
 
void writeFile (const char *inputFile)
 
 ~EcalTPGBadStripHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalTPGStripStatus >
void convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
void initialize (cond::DbSession dbSession, cond::TagInfo const &tagInfo, cond::LogDBEntry const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry const & logDBEntry () const
 
std::pair< Container const
*, std::string const > 
operator() (cond::DbSession session, cond::TagInfo const &tagInfo, cond::LogDBEntry const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
void sort ()
 
cond::TagInfo 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< TripletContainer
 
typedef std::vector< std::pair
< EcalTPGStripStatus
*, cond::Time_t > > 
OldContainer
 
typedef PopConSourceHandler
< EcalTPGStripStatus
self
 
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)
 
- 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 &  ps)

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, and m_user.

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 ( )

Definition at line 43 of file EcalTPGBadStripHandler.cc.

44 {
45 }

Member Function Documentation

void popcon::EcalTPGBadStripHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalTPGStripStatus >.

Definition at line 48 of file EcalTPGBadStripHandler.cc.

References gather_cfg::cout, dataset::dataset, alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, FEConfigMainInfo::getBstId(), RunTPGConfigDat::getConfigTag(), RunList::getRuns(), FEConfigBadStripDat::getStatus(), FEConfigBadStripDat::getStripId(), FEConfigBadStripDat::getTCCId(), FEConfigBadStripDat::getTTId(), RunTPGConfigDat::getVersion(), AlCaHLTBitMon_ParallelJobs::p, IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigBadStripInfo::setId(), LocationDef::setLocation(), RunTag::setLocationDef(), RunTypeDef::setRunType(), RunTag::setRunTypeDef(), EcalTPGStripStatus::setValue(), and FEConfigMainInfo::setVersion().

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 }
std::vector< RunIOV > getRuns()
Definition: RunList.cc:35
void setLocationDef(const LocationDef locDef)
Definition: RunTag.cc:53
std::string getConfigTag() const
void writeFile(const char *inputFile)
int getVersion() const
Definition: RunTag.h:13
void setVersion(int id)
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)
void fetchConfigDataSet(std::vector< DATT > *fillMap, ICONF *iconf)
RunList fetchGlobalRunListByLocation(RunTag tag, int min_run, int max_run, const LocationDef locDef)
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov)
void setRunTypeDef(const RunTypeDef runTypeDef)
Definition: RunTag.cc:70
void readFromFile(const char *inputFile)
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:33
tuple dataset
Definition: dataset.py:400
void setConfigTag(std::string x)
Definition: IODConfig.h:31
cond::ValidityInterval lastInterval
Definition: TagInfo.h:11
int getBstId() const
void setLocation(std::string loc)
Definition: LocationDef.cc:33
tuple cout
Definition: gather_cfg.py:121
void setGeneralTag(std::string tag)
Definition: RunTag.cc:36
void setValue(const uint32_t &id, const uint16_t &val)
std::string popcon::EcalTPGBadStripHandler::id ( void  ) const
inlinevirtual

Implements popcon::PopConSourceHandler< EcalTPGStripStatus >.

Definition at line 60 of file EcalTPGBadStripHandler.h.

References m_name.

60 { return m_name;}
std::map<std::string, int> popcon::EcalTPGBadStripHandler::makeTTEEDetId ( )
void popcon::EcalTPGBadStripHandler::readFromFile ( const char *  inputFile)

Definition at line 295 of file EcalTPGBadStripHandler.cc.

References analyzePatCOC_cfg::inputFile, geometryCSVtoXML::line, and cond::to_string().

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  }
308 
309  char line[256];
310 
311  std::ostringstream str;
312 
313  fgets(line,255,inpFile);
314  m_i_tag=to_string(line);
315  str << "gen tag " << m_i_tag << std::endl ; // should I use this?
316 
317  fgets(line,255,inpFile);
318  m_i_version=atoi(line);
319  str << "version= " << m_i_version << std::endl ;
320 
321  fgets(line,255,inpFile);
322  m_i_run_number=atoi(line);
323  str << "run_number= " << m_i_run_number << std::endl ;
324 
325  fgets(line,255,inpFile);
326  m_i_badStrip=atoi(line);
327  str << "badTT_config= " << m_i_badStrip << std::endl ;
328 
329 
330  fclose(inpFile); // close inp. file
331 
332 }
std::string to_string(char value[])
std::string popcon::EcalTPGBadStripHandler::to_string ( char  value[])
inlineprivate

Definition at line 68 of file EcalTPGBadStripHandler.h.

References relativeConstraints::value.

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

Definition at line 335 of file EcalTPGBadStripHandler.cc.

Referenced by Vispa.Main.TabController.TabController::save().

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

Member Data Documentation

EcalCondDBInterface* popcon::EcalTPGBadStripHandler::econn

Definition at line 65 of file EcalTPGBadStripHandler.h.

unsigned int popcon::EcalTPGBadStripHandler::m_firstRun
private

Definition at line 76 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

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

Definition at line 81 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

int popcon::EcalTPGBadStripHandler::m_i_badStrip
private

Definition at line 92 of file EcalTPGBadStripHandler.h.

unsigned int popcon::EcalTPGBadStripHandler::m_i_run_number
private

Definition at line 91 of file EcalTPGBadStripHandler.h.

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

Definition at line 89 of file EcalTPGBadStripHandler.h.

int popcon::EcalTPGBadStripHandler::m_i_version
private

Definition at line 90 of file EcalTPGBadStripHandler.h.

unsigned int popcon::EcalTPGBadStripHandler::m_lastRun
private

Definition at line 77 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

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

Definition at line 80 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

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.

Referenced by id().

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

Definition at line 84 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

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().

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

Definition at line 82 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

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

Definition at line 83 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

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.