ATLAS Offline Software
Loading...
Searching...
No Matches
AFPDBTester.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8{
9 ATH_MSG_DEBUG("in the initialize of AFPDBTester, hello there");
10
11 ATH_CHECK( m_key.initialize() );
12 ATH_MSG_INFO( "m_key id: " << m_key.fullKey() );
13 ATH_CHECK( m_readKey.initialize() );
14 ATH_MSG_INFO( "m_readKey id: " << m_readKey.fullKey() );
15 ATH_CHECK( m_rch_locshiftX.initialize() );
16 ATH_MSG_INFO( "m_rch_locshiftX id: " << m_rch_locshiftX.fullKey() );
17 ATH_CHECK( m_rch_globshiftX.initialize() );
18 ATH_MSG_INFO( "m_rch_globshiftX id: " << m_rch_globshiftX.fullKey() );
19 ATH_CHECK( m_rch_loctof.initialize() );
20 ATH_MSG_INFO( "m_rch_loctof id: " << m_rch_loctof.fullKey() );
21 ATH_CHECK( m_rch_vtxtof.initialize() );
22 ATH_MSG_INFO( "m_rch_vtxtof id: " << m_rch_vtxtof.fullKey() );
23
24 return StatusCode::SUCCESS;
25}
26
27
28StatusCode AFPDBTester::execute(const EventContext& ctx) const
29{
30// check if calo conditions can be loaded
31 ATH_MSG_INFO("execute: "<<ctx.eventID().event_number()<<" , before CaloLocalHadCoeff");
33 const CaloLocalHadCoeff* condObject = *rch;
34 if(condObject==nullptr) {
35 ATH_MSG_ERROR("Unable to access conditions object CaloLocalHadCoeff");
36 return StatusCode::FAILURE;
37 }
38
39// check if beamspot conditions can be loaded
40 ATH_MSG_INFO("execute: "<<ctx.eventID().event_number()<<" , before beam pos");
42 const AthenaAttributeList* raw { *readHandle };
43 if ( raw == nullptr )
44 {
45 ATH_MSG_ERROR("Beam Spot data for key " << m_readKey.fullKey() << " not found");
46 return StatusCode::FAILURE;
47 }
48 float beamposX { (*raw)["posX"].data<float>() };
49 ATH_MSG_INFO("execute: "<<ctx.eventID().event_number()<<" , beam pos X = "<<beamposX);
50
51// load local AFP alignment and print out something
52 ATH_MSG_INFO("execute: "<<ctx.eventID().event_number()<<" , before loc shiftX");
54 const CondAttrListCollection* attrLocList { *ch_locshiftX };
55 if ( attrLocList == nullptr )
56 {
57 ATH_MSG_ERROR("local shiftX data for key " << m_rch_locshiftX.fullKey() << " not found");
58 return StatusCode::FAILURE;
59 }
60
61 int counter=1;
63 for (itr = attrLocList->begin(); itr != attrLocList->end(); ++itr) {
64 if(counter>1) ATH_MSG_INFO("there should be only one real channel in /FWD/AFP/Align/Local, this is real channel nr. "<<counter);
65
66 const coral::AttributeList &atr = itr->second;
67 std::string data = *(static_cast<const std::string *>((atr["data"]).addressOfData()));
68
69 nlohmann::json jsondata = nlohmann::json::parse(data);
70 int nchannels=jsondata["nchannels"];
71 nlohmann::json channeldata=jsondata["data"];
72 for(auto& chan : channeldata.items())
73 {
74 // channels are ordered alphabetically: 0,1,10,...,15,2,3,...,9
75 ATH_MSG_INFO("reading channel nr. "<<chan.key());
76 nlohmann::json aligndata=chan.value();
77
78 std::string channel=chan.key();
79 int layerID=aligndata["layerID"];
80 float shiftX=aligndata["shiftX"];
81
82 ATH_MSG_INFO("execute: run "<<ctx.eventID().run_number()<<", lb "<<ctx.eventID().lumi_block()<<", evnt "<<ctx.eventID().event_number()<<", channel "<<channel<<"/"<<nchannels<<", layerID "<<layerID<<", shiftX = "<<shiftX);
83 }
84
85 ++counter;
86 }
87
88
89// load global AFP alignment and print out something else
90 ATH_MSG_INFO("test: "<<ctx.eventID().event_number()<<" , before glob shiftX");
92 const CondAttrListCollection* attrGlobList { *ch_globshiftX };
93 if ( attrGlobList == nullptr )
94 {
95 ATH_MSG_ERROR("global shiftX data for key " << m_rch_globshiftX.fullKey() << " not found");
96 return StatusCode::FAILURE;
97 }
98
99 counter=1;
101 for (itr2 = attrGlobList->begin(); itr2 != attrGlobList->end(); ++itr2) {
102 if(counter>1) ATH_MSG_INFO("there should be only one real channel in /FWD/AFP/Align/Global, this is real channel nr. "<<counter);
103
104 const coral::AttributeList &atr = itr2->second;
105 std::string data = *(static_cast<const std::string *>((atr["data"]).addressOfData()));
106
107 nlohmann::json jsondata = nlohmann::json::parse(data);
108 int nchannels=jsondata["nchannels"];
109 nlohmann::json channeldata=jsondata["data"];
110 for(auto& chan : channeldata.items())
111 {
112 // channels are ordered alphabetically: 0,1,10,...,15,2,3,...,9
113 ATH_MSG_INFO("reading channel nr. "<<chan.key());
114 nlohmann::json aligndata=chan.value();
115
116 std::string channel=chan.key();
117 std::string alignType=aligndata["alignType"];
118 float shiftX=aligndata["shiftX"];
119
120 ATH_MSG_INFO("execute: run "<<ctx.eventID().run_number()<<", lb "<<ctx.eventID().lumi_block()<<", evnt "<<ctx.eventID().event_number()<<", channel "<<channel<<"/"<<nchannels<<", alignType "<<alignType<<", shiftX = "<<shiftX);
121 }
122
123 ++counter;
124 }
125
126
127// load local AFP ToF parameters and print out something
128 ATH_MSG_INFO("execute: "<<ctx.eventID().event_number()<<" , before loc tof");
130 const CondAttrListCollection* attrLocToFList { *ch_loctof };
131 if ( attrLocToFList == nullptr )
132 {
133 ATH_MSG_ERROR("local ToF data for key " << m_rch_loctof.fullKey() << " not found");
134 return StatusCode::FAILURE;
135 }
136
137 counter=1;
139 for (itr3 = attrLocToFList->begin(); itr3 != attrLocToFList->end(); ++itr3) {
140 if(counter>1) ATH_MSG_INFO("there should be only one real channel in /FWD/AFP/ToFParameters/Local, this is real channel nr. "<<counter);
141
142 const coral::AttributeList &atr = itr3->second;
143 std::string data = *(static_cast<const std::string *>((atr["data"]).addressOfData()));
144
145 nlohmann::json jsondata = nlohmann::json::parse(data);
146 int nchannels=jsondata["nchannels"];
147 nlohmann::json channeldata=jsondata["data"];
148 for(auto& chan : channeldata.items())
149 {
150 // channels are ordered alphabetically: 0,1,10,...,19,2,20,21,...29,3,30,31,4,...,9
151 ATH_MSG_INFO("reading channel nr. "<<chan.key());
152 nlohmann::json paramdata=chan.value();
153
154 std::string channel=chan.key();
155 int trainID=paramdata["trainID"];
156 float barWeight=paramdata["barWeight"];
157
158 ATH_MSG_INFO("execute: run "<<ctx.eventID().run_number()<<", lb "<<ctx.eventID().lumi_block()<<", evnt "<<ctx.eventID().event_number()<<", channel "<<channel<<"/"<<nchannels<<", trainID "<<trainID<<", barWeight = "<<barWeight);
159 }
160
161 ++counter;
162 }
163
164// load vertex AFP ToF parameters and print out something
165 ATH_MSG_INFO("execute: "<<ctx.eventID().event_number()<<" , before vtx tof");
167 const CondAttrListCollection* attrVtxToFList { *ch_vtxtof };
168 if ( attrVtxToFList == nullptr )
169 {
170 ATH_MSG_ERROR("vertex ToF data for key " << m_rch_vtxtof.fullKey() << " not found");
171 return StatusCode::FAILURE;
172 }
173
174 counter=1;
176 for (itr4 = attrVtxToFList->begin(); itr4 != attrVtxToFList->end(); ++itr4) {
177 if(counter>1) ATH_MSG_INFO("there should be only one real channel in /FWD/AFP/ToFParameters/Vertex, this is real channel nr. "<<counter);
178
179 const coral::AttributeList &atr = itr4->second;
180 std::string data = *(static_cast<const std::string *>((atr["data"]).addressOfData()));
181
182 nlohmann::json jsondata = nlohmann::json::parse(data);
183 int nchannels=jsondata["nchannels"];
184 nlohmann::json channeldata=jsondata["data"];
185 for(auto& chan : channeldata.items())
186 {
187 // channels are ordered alphabetically: 0,1
188 ATH_MSG_INFO("reading channel nr. "<<chan.key());
189 nlohmann::json paramdata=chan.value();
190
191 std::string channel=chan.key();
192 int stationID=paramdata["stationID"];
193 float timeGlobalOffset=paramdata["timeGlobalOffset"];
194 std::vector<float> trainEdge=paramdata["trainEdge"];
195
196 ATH_MSG_INFO("execute: run "<<ctx.eventID().run_number()<<", lb "<<ctx.eventID().lumi_block()<<", evnt "<<ctx.eventID().event_number()<<", channel "<<channel<<"/"<<nchannels<<", stationID "<<stationID<<", timeGlobalOffset = "<<timeGlobalOffset<<", trainEdge = ("<<trainEdge.at(0)<<", "<<trainEdge.at(1)<<", ... "<<trainEdge.at(4)<<")");
197 }
198
199 ++counter;
200 }
201
202 return StatusCode::SUCCESS;
203}
204
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
virtual StatusCode execute(const EventContext &ctx) const override
SG::ReadCondHandleKey< CaloLocalHadCoeff > m_key
Definition AFPDBTester.h:38
SG::ReadCondHandleKey< CondAttrListCollection > m_rch_globshiftX
Definition AFPDBTester.h:34
SG::ReadCondHandleKey< AthenaAttributeList > m_readKey
Definition AFPDBTester.h:37
SG::ReadCondHandleKey< CondAttrListCollection > m_rch_locshiftX
Definition AFPDBTester.h:33
SG::ReadCondHandleKey< CondAttrListCollection > m_rch_loctof
Definition AFPDBTester.h:35
virtual StatusCode initialize() override
SG::ReadCondHandleKey< CondAttrListCollection > m_rch_vtxtof
Definition AFPDBTester.h:36
An AttributeList represents a logical row of attributes in a metadata table.
Hold binned correction data for local hadronic calibration procedure.
This class is a collection of AttributeLists where each one is associated with a channel number.
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
ChanAttrListMap::const_iterator const_iterator