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

#include <EcalTPGWeightGroupHandler.h>

Inheritance diagram for popcon::EcalTPGWeightGroupHandler:
popcon::PopConSourceHandler< EcalTPGWeightGroup >

Public Member Functions

 EcalTPGWeightGroupHandler (edm::ParameterSet const &)
 
void getNewObjects ()
 
std::string id () const
 
std::map< std::string, int > makeStripId ()
 
void readFromFile (const char *inputFile)
 
void writeFile (const char *inputFile)
 
 ~EcalTPGWeightGroupHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalTPGWeightGroup >
void convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
void initialize (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry const & logDBEntry () const
 
std::pair< Container const
*, std::string const > 
operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry 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

std::map< std::string, int > correspId
 
const EcalElectronicsMappingecalMapping_
 
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_weightGroup
 
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< EcalTPGWeightGroup >
typedef std::vector< TripletContainer
 
typedef std::vector< std::pair
< EcalTPGWeightGroup
*, cond::Time_t > > 
OldContainer
 
typedef PopConSourceHandler
< EcalTPGWeightGroup
self
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef EcalTPGWeightGroup value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< EcalTPGWeightGroup >
int add (value_type *payload, Summary *summary, Time_t time)
 
- Protected Attributes inherited from popcon::PopConSourceHandler< EcalTPGWeightGroup >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 51 of file EcalTPGWeightGroupHandler.h.

Constructor & Destructor Documentation

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

Definition at line 30 of file EcalTPGWeightGroupHandler.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","EcalTPGWeightGroupHandler")) {
32 
33  edm::LogInfo("EcalTPGWeightGroupHandler") << "EcalTPGWeightGroup Source handler constructor.";
34  m_firstRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("firstRun").c_str()));
35  m_lastRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("lastRun").c_str()));
36  m_sid= ps.getParameter<std::string>("OnlineDBSID");
37  m_user= ps.getParameter<std::string>("OnlineDBUser");
38  m_pass= ps.getParameter<std::string>("OnlineDBPassword");
39  m_locationsource= ps.getParameter<std::string>("LocationSource");
40  m_location=ps.getParameter<std::string>("Location");
41  m_gentag=ps.getParameter<std::string>("GenTag");
42  m_runtype=ps.getParameter<std::string>("RunType");
43 
44  edm::LogInfo("EcalTPGWeightGroupHandler") << m_sid<<"/"<<m_user<<"/"<<m_location<<"/"<<m_gentag;
45 }
popcon::EcalTPGWeightGroupHandler::~EcalTPGWeightGroupHandler ( )

Definition at line 47 of file EcalTPGWeightGroupHandler.cc.

48 {
49 }

Member Function Documentation

void popcon::EcalTPGWeightGroupHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalTPGWeightGroup >.

Definition at line 51 of file EcalTPGWeightGroupHandler.cc.

References gather_cfg::cout, dataset::dataset, alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, RunTPGConfigDat::getConfigTag(), EcalLogicID::getID1(), EcalLogicID::getID2(), EcalLogicID::getID3(), EcalLogicID::getName(), RunList::getRuns(), RunTPGConfigDat::getVersion(), FEConfigMainInfo::getWeiId(), python.multivaluedict::map(), AlCaHLTBitMon_ParallelJobs::p, IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigWeightInfo::setId(), LocationDef::setLocation(), RunTag::setLocationDef(), RunTypeDef::setRunType(), RunTag::setRunTypeDef(), EcalTPGGroups::setValue(), FEConfigMainInfo::setVersion(), findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, dumpRecoGeometry_cfg::tagInfo, and groupFilesInBlocks::tt.

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

Definition at line 324 of file EcalTPGWeightGroupHandler.cc.

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

324  {
325  //-------------------------------------------------------------
326 
327  m_i_tag="";
328  m_i_version=0;
329  m_i_run_number=0;
330  m_i_weightGroup=0;
331 
332  FILE *inpFile; // input file
333  inpFile = fopen(inputFile,"r");
334  if(!inpFile) {
335  edm::LogError("EcalTPGWeightGroupHandler")<<"*** Can not open file: "<<inputFile;
336  return;
337  }
338 
339  char line[256];
340 
341  std::ostringstream str;
342 
343  fgets(line,255,inpFile);
344  m_i_tag=to_string(line);
345  str << "gen tag " << m_i_tag << std::endl ; // should I use this?
346 
347  fgets(line,255,inpFile);
348  m_i_version=atoi(line);
349  str << "version= " << m_i_version << std::endl ;
350 
351  fgets(line,255,inpFile);
352  m_i_run_number=atoi(line);
353  str << "run_number= " << m_i_run_number << std::endl ;
354 
355  fgets(line,255,inpFile);
356  m_i_weightGroup=atoi(line);
357  str << "weightGroup_config= " << m_i_weightGroup << std::endl ;
358 
359 
360  fclose(inpFile); // close inp. file
361 
362 }
std::string popcon::EcalTPGWeightGroupHandler::to_string ( char  value[])
inlineprivate

Definition at line 70 of file EcalTPGWeightGroupHandler.h.

References relativeConstraints::value.

70  {
71  std::ostringstream streamOut;
72  streamOut << value;
73  return streamOut.str();
74  }
void popcon::EcalTPGWeightGroupHandler::writeFile ( const char *  inputFile)

Definition at line 364 of file EcalTPGWeightGroupHandler.cc.

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

364  {
365  //-------------------------------------------------------------
366 
367 
368  std::ofstream myfile;
369  myfile.open (inputFile);
370  myfile << m_i_tag <<std::endl;
371  myfile << m_i_version <<std::endl;
372  myfile << m_i_run_number <<std::endl;
373  myfile << m_i_weightGroup <<std::endl;
374 
375  myfile.close();
376 
377 }

Member Data Documentation

std::map<std::string, int> popcon::EcalTPGWeightGroupHandler::correspId
private

Definition at line 79 of file EcalTPGWeightGroupHandler.h.

const EcalElectronicsMapping* popcon::EcalTPGWeightGroupHandler::ecalMapping_
private

Definition at line 81 of file EcalTPGWeightGroupHandler.h.

EcalCondDBInterface* popcon::EcalTPGWeightGroupHandler::econn

Definition at line 67 of file EcalTPGWeightGroupHandler.h.

unsigned int popcon::EcalTPGWeightGroupHandler::m_firstRun
private

Definition at line 76 of file EcalTPGWeightGroupHandler.h.

Referenced by EcalTPGWeightGroupHandler().

std::string popcon::EcalTPGWeightGroupHandler::m_gentag
private

Definition at line 83 of file EcalTPGWeightGroupHandler.h.

Referenced by EcalTPGWeightGroupHandler().

unsigned int popcon::EcalTPGWeightGroupHandler::m_i_run_number
private

Definition at line 93 of file EcalTPGWeightGroupHandler.h.

std::string popcon::EcalTPGWeightGroupHandler::m_i_tag
private

Definition at line 91 of file EcalTPGWeightGroupHandler.h.

int popcon::EcalTPGWeightGroupHandler::m_i_version
private

Definition at line 92 of file EcalTPGWeightGroupHandler.h.

int popcon::EcalTPGWeightGroupHandler::m_i_weightGroup
private

Definition at line 94 of file EcalTPGWeightGroupHandler.h.

unsigned int popcon::EcalTPGWeightGroupHandler::m_lastRun
private

Definition at line 77 of file EcalTPGWeightGroupHandler.h.

Referenced by EcalTPGWeightGroupHandler().

std::string popcon::EcalTPGWeightGroupHandler::m_location
private

Definition at line 82 of file EcalTPGWeightGroupHandler.h.

Referenced by EcalTPGWeightGroupHandler().

std::string popcon::EcalTPGWeightGroupHandler::m_locationsource
private

Definition at line 87 of file EcalTPGWeightGroupHandler.h.

Referenced by EcalTPGWeightGroupHandler().

std::string popcon::EcalTPGWeightGroupHandler::m_name
private

Definition at line 88 of file EcalTPGWeightGroupHandler.h.

Referenced by id().

std::string popcon::EcalTPGWeightGroupHandler::m_pass
private

Definition at line 86 of file EcalTPGWeightGroupHandler.h.

Referenced by EcalTPGWeightGroupHandler().

unsigned int popcon::EcalTPGWeightGroupHandler::m_runnr
private

Definition at line 89 of file EcalTPGWeightGroupHandler.h.

std::string popcon::EcalTPGWeightGroupHandler::m_runtype
private

Definition at line 90 of file EcalTPGWeightGroupHandler.h.

Referenced by EcalTPGWeightGroupHandler().

std::string popcon::EcalTPGWeightGroupHandler::m_sid
private

Definition at line 84 of file EcalTPGWeightGroupHandler.h.

Referenced by EcalTPGWeightGroupHandler().

std::string popcon::EcalTPGWeightGroupHandler::m_user
private

Definition at line 85 of file EcalTPGWeightGroupHandler.h.

Referenced by EcalTPGWeightGroupHandler().