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

#include <EcalTPGWeightIdMapHandler.h>

Inheritance diagram for popcon::EcalTPGWeightIdMapHandler:
popcon::PopConSourceHandler< EcalTPGWeightIdMap >

Public Member Functions

 EcalTPGWeightIdMapHandler (edm::ParameterSet const &)
 
void getNewObjects ()
 
std::string id () const
 
void readFromFile (const char *inputFile)
 
void writeFile (const char *inputFile)
 
 ~EcalTPGWeightIdMapHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalTPGWeightIdMap >
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
 
unsigned int m_i_run_number
 
std::string m_i_tag
 
int m_i_version
 
int m_i_weightIdMap
 
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 EcalTPGWeightIdMapmyweightIdMap
 

Additional Inherited Members

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

Detailed Description

Definition at line 49 of file EcalTPGWeightIdMapHandler.h.

Constructor & Destructor Documentation

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

Definition at line 24 of file EcalTPGWeightIdMapHandler.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","EcalTPGWeightIdMapHandler")) {
26 
27  edm::LogInfo("EcalTPGWeightIdMapHandler") << "EcalTPGWeightIdMap Source handler constructor";
28  m_firstRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("firstRun").c_str()));
29  m_lastRun=static_cast<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("EcalTPGWeightIdMapHandler") << m_sid<<"/"<<m_user<<"/"<<m_location<<"/"<<m_gentag;
39 
40 }
popcon::EcalTPGWeightIdMapHandler::~EcalTPGWeightIdMapHandler ( )

Definition at line 42 of file EcalTPGWeightIdMapHandler.cc.

43 {
44 }

Member Function Documentation

void popcon::EcalTPGWeightIdMapHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalTPGWeightIdMap >.

Definition at line 47 of file EcalTPGWeightIdMapHandler.cc.

References gather_cfg::cout, dataset::dataset, alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, RunTPGConfigDat::getConfigTag(), RunList::getRuns(), RunTPGConfigDat::getVersion(), FEConfigWeightGroupDat::getWeight0(), FEConfigWeightGroupDat::getWeight1(), FEConfigWeightGroupDat::getWeight2(), FEConfigWeightGroupDat::getWeight3(), FEConfigWeightGroupDat::getWeight4(), FEConfigWeightGroupDat::getWeightGroupId(), FEConfigMainInfo::getWeiId(), AlCaHLTBitMon_ParallelJobs::p, IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigWeightInfo::setId(), LocationDef::setLocation(), RunTag::setLocationDef(), RunTypeDef::setRunType(), RunTag::setRunTypeDef(), EcalTPGWeightIdMap::setValue(), EcalTPGWeights::setValues(), FEConfigMainInfo::setVersion(), findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, and w().

