ATLAS Offline Software
Loading...
Searching...
No Matches
StatusFlagCOOL.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4
5// **********************************************************************
6// $Id: StatusFlagCOOL.cxx,v 1.6 2009-02-13 12:32:11 ponyisi Exp $
7// **********************************************************************
8
10
11//CORAL API include files
12#include "CoralBase/Attribute.h"
13
14//COOL API include files (CoolKernel)
15#include "CoolKernel/IDatabase.h"
16#include "CoolKernel/IFolder.h"
17#include "CoolKernel/IObjectIterator.h"
18#include "CoolKernel/IObject.h"
19#include "CoolKernel/Record.h"
20#include "CoolKernel/Exception.h"
21#include "CoolKernel/IDatabaseSvc.h"
22#include "CoolKernel/StorageType.h"
23
25
26namespace dqutils {
28 StatusFlagCOOL (const std::string& dbStr, const std::string& folderStr, int runS, int lumiS, int runU, int lumiU)
29 : StatusFlagCOOLBase(dbStr, folderStr, runS, lumiS, runU, lumiU) {
30 }
31
33 StatusFlagCOOL (int runS, int lumiS, int runU, int lumiU)
34 : StatusFlagCOOLBase(runS, lumiS, runU, lumiU) {
35 }
36
39 : StatusFlagCOOLBase() {
40 }
41
42 cool::RecordSpecification
45 //std::cout << "Preparing RecordSpecification" << std::endl;
46 cool::RecordSpecification spec;
47 spec.extend("Code", cool::StorageType::Int32);
48 spec.extend("deadFrac", cool::StorageType::Float);
49 spec.extend("Thrust", cool::StorageType::Float);
50 if (!(spec == m_coolFolder->payloadSpecification())) {
51 std::cout << "ERROR Source and destination folder specifications differ." << std::endl;
52 }
53 return spec;
54 }
55
56 coral::AttributeList
58 createPayload(int colourCode, float dfrac, float thrust, const cool::RecordSpecification& spec) {
59 coral::AttributeList payload = cool::Record(spec).attributeList();
60 payload["Code"].data<cool::Int32>() = colourCode;
61 payload["deadFrac"].data<cool::Float>() = dfrac;
62 payload["Thrust"].data<cool::Float>() = thrust;
63 //std::cout << "Creating payload: ";
64 //std::cout << "[Code : " << colourCode << "],";
65 //std::cout << "[DeadFraction : " << dfrac << "],";
66 //std::cout << "[Thrust : " << thrust << "]" << std::endl;
67 return payload;
68 }
69
70 void
72 insert(cool::ChannelId channelId, int code, float dfrac, float thrust, const std::string& tag_name) {
73 try {
74 cool::RecordSpecification spec = this->createSpec();
75 coral::AttributeList payload = this->createPayload(code, dfrac, thrust, spec);
76 //std::cout << "Trying to store payload [channel " << this->getCoolFolder()->channelName(channelId) <<" ("<<
77 // channelId <<")]...";
78 insert_helper(channelId, payload, tag_name);
79 }
80 catch (cool::Exception& e) {
81 std::cout << "Unknown exception caught!" << e.what() << std::endl;
82 }
83 }
84
85 void
87 insert(std::string channelName, int code, float dfrac, float thrust, const std::string& tag_name) {
88 try {
89 this->insert(this->getCoolFolder()->channelId(channelName), code, dfrac, thrust, tag_name);
90 }
91 catch (cool::Exception& e) {
92 std::cout << "Unknown exception caught!" << e.what() << std::endl;
93 }
94 }
95} //namespace dqutils
ClassImp(dqutils::StatusFlagCOOL) namespace dqutils
cool::IFolderPtr getCoolFolder()
void insert_helper(cool::ChannelId channelId, coral::AttributeList &payload, const std::string &tag_name)
cool::RecordSpecification createSpec()
void insert(cool::ChannelId channelId, int code, float dfrac, float thrust, const std::string &tag_name)
coral::AttributeList createPayload(int colourCode, float dfrac, float thrust, const cool::RecordSpecification &spec)