CMS 3D CMS Logo

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

#include <EcalTPGSlidingWindowHandler.h>

Inheritance diagram for popcon::EcalTPGSlidingWindowHandler:
popcon::PopConSourceHandler< EcalTPGSlidingWindow >

Public Member Functions

 EcalTPGSlidingWindowHandler (edm::ParameterSet const &)
 
void getNewObjects () override
 
std::string id () const override
 
std::map< std::string, int > makeStripIdEB ()
 
std::map< std::string, int > makeStripIdEE ()
 
void readFromFile (const char *inputFile)
 
void writeFile (const char *inputFile)
 
 ~EcalTPGSlidingWindowHandler () override
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalTPGSlidingWindow >
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

std::map< std::string, int > correspEBId
 
std::map< std::string, int > correspEEId
 
unsigned int m_firstRun
 
std::string m_gentag
 
unsigned int m_i_run_number
 
int m_i_sliding
 
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
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< EcalTPGSlidingWindow >
typedef std::map< Time_t, std::shared_ptr< EcalTPGSlidingWindow > > Container
 
typedef std::unique_ptr< EcalTPGSlidingWindowRef
 
typedef PopConSourceHandler< EcalTPGSlidingWindowself
 
typedef cond::Time_t Time_t
 
typedef EcalTPGSlidingWindow value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< EcalTPGSlidingWindow >
cond::persistency::SessiondbSession () const
 
- Protected Attributes inherited from popcon::PopConSourceHandler< EcalTPGSlidingWindow >
Container m_iovs
 
std::vector< std::pair< EcalTPGSlidingWindow *, Time_t > > m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 46 of file EcalTPGSlidingWindowHandler.h.

Constructor & Destructor Documentation

◆ EcalTPGSlidingWindowHandler()

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

Definition at line 30 of file EcalTPGSlidingWindowHandler.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.

31  : m_name(ps.getUntrackedParameter<std::string>("name", "EcalTPGSlidingWindowHandler")) {
32  edm::LogInfo("EcalTPGSlidingWindowHandler") << "EcalTPGSlidingWindow Source handler constructor";
33  m_firstRun = static_cast<unsigned int>(atoi(ps.getParameter<std::string>("firstRun").c_str()));
34  m_lastRun = static_cast<unsigned int>(atoi(ps.getParameter<std::string>("lastRun").c_str()));
35  m_sid = ps.getParameter<std::string>("OnlineDBSID");
36  m_user = ps.getParameter<std::string>("OnlineDBUser");
37  m_pass = ps.getParameter<std::string>("OnlineDBPassword");
38  m_locationsource = ps.getParameter<std::string>("LocationSource");
39  m_location = ps.getParameter<std::string>("Location");
40  m_gentag = ps.getParameter<std::string>("GenTag");
41  m_runtype = ps.getParameter<std::string>("RunType");
42 
43  edm::LogInfo("EcalTPGSlidingWindowHandler") << m_sid << "/" << m_user << "/" << m_location << "/" << m_gentag;
44 }
Log< level::Info, false > LogInfo

◆ ~EcalTPGSlidingWindowHandler()

popcon::EcalTPGSlidingWindowHandler::~EcalTPGSlidingWindowHandler ( )
override

Definition at line 46 of file EcalTPGSlidingWindowHandler.cc.

46 {}

Member Function Documentation

◆ getNewObjects()

void popcon::EcalTPGSlidingWindowHandler::getNewObjects ( )
overridevirtual

Implements popcon::PopConSourceHandler< EcalTPGSlidingWindow >.

Definition at line 48 of file EcalTPGSlidingWindowHandler.cc.

References gather_cfg::cout, writedatasetfile::dataset, MillePedeFileConverter_cfg::e, test_db_connect::econn, cppFunctionSkipper::exception, Exception, RunTPGConfigDat::getConfigTag(), EcalLogicID::getID1(), EcalLogicID::getID2(), EcalLogicID::getID3(), EcalLogicID::getName(), RunList::getRuns(), FEConfigSlidingDat::getSliding(), FEConfigMainInfo::getSliId(), RunTPGConfigDat::getVersion(), globals_cff::id1, globals_cff::id2, test_db_connect::my_locdef, test_db_connect::my_rundef, EgHLTOffHistBins_cfi::nr, AlCaHLTBitMon_ParallelJobs::p, IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigSlidingInfo::setId(), RunTag::setLocationDef(), RunTag::setRunTypeDef(), EcalTPGSlidingWindow::setValue(), FEConfigMainInfo::setVersion(), findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, digitizers_cfi::strip, and dumpRecoGeometry_cfg::tagInfo.