48 {
49 
50  edm::LogInfo("EcalTPGWeightIdMapHandler") << "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("EcalTPGWeightIdMapHandler") << "max_since : " << max_since;
65  Ref weightIdMap_db = lastPayload();
66 
67  edm::LogInfo("EcalTPGWeightIdMapHandler") << "retrieved last payload ";
68 
69  // here we retrieve all the runs after the last from online DB
70  edm::LogInfo("EcalTPGWeightIdMapHandler") << "Retrieving run list from ONLINE DB ... ";
71 
72  edm::LogInfo("EcalTPGWeightIdMapHandler") << "Making connection...";
74  edm::LogInfo("EcalTPGWeightIdMapHandler") << "Done.";
75 
76  if (!econn)
77  {
78  std::cout << " connection parameters " <<m_sid <<"/"<<m_user<<std::endl;
79  // cerr << e.what() << std::endl;
80  throw cms::Exception("OMDS not available");
81  }
82 
83 
84  LocationDef my_locdef;
85  my_locdef.setLocation(m_location);
86 
87  RunTypeDef my_rundef;
88  my_rundef.setRunType(m_runtype);
89 
90  RunTag my_runtag;
91  my_runtag.setLocationDef( my_locdef );
92  my_runtag.setRunTypeDef( my_rundef );
93  my_runtag.setGeneralTag(m_gentag);
94 
95  readFromFile("last_tpg_weightIdMap_settings.txt");
96 
97 
98  unsigned int min_run=m_i_run_number+1;
99 
101  min_run=m_i_run_number+1;
102  } else {
103  min_run=m_firstRun;
104  }
105 
106  if(min_run<max_since) {
107  min_run=max_since+1; // we have to add 1 to the last transferred one
108  }
109 
110  std::cout<<"m_i_run_number"<< m_i_run_number <<"m_firstRun "<<m_firstRun<< "max_since " <<max_since<< std::endl;
111 
112  unsigned int max_run=m_lastRun;
113  edm::LogInfo("EcalTPGWeightIdMapHandler") << "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  edm::LogInfo("EcalTPGWeightIdMapHandler") << "number of Mon runs is : "<< num_runs;
122 
123  unsigned int irun;
124  if(num_runs>0){
125  for(size_t kr=0; kr<run_vec.size(); kr++){
126 
127  irun=static_cast<unsigned int>(run_vec[kr].getRunNumber());
128 
129  std::cout<<" **************** "<<std::endl;
130  std::cout<<" **************** "<<std::endl;
131  std::cout<<" run= "<<irun<<std::endl;
132 
133  // retrieve the data :
134  std::map<EcalLogicID, RunTPGConfigDat> dataset;
135  econn->fetchDataSet(&dataset, &run_vec[kr]);
136 
137  std::string the_config_tag="";
138  int the_config_version=0;
139 
140  std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
141 
142  int nr=0;
143  for( it=dataset.begin(); it!=dataset.end(); it++ )
144  {
145  ++nr;
146  //EcalLogicID ecalid = it->first;
147  RunTPGConfigDat dat = it->second;
148  the_config_tag=dat.getConfigTag();
149  the_config_version=dat.getVersion();
150  }
151 
152 
153  // it is all the same for all SM... get the last one
154 
155 
156  std::cout<<" run= "<<irun<<" tag "<<the_config_tag<<" version="<<the_config_version <<std::endl;
157 
158  // here we should check if it is the same as previous run.
159 
160 
161  if((the_config_tag != m_i_tag || the_config_version != m_i_version ) && nr>0 ) {
162  std::cout<<"the tag is different from last transferred run ... retrieving last config set from DB"<<std::endl;
163 
164  FEConfigMainInfo fe_main_info;
165  fe_main_info.setConfigTag(the_config_tag);
166  fe_main_info.setVersion(the_config_version);
167 
168  try{
169  std::cout << " before fetch config set" << std::endl;
170  econn-> fetchConfigSet(&fe_main_info);
171  std::cout << " after fetch config set" << std::endl;
172 
173 
174  // now get TPGWeightIdMap
175  int weightId=fe_main_info.getWeiId();
176 
177  if( weightId != m_i_weightIdMap ) {
178 
179  FEConfigWeightInfo fe_weight_info;
180  fe_weight_info.setId(weightId);
181  econn-> fetchConfigSet(&fe_weight_info);
182  std::map<EcalLogicID, FEConfigWeightGroupDat> dataset_TpgWeight;
183  econn->fetchDataSet(&dataset_TpgWeight, &fe_weight_info);
184  edm::LogInfo("EcalTPGWeightIdMapHandler") << "Got object!";
185  EcalTPGWeightIdMap* weightMap = new EcalTPGWeightIdMap;
186  typedef std::map<EcalLogicID, FEConfigWeightGroupDat>::const_iterator CIfeweight;
187  EcalLogicID ecid_xt;
189 
190  int igroups=0;
191  for (CIfeweight p = dataset_TpgWeight.begin(); p != dataset_TpgWeight.end(); p++) {
192 
193  rd_w = p->second;
194  // EB and EE data
195  EcalTPGWeights w;
196  unsigned int weight0 = static_cast<unsigned int>(rd_w.getWeight4());
197  unsigned int weight1 = static_cast<unsigned int>(rd_w.getWeight3());
198  unsigned int weight2 = static_cast<unsigned int>(rd_w.getWeight2());
199  unsigned int weight3 = static_cast<unsigned int>(rd_w.getWeight1()- 0x80);
200  unsigned int weight4 = static_cast<unsigned int>(rd_w.getWeight0());
201 
202  w.setValues(weight0,weight1,weight2,weight3,weight4);
203  weightMap->setValue(rd_w.getWeightGroupId(),w);
204 
205  ++igroups;
206  }
207 
208  edm::LogInfo("EcalTPGWeightIdMapHandler") << "found " << igroups << "Weight groups";
209 
210  Time_t snc= (Time_t) irun;
211  m_to_transfer.push_back(std::make_pair((EcalTPGWeightIdMap*)weightMap,snc));
212 
213  m_i_run_number=irun;
214  m_i_tag=the_config_tag;
215  m_i_version=the_config_version;
216  m_i_weightIdMap=weightId;
217 
218  writeFile("last_tpg_weightIdMap_settings.txt");
219 
220  } else {
221 
222  m_i_run_number=irun;
223  m_i_tag=the_config_tag;
224  m_i_version=the_config_version;
225 
226  writeFile("last_tpg_weightIdMap_settings.txt");
227 
228  std::cout<< " even if the tag/version is not the same, the weightIdMap id is the same -> no transfer needed "<< std::endl;
229 
230  }
231 
232  } catch (std::exception &e) {
233  std::cout << "ERROR: THIS CONFIG DOES NOT EXIST: tag=" <<the_config_tag
234  <<" version="<<the_config_version<< std::endl;
235  std::cout << e.what() << std::endl;
236  m_i_run_number=irun;
237 
238  }
239  std::cout<<" **************** "<<std::endl;
240 
241  } else if(nr==0) {
242  m_i_run_number=irun;
243  std::cout<< " no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed "<< std::endl;
244  std::cout<<" **************** "<<std::endl;
245  } else {
246  m_i_run_number=irun;
247  m_i_tag=the_config_tag;
248  m_i_version=the_config_version;
249  std::cout<< " the tag/version is the same -> no transfer needed "<< std::endl;
250  std::cout<<" **************** "<<std::endl;
251  writeFile("last_tpg_weightIdMap_settings.txt");
252  }
253 
254  }
255  }
256 
257  delete econn;
258 
259  edm::LogInfo("EcalTPGWeightIdMapHandler") << "Ecal - > end of getNewObjects -----------";
260 
261 }
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::string name
Definition: TagInfo.h:9
RunList fetchGlobalRunListByLocation(RunTag tag, int min_run, int max_run, const LocationDef locDef)
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov)
void setRunTypeDef(const RunTypeDef runTypeDef)
Definition: RunTag.cc:70
int getWeiId() const
size_t size
Definition: TagInfo.h:13
void setValue(const uint32_t &id, const EcalTPGWeights &value)
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:33
tuple dataset
Definition: dataset.py:393
void setConfigTag(std::string x)
Definition: IODConfig.h:31
cond::ValidityInterval lastInterval
Definition: TagInfo.h:11
void setLocation(std::string loc)
Definition: LocationDef.cc:33
tuple cout
Definition: gather_cfg.py:121
T w() const
void setGeneralTag(std::string tag)
Definition: RunTag.cc:36
void setValues(const uint32_t &w0, const uint32_t &w1, const uint32_t &w2, const uint32_t &w3, const uint32_t &w4)
tuple size
Write out results.
std::string popcon::EcalTPGWeightIdMapHandler::id ( void  ) const
inlinevirtual
void popcon::EcalTPGWeightIdMapHandler::readFromFile ( const char *  inputFile)

