CMS 3D CMS Logo

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

#include <EcalTPGLutIdMapHandler.h>

Inheritance diagram for popcon::EcalTPGLutIdMapHandler:
popcon::PopConSourceHandler< EcalTPGLutIdMap >

Public Member Functions

 EcalTPGLutIdMapHandler (edm::ParameterSet const &)
 
void getNewObjects () override
 
std::string id () const override
 
void readFromFile (const char *inputFile)
 
void writeFile (const char *inputFile)
 
 ~EcalTPGLutIdMapHandler () override
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalTPGLutIdMap >
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_lutIdMap
 
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
 
const EcalTPGLutIdMapmypedestals
 

Additional Inherited Members

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

Detailed Description

Definition at line 44 of file EcalTPGLutIdMapHandler.h.

Constructor & Destructor Documentation

◆ EcalTPGLutIdMapHandler()

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

Definition at line 23 of file EcalTPGLutIdMapHandler.cc.

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

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

◆ ~EcalTPGLutIdMapHandler()

popcon::EcalTPGLutIdMapHandler::~EcalTPGLutIdMapHandler ( )
override

Definition at line 39 of file EcalTPGLutIdMapHandler.cc.

39 {}

Member Function Documentation

◆ getNewObjects()

void popcon::EcalTPGLutIdMapHandler::getNewObjects ( )
overridevirtual

Implements popcon::PopConSourceHandler< EcalTPGLutIdMap >.

Definition at line 41 of file EcalTPGLutIdMapHandler.cc.

References gather_cfg::cout, writedatasetfile::dataset, MillePedeFileConverter_cfg::e, test_db_connect::econn, cppFunctionSkipper::exception, Exception, RunTPGConfigDat::getConfigTag(), FEConfigLUTGroupDat::getLUTGroupId(), FEConfigMainInfo::getLUTId(), FEConfigLUTGroupDat::getLUTValue(), RunList::getRuns(), RunTPGConfigDat::getVersion(), test_db_connect::my_locdef, test_db_connect::my_rundef, EgHLTOffHistBins_cfi::nr, AlCaHLTBitMon_ParallelJobs::p, IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigLUTInfo::setId(), RunTag::setLocationDef(), EcalTPGLut::setLut(), RunTag::setRunTypeDef(), EcalTPGLutIdMap::setValue(), FEConfigMainInfo::setVersion(), findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, and dumpRecoGeometry_cfg::tagInfo.

