CMS 3D CMS Logo

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

#include <L1TOMDSHelper.h>

Public Types

enum  Error { NO_ERROR = 0, WARNING_DB_CONN_FAILED, WARNING_DB_QUERY_FAILED, WARNING_DB_INCORRECT_NBUNCHES }
 

Public Member Functions

bool connect (std::string iOracleDB, std::string iPathCondDB, int &error)
 
std::string enumToStringError (int)
 
BeamConfiguration getBeamConfiguration (int lhcFillNumber, int &error)
 
std::vector< bool > getBunchStructure (int lhcFillNumber, int &error)
 
std::vector< float > getInitBunchLumi (int lhcFillNumber, int &error)
 
int getNumberCollidingBunches (int lhcFillNumber, int &error)
 
std::vector< double > getRelativeBunchLumi (int lhcFillNumber, int &error)
 
std::map< std::string, WbMTriggerXSecFitgetWbMAlgoXsecFits (int &error)
 
std::map< std::string, WbMTriggerXSecFitgetWbMTechXsecFits (int &error)
 
std::map< std::string, WbMTriggerXSecFitgetWbMTriggerXsecFits (std::string iTable, int &error)
 
 L1TOMDSHelper ()
 
 ~L1TOMDSHelper ()
 

Private Attributes

l1t::OMDSReaderm_omdsReader
 
std::string m_oracleDB
 
std::string m_pathCondDB
 

Detailed Description

Definition at line 50 of file L1TOMDSHelper.h.

Member Enumeration Documentation

◆ Error

Enumerator
NO_ERROR 
WARNING_DB_CONN_FAILED 
WARNING_DB_QUERY_FAILED 
WARNING_DB_INCORRECT_NBUNCHES 

Definition at line 52 of file L1TOMDSHelper.h.

Constructor & Destructor Documentation

◆ L1TOMDSHelper()

L1TOMDSHelper::L1TOMDSHelper ( )

Definition at line 9 of file L1TOMDSHelper.cc.

9 { m_omdsReader = nullptr; }

◆ ~L1TOMDSHelper()

L1TOMDSHelper::~L1TOMDSHelper ( )

Definition at line 12 of file L1TOMDSHelper.cc.

12 { delete m_omdsReader; }

Member Function Documentation

◆ connect()

bool L1TOMDSHelper::connect ( std::string  iOracleDB,
std::string  iPathCondDB,
int &  error 
)

Definition at line 15 of file L1TOMDSHelper.cc.

15  {
16  // Handeling inputs
17  m_oracleDB = iOracleDB;
18  m_pathCondDB = iPathCondDB;
19  error = NO_ERROR;
20 
21  // Initializing variables
22  bool SessionOpen = false;
23  bool out = false;
24 
27 
28  // Testing session
29  if (!m_omdsReader->dbSession().connectionString().empty()) {
30  SessionOpen = true;
31  }
32 
33  // Defining output and error message if needed
34  if (SessionOpen) {
35  out = true;
36  } else {
38  }
39 
40  return out;
41 }

References relativeConstraints::error, and MillePedeFileConverter_cfg::out.

Referenced by L1TRate::getXSexFitsOMDS(), and o2o_db_cfgmap.DbManagerDAQ::update_hashmap().

◆ enumToStringError()

string L1TOMDSHelper::enumToStringError ( int  iObject)

Definition at line 333 of file L1TOMDSHelper.cc.

333  {
334  string out;
335 
336  switch (iObject) {
337  case NO_ERROR:
338  out = "NO_ERROR";
339  break;
341  out = "WARNING_DB_CONN_FAILED";
342  break;
344  out = "WARNING_DB_QUERY_FAILED";
345  break;
347  out = "WARNING_DB_INCORRECT_NBUNCHES";
348  break;
349  default:
350  out = "UNKNOWN";
351  break;
352  };
353 
354  return out;
355 }

References MillePedeFileConverter_cfg::out.

◆ getBeamConfiguration()

BeamConfiguration L1TOMDSHelper::getBeamConfiguration ( int  lhcFillNumber,
int &  error 
)

Definition at line 143 of file L1TOMDSHelper.cc.

