CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
ODDCCConfig Class Reference

#include <ODDCCConfig.h>

Inheritance diagram for ODDCCConfig:
IODConfig IDBObject

Public Member Functions

unsigned char * getDCCClob () const
 
unsigned int getDCCClobSize () const
 
std::string getDCCConfigurationUrl () const
 
std::string getDCCWeightsMode () const
 
int getId () const
 
int getNTestPatternsToLoad () const
 
unsigned int getSize () const
 
int getSMHalf () const
 
std::string getTable () override
 
std::string getTestPatternFileUrl () const
 
 ODDCCConfig ()
 
void setDCCClob (unsigned char *x)
 
void setDCCConfigurationUrl (std::string x)
 
void setDCCWeightsMode (std::string x)
 
void setId (int id)
 
void setNTestPatternsToLoad (int id)
 
void setParameters (const std::map< std::string, std::string > &my_keys_map)
 
void setSize (unsigned int id)
 
void setSMHalf (int id)
 
void setTestPatternFileUrl (std::string x)
 
 ~ODDCCConfig () override
 
- Public Member Functions inherited from IODConfig
std::string getConfigTag ()
 
void setConfigTag (std::string x)
 
- Public Member Functions inherited from IDBObject
oracle::occi::Connection * getConn () const
 
oracle::occi::Environment * getEnv () const
 
void setConnection (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
virtual ~IDBObject ()
 

Private Member Functions

void clear ()
 
void fetchData (ODDCCConfig *result) noexcept(false)
 
int fetchID () noexcept(false)
 
int fetchNextId () noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB () noexcept(false)
 

Private Attributes

unsigned char * m_dcc_clob
 
std::string m_dcc_url
 
int m_ID
 
int m_ntest
 
unsigned int m_size
 
int m_sm_half
 
std::string m_test_url
 
std::string m_wei
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Public Types inherited from IODConfig
typedef oracle::occi::Clob Clob
 
typedef oracle::occi::SQLException SQLException
 
typedef oracle::occi::Statement Statement
 
typedef oracle::occi::Stream Stream
 
- Public Attributes inherited from IODConfig
std::string m_config_tag
 
- Static Public Attributes inherited from IDBObject
static const int ECALDB_NROWS = 1024
 
- Protected Member Functions inherited from IODConfig
void checkPrepare () noexcept(false)
 
void createReadStatement () noexcept(false)
 
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) noexcept(false)
 
unsigned char * readClob (Clob &clob, int size) noexcept(false)
 
void setPrefetchRowCount (int ncount) noexcept(false)
 
void terminateReadStatement () noexcept(false)
 
void terminateWriteStatement () noexcept(false)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 
- Protected Attributes inherited from IODConfig
Statementm_readStmt
 
Statementm_writeStmt
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Definition at line 15 of file ODDCCConfig.h.

Constructor & Destructor Documentation

◆ ODDCCConfig()

ODDCCConfig::ODDCCConfig ( )

Definition at line 15 of file ODDCCConfig.cc.

15  {
16  m_env = nullptr;
17  m_conn = nullptr;
18  m_writeStmt = nullptr;
19  m_readStmt = nullptr;
20  m_size = 0;
21  m_config_tag = "";
22  m_ID = 0;
23  m_wei = "";
24  clear();
25 }

References clear().

◆ ~ODDCCConfig()

ODDCCConfig::~ODDCCConfig ( )
override

Definition at line 27 of file ODDCCConfig.cc.

27 {}

Member Function Documentation

◆ clear()

void ODDCCConfig::clear ( void  )
private

Definition at line 165 of file ODDCCConfig.cc.

165  {
166  m_dcc_url = "";
167  m_test_url = "";
168  m_ntest = 0;
169  m_sm_half = 0;
170  m_wei = "";
171 }

◆ fetchData()

void ODDCCConfig::fetchData ( ODDCCConfig result)
privatenoexcept

Definition at line 173 of file ODDCCConfig.cc.

