ATLAS Offline Software
Loading...
Searching...
No Matches
CTPByteStreamTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5// CTP data format include(s):
6#include "CTPfragment/CTPfragment.h"
7#include "CTPfragment/CTPdataformat.h"
8#include "CTPfragment/CTPdataformatVersion.h"
9
10// Trigger include(s):
12
13// Local include(s):
14#include "CTPByteStreamTool.h"
15
17static const InterfaceID IID_ICTPByteStreamTool( "CTPByteStreamTool", 1, 0 );
18
23const InterfaceID& CTPByteStreamTool::interfaceID() {
25}
26
31CTPByteStreamTool::CTPByteStreamTool( const std::string& type, const std::string& name,
32 const IInterface* parent )
33 : AthAlgTool( type, name, parent ) {
34
35 declareInterface< CTPByteStreamTool >( this );
36}
37
38
44
45 MsgStream log( msgSvc(), name() );
46 ATH_MSG_DEBUG("executing convert() from RDO to ROBFragment");
47
48 //get CTP version
49 unsigned int ctpVersionNumber = result->getCTPVersionNumber();
50 CTPdataformatVersion ctpVersion(ctpVersionNumber);
51
52 // Clear Event Assembler
53 m_fea.clear();
54
55 // Reset lumi-block number to 1
56 m_fea.setDetEvtType( 1 );
57 // Set L1Apos to center of readout window
58 uint16_t minorVersion = ( result->getNumberOfBunches() - 1u ) / 2u;
59 minorVersion &= ctpVersion.getL1APositionMask();
60 minorVersion <<= ctpVersion.getL1APositionShift();
61 m_fea.setRodMinorVersion( minorVersion );
62
64
65 // Source ID of CTP
66 const uint32_t rodId = m_srcIdMap.getRodID();
67
68 ATH_MSG_DEBUG(" ROD ID:" << MSG::hex << rodId);
69
70 // get the ROD data container to be filled
71 theROD = m_fea.getRodData( rodId );
72
73 ATH_MSG_VERBOSE(" Dumping CTP words:");
74
75 // fill Data Words
76 const std::vector< uint32_t >& vDataWords = result->getDataWords();
77 std::vector< uint32_t >::const_iterator it = vDataWords.begin();
78 std::vector< uint32_t >::const_iterator end = vDataWords.end();
79 for( ; it != end; ++it ) {
80 theROD->push_back( *it );
81 ATH_MSG_VERBOSE(" 0x" << MSG::hex << std::setw( 8 ) << ( *it ));
82 }
83
84 // Now fill full event
85 ATH_MSG_DEBUG("Now filling the event with the CTP fragment");
86 m_fea.fill( re, log );
87
88 return StatusCode::SUCCESS;
89}
90
91
96StatusCode CTPByteStreamTool::convert( const ROBF* rob, CTP_RDO*& result ) {
97
98 MsgStream log( msgSvc(), name() );
99 ATH_MSG_DEBUG("executing convert() from ROBFragment to RDO");
100
101 const uint32_t ctpRodId = m_srcIdMap.getRodID();
102 const uint32_t rodId = rob->rod_source_id();
103
104 ATH_MSG_DEBUG(" expected ROD sub-detector ID: " << std::hex << ctpRodId
105 << " ID found: " << std::hex << rodId << std::dec);
106
107 if ( rodId == ctpRodId ) {
108
109 ATH_MSG_VERBOSE(" Dumping CTP words:");
110
111 // For generality let's declare the data pointer like this. Altough it's
112 // unlikely to ever change from being a pointer to uint32_t-s.
114 rob->rod_data( it_data );
115 const uint32_t ndata = rob->rod_ndata();
116
117 // data words
118 std::vector<uint32_t> vDataWords;
119 for ( uint32_t i = 0; i < ndata; ++i, ++it_data ) {
120 vDataWords.push_back( static_cast<uint32_t>( *it_data ) );
121 ATH_MSG_VERBOSE(" 0x" << MSG::hex << std::setw( 8 ) << *it_data);
122 }
123
124 // create CTP RDO
125 uint32_t nExtraWords=0;
126 nExtraWords=CTPfragment::numberExtraPayloadWords(rob);
127 unsigned int ctpVersionNumber = CTPfragment::ctpFormatVersion(rob);
128 result = new CTP_RDO(ctpVersionNumber, std::move(vDataWords) , nExtraWords);
129
130 uint8_t l1apos = CTPfragment::lvl1AcceptBunch(rob);
131 result->setL1AcceptBunchPosition(l1apos);
132
133 uint32_t tc = CTPfragment::turnCounter(rob);
134 result->setTurnCounter(tc);
135
136 return StatusCode::SUCCESS;
137 }
138
139 ATH_MSG_ERROR("Wrong ROD ID found in the CTP ROB fragment!");
140 return StatusCode::FAILURE;
141}
const boost::regex re(r_e)
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
static const InterfaceID IID_ICTPByteStreamTool("CTPByteStreamTool", 1, 0)
Unique interface ID of the tool that identifies it to the framweork.
static Double_t tc
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
Definition RawEvent.h:39
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
StatusCode convert(const ROBF *rob, CTP_RDO *&result)
Convert ROBFragment to CTP_RDO.
CTPSrcIdMap m_srcIdMap
Object storing the various IDs of the CTP fragment.
FullEventAssembler< CTPSrcIdMap > m_fea
Object used in creating the CTP ROB fragment.
CTPByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
Default constructor.
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment ROBF
static const InterfaceID & interfaceID()
AlgTool InterfaceID.
std::vector< uint32_t > RODDATA
ROD data as a vector of unsigned int.
const DataType * PointerType
Definition RawEvent.h:25