ATLAS Offline Software
Loading...
Searching...
No Matches
MCKLoader.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include <CoralBase/Attribute.h>
7#include <CoralBase/AttributeList.h>
8
9#include <string>
10#include "./DBHelper.h"
11
12using namespace std;
13
15 DBLoader("MCKLoader", sm, sm.sessionMgr().createSession())
16{}
17
18bool
19TrigConf::MCKLoader::loadMCKlinkedToSMK(unsigned int smk, unsigned int & mck)
20{
21
22 unique_ptr< coral::IQuery > q;
23
25
26 try {
27 unique_ptr< coral::IQuery > qtmp( m_session.nominalSchema().tableHandle( "MCK_TO_SMK_LINK").newQuery() );
28 q = std::move(qtmp);
29 }
30 catch(coral::TableNotExistingException & ex) {
31 TRG_MSG_WARNING("MAM tables not found in this trigger database");
32 return false;
33 }
34
35 std::string theCondition = "SMK_LINK_SMK = :smId";
36 theCondition += string( " AND SMK_LINK_ACTIVE_MCK = 1" );
37
38 coral::AttributeList bindings;
39 bindings.extend<int>("smId");
40 bindings[0].data<int>() = smk;
41
42 q->setCondition( theCondition, bindings );
43
44 coral::AttributeList attList;
45 attList.extend<int>( "SMK_LINK_MCK" );
46
47 fillQuery(q.get(), attList);
48
49 coral::ICursor& cursor = q->execute();
50
51 int nFound(0);
52 while (cursor.next()) {
53 ++nFound;
54 const coral::AttributeList& row = cursor.currentRow();
55 mck = row["SMK_LINK_MCK"].data<int>();
56 }
58
59 if(nFound>1) {
60 TRG_MSG_ERROR("Found more than one active MCKs for SMK " << smk);
61 } else if(nFound==1) {
62 TRG_MSG_INFO("Found active MCK " << mck << " for SMK " << smk);
63 } else {
64 TRG_MSG_INFO("Found no active MCK for SMK " << smk);
65 }
66 return nFound==1;
67}
68
69bool
70TrigConf::MCKLoader::loadReleaseLinkedToMCK(unsigned int mck, std::string & mck_release)
71{
72 //load athena release (when MCK!=0)
73
74 if ( mck == 0 ){
75 TRG_MSG_ERROR("No release exists for MCK 0");
76 return false;
77 }
78
80
81 unique_ptr< coral::IQuery > q;
82
83 try {
84 unique_ptr< coral::IQuery > qtmp( m_session.nominalSchema().tableHandle( "MCK_TABLE").newQuery() );
85 q = std::move(qtmp);
86 }
87 catch(coral::TableNotExistingException & ex) {
88 TRG_MSG_WARNING("MAM tables not found in this trigger database");
89 return false;
90 }
91
92 coral::AttributeList bindings;
93 bindings.extend<int>("mck");
94 bindings[0].data<int>() = mck;
95
96 q->setCondition( "MCK_ID = :mck", bindings );
97
98 coral::AttributeList attList;
99 attList.extend<std::string> ( "MCK_ATHENA_VERSION" );
100
101 fillQuery(q.get(), attList);
102
103 coral::ICursor& cursor = q->execute();
104
105 int nFound(0);
106 while (cursor.next()) {
107 ++nFound;
108 const coral::AttributeList& row = cursor.currentRow();
109 mck_release = row["MCK_ATHENA_VERSION"].data<std::string>();
110 }
112
113 if(nFound>1) {
114 TRG_MSG_ERROR("Found more than one release for MCK " << mck);
115 } else if(nFound==1) {
116 TRG_MSG_INFO("Found release " << mck_release << " for MCK " << mck);
117 } else {
118 TRG_MSG_INFO("Found no release for MCK " << mck);
119 }
120 return nFound==1;
121
122}
123
DBLoader(StorageMgr &sm, coral::ISessionProxy &session)
constructor
Definition DBLoader.cxx:30
void commitSession()
commit session if not already done
Definition DBLoader.cxx:45
coral::ISessionProxy & m_session
CORAL interface to database session.
Definition DBLoader.h:68
void startSession()
start session if not already active
Definition DBLoader.cxx:35
MCKLoader(StorageMgr &sm)
Definition MCKLoader.cxx:14
bool loadReleaseLinkedToMCK(unsigned int mck, std::string &mck_release)
Definition MCKLoader.cxx:70
bool loadMCKlinkedToSMK(unsigned int smk, unsigned int &mck)
Definition MCKLoader.cxx:19
Database Storage Manager, controls the database session and the different loader classes for DB acces...
Definition StorageMgr.h:23
void fillQuery(coral::IQuery *q, coral::AttributeList &attList)
Definition DBHelper.cxx:13
STL namespace.