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

#include <EcalTPGLinConstHandler.h>

Inheritance diagram for popcon::EcalTPGLinConstHandler:
popcon::PopConSourceHandler< EcalTPGLinearizationConst >

Public Member Functions

 EcalTPGLinConstHandler (edm::ParameterSet const &)
 
void getNewObjects ()
 
std::string id () const
 
void readFromFile (const char *inputFile)
 
void writeFile (const char *inputFile)
 
 ~EcalTPGLinConstHandler ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< EcalTPGLinearizationConst >
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
 
int m_i_lin
 
unsigned int m_i_run_number
 
std::string m_i_tag
 
int m_i_version
 
unsigned int m_lastRun
 
const EcalTPGLinearizationConstm_linearizationConst
 
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< EcalTPGLinearizationConst >
typedef std::vector< TripletContainer
 
typedef std::vector< std::pair
< EcalTPGLinearizationConst
*, cond::Time_t > > 
OldContainer
 
typedef PopConSourceHandler
< EcalTPGLinearizationConst
self
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef EcalTPGLinearizationConst value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< EcalTPGLinearizationConst >
int add (value_type *payload, Summary *summary, Time_t time)
 
- Protected Attributes inherited from popcon::PopConSourceHandler< EcalTPGLinearizationConst >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 49 of file EcalTPGLinConstHandler.h.

Constructor & Destructor Documentation

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

Definition at line 24 of file EcalTPGLinConstHandler.cc.

References edm::ParameterSet::getParameter(), m_firstRun, m_gentag, m_lastRun, m_location, m_locationsource, m_pass, m_runtype, m_sid, and m_user.

25  : m_name(ps.getUntrackedParameter<std::string>("name","EcalTPGLinConstHandler")) {
26 
27  edm::LogInfo("EcalTPGLinConstHandler") << "EcalTPGLinConst 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("EcalTPGLinConstHandler") << m_sid <<"/"<<m_user<<"/"<<m_location<<"/"<<m_gentag;
39 }
popcon::EcalTPGLinConstHandler::~EcalTPGLinConstHandler ( )

Definition at line 41 of file EcalTPGLinConstHandler.cc.

42 {
43 }

Member Function Documentation

void popcon::EcalTPGLinConstHandler::getNewObjects ( )
virtual

Implements popcon::PopConSourceHandler< EcalTPGLinearizationConst >.

Definition at line 46 of file EcalTPGLinConstHandler.cc.

References gather_cfg::cout, dataset::dataset, alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, RunTPGConfigDat::getConfigTag(), EcalLogicID::getID1(), EcalLogicID::getID2(), EcalLogicID::getID3(), FEConfigMainInfo::getLinId(), FEConfigLinDat::getMultX1(), FEConfigLinDat::getMultX12(), FEConfigLinDat::getMultX6(), EcalLogicID::getName(), RunList::getRuns(), FEConfigLinDat::getShift1(), FEConfigLinDat::getShift12(), FEConfigLinDat::getShift6(), RunTPGConfigDat::getVersion(), EcalCondObjectContainer< T >::insert(), AlCaHLTBitMon_ParallelJobs::p, DetId::rawId(), IODConfig::setConfigTag(), RunTag::setGeneralTag(), FEConfigLinInfo::setId(), LocationDef::setLocation(), RunTag::setLocationDef(), RunTypeDef::setRunType(), RunTag::setRunTypeDef(), FEConfigMainInfo::setVersion(), findQualityFiles::size, EBDetId::SMCRYSTALMODE, x, EEDetId::XYMODE, detailsBasic3DVector::y, and detailsBasic3DVector::z.