Definition at line 263 of file EcalTPGWeightIdMapHandler.cc.

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

263  {
264  //-------------------------------------------------------------
265 
266  m_i_tag="";
267  m_i_version=0;
268  m_i_run_number=0;
269  m_i_weightIdMap=0;
270 
271  FILE *inpFile; // input file
272  inpFile = fopen(inputFile,"r");
273  if(!inpFile) {
274  edm::LogError("EcalTPGWeightIdMapHandler")<<"*** Can not open file: "<<inputFile;
275  }
276 
277  char line[256];
278 
279  std::ostringstream str;
280 
281  fgets(line,255,inpFile);
282  m_i_tag=to_string(line);
283  str << "gen tag " << m_i_tag << std::endl ; // should I use this?
284 
285  fgets(line,255,inpFile);
286  m_i_version=atoi(line);
287  str << "version= " << m_i_version << std::endl ;
288 
289  fgets(line,255,inpFile);
290  m_i_run_number=atoi(line);
291  str << "run_number= " << m_i_run_number << std::endl ;
292 
293  fgets(line,255,inpFile);
294  m_i_weightIdMap=atoi(line);
295  str << "weightIdMap_config= " << m_i_weightIdMap << std::endl ;
296 
297 
298  fclose(inpFile); // close inp. file
299 
300 }
std::string popcon::EcalTPGWeightIdMapHandler::to_string ( char  value[])
inlineprivate