143  {
144  BeamConfiguration bConfig;
145  error = NO_ERROR;
146 
147  // Fields to retrive in the query
148  string rtlSchema = "CMS_RUNTIME_LOGGER";
149  string table = "FILL_INITLUMIPERBUNCH";
150  string atribute1 = "LHCFILL";
151 
152  // Setting the strings we want to recover from OMDS
153  vector<std::string> qStrings;
154  qStrings.push_back("BUNCH");
155  qStrings.push_back("BEAM1CONFIG");
156  qStrings.push_back("BEAM2CONFIG");
157 
159  m_omdsReader->basicQuery(qStrings, rtlSchema, table, atribute1, m_omdsReader->singleAttribute(lhcFillNumber));
160 
161  if (qResults.queryFailed()) {
163  } else {
164  if (qResults.numberRows() != 3564) {
166  } else {
167  bConfig.m_valid = true;
168 
169  int nCollidingBunches = 0;
170 
171  for (int i = 0; i < qResults.numberRows(); ++i) {
172  int bunch;
173  bool beam1config, beam2config;
174  qResults.fillVariableFromRow("BUNCH", i, bunch);
175  qResults.fillVariableFromRow("BEAM1CONFIG", i, beam1config);
176  qResults.fillVariableFromRow("BEAM2CONFIG", i, beam2config);
177 
178  if (beam1config) {
179  bConfig.beam1.push_back(true);
180  } else {
181  bConfig.beam1.push_back(false);
182  }
183 
184  if (beam2config) {
185  bConfig.beam2.push_back(true);
186  } else {
187  bConfig.beam2.push_back(false);
188  }
189 
190  if (beam1config && beam2config) {
191  nCollidingBunches++;
192  }
193  }
194 
195  bConfig.nCollidingBunches = nCollidingBunches;
196  }
197  }
198 
199  return bConfig;
200 }

References BeamConfiguration::beam1, BeamConfiguration::beam2, relativeConstraints::error, l1t::OMDSReader::QueryResults::fillVariableFromRow(), mps_fire::i, BeamConfiguration::m_valid, BeamConfiguration::nCollidingBunches, l1t::OMDSReader::QueryResults::numberRows(), l1t::OMDSReader::QueryResults::queryFailed(), and TableParser::table.

◆ getBunchStructure()

vector< bool > L1TOMDSHelper::getBunchStructure ( int  lhcFillNumber,
int &  error 
)

Definition at line 203 of file L1TOMDSHelper.cc.

203  {
204  vector<bool> BunchStructure;
205  error = NO_ERROR;
206 
207  // Fields to retrive in the query
208  string rtlSchema = "CMS_RUNTIME_LOGGER";
209  string table = "FILL_INITLUMIPERBUNCH";
210  string atribute1 = "LHCFILL";
211 
212  // Setting the strings we want to recover from OMDS
213  vector<std::string> qStrings;
214  qStrings.push_back("BUNCH");
215  qStrings.push_back("BEAM1CONFIG");
216  qStrings.push_back("BEAM2CONFIG");
217 
219  m_omdsReader->basicQuery(qStrings, rtlSchema, table, atribute1, m_omdsReader->singleAttribute(lhcFillNumber));
220 
221  if (qResults.queryFailed()) {
223  } else {
224  if (qResults.numberRows() != 3564) {
226  } else {
227  for (int i = 0; i < qResults.numberRows(); ++i) {
228  int bunch;
229  bool beam1config, beam2config;
230  qResults.fillVariableFromRow("BUNCH", i, bunch);
231  qResults.fillVariableFromRow("BEAM1CONFIG", i, beam1config);
232  qResults.fillVariableFromRow("BEAM2CONFIG", i, beam2config);
233 
234  if (beam1config && beam2config) {
235  BunchStructure.push_back(true);
236  } else {
237  BunchStructure.push_back(false);
238  }
239  }
240  }
241  }
242 
243  return BunchStructure;
244 }

References relativeConstraints::error, l1t::OMDSReader::QueryResults::fillVariableFromRow(), mps_fire::i, l1t::OMDSReader::QueryResults::numberRows(), l1t::OMDSReader::QueryResults::queryFailed(), and TableParser::table.

◆ getInitBunchLumi()

vector< float > L1TOMDSHelper::getInitBunchLumi ( int  lhcFillNumber,
int &  error 
)

Definition at line 247 of file L1TOMDSHelper.cc.