48  {
49  edm::LogInfo("EcalTPGSlidingWindowHandler") << "Started GetNewObjects!!!";
50 
51  //check whats already inside of database
52  if (tagInfo().size) {
53  //check whats already inside of database
54  std::cout << "got offlineInfo = " << std::endl;
55  std::cout << "tag name = " << tagInfo().name << std::endl;
56  std::cout << "size = " << tagInfo().size << std::endl;
57  } else {
58  std::cout << " First object for this tag " << std::endl;
59  }
60 
61  unsigned int max_since = 0;
62  max_since = static_cast<unsigned int>(tagInfo().lastInterval.since);
63  edm::LogInfo("EcalTPGSlidingWindowHandler") << "max_since : " << max_since;
64  edm::LogInfo("EcalTPGSlidingWindowHandler") << "retrieved last payload ";
65 
66  // here we retrieve all the runs after the last from online DB
67 
68  edm::LogInfo("EcalTPGSlidingWindowHandler") << "Retrieving run list from ONLINE DB ... ";
69 
70  edm::LogInfo("EcalTPGSlidingWindowHandler") << "Making connection...";
72  edm::LogInfo("EcalTPGSlidingWindowHandler") << "Done.";
73 
74  if (!econn) {
75  std::cout << " connection parameters " << m_sid << "/" << m_user << std::endl;
76  throw cms::Exception("OMDS not available");
77  }
78 
80  my_locdef.setLocation(m_location);
81 
83  my_rundef.setRunType(m_runtype);
84 
85  RunTag my_runtag;
86  my_runtag.setLocationDef(my_locdef);
87  my_runtag.setRunTypeDef(my_rundef);
88  my_runtag.setGeneralTag(m_gentag);
89 
90  readFromFile("last_tpg_sliding_settings.txt");
91 
92  unsigned int min_run;
93  if (m_firstRun < m_i_run_number) {
94  min_run = m_i_run_number + 1; // we have to add 1 to the last transferred one
95  } else {
96  min_run = m_firstRun;
97  }
98 
99  if (min_run < max_since) {
100  min_run = max_since + 1; // we have to add 1 to the last transferred one
101  }
102 
103  std::cout << "m_i_run_number" << m_i_run_number << "m_firstRun " << m_firstRun << "max_since " << max_since
104  << std::endl;
105 
106  unsigned int max_run = m_lastRun;
107 
108  edm::LogInfo("EcalTPGSlidingWindowHandler") << "min_run= " << min_run << "max_run= " << max_run;
109 
110  RunList my_list;
111  my_list = econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
112  // my_list=econn->fetchRunListByLocation(my_runtag,min_run,max_run, my_locdef);
113 
114  std::vector<RunIOV> run_vec = my_list.getRuns();
115  size_t num_runs = run_vec.size();
116 
117  std::cout << "number of runs is : " << num_runs << std::endl;
118 
119  unsigned int irun = 0;
120  if (num_runs > 0) {
121  // going to query the ecal logic id
122  std::vector<EcalLogicID> my_StripEcalLogicId_EE;
123  my_StripEcalLogicId_EE =
124  econn->getEcalLogicIDSetOrdered("ECAL_readout_strip", 1, 1000, 1, 70, 0, 5, "EE_offline_stripid", 123);
125  std::cout << " GOT the logic ID for the EE trigger strips " << std::endl;
126 
127  for (size_t kr = 0; kr < run_vec.size(); kr++) {
128  irun = static_cast<unsigned int>(run_vec[kr].getRunNumber());
129 
130  std::cout << " **************** " << std::endl;
131  std::cout << " **************** " << std::endl;
132  std::cout << " run= " << irun << std::endl;
133 
134  // retrieve the data :
135  std::map<EcalLogicID, RunTPGConfigDat> dataset;
136  econn->fetchDataSet(&dataset, &run_vec[kr]);
137 
138  std::string the_config_tag = "";
139  int the_config_version = 0;
140 
141  std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
142  FEConfigMainInfo fe_main_info;
143 
144  int nr = 0;
145  for (it = dataset.begin(); it != dataset.end(); it++) {
146  ++nr;
147  //EcalLogicID ecalid = it->first;
148  RunTPGConfigDat dat = it->second;
149  the_config_tag = dat.getConfigTag();
150  the_config_version = dat.getVersion();
151  }
152 
153  // it is all the same for all SM... get the last one
154 
155  std::cout << " run= " << irun << " tag " << the_config_tag << " version=" << the_config_version << std::endl;
156 
157  // here we should check if it is the same as previous run.
158 
159  if ((the_config_tag != m_i_tag || the_config_version != m_i_version) && nr > 0) {
160  std::cout << "the tag is different from last transferred run ... retrieving last config set from DB"
161  << std::endl;
162 
163  FEConfigMainInfo fe_main_info;
164  fe_main_info.setConfigTag(the_config_tag);
165  fe_main_info.setVersion(the_config_version);
166 
167  try {
168  std::cout << " before fetch config set" << std::endl;
169  econn->fetchConfigSet(&fe_main_info);
170  std::cout << " after fetch config set" << std::endl;
171 
172  // now get TPGSlidingWindow
173  int slidingId = fe_main_info.getSliId();
174 
175  if (slidingId != m_i_sliding) {
176  FEConfigSlidingInfo fe_sli_info;
177  fe_sli_info.setId(slidingId);
178  econn->fetchConfigSet(&fe_sli_info);
179  std::map<EcalLogicID, FEConfigSlidingDat> dataset_TpgSli;
180  econn->fetchDataSet(&dataset_TpgSli, &fe_sli_info);
181 
183  typedef std::map<EcalLogicID, FEConfigSlidingDat>::const_iterator CIfesli;
184  EcalLogicID ecid_xt;
185  FEConfigSlidingDat rd_sli;
186  int icells = 0;
187 
188  for (CIfesli p = dataset_TpgSli.begin(); p != dataset_TpgSli.end(); p++) {
189  ecid_xt = p->first;
190  rd_sli = p->second;
191 
192  std::string ecid_name = ecid_xt.getName();
193 
194  // EB data
195  if (ecid_name == "EB_VFE") {
196  int sm = ecid_xt.getID1();
197  int tt = ecid_xt.getID2();
198  int strip = ecid_xt.getID3();
199  int tcc = sm + 54;
200  if (sm > 18)
201  tcc = sm + 18;
202 
203  // simple formula to calculate the Srip EB identifier
204 
205  unsigned int stripEBId = 303176 + (tt - 1) * 64 + (strip - 1) * 8 + (tcc - 37) * 8192;
206 
207  sliW->setValue(stripEBId, (unsigned int)rd_sli.getSliding());
208  ++icells;
209 
210  } else if (ecid_name == "ECAL_readout_strip") {
211  // EE data
212  int id1 = ecid_xt.getID1(); // dcc
213  int id2 = ecid_xt.getID2(); // ccu
214  int id3 = ecid_xt.getID3(); // strip
215 
216  bool set_the_strip = false;
217  int stripid;
218  for (size_t istrip = 0; istrip < my_StripEcalLogicId_EE.size(); istrip++) {
219  if (!set_the_strip) {
220  if (my_StripEcalLogicId_EE[istrip].getID1() == id1 &&
221  my_StripEcalLogicId_EE[istrip].getID2() == id2 &&
222  my_StripEcalLogicId_EE[istrip].getID3() == id3) {
223  stripid = my_StripEcalLogicId_EE[istrip].getLogicID();
224  set_the_strip = true;
225  break;
226  }
227  }
228  }
229 
230  if (set_the_strip) {
231  sliW->setValue(stripid, (unsigned int)rd_sli.getSliding());
232 
233  } else {
234  std::cout << " these may be the additional towers TCC/TT " << id1 << "/" << id2 << std::endl;
235  }
236 
237  ++icells;
238  }
239  }
240 
241  Time_t snc = (Time_t)irun;
242  m_to_transfer.push_back(std::make_pair((EcalTPGSlidingWindow*)sliW, snc));
243 
244  m_i_run_number = irun;
245  m_i_tag = the_config_tag;
246  m_i_version = the_config_version;
247  m_i_sliding = slidingId;
248 
249  writeFile("last_tpg_sliding_settings.txt");
250 
251  } else {
252  m_i_run_number = irun;
253  m_i_tag = the_config_tag;
254  m_i_version = the_config_version;
255 
256  writeFile("last_tpg_sliding_settings.txt");
257 
258  std::cout
259  << " even if the tag/version is not the same, the sliding windows id is the same -> no transfer needed "
260  << std::endl;
261  }
262  } catch (std::exception& e) {
263  std::cout << "ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag << " version=" << the_config_version
264  << std::endl;
265  std::cout << e.what() << std::endl;
266 
267  m_i_run_number = irun;
268  }
269 
270  std::cout << " **************** " << std::endl;
271 
272  } else if (nr == 0) {
273  m_i_run_number = irun;
274  std::cout << " no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
275  std::cout << " **************** " << std::endl;
276  } else {
277  m_i_run_number = irun;
278  m_i_tag = the_config_tag;
279  m_i_version = the_config_version;
280  std::cout << " the tag/version is the same -> no transfer needed " << std::endl;
281  std::cout << " **************** " << std::endl;
282  writeFile("last_tpg_sliding_settings.txt");
283  }
284  }
285  }
286 
287  delete econn;
288 
289  edm::LogInfo("EcalTPGSlidingWindowHandler") << "Ecal - > end of getNewObjects -----------";
290 }
size
Write out results.
void setRunTypeDef(const RunTypeDef &runTypeDef)
Definition: RunTag.cc:42
std::vector< RunIOV > getRuns()
Definition: RunList.cc:25
RunList fetchGlobalRunListByLocation(const RunTag &tag, int min_run, int max_run, const LocationDef &locDef) noexcept(false)
int getID1() const
Definition: EcalLogicID.cc:30
Iov_t lastInterval
Definition: Types.h:73
std::string getName() const
Definition: EcalLogicID.cc:26
Definition: RunTag.h:13
int getID2() const
Definition: EcalLogicID.cc:32
Time_t since
Definition: Types.h:53
size_t size
Definition: Types.h:74
int getVersion() const
float getSliding() const
void fetchConfigSet(ICONF *iconf) noexcept(false)
void setVersion(int id)
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov) noexcept(false)
std::string name
Definition: Types.h:72
Definition: TTTypes.h:54
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< EcalTPGSlidingWindow *, Time_t > > m_to_transfer
void setLocationDef(const LocationDef &locDef)
Definition: RunTag.cc:33
void setValue(const uint32_t &id, const uint32_t &value)
Log< level::Info, false > LogInfo
int getSliId() const
std::string getConfigTag() const
int getID3() const
Definition: EcalLogicID.cc:34
void setConfigTag(std::string x)
Definition: IODConfig.h:29
void setGeneralTag(std::string tag)
Definition: RunTag.cc:24

