ATLAS Offline Software
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):
11 #include "TrigT1Result/CTP_RDO.h"
12 
13 // Local include(s):
14 #include "CTPByteStreamTool.h"
15 
17 static const InterfaceID IID_ICTPByteStreamTool( "CTPByteStreamTool", 1, 0 );
18 
23 const InterfaceID& CTPByteStreamTool::interfaceID() {
24  return IID_ICTPByteStreamTool;
25 }
26 
31 CTPByteStreamTool::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 
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 
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 }
RawEventWrite
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
Definition: RawEvent.h:39
get_generator_info.result
result
Definition: get_generator_info.py:21
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
FullEventAssembler
Template class for assembling a full atlas raw event from subfragments.
Definition: FullEventAssembler.h:40
CTP_RDO
CTP_RDO
Definition: TrigT1EventTPCnv.cxx:102
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
skel.it
it
Definition: skel.GENtoEVGEN.py:423
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CTPByteStreamTool::m_fea
FullEventAssembler< CTPSrcIdMap > m_fea
Object used in creating the CTP ROB fragment.
Definition: CTPByteStreamTool.h:55
python.CTPfragment.numberExtraPayloadWords
def numberExtraPayloadWords(rob)
Definition: CTPfragment.py:93
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
CTPByteStreamTool::m_srcIdMap
CTPSrcIdMap m_srcIdMap
Object storing the various IDs of the CTP fragment.
Definition: CTPByteStreamTool.h:53
OFFLINE_FRAGMENTS_NAMESPACE::PointerType
const DataType * PointerType
Definition: RawEvent.h:25
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
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
CTPByteStreamTool::convert
StatusCode convert(const ROBF *rob, CTP_RDO *&result)
Convert ROBFragment to CTP_RDO.
Definition: CTPByteStreamTool.cxx:96
FullEventAssembler::clear
void clear()
Clear internal stack.
CTPByteStreamTool::interfaceID
static const InterfaceID & interfaceID()
AlgTool InterfaceID.
Definition: CTPByteStreamTool.cxx:23
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
python.CTPfragment.ctpFormatVersion
def ctpFormatVersion(rob)
Definition: CTPfragment.py:64
CTPByteStreamTool.h
python.CTPfragment.lvl1AcceptBunch
def lvl1AcceptBunch(rob)
Definition: CTPfragment.py:150
CTP_RDO.h
CTPByteStreamTool::CTPByteStreamTool
CTPByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
Default constructor.
Definition: CTPByteStreamTool.cxx:31
CTP_RDO
Definition: CTP_RDO.h:20
CTPSrcIdMap::getRodID
uint32_t getRodID() const
get a ROD Source ID
Definition: CTPSrcIdMap.cxx:13
FullEventAssembler::setRodMinorVersion
void setRodMinorVersion(uint16_t m)
change the ROD minor version
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
re
const boost::regex re(r_e)
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
AthAlgTool
Definition: AthAlgTool.h:26
FullEventAssembler::getRodData
RODDATA * getRodData(uint32_t id)
get a block of ROD data
FullEventAssembler::setDetEvtType
void setDetEvtType(uint32_t m)
change Detector Event Type
FullEventAssembler::fill
void fill(RawEventWrite *re, MsgStream &log)
Fill the FullEventFragment with all the ROD data stored in this.