247  {
248  vector<float> InitBunchLumi;
249  error = NO_ERROR;
250 
251  // Fields to retrive in the query
252  string rtlSchema = "CMS_RUNTIME_LOGGER";
253  string table = "FILL_INITLUMIPERBUNCH";
254  string atribute1 = "LHCFILL";
255 
256  // Setting the strings we want to recover from OMDS
257  vector<std::string> qStrings;
258  qStrings.push_back("BUNCH");
259  qStrings.push_back("INITBUNCHLUMI");
260 
262  m_omdsReader->basicQuery(qStrings, rtlSchema, table, atribute1, m_omdsReader->singleAttribute(lhcFillNumber));
263 
264  if (qResults.queryFailed()) {
266  } else {
267  if (qResults.numberRows() != 3564) {
269  } else {
270  for (int i = 0; i < qResults.numberRows(); ++i) {
271  int bunch;
272  float initbunchlumi;
273  qResults.fillVariableFromRow("BUNCH", i, bunch);
274  qResults.fillVariableFromRow("INITBUNCHLUMI", i, initbunchlumi);
275 
276  InitBunchLumi.push_back(initbunchlumi);
277  }
278  }
279  }
280 
281  return InitBunchLumi;
282 }

References relativeConstraints::error, l1t::OMDSReader::QueryResults::fillVariableFromRow(), mps_fire::i, l1t::OMDSReader::QueryResults::numberRows(), l1t::OMDSReader::QueryResults::queryFailed(), and TableParser::table.

◆ getNumberCollidingBunches()

int L1TOMDSHelper::getNumberCollidingBunches ( int  lhcFillNumber,
int &  error 
)

Definition at line 99 of file L1TOMDSHelper.cc.

99  {
100  int nCollidingBunches = 0;
101  error = NO_ERROR;
102 
103  // Parameters
104  string rtlSchema = "CMS_RUNTIME_LOGGER";
105  string table = "FILL_INITLUMIPERBUNCH";
106  string atribute1 = "LHCFILL";
107 
108  // Fields to retrive in the query
109  vector<std::string> qStrings;
110  qStrings.push_back("BUNCH");
111  qStrings.push_back("BEAM1CONFIG");
112  qStrings.push_back("BEAM2CONFIG");
113 
115  m_omdsReader->basicQuery(qStrings, rtlSchema, table, atribute1, m_omdsReader->singleAttribute(lhcFillNumber));
116 
117  // Check query successful
118  if (qResults.queryFailed()) {
120  } else {
121  if (qResults.numberRows() != 3564) {
123  } else {
124  // Now we count the number of bunches with both beam 1 and 2 configured
125  for (int i = 0; i < qResults.numberRows(); ++i) {
126  int bunch;
127  bool beam1config, beam2config;
128  qResults.fillVariableFromRow("BUNCH", i, bunch);
129  qResults.fillVariableFromRow("BEAM1CONFIG", i, beam1config);
130  qResults.fillVariableFromRow("BEAM2CONFIG", i, beam2config);
131 
132  if (beam1config && beam2config) {
133  nCollidingBunches++;
134  }
135  }
136  }
137  }
138 
139  return nCollidingBunches;
140 }

References relativeConstraints::error, l1t::OMDSReader::QueryResults::fillVariableFromRow(), mps_fire::i, l1t::OMDSReader::QueryResults::numberRows(), l1t::OMDSReader::QueryResults::queryFailed(), and TableParser::table.

◆ getRelativeBunchLumi()

vector< double > L1TOMDSHelper::getRelativeBunchLumi ( int  lhcFillNumber,
int &  error 
)

Definition at line 285 of file L1TOMDSHelper.cc.

