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

#include <EcalTPGFineGrainEBIdMapHandler.h>

Inheritance diagram for popcon::EcalTPGFineGrainEBIdMapHandler:
popcon::PopConSourceHandler< EcalTPGFineGrainEBIdMap >

Public Member Functions

 EcalTPGFineGrainEBIdMapHandler (edm::ParameterSet const &)
 
void getNewObjects ()
 
std::string id () const
 
void readFromFile (const char *inputFile)
 
void writeFile (const char *inputFile)
 
 ~EcalTPGFineGrainEBIdMapHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalTPGFineGrainEBIdMap >
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_fgrIdMap
 
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 EcalTPGFineGrainEBIdMapmypedestals
 

Additional Inherited Members

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

Detailed Description

Definition at line 49 of file EcalTPGFineGrainEBIdMapHandler.h.

Constructor & Destructor Documentation

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

Definition at line 22 of file EcalTPGFineGrainEBIdMapHandler.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.

23  : m_name(ps.getUntrackedParameter<std::string>("name","EcalTPGFineGrainEBIdMapHandler")) {
24 
25  edm::LogInfo("EcalTPGFineGrainEBIdMapHandler") << "EcalTPGFineGrainEBIdMap Source handler constructor.";
26  m_firstRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("firstRun").c_str()));
27  m_lastRun=static_cast<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("EcalTPGFineGrainEBIdMapHandler") << m_sid<<"/"<<m_user<<"/"<<m_location<<"/"<<m_gentag;
37 }
popcon::EcalTPGFineGrainEBIdMapHandler::~EcalTPGFineGrainEBIdMapHandler ( )

Definition at line 39 of file EcalTPGFineGrainEBIdMapHandler.cc.

40 {
41 }

Member Function Documentation

void popcon::EcalTPGFineGrainEBIdMapHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalTPGFineGrainEBIdMap >.

Definition at line 44 of file EcalTPGFineGrainEBIdMapHandler.cc.

References gather_cfg::cout, dat, dataset::dataset, alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, f, RunTPGConfigDat::getConfigTag(), FEConfigFgrGroupDat::getFgrGroupId(), FEConfigMainInfo::getFgrId(), FEConfigFgrGroupDat::getLUTValue(), EcalLogicID::getName(), FEConfigFgrGroupDat::getRatioHigh(), FEConfigFgrGroupDat::getRatioLow(), RunList::getRuns(), FEConfigFgrGroupDat::getThreshHigh(), FEConfigFgrGroupDat::getThreshLow(), RunTPGConfigDat::getVersion(), AlCaHLTBitMon_ParallelJobs::p, IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigFgrInfo::setId(), LocationDef::setLocation(), RunTag::setLocationDef(), RunTypeDef::setRunType(), RunTag::setRunTypeDef(), EcalTPGFineGrainEBIdMap::setValue(), EcalTPGFineGrainConstEB::setValues(), FEConfigMainInfo::setVersion(), findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, and dumpRecoGeometry_cfg::tagInfo.

