ATLAS Offline Software
MuCTPIByteStreamTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MuCTPIByteStreamTool.h"
8 
9 
10 // Unique interface ID of the tool that identifies it to the framweork
11 static const InterfaceID IID_IMuCTPIByteStreamTool( "MuCTPIByteStreamTool", 1, 1 );
12 
17 const InterfaceID & MuCTPIByteStreamTool::interfaceID() {
18  return IID_IMuCTPIByteStreamTool;
19 }
20 
25 MuCTPIByteStreamTool::MuCTPIByteStreamTool( const std::string& type, const std::string& name,
26  const IInterface* parent )
27  : AthAlgTool( type, name, parent ) {
28 
29  declareInterface<MuCTPIByteStreamTool>( this );
30 }
31 
37 
38  ATH_MSG_DEBUG("executing convert() from RDO to ROBFragment");
39 
40  // Clear Event Assembler
41  m_fea.clear();
42 
43  // MIROD
45 
46  // Source ID of MIROD
47  const uint32_t rodId = m_srcIdMap.getRodID();
48 
49  // get the ROD data container to be filled
50  theROD = m_fea.getRodData( rodId );
51 
52  ATH_MSG_VERBOSE(" Dumping MuCTPI words:");
53 
54  // fill Candidate Multiplicity
55  const std::vector< uint32_t >& multiWord = result->getAllCandidateMultiplicities();
56  std::vector< uint32_t >::const_iterator it = multiWord.begin();
57  std::vector< uint32_t >::const_iterator it_e = multiWord.end();
58  for( ; it != it_e; ++it ) {
59  theROD->push_back( *it );
60  ATH_MSG_VERBOSE(" 0x" << MSG::hex << std::setfill( '0' )
61  << std::setw( 8 ) << ( *it ) << " (candidate multiplicity)");
62  }
63 
64  // fill Data Words
65  const std::vector< uint32_t >& dataWord = result->dataWord();
66  it = dataWord.begin();
67  it_e = dataWord.end();
68  for( ; it != it_e; ++it ) {
69  theROD->push_back( *it );
70  ATH_MSG_VERBOSE(" 0x" << MSG::hex << std::setfill( '0' )
71  << std::setw( 8 ) << ( *it ) << " (candidate word)");
72  }
73 
74  // Now fill full event
75  ATH_MSG_DEBUG("Now filling the event with the MuCTPI fragment");
76  m_fea.fill( re, msg() );
77 
78  return StatusCode::SUCCESS;
79 }
80 
86 
87  ATH_MSG_DEBUG("executing convert() from ROBFragment to RDO");
88 
89  // Source ID of MIROD
90  const uint32_t miRodId = m_srcIdMap.getRodID();
91 
92  // check ROD source ID
93  const uint32_t rodId = rob->rod_source_id();
94 
95  // check BC ID
96  const uint32_t bcId = rob->rod_bc_id();
97 
98  ATH_MSG_DEBUG(" expected ROD sub-detector ID: " << std::hex << miRodId
99  << " ID found: " << std::hex << rodId << std::dec);
100 
101  if( rodId == miRodId || rodId == 0x7501 ) {
102 
103  ATH_MSG_VERBOSE(" ROD Header BCID " << bcId << ", dumping MuCTPI words:");
104  if( rodId == 0x7501 ) {
105  ATH_MSG_DEBUG(" Deprecated ROD source id found: "
106  << std::hex << rodId << std::dec);
107  }
108 
109  // For generality let's declare the data pointer like this. Altough it's
110  // unlikely to ever change from being a pointer to uint32_t-s.
112  rob->rod_data( it_data );
113  const uint32_t ndata = rob->rod_ndata();
114  ATH_MSG_VERBOSE(" number of data words: " << ndata);
115 
116  // candidate multiplicity
117  std::vector< uint32_t > candidateMultiplicity;
118  // data words
119  std::vector< uint32_t > dataWord;
120  for( uint32_t i = 0; i < ndata; ++i, ++it_data ) {
121  if( *it_data >> LVL1::MuCTPIBits::MULT_WORD_FLAG_SHIFT ) {
122  candidateMultiplicity.push_back( static_cast< uint32_t >( *it_data ) );
123  ATH_MSG_VERBOSE(" 0x" << MSG::hex << std::setw( 8 ) << std::setfill( '0' )
124  << ( *it_data ) << " (candidate multiplicity)");
125  } else {
126  dataWord.push_back( static_cast< uint32_t >( *it_data ) );
127  ATH_MSG_VERBOSE(" 0x" << MSG::hex << std::setw( 8 ) << std::setfill( '0' )
128  << ( *it_data ) << " (candidate word)");
129  }
130  }
131 
132  // create MuCTPI RDO
133  result = new MuCTPI_RDO( std::move(candidateMultiplicity), std::move(dataWord) );
134  return StatusCode::SUCCESS;
135 
136  }
137 
138  ATH_MSG_ERROR("Wrong ROD ID found in the MuCTPI ROB fragment!");
139  return StatusCode::FAILURE;
140 }
RawEventWrite
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
Definition: RawEvent.h:39
MuCTPISrcIdMap::getRodID
uint32_t getRodID() const
get a ROD Source ID
Definition: MuCTPISrcIdMap.cxx:12
get_generator_info.result
result
Definition: get_generator_info.py:21
FullEventAssembler
Template class for assembling a full atlas raw event from subfragments.
Definition: FullEventAssembler.h:40
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
MuCTPIByteStreamTool::interfaceID
static const InterfaceID & interfaceID()
AlgTool InterfaceID.
Definition: MuCTPIByteStreamTool.cxx:17
skel.it
it
Definition: skel.GENtoEVGEN.py:423
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
MuCTPIByteStreamTool::MuCTPIByteStreamTool
MuCTPIByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
Default constructor.
Definition: MuCTPIByteStreamTool.cxx:25
MuCTPIByteStreamTool::m_srcIdMap
MuCTPISrcIdMap m_srcIdMap
Object storing the various IDs of the MuCTPI fragment.
Definition: MuCTPIByteStreamTool.h:52
OFFLINE_FRAGMENTS_NAMESPACE::PointerType
const DataType * PointerType
Definition: RawEvent.h:25
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
eformat::ROBFragment
Definition: L1CaloBsDecoderUtil.h:12
lumiFormat.i
int i
Definition: lumiFormat.py:92
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
MuCTPIByteStreamTool.h
FullEventAssembler::clear
void clear()
Clear internal stack.
bcId
uint16_t bcId(uint32_t data)
Definition: TgcByteStreamData.h:329
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
MuCTPI_Bits.h
MuCTPIByteStreamTool::m_fea
FullEventAssembler< MuCTPISrcIdMap > m_fea
Object used in creating the MuCTPI ROB fragment.
Definition: MuCTPIByteStreamTool.h:54
MuCTPI_RDO.h
MuCTPI_RDO
Class representing the readout data of the MuCTPI hardware and simulation.
Definition: MuCTPI_RDO.h:41
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
re
const boost::regex re(r_e)
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
AthAlgTool
Definition: AthAlgTool.h:26
MuCTPIByteStreamTool::convert
StatusCode convert(const ROBF *rob, MuCTPI_RDO *&result)
Convert ROBFragment to MuCTPI_RDO.
Definition: MuCTPIByteStreamTool.cxx:85
FullEventAssembler::getRodData
RODDATA * getRodData(uint32_t id)
get a block of ROD data
FullEventAssembler::fill
void fill(RawEventWrite *re, MsgStream &log)
Fill the FullEventFragment with all the ROD data stored in this.