CMS 3D CMS Logo

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

An interface class to the PVSS cond DB. More...

#include <SiStripCoralIface.h>

Public Member Functions

void doNameQuery (std::vector< std::string > &vec_dpname, std::vector< uint32_t > &vec_dpid)
 
void doQuery (std::string queryType, const coral::TimeStamp &startTime, const coral::TimeStamp &endTime, std::vector< coral::TimeStamp > &, std::vector< float > &, std::vector< std::string > &)
 
void doSettingsQuery (const coral::TimeStamp &startTime, const coral::TimeStamp &endTime, std::vector< coral::TimeStamp > &, std::vector< float > &, std::vector< std::string > &, std::vector< uint32_t > &)
 
 SiStripCoralIface (std::string connectionString, std::string authenticationPath, const bool debug)
 
 ~SiStripCoralIface ()
 

Private Member Functions

void initialize ()
 

Private Attributes

bool debug_
 
std::string m_authPath
 
std::string m_connectionString
 
std::map< std::string, unsigned int > m_id_map
 
cond::persistency::Session m_session
 
std::unique_ptr< cond::persistency::TransactionScopem_transaction
 

Detailed Description

An interface class to the PVSS cond DB.

Author
J.Chen, J.Cole

Definition at line 17 of file SiStripCoralIface.h.

Constructor & Destructor Documentation

◆ SiStripCoralIface()

SiStripCoralIface::SiStripCoralIface ( std::string  connectionString,
std::string  authenticationPath,
const bool  debug 
)

constructor

Definition at line 21 of file SiStripCoralIface.cc.

23  std::cout << "Building coral interface" << std::endl;
24  initialize();
25 }

References gather_cfg::cout, and initialize().

◆ ~SiStripCoralIface()

SiStripCoralIface::~SiStripCoralIface ( )

destructor

Definition at line 28 of file SiStripCoralIface.cc.

28  {
29  LogTrace("SiStripCoralIface") << "[SiStripCoralIface::" << __func__ << "] Destructor called.";
30  // m_connection.close();
31 }

References LogTrace.

Member Function Documentation

◆ doNameQuery()

void SiStripCoralIface::doNameQuery ( std::vector< std::string > &  vec_dpname,
std::vector< uint32_t > &  vec_dpid 
)

Definition at line 179 of file SiStripCoralIface.cc.

179  {
180  std::unique_ptr<coral::IQuery> query(
181  m_session.coralSession().schema(std::string("CMS_TRK_DCS_PVSS_COND")).newQuery());
182  query->addToOutputList("DP_NAME2ID.DPNAME", "DPNAME");
183  query->addToOutputList("DP_NAME2ID.ID", "DPID");
184  query->addToTableList("DP_NAME2ID");
185 
186  std::string condition = "DP_NAME2ID.DPNAME like '%easyBoard%' ";
187  query->setCondition(condition, coral::AttributeList());
188 
189  query->setMemoryCacheSize(100);
190  coral::ICursor& cursor = query->execute();
191  int numberRow = 0;
192  while (cursor.next()) {
193  const coral::AttributeList& row = cursor.currentRow();
194  numberRow++;
195  uint32_t id = (uint32_t)row["DPID"].data<float>();
196  vec_dpid.push_back(id);
197  std::string id_name = (std::string)row["DPNAME"].data<std::string>();
198  vec_dpname.push_back(id_name);
199  }
200  cursor.close();
201  edm::LogInfo("SiStripCoralIface") << "[SiStripCoralIface::" << __func__ << "] " << numberRow
202  << " rows retrieved from PVSS Cond DB";
203 }

References goodZToMuMu_cfi::condition, cond::persistency::Session::coralSession(), m_session, contentValuesFiles::query, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ doQuery()

void SiStripCoralIface::doQuery ( std::string  queryType,
const coral::TimeStamp &  startTime,
const coral::TimeStamp &  endTime,
std::vector< coral::TimeStamp > &  vec_changedate,
std::vector< float > &  vec_actualValue,
std::vector< std::string > &  vec_dpname 
)

Method to retrieve information from status change table or lastValue table. queryType defines which table is to be accessed.