45 {
46 
47  edm::LogInfo("EcalTPGFineGrainEBIdMapHandler") << "Started GetNewObjects!!!";
48 
49  //check whats already inside of database
50  if (tagInfo().size){
51  //check whats already inside of database
52  std::cout << "got offlineInfo = " << std::endl;
53  std::cout << "tag name = " << tagInfo().name << std::endl;
54  std::cout << "size = " << tagInfo().size << std::endl;
55  } else {
56  std::cout << " First object for this tag " << std::endl;
57  }
58 
59 
60  unsigned int max_since=0;
61  max_since=static_cast<unsigned int>(tagInfo().lastInterval.first);
62  edm::LogInfo("EcalTPGFineGrainEBIdMapHandler") << "max_since : " << max_since;
63  Ref fgrIdMap_db = lastPayload();
64 
65  edm::LogInfo("EcalTPGFineGrainEBIdMapHandler") << "retrieved last payload ";
66 
67  edm::LogInfo("EcalTPGFineGrainEBIdMapHandler") <<"WOW: we just retrieved the last valid record from DB ";
68 
69 
70  // here we retrieve all the runs after the last from online DB
71 
72  edm::LogInfo("EcalTPGFineGrainEBIdMapHandler") << "Retrieving run list from ONLINE DB ... ";
73 
74  edm::LogInfo("EcalTPGFineGrainEBIdMapHandler") << "Making connection...";
76  edm::LogInfo("EcalTPGFineGrainEBIdMapHandler") << "Done.";
77 
78  if (!econn)
79  {
80  std::cout << " connection parameters " <<m_sid <<"/"<<m_user<<std::endl;
81  // cerr << e.what() << std::endl;
82  throw cms::Exception("OMDS not available");
83  }
84 
85 
86  LocationDef my_locdef;
87  my_locdef.setLocation(m_location);
88 
89  RunTypeDef my_rundef;
90  my_rundef.setRunType(m_runtype);
91 
92  RunTag my_runtag;
93  my_runtag.setLocationDef( my_locdef );
94  my_runtag.setRunTypeDef( my_rundef );
95  my_runtag.setGeneralTag(m_gentag);
96 
97  readFromFile("last_tpg_fgrIdMap_settings.txt");
98 
99 
100  unsigned int min_run=m_i_run_number+1;
101 
103  min_run=m_i_run_number+1;
104  } else {
105  min_run=m_firstRun;
106  }
107  if(min_run<max_since) {
108  min_run=max_since+1; // we have to add 1 to the last transferred one
109  }
110 
111  std::cout<<"m_i_run_number"<< m_i_run_number <<"m_firstRun "<<m_firstRun<< "max_since " <<max_since<< std::endl;
112 
113  unsigned int max_run=m_lastRun;
114  edm::LogInfo("EcalTPGFineGrainEBIdMapHandler") << "min_run= " << min_run << "max_run= " << max_run;
115 
116  RunList my_list;
117  my_list=econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
118  // my_list=econn->fetchRunListByLocation(my_runtag,min_run,max_run,my_locdef);
119  printf ("after fetchRunList\n");fflush(stdout);
120 
121  std::vector<RunIOV> run_vec= my_list.getRuns();
122  size_t num_runs=run_vec.size();
123 
124  std::cout <<"number of runs is : "<< num_runs<< std::endl;
125 
126  unsigned int irun;
127  if(num_runs>0){
128 
129  for(size_t kr=0; kr<run_vec.size(); kr++){
130 
131  irun=static_cast<unsigned int>(run_vec[kr].getRunNumber());
132 
133  std::cout<<" **************** "<<std::endl;
134  std::cout<<" **************** "<<std::endl;
135  std::cout<<" run= "<<irun<<std::endl;
136 
137  // retrieve the data :
138  std::map<EcalLogicID, RunTPGConfigDat> dataset;
139  econn->fetchDataSet(&dataset, &run_vec[kr]);
140 
141  std::string the_config_tag="";
142  int the_config_version=0;
143 
144  std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
145 
146  int nr=0;
147  for( it=dataset.begin(); it!=dataset.end(); it++ )
148  {
149  ++nr;
150  EcalLogicID ecalid = it->first;
151  RunTPGConfigDat dat = it->second;
152  the_config_tag=dat.getConfigTag();
153  the_config_version=dat.getVersion();
154  }
155 
156  // it is all the same for all SM... get the last one
157 
158 
159  std::cout<<" run= "<<irun<<" tag "<<the_config_tag<<" version="<<the_config_version <<std::endl;
160 
161  // here we should check if it is the same as previous run.
162 
163 
164  if((the_config_tag != m_i_tag || the_config_version != m_i_version ) && nr>0 ) {
165  std::cout<<"the tag is different from last transferred run ... retrieving last config set from DB"<<std::endl;
166 
167  FEConfigMainInfo fe_main_info;
168  fe_main_info.setConfigTag(the_config_tag);
169  fe_main_info.setVersion(the_config_version);
170 
171  try{
172  std::cout << " before fetch config set" << std::endl;
173  econn-> fetchConfigSet(&fe_main_info);
174  std::cout << " after fetch config set" << std::endl;
175 
176  // now get TPGFineGrainEBIdMap
177  int fgrId=fe_main_info.getFgrId();
178  if( fgrId != m_i_fgrIdMap ) {
179 
180  FEConfigFgrInfo fe_fgr_info;
181  fe_fgr_info.setId(fgrId);
182  econn-> fetchConfigSet(&fe_fgr_info);
183  std::map<EcalLogicID, FEConfigFgrGroupDat> dataset_TpgFineGrainEB;
184  econn->fetchDataSet(&dataset_TpgFineGrainEB, &fe_fgr_info);
185  edm::LogInfo("EcalTPGFineGrainEBIdMapHandler") << "Got object!";
187  typedef std::map<EcalLogicID, FEConfigFgrGroupDat>::const_iterator CIfefgr;
188  EcalLogicID ecid_xt;
189  FEConfigFgrGroupDat rd_fgr;
190 
191  int igroups=0;
192  for (CIfefgr p = dataset_TpgFineGrainEB.begin(); p != dataset_TpgFineGrainEB.end(); p++)
193  {
194  ecid_xt = p->first;
195  rd_fgr = p->second;
196 
197  std::string ecid_name=ecid_xt.getName();
198 
200  unsigned int ThrL = (unsigned int)rd_fgr.getThreshLow();
201  unsigned int ThrH = (unsigned int)rd_fgr.getThreshHigh();
202  unsigned int RatioL = (unsigned int)rd_fgr.getRatioLow();
203  unsigned int RatioH = (unsigned int)rd_fgr.getRatioHigh();
204  unsigned int LutConfId = (unsigned int)rd_fgr.getLUTValue();
205  // I have exchanged the values to see if it works
206  f.setValues(RatioL,RatioH, ThrL,ThrH,LutConfId);
207  fgrMap->setValue(rd_fgr.getFgrGroupId(),f);
208  ++igroups;
209  }
210 
211  Time_t snc= (Time_t) irun ;
212  m_to_transfer.push_back(std::make_pair((EcalTPGFineGrainEBIdMap*)fgrMap,snc));
213 
214  m_i_run_number=irun;
215  m_i_tag=the_config_tag;
216  m_i_version=the_config_version;
217  m_i_fgrIdMap=fgrId;
218 
219  writeFile("last_tpg_fgrIdMap_settings.txt");
220 
221  } else {
222 
223  m_i_run_number=irun;
224  m_i_tag=the_config_tag;
225  m_i_version=the_config_version;
226 
227  writeFile("last_tpg_fgrIdMap_settings.txt");
228 
229  std::cout<< " even if the tag/version is not the same, the fgrIdMap is the same -> no transfer needed "<< std::endl;
230 
231  }
232 
233  }
234 
235  catch (std::exception &e) {
236  std::cout << "ERROR: THIS CONFIG DOES NOT EXIST: tag=" <<the_config_tag
237  <<" version="<<the_config_version<< std::endl;
238  std::cout << e.what() << std::endl;
239  m_i_run_number=irun;
240 
241  }
242  std::cout<<" **************** "<<std::endl;
243 
244  } else if(nr==0) {
245  m_i_run_number=irun;
246  std::cout<< " no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed "<< std::endl;
247  std::cout<<" **************** "<<std::endl;
248  } else {
249  m_i_run_number=irun;
250  m_i_tag=the_config_tag;
251  m_i_version=the_config_version;
252  std::cout<< " the tag/version is the same -> no transfer needed "<< std::endl;
253  std::cout<<" **************** "<<std::endl;
254  writeFile("last_tpg_fgrIdMap_settings.txt");
255  }
256 
257  }
258  }
259 
260  delete econn;
261  edm::LogInfo("EcalTPGFineGrainEBIdMapHandler") << "Ecal - > end of getNewObjects -----------";
262 }
void setRunTypeDef(const RunTypeDef &runTypeDef)
Definition: RunTag.cc:70
void setValue(const uint32_t &id, const EcalTPGFineGrainConstEB &value)
std::vector< RunIOV > getRuns()
Definition: RunList.cc:35
std::string getConfigTag() const
int getVersion() const
Definition: RunTag.h:13
void setValues(const uint32_t &ThresholdETLow, const uint32_t &ThresholdETHigh, const uint32_t &RatioLow, const uint32_t &RatioHigh, const uint32_t &LUT)
size_t size
Definition: Types.h:72
void setVersion(int id)
std::string name
Definition: Types.h:68
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)
float getRatioLow() const
double f[11][100]
void setLocationDef(const LocationDef &locDef)
Definition: RunTag.cc:53
void setId(int id)
float getThreshLow() const
float getRatioHigh() const
int getFgrId() const
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:33
tuple dataset
Definition: dataset.py:400
static std::vector< std::string > checklist dat
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
float getThreshHigh() const
void setGeneralTag(std::string tag)
Definition: RunTag.cc:36
tuple size
Write out results.
std::string popcon::EcalTPGFineGrainEBIdMapHandler::id ( void  ) const
inlinevirtual
void popcon::EcalTPGFineGrainEBIdMapHandler::readFromFile ( const char *  inputFile)