41  {
42  edm::LogInfo("EcalTPGLutIdMapHandler") << "Started GetNewObjects!!!";
43 
44  //check whats already inside of database
45  if (tagInfo().size) {
46  //check whats already inside of database
47  std::cout << "got offlineInfo = " << std::endl;
48  std::cout << "tag name = " << tagInfo().name << std::endl;
49  std::cout << "size = " << tagInfo().size << std::endl;
50  } else {
51  std::cout << " First object for this tag " << std::endl;
52  }
53 
54  unsigned int max_since = 0;
55  max_since = static_cast<unsigned int>(tagInfo().lastInterval.since);
56  edm::LogInfo("EcalTPGLutIdMapHandler") << "max_since : " << max_since;
57  edm::LogInfo("EcalTPGLutIdMapHandler") << "retrieved last payload ";
58 
59  // here we retrieve all the runs after the last from online DB
60  edm::LogInfo("EcalTPGLutIdMapHandler") << "Retrieving run list from ONLINE DB ... ";
61 
62  edm::LogInfo("EcalTPGLutIdMapHandler") << "Making connection...";
64  edm::LogInfo("EcalTPGLutIdMapHandler") << "Done.";
65 
66  if (!econn) {
67  std::cout << " connection parameters " << m_sid << "/" << m_user << std::endl;
68  // cerr << e.what() << std::endl;
69  throw cms::Exception("OMDS not available");
70  }
71 
73  my_locdef.setLocation(m_location);
74 
76  my_rundef.setRunType(m_runtype);
77 
78  RunTag my_runtag;
79  my_runtag.setLocationDef(my_locdef);
80  my_runtag.setRunTypeDef(my_rundef);
81  my_runtag.setGeneralTag(m_gentag);
82 
83  readFromFile("last_tpg_lutIdMap_settings.txt");
84 
85  unsigned int min_run;
86 
87  if (m_firstRun < m_i_run_number) {
88  min_run = m_i_run_number + 1;
89  } else {
90  min_run = m_firstRun;
91  }
92 
93  if (min_run < max_since) {
94  min_run = max_since + 1; // we have to add 1 to the last transferred one
95  }
96 
97  std::cout << "m_i_run_number" << m_i_run_number << "m_firstRun " << m_firstRun << "max_since " << max_since
98  << std::endl;
99 
100  unsigned int max_run = m_lastRun;
101  edm::LogInfo("EcalTPGLutIdMapHandler") << "min_run= " << min_run << "max_run= " << max_run;
102 
103  RunList my_list;
104  my_list = econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
105  // my_list=econn->fetchRunListByLocation(my_runtag,min_run,max_run,my_locdef);
106 
107  std::vector<RunIOV> run_vec = my_list.getRuns();
108  size_t num_runs = run_vec.size();
109 
110  std::cout << "number of runs is : " << num_runs << std::endl;
111 
112  unsigned int irun;
113  if (num_runs > 0) {
114  for (size_t kr = 0; kr < run_vec.size(); kr++) {
115  irun = static_cast<unsigned int>(run_vec[kr].getRunNumber());
116 
117  std::cout << " **************** " << std::endl;
118  std::cout << " **************** " << std::endl;
119  std::cout << " run= " << irun << std::endl;
120 
121  // retrieve the data :
122  std::map<EcalLogicID, RunTPGConfigDat> dataset;
123  econn->fetchDataSet(&dataset, &run_vec[kr]);
124 
125  std::string the_config_tag = "";
126  int the_config_version = 0;
127 
128  std::map<EcalLogicID, RunTPGConfigDat>::const_iterator it;
129 
130  int nr = 0;
131  for (it = dataset.begin(); it != dataset.end(); it++) {
132  ++nr;
133  EcalLogicID ecalid = it->first;
134  RunTPGConfigDat dat = it->second;
135  the_config_tag = dat.getConfigTag();
136  the_config_version = dat.getVersion();
137  }
138 
139  // it is all the same for all SM... get the last one
140 
141  std::cout << " run= " << irun << " tag " << the_config_tag << " version=" << the_config_version << std::endl;
142 
143  // here we should check if it is the same as previous run.
144 
145  if ((the_config_tag != m_i_tag || the_config_version != m_i_version) && nr > 0) {
146  std::cout << "the tag is different from last transferred run ... retrieving last config set from DB"
147  << std::endl;
148 
149  FEConfigMainInfo fe_main_info;
150  fe_main_info.setConfigTag(the_config_tag);
151  fe_main_info.setVersion(the_config_version);
152 
153  try {
154  std::cout << " before fetch config set" << std::endl;
155  econn->fetchConfigSet(&fe_main_info);
156  std::cout << " after fetch config set" << std::endl;
157 
158  // now get TPGLutIdMap
159  int lutId = fe_main_info.getLUTId();
160 
161  if (lutId != m_i_lutIdMap) {
162  FEConfigLUTInfo fe_lut_info;
163  fe_lut_info.setId(lutId);
164  econn->fetchConfigSet(&fe_lut_info);
165  std::map<EcalLogicID, FEConfigLUTGroupDat> dataset_TpgLut;
166 
167  econn->fetchDataSet(&dataset_TpgLut, &fe_lut_info);
168  edm::LogInfo("EcalTPGLutIdMapHandler") << "Got object!";
169 
170  EcalTPGLutIdMap* lutMap = new EcalTPGLutIdMap;
171 
172  typedef std::map<EcalLogicID, FEConfigLUTGroupDat>::const_iterator CIfelut;
173  EcalLogicID ecid_xt;
174  FEConfigLUTGroupDat rd_lut;
175  int igroups = 0;
176 
177  for (CIfelut p = dataset_TpgLut.begin(); p != dataset_TpgLut.end(); p++) {
178  ecid_xt = p->first;
179  rd_lut = p->second;
180 
181  //std::string ecid_name=ecid_xt.getName();
182 
183  unsigned int lutArray[1024];
184  for (int ilut = 0; ilut < 1024; ++ilut) {
185  lutArray[ilut] = rd_lut.getLUTValue(ilut);
186  std::cout << ilut << " " << rd_lut.getLUTValue(ilut) << std::endl;
187  }
188 
189  EcalTPGLut mylut;
190  mylut.setLut(lutArray);
191  lutMap->setValue(rd_lut.getLUTGroupId(), mylut);
192  ++igroups;
193  }
194 
195  Time_t snc = (Time_t)irun;
196  m_to_transfer.push_back(std::make_pair((EcalTPGLutIdMap*)lutMap, snc));
197 
198  m_i_run_number = irun;
199  m_i_tag = the_config_tag;
200  m_i_version = the_config_version;
201  m_i_lutIdMap = lutId;
202 
203  writeFile("last_tpg_lutIdMap_settings.txt");
204 
205  } else {
206  m_i_run_number = irun;
207  m_i_tag = the_config_tag;
208  m_i_version = the_config_version;
209 
210  writeFile("last_tpg_lutIdMap_settings.txt");
211 
212  std::cout << " even if the tag/version is not the same, the lutIdMap id is the same -> no transfer needed "
213  << std::endl;
214  }
215 
216  }
217 
218  catch (std::exception& e) {
219  std::cout << "ERROR: THIS CONFIG DOES NOT EXIST: tag=" << the_config_tag << " version=" << the_config_version
220  << std::endl;
221  std::cout << e.what() << std::endl;
222  m_i_run_number = irun;
223  }
224  std::cout << " **************** " << std::endl;
225 
226  } else if (nr == 0) {
227  m_i_run_number = irun;
228  std::cout << " no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed " << std::endl;
229  std::cout << " **************** " << std::endl;
230  } else {
231  m_i_run_number = irun;
232  m_i_tag = the_config_tag;
233  m_i_version = the_config_version;
234  std::cout << " the tag/version is the same -> no transfer needed " << std::endl;
235  std::cout << " **************** " << std::endl;
236  writeFile("last_tpg_lutIdMap_settings.txt");
237  }
238  }
239  }
240 
241  delete econn;
242 
243  edm::LogInfo("EcalTPGLutIdMapHandler") << "Ecal - > end of getNewObjects -----------";
244 }
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 getLUTValue(int i) const
Iov_t lastInterval
Definition: Types.h:73
void writeFile(const char *inputFile)
Definition: RunTag.h:13
Time_t since
Definition: Types.h:53
size_t size
Definition: Types.h:74
int getVersion() const
void fetchConfigSet(ICONF *iconf) noexcept(false)
void setVersion(int id)
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov) noexcept(false)
void setLut(const unsigned int *lut)
Definition: EcalTPGLut.cc:15
std::string name
Definition: Types.h:72
std::vector< std::pair< EcalTPGLutIdMap *, Time_t > > m_to_transfer
void setValue(const uint32_t &id, const EcalTPGLut &value)
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
int getLUTId() const
void setGeneralTag(std::string tag)
Definition: RunTag.cc:24
void setId(int id)

