30 coolDbInstance(
const std::string& dbStr,
bool readOnly) {
33 cool::IDatabaseSvc&
dbSvc = this->databaseService();
35 return dbSvc.openDatabase(dbStr.c_str(), readOnly);
37 catch (cool::DatabaseDoesNotExist&) {
38 std::cout <<
"Error! Database does not exist!" << std::endl;
45 coolFolderInstance(
const std::string& folderStr) {
47 cool::IFolderPtr
folder = m_coolDb->getFolder(folderStr.c_str());
51 catch (cool::FolderNotFound&) {
52 std::cout <<
"Error! Folder '" << folderStr <<
"' does not exist!" << std::endl;
58 CoolRpc::coolDbFolder(
const std::string& dbStr,
const std::string& folderStr) {
59 m_coolDb = this->coolDbInstance(dbStr,
false);
60 m_coolFolder = this->coolFolderInstance(folderStr);
65 setSince(cool::Int64
run, cool::Int64
lumi) {
71 setUntil(cool::Int64 iovmax, cool::Int64
lumi) {
72 m_until = ((iovmax << 32) +
lumi);
77 setIOV(cool::Int64 runS, cool::Int64 lumiS, cool::Int64 runU, cool::Int64 lumiU) {
78 this->setSince(runS, lumiS);
79 this->setUntil(runU, lumiU);
85 setIOV(cool::Int64
run) {
86 this->setSince(
run, 0);
87 this->setUntil(
run, 4294967295U);
94 cool::Int64 runS = m_since >> 32;
95 cool::Int64 lumiS = m_since - (runS << 32);
96 cool::Int64 runU = m_until >> 32;
97 cool::Int64 lumiU = m_until - (runU << 32);
98 std::cout <<
"Using IOVrange [(" << runS <<
"," << lumiS <<
"),(" << runU <<
"," << lumiU <<
")] " <<
"[" <<
99 m_since <<
"," << m_until <<
"]" << std::endl;
104 CoolOpen(
const std::string& dbStr) {
105 m_coolDb = this->coolDbInstance(dbStr,
false);
110 m_coolDb->closeDatabase();
111 std::cout <<
"Cleared!" << std::endl;
114 cool::RecordSpecification
118 cool::RecordSpecification
spec;
119 spec.extend(
"recEta", cool::StorageType::String4k);
120 spec.extend(
"detEta", cool::StorageType::String4k);
121 spec.extend(
"recPhi1", cool::StorageType::String4k);
122 spec.extend(
"recPhi2", cool::StorageType::String4k);
123 spec.extend(
"detPhi1", cool::StorageType::String4k);
124 spec.extend(
"detPhi2", cool::StorageType::String4k);
125 m_coolFolder = this->coolFolderInstance(
"/OFFLINE/OFFLINE_DQMF");
126 if (!(
spec == m_coolFolder->payloadSpecification())) {
127 std::cout <<
"ERROR Source and destination folder specifications differ." << std::endl;
133 cool::RecordSpecification
135 createSpecDataCondDB() {
137 cool::RecordSpecification
spec;
138 spec.extend(
"PanelRes", cool::StorageType::String255);
139 spec.extend(
"StripStatus", cool::StorageType::String4k);
140 m_coolFolder = this->coolFolderInstance(
"/OFFLINE/FINAL");
141 if (!(
spec == m_coolFolder->payloadSpecification())) {
142 std::cout <<
"ERROR Source and destination folder specifications differ." << std::endl;
150 createPayloadData(
const std::string& recEta,
151 const std::string& detEta,
152 const std::string& recPhi1,
153 const std::string& recPhi2,
154 const std::string& detPhi1,
155 const std::string& detPhi2,
156 const cool::RecordSpecification&
spec) {
161 payload[
"recEta"].data<cool::String4k>() = recEta;
162 payload[
"detEta"].data<cool::String4k>() = detEta;
163 payload[
"recPhi1"].data<cool::String4k>() = recPhi1;
165 payload[
"recPhi2"].data<cool::String4k>() = recPhi2;
166 payload[
"detPhi1"].data<cool::String4k>() = detPhi1;
167 payload[
"detPhi2"].data<cool::String4k>() = detPhi2;
177 createPayloadDataCondDB(
const std::string& PanelRes,
const std::string& StripStatus,
178 const cool::RecordSpecification&
spec) {
183 payload[
"PanelRes"].data<cool::String255>() = PanelRes;
184 payload[
"StripStatus"].data<cool::String4k>() = StripStatus;
193 cool::IObjectIteratorPtr
objects = m_coolFolder->browseObjects(m_since, m_until,
selection,
"");
195 const cool::IObject& element =
objects->currentRef();
196 std::cout << element << std::endl;
199 catch (cool::Exception&
e) {
200 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
201 std::cout <<
" Inside create payload" << std::endl;
211 cool::IObjectIteratorPtr
objects = m_coolFolder->browseObjects(m_since, m_until,
selection,
"");
213 const cool::IObject& element =
objects->currentRef();
217 catch (cool::Exception&
e) {
218 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
225 dumpCode(
const std::string& channelName) {
226 std::string
result = this->dumpField(this->getCoolFolder()->
channelId(channelName.c_str()),
"Code");
240 insert_withTag(cool::Int64
run,
242 const std::string& recEta,
243 const std::string& detEta,
244 const std::string& recPhi1,
245 const std::string& recPhi2,
246 const std::string& detPhi1,
247 const std::string& detPhi2,
251 cool::RecordSpecification
spec = this->createSpecData();
253 cool::ValidityKey since_u = (
run << 32);
254 cool::ValidityKey until_u = (
run + 1) << 32;
255 m_coolFolder->storeObject(since_u, until_u, cool::Record(
259 catch (cool::Exception&
e) {
260 std::cout <<
" Inside create insert" << std::endl;
261 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
267 insertCondDB_withTag(cool::Int64
run,
269 const std::string& PanelRes,
270 const std::string& StripStatus,
274 cool::RecordSpecification
spec = this->createSpecDataCondDB();
276 cool::ValidityKey since_u = (
run << 32) * 0;
277 cool::ValidityKey until_u = (
run + 1) << 32;
278 m_coolFolder->storeObject(since_u, until_u, cool::Record(
282 catch (cool::Exception&
e) {
283 std::cout <<
" Inside create insert" << std::endl;
284 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
290 insert(cool::Int64
run,
292 const std::string& recEta,
293 const std::string& detEta,
294 const std::string& recPhi1,
295 const std::string& recPhi2,
296 const std::string& detPhi1,
297 const std::string& detPhi2) {
298 std::cout <<
"Trying to store payload [channel " << std::endl;
300 cool::RecordSpecification
spec = this->createSpecData();
302 cool::ValidityKey since_u = (
run << 32);
303 cool::ValidityKey until_u = (
run + 1) << 32;
304 m_coolFolder->storeObject(since_u, until_u, cool::Record(m_coolFolder->payloadSpecification(),
payload),
306 std::cout <<
"stored! without Tag" << std::endl;
308 catch (cool::Exception&
e) {
309 std::cout <<
" Inside create insert" << std::endl;
310 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
317 return this->m_coolFolder;
323 return this->m_coolDb;