Definition at line 264 of file EcalTPGFineGrainEBIdMapHandler.cc.

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

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

Definition at line 66 of file EcalTPGFineGrainEBIdMapHandler.h.

References relativeConstraints::value.

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

Definition at line 303 of file EcalTPGFineGrainEBIdMapHandler.cc.

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

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

Member Data Documentation

EcalCondDBInterface* popcon::EcalTPGFineGrainEBIdMapHandler::econn

Definition at line 63 of file EcalTPGFineGrainEBIdMapHandler.h.

unsigned int popcon::EcalTPGFineGrainEBIdMapHandler::m_firstRun
private

Definition at line 74 of file EcalTPGFineGrainEBIdMapHandler.h.

Referenced by EcalTPGFineGrainEBIdMapHandler().

std::string popcon::EcalTPGFineGrainEBIdMapHandler::m_gentag
private

Definition at line 78 of file EcalTPGFineGrainEBIdMapHandler.h.

Referenced by EcalTPGFineGrainEBIdMapHandler().

int popcon::EcalTPGFineGrainEBIdMapHandler::m_i_fgrIdMap
private

Definition at line 89 of file EcalTPGFineGrainEBIdMapHandler.h.

unsigned int popcon::EcalTPGFineGrainEBIdMapHandler::m_i_run_number
private

