test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

Enumerator
HF 
PIXEL 

Definition at line 35 of file NormDML.h.

Constructor & Destructor Documentation

NormDML::NormDML ( )

Definition at line 15 of file NormDML.cc.

15  {
16 }
lumi::NormDML::~NormDML ( )
inline

Definition at line 37 of file NormDML.h.

37 {}

Member Function Documentation

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 98 of file NormDML.cc.

References lumiNorm::correctorStr, lumi::LumiNames::luminormv2dataTableName(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by LumiCorrectionSource::fillparamcache().

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

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

Referenced by LumiCorrectionSource::fillparamcache().

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

References gather_cfg::cout, edm::hlt::Exception, HF, lumi::LumiNames::luminormv2TableName(), lumiCalc2::normid, lumiCalc2::normname, 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");
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 }
string lumitype
Definition: lumiNorm.py:96
string normname
check normtag and get norm values if required
Definition: lumiCalc2.py:355
int normid
Definition: lumiCalc2.py:356
static const std::string luminormv2TableName()
Definition: LumiNames.cc:23
tuple cout
Definition: gather_cfg.py:121
void NormDML::parseAfterglows ( const std::string &  afterglowStr,
std::map< unsigned int, float > &  afterglowmap 
)

Definition at line 151 of file NormDML.cc.

References counter, cmsHarvester::sep, AlCaHLTBitMon_QueryRunRegistry::string, and dtDQMClient_cfg::threshold.

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

Definition at line 144 of file NormDML.cc.

References split, and AlCaHLTBitMon_QueryRunRegistry::string.

145  {
146  std::string cleancorrectorStr(correctorStr);
147  boost::trim(cleancorrectorStr);
148  boost::split(correctorParams,cleancorrectorStr,boost::is_any_of(":,"));
149 }
list correctorStr
Definition: lumiNorm.py:120
double split
Definition: MVATrainer.cc:139