ATLAS Offline Software
Loading...
Searching...
No Matches
EventInfoBSErrDecorator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Author: Daiki Hayakawa ( daiki.hayakawa@cern.ch )
6
10
12
13#include <vector>
14#include <utility>
15#include <string>
16
17namespace DerivationFramework {
18
20 {
21
22 if (m_prefix.empty()) {
23 ATH_MSG_WARNING("No decoration prefix name provided for the output of EventInfoBSErrDecorator!");
24 }
25
26 ATH_CHECK(m_eventInfoKey.initialize() );
27
28 // need Atlas id-helpers to identify sub-detectors, take them from detStore
29 if( detStore()->retrieve(m_sctId,"SCT_ID").isFailure() ){
30 ATH_MSG_ERROR("Could not retrieve SCT helper");
31 return StatusCode::FAILURE;
32 }
33
34 CHECK ( m_byteStreamErrTool.retrieve() );
35 CHECK ( m_cabling.retrieve() );
36
37 {
38 std::vector<std::string> names;
39 names.resize(kNIntDecor);
40 names[kSCT_BSErr_Ntot] ="SCT_BSErr_Ntot";
41 names[kSCT_BSErr_bec] ="SCT_BSErr_bec";
42 names[kSCT_BSErr_layer] ="SCT_BSErr_layer";
43 names[kSCT_BSErr_eta] ="SCT_BSErr_eta";
44 names[kSCT_BSErr_phi] ="SCT_BSErr_phi";
45 names[kSCT_BSErr_side] ="SCT_BSErr_side";
46 names[kSCT_BSErr_rodid] ="SCT_BSErr_rodid";
47 names[kSCT_BSErr_channel] ="SCT_BSErr_channel";
48 names[kSCT_BSErr_type] ="SCT_BSErr_type";
50 }
51
52 return StatusCode::SUCCESS;
53 }
54
55
56 StatusCode EventInfoBSErrDecorator::addBranches(const EventContext& ctx) const
57 {
58 ATH_MSG_DEBUG("Adding ByteStream errors to EventInfo");
59
61 CHECK( eventInfo.isValid() ? StatusCode::SUCCESS : StatusCode::FAILURE );
62
63 std::array<std::vector<int>,kNIntDecor> scterr;
64 int totalNumErrors=0;
65
66 // fill BS error information
67 for (int n_type=0; n_type < SCT_ByteStreamErrors::NUM_ERROR_TYPES; ++n_type) {
68 const std::set<IdentifierHash> errorSet = m_byteStreamErrTool->getErrorSet(n_type);
69 int eta=0,phi=0,bec=0,layer=0,side=0;
70 // add totalNumErrors to vector
71 totalNumErrors += errorSet.size();
72 scterr[kSCT_BSErr_Ntot].push_back(totalNumErrors);
73
74 // loop in errorSet
75 for(const auto& error : errorSet) {
76 ATH_MSG_DEBUG("debugging information");
77 Identifier itId = m_sctId->wafer_id(error);
79 ATH_MSG_DEBUG(n_type);
80 layer = m_sctId->layer_disk(itId);
81 side = m_sctId->side(itId);
82 eta = m_sctId->eta_module(itId);
83 phi = m_sctId->phi_module(itId);
84 bec = m_sctId->barrel_ec(itId);
85
86 // add variables to vector
87 scterr[kSCT_BSErr_bec].push_back(bec);
88 scterr[kSCT_BSErr_layer].push_back(layer);
89 scterr[kSCT_BSErr_eta].push_back(eta);
90 scterr[kSCT_BSErr_phi].push_back(phi);
91 scterr[kSCT_BSErr_side].push_back(side);
92 scterr[kSCT_BSErr_type].push_back(n_type);
93
94 uint32_t onlineID = m_cabling->getOnlineIdFromHash(error);
95 SCT_OnlineId online(onlineID);
96 uint32_t rod = online.rod();
97 uint32_t fibre = online.fibre();
98 scterr[kSCT_BSErr_rodid].push_back((int)rod);
99 scterr[kSCT_BSErr_channel].push_back((int)fibre);
100 }
101 }
102 std::vector<SG::WriteDecorHandle<xAOD::EventInfo,std::vector<int> > > int_decor_handles(createDecorators<xAOD::EventInfo,std::vector<int> >(m_intDecorKeys,ctx));
103
104 assert(int_decor_handles.size() == kNIntDecor);
105 // decorate SCT BS error
106 for(unsigned int decorate_i=0; decorate_i<int_decor_handles.size(); ++decorate_i) {
107 int_decor_handles[decorate_i](*eventInfo) = std::move(scterr[decorate_i]);
108 }
109 return StatusCode::SUCCESS;
110 }
111
112}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
This is an Identifier helper class for the SCT subdetector.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
ToolHandle< ISCT_ByteStreamErrorsTool > m_byteStreamErrTool
virtual StatusCode addBranches(const EventContext &ctx) const override final
std::vector< SG::WriteDecorHandleKey< xAOD::EventInfo > > m_intDecorKeys
SCT_OnlineId is a class to hold an online id number and provide check on validity,...
virtual bool isValid() override final
Can the handle be successfully dereferenced?
THE reconstruction tool.
std::vector< SG::WriteDecorHandle< T_Cont, T > > createDecorators(const std::vector< SG::WriteDecorHandleKey< T_Cont > > &keys, const EventContext &ctx)
void createDecoratorKeys(T_Parent &parent, const SG::ReadHandleKey< T_Cont > &container_key, const std::string &prefix, const std::vector< std::string > &decor_names, std::vector< SG::WriteDecorHandleKey< T_Cont > > &decor_out)
EventInfo_v1 EventInfo
Definition of the latest event info version.