173  {
174  this->checkConnection();
175  // result->clear();
176  if (result->getId() == 0 && (result->getConfigTag().empty())) {
177  // throw(std::runtime_error("ODDCCConfig::fetchData(): no Id defined for this ODDCCConfig "));
178  result->fetchID();
179  }
180 
181  try {
182  m_readStmt->setSQL(
183  "SELECT * "
184  "FROM ECAL_DCC_CONFIGURATION "
185  " where dcc_configuration_id = :1 or dcc_tag=:2 ");
186  m_readStmt->setInt(1, result->getId());
187  m_readStmt->setString(2, result->getConfigTag());
188  ResultSet *rset = m_readStmt->executeQuery();
189 
190  rset->next();
191 
192  // 1 is the id and 2 is the config tag
193 
194  result->setId(rset->getInt(1));
195  result->setConfigTag(rset->getString(2));
196  result->setDCCConfigurationUrl(rset->getString(3));
197  result->setTestPatternFileUrl(rset->getString(4));
198  result->setNTestPatternsToLoad(rset->getInt(5));
199  result->setSMHalf(rset->getInt(6));
200 
201  Clob clob = rset->getClob(7);
202  m_size = clob.length();
203  Stream *instream = clob.getStream(1, 0);
204  unsigned char *buffer = new unsigned char[m_size];
205  memset(buffer, 0, m_size);
206  instream->readBuffer((char *)buffer, m_size);
207  /*
208  cout << "Opening the clob in Read only mode" << endl;
209  clob.open (OCCI_LOB_READONLY);
210  int clobLength=clob.length ();
211  cout << "Length of the clob is: " << clobLength << endl;
212  m_size=clobLength;
213  unsigned char* buffer = readClob (clob, m_size);
214  clob.close ();
215  cout<< "the clob buffer is:"<<endl;
216  for (int i = 0; i < clobLength; ++i)
217  cout << (char) buffer[i];
218  cout << endl;
219 
220 
221  */
222  result->setDCCClob(buffer);
223  result->setDCCWeightsMode(rset->getString(8));
224 
225  } catch (SQLException &e) {
226  throw(std::runtime_error(std::string("ODDCCConfig::fetchData(): ") + e.getMessage()));
227  }
228 }

References edmScanValgrind::buffer, MillePedeFileConverter_cfg::e, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ fetchID()

int ODDCCConfig::fetchID ( )
privatenoexcept

Definition at line 230 of file ODDCCConfig.cc.

230  {
231  if (m_ID != 0) {
232  return m_ID;
233  }
234 
235  this->checkConnection();
236 
237  try {
238  Statement *stmt = m_conn->createStatement();
239  stmt->setSQL(
240  "SELECT DCC_configuration_id FROM ecal_dcc_configuration "
241  "WHERE dcc_tag=:dcc_tag ");
242 
243  stmt->setString(1, getConfigTag());
244 
245  ResultSet *rset = stmt->executeQuery();
246 
247  if (rset->next()) {
248  m_ID = rset->getInt(1);
249  } else {
250  m_ID = 0;
251  }
252  m_conn->terminateStatement(stmt);
253  } catch (SQLException &e) {
254  throw(std::runtime_error(std::string("ODDCCConfig::fetchID: ") + e.getMessage()));
255  }
256 
257  return m_ID;
258 }

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ fetchNextId()

int ODDCCConfig::fetchNextId ( )
privatenoexcept

Definition at line 29 of file ODDCCConfig.cc.

29  {
30  int result = 0;
31  try {
32  this->checkConnection();
33 
34  m_readStmt = m_conn->createStatement();
35  m_readStmt->setSQL("select ecal_dcc_config_sq.NextVal from dual");
36  ResultSet *rset = m_readStmt->executeQuery();
37  while (rset->next()) {
38  result = rset->getInt(1);
39  }
40  m_conn->terminateStatement(m_readStmt);
41  return result;
42 
43  } catch (SQLException &e) {
44  throw(std::runtime_error(std::string("ODDCCConfig::fetchNextId(): ") + e.getMessage()));
45  }
46 }

References MillePedeFileConverter_cfg::e, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ getDCCClob()

unsigned char* ODDCCConfig::getDCCClob ( ) const
inline

Definition at line 42 of file ODDCCConfig.h.

42 { return m_dcc_clob; }

References m_dcc_clob.

Referenced by popcon::EcalSRPHandler::getNewObjects().

◆ getDCCClobSize()

unsigned int ODDCCConfig::getDCCClobSize ( ) const
inline

Definition at line 43 of file ODDCCConfig.h.

43 { return m_size; }

References m_size.

Referenced by popcon::EcalSRPHandler::getNewObjects().

◆ getDCCConfigurationUrl()

std::string ODDCCConfig::getDCCConfigurationUrl ( ) const
inline

Definition at line 30 of file ODDCCConfig.h.

30 { return m_dcc_url; }

References m_dcc_url.

◆ getDCCWeightsMode()

std::string ODDCCConfig::getDCCWeightsMode ( ) const
inline

Definition at line 45 of file ODDCCConfig.h.

45 { return m_wei; }

References m_wei.

