ATLAS Offline Software
PixelRawDataProviderTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "PixelRodDecoder.h"
8 
10 
11 //#define PIXEL_DEBUG
12 //#define PLOTS
13 
14 // -------------------------------------------------------
15 // default contructor
16 
17 PixelRawDataProviderTool::PixelRawDataProviderTool(const std::string& type, const std::string& name, const IInterface* parent):
19  m_DecodeErrCount(0)
20 {
21  declareInterface<IPixelRawDataProviderTool>(this);
22 }
23 
26  ATH_CHECK(m_decoder.retrieve());
27 
30 
31  return StatusCode::SUCCESS;
32 }
33 
34 StatusCode PixelRawDataProviderTool::convert(std::vector<const ROBFragment*>& vecRobs, IPixelRDO_Container* rdoIdc,
35  IDCInDetBSErrContainer& decodingErrors, const EventContext& ctx ) const {
36  if (vecRobs.size()==0) { return StatusCode::SUCCESS; }
37 
38  std::vector<const ROBFragment*>::const_iterator rob_it = vecRobs.begin();
39 
40 #ifdef PIXEL_DEBUG
41  ATH_MSG_DEBUG(" New ROD collection found: LVL1=" << (*rob_it)->rod_lvl1_id() << " Size=" << vecRobs.size());
42 #endif
43 #ifdef PLOTS
44  std::cout << " New ROD collection found: LVL1=" << (*rob_it)->rod_lvl1_id() << " Size=" << vecRobs.size() << std::endl;
45 #endif
46 
49 
50  if ( m_storeInDetTimeColls ) {
51  // are we working on a new event ?
52  LVL1Collection = SG::makeHandle(m_LVL1CollectionKey,ctx);
53  ATH_CHECK(LVL1Collection.record(std::make_unique<InDetTimeCollection>()));
54  ATH_MSG_DEBUG("InDetTimeCollection " << LVL1Collection.name() << " registered in StoreGate");
55  LVL1Collection->reserve(vecRobs.size());
56 
57  BCIDCollection = SG::makeHandle(m_BCIDCollectionKey,ctx);
58  ATH_CHECK(BCIDCollection.record(std::make_unique<InDetTimeCollection>()));
59  ATH_MSG_DEBUG("InDetTimeCollection " << BCIDCollection.name() << " registered in StoreGate");
60  BCIDCollection->reserve(vecRobs.size());
61  }
62 
63 #ifdef PIXEL_DEBUG
64  ATH_MSG_DEBUG(" New event, reset the collection set");
65 #endif
66 
67  // loop over the ROB fragments
68  for (; rob_it!=vecRobs.end(); ++rob_it) {
69  uint32_t robid = (*rob_it)->rob_source_id();
70 #ifdef PIXEL_DEBUG
71  ATH_MSG_DEBUG("Found ROB " << std::hex << robid << std::dec);
72 #endif
73 
74  if ( m_storeInDetTimeColls ) {
75  unsigned int lvl1id = (*rob_it)->rod_lvl1_id();
76  LVL1Collection->emplace_back(robid,lvl1id) ;
77 
78  unsigned int bcid = (*rob_it)->rod_bc_id();
79  BCIDCollection->emplace_back(robid,bcid);
80 
81 #ifdef PIXEL_DEBUG
82  ATH_MSG_DEBUG("Stored LVL1ID "<<lvl1id<<" and BCID "<<bcid<<" in InDetTimeCollections");
83 #endif
84 
85  }
86 
87  // here the code for the timing monitoring should be reinserted
88  // using 1 container per event and subdetector
89  StatusCode sc = m_decoder->fillCollection(&**rob_it, rdoIdc, decodingErrors,nullptr,ctx);
90 
91  const int issuesMessageCountLimit = 100;
92  if (sc==StatusCode::FAILURE) {
93  if (m_DecodeErrCount < issuesMessageCountLimit) {
94  ATH_MSG_INFO("Problem with Pixel ByteStream Decoding!");
96  }
97  else if (issuesMessageCountLimit == m_DecodeErrCount) {
98  ATH_MSG_INFO("Too many Problems with Pixel Decoding messages. Turning message off.");
100  }
101  }
102  }
103  return StatusCode::SUCCESS;
104 }
105 
107  //=========================================================
108  // Size of Pixel BS Error container
109  //
110  // The error would be stored not only for module but also each FE (x16) per module.
111  // In addition, IBL FEI4 provides error counter between trigger, this also extends
112  // the size beyond nominal module + FE ID. These numbers come from the hardware
113  // specification so that there is no easy way to document in the header file.
114  // Rather, put the hardcoded number here.
115  //
116  // Total number of pixel modules: 2048
117  // Number of FE chips per module: 16
118  // -------------------------------------
119  // 2048 x 17 (module + FE) = 34816
120  //
121  // IBL extra error information :
122  // 280(module) x 2(FE) x 32(error counter) = 17920
123  // -------------------------------------
124  //
125  // isActive status : 2048
126  // -------------------------------------
127  // Total : 54784
128  //=========================================================
130 }
PixelRawDataProviderTool::initialize
StatusCode initialize() override
initialize
Definition: PixelRawDataProviderTool.cxx:24
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
PixelRodDecoder::ERROR_CONTAINER_MAX
constexpr static size_t ERROR_CONTAINER_MAX
Definition: PixelRodDecoder.h:111
initialize
void initialize()
Definition: run_EoverP.cxx:894
IDCInDetBSErrContainer
IDC like storage for BS errors, TODO, customise implementation further so that we store int rather th...
Definition: IDCInDetBSErrContainer.h:19
PixelRawDataProviderTool::PixelRawDataProviderTool
PixelRawDataProviderTool(const std::string &type, const std::string &name, const IInterface *parent)
constructor
Definition: PixelRawDataProviderTool.cxx:17
PixelRawDataProviderTool::m_LVL1CollectionKey
SG::WriteHandleKey< InDetTimeCollection > m_LVL1CollectionKey
Definition: PixelRawDataProviderTool.h:47
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
PixelRawDataProviderTool.h
EventContainers::IIdentifiableCont
Definition: IIdentifiableCont.h:13
PixelRawDataProviderTool::m_DecodeErrCount
std::atomic_int m_DecodeErrCount
Definition: PixelRawDataProviderTool.h:51
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:269
PixelRawDataProviderTool::convert
StatusCode convert(std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vecRobs, IPixelRDO_Container *rdoIdc, IDCInDetBSErrContainer &decodingErrors, const EventContext &ctx) const final
this is the main decoding method
Definition: PixelRawDataProviderTool.cxx:34
WriteHandle.h
Handle class for recording to StoreGate.
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment
eformat::ROBFragment< PointerType > ROBFragment
Definition: RawEvent.h:27
PixelRawDataProviderTool::m_storeInDetTimeColls
Gaudi::Property< bool > m_storeInDetTimeColls
Definition: PixelRawDataProviderTool.h:49
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
PixelRawDataProviderTool::SizeOfIDCInDetBSErrContainer
int SizeOfIDCInDetBSErrContainer() const final
Size of IDCInDetBSErrContainer.
Definition: PixelRawDataProviderTool.cxx:106
PixelRodDecoder.h
PixelRawDataProviderTool::m_BCIDCollectionKey
SG::WriteHandleKey< InDetTimeCollection > m_BCIDCollectionKey
Definition: PixelRawDataProviderTool.h:48
PixelRawDataProviderTool::m_decoder
ToolHandle< IPixelRodDecoder > m_decoder
Definition: PixelRawDataProviderTool.h:44
AthAlgTool
Definition: AthAlgTool.h:26