◆ id()

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

◆ makeStripIdEB()

std::map<std::string, int> popcon::EcalTPGSlidingWindowHandler::makeStripIdEB ( )

◆ makeStripIdEE()

std::map<std::string, int> popcon::EcalTPGSlidingWindowHandler::makeStripIdEE ( )

◆ readFromFile()

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

Definition at line 292 of file EcalTPGSlidingWindowHandler.cc.

References makeListRunsInFiles::inputFile, mps_splice::line, str, and to_string().

292  {
293  //-------------------------------------------------------------
294 
295  m_i_tag = "";
296  m_i_version = 0;
297  m_i_run_number = 0;
298  m_i_sliding = 0;
299 
300  FILE* inpFile; // input file
301  inpFile = fopen(inputFile, "r");
302  if (!inpFile) {
303  edm::LogError("EcalTPGSlidingWindowHandler") << "*** Can not open file: " << inputFile;
304  return;
305  }
306 
307  char line[256];
308 
309  std::ostringstream str;
310 
311  fgets(line, 255, inpFile);
313  str << "gen tag " << m_i_tag << std::endl; // should I use this?
314 
315  fgets(line, 255, inpFile);
316  m_i_version = atoi(line);
317  str << "version= " << m_i_version << std::endl;
318 
319  fgets(line, 255, inpFile);
320  m_i_run_number = atoi(line);
321  str << "run_number= " << m_i_run_number << std::endl;
322 
323  fgets(line, 255, inpFile);
324  m_i_sliding = atoi(line);
325  str << "sliding_config= " << m_i_sliding << std::endl;
326 
327  fclose(inpFile); // close inp. file
328 }
Log< level::Error, false > LogError
#define str(s)

