ATLAS Offline Software
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 
11 #include "InDetIdentifier/SCT_ID.h"
12 
13 #include <vector>
14 #include <utility>
15 #include <string>
16 
17 namespace 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 
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");
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 }
DecoratorUtils.h
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
DerivationFramework::EventInfoBSErrDecorator::kNIntDecor
@ kNIntDecor
Definition: EventInfoBSErrDecorator.h:58
DerivationFramework::EventInfoBSErrDecorator::kSCT_BSErr_side
@ kSCT_BSErr_side
Definition: EventInfoBSErrDecorator.h:54
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
DerivationFramework::createDecoratorKeys
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)
Definition: DecoratorUtils.h:20
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
AthMsgStreamMacros.h
ParticleGun_SamplingFraction.bec
int bec
Definition: ParticleGun_SamplingFraction.py:89
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
DerivationFramework::EventInfoBSErrDecorator::m_byteStreamErrTool
ToolHandle< ISCT_ByteStreamErrorsTool > m_byteStreamErrTool
Definition: EventInfoBSErrDecorator.h:46
DerivationFramework::EventInfoBSErrDecorator::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: EventInfoBSErrDecorator.h:42
SCT_OnlineId
Definition: SCT_OnlineId.h:22
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:686
DerivationFramework::EventInfoBSErrDecorator::kSCT_BSErr_Ntot
@ kSCT_BSErr_Ntot
Definition: EventInfoBSErrDecorator.h:49
SCT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: SCT_ID.h:698
EventInfoBSErrDecorator.h
TRT::Hit::side
@ side
Definition: HitInfo.h:83
TileSynchronizeBch.online
online
Definition: TileSynchronizeBch.py:88
DerivationFramework::EventInfoBSErrDecorator::kSCT_BSErr_phi
@ kSCT_BSErr_phi
Definition: EventInfoBSErrDecorator.h:53
DerivationFramework::EventInfoBSErrDecorator::m_sctId
const SCT_ID * m_sctId
Definition: EventInfoBSErrDecorator.h:44
DerivationFramework::EventInfoBSErrDecorator::kSCT_BSErr_rodid
@ kSCT_BSErr_rodid
Definition: EventInfoBSErrDecorator.h:55
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
python.subdetectors.mmg.names
names
Definition: mmg.py:8
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DerivationFramework::EventInfoBSErrDecorator::kSCT_BSErr_layer
@ kSCT_BSErr_layer
Definition: EventInfoBSErrDecorator.h:51
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
RunTileMonitoring.rod
rod
Definition: RunTileMonitoring.py:134
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
DerivationFramework::EventInfoBSErrDecorator::kSCT_BSErr_bec
@ kSCT_BSErr_bec
Definition: EventInfoBSErrDecorator.h:50
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:692
DerivationFramework::EventInfoBSErrDecorator::m_cabling
ToolHandle< ISCT_CablingTool > m_cabling
Definition: EventInfoBSErrDecorator.h:47
DerivationFramework::EventInfoBSErrDecorator::m_intDecorKeys
std::vector< SG::WriteDecorHandleKey< xAOD::EventInfo > > m_intDecorKeys
Definition: EventInfoBSErrDecorator.h:60
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
DerivationFramework::EventInfoBSErrDecorator::kSCT_BSErr_type
@ kSCT_BSErr_type
Definition: EventInfoBSErrDecorator.h:57
DerivationFramework::EventInfoBSErrDecorator::kSCT_BSErr_channel
@ kSCT_BSErr_channel
Definition: EventInfoBSErrDecorator.h:56
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
SCT_FlaggedCondEnum::NUM_ERROR_TYPES
@ NUM_ERROR_TYPES
Definition: SCT_FlaggedCondEnum.h:28
DerivationFramework::EventInfoBSErrDecorator::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition: EventInfoBSErrDecorator.cxx:56
SCT_ID::eta_module
int eta_module(const Identifier &id) const
Definition: SCT_ID.h:704
DerivationFramework::createDecorators
std::vector< SG::WriteDecorHandle< T_Cont, T > > createDecorators(const std::vector< SG::WriteDecorHandleKey< T_Cont > > &keys, const EventContext &ctx)
Definition: DecoratorUtils.h:51
SCT_ID::side
int side(const Identifier &id) const
Definition: SCT_ID.h:710
SCT_ID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
Definition: SCT_ID.h:464
DerivationFramework::EventInfoBSErrDecorator::kSCT_BSErr_eta
@ kSCT_BSErr_eta
Definition: EventInfoBSErrDecorator.h:52
error
Definition: IImpactPoint3dEstimator.h:70
DerivationFramework::EventInfoBSErrDecorator::m_prefix
Gaudi::Property< std::string > m_prefix
Definition: EventInfoBSErrDecorator.h:40
DerivationFramework::EventInfoBSErrDecorator::initialize
virtual StatusCode initialize() override final
Definition: EventInfoBSErrDecorator.cxx:19
Identifier
Definition: IdentifierFieldParser.cxx:14