47 {
48 
49  edm::LogInfo("EcalTPGLinConstHandler") << "Started getNewObjects";
50 
51  if (tagInfo().size){
52  //check whats already inside of database
53  std::cout << "got offlineInfo = " << std::endl;
54  std::cout << "tag name = " << tagInfo().name << std::endl;
55  std::cout << "size = " << tagInfo().size << std::endl;
56  } else {
57  std::cout << " First object for this tag " << std::endl;
58  }
59 
60  unsigned int max_since =0;
61  max_since=static_cast<unsigned int>(tagInfo().lastInterval.first);
62  edm::LogInfo("EcalTPGLinConstHandler") << "max_since = " << max_since;
63  edm::LogInfo("EcalTPGLinConstHandler")<< "Retrieved last payload ";
64 
65  // here we retrieve all the runs after the last from online DB
66  edm::LogInfo("EcalTPGLinConstHandler")<< "Retrieving run list from ONLINE DB ... " << std::endl;
67 
68  edm::LogInfo("EcalTPGLinConstHandler") << "Making connection..." << std::flush;
70  edm::LogInfo("EcalTPGLinConstHandler") << "Done." << std::endl;
71 
72  if (!econn)
73  {
74  std::cout << " connection parameters " <<m_sid <<"/"<<m_user<<std::endl;
75  // cerr << e.what() << std::endl;
76  throw cms::Exception("OMDS not available");
77  }
78 
79 
80  LocationDef my_locdef;
81  my_locdef.setLocation(m_location);
82 
83  RunTypeDef my_rundef;
84  my_rundef.setRunType(m_runtype);
85 
86  RunTag my_runtag;
87  my_runtag.setLocationDef( my_locdef );
88  my_runtag.setRunTypeDef( my_rundef );
89  my_runtag.setGeneralTag(m_gentag);
90 
91  readFromFile("last_tpg_lin_settings.txt");
92 
93 
94  unsigned int min_run=m_i_run_number+1;
95 
97  min_run=m_i_run_number+1; // we have to add 1 to the last transferred one
98  } else {
99  min_run=m_firstRun;
100  }
101 
102  if(min_run<max_since) {
103  min_run= max_since+1; // we have to add 1 to the last transferred one
104  }
105 
106  std::cout<<"m_i_run_number"<< m_i_run_number <<"m_firstRun "<<m_firstRun<< "max_since " <<max_since<< std::endl;
107 
108  unsigned int max_run=m_lastRun;
109  edm::LogInfo("EcalTPGLinConstHandler") << "min_run= " << min_run << "max_run = " << max_run;
110 
111  RunList my_list;
112  my_list=econn->fetchGlobalRunListByLocation(my_runtag, min_run, max_run, my_locdef);
113  // my_list=econn->fetchRunListByLocation(my_runtag, min_run, max_run, my_locdef);
114 
115  std::vector<RunIOV> run_vec= my_list.getRuns();
116  size_t num_runs=run_vec.size();
117 
118  std::cout <<"number of runs is : "<< num_runs<< std::endl;
119 
120  unsigned int irun=0;
121  if(num_runs>0){
122 
123  for(size_t kr=0; kr<run_vec.size(); kr++){
124 
125  irun=static_cast<unsigned int>(run_vec[kr].getRunNumber());
126  std::cout<<" **************** "<<std::endl;
127  std::cout<<" **************** "<<std::endl;
128  std::cout<<" run= "<<irun<<std::endl;
129 
130  // retrieve the data :
131  std::map<EcalLogicID, RunTPGConfigDat> dataset;
132  econn->fetchDataSet(&dataset, &run_vec[kr]);
133 
134  std::string the_config_tag="";
135  int the_config_version=0;
136 
137  std::map< EcalLogicID, RunTPGConfigDat>::const_iterator it;
138 
139  int nr=0;
140  for( it=dataset.begin(); it!=dataset.end(); it++ )
141  {
142  ++nr;
143  //EcalLogicID ecalid = it->first;
144 
145  RunTPGConfigDat dat = it->second;
146  the_config_tag=dat.getConfigTag();
147  the_config_version=dat.getVersion();
148  }
149 
150 
151  // it is all the same for all SM... get the last one
152 
153 
154  std::cout<<" run= "<<irun<<" tag "<<the_config_tag<<" version="<<the_config_version <<std::endl;
155 
156  // here we should check if it is the same as previous run.
157 
158 
159  if((the_config_tag != m_i_tag || the_config_version != m_i_version ) && nr>0 ) {
160  std::cout<<"the tag is different from last transferred run ... retrieving last config set from DB"<<std::endl;
161 
162  FEConfigMainInfo fe_main_info;
163  fe_main_info.setConfigTag(the_config_tag);
164  fe_main_info.setVersion(the_config_version);
165 
166  try{
167  std::cout << " before fetch config set" << std::endl;
168  econn-> fetchConfigSet(&fe_main_info);
169  std::cout << " after fetch config set" << std::endl;
170 
171 
172  // now get TPGLinConst
173  int linId=fe_main_info.getLinId();
174 
175  if( linId != m_i_lin ) {
176 
177  FEConfigLinInfo fe_lin_info;
178  fe_lin_info.setId(linId);
179  econn-> fetchConfigSet(&fe_lin_info);
180  std::map<EcalLogicID, FEConfigLinDat> dataset_TpgLin;
181  econn->fetchDataSet(&dataset_TpgLin, &fe_lin_info);
182 
184  typedef std::map<EcalLogicID, FEConfigLinDat>::const_iterator CIfelin;
185  EcalLogicID ecid_xt;
186  FEConfigLinDat rd_lin;
187  int icells=0;
188 
189  for (CIfelin p = dataset_TpgLin.begin(); p != dataset_TpgLin.end(); p++) {
190  ecid_xt = p->first;
191  rd_lin = p->second;
192  std::string ecid_name=ecid_xt.getName();
193 
194  //EB data
195  if (ecid_name=="EB_crystal_number") {
196  int sm_num=ecid_xt.getID1();
197  int xt_num=ecid_xt.getID2();
198  EBDetId ebdetid(sm_num,xt_num,EBDetId::SMCRYSTALMODE);
199 
201  item.mult_x1 =rd_lin.getMultX1() ;
202  item.mult_x6 =rd_lin.getMultX6();
203  item.mult_x12 =rd_lin.getMultX12();
204  item.shift_x1 =rd_lin.getShift1() ;
205  item.shift_x6 =rd_lin.getShift6();
206  item.shift_x12 =rd_lin.getShift12();
207 
208  linC->insert(std::make_pair(ebdetid.rawId(),item));
209  ++icells;
210  }
211  else {
212  //EE data
213  int z=ecid_xt.getID1();
214  int x=ecid_xt.getID2();
215  int y=ecid_xt.getID3();
216  EEDetId eedetid(x,y,z,EEDetId::XYMODE);
217 
219 
220  item.mult_x1 =rd_lin.getMultX1() ;
221  item.mult_x6 =rd_lin.getMultX6();
222  item.mult_x12 =rd_lin.getMultX12();
223  item.shift_x1 =rd_lin.getShift1() ;
224  item.shift_x6 =rd_lin.getShift6();
225  item.shift_x12 =rd_lin.getShift12();
226 
227  linC->insert(std::make_pair(eedetid.rawId(),item));
228  ++icells;
229  }
230  }
231 
232  Time_t snc= (Time_t) irun ;
233  m_to_transfer.push_back(std::make_pair((EcalTPGLinearizationConst*)linC,snc));
234 
235  m_i_run_number=irun;
236  m_i_tag=the_config_tag;
237  m_i_version=the_config_version;
238  m_i_lin=linId;
239 
240  writeFile("last_tpg_lin_settings.txt");
241 
242  } else {
243 
244  m_i_run_number=irun;
245  m_i_tag=the_config_tag;
246  m_i_version=the_config_version;
247 
248  writeFile("last_tpg_lin_settings.txt");
249 
250  std::cout<< " even if the tag/version is not the same, the linearization constants id is the same -> no transfer needed "<< std::endl;
251 
252  }
253  } catch (std::exception &e) {
254  std::cout << "ERROR: THIS CONFIG DOES NOT EXIST: tag=" <<the_config_tag
255  <<" version="<<the_config_version<< std::endl;
256  std::cout << e.what() << std::endl;
257  m_i_run_number=irun;
258 
259  }
260  std::cout<<" **************** "<<std::endl;
261 
262  } else if(nr==0) {
263  m_i_run_number=irun;
264  std::cout<< " no tag saved to RUN_TPGCONFIG_DAT by EcalSupervisor -> no transfer needed "<< std::endl;
265  std::cout<<" **************** "<<std::endl;
266  } else {
267  m_i_run_number=irun;
268  m_i_tag=the_config_tag;
269  m_i_version=the_config_version;
270  std::cout<< " the tag/version is the same -> no transfer needed "<< std::endl;
271  std::cout<<" **************** "<<std::endl;
272  writeFile("last_tpg_lin_settings.txt");
273  }
274 
275  }
276  }
277 
278  delete econn;
279 
280  edm::LogInfo("EcalTPGLinConstHandler") << "Ecal - > end of getNewObjects -----------";
281 }
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
static const int XYMODE
Definition: EEDetId.h:316
int getMultX12() const
void setVersion(int id)
double double double z
void setId(int id)
int getID2() const
Definition: EcalLogicID.cc:52
std::string name
Definition: TagInfo.h:9
int getMultX1() const
std::string getName() const
Definition: EcalLogicID.cc:37
int getShift6() const
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 getLinId() const
int getID1() const
Definition: EcalLogicID.cc:47
int getShift12() const
int getMultX6() const
size_t size
Definition: TagInfo.h:13
void insert(std::pair< uint32_t, Item > const &a)
void readFromFile(const char *inputFile)
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:33
tuple dataset
Definition: dataset.py:393
void setConfigTag(std::string x)
Definition: IODConfig.h:31
void writeFile(const char *inputFile)
cond::ValidityInterval lastInterval
Definition: TagInfo.h:11
void setLocation(std::string loc)
Definition: LocationDef.cc:33
tuple cout
Definition: gather_cfg.py:121
int getID3() const
Definition: EcalLogicID.cc:57
Definition: DDAxes.h:10
void setGeneralTag(std::string tag)
Definition: RunTag.cc:36
static const int SMCRYSTALMODE
Definition: EBDetId.h:146
tuple size
Write out results.
int getShift1() const
EcalTPGLinearizationConstMap EcalTPGLinearizationConst
std::string popcon::EcalTPGLinConstHandler::id ( void  ) const
inlinevirtual
void popcon::EcalTPGLinConstHandler::readFromFile ( const char *  inputFile)