Definition at line 88 of file EcalTPGFineGrainEBIdMapHandler.h.

std::string popcon::EcalTPGFineGrainEBIdMapHandler::m_i_tag
private

Definition at line 86 of file EcalTPGFineGrainEBIdMapHandler.h.

int popcon::EcalTPGFineGrainEBIdMapHandler::m_i_version
private

Definition at line 87 of file EcalTPGFineGrainEBIdMapHandler.h.

unsigned int popcon::EcalTPGFineGrainEBIdMapHandler::m_lastRun
private

Definition at line 75 of file EcalTPGFineGrainEBIdMapHandler.h.

Referenced by EcalTPGFineGrainEBIdMapHandler().

std::string popcon::EcalTPGFineGrainEBIdMapHandler::m_location
private

Definition at line 77 of file EcalTPGFineGrainEBIdMapHandler.h.

Referenced by EcalTPGFineGrainEBIdMapHandler().

std::string popcon::EcalTPGFineGrainEBIdMapHandler::m_locationsource
private

Definition at line 82 of file EcalTPGFineGrainEBIdMapHandler.h.

Referenced by EcalTPGFineGrainEBIdMapHandler().

std::string popcon::EcalTPGFineGrainEBIdMapHandler::m_name
private

Definition at line 83 of file EcalTPGFineGrainEBIdMapHandler.h.

Referenced by id().

std::string popcon::EcalTPGFineGrainEBIdMapHandler::m_pass
private

Definition at line 81 of file EcalTPGFineGrainEBIdMapHandler.h.

Referenced by EcalTPGFineGrainEBIdMapHandler().

unsigned int popcon::EcalTPGFineGrainEBIdMapHandler::m_runnr
private

Definition at line 84 of file EcalTPGFineGrainEBIdMapHandler.h.

std::string popcon::EcalTPGFineGrainEBIdMapHandler::m_runtype
private

Definition at line 85 of file EcalTPGFineGrainEBIdMapHandler.h.

Referenced by EcalTPGFineGrainEBIdMapHandler().

std::string popcon::EcalTPGFineGrainEBIdMapHandler::m_sid
private

Definition at line 79 of file EcalTPGFineGrainEBIdMapHandler.h.

Referenced by EcalTPGFineGrainEBIdMapHandler().

std::string popcon::EcalTPGFineGrainEBIdMapHandler::m_user
private

Definition at line 80 of file EcalTPGFineGrainEBIdMapHandler.h.

Referenced by EcalTPGFineGrainEBIdMapHandler().

const EcalTPGFineGrainEBIdMap* popcon::EcalTPGFineGrainEBIdMapHandler::mypedestals
private

Definition at line 72 of file EcalTPGFineGrainEBIdMapHandler.h.