Referenced by popcon::EcalSRPHandler::getNewObjects().

◆ getId()

int ODDCCConfig::getId ( void  ) const
inline

Definition at line 25 of file ODDCCConfig.h.

25 { return m_ID; }

References m_ID.

◆ getNTestPatternsToLoad()

int ODDCCConfig::getNTestPatternsToLoad ( ) const
inline

Definition at line 36 of file ODDCCConfig.h.

36 { return m_ntest; }

References m_ntest.

◆ getSize()

unsigned int ODDCCConfig::getSize ( ) const
inline

Definition at line 27 of file ODDCCConfig.h.

27 { return m_size; }

References m_size.

◆ getSMHalf()

int ODDCCConfig::getSMHalf ( ) const
inline

Definition at line 39 of file ODDCCConfig.h.

39 { return m_sm_half; }

References m_sm_half.

◆ getTable()

std::string ODDCCConfig::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 22 of file ODDCCConfig.h.

22 { return "ECAL_DCC_CONFIGURATION"; }

◆ getTestPatternFileUrl()

std::string ODDCCConfig::getTestPatternFileUrl ( ) const
inline

Definition at line 33 of file ODDCCConfig.h.

33 { return m_test_url; }

References m_test_url.

◆ prepareWrite()

void ODDCCConfig::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 48 of file ODDCCConfig.cc.

48  {
49  this->checkConnection();
50 
51  int next_id = fetchNextId();
52 
53  try {
54  m_writeStmt = m_conn->createStatement();
55  m_writeStmt->setSQL(
56  "INSERT INTO ECAL_DCC_CONFIGURATION (dcc_configuration_id, dcc_tag, "
57  " DCC_CONFIGURATION_URL, TESTPATTERN_FILE_URL, "
58  " N_TESTPATTERNS_TO_LOAD , SM_HALF, weightsmode, "
59  " dcc_configuration) "
60  "VALUES (:1, :2, :3, :4, :5, :6 , :7 ,:8 )");
61  m_writeStmt->setInt(1, next_id);
62  m_writeStmt->setString(2, getConfigTag());
63  m_writeStmt->setString(3, getDCCConfigurationUrl());
64  m_writeStmt->setString(4, getTestPatternFileUrl());
65  m_writeStmt->setInt(5, getNTestPatternsToLoad());
66  m_writeStmt->setInt(6, getSMHalf());
67  m_writeStmt->setString(7, getDCCWeightsMode());
68 
69  // and now the clob
70  oracle::occi::Clob clob(m_conn);
71  clob.setEmpty();
72  m_writeStmt->setClob(8, clob);
73  m_writeStmt->executeUpdate();
74  m_ID = next_id;
75 
76  m_conn->terminateStatement(m_writeStmt);
77  std::cout << "DCC Clob inserted into CONFIGURATION with id=" << next_id << std::endl;
78 
79  // now we read and update it
80  m_writeStmt = m_conn->createStatement();
81  m_writeStmt->setSQL(
82  "SELECT dcc_configuration FROM ECAL_DCC_CONFIGURATION WHERE"
83  " dcc_configuration_id=:1 FOR UPDATE");
84 
85  std::cout << "updating the clob 0" << std::endl;
86 
87  } catch (SQLException &e) {
88  throw(std::runtime_error(std::string("ODDCCConfig::prepareWrite(): ") + e.getMessage()));
89  }
90 
91  std::cout << "updating the clob 1 " << std::endl;
92 }

References gather_cfg::cout, MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ setDCCClob()

void ODDCCConfig::setDCCClob ( unsigned char *  x)
inline

Definition at line 41 of file ODDCCConfig.h.

41 { m_dcc_clob = x; }

References m_dcc_clob, and x.

◆ setDCCConfigurationUrl()

void ODDCCConfig::setDCCConfigurationUrl ( std::string  x)
inline

Definition at line 29 of file ODDCCConfig.h.

29 { m_dcc_url = x; }

References m_dcc_url, and x.

◆ setDCCWeightsMode()

void ODDCCConfig::setDCCWeightsMode ( std::string  x)
inline

Definition at line 44 of file ODDCCConfig.h.

44 { m_wei = x; }

References m_wei, and x.

◆ setId()

void ODDCCConfig::setId ( int  id)
inline

Definition at line 24 of file ODDCCConfig.h.

24 { m_ID = id; }

References triggerObjects_cff::id, and m_ID.

Referenced by popcon::EcalSRPHandler::getNewObjects().

◆ setNTestPatternsToLoad()

void ODDCCConfig::setNTestPatternsToLoad ( int  id)
inline

