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 ()
 
std::string id () const
 
void readFromFile (const char *inputFile)
 
void writeFile (const char *inputFile)
 
 ~EcalTPGLutIdMapHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalTPGLutIdMap >
void convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
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 ()
 
void sort ()
 
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::vector< Triplet > Container
 
typedef std::vector< std::pair< EcalTPGLutIdMap *, cond::Time_t > > OldContainer
 
typedef PopConSourceHandler< EcalTPGLutIdMapself
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef EcalTPGLutIdMap value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< EcalTPGLutIdMap >
int add (value_type *payload, Summary *summary, Time_t time)
 
cond::persistency::SessiondbSession () const
 
- Protected Attributes inherited from popcon::PopConSourceHandler< EcalTPGLutIdMap >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 49 of file EcalTPGLutIdMapHandler.h.

Constructor & Destructor Documentation

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

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

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

Definition at line 43 of file EcalTPGLutIdMapHandler.cc.

44 {
45 }

Member Function Documentation

void popcon::EcalTPGLutIdMapHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalTPGLutIdMap >.

Definition at line 48 of file EcalTPGLutIdMapHandler.cc.

References gather_cfg::cout, createfilelist::dataset, MillePedeFileConverter_cfg::e, econn, cppFunctionSkipper::exception, Exception, EcalCondDBInterface::fetchDataSet(), EcalCondDBInterface::fetchGlobalRunListByLocation(), RunTPGConfigDat::getConfigTag(), FEConfigLUTGroupDat::getLUTGroupId(), FEConfigMainInfo::getLUTId(), FEConfigLUTGroupDat::getLUTValue(), RunList::getRuns(), RunTPGConfigDat::getVersion(), cond::TagInfo_t::lastInterval, m_firstRun, m_gentag, m_i_lutIdMap, m_i_run_number, m_i_tag, m_i_version, m_lastRun, m_location, m_pass, m_runtype, m_sid, popcon::PopConSourceHandler< EcalTPGLutIdMap >::m_to_transfer, m_user, cond::TagInfo_t::name, AlCaHLTBitMon_ParallelJobs::p, readFromFile(), IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigLUTInfo::setId(), LocationDef::setLocation(), RunTag::setLocationDef(), EcalTPGLut::setLut(), RunTypeDef::setRunType(), RunTag::setRunTypeDef(), EcalTPGLutIdMap::setValue(), FEConfigMainInfo::setVersion(), cond::TagInfo_t::size, findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, popcon::PopConSourceHandler< EcalTPGLutIdMap >::tagInfo(), and writeFile().

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

Definition at line 272 of file EcalTPGLutIdMapHandler.cc.

References analyzePatCleaning_cfg::inputFile, geometryCSVtoXML::line, m_i_lutIdMap, m_i_run_number, m_i_tag, m_i_version, harvestTrackValidationPlots::str, and to_string().

Referenced by getNewObjects().

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

Definition at line 67 of file EcalTPGLutIdMapHandler.h.

References relativeConstraints::value.

Referenced by readFromFile().

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

Definition at line 312 of file EcalTPGLutIdMapHandler.cc.

References m_i_lutIdMap, m_i_run_number, m_i_tag, and m_i_version.

Referenced by getNewObjects(), and Vispa.Main.TabController.TabController::save().

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

Member Data Documentation

EcalCondDBInterface* popcon::EcalTPGLutIdMapHandler::econn

Definition at line 64 of file EcalTPGLutIdMapHandler.h.

Referenced by getNewObjects().

unsigned int popcon::EcalTPGLutIdMapHandler::m_firstRun
private

Definition at line 75 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler(), and getNewObjects().

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

Definition at line 79 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler(), and getNewObjects().

int popcon::EcalTPGLutIdMapHandler::m_i_lutIdMap
private

Definition at line 90 of file EcalTPGLutIdMapHandler.h.

Referenced by getNewObjects(), readFromFile(), and writeFile().

unsigned int popcon::EcalTPGLutIdMapHandler::m_i_run_number
private

Definition at line 89 of file EcalTPGLutIdMapHandler.h.

Referenced by getNewObjects(), readFromFile(), and writeFile().

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

Definition at line 87 of file EcalTPGLutIdMapHandler.h.

Referenced by getNewObjects(), readFromFile(), and writeFile().

int popcon::EcalTPGLutIdMapHandler::m_i_version
private

Definition at line 88 of file EcalTPGLutIdMapHandler.h.

Referenced by getNewObjects(), readFromFile(), and writeFile().

unsigned int popcon::EcalTPGLutIdMapHandler::m_lastRun
private

Definition at line 76 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler(), and getNewObjects().

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

Definition at line 78 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler(), and getNewObjects().

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

Definition at line 83 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler().

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

Definition at line 84 of file EcalTPGLutIdMapHandler.h.

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

Definition at line 82 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler(), and getNewObjects().

unsigned int popcon::EcalTPGLutIdMapHandler::m_runnr
private

Definition at line 85 of file EcalTPGLutIdMapHandler.h.

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

Definition at line 86 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler(), and getNewObjects().

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

Definition at line 80 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler(), and getNewObjects().

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

Definition at line 81 of file EcalTPGLutIdMapHandler.h.

Referenced by EcalTPGLutIdMapHandler(), and getNewObjects().

const EcalTPGLutIdMap* popcon::EcalTPGLutIdMapHandler::mypedestals
private

Definition at line 73 of file EcalTPGLutIdMapHandler.h.