CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions
lumi::NormDML Class Reference

#include <NormDML.h>

Classes

struct  normData
 

Public Types

enum  LumiType { HF, PIXEL }
 

Public Member Functions

void normById (const coral::ISchema &schema, unsigned long long normid, std::map< unsigned int, normData > &result)
 
 NormDML ()
 
unsigned long long normIdByName (const coral::ISchema &schema, const std::string &normtagname)
 
void normIdByType (const coral::ISchema &schema, std::map< std::string, unsigned long long > &resultMap, LumiType=HF, bool defaultonly=true)
 
void parseAfterglows (const std::string &afterglowStr, std::map< unsigned int, float > &afterglowmap)
 
void parseLumiCorrector (const std::string &correctorStr, std::vector< std::string > &correctorParams)
 
 ~NormDML ()
 

Detailed Description

Definition at line 25 of file NormDML.h.

Member Enumeration Documentation

◆ LumiType

Enumerator
HF 
PIXEL 

Definition at line 35 of file NormDML.h.

Constructor & Destructor Documentation

◆ NormDML()

NormDML::NormDML ( )

Definition at line 15 of file NormDML.cc.

15 {}

◆ ~NormDML()

lumi::NormDML::~NormDML ( )
inline

Definition at line 37 of file NormDML.h.

37 {}

Member Function Documentation

◆ normById()

void NormDML::normById ( const coral::ISchema &  schema,
unsigned long long  normid,
std::map< unsigned int, normData > &  result 
)

select * from luminormsv2data where data_id=normid

Definition at line 97 of file NormDML.cc.

References lumi::LumiNames::luminormv2dataTableName(), mps_fire::result, SiStripBadComponentsDQMServiceTemplate_cfg::since, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by LumiCorrectionSource::fillparamcache().

99  {
101  coral::IQuery* qHandle = schema.newQuery();
102  qHandle->addToTableList(lumi::LumiNames::luminormv2dataTableName());
103  std::string qConditionStr("DATA_ID=:normid ");
104  coral::AttributeList qCondition;
105  qCondition.extend("normid", typeid(unsigned long long));
106  qCondition["normid"].data<unsigned long long>() = normid;
107  qHandle->setCondition(qConditionStr, qCondition);
108  coral::AttributeList qResult;
109  coral::ICursor& cursor = qHandle->execute();
110  while (cursor.next()) {
111  const coral::AttributeList& row = cursor.currentRow();
112  unsigned int since = row["SINCE"].data<unsigned int>();
113  if (result.find(since) == result.end()) {
114  lumi::NormDML::normData thisnorm;
115  result.insert(std::make_pair(since, thisnorm));
116  }
117  const std::string correctorStr = row["CORRECTOR"].data<std::string>();
118  if (!row["AMODETAG"].isNull()) {
119  result[since].amodetag = row["AMODETAG"].data<std::string>();
120  }
121  if (!row["NOMINALEGEV"].isNull()) {
122  result[since].beamegev = row["NOMINALEGEV"].data<unsigned int>();
123  }
124 
125  std::vector<std::string> correctorParams;
126  parseLumiCorrector(correctorStr, correctorParams);
127  result[since].corrfunc = *(correctorParams.begin());
128  for (std::vector<std::string>::iterator corrIt = correctorParams.begin() + 1; corrIt != correctorParams.end();
129  corrIt++) {
130  std::string paramName = boost::to_upper_copy(*corrIt);
131  if (paramName == std::string("AFTERGLOW")) {
132  const std::string afterglowStr = row["AFTERGLOW"].data<std::string>();
133  parseAfterglows(afterglowStr, result[since].afterglows);
134  } else {
135  float param = row[paramName].data<float>();
136  result[since].coefficientmap.insert(std::make_pair(paramName, param));
137  }
138  }
139  }
140  delete qHandle;
141 }
void parseAfterglows(const std::string &afterglowStr, std::map< unsigned int, float > &afterglowmap)
Definition: NormDML.cc:147
static const std::string luminormv2dataTableName()
Definition: LumiNames.cc:10
void parseLumiCorrector(const std::string &correctorStr, std::vector< std::string > &correctorParams)
Definition: NormDML.cc:142

◆ normIdByName()

unsigned long long NormDML::normIdByName ( const coral::ISchema &  schema,
const std::string &  normtagname 
)

select max(DATA_ID) FROM LUMINORMSV2 WHERE ENTRY_NAME=:normname

Definition at line 16 of file NormDML.cc.

References lumi::LumiNames::luminormv2TableName(), mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by LumiCorrectionSource::fillparamcache().