Definition at line 35 of file ODDCCConfig.h.

35 { m_ntest = id; }

References triggerObjects_cff::id, and m_ntest.

◆ setParameters()

void ODDCCConfig::setParameters ( const std::map< std::string, std::string > &  my_keys_map)

Definition at line 94 of file ODDCCConfig.cc.

94  {
95  // parses the result of the XML parser that is a map of
96  // string string with variable name variable value
97 
98  for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
99  if (ci->first == "DCC_CONFIGURATION_ID")
100  setConfigTag(ci->second);
101  if (ci->first == "TESTPATTERN_FILE_URL")
102  setTestPatternFileUrl(ci->second);
103  if (ci->first == "N_TESTPATTERNS_TO_LOAD")
104  setNTestPatternsToLoad(atoi(ci->second.c_str()));
105  if (ci->first == "SM_HALF")
106  setSMHalf(atoi(ci->second.c_str()));
107  if (ci->first == "WEIGHTSMODE")
108  setDCCWeightsMode(ci->second);
109  if (ci->first == "DCC_CONFIGURATION_URL") {
110  std::string fname = ci->second;
112 
113  // here we must open the file and read the DCC Clob
114  std::cout << "Going to read DCC file: " << fname << endl;
115 
116  ifstream inpFile;
117  inpFile.open(fname.c_str());
118 
119  // tell me size of file
120  int bufsize = 0;
121  inpFile.seekg(0, ios::end);
122  bufsize = inpFile.tellg();
123  std::cout << " bufsize =" << bufsize << std::endl;
124  // set file pointer to start again
125  inpFile.seekg(0, ios::beg);
126 
127  m_size = bufsize;
128 
129  inpFile.close();
130  }
131  }
132 }

References gather_cfg::cout, mps_fire::end, alignmentValidation::fname, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ setSize()

void ODDCCConfig::setSize ( unsigned int  id)
inline

Definition at line 26 of file ODDCCConfig.h.

26 { m_size = id; }

References triggerObjects_cff::id, and m_size.

◆ setSMHalf()

void ODDCCConfig::setSMHalf ( int  id)
inline

Definition at line 38 of file ODDCCConfig.h.

38 { m_sm_half = id; }

References triggerObjects_cff::id, and m_sm_half.

◆ setTestPatternFileUrl()

void ODDCCConfig::setTestPatternFileUrl ( std::string  x)
inline

Definition at line 32 of file ODDCCConfig.h.

32 { m_test_url = x; }

References m_test_url, and x.

◆ writeDB()

void ODDCCConfig::writeDB ( )
privatenoexcept

Definition at line 134 of file ODDCCConfig.cc.

134  {
135  std::cout << "updating the clob " << std::endl;
136 
137  try {
138  m_writeStmt->setInt(1, m_ID);
139  ResultSet *rset = m_writeStmt->executeQuery();
140 
141  rset->next();
142  oracle::occi::Clob clob = rset->getClob(1);
143 
144  cout << "Opening the clob in read write mode" << endl;
145 
146  std::cout << "Populating the clob" << endl;
147 
149  int clobLength = clob.length();
150  cout << "Length of the clob is: " << clobLength << endl;
151 
152  m_writeStmt->executeUpdate();
153 
154  m_writeStmt->closeResultSet(rset);
155 
156  } catch (SQLException &e) {
157  throw(std::runtime_error(std::string("ODDCCConfig::writeDB(): ") + e.getMessage()));
158  }
159  // Now get the ID
160  if (!this->fetchID()) {
161  throw(std::runtime_error("ODDCCConfig::writeDB: Failed to write"));
162  }
163 }

References gather_cfg::cout, MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 17 of file ODDCCConfig.h.

Member Data Documentation

◆ m_dcc_clob

unsigned char* ODDCCConfig::m_dcc_clob
private

Definition at line 60 of file ODDCCConfig.h.

Referenced by getDCCClob(), and setDCCClob().

◆ m_dcc_url

std::string ODDCCConfig::m_dcc_url
private

Definition at line 61 of file ODDCCConfig.h.

Referenced by getDCCConfigurationUrl(), and setDCCConfigurationUrl().

◆ m_ID

int ODDCCConfig::m_ID
private

Definition at line 59 of file ODDCCConfig.h.

Referenced by getId(), and setId().

◆ m_ntest

int ODDCCConfig::m_ntest
private

Definition at line 63 of file ODDCCConfig.h.

Referenced by getNTestPatternsToLoad(), and setNTestPatternsToLoad().

