2 #include "RelationalAccess/ISchema.h" 3 #include "RelationalAccess/IQuery.h" 4 #include "RelationalAccess/ICursor.h" 5 #include "CoralBase/AttributeList.h" 6 #include "CoralBase/Attribute.h" 7 #include "CoralBase/AttributeSpecification.h" 13 #include <boost/algorithm/string.hpp> 14 #include <boost/tokenizer.hpp> 20 unsigned long long result=0;
21 std::vector<unsigned long long> luminormids;
22 coral::IQuery* qHandle=schema.newQuery();
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);
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>());
41 std::vector<unsigned long long>::iterator resultIt;
42 for(resultIt=luminormids.begin();resultIt!=luminormids.end();++resultIt){
52 coral::IQuery* qHandle=schema.newQuery();
54 qHandle->addToOutputList(
"DATA_ID");
55 qHandle->addToOutputList(
"ENTRY_NAME");
56 coral::AttributeList qCondition;
63 qCondition[
"lumitype"].data<
std::string>()=lumitypeStr;
65 qConditionStr+=
" AND ISTYPEDEFAULT=:istypedefault";
66 qCondition.extend(
"istypedefault",
typeid(
unsigned int));
67 qCondition[
"istypedefault"].data<
unsigned int>()=1;
69 qHandle->setCondition(qConditionStr,qCondition);
70 coral::AttributeList qResult;
71 qResult.extend(
"DATA_ID",
typeid(
unsigned long long));
73 qHandle->defineOutput(qResult);
75 coral::ICursor& cursor=qHandle->execute();
76 while( cursor.next() ){
77 const coral::AttributeList& row=cursor.currentRow();
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));
83 if(resultMap[normname]<normid){
84 resultMap.insert(std::make_pair(normname,normid));
89 std::cout<<
"database error in NormDML::normIdByType "<<er.what()<<std::endl;
100 std::map< unsigned int,lumi::NormDML::normData >&
result){
102 coral::IQuery* qHandle=schema.newQuery();
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()){
116 result.insert(std::make_pair(since,thisnorm));
119 if(!row[
"AMODETAG"].isNull()){
122 if(!row[
"NOMINALEGEV"].isNull()){
123 result[
since].beamegev=row[
"NOMINALEGEV"].data<
unsigned int>();
126 std::vector<std::string> 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);
136 float param=row[paramName].data<
float>();
137 result[
since].coefficientmap.insert(std::make_pair(paramName,param));
145 std::vector<std::string>& correctorParams){
148 boost::split(correctorParams,cleancorrectorStr,boost::is_any_of(
":,"));
152 typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
153 boost::char_separator<char> sep(
"[(,)] ");
154 tokenizer tokens(afterglowStr,sep);
158 for(tokenizer::iterator tok_iter=tokens.begin();tok_iter != tokens.end(); ++tok_iter){
162 std::stringstream strStream(valStr);
164 afterglowmap.insert(std::make_pair(threshold,val));
166 thresholdStr=*(tok_iter);
167 std::stringstream strStream(thresholdStr);
static void trim(std::string &s)
void parseAfterglows(const std::string &afterglowStr, std::map< unsigned int, float > &afterglowmap)
static const std::string luminormv2dataTableName()
void parseLumiCorrector(const std::string &correctorStr, std::vector< std::string > &correctorParams)
normname
check normtag and get norm values if required
void normById(const coral::ISchema &schema, unsigned long long normid, std::map< unsigned int, normData > &result)
static const std::string luminormv2TableName()
static std::atomic< unsigned int > counter
void normIdByType(const coral::ISchema &schema, std::map< std::string, unsigned long long > &resultMap, LumiType=HF, bool defaultonly=true)
unsigned long long normIdByName(const coral::ISchema &schema, const std::string &normtagname)