◆ to_string()

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

Definition at line 63 of file EcalTPGSlidingWindowHandler.h.

References relativeConstraints::value.

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

◆ writeFile()

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

Definition at line 330 of file EcalTPGSlidingWindowHandler.cc.

References makeListRunsInFiles::inputFile.

330  {
331  //-------------------------------------------------------------
332 
333  std::ofstream myfile;
334  myfile.open(inputFile);
335  myfile << m_i_tag << std::endl;
336  myfile << m_i_version << std::endl;
337  myfile << m_i_run_number << std::endl;
338  myfile << m_i_sliding << std::endl;
339 
340  myfile.close();
341 }

Member Data Documentation

◆ correspEBId

std::map<std::string, int> popcon::EcalTPGSlidingWindowHandler::correspEBId
private

Definition at line 71 of file EcalTPGSlidingWindowHandler.h.

◆ correspEEId

std::map<std::string, int> popcon::EcalTPGSlidingWindowHandler::correspEEId
private

Definition at line 72 of file EcalTPGSlidingWindowHandler.h.

◆ econn

EcalCondDBInterface* popcon::EcalTPGSlidingWindowHandler::econn

Definition at line 60 of file EcalTPGSlidingWindowHandler.h.

◆ m_firstRun

unsigned int popcon::EcalTPGSlidingWindowHandler::m_firstRun
private

