ATLAS Offline Software
Loading...
Searching...
No Matches
AFP::ToFLocParamDBTool Class Reference

Tool providing local parameters of ToF detectors from the conditions database. More...

#include <ToFLocParamDBTool.h>

Inheritance diagram for AFP::ToFLocParamDBTool:
Collaboration diagram for AFP::ToFLocParamDBTool:

Public Member Functions

 ToFLocParamDBTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~ToFLocParamDBTool () override
 Does nothing.
virtual StatusCode initialize () override
 Does nothing.
virtual StatusCode finalize () override
 Does nothing.
nlohmann::json parametersData (const EventContext &ctx) const override
 Provide ToF parameters for a given bar. Returns zeros if no data available.
const ToFLocParamData parameters (const nlohmann::json &jsondata, const int stationID, const int trainID, const int barID) const override

Private Attributes

SG::ReadCondHandleKey< CondAttrListCollectionm_rch_loc {this, "loc_param_key", "/FWD/Onl/AFP/ToFParameters/Local", "read condition handle for local ToF parameters"}

Detailed Description

Tool providing local parameters of ToF detectors from the conditions database.

Definition at line 33 of file ToFLocParamDBTool.h.

Constructor & Destructor Documentation

◆ ToFLocParamDBTool()

AFP::ToFLocParamDBTool::ToFLocParamDBTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 10 of file ToFLocParamDBTool.cxx.

10 :
11 base_class(type, name, parent)
12 {
13 }

◆ ~ToFLocParamDBTool()

virtual AFP::ToFLocParamDBTool::~ToFLocParamDBTool ( )
inlineoverridevirtual

Does nothing.

Definition at line 39 of file ToFLocParamDBTool.h.

39{}

Member Function Documentation

◆ finalize()

StatusCode AFP::ToFLocParamDBTool::finalize ( )
overridevirtual

Does nothing.

Definition at line 23 of file ToFLocParamDBTool.cxx.

24 {
25 ATH_MSG_DEBUG("in the finalize of ToFLocParamDBTool, bye bye");
26 return StatusCode::SUCCESS;
27 }
#define ATH_MSG_DEBUG(x)

◆ initialize()

StatusCode AFP::ToFLocParamDBTool::initialize ( )
overridevirtual

Does nothing.

Definition at line 16 of file ToFLocParamDBTool.cxx.

17 {
18 ATH_CHECK( m_rch_loc.initialize() );
19 ATH_MSG_DEBUG( "using DB with key " << m_rch_loc.fullKey() );
20 return StatusCode::SUCCESS;
21 }
#define ATH_CHECK
Evaluate an expression and check for errors.
SG::ReadCondHandleKey< CondAttrListCollection > m_rch_loc

◆ parameters()

const ToFLocParamData AFP::ToFLocParamDBTool::parameters ( const nlohmann::json & jsondata,
const int stationID,
const int trainID,
const int barID ) const
override

Definition at line 52 of file ToFLocParamDBTool.cxx.

53 {
54 ATH_MSG_DEBUG("will get local ToF parameters for station "<<stationID<<", trainID "<<trainID<<", barID "<<barID);
55 nlohmann::json channeldata=jsondata["data"];
56
57 // first, try to guess the channel nr.
58 int guess_ch=(stationID/3)*16+trainID*4+barID;
59
60 nlohmann::json paramdata=channeldata.at(std::to_string(guess_ch)); // because using int would be too simple
61 int st=paramdata["stationID"];
62 int tr=paramdata["trainID"];
63 int ba=paramdata["barID"];
64 if(stationID==st && trainID==tr && barID==ba)
65 {
66 ATH_MSG_DEBUG("channel guessed correctly, stationID "<<st<<", trainID "<<trainID<<", barID "<<barID<<", channel guess "<<guess_ch);
67 return ToFLocParamData(st, tr, ba, paramdata["barWeight"], paramdata["barTimeOffset"]);
68 }
69 else
70 {
71 ATH_MSG_DEBUG("channel was not guessed correctly, stationID "<<st<<", trainID "<<trainID<<", barID "<<barID<<", channel guess "<<guess_ch);
72 }
73
74 // if guess is not correct, loop over all channels
75 for(auto& chan : channeldata.items())
76 {
77 // channels are ordered alphabetically: 0,1,10,...,19,2,20,21,...29,3,30,31,4,...,9
78 nlohmann::json paramdata=chan.value();
79
80 int st=paramdata["stationID"];
81 int tr=paramdata["trainID"];
82 int ba=paramdata["barID"];
83
84 if(stationID==st && trainID==tr && barID==ba)
85 {
86 ATH_MSG_DEBUG("channel found for stationID "<<st<<", trainID "<<trainID<<", barID "<<barID<<", channel nr. "<<chan.key());
87 return ToFLocParamData(st, tr, ba, paramdata["barWeight"], paramdata["barTimeOffset"]);
88 }
89 }
90
91 ATH_MSG_WARNING("local ToF parameters data stationID "<<stationID<<", trainID "<<trainID<<", barID "<<barID<<" not found in any channels, returning zeros");
92 return ToFLocParamData(stationID, trainID, barID);
93 }
#define ATH_MSG_WARNING(x)
constexpr uint8_t stationID
Large or Small wedge.

◆ parametersData()

nlohmann::json AFP::ToFLocParamDBTool::parametersData ( const EventContext & ctx) const
override

Provide ToF parameters for a given bar. Returns zeros if no data available.

Definition at line 30 of file ToFLocParamDBTool.cxx.

31 {
32 ATH_MSG_DEBUG("will get local ToF parameters for run "<<ctx.eventID().run_number()<<", lb "<<ctx.eventID().lumi_block()<<", event "<<ctx.eventID().event_number());
33
34 SG::ReadCondHandle<CondAttrListCollection> ch_loc( m_rch_loc, ctx );
35 const CondAttrListCollection* attrLocList { *ch_loc};
36 if ( attrLocList == nullptr )
37 {
38 ATH_MSG_WARNING("local ToF parameters data for key " << m_rch_loc.fullKey() << " not found, returning empty string");
39 return nlohmann::json::parse("");
40 }
41
42 if(attrLocList->size()>1) ATH_MSG_INFO("there should be only one real channel in "<< m_rch_loc.fullKey() <<", there are "<<attrLocList->size()<<" real channels, only the first one will be used ");
43
45 const coral::AttributeList &atr = itr->second;
46 std::string data = *(static_cast<const std::string *>((atr["data"]).addressOfData()));
47
48 return nlohmann::json::parse(data);
49 }
#define ATH_MSG_INFO(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
size_type size() const
number of Chan/AttributeList pairs
ChanAttrListMap::const_iterator const_iterator

Member Data Documentation

◆ m_rch_loc

SG::ReadCondHandleKey<CondAttrListCollection> AFP::ToFLocParamDBTool::m_rch_loc {this, "loc_param_key", "/FWD/Onl/AFP/ToFParameters/Local", "read condition handle for local ToF parameters"}
private

Definition at line 52 of file ToFLocParamDBTool.h.

52{this, "loc_param_key", "/FWD/Onl/AFP/ToFParameters/Local", "read condition handle for local ToF parameters"};

The documentation for this class was generated from the following files: