CMS 3D CMS Logo

List of all members | Public Member Functions
lumi::HLTConf2DB Class Reference
Inheritance diagram for lumi::HLTConf2DB:
lumi::DataPipe

Public Member Functions

const std::string dataType () const override
 
 HLTConf2DB (const std::string &dest)
 
unsigned long long retrieveData (unsigned int) override
 
const std::string sourceType () const override
 
 ~HLTConf2DB () override
 
- Public Member Functions inherited from lumi::DataPipe
 DataPipe (const std::string &)
 
std::string getAuthPath () const
 
std::string getMode () const
 
float getNorm () const
 
std::string getSource () const
 
void setAuthPath (const std::string &authpath)
 
void setMode (const std::string &mode)
 
void setNoCheckingStableBeam ()
 
void setNorm (float norm)
 
void setNoValidate ()
 
void setSource (const std::string &source)
 
virtual ~DataPipe ()
 

Additional Inherited Members

- Protected Attributes inherited from lumi::DataPipe
std::string m_authpath
 
std::string m_dest
 
std::string m_mode
 
bool m_nocheckingstablebeam
 
float m_norm
 
bool m_novalidate
 
std::string m_source
 

Detailed Description

Definition at line 31 of file HLTConf2DB.cc.

Constructor & Destructor Documentation

lumi::HLTConf2DB::HLTConf2DB ( const std::string &  dest)
explicit

Definition at line 42 of file HLTConf2DB.cc.

42 : DataPipe(dest) {}
DataPipe(const std::string &)
Definition: DataPipe.cc:2
lumi::HLTConf2DB::~HLTConf2DB ( )
override

Definition at line 228 of file HLTConf2DB.cc.

References DEFINE_EDM_PLUGIN.

228 {}

Member Function Documentation

const std::string lumi::HLTConf2DB::dataType ( ) const
overridevirtual

Implements lumi::DataPipe.

Definition at line 226 of file HLTConf2DB.cc.

226 { return "HLTConf"; }
unsigned long long lumi::HLTConf2DB::retrieveData ( unsigned int  runnumber)
overridevirtual

select paths.name,stringparamvalues.value from stringparamvalues,paths,parameters,superidparameterassoc,modules,moduletemplates,pathmoduleassoc,configurationpathassoc,configurations where parameters.paramid=stringparamvalues.paramid and superidparameterassoc.paramid=parameters.paramid and modules.superid=superidparameterassoc.superid and moduletemplates.superid=modules.templateid and pathmoduleassoc.moduleid=modules.superid and paths.pathid=pathmoduleassoc.pathid and configurationpathassoc.pathid=paths.pathid and configurations.configid=configurationpathassoc.configid and moduletemplates.name='HLTLevel1GTSeed' and parameters.name='L1SeedsLogicalExpression' and configurations.configid=1905;

Implements lumi::DataPipe.

Definition at line 43 of file HLTConf2DB.cc.

References gather_cfg::cout, Exception, lumi::DataPipe::m_authpath, lumi::DataPipe::m_dest, lumi::DataPipe::m_source, q1, alignCSCRings::s, lumi::DBConfig::setAuthentication(), AlCaHLTBitMon_QueryRunRegistry::string, and lumi::LumiNames::trghltMapTableName().

43  {
44  std::string runinfoschema("CMS_RUNINFO");
45  //std::string hltschema("CMS_HLT_V0");
46  std::string hltschema("CMS_HLT");
47  std::string runsessiontable("RUNSESSION_PARAMETER");
48  //
49  //must login as cms_hlt_r
50  coral::ConnectionService* svc = new coral::ConnectionService;
51  lumi::DBConfig dbconf(*svc);
52  if (!m_authpath.empty()) {
53  dbconf.setAuthentication(m_authpath);
54  }
55  //std::cout<<"m_source "<<m_source<<std::endl;
56  coral::ISessionProxy* srcsession = svc->connect(m_source, coral::ReadOnly);
57  coral::ITypeConverter& tpc = srcsession->typeConverter();
58  tpc.setCppTypeForSqlType("unsigned int", "NUMBER(38)");
59  //
60  //select string_value from CMS_RUNINFO.runsession_parameter where name='CMS.LVL0:HLT_KEY_DESCRIPTION' and runnumber=xx;
61  //
62  std::string hltkey("");
63  std::vector<std::pair<std::string, std::string> > hlt2l1map;
64  hlt2l1map.reserve(200);
65  try {
66  srcsession->transaction().start(true);
67  coral::ISchema& runinfoSchemaHandle = srcsession->schema(runinfoschema);
68  if (!runinfoSchemaHandle.existsTable(runsessiontable)) {
69  throw lumi::Exception("missing runsession table", "retrieveData", "HLTConf2DB");
70  }
71  coral::AttributeList rfBindVariableList;
72  rfBindVariableList.extend("name", typeid(std::string));
73  rfBindVariableList.extend("runnumber", typeid(unsigned int));
74  rfBindVariableList["name"].data<std::string>() = std::string("CMS.LVL0:HLT_KEY_DESCRIPTION");
75  rfBindVariableList["runnumber"].data<unsigned int>() = runnumber;
76  coral::IQuery* kq = runinfoSchemaHandle.newQuery();
77  coral::AttributeList runinfoOut;
78  runinfoOut.extend("STRING_VALUE", typeid(std::string));
79  kq->addToTableList(runsessiontable);
80  kq->setCondition("NAME = :name AND RUNNUMBER = :runnumber", rfBindVariableList);
81  kq->addToOutputList("STRING_VALUE");
82  kq->defineOutput(runinfoOut);
83  coral::ICursor& kcursor = kq->execute();
84  unsigned int s = 0;
85  while (kcursor.next()) {
86  const coral::AttributeList& row = kcursor.currentRow();
87  hltkey = row["STRING_VALUE"].data<std::string>();
88  ++s;
89  }
90  if (s == 0 || hltkey.empty()) {
91  kcursor.close();
92  delete kq;
93  srcsession->transaction().rollback();
94  throw lumi::Exception(std::string("requested run has no or invalid hltkey"), "retrieveData", "TRG2DB");
95  }
96  if (s > 1) {
97  kcursor.close();
98  delete kq;
99  srcsession->transaction().rollback();
100  throw lumi::Exception(std::string("requested run has multile hltkey"), "retrieveData", "TRG2DB");
101  }
102  } catch (const coral::Exception& er) {
103  std::cout << "source runinfo database problem " << er.what() << std::endl;
104  srcsession->transaction().rollback();
105  delete srcsession;
106  delete svc;
107  throw er;
108  }
109  coral::ISchema& confSchemaHandle = srcsession->nominalSchema();
110  try {
111  //srcsession->transaction().start(true);
112  if (!confSchemaHandle.existsTable("PATHS") || !confSchemaHandle.existsTable("STRINGPARAMVALUES") ||
113  !confSchemaHandle.existsTable("PARAMETERS") || !confSchemaHandle.existsTable("SUPERIDPARAMETERASSOC") ||
114  !confSchemaHandle.existsTable("MODULES") || !confSchemaHandle.existsTable("MODULETEMPLATES") ||
115  !confSchemaHandle.existsTable("PATHMODULEASSOC") || !confSchemaHandle.existsTable("CONFIGURATIONPATHASSOC") ||
116  !confSchemaHandle.existsTable("CONFIGURATIONS")) {
117  throw lumi::Exception("missing hlt conf tables", "retrieveData", "HLTConf2DB");
118  }
119  coral::AttributeList q1BindVariableList;
120  q1BindVariableList.extend("hltseed", typeid(std::string));
121  q1BindVariableList.extend("l1seedexpr", typeid(std::string));
122  q1BindVariableList.extend("hltkey", typeid(std::string));
123  q1BindVariableList["hltseed"].data<std::string>() = std::string("HLTLevel1GTSeed");
124  q1BindVariableList["l1seedexpr"].data<std::string>() = std::string("L1SeedsLogicalExpression");
125  q1BindVariableList["hltkey"].data<std::string>() = hltkey;
126  coral::IQuery* q1 = confSchemaHandle.newQuery();
127  q1->addToOutputList("PATHS.NAME", "hltpath");
128  q1->addToOutputList("STRINGPARAMVALUES.VALUE", "l1expression");
129 
130  q1->addToTableList("PATHS");
131  q1->addToTableList("STRINGPARAMVALUES");
132  q1->addToTableList("PARAMETERS");
133  q1->addToTableList("SUPERIDPARAMETERASSOC");
134  q1->addToTableList("MODULES");
135  q1->addToTableList("MODULETEMPLATES");
136  q1->addToTableList("PATHMODULEASSOC");
137  q1->addToTableList("CONFIGURATIONPATHASSOC");
138  q1->addToTableList("CONFIGURATIONS");
139 
140  q1->setCondition(
141  "PARAMETERS.PARAMID=STRINGPARAMVALUES.PARAMID and SUPERIDPARAMETERASSOC.PARAMID=PARAMETERS.PARAMID and "
142  "MODULES.SUPERID=SUPERIDPARAMETERASSOC.SUPERID and MODULETEMPLATES.SUPERID=MODULES.TEMPLATEID and "
143  "PATHMODULEASSOC.MODULEID=MODULES.SUPERID and PATHS.PATHID=PATHMODULEASSOC.PATHID and "
144  "CONFIGURATIONPATHASSOC.PATHID=PATHS.PATHID and CONFIGURATIONS.CONFIGID=CONFIGURATIONPATHASSOC.CONFIGID and "
145  "MODULETEMPLATES.NAME = :hltseed and PARAMETERS.NAME = :l1seedexpr and CONFIGURATIONS.CONFIGDESCRIPTOR = "
146  ":hltkey",
147  q1BindVariableList);
148 
152  coral::ICursor& cursor1 = q1->execute();
153  while (cursor1.next()) {
154  const coral::AttributeList& row = cursor1.currentRow();
155  std::string hltpath = row["hltpath"].data<std::string>();
156  std::string l1expression = row["l1expression"].data<std::string>();
157  hlt2l1map.push_back(std::make_pair(hltpath, l1expression));
158  }
159  cursor1.close();
160  delete q1;
161  } catch (const coral::Exception& er) {
162  std::cout << "database problem with source hlt confdb" << er.what() << std::endl;
163  srcsession->transaction().rollback();
164  delete srcsession;
165  throw er;
166  }
167  srcsession->transaction().commit();
168  delete srcsession;
169  std::vector<std::pair<std::string, std::string> >::const_iterator mIt;
170  std::vector<std::pair<std::string, std::string> >::const_iterator mBeg = hlt2l1map.begin();
171  std::vector<std::pair<std::string, std::string> >::const_iterator mEnd = hlt2l1map.end();
172 
173  coral::ISessionProxy* destsession = svc->connect(m_dest, coral::Update);
174  try {
175  //check if hltkey already exists
176  destsession->transaction().start(true);
177  bool hltkeyExists = false;
178  coral::AttributeList kQueryBindList;
179  kQueryBindList.extend("hltkey", typeid(std::string));
180  coral::IQuery* kQuery = destsession->nominalSchema().tableHandle(LumiNames::trghltMapTableName()).newQuery();
181  kQuery->setCondition("HLTKEY =:hltkey", kQueryBindList);
182  kQueryBindList["hltkey"].data<std::string>() = hltkey;
183  coral::ICursor& kResult = kQuery->execute();
184  while (kResult.next()) {
185  hltkeyExists = true;
186  }
187  if (hltkeyExists) {
188  std::cout << "hltkey " << hltkey << " already registered , do nothing" << std::endl;
189  destsession->transaction().commit();
190  delete kQuery;
191  delete svc;
192  return 0;
193  }
194  destsession->transaction().commit();
195  destsession->transaction().start(false);
196  coral::ISchema& destschema = destsession->nominalSchema();
197  coral::ITable& hltconftable = destschema.tableHandle(LumiNames::trghltMapTableName());
198  coral::AttributeList hltconfData;
199  hltconfData.extend<std::string>("HLTKEY");
200  hltconfData.extend<std::string>("HLTPATHNAME");
201  hltconfData.extend<std::string>("L1SEED");
202  coral::IBulkOperation* hltconfInserter = hltconftable.dataEditor().bulkInsert(hltconfData, 200);
203  hltconfData["HLTKEY"].data<std::string>() = hltkey;
204  std::string& hltpathname = hltconfData["HLTPATHNAME"].data<std::string>();
205  std::string& l1seedname = hltconfData["L1SEED"].data<std::string>();
206  for (mIt = mBeg; mIt != mEnd; ++mIt) {
207  hltpathname = mIt->first;
208  l1seedname = mIt->second;
209  hltconfInserter->processNextIteration();
210  //std::cout<<mIt->first<<" "<<mIt->second<<std::endl;
211  }
212  hltconfInserter->flush();
213  delete hltconfInserter;
214  destsession->transaction().commit();
215  } catch (const coral::Exception& er) {
216  std::cout << "database problem " << er.what() << std::endl;
217  destsession->transaction().rollback();
218  delete destsession;
219  delete svc;
220  throw er;
221  }
222  delete destsession;
223  delete svc;
224  return 0;
225  }
std::string m_dest
Definition: DataPipe.h:27
std::string m_source
Definition: DataPipe.h:28
double q1[4]
Definition: TauolaWrapper.h:87
static const std::string trghltMapTableName()
Definition: LumiNames.cc:19
std::string m_authpath
Definition: DataPipe.h:29
const std::string lumi::HLTConf2DB::sourceType ( ) const
overridevirtual

Implements lumi::DataPipe.

Definition at line 227 of file HLTConf2DB.cc.

227 { return "DB"; }