Definition at line 283 of file EcalTPGLinConstHandler.cc.

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

283  {
284  //-------------------------------------------------------------
285 
286  m_i_tag="";
287  m_i_version=0;
288  m_i_run_number=0;
289  m_i_lin=0;
290 
291  FILE *inpFile; // input file
292  inpFile = fopen(inputFile,"r");
293  if(!inpFile) {
294  edm::LogError("EcalTPGLinConstHandler")<<"*** Can not open file: "<<inputFile;
295  }
296 
297  char line[256];
298 
299  std::ostringstream str;
300 
301  fgets(line,255,inpFile);
302  m_i_tag=to_string(line);
303  str << "gen tag " << m_i_tag << std::endl ; // should I use this?
304 
305  fgets(line,255,inpFile);
306  m_i_version=atoi(line);
307  str << "version= " << m_i_version << std::endl ;
308 
309  fgets(line,255,inpFile);
310  m_i_run_number=atoi(line);
311  str << "run_number= " << m_i_run_number << std::endl ;
312 
313  fgets(line,255,inpFile);
314  m_i_lin=atoi(line);
315  str << "lin_config= " << m_i_lin << std::endl ;
316 
317 
318  fclose(inpFile); // close inp. file
319 
320 }
std::string to_string(char value[])
std::string popcon::EcalTPGLinConstHandler::to_string ( char  value[])
inlineprivate

