ATLAS Offline Software
Loading...
Searching...
No Matches
AFP_LinkNumTranslator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7AFP_LinkNumTranslator::AFP_LinkNumTranslator(const std::string& type, const std::string& name, const IInterface* parent) :
8 base_class(type, name, parent)
9{
10}
11
15
17{
18 if(m_useDB)
19 {
20 ATH_MSG_ERROR("Using DB is not implemented yet");
21 return StatusCode::FAILURE;
22/*
23 ATH_CHECK( m_readDBKey_AF.initialize() );
24 ATH_MSG_INFO( "Using DB with key " << m_readDBKey_AF.fullKey() );
25 ATH_CHECK( m_readDBKey_AN.initialize() );
26 ATH_MSG_INFO( "Using DB with key " << m_readDBKey_AN.fullKey() );
27 ATH_CHECK( m_readDBKey_CF.initialize() );
28 ATH_MSG_INFO( "Using DB with key " << m_readDBKey_CF.fullKey() );
29 ATH_CHECK( m_readDBKey_CN.initialize() );
30 ATH_MSG_INFO( "Using DB with key " << m_readDBKey_CN.fullKey() );
31*/
32 }
33 else
34 {
35 ATH_MSG_INFO("Using hard-coded values");
36 }
37 return StatusCode::SUCCESS;
38}
39
41{
42 return StatusCode::SUCCESS;
43}
44
45unsigned int AFP_LinkNumTranslator::translate(unsigned int origlink) const
46{
47
48 const EventContext& ctx = Gaudi::Hive::currentContext();
49 // EventIDBase t( ctx.eventID() );
50
51 if(m_useDB)
52 {
53 ATH_MSG_ERROR("Using DB is not implemented yet, will return kUnknown = "<<kUnknown);
54 return kUnknown;
55
56 // TODO: distinguish between A and C?
57 // TODO: change based on reality
58 /*
59 SG::ReadCondHandle<CondAttrListCollection> readHandle_AF( m_readDBKey_AF, ctx );
60 const CondAttrListCollection* attrLocList_AF { *readHandle_AF };
61 if ( attrLocList_AF == nullptr )
62 {
63 ATH_MSG_ERROR("data for key " << m_readDBKey_AF.fullKey() << " not found");
64 return 0;
65 }
66 CondAttrListCollection::const_iterator chanIt=attrLocList_AF->begin();
67 CondAttrListCollection::const_iterator chanIt_e=attrLocList_AF->end();
68 for(;chanIt!=chanIt_e;++chanIt) {
69 const unsigned channel=chanIt->first;
70 const coral::AttributeList& attr=chanIt->second;
71 int linkNr = (attr)["linkNr"].data<int>(); // TODO: get link number from the blob
72 ATH_MSG_INFO("execute: run "<<ctx.eventID().run_number()<<", lb "<<ctx.eventID().lumi_block()<<", evnt "<<ctx.eventID().event_number()<<", channel "<<channel<<", linkNr "<<linkNr);
73
74 if((unsigned int)linkNr==origlink)
75 {
76 switch(channel)
77 {
78 case 0: return kNS0;
79 case 1: return kNS1;
80 case 2: return kNS2;
81 case 3: return kNS3;
82 }
83 }
84 }
85
86 // not found in far, try near
87 SG::ReadCondHandle<CondAttrListCollection> readHandle_AN( m_readDBKey_AN, ctx );
88 const CondAttrListCollection* attrLocList_AN { *readHandle_AN };
89 if ( attrLocList_AN == nullptr )
90 {
91 ATH_MSG_ERROR("data for key " << m_readDBKey_AN.fullKey() << " not found");
92 return 0;
93 }
94 chanIt=attrLocList_AN->begin();
95 chanIt_e=attrLocList_AN->end();
96 for(;chanIt!=chanIt_e;++chanIt) {
97 const unsigned channel=chanIt->first;
98 const coral::AttributeList& attr=chanIt->second;
99 int linkNr = (attr)["linkNr"].data<int>(); // TODO: get link number from the blob
100 ATH_MSG_INFO("execute: run "<<ctx.eventID().run_number()<<", lb "<<ctx.eventID().lumi_block()<<", evnt "<<ctx.eventID().event_number()<<", channel "<<channel<<", linkNr "<<linkNr);
101
102 if((unsigned int)linkNr==origlink)
103 {
104 switch(channel)
105 {
106 case 0: return kFS0;
107 case 1: return kFS1;
108 case 2: return kFS2;
109 case 3: return kFS3;
110 case 4: return kFS4;
111 case 5: return kFS5;
112 }
113 }
114 }
115
116 ATH_MSG_ERROR("did not find the corresponding entry in DB; requested translation of link number " << origlink << " for run " << ctx.eventID().run_number());
117 return 0;
118 */
119 }
120 else
121 {
122 // don't use DB
123
124 int run_nr = ctx.eventID().run_number();
125 int Run = (run_nr > 370000 ? 3 : 2);
127
128 if(Run==2)
129 {
130 ATH_MSG_DEBUG("asked for link "<<origlink<<", from run "<<run_nr<<", Run "<<Run);
131 return origlink;
132 }
133 else if(Run==3)
134 {
135 unsigned int kReturn=999;
136 switch(origlink)
137 {
138 case 0: kReturn=kNS0; break;
139 case 2: kReturn=kNS1; break;
140 case 4: kReturn=kNS2; break;
141 case 6: kReturn=kNS3; break;
142 case 8: kReturn=kFS0; break;
143 case 10: kReturn=kFS1; break;
144 case 12: kReturn=kFS2; break;
145 case 14: kReturn=kFS3; break;
146 case 9: kReturn=kFS4; break;
147 case 11: kReturn=kFS5; break;
148 default:
149 ATH_MSG_ERROR("requested translation of unknown link number " << origlink << " for run " << run_nr);
150 kReturn=kUnknown;
151 }
152 ATH_MSG_DEBUG("asked for link "<<origlink<<", from run "<<run_nr<<", Run "<<Run<<", will return "<<kReturn);
153
154 return kReturn;
155 }
156 else
157 {
158 ATH_MSG_ERROR("requested link " << origlink << " for unknown Run " << Run );
159 return kUnknown;
160 }
161 }
162
163}
164
165
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Property< bool > m_useDB
Gaudi::Property< int > m_forceRunConfig
virtual StatusCode initialize() override
unsigned int translate(unsigned int origlink) const override
virtual ~AFP_LinkNumTranslator() override
virtual StatusCode finalize() override
AFP_LinkNumTranslator(const std::string &type, const std::string &name, const IInterface *parent)