ATLAS Offline Software
EventInfoBSErrDecorator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // EventInfoBSErrDecorator.cxx, (c) ATLAS Detector software
8 // Author: Daiki Hayakawa ( daiki.hayakawa@cern.ch )
9 
13 
14 #include "InDetIdentifier/SCT_ID.h"
15 
16 #include <vector>
17 #include <utility>
18 #include <string>
19 
20 namespace DerivationFramework {
21 
23  const std::string& name,
24  const IInterface* parent) :
26  {
27  declareInterface<DerivationFramework::IAugmentationTool>(this);
28  }
29 
31  {
32 
33  if (m_prefix.empty()) {
34  ATH_MSG_WARNING("No decoration prefix name provided for the output of EventInfoBSErrDecorator!");
35  }
36 
38 
39  // need Atlas id-helpers to identify sub-detectors, take them from detStore
40  if( detStore()->retrieve(m_sctId,"SCT_ID").isFailure() ){
41  ATH_MSG_ERROR("Could not retrieve SCT helper");
42  return StatusCode::FAILURE;
43  }
44 
45  CHECK ( m_byteStreamErrTool.retrieve() );
46  CHECK ( m_cabling.retrieve() );
47 
48  {
49  std::vector<std::string> names;
50  names.resize(kNIntDecor);
51  names[kSCT_BSErr_Ntot] ="SCT_BSErr_Ntot";
52  names[kSCT_BSErr_bec] ="SCT_BSErr_bec";
53  names[kSCT_BSErr_layer] ="SCT_BSErr_layer";
54  names[kSCT_BSErr_eta] ="SCT_BSErr_eta";
55  names[kSCT_BSErr_phi] ="SCT_BSErr_phi";
56  names[kSCT_BSErr_side] ="SCT_BSErr_side";
57  names[kSCT_BSErr_rodid] ="SCT_BSErr_rodid";
58  names[kSCT_BSErr_channel] ="SCT_BSErr_channel";
59  names[kSCT_BSErr_type] ="SCT_BSErr_type";
61  }
62 
63  return StatusCode::SUCCESS;
64  }
65 
67  {
68  return StatusCode::SUCCESS;
69  }
70 
72  {
73  ATH_MSG_DEBUG("Adding ByteStream errors to EventInfo");
74 
75  const EventContext& ctx = Gaudi::Hive::currentContext();
77  CHECK( eventInfo.isValid() ? StatusCode::SUCCESS : StatusCode::FAILURE );
78 
79  std::array<std::vector<int>,kNIntDecor> scterr;
80  int totalNumErrors=0;
81 
82  // fill BS error information
83  for (int n_type=0; n_type < SCT_ByteStreamErrors::NUM_ERROR_TYPES; ++n_type) {
84  const std::set<IdentifierHash> errorSet = m_byteStreamErrTool->getErrorSet(n_type);
85  int eta=0,phi=0,bec=0,layer=0,side=0;
86  // add totalNumErrors to vector
87  totalNumErrors += errorSet.size();
88  scterr[kSCT_BSErr_Ntot].push_back(totalNumErrors);
89 
90  // loop in errorSet
91  for(const auto& error : errorSet) {
92  ATH_MSG_DEBUG("debugging information");
95  ATH_MSG_DEBUG(n_type);
96  layer = m_sctId->layer_disk(itId);
97  side = m_sctId->side(itId);
98  eta = m_sctId->eta_module(itId);
99  phi = m_sctId->phi_module(itId);
100  bec = m_sctId->barrel_ec(itId);
101 
102  // add variables to vector
103  scterr[kSCT_BSErr_bec].push_back(bec);
104  scterr[kSCT_BSErr_layer].push_back(layer);
105  scterr[kSCT_BSErr_eta].push_back(eta);
106  scterr[kSCT_BSErr_phi].push_back(phi);
107  scterr[kSCT_BSErr_side].push_back(side);
108  scterr[kSCT_BSErr_type].push_back(n_type);
109 
110  uint32_t onlineID = m_cabling->getOnlineIdFromHash(error);
111  SCT_OnlineId online(onlineID);
112  uint32_t rod = online.rod();
113  uint32_t fibre = online.fibre();
114  scterr[kSCT_BSErr_rodid].push_back((int)rod);
115  scterr[kSCT_BSErr_channel].push_back((int)fibre);
116  }
117  }
118  std::vector<SG::WriteDecorHandle<xAOD::EventInfo,std::vector<int> > > int_decor_handles(createDecorators<xAOD::EventInfo,std::vector<int> >(m_intDecorKeys,ctx));
119 
120  assert(int_decor_handles.size() == kNIntDecor);
121  // decorate SCT BS error
122  for(unsigned int decorate_i=0; decorate_i<int_decor_handles.size(); ++decorate_i) {
123  int_decor_handles[decorate_i](*eventInfo) = std::move(scterr[decorate_i]);
124  }
125  return StatusCode::SUCCESS;
126  }
127 
128 }
DecoratorUtils.h
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
DerivationFramework::EventInfoBSErrDecorator::kNIntDecor
@ kNIntDecor
Definition: EventInfoBSErrDecorator.h:62
DerivationFramework::EventInfoBSErrDecorator::kSCT_BSErr_side
@ kSCT_BSErr_side
Definition: EventInfoBSErrDecorator.h:58
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
AthMsgStreamMacros.h
ParticleGun_SamplingFraction.bec
int bec
Definition: ParticleGun_SamplingFraction.py:89
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
DerivationFramework::EventInfoBSErrDecorator::m_byteStreamErrTool
ToolHandle< ISCT_ByteStreamErrorsTool > m_byteStreamErrTool
Definition: EventInfoBSErrDecorator.h:50
DerivationFramework::EventInfoBSErrDecorator::finalize
StatusCode finalize()
Definition: EventInfoBSErrDecorator.cxx:66
DerivationFramework::EventInfoBSErrDecorator::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: EventInfoBSErrDecorator.h:46
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:728
DerivationFramework::EventInfoBSErrDecorator::kSCT_BSErr_Ntot
@ kSCT_BSErr_Ntot
Definition: EventInfoBSErrDecorator.h:53
SCT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: SCT_ID.h:740
EventInfoBSErrDecorator.h
DerivationFramework::EventInfoBSErrDecorator::EventInfoBSErrDecorator
EventInfoBSErrDecorator(const std::string &type, const std::string &name, const IInterface *parent)
Definition: EventInfoBSErrDecorator.cxx:22
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
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:57
DerivationFramework::EventInfoBSErrDecorator::m_sctId
const SCT_ID * m_sctId
Definition: EventInfoBSErrDecorator.h:48
DerivationFramework::EventInfoBSErrDecorator::kSCT_BSErr_rodid
@ kSCT_BSErr_rodid
Definition: EventInfoBSErrDecorator.h:59
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
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:55
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?
DerivationFramework::EventInfoBSErrDecorator::addBranches
virtual StatusCode addBranches() const
Pass the thinning service
Definition: EventInfoBSErrDecorator.cxx:71
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
DerivationFramework::EventInfoBSErrDecorator::kSCT_BSErr_bec
@ kSCT_BSErr_bec
Definition: EventInfoBSErrDecorator.h:54
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:734
DerivationFramework::EventInfoBSErrDecorator::m_cabling
ToolHandle< ISCT_CablingTool > m_cabling
Definition: EventInfoBSErrDecorator.h:51
DerivationFramework::EventInfoBSErrDecorator::m_intDecorKeys
std::vector< SG::WriteDecorHandleKey< xAOD::EventInfo > > m_intDecorKeys
Definition: EventInfoBSErrDecorator.h:64
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
DerivationFramework::EventInfoBSErrDecorator::initialize
StatusCode initialize()
Definition: EventInfoBSErrDecorator.cxx:30
DerivationFramework::EventInfoBSErrDecorator::kSCT_BSErr_type
@ kSCT_BSErr_type
Definition: EventInfoBSErrDecorator.h:61
DerivationFramework::EventInfoBSErrDecorator::kSCT_BSErr_channel
@ kSCT_BSErr_channel
Definition: EventInfoBSErrDecorator.h:60
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
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SCT_ID::eta_module
int eta_module(const Identifier &id) const
Definition: SCT_ID.h:746
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:752
AthAlgTool
Definition: AthAlgTool.h:26
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:56
error
Definition: IImpactPoint3dEstimator.h:70
DerivationFramework::EventInfoBSErrDecorator::m_prefix
Gaudi::Property< std::string > m_prefix
Definition: EventInfoBSErrDecorator.h:44
Identifier
Definition: IdentifierFieldParser.cxx:14