Definition at line 66 of file EcalTPGWeightIdMapHandler.h.

References relativeConstraints::value.

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

Definition at line 302 of file EcalTPGWeightIdMapHandler.cc.

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

302  {
303  //-------------------------------------------------------------
304 
305 
306  std::ofstream myfile;
307  myfile.open (inputFile);
308  myfile << m_i_tag <<std::endl;
309  myfile << m_i_version <<std::endl;
310  myfile << m_i_run_number <<std::endl;
311  myfile << m_i_weightIdMap <<std::endl;
312 
313  myfile.close();
314 
315 }

Member Data Documentation

EcalCondDBInterface* popcon::EcalTPGWeightIdMapHandler::econn

Definition at line 63 of file EcalTPGWeightIdMapHandler.h.

unsigned int popcon::EcalTPGWeightIdMapHandler::m_firstRun
private

Definition at line 74 of file EcalTPGWeightIdMapHandler.h.

Referenced by EcalTPGWeightIdMapHandler().

std::string popcon::EcalTPGWeightIdMapHandler::m_gentag
private

Definition at line 78 of file EcalTPGWeightIdMapHandler.h.

Referenced by EcalTPGWeightIdMapHandler().

unsigned int popcon::EcalTPGWeightIdMapHandler::m_i_run_number
private

Definition at line 88 of file EcalTPGWeightIdMapHandler.h.

std::string popcon::EcalTPGWeightIdMapHandler::m_i_tag
private

Definition at line 86 of file EcalTPGWeightIdMapHandler.h.

int popcon::EcalTPGWeightIdMapHandler::m_i_version
private

Definition at line 87 of file EcalTPGWeightIdMapHandler.h.

int popcon::EcalTPGWeightIdMapHandler::m_i_weightIdMap
private

Definition at line 89 of file EcalTPGWeightIdMapHandler.h.

unsigned int popcon::EcalTPGWeightIdMapHandler::m_lastRun
private

Definition at line 75 of file EcalTPGWeightIdMapHandler.h.

Referenced by EcalTPGWeightIdMapHandler().

std::string popcon::EcalTPGWeightIdMapHandler::m_location
private

Definition at line 77 of file EcalTPGWeightIdMapHandler.h.

Referenced by EcalTPGWeightIdMapHandler().

std::string popcon::EcalTPGWeightIdMapHandler::m_locationsource
private

Definition at line 82 of file EcalTPGWeightIdMapHandler.h.

Referenced by EcalTPGWeightIdMapHandler().

std::string popcon::EcalTPGWeightIdMapHandler::m_name
private

Definition at line 83 of file EcalTPGWeightIdMapHandler.h.

Referenced by id().

std::string popcon::EcalTPGWeightIdMapHandler::m_pass
private

Definition at line 81 of file EcalTPGWeightIdMapHandler.h.

Referenced by EcalTPGWeightIdMapHandler().

unsigned int popcon::EcalTPGWeightIdMapHandler::m_runnr
private

Definition at line 84 of file EcalTPGWeightIdMapHandler.h.

std::string popcon::EcalTPGWeightIdMapHandler::m_runtype
private

Definition at line 85 of file EcalTPGWeightIdMapHandler.h.

Referenced by EcalTPGWeightIdMapHandler().

std::string popcon::EcalTPGWeightIdMapHandler::m_sid
private

Definition at line 79 of file EcalTPGWeightIdMapHandler.h.

Referenced by EcalTPGWeightIdMapHandler().

std::string popcon::EcalTPGWeightIdMapHandler::m_user
private

Definition at line 80 of file EcalTPGWeightIdMapHandler.h.

Referenced by EcalTPGWeightIdMapHandler().

const EcalTPGWeightIdMap* popcon::EcalTPGWeightIdMapHandler::myweightIdMap
private

Definition at line 72 of file EcalTPGWeightIdMapHandler.h.