Definition at line 67 of file EcalTPGLinConstHandler.h.

References relativeConstraints::value.

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

Definition at line 322 of file EcalTPGLinConstHandler.cc.

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

322  {
323  //-------------------------------------------------------------
324 
325 
326  std::ofstream myfile;
327  myfile.open (inputFile);
328  myfile << m_i_tag <<std::endl;
329  myfile << m_i_version <<std::endl;
330  myfile << m_i_run_number <<std::endl;
331  myfile << m_i_lin <<std::endl;
332 
333  myfile.close();
334 
335 }

Member Data Documentation

EcalCondDBInterface* popcon::EcalTPGLinConstHandler::econn

Definition at line 64 of file EcalTPGLinConstHandler.h.

unsigned int popcon::EcalTPGLinConstHandler::m_firstRun
private

Definition at line 75 of file EcalTPGLinConstHandler.h.

Referenced by EcalTPGLinConstHandler().

std::string popcon::EcalTPGLinConstHandler::m_gentag
private

Definition at line 79 of file EcalTPGLinConstHandler.h.

Referenced by EcalTPGLinConstHandler().

int popcon::EcalTPGLinConstHandler::m_i_lin
private

Definition at line 90 of file EcalTPGLinConstHandler.h.

unsigned int popcon::EcalTPGLinConstHandler::m_i_run_number
private