◆ m_size

unsigned int ODDCCConfig::m_size
private

Definition at line 65 of file ODDCCConfig.h.

Referenced by getDCCClobSize(), getSize(), and setSize().

◆ m_sm_half

int ODDCCConfig::m_sm_half
private

Definition at line 64 of file ODDCCConfig.h.

Referenced by getSMHalf(), and setSMHalf().

◆ m_test_url

std::string ODDCCConfig::m_test_url
private

Definition at line 62 of file ODDCCConfig.h.

Referenced by getTestPatternFileUrl(), and setTestPatternFileUrl().

◆ m_wei

std::string ODDCCConfig::m_wei
private

Definition at line 66 of file ODDCCConfig.h.

Referenced by getDCCWeightsMode(), and setDCCWeightsMode().

ODDCCConfig::getDCCWeightsMode
std::string getDCCWeightsMode() const
Definition: ODDCCConfig.h:45
IODConfig::Statement
oracle::occi::Statement Statement
Definition: IODConfig.h:21
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ODDCCConfig::fetchID
int fetchID() noexcept(false)
Definition: ODDCCConfig.cc:230
ODDCCConfig::m_test_url
std::string m_test_url
Definition: ODDCCConfig.h:62
DDAxes::x
IODConfig::SQLException
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
ODDCCConfig::m_dcc_clob
unsigned char * m_dcc_clob
Definition: ODDCCConfig.h:60
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
ODDCCConfig::m_ID
int m_ID
Definition: ODDCCConfig.h:59
ODDCCConfig::getTestPatternFileUrl
std::string getTestPatternFileUrl() const
Definition: ODDCCConfig.h:33
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
IODConfig::Stream
oracle::occi::Stream Stream
Definition: IODConfig.h:22
mps_fire.end
end
Definition: mps_fire.py:242
ODDCCConfig::setTestPatternFileUrl
void setTestPatternFileUrl(std::string x)
Definition: ODDCCConfig.h:32
ODDCCConfig::setDCCWeightsMode
void setDCCWeightsMode(std::string x)
Definition: ODDCCConfig.h:44
IODConfig::getConfigTag
std::string getConfigTag()
Definition: IODConfig.h:30
IDBObject::checkConnection
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
IODConfig::m_readStmt
Statement * m_readStmt
Definition: IODConfig.h:34
ODDCCConfig::getSMHalf
int getSMHalf() const
Definition: ODDCCConfig.h:39
ODDCCConfig::m_dcc_url
std::string m_dcc_url
Definition: ODDCCConfig.h:61
ODDCCConfig::getId
int getId() const
Definition: ODDCCConfig.h:25
IODConfig::populateClob
void populateClob(Clob &clob, std::string fname, unsigned int bufsize) noexcept(false)
Definition: IODConfig.h:67
ODDCCConfig::fetchNextId
int fetchNextId() noexcept(false)
Definition: ODDCCConfig.cc:29
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ODDCCConfig::m_sm_half
int m_sm_half
Definition: ODDCCConfig.h:64
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
IODConfig::Clob
oracle::occi::Clob Clob
Definition: IODConfig.h:23
IODConfig::m_writeStmt
Statement * m_writeStmt
Definition: IODConfig.h:33
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
IODConfig::m_config_tag
std::string m_config_tag
Definition: IODConfig.h:25
ODDCCConfig::getDCCConfigurationUrl
std::string getDCCConfigurationUrl() const
Definition: ODDCCConfig.h:30
ODDCCConfig::m_ntest
int m_ntest
Definition: ODDCCConfig.h:63
ODDCCConfig::setSMHalf
void setSMHalf(int id)
Definition: ODDCCConfig.h:38
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
mps_fire.result
result
Definition: mps_fire.py:311
ODDCCConfig::getNTestPatternsToLoad
int getNTestPatternsToLoad() const
Definition: ODDCCConfig.h:36
IODConfig::setConfigTag
void setConfigTag(std::string x)
Definition: IODConfig.h:29
ODDCCConfig::setNTestPatternsToLoad
void setNTestPatternsToLoad(int id)
Definition: ODDCCConfig.h:35
ODDCCConfig::clear
void clear()
Definition: ODDCCConfig.cc:165
ODDCCConfig::m_size
unsigned int m_size
Definition: ODDCCConfig.h:65
ODDCCConfig::setDCCConfigurationUrl
void setDCCConfigurationUrl(std::string x)
Definition: ODDCCConfig.h:29
ODDCCConfig::m_wei
std::string m_wei
Definition: ODDCCConfig.h:66
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37