285  {
286  vector<double> RelativeBunchLumi;
287  error = NO_ERROR;
288 
289  // Fields to retrive in the query
290  string rtlSchema = "CMS_RUNTIME_LOGGER";
291  string table = "FILL_INITLUMIPERBUNCH";
292  string atribute1 = "LHCFILL";
293 
294  // Setting the strings we want to recover from OMDS
295  vector<std::string> qStrings;
296  qStrings.push_back("BUNCH");
297  qStrings.push_back("INITBUNCHLUMI");
298 
300  m_omdsReader->basicQuery(qStrings, rtlSchema, table, atribute1, m_omdsReader->singleAttribute(lhcFillNumber));
301 
302  if (qResults.queryFailed()) {
304  } else {
305  if (qResults.numberRows() != 3564) {
307  } else {
308  //-> Get the inicial bunch luminosity add calculate the total luminosity of the fill
309  double InitTotalLumi = 0;
310  vector<float> InitBunchLumi;
311 
312  for (int i = 0; i < qResults.numberRows(); ++i) {
313  int bunch;
314  float initbunchlumi;
315  qResults.fillVariableFromRow("BUNCH", i, bunch);
316  qResults.fillVariableFromRow("INITBUNCHLUMI", i, initbunchlumi);
317 
318  InitTotalLumi += initbunchlumi;
319  InitBunchLumi.push_back(initbunchlumi);
320  }
321 
322  //-> We calculate the relative luminosity for each bunch
323  for (unsigned int i = 0; i < InitBunchLumi.size(); i++) {
324  RelativeBunchLumi.push_back(InitBunchLumi[i] / InitTotalLumi);
325  }
326  }
327  }
328 
329  return RelativeBunchLumi;
330 }

References relativeConstraints::error, l1t::OMDSReader::QueryResults::fillVariableFromRow(), mps_fire::i, l1t::OMDSReader::QueryResults::numberRows(), l1t::OMDSReader::QueryResults::queryFailed(), and TableParser::table.

◆ getWbMAlgoXsecFits()

map< string, WbMTriggerXSecFit > L1TOMDSHelper::getWbMAlgoXsecFits ( int &  error)

Definition at line 89 of file L1TOMDSHelper.cc.

89  {
90  return getWbMTriggerXsecFits("LEVEL1_ALGO_CROSS_SECTION", error);
91 }

References relativeConstraints::error.

◆ getWbMTechXsecFits()

map< string, WbMTriggerXSecFit > L1TOMDSHelper::getWbMTechXsecFits ( int &  error)

Definition at line 94 of file L1TOMDSHelper.cc.

94  {
95  return getWbMTriggerXsecFits("LEVEL1_TECH_CROSS_SECTION", error);
96 }

References relativeConstraints::error.

◆ getWbMTriggerXsecFits()

map< string, WbMTriggerXSecFit > L1TOMDSHelper::getWbMTriggerXsecFits ( std::string  iTable,
int &  error 
)

Definition at line 44 of file L1TOMDSHelper.cc.

44  {
45  map<string, WbMTriggerXSecFit> out;
46  const l1t::OMDSReader::QueryResults qresults;
47  error = NO_ERROR;
48 
49  // Parameters
50  string qSchema = "CMS_WBM";
51 
52  // Fields to retrive in the query
53  vector<string> qStrings;
54  qStrings.push_back("BIT");
55  qStrings.push_back("NAME");
56  qStrings.push_back("PM1"); //Inverse
57  qStrings.push_back("P0"); //Constant
58  qStrings.push_back("P1"); //Linear
59  qStrings.push_back("P2"); //Quadratic
60 
61  l1t::OMDSReader::QueryResults paramResults = m_omdsReader->basicQuery(qStrings, qSchema, iTable, "", qresults);
62 
63  if (paramResults.queryFailed()) {
65  } else {
66  for (int i = 0; i < paramResults.numberRows(); ++i) {
67  WbMTriggerXSecFit tFit;
68  tFit.fitFunction = "[0]/x+[1]+[2]*x+[3]*x*x"; // Fitting function hardcoded for now
69 
70  string tBitName;
71 
72  paramResults.fillVariableFromRow("BIT", i, tFit.bitNumber);
73  paramResults.fillVariableFromRow("NAME", i, tBitName);
74  paramResults.fillVariableFromRow("PM1", i, tFit.pm1);
75  paramResults.fillVariableFromRow("P0", i, tFit.p0);
76  paramResults.fillVariableFromRow("P1", i, tFit.p1);
77  paramResults.fillVariableFromRow("P2", i, tFit.p2);
78 
79  tFit.bitName = tBitName;
80 
81  out[tBitName] = tFit;
82  }
83  }
84 
85  return out;
86 }

References WbMTriggerXSecFit::bitName, WbMTriggerXSecFit::bitNumber, relativeConstraints::error, l1t::OMDSReader::QueryResults::fillVariableFromRow(), WbMTriggerXSecFit::fitFunction, mps_fire::i, l1t::OMDSReader::QueryResults::numberRows(), MillePedeFileConverter_cfg::out, WbMTriggerXSecFit::p0, WbMTriggerXSecFit::p1, WbMTriggerXSecFit::p2, WbMTriggerXSecFit::pm1, and l1t::OMDSReader::QueryResults::queryFailed().

