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::EcalTPGBadTTHandler Class Reference

#include <EcalTPGBadTTHandler.h>

Inheritance diagram for popcon::EcalTPGBadTTHandler:
popcon::PopConSourceHandler< EcalTPGTowerStatus >

Public Member Functions

 EcalTPGBadTTHandler (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)
 
 ~EcalTPGBadTTHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalTPGTowerStatus >
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_badTT
 
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 EcalTPGTowerStatusmytowerStat
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< EcalTPGTowerStatus >
typedef std::vector< TripletContainer
 
typedef std::vector< std::pair
< EcalTPGTowerStatus
*, cond::Time_t > > 
OldContainer
 
typedef PopConSourceHandler
< EcalTPGTowerStatus
self
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef EcalTPGTowerStatus value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< EcalTPGTowerStatus >
int add (value_type *payload, Summary *summary, Time_t time)
 
- Protected Attributes inherited from popcon::PopConSourceHandler< EcalTPGTowerStatus >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 49 of file EcalTPGBadTTHandler.h.

Constructor & Destructor Documentation

popcon::EcalTPGBadTTHandler::EcalTPGBadTTHandler ( edm::ParameterSet const &  ps)

Definition at line 25 of file EcalTPGBadTTHandler.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","EcalTPGBadTTHandler")) {
27 
28  edm::LogInfo("EcalTPGBadTTHandler") << "EcalTPGTowerStatus 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("EcalTPGBadTTHandler") << m_sid<<"/"<<m_user<<"/"<<m_location<<"/"<<m_gentag;
40 
41 }
popcon::EcalTPGBadTTHandler::~EcalTPGBadTTHandler ( )

Definition at line 43 of file EcalTPGBadTTHandler.cc.

44 {
45 }

Member Function Documentation

void popcon::EcalTPGBadTTHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalTPGTowerStatus >.

Definition at line 48 of file EcalTPGBadTTHandler.cc.

References gather_cfg::cout, dataset::dataset, alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, FEConfigMainInfo::getBttId(), RunTPGConfigDat::getConfigTag(), RunList::getRuns(), FEConfigBadTTDat::getStatus(), FEConfigBadTTDat::getTCCId(), FEConfigBadTTDat::getTTId(), RunTPGConfigDat::getVersion(), errorMatrix2Lands_multiChannel::id, ecalpyutils::ism(), EcalLogicID::NULLID, AlCaHLTBitMon_ParallelJobs::p, DetId::rawId(), IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigBadTTInfo::setId(), LocationDef::setLocation(), RunTag::setLocationDef(), RunTypeDef::setRunType(), RunTag::setRunTypeDef(), EcalTPGTowerStatus::setValue(), FEConfigMainInfo::setVersion(), and EBDetId::SMCRYSTALMODE.