Definition at line 50 of file SiStripCoralIface.cc.

55  {
56  std::unique_ptr<coral::IQuery> query(
57  m_session.coralSession().schema(std::string("CMS_TRK_DCS_PVSS_COND")).newQuery());
59 
60  LogTrace("SiStripCoralIface") << "[SiStripCoralIface::" << __func__ << "] table to be accessed: " << queryType;
61 
62  if (queryType == "STATUSCHANGE") {
63  query->addToOutputList("FWCAENCHANNEL.CHANGE_DATE", "CHANGE_DATE");
64  query->addToOutputList("FWCAENCHANNEL.ACTUAL_STATUS", "ACTUAL_STATUS");
65  query->addToOutputList("DP_NAME2ID.DPNAME", "DPNAME");
66  query->addToOrderList("FWCAENCHANNEL.CHANGE_DATE");
67  query->addToTableList("FWCAENCHANNEL");
68  query->addToTableList("DP_NAME2ID");
69  condition =
70  "FWCAENCHANNEL.DPID = DP_NAME2ID.ID AND FWCAENCHANNEL.CHANGE_DATE<=:tmax AND FWCAENCHANNEL.ACTUAL_STATUS IS "
71  "NOT NULL AND FWCAENCHANNEL.CHANGE_DATE >=:tmin AND (DP_NAME2ID.DPNAME like '%easyBoard%')";
72  } else if (queryType == "LASTVALUE") {
73  query->addToOutputList("DCSLASTVALUE_VOLTAGE.CHANGE_DATE", "CHANGE_DATE");
74  query->addToOutputList("DCSLASTVALUE_VOLTAGE.ACTUAL_VMON", "ACTUAL_VMON");
75  query->addToOutputList("DP_NAME2ID.DPNAME", "DPNAME");
76  query->addToOrderList("DCSLASTVALUE_VOLTAGE.CHANGE_DATE");
77  query->addToTableList("DCSLASTVALUE_VOLTAGE");
78  query->addToTableList("DP_NAME2ID");
79  condition =
80  "DCSLASTVALUE_VOLTAGE.DPID = DP_NAME2ID.ID AND DCSLASTVALUE_VOLTAGE.CHANGE_DATE<=:tmax AND "
81  "DCSLASTVALUE_VOLTAGE.CHANGE_DATE>=:tmin AND DCSLASTVALUE_VOLTAGE.ACTUAL_VMON IS NOT NULL AND "
82  "(DP_NAME2ID.DPNAME like '%easyBoard%')";
83  }
84 
85  coral::AttributeList conditionData;
86  conditionData.extend<coral::TimeStamp>("tmax");
87  conditionData.extend<coral::TimeStamp>("tmin");
88  query->setCondition(condition, conditionData);
89  conditionData[0].data<coral::TimeStamp>() = endTime;
90  conditionData[1].data<coral::TimeStamp>() = startTime;
91 
92  query->setMemoryCacheSize(100);
93  std::cout << "Executing query" << std::endl;
94  if (debug_)
95  std::cout << "[SiStripCoralIface::" << __func__ << "] Dumping all query results:" << std::endl;
96  coral::ICursor& cursor = query->execute();
97  int numberRow = 0;
98  while (cursor.next()) {
99  const coral::AttributeList& row = cursor.currentRow();
100  //DEBUG
101  //Output the query results directly to cout,
102  //Can be subsequently parsed by Python validation code
103  if (debug_)
104  row.toOutputStream(std::cout) << std::endl;
105  numberRow++;
106  if (queryType == "STATUSCHANGE") {
107  coral::TimeStamp ts = row["CHANGE_DATE"].data<coral::TimeStamp>();
108  vec_changedate.push_back(ts);
109  float as = (float)row["ACTUAL_STATUS"].data<float>();
110  vec_actualValue.push_back(as);
111  std::string id_name = (std::string)row["DPNAME"].data<std::string>();
112  vec_dpname.push_back(id_name);
113  } else if (queryType == "LASTVALUE") {
114  coral::TimeStamp ts = row["CHANGE_DATE"].data<coral::TimeStamp>();
115  vec_changedate.push_back(ts);
116  float av = (float)row["ACTUAL_VMON"].data<float>();
117  vec_actualValue.push_back(av);
118  std::string id_name = (std::string)row["DPNAME"].data<std::string>();
119  vec_dpname.push_back(id_name);
120  }
121  }
122  cursor.close();
123  if (debug_)
124  std::cout << "[SiStripCoralIface::" << __func__ << "] Finished dumping query results, " << numberRow
125  << " rows were retrieved from PVSS Cond DB (both Pixel and Strip CAEN supplies)" << std::endl;
126  edm::LogInfo("SiStripCoralIface") << "[SiStripCoralIface::" << __func__ << "] " << numberRow
127  << " rows retrieved from PVSS Cond DB";
128 }

