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

#include <EcalTPGSlidingWindowHandler.h>

Inheritance diagram for popcon::EcalTPGSlidingWindowHandler:
popcon::PopConSourceHandler< EcalTPGSlidingWindow >

Public Member Functions

 EcalTPGSlidingWindowHandler (edm::ParameterSet const &)
 
void getNewObjects ()
 
std::string id () const
 
std::map< std::string, int > makeStripIdEB ()
 
std::map< std::string, int > makeStripIdEE ()
 
void readFromFile (const char *inputFile)
 
void writeFile (const char *inputFile)
 
 ~EcalTPGSlidingWindowHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalTPGSlidingWindow >
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 > correspEBId
 
std::map< std::string, int > correspEEId
 
unsigned int m_firstRun
 
std::string m_gentag
 
unsigned int m_i_run_number
 
int m_i_sliding
 
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
 

Additional Inherited Members

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

Detailed Description

Definition at line 51 of file EcalTPGSlidingWindowHandler.h.

Constructor & Destructor Documentation

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

Definition at line 33 of file EcalTPGSlidingWindowHandler.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.

34  : m_name(ps.getUntrackedParameter<std::string>("name","EcalTPGSlidingWindowHandler")) {
35 
36  edm::LogInfo("EcalTPGSlidingWindowHandler") << "EcalTPGSlidingWindow Source handler constructor";
37  m_firstRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("firstRun").c_str()));
38  m_lastRun=static_cast<unsigned int>(atoi( ps.getParameter<std::string>("lastRun").c_str()));
39  m_sid= ps.getParameter<std::string>("OnlineDBSID");
40  m_user= ps.getParameter<std::string>("OnlineDBUser");
41  m_pass= ps.getParameter<std::string>("OnlineDBPassword");
42  m_locationsource= ps.getParameter<std::string>("LocationSource");
43  m_location=ps.getParameter<std::string>("Location");
44  m_gentag=ps.getParameter<std::string>("GenTag");
45  m_runtype=ps.getParameter<std::string>("RunType");
46 
47  edm::LogInfo("EcalTPGSlidingWindowHandler") << m_sid<<"/"<<m_user<<"/"<<m_location<<"/"<<m_gentag;
48 
49 
50 }
popcon::EcalTPGSlidingWindowHandler::~EcalTPGSlidingWindowHandler ( )

Definition at line 52 of file EcalTPGSlidingWindowHandler.cc.

53 {
54 }

Member Function Documentation

void popcon::EcalTPGSlidingWindowHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalTPGSlidingWindow >.

Definition at line 56 of file EcalTPGSlidingWindowHandler.cc.

References gather_cfg::cout, dataset::dataset, alignCSCRings::e, cppFunctionSkipper::exception, Exception, RunTPGConfigDat::getConfigTag(), EcalLogicID::getID1(), EcalLogicID::getID2(), EcalLogicID::getID3(), EcalLogicID::getName(), RunList::getRuns(), FEConfigSlidingDat::getSliding(), FEConfigMainInfo::getSliId(), RunTPGConfigDat::getVersion(), AlCaHLTBitMon_ParallelJobs::p, IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigSlidingInfo::setId(), LocationDef::setLocation(), RunTag::setLocationDef(), RunTypeDef::setRunType(), RunTag::setRunTypeDef(), EcalTPGSlidingWindow::setValue(), FEConfigMainInfo::setVersion(), findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, dumpRecoGeometry_cfg::tagInfo, and groupFilesInBlocks::tt.

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

Definition at line 329 of file EcalTPGSlidingWindowHandler.cc.

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

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

Definition at line 71 of file EcalTPGSlidingWindowHandler.h.

References relativeConstraints::value.

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

Definition at line 369 of file EcalTPGSlidingWindowHandler.cc.

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

369  {
370  //-------------------------------------------------------------
371 
372 
373  std::ofstream myfile;
374  myfile.open (inputFile);
375  myfile << m_i_tag <<std::endl;
376  myfile << m_i_version <<std::endl;
377  myfile << m_i_run_number <<std::endl;
378  myfile << m_i_sliding <<std::endl;
379 
380  myfile.close();
381 
382 }

Member Data Documentation

std::map<std::string, int> popcon::EcalTPGSlidingWindowHandler::correspEBId
private

Definition at line 79 of file EcalTPGSlidingWindowHandler.h.

std::map<std::string, int> popcon::EcalTPGSlidingWindowHandler::correspEEId
private

Definition at line 80 of file EcalTPGSlidingWindowHandler.h.

EcalCondDBInterface* popcon::EcalTPGSlidingWindowHandler::econn

Definition at line 68 of file EcalTPGSlidingWindowHandler.h.

unsigned int popcon::EcalTPGSlidingWindowHandler::m_firstRun
private

Definition at line 77 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().

std::string popcon::EcalTPGSlidingWindowHandler::m_gentag
private

Definition at line 83 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().

unsigned int popcon::EcalTPGSlidingWindowHandler::m_i_run_number
private

Definition at line 93 of file EcalTPGSlidingWindowHandler.h.

int popcon::EcalTPGSlidingWindowHandler::m_i_sliding
private

Definition at line 94 of file EcalTPGSlidingWindowHandler.h.

std::string popcon::EcalTPGSlidingWindowHandler::m_i_tag
private

Definition at line 91 of file EcalTPGSlidingWindowHandler.h.

int popcon::EcalTPGSlidingWindowHandler::m_i_version
private

Definition at line 92 of file EcalTPGSlidingWindowHandler.h.

unsigned int popcon::EcalTPGSlidingWindowHandler::m_lastRun
private

Definition at line 78 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().

std::string popcon::EcalTPGSlidingWindowHandler::m_location
private

Definition at line 82 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().

std::string popcon::EcalTPGSlidingWindowHandler::m_locationsource
private

Definition at line 87 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().

std::string popcon::EcalTPGSlidingWindowHandler::m_name
private

Definition at line 88 of file EcalTPGSlidingWindowHandler.h.

Referenced by id().

std::string popcon::EcalTPGSlidingWindowHandler::m_pass
private

Definition at line 86 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().

unsigned int popcon::EcalTPGSlidingWindowHandler::m_runnr
private

Definition at line 89 of file EcalTPGSlidingWindowHandler.h.

std::string popcon::EcalTPGSlidingWindowHandler::m_runtype
private

Definition at line 90 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().

std::string popcon::EcalTPGSlidingWindowHandler::m_sid
private

Definition at line 84 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().

std::string popcon::EcalTPGSlidingWindowHandler::m_user
private

Definition at line 85 of file EcalTPGSlidingWindowHandler.h.

Referenced by EcalTPGSlidingWindowHandler().