◆ id()

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

Implements popcon::PopConSourceHandler< EcalTPGLutIdMap >.

Definition at line 51 of file EcalTPGLutIdMapHandler.h.

References m_name.

51 { return m_name; }

◆ readFromFile()

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

Definition at line 246 of file EcalTPGLutIdMapHandler.cc.

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

246  {
247  //-------------------------------------------------------------
248 
249  m_i_tag = "";
250  m_i_version = 0;
251  m_i_run_number = 0;
252  m_i_lutIdMap = 0;
253 
254  FILE* inpFile; // input file
255  inpFile = fopen(inputFile, "r");
256  if (!inpFile) {
257  edm::LogError("EcalTPGLutIdMapHandler") << "*** Can not open file: " << inputFile;
258  return;
259  }
260 
261  char line[256];
262 
263  std::ostringstream str;
264 
265  fgets(line, 255, inpFile);
267  str << "gen tag " << m_i_tag << std::endl; // should I use this?
268 
269  fgets(line, 255, inpFile);
270  m_i_version = atoi(line);
271  str << "version= " << m_i_version << std::endl;
272 
273  fgets(line, 255, inpFile);
274  m_i_run_number = atoi(line);
275  str << "run_number= " << m_i_run_number << std::endl;
276 
277  fgets(line, 255, inpFile);
278  m_i_lutIdMap = atoi(line);
279  str << "lutIdMap_config= " << m_i_lutIdMap << std::endl;
280 
281  fclose(inpFile); // close inp. file
282 }
std::string to_string(char value[])
Log< level::Error, false > LogError
#define str(s)