References goodZToMuMu_cfi::condition, cond::persistency::Session::coralSession(), gather_cfg::cout, debug_, dqmMemoryStats::float, LogTrace, m_session, contentValuesFiles::query, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ doSettingsQuery()

void SiStripCoralIface::doSettingsQuery ( const coral::TimeStamp &  startTime,
const coral::TimeStamp &  endTime,
std::vector< coral::TimeStamp > &  vec_changedate,
std::vector< float > &  vec_settings,
std::vector< std::string > &  vec_dpname,
std::vector< uint32_t > &  vec_dpid 
)

Method to access the settings for each channel stored in the status change table

Definition at line 131 of file SiStripCoralIface.cc.

136  {
137  std::unique_ptr<coral::IQuery> query(
138  m_session.coralSession().schema(std::string("CMS_TRK_DCS_PVSS_COND")).newQuery());
139  query->addToOutputList("FWCAENCHANNEL.CHANGE_DATE", "CHANGE_DATE");
140  query->addToOutputList("FWCAENCHANNEL.SETTINGS_V0", "VSET");
141  query->addToOutputList("FWCAENCHANNEL.DPID", "DPID");
142  query->addToOutputList("DP_NAME2ID.DPNAME", "DPNAME");
143  query->addToOrderList("FWCAENCHANNEL.CHANGE_DATE");
144  query->addToTableList("FWCAENCHANNEL");
145  query->addToTableList("DP_NAME2ID");
147  "FWCAENCHANNEL.DPID = DP_NAME2ID.ID AND FWCAENCHANNEL.CHANGE_DATE<=:tmax AND FWCAENCHANNEL.SETTINGS_V0 IS NOT "
148  "NULL AND FWCAENCHANNEL.CHANGE_DATE >=:tmin AND (DP_NAME2ID.DPNAME like '%easyBoard%')";
149 
150  coral::AttributeList conditionData;
151  conditionData.extend<coral::TimeStamp>("tmax");
152  conditionData.extend<coral::TimeStamp>("tmin");
153  query->setCondition(condition, conditionData);
154  conditionData[0].data<coral::TimeStamp>() = endTime;
155  conditionData[1].data<coral::TimeStamp>() = startTime;
156 
157  query->setMemoryCacheSize(100);
158  coral::ICursor& cursor = query->execute();
159  int numberRow = 0;
160  while (cursor.next()) {
161  const coral::AttributeList& row = cursor.currentRow();
162  if (debug_)
163  row.toOutputStream(std::cout) << std::endl;
164  numberRow++;
165  coral::TimeStamp ts = row["CHANGE_DATE"].data<coral::TimeStamp>();
166  vec_changedate.push_back(ts);
167  float vs = (float)row["VSET"].data<float>();
168  vec_settings.push_back(vs);
169  uint32_t id = (uint32_t)row["DPID"].data<float>();
170  vec_dpid.push_back(id);
171  std::string id_name = (std::string)row["DPNAME"].data<std::string>();
172  vec_dpname.push_back(id_name);
173  }
174  cursor.close();
175  edm::LogInfo("SiStripCoralIface") << "[SiStripCoralIface::" << __func__ << "] " << numberRow
176  << " rows retrieved from PVSS Cond DB";
177 }

References goodZToMuMu_cfi::condition, cond::persistency::Session::coralSession(), gather_cfg::cout, debug_, dqmMemoryStats::float, m_session, contentValuesFiles::query, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ initialize()