Definition at line 89 of file EcalTPGLinConstHandler.h.

std::string popcon::EcalTPGLinConstHandler::m_i_tag
private

Definition at line 87 of file EcalTPGLinConstHandler.h.

int popcon::EcalTPGLinConstHandler::m_i_version
private

Definition at line 88 of file EcalTPGLinConstHandler.h.

unsigned int popcon::EcalTPGLinConstHandler::m_lastRun
private

Definition at line 76 of file EcalTPGLinConstHandler.h.

Referenced by EcalTPGLinConstHandler().

const EcalTPGLinearizationConst* popcon::EcalTPGLinConstHandler::m_linearizationConst
private

Definition at line 73 of file EcalTPGLinConstHandler.h.

std::string popcon::EcalTPGLinConstHandler::m_location
private

Definition at line 78 of file EcalTPGLinConstHandler.h.

Referenced by EcalTPGLinConstHandler().

std::string popcon::EcalTPGLinConstHandler::m_locationsource
private

Definition at line 83 of file EcalTPGLinConstHandler.h.

Referenced by EcalTPGLinConstHandler().

std::string popcon::EcalTPGLinConstHandler::m_name
private

Definition at line 84 of file EcalTPGLinConstHandler.h.

Referenced by id().

std::string popcon::EcalTPGLinConstHandler::m_pass
private

Definition at line 82 of file EcalTPGLinConstHandler.h.

Referenced by EcalTPGLinConstHandler().

unsigned int popcon::EcalTPGLinConstHandler::m_runnr
private

Definition at line 85 of file EcalTPGLinConstHandler.h.

std::string popcon::EcalTPGLinConstHandler::m_runtype
private

Definition at line 86 of file EcalTPGLinConstHandler.h.

Referenced by EcalTPGLinConstHandler().

std::string popcon::EcalTPGLinConstHandler::m_sid
private

Definition at line 80 of file EcalTPGLinConstHandler.h.

Referenced by EcalTPGLinConstHandler().

std::string popcon::EcalTPGLinConstHandler::m_user
private

Definition at line 81 of file EcalTPGLinConstHandler.h.

Referenced by EcalTPGLinConstHandler().