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 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 ()
 
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::map< Time_t, std::shared_ptr< EcalTPGStripStatus > > Container
 
typedef std::unique_ptr< EcalTPGStripStatusRef
 
typedef PopConSourceHandler< EcalTPGStripStatusself
 
typedef cond::Time_t Time_t
 
typedef EcalTPGStripStatus value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< EcalTPGStripStatus >
cond::persistency::SessiondbSession () const
 
- Protected Attributes inherited from popcon::PopConSourceHandler< EcalTPGStripStatus >
Container m_iovs
 
std::vector< std::pair< EcalTPGStripStatus *, Time_t > > m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 44 of file EcalTPGBadStripHandler.h.

Constructor & Destructor Documentation

◆ EcalTPGBadStripHandler()

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

Definition at line 24 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.

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

◆ ~EcalTPGBadStripHandler()

popcon::EcalTPGBadStripHandler::~EcalTPGBadStripHandler ( )
override

Definition at line 40 of file EcalTPGBadStripHandler.cc.

40 {}

Member Function Documentation

◆ getNewObjects()

void popcon::EcalTPGBadStripHandler::getNewObjects ( )
overridevirtual

Implements popcon::PopConSourceHandler< EcalTPGStripStatus >.

Definition at line 42 of file EcalTPGBadStripHandler.cc.

References gather_cfg::cout, writedatasetfile::dataset, MillePedeFileConverter_cfg::e, test_db_connect::econn, cppFunctionSkipper::exception, Exception, FEConfigMainInfo::getBstId(), RunTPGConfigDat::getConfigTag(), RunList::getRuns(), FEConfigBadStripDat::getStatus(), FEConfigBadStripDat::getStripId(), FEConfigBadStripDat::getTCCId(), FEConfigBadStripDat::getTTId(), RunTPGConfigDat::getVersion(), test_db_connect::my_locdef, test_db_connect::my_rundef, EgHLTOffHistBins_cfi::nr, AlCaHLTBitMon_ParallelJobs::p, l1tpf_impl::readFromFile(), IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigBadStripInfo::setId(), RunTag::setLocationDef(), RunTag::setRunTypeDef(), EcalTPGStripStatus::setValue(), FEConfigMainInfo::setVersion(), str, AlCaHLTBitMon_QueryRunRegistry::string, and dumpRecoGeometry_cfg::tagInfo.

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

◆ id()

std::string popcon::EcalTPGBadStripHandler::id ( ) const
inlineoverridevirtual

Implements popcon::PopConSourceHandler< EcalTPGStripStatus >.

Definition at line 53 of file EcalTPGBadStripHandler.h.

References m_name.

53 { return m_name; }

◆ makeTTEEDetId()

std::map<std::string, int> popcon::EcalTPGBadStripHandler::makeTTEEDetId ( )

◆ readFromFile()

void popcon::EcalTPGBadStripHandler::readFromFile ( const char *  inputFile)

Definition at line 273 of file EcalTPGBadStripHandler.cc.

References dtResolutionTest_cfi::inputFile, mps_splice::line, str, and cond::impl::to_string().

273  {
274  //-------------------------------------------------------------
275 
276  m_i_tag = "";
277  m_i_version = 0;
278  m_i_run_number = 0;
279  m_i_badStrip = 0;
280 
281  FILE* inpFile; // input file
282  inpFile = fopen(inputFile, "r");
283  if (!inpFile) {
284  edm::LogError("EcalTPGBadStripHandler") << "*** Can not open file: " << inputFile;
285  return;
286  }
287 
288  char line[256];
289 
290  std::ostringstream str;
291 
292  fgets(line, 255, inpFile);
294  str << "gen tag " << m_i_tag << std::endl; // should I use this?
295 
296  fgets(line, 255, inpFile);
297  m_i_version = atoi(line);
298  str << "version= " << m_i_version << std::endl;
299 
300  fgets(line, 255, inpFile);
301  m_i_run_number = atoi(line);
302  str << "run_number= " << m_i_run_number << std::endl;
303 
304  fgets(line, 255, inpFile);
305  m_i_badStrip = atoi(line);
306  str << "badTT_config= " << m_i_badStrip << std::endl;
307 
308  fclose(inpFile); // close inp. file
309 }
Log< level::Error, false > LogError
std::string to_string(char value[])
#define str(s)

◆ to_string()

std::string popcon::EcalTPGBadStripHandler::to_string ( char  value[])
inlineprivate

Definition at line 61 of file EcalTPGBadStripHandler.h.

References relativeConstraints::value.

61  {
62  std::ostringstream streamOut;
63  streamOut << value;
64  return streamOut.str();
65  }

◆ writeFile()

void popcon::EcalTPGBadStripHandler::writeFile ( const char *  inputFile)

Definition at line 311 of file EcalTPGBadStripHandler.cc.

References dtResolutionTest_cfi::inputFile.

311  {
312  //-------------------------------------------------------------
313 
314  std::ofstream myfile;
315  myfile.open(inputFile);
316  myfile << m_i_tag << std::endl;
317  myfile << m_i_version << std::endl;
318  myfile << m_i_run_number << std::endl;
319  myfile << m_i_badStrip << std::endl;
320 
321  myfile.close();
322 }

Member Data Documentation

◆ econn

EcalCondDBInterface* popcon::EcalTPGBadStripHandler::econn

Definition at line 58 of file EcalTPGBadStripHandler.h.

◆ m_firstRun

unsigned int popcon::EcalTPGBadStripHandler::m_firstRun
private

Definition at line 69 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

◆ m_gentag

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

Definition at line 74 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

◆ m_i_badStrip

int popcon::EcalTPGBadStripHandler::m_i_badStrip
private

Definition at line 85 of file EcalTPGBadStripHandler.h.

◆ m_i_run_number

unsigned int popcon::EcalTPGBadStripHandler::m_i_run_number
private

Definition at line 84 of file EcalTPGBadStripHandler.h.

◆ m_i_tag

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

Definition at line 82 of file EcalTPGBadStripHandler.h.

◆ m_i_version

int popcon::EcalTPGBadStripHandler::m_i_version
private

Definition at line 83 of file EcalTPGBadStripHandler.h.

◆ m_lastRun

unsigned int popcon::EcalTPGBadStripHandler::m_lastRun
private

Definition at line 70 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

◆ m_location

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

Definition at line 73 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

◆ m_locationsource

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

Definition at line 78 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

◆ m_name

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

Definition at line 79 of file EcalTPGBadStripHandler.h.

Referenced by id().

◆ m_pass

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

Definition at line 77 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

◆ m_runnr

unsigned int popcon::EcalTPGBadStripHandler::m_runnr
private

Definition at line 80 of file EcalTPGBadStripHandler.h.

◆ m_runtype

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

Definition at line 81 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

◆ m_sid

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

Definition at line 75 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

◆ m_user

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

Definition at line 76 of file EcalTPGBadStripHandler.h.

Referenced by EcalTPGBadStripHandler().

◆ mapDetEEId

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

Definition at line 71 of file EcalTPGBadStripHandler.h.

◆ mystripStat

const EcalTPGStripStatus* popcon::EcalTPGBadStripHandler::mystripStat
private

Definition at line 67 of file EcalTPGBadStripHandler.h.