49 {
50  edm::LogInfo("EcalTPGBadTTHandler") << "Started GetNewObjects!!!";
51 
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 ";
56 
57  // here we retrieve all the runs after the last from online DB
58  edm::LogInfo("EcalTPGBadTTHandler") << "Retrieving run list from ONLINE DB ... ";
59 
60  edm::LogInfo("EcalTPGBadTTHandler") << "Making connection...";
62  edm::LogInfo("EcalTPGBadTTHandler") << "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_badTT_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("EcalTPGBadTTHandler") << "min_run= " << min_run << "max_run= " << max_run;
99 
100  RunList my_list;
101  // my_list=econn->fetchRunListByLocation(my_runtag, min_run, max_run, my_locdef);
102  my_list=econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
103 
104  std::vector<RunIOV> run_vec= my_list.getRuns();
105  size_t num_runs=run_vec.size();
106 
107  std::cout <<"number of runs is : "<< num_runs<< std::endl;
108 
109  std::string str="";
110 
111  unsigned int irun=0;
112  if(num_runs>0){
113 
114 
115  // going to query the ecal logic id
116  std::vector<EcalLogicID> my_TTEcalLogicId_EE;
117  my_TTEcalLogicId_EE = econn->getEcalLogicIDSetOrdered( "EE_trigger_tower",
118  1, 200,
119  1, 70,
121  "EE_offline_towerid",12 );
122  std::cout <<" GOT the logic ID for the EE trigger towers "<< std::endl;
123 
124 
125 
126  for(size_t kr=0; kr<run_vec.size(); kr++){
127 
128  irun=static_cast<unsigned int>(run_vec[kr].getRunNumber());
129 
130  // retrieve the data :
131  std::map<EcalLogicID, RunTPGConfigDat> dataset;
132  econn->fetchDataSet(&dataset, &run_vec[kr]);
133 
134  std::string the_config_tag="";
135  int the_config_version=0;
136 
137  std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
138 
139  int nr=0;
140  for( it=dataset.begin(); it!=dataset.end(); it++ )
141  {
142  ++nr;
143  //EcalLogicID ecalid = it->first;
144 
145  RunTPGConfigDat dat = it->second;
146  the_config_tag=dat.getConfigTag();
147  the_config_version=dat.getVersion();
148  }
149 
150  // it is all the same for all SM... get the last one
151 
152 
153  // here we should check if it is the same as previous run.
154 
155 
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;
159 
160  FEConfigMainInfo fe_main_info;
161  fe_main_info.setConfigTag(the_config_tag);
162  fe_main_info.setVersion(the_config_version);
163 
164  try{
165 
166  econn-> fetchConfigSet(&fe_main_info);
167 
168  // now get TPGTowerStatus
169  int badttId=fe_main_info.getBttId();
170 
171  if( badttId != m_i_badTT ) {
172 
173  FEConfigBadTTInfo fe_badTT_info;
174  fe_badTT_info.setId(badttId);
175 
176  econn-> fetchConfigSet(&fe_badTT_info);
177 
178  std::vector< FEConfigBadTTDat > dataset_TpgBadTT;
179 
180  econn->fetchConfigDataSet(&dataset_TpgBadTT, &fe_badTT_info);
181 
182  EcalTPGTowerStatus* towerStatus = new EcalTPGTowerStatus;
183  typedef std::vector<FEConfigBadTTDat>::const_iterator CIfeped;
184  EcalLogicID ecid_xt;
185  FEConfigBadTTDat rd_badTT;
186 
187  // reset the map
188  // EB
189  for(int ism=1; ism<=36; ism++) {
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 ;
195  const EcalTrigTowerDetId towid= id.tower();
196  int tower_status=0;
197  towerStatus->setValue(towid.rawId(),tower_status);
198  }
199  }
200  //EE
201  for (size_t itower=0; itower<my_TTEcalLogicId_EE.size(); itower++) {
202  int towid =my_TTEcalLogicId_EE[itower].getLogicID();
203  int tower_status=0;
204  towerStatus->setValue(towid,tower_status);
205  }
206 
207  // now put at 1 those that are bad
208  int icells=0;
209  for (CIfeped p = dataset_TpgBadTT.begin(); p != dataset_TpgBadTT.end(); p++) {
210  rd_badTT = *p;
211 
212  int tcc_num=rd_badTT.getTCCId();
213  int tt_num=rd_badTT.getTTId();
214 
215  std::cout<< " tcc/tt"<< tcc_num<<"/"<<tt_num<< std::endl;
216 
217  if(tcc_num>36 && tcc_num<=72) {
218  // SM number
219  int smid=tcc_num-54;
220  if(tcc_num<55) smid=tcc_num-18;
221  // TT number
222  int towerid=tt_num;
223 
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 ;
227 
228  EBDetId id(smid, axt, EBDetId::SMCRYSTALMODE ) ;
229  const EcalTrigTowerDetId towid= id.tower();
230  towerStatus->setValue(towid.rawId(),rd_badTT.getStatus());
231 
232  ++icells;
233  } else {
234  // EE data
235 
236  // TCC number
237  int tccid=tcc_num;
238  // TT number
239  int towerid=tt_num;
240 
241  bool set_the_tower=false;
242  int towid;
243  for (size_t itower=0; itower<my_TTEcalLogicId_EE.size(); itower++) {
244 
245  if(!set_the_tower){
246 
247  if(my_TTEcalLogicId_EE[itower].getID1()==tccid && my_TTEcalLogicId_EE[itower].getID2()==towerid){
248  towid =my_TTEcalLogicId_EE[itower].getLogicID();
249  set_the_tower=true;
250  break;
251  }
252  }
253 
254  }
255 
256  if(set_the_tower){
257 
258  towerStatus->setValue(towid,rd_badTT.getStatus());
259 
260 
261  } else {
262  std::cout <<" these may be the additional towers TCC/TT "
263  << tccid<<"/"<<towerid<<std::endl;
264  }
265 
266  ++icells;
267 
268  }
269  }
270 
271 
272 
273 
274 
275 
276  edm::LogInfo("EcalTPGBadTTHandler") << "Finished badTT reading.";
277 
278  Time_t snc= (Time_t) irun ;
279 
280  m_to_transfer.push_back(std::make_pair((EcalTPGTowerStatus*)towerStatus,snc));
281 
282  m_i_run_number=irun;
283  m_i_tag=the_config_tag;
284  m_i_version=the_config_version;
285  m_i_badTT=badttId;
286 
287  writeFile("last_tpg_badTT_settings.txt");
288 
289  } else {
290 
291  m_i_run_number=irun;
292  m_i_tag=the_config_tag;
293  m_i_version=the_config_version;
294 
295  writeFile("last_tpg_badTT_settings.txt");
296 
297  // std::cout<< " even if the tag/version is not the same, the badTT id is the same -> no transfer needed "<< std::endl;
298 
299  }
300 
301  }
302 
303  catch (std::exception &e) {
304  std::cout << "ERROR: THIS CONFIG DOES NOT EXIST: tag=" <<the_config_tag
305  <<" version="<<the_config_version<< std::endl;
306  std::cout << e.what() << std::endl;
307  m_i_run_number=irun;
308 
309  }
310 
311 
312  } else if(nr==0) {
313  m_i_run_number=irun;
314  // std::cout<< " no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed "<< std::endl;
315  } else {
316  m_i_run_number=irun;
317  m_i_tag=the_config_tag;
318  m_i_version=the_config_version;
319 
320  writeFile("last_tpg_badTT_settings.txt");
321  }
322  }
323  }
324 
325  delete econn;
326 
327  edm::LogInfo("EcalTPGBadTTHandler") << "Ecal - > end of getNewObjects -----------";
328 }
std::vector< RunIOV > getRuns()
Definition: RunList.cc:35
void setLocationDef(const LocationDef locDef)
Definition: RunTag.cc:53
std::string getConfigTag() const
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)
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
RunList fetchGlobalRunListByLocation(RunTag tag, int min_run, int max_run, const LocationDef locDef)
void writeFile(const char *inputFile)
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov)
int getTTId() const
void setRunTypeDef(const RunTypeDef runTypeDef)
Definition: RunTag.cc:70
EcalCondDBInterface * econn
int getBttId() const
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:33
tuple dataset
Definition: dataset.py:400
void readFromFile(const char *inputFile)
void setConfigTag(std::string x)
Definition: IODConfig.h:31
static const int NULLID
Definition: EcalLogicID.h:43
cond::ValidityInterval lastInterval
Definition: TagInfo.h:11
int getStatus() const
void setLocation(std::string loc)
Definition: LocationDef.cc:33
void setValue(const uint32_t &id, const uint16_t &val)
tuple cout
Definition: gather_cfg.py:121
int getTCCId() const
void setGeneralTag(std::string tag)
Definition: RunTag.cc:36
static const int SMCRYSTALMODE
Definition: EBDetId.h:146
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
std::string popcon::EcalTPGBadTTHandler::id ( void  ) const
inlinevirtual

Implements popcon::PopConSourceHandler< EcalTPGTowerStatus >.

Definition at line 60 of file EcalTPGBadTTHandler.h.

References m_name.

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

Definition at line 331 of file EcalTPGBadTTHandler.cc.

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

331  {
332  //-------------------------------------------------------------
333 
334  m_i_tag="";
335  m_i_version=0;
336  m_i_run_number=0;
337  m_i_badTT=0;
338 
339  FILE *inpFile; // input file
340  inpFile = fopen(inputFile,"r");
341  if(!inpFile) {
342  edm::LogError("EcalTPGBadTTHandler")<<"*** Can not open file: "<<inputFile;
343  }
344 
345  char line[256];
346 
347  std::ostringstream str;
348 
349  fgets(line,255,inpFile);
350  m_i_tag=to_string(line);
351  str << "gen tag " << m_i_tag << std::endl ; // should I use this?
352 
353  fgets(line,255,inpFile);
354  m_i_version=atoi(line);
355  str << "version= " << m_i_version << std::endl ;
356 
357  fgets(line,255,inpFile);
358  m_i_run_number=atoi(line);
359  str << "run_number= " << m_i_run_number << std::endl ;
360 
361  fgets(line,255,inpFile);
362  m_i_badTT=atoi(line);
363  str << "badTT_config= " << m_i_badTT << std::endl ;
364 
365 
366  fclose(inpFile); // close inp. file
367 
368 }
std::string to_string(char value[])
std::string popcon::EcalTPGBadTTHandler::to_string ( char  value[])
inlineprivate