Definition at line 69 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().

◆ m_gentag

std::string popcon::EcalTPGSlidingWindowHandler::m_gentag
private

Definition at line 75 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().

◆ m_i_run_number

unsigned int popcon::EcalTPGSlidingWindowHandler::m_i_run_number
private

Definition at line 85 of file EcalTPGSlidingWindowHandler.h.

◆ m_i_sliding

int popcon::EcalTPGSlidingWindowHandler::m_i_sliding
private

Definition at line 86 of file EcalTPGSlidingWindowHandler.h.

◆ m_i_tag

std::string popcon::EcalTPGSlidingWindowHandler::m_i_tag
private

Definition at line 83 of file EcalTPGSlidingWindowHandler.h.

◆ m_i_version

int popcon::EcalTPGSlidingWindowHandler::m_i_version
private

Definition at line 84 of file EcalTPGSlidingWindowHandler.h.

◆ m_lastRun

unsigned int popcon::EcalTPGSlidingWindowHandler::m_lastRun
private

Definition at line 70 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().

◆ m_location

std::string popcon::EcalTPGSlidingWindowHandler::m_location
private

Definition at line 74 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().

◆ m_locationsource

std::string popcon::EcalTPGSlidingWindowHandler::m_locationsource
private

Definition at line 79 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().

◆ m_name

std::string popcon::EcalTPGSlidingWindowHandler::m_name
private

Definition at line 80 of file EcalTPGSlidingWindowHandler.h.

Referenced by id().

◆ m_pass

std::string popcon::EcalTPGSlidingWindowHandler::m_pass
private

Definition at line 78 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().

◆ m_runnr

unsigned int popcon::EcalTPGSlidingWindowHandler::m_runnr
private

Definition at line 81 of file EcalTPGSlidingWindowHandler.h.

◆ m_runtype

std::string popcon::EcalTPGSlidingWindowHandler::m_runtype
private

Definition at line 82 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().

◆ m_sid

std::string popcon::EcalTPGSlidingWindowHandler::m_sid
private

Definition at line 76 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().

◆ m_user

std::string popcon::EcalTPGSlidingWindowHandler::m_user
private

Definition at line 77 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().