◆ to_string()

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

Definition at line 59 of file EcalTPGLutIdMapHandler.h.

References relativeConstraints::value.

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

◆ writeFile()

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

Definition at line 284 of file EcalTPGLutIdMapHandler.cc.

References makeListRunsInFiles::inputFile.

284  {
285  //-------------------------------------------------------------
286 
287  std::ofstream myfile;
288  myfile.open(inputFile);
289  myfile << m_i_tag << std::endl;
290  myfile << m_i_version << std::endl;
291  myfile << m_i_run_number << std::endl;
292  myfile << m_i_lutIdMap << std::endl;
293 
294  myfile.close();
295 }

Member Data Documentation

◆ econn

EcalCondDBInterface* popcon::EcalTPGLutIdMapHandler::econn

Definition at line 56 of file EcalTPGLutIdMapHandler.h.

◆ m_firstRun

unsigned int popcon::EcalTPGLutIdMapHandler::m_firstRun
private

Definition at line 67 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler().

◆ m_gentag

std::string popcon::EcalTPGLutIdMapHandler::m_gentag
private

Definition at line 71 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler().

◆ m_i_lutIdMap

int popcon::EcalTPGLutIdMapHandler::m_i_lutIdMap
private

Definition at line 82 of file EcalTPGLutIdMapHandler.h.

◆ m_i_run_number

unsigned int popcon::EcalTPGLutIdMapHandler::m_i_run_number
private

Definition at line 81 of file EcalTPGLutIdMapHandler.h.

◆ m_i_tag

std::string popcon::EcalTPGLutIdMapHandler::m_i_tag
private

Definition at line 79 of file EcalTPGLutIdMapHandler.h.

◆ m_i_version

int popcon::EcalTPGLutIdMapHandler::m_i_version
private

Definition at line 80 of file EcalTPGLutIdMapHandler.h.

◆ m_lastRun

unsigned int popcon::EcalTPGLutIdMapHandler::m_lastRun
private

Definition at line 68 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler().

◆ m_location

std::string popcon::EcalTPGLutIdMapHandler::m_location
private

Definition at line 70 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler().

◆ m_locationsource

std::string popcon::EcalTPGLutIdMapHandler::m_locationsource
private

Definition at line 75 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler().

◆ m_name

std::string popcon::EcalTPGLutIdMapHandler::m_name
private

Definition at line 76 of file EcalTPGLutIdMapHandler.h.

Referenced by id().

◆ m_pass

std::string popcon::EcalTPGLutIdMapHandler::m_pass
private

Definition at line 74 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler().

◆ m_runnr

unsigned int popcon::EcalTPGLutIdMapHandler::m_runnr
private

Definition at line 77 of file EcalTPGLutIdMapHandler.h.

◆ m_runtype

std::string popcon::EcalTPGLutIdMapHandler::m_runtype
private

Definition at line 78 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler().

◆ m_sid

std::string popcon::EcalTPGLutIdMapHandler::m_sid
private

Definition at line 72 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler().

◆ m_user

std::string popcon::EcalTPGLutIdMapHandler::m_user
private

Definition at line 73 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler().

◆ mypedestals

const EcalTPGLutIdMap* popcon::EcalTPGLutIdMapHandler::mypedestals
private

Definition at line 65 of file EcalTPGLutIdMapHandler.h.