Definition at line 68 of file EcalTPGBadTTHandler.h.

References relativeConstraints::value.

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

Definition at line 370 of file EcalTPGBadTTHandler.cc.

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

370  {
371  //-------------------------------------------------------------
372 
373 
374  std::ofstream myfile;
375  myfile.open (inputFile);
376  myfile << m_i_tag <<std::endl;
377  myfile << m_i_version <<std::endl;
378  myfile << m_i_run_number <<std::endl;
379  myfile << m_i_badTT <<std::endl;
380 
381  myfile.close();
382 
383 }

Member Data Documentation

EcalCondDBInterface* popcon::EcalTPGBadTTHandler::econn

Definition at line 65 of file EcalTPGBadTTHandler.h.

unsigned int popcon::EcalTPGBadTTHandler::m_firstRun
private

Definition at line 76 of file EcalTPGBadTTHandler.h.

Referenced by EcalTPGBadTTHandler().

std::string popcon::EcalTPGBadTTHandler::m_gentag
private

Definition at line 81 of file EcalTPGBadTTHandler.h.

Referenced by EcalTPGBadTTHandler().

int popcon::EcalTPGBadTTHandler::m_i_badTT
private

Definition at line 92 of file EcalTPGBadTTHandler.h.

unsigned int popcon::EcalTPGBadTTHandler::m_i_run_number
private

Definition at line 91 of file EcalTPGBadTTHandler.h.

std::string popcon::EcalTPGBadTTHandler::m_i_tag
private

Definition at line 89 of file EcalTPGBadTTHandler.h.

int popcon::EcalTPGBadTTHandler::m_i_version
private

Definition at line 90 of file EcalTPGBadTTHandler.h.

unsigned int popcon::EcalTPGBadTTHandler::m_lastRun
private

Definition at line 77 of file EcalTPGBadTTHandler.h.

Referenced by EcalTPGBadTTHandler().

std::string popcon::EcalTPGBadTTHandler::m_location
private

Definition at line 80 of file EcalTPGBadTTHandler.h.

Referenced by EcalTPGBadTTHandler().

std::string popcon::EcalTPGBadTTHandler::m_locationsource
private

Definition at line 85 of file EcalTPGBadTTHandler.h.

Referenced by EcalTPGBadTTHandler().

std::string popcon::EcalTPGBadTTHandler::m_name
private

Definition at line 86 of file EcalTPGBadTTHandler.h.

Referenced by id().

std::string popcon::EcalTPGBadTTHandler::m_pass
private

Definition at line 84 of file EcalTPGBadTTHandler.h.

Referenced by EcalTPGBadTTHandler().

unsigned int popcon::EcalTPGBadTTHandler::m_runnr
private

Definition at line 87 of file EcalTPGBadTTHandler.h.

std::string popcon::EcalTPGBadTTHandler::m_runtype
private

Definition at line 88 of file EcalTPGBadTTHandler.h.

Referenced by EcalTPGBadTTHandler().

std::string popcon::EcalTPGBadTTHandler::m_sid
private

Definition at line 82 of file EcalTPGBadTTHandler.h.

Referenced by EcalTPGBadTTHandler().

std::string popcon::EcalTPGBadTTHandler::m_user
private

Definition at line 83 of file EcalTPGBadTTHandler.h.

Referenced by EcalTPGBadTTHandler().

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

Definition at line 78 of file EcalTPGBadTTHandler.h.

const EcalTPGTowerStatus* popcon::EcalTPGBadTTHandler::mytowerStat
private

Definition at line 74 of file EcalTPGBadTTHandler.h.