void SiStripCoralIface::initialize ( )
private

Set up the connection to the database

Definition at line 34 of file SiStripCoralIface.cc.

34  {
37  connection.configure();
39  try {
41  m_transaction->start(true);
42  LogTrace("SiStripCoralIface") << "[SiStripCoralIface::" << __func__ << "] Database connection opened";
43  } catch (...) {
44  edm::LogError("SiStripCoralIface") << "Database connection failed";
45  exit(1);
46  }
47 }

References cond::persistency::ConnectionPool::configure(), cond::persistency::ConnectionPool::createSession(), beamvalidation::exit(), LogTrace, m_authPath, m_connectionString, m_session, m_transaction, cond::persistency::ConnectionPool::setAuthenticationPath(), and cond::persistency::Session::transaction().

Referenced by SiStripCoralIface().

Member Data Documentation

◆ debug_

bool SiStripCoralIface::debug_
private

Definition at line 53 of file SiStripCoralIface.h.

Referenced by doQuery(), and doSettingsQuery().

◆ m_authPath

std::string SiStripCoralIface::m_authPath
private

Definition at line 46 of file SiStripCoralIface.h.

Referenced by initialize().

◆ m_connectionString

std::string SiStripCoralIface::m_connectionString
private

Definition at line 45 of file SiStripCoralIface.h.

Referenced by initialize().

◆ m_id_map

std::map<std::string, unsigned int> SiStripCoralIface::m_id_map
private

Definition at line 47 of file SiStripCoralIface.h.

◆ m_session

cond::persistency::Session SiStripCoralIface::m_session
private

Definition at line 48 of file SiStripCoralIface.h.

Referenced by doNameQuery(), doQuery(), doSettingsQuery(), and initialize().

◆ m_transaction

std::unique_ptr<cond::persistency::TransactionScope> SiStripCoralIface::m_transaction
private

Definition at line 49 of file SiStripCoralIface.h.

Referenced by initialize().

cond::persistency::TransactionScope
Definition: Session.h:231
SiStripCoralIface::m_transaction
std::unique_ptr< cond::persistency::TransactionScope > m_transaction
Definition: SiStripCoralIface.h:49
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::LogInfo
Definition: MessageLogger.h:254
cond::persistency::ConnectionPool::createSession
Session createSession(const std::string &connectionString, bool writeCapable=false)
Definition: ConnectionPool.cc:154
SiStripCoralIface::m_authPath
std::string m_authPath
Definition: SiStripCoralIface.h:46
debug
#define debug
Definition: HDRShower.cc:19
query
Definition: query.py:1
cond::persistency::ConnectionPool
Definition: ConnectionPool.h:31
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogError
Definition: MessageLogger.h:183
SiStripCoralIface::initialize
void initialize()
Definition: SiStripCoralIface.cc:34
cond::persistency::Session::coralSession
coral::ISessionProxy & coralSession()
Definition: Session.cc:218
cond::persistency::ConnectionPool::setAuthenticationPath
void setAuthenticationPath(const std::string &p)
Definition: ConnectionPool.cc:32
SiStripCoralIface::m_session
cond::persistency::Session m_session
Definition: SiStripCoralIface.h:48
SiStripCoralIface::debug_
bool debug_
Definition: SiStripCoralIface.h:53
cond::persistency::ConnectionPool::configure
void configure()
Definition: ConnectionPool.cc:121
goodZToMuMu_cfi.condition
condition
Definition: goodZToMuMu_cfi.py:37
writeEcalDQMStatus.authenticationPath
authenticationPath
Definition: writeEcalDQMStatus.py:19
cond::persistency::Session::transaction
Transaction & transaction()
Definition: Session.cc:52
SiStripCoralIface::m_connectionString
std::string m_connectionString
Definition: SiStripCoralIface.h:45
contentValuesFiles.query
query
Definition: contentValuesFiles.py:38
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
l1RCTOmdsFedVectorProducer_cfi.connectionString
connectionString
Definition: l1RCTOmdsFedVectorProducer_cfi.py:4