16  {
18  unsigned long long result = 0;
19  std::vector<unsigned long long> luminormids;
20  coral::IQuery* qHandle = schema.newQuery();
21  qHandle->addToTableList(lumi::LumiNames::luminormv2TableName());
22  qHandle->addToOutputList("DATA_ID");
23  if (!normtagname.empty()) {
24  std::string qConditionStr("ENTRY_NAME=:normtagname");
25  coral::AttributeList qCondition;
26  qCondition.extend("normtagname", typeid(std::string));
27  qCondition["normtagname"].data<std::string>() = normtagname;
28  qHandle->setCondition(qConditionStr, qCondition);
29  }
30  coral::AttributeList qResult;
31  qResult.extend("DATA_ID", typeid(unsigned long long));
32  qHandle->defineOutput(qResult);
33  coral::ICursor& cursor = qHandle->execute();
34  while (cursor.next()) {
35  const coral::AttributeList& row = cursor.currentRow();
36  luminormids.push_back(row["DATA_ID"].data<unsigned long long>());
37  }
38  delete qHandle;
39  std::vector<unsigned long long>::iterator resultIt;
40  for (resultIt = luminormids.begin(); resultIt != luminormids.end(); ++resultIt) {
41  if ((*resultIt) > result) {
42  result = *resultIt;
43  }
44  }
45  return result;
46 }
static const std::string luminormv2TableName()
Definition: LumiNames.cc:9

◆ normIdByType()

void NormDML::normIdByType ( const coral::ISchema &  schema,
std::map< std::string, unsigned long long > &  resultMap,
LumiType  lumitype = HF,
bool  defaultonly = true 
)

select max(DATA_ID) FROM LUMINORMSV2 WHERE LUMITYPE=:lumitype and ISTYPEDEFAULT=1

Definition at line 47 of file NormDML.cc.

References gather_cfg::cout, Exception, HF, lumi::LumiNames::luminormv2TableName(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by LumiCorrectionSource::fillparamcache().

50  {
52  coral::IQuery* qHandle = schema.newQuery();
53  qHandle->addToTableList(lumi::LumiNames::luminormv2TableName());
54  qHandle->addToOutputList("DATA_ID");
55  qHandle->addToOutputList("ENTRY_NAME");
56  coral::AttributeList qCondition;
57  std::string qConditionStr("LUMITYPE=:lumitype");
58  qCondition.extend("lumitype", typeid(std::string));
59  std::string lumitypeStr("HF");
60  if (lumitype != lumi::NormDML::HF) {
61  lumitypeStr = "PIXEL";
62  }
63  qCondition["lumitype"].data<std::string>() = lumitypeStr;
64  if (defaultonly) {
65  qConditionStr += " AND ISTYPEDEFAULT=:istypedefault";
66  qCondition.extend("istypedefault", typeid(unsigned int));
67  qCondition["istypedefault"].data<unsigned int>() = 1;
68  }
69  qHandle->setCondition(qConditionStr, qCondition);
70  coral::AttributeList qResult;
71  qResult.extend("DATA_ID", typeid(unsigned long long));
72  qResult.extend("ENTRY_NAME", typeid(std::string));
73  qHandle->defineOutput(qResult);
74  try {
75  coral::ICursor& cursor = qHandle->execute();
76  while (cursor.next()) {
77  const coral::AttributeList& row = cursor.currentRow();
78  const std::string normname = row["ENTRY_NAME"].data<std::string>();
79  unsigned long long normid = row["DATA_ID"].data<unsigned long long>();
80  if (resultMap.find(normname) == resultMap.end()) {
81  resultMap.insert(std::make_pair(normname, normid));
82  } else {
83  if (resultMap[normname] < normid) {
84  resultMap.insert(std::make_pair(normname, normid));
85  }
86  }
87  }
88  } catch (const coral::Exception& er) {
89  std::cout << "database error in NormDML::normIdByType " << er.what() << std::endl;
90  delete qHandle;
91  throw er;
92  } catch (...) {
93  throw;
94  }
95  delete qHandle;
96 }
static const std::string luminormv2TableName()
Definition: LumiNames.cc:9

◆ parseAfterglows()

void NormDML::parseAfterglows ( const std::string &  afterglowStr,
std::map< unsigned int, float > &  afterglowmap 
)

Definition at line 147 of file NormDML.cc.

References counter, AlCaHLTBitMon_QueryRunRegistry::string, remoteMonitoring_LASER_era2018_cfg::threshold, and heppy_batch::val.

147  {
148  typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
149  boost::char_separator<char> sep("[(,)] ");
150  tokenizer tokens(afterglowStr, sep);
151  unsigned int counter = 1;
152  std::string thresholdStr;
153  unsigned int threshold;
154  for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter) {
155  if (counter % 2 == 0) {
156  const std::string& valStr = *(tok_iter);
157  float val = 0.;
158  std::stringstream strStream(valStr);
159  strStream >> val;
160  afterglowmap.insert(std::make_pair(threshold, val));
161  } else {
162  thresholdStr = *(tok_iter);
163  std::stringstream strStream(thresholdStr);
164  strStream >> threshold;
165  }
166  ++counter;
167  }
168 }
static std::atomic< unsigned int > counter

◆ parseLumiCorrector()

void NormDML::parseLumiCorrector ( const std::string &  correctorStr,
std::vector< std::string > &  correctorParams 
)

Definition at line 142 of file NormDML.cc.

References submitPVValidationJobs::split(), AlCaHLTBitMon_QueryRunRegistry::string, and trim().

142  {
143  std::string cleancorrectorStr(correctorStr);
144  boost::trim(cleancorrectorStr);
145  boost::split(correctorParams, cleancorrectorStr, boost::is_any_of(":,"));
146 }
static void trim(std::string &s)