Member Data Documentation

◆ m_omdsReader

l1t::OMDSReader* L1TOMDSHelper::m_omdsReader
private

Definition at line 74 of file L1TOMDSHelper.h.

◆ m_oracleDB

std::string L1TOMDSHelper::m_oracleDB
private

Definition at line 71 of file L1TOMDSHelper.h.

◆ m_pathCondDB

std::string L1TOMDSHelper::m_pathCondDB
private

Definition at line 72 of file L1TOMDSHelper.h.

l1t::OMDSReader::QueryResults
Definition: OMDSReader.h:49
L1TOMDSHelper::m_omdsReader
l1t::OMDSReader * m_omdsReader
Definition: L1TOMDSHelper.h:74
BeamConfiguration::m_valid
bool m_valid
Definition: L1TOMDSHelper.h:36
mps_fire.i
i
Definition: mps_fire.py:428
l1t::OMDSReader
Definition: OMDSReader.h:42
WbMTriggerXSecFit::bitNumber
float bitNumber
Definition: L1TOMDSHelper.h:46
l1t::OMDSReader::singleAttribute
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:259
WbMTriggerXSecFit::p0
float p0
Definition: L1TOMDSHelper.h:47
WbMTriggerXSecFit::p2
float p2
Definition: L1TOMDSHelper.h:47
L1TOMDSHelper::WARNING_DB_QUERY_FAILED
Definition: L1TOMDSHelper.h:52
relativeConstraints.error
error
Definition: relativeConstraints.py:53
L1TOMDSHelper::NO_ERROR
Definition: L1TOMDSHelper.h:52
L1TOMDSHelper::m_pathCondDB
std::string m_pathCondDB
Definition: L1TOMDSHelper.h:72
l1t::OMDSReader::QueryResults::fillVariableFromRow
bool fillVariableFromRow(const std::string &columnName, int rowNumber, T &outputVariable) const
Definition: OMDSReader.h:279
WbMTriggerXSecFit::fitFunction
TString fitFunction
Definition: L1TOMDSHelper.h:45
l1t::OMDSReader::connect
void connect(const std::string &connectString, const std::string &authenticationPath)
Definition: OMDSReader.cc:43
L1TOMDSHelper::getWbMTriggerXsecFits
std::map< std::string, WbMTriggerXSecFit > getWbMTriggerXsecFits(std::string iTable, int &error)
Definition: L1TOMDSHelper.cc:44
cond::persistency::Session::connectionString
std::string connectionString()
Definition: Session.cc:216
WbMTriggerXSecFit::p1
float p1
Definition: L1TOMDSHelper.h:47
l1t::OMDSReader::QueryResults::numberRows
int numberRows() const
Definition: OMDSReader.h:60
BeamConfiguration::nCollidingBunches
int nCollidingBunches
Definition: L1TOMDSHelper.h:37
L1TOMDSHelper::WARNING_DB_CONN_FAILED
Definition: L1TOMDSHelper.h:52
l1t::OMDSReader::basicQuery
const QueryResults basicQuery(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &tableName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="")
Definition: OMDSReader.cc:75
WbMTriggerXSecFit::bitName
TString bitName
Definition: L1TOMDSHelper.h:44
BeamConfiguration
Definition: L1TOMDSHelper.h:19
WbMTriggerXSecFit::pm1
float pm1
Definition: L1TOMDSHelper.h:47
l1t::OMDSReader::QueryResults::queryFailed
bool queryFailed() const
Definition: OMDSReader.h:59
WbMTriggerXSecFit
Definition: L1TOMDSHelper.h:43
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
BeamConfiguration::beam2
std::vector< bool > beam2
Definition: L1TOMDSHelper.h:39
l1t::DataManager::dbSession
cond::persistency::Session dbSession()
Definition: DataManager.h:26
TableParser.table
table
Definition: TableParser.py:111
L1TOMDSHelper::WARNING_DB_INCORRECT_NBUNCHES
Definition: L1TOMDSHelper.h:52
L1TOMDSHelper::m_oracleDB
std::string m_oracleDB
Definition: L1TOMDSHelper.h:71
BeamConfiguration::beam1
std::vector< bool > beam1
Definition: L1TOMDSHelper.h:38