31 coolDbInstance(
const std::string& dbStr,
bool readOnly) {
33 std::cout <<
"Opening database '" << dbStr <<
"'...";
34 cool::IDatabaseSvc&
dbSvc = this->databaseService();
35 std::cout <<
"done." << std::endl;
36 return dbSvc.openDatabase(dbStr.c_str(), readOnly);
38 catch (cool::DatabaseDoesNotExist&) {
39 std::cout <<
"Error! Database does not exist!" << std::endl;
46 coolFolderInstance(
const std::string& folderStr) {
48 cool::IFolderPtr
folder = m_coolDb->getFolder(folderStr.c_str());
52 catch (cool::FolderNotFound&) {
53 std::cout <<
"Error! Folder '" << folderStr <<
"' does not exist!" << std::endl;
59 CoolTgc::coolDbFolder(
const std::string& dbStr,
const std::string& folderStr) {
60 m_coolDb = this->coolDbInstance(dbStr,
false);
61 m_coolFolder = this->coolFolderInstance(folderStr);
66 setSince(cool::Int64
run, cool::Int64
lumi) {
72 setUntil(cool::Int64
run, cool::Int64
lumi) {
78 setIOV(cool::Int64 runS, cool::Int64 lumiS, cool::Int64 runU, cool::Int64 lumiU) {
79 this->setSince(runS, lumiS);
80 this->setUntil(runU, lumiU);
86 setIOV(cool::Int64
run) {
87 this->setSince(
run, 0);
88 this->setUntil(
run, 4294967295U);
95 cool::Int64 runS = m_since >> 32;
96 cool::Int64 lumiS = m_since - (runS << 32);
97 cool::Int64 runU = m_until >> 32;
98 cool::Int64 lumiU = m_until - (runU << 32);
99 std::cout <<
"Using IOVrange [(" << runS <<
"," << lumiS <<
"),(" << runU <<
"," << lumiU <<
")] " <<
"[" <<
100 m_since <<
"," << m_until <<
"]" << std::endl;
105 CoolOpen(
const std::string& dbStr) {
106 m_coolDb = this->coolDbInstance(dbStr,
false);
111 m_coolDb->closeDatabase();
112 std::cout <<
"Cleared!" << std::endl;
115 cool::RecordSpecification
117 createSpecDataDead() {
119 cool::RecordSpecification
spec;
120 spec.extend(
"Chamber_Name", cool::StorageType::String255);
121 spec.extend(
"Dead_multilayer", cool::StorageType::String255);
122 spec.extend(
"Dead_tube", cool::StorageType::String4k);
124 m_coolFolder = this->coolFolderInstance(
"/OFFLINE/DQMFOFFLINE/DQMFOFFLINE_DEAD");
125 if (!(
spec == m_coolFolder->payloadSpecification())) {
126 std::cout <<
"ERROR Source and destination folder specifications differ." << std::endl;
134 createPayloadDataDead(
const std::string& ChamberName,
135 const std::string& DeadMultilayer,
136 const std::string& DeadTube,
137 const cool::RecordSpecification&
spec) {
142 payload[
"Chamber_Name"].data<cool::String255>() = ChamberName;
143 payload[
"Dead_multilayer"].data<cool::String255>() = DeadMultilayer;
144 payload[
"Dead_tube"].data<cool::String4k>() = DeadTube;
151 cool::RecordSpecification
153 createSpecDataNoisy() {
155 cool::RecordSpecification
spec;
156 spec.extend(
"Chamber_Name", cool::StorageType::String255);
157 spec.extend(
"Noisy_multilayer", cool::StorageType::String255);
158 spec.extend(
"Noisy_tube", cool::StorageType::String4k);
160 m_coolFolder = this->coolFolderInstance(
"/OFFLINE/DQMFOFFLINE/DQMFOFFLINE_NOISY");
161 if (!(
spec == m_coolFolder->payloadSpecification())) {
162 std::cout <<
"ERROR Source and destination folder specifications differ." << std::endl;
170 createPayloadDataNoisy(
const std::string& ChamberName,
171 const std::string& NoisyMultilayer,
172 const std::string& NoisyTube,
173 const cool::RecordSpecification&
spec) {
178 payload[
"Chamber_Name"].data<cool::String255>() = ChamberName;
179 payload[
"Noisy_multilayer"].data<cool::String255>() = NoisyMultilayer;
180 payload[
"Noisy_tube"].data<cool::String4k>() = NoisyTube;
192 cool::IObjectIteratorPtr
objects = m_coolFolder->browseObjects(m_since, m_until,
selection,
"");
194 const cool::IObject& element =
objects->currentRef();
195 std::cout << element << std::endl;
198 catch (cool::Exception&
e) {
199 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
200 std::cout <<
" dentro create payload" << std::endl;
210 cool::IObjectIteratorPtr
objects = m_coolFolder->browseObjects(m_since, m_until,
selection,
"");
212 const cool::IObject& element =
objects->currentRef();
216 catch (cool::Exception&
e) {
217 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
224 dumpCode(
const std::string& channelName) {
225 std::string
result = this->dumpField(this->getCoolFolder()->
channelId(channelName.c_str()),
"Code");
237 insertDeadFlag_withTag(cool::Int64
run,
239 const std::string& ChamberName,
240 const std::string& DeadMultilayer,
241 const std::string& DeadTube,
244 cool::RecordSpecification
spec = this->createSpecDataDead();
246 cool::ValidityKey since_u = (
run << 32);
247 cool::ValidityKey until_u = (
run + 1) << 32;
248 m_coolFolder->storeObject(since_u, until_u, cool::Record(
250 std::cout <<
"stored! With Tag =" <<
cool_tag << std::endl;
252 catch (cool::Exception&
e) {
253 std::cout <<
" dentro create insert" << std::endl;
254 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
260 insertDeadFlag(cool::Int64
run,
262 const std::string& ChamberName,
263 const std::string& DeadMultilayer,
264 const std::string& DeadTube) {
265 std::cout <<
"Trying to store payload [channel " << std::endl;
267 cool::RecordSpecification
spec = this->createSpecDataDead();
269 cool::ValidityKey since_u = (
run << 32);
270 cool::ValidityKey until_u = (
run + 1) << 32;
271 m_coolFolder->storeObject(since_u, until_u, cool::Record(m_coolFolder->payloadSpecification(),
payload),
273 std::cout <<
"stored! without Tag" << std::endl;
275 catch (cool::Exception&
e) {
276 std::cout <<
" dentro create insert" << std::endl;
277 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
287 insertNoisyFlag_withTag(cool::Int64
run,
289 const std::string& ChamberName,
290 const std::string& NoisyMultilayer,
291 const std::string& NoisyTube,
294 cool::RecordSpecification
spec = this->createSpecDataNoisy();
296 cool::ValidityKey since_u = (
run << 32);
297 cool::ValidityKey until_u = (
run + 1) << 32;
298 m_coolFolder->storeObject(since_u, until_u, cool::Record(
300 std::cout <<
"stored! With Tag =" <<
cool_tag << std::endl;
302 catch (cool::Exception&
e) {
303 std::cout <<
" dentro create insert" << std::endl;
304 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
310 insertNoisyFlag(cool::Int64
run,
312 const std::string& ChamberName,
313 const std::string& NoisyMultilayer,
314 const std::string& NoisyTube) {
315 std::cout <<
"Trying to store payload [channel " << std::endl;
317 cool::RecordSpecification
spec = this->createSpecDataNoisy();
319 cool::ValidityKey since_u = (
run << 32);
320 cool::ValidityKey until_u = (
run + 1) << 32;
321 m_coolFolder->storeObject(since_u, until_u, cool::Record(m_coolFolder->payloadSpecification(),
payload),
323 std::cout <<
"stored! without Tag" << std::endl;
325 catch (cool::Exception&
e) {
326 std::cout <<
" dentro create insert" << std::endl;
327 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
334 return this->m_coolFolder;
340 return this->m_coolDb;