ATLAS Offline Software
RecMuCTPIByteStreamTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 // Trigger include(s):
10 #include "TrigConfData/L1Menu.h"
11 
12 // Local include(s):
14 
16 static const InterfaceID IID_IRecMuCTPIByteStreamTool( "RecMuCTPIByteStreamTool", 1, 1 );
17 
23 
24  return IID_IRecMuCTPIByteStreamTool;
25 
26 }
27 
32 RecMuCTPIByteStreamTool::RecMuCTPIByteStreamTool( const std::string& type, const std::string& name,
33  const IInterface* parent )
34  : AthAlgTool( type, name, parent )
35 
36 {
37  declareInterface< RecMuCTPIByteStreamTool >( this );
38 }
39 
40 
46 
47  StatusCode sc = m_rpcRoITool.retrieve();
48  if( sc.isFailure() ) {
49  ATH_MSG_WARNING("Couldn't access RPC RecMuonRoISvc");
50  } else {
51  ATH_MSG_DEBUG("Connected to RPC RecMuonRoISvc");
52  }
53 
54  sc = m_tgcRoITool.retrieve();
55  if( sc.isFailure() ) {
56  ATH_MSG_WARNING("Couldn't access TGC RecMuonRoISvc");
57  } else {
58  ATH_MSG_DEBUG("Connected to TGC RecMuonRoISvc");
59  }
60 
61  return StatusCode::SUCCESS;
62 
63 }
64 
65 
71 
72  ATH_MSG_DEBUG("executing convert() from ROBFragment to RIO");
73 
74  // L1Menu
75  const TrigConf::L1Menu * l1menu = nullptr;
77 
78  // Source ID of MIROD
79  const uint32_t miRodId = m_srcIdMap.getRodID();
80 
81  /* get ROD source ID */
82  uint32_t rodId = rob->rod_source_id();
83 
84  if( rodId == miRodId ) {
85 
86  // result
87  MuCTPI_RIO* muCTPI_RIO = new MuCTPI_RIO;
88 
89  // get the ROD header data and store it
90  const uint32_t bcid = rob->rod_bc_id();
91  const uint32_t ndata = rob->rod_ndata();
92  const uint32_t detev_type = rob->rod_detev_type();
93  const uint32_t lvl1_type = rob->rod_lvl1_trigger_type();
94  const uint32_t lvl1_id = rob->rod_lvl1_id();
95  const uint32_t run_no = rob->rod_run_no();
96  const uint32_t nstatus = rob->rod_nstatus();
98  rob->rod_status( it_statusData );
99 
100  ATH_MSG_VERBOSE(" Dumping CTP ROD fragment Header data:");
101  ATH_MSG_VERBOSE("Source ID 0x" << MSG::hex << rodId << MSG::dec);
102  ATH_MSG_VERBOSE("BCID 0x" << MSG::hex << bcid << MSG::dec
103  << " (dec " << bcid << ")");
104  ATH_MSG_VERBOSE("Detector event type 0x" << MSG::hex << detev_type
105  << MSG::dec << " (dec " << detev_type << ")");
106  ATH_MSG_VERBOSE("Level-1 ID 0x" << MSG::hex << lvl1_id << MSG::dec
107  << " (dec " << lvl1_id << ")");
108  ATH_MSG_VERBOSE("Level-1 type 0x" << MSG::hex << lvl1_type << MSG::dec
109  << " (dec " << lvl1_type << ")");
110  ATH_MSG_VERBOSE("Run number " << run_no);
111  ATH_MSG_VERBOSE("Number of data words " << ndata);
112  ATH_MSG_VERBOSE("Number of status words ");
113  for ( uint32_t i = 0; i < nstatus; ++i , ++it_statusData) {
114  ATH_MSG_VERBOSE("Status word # " << i << ": 0x" << MSG::hex << (*it_statusData) << MSG::dec
115  << " (dec " << (*it_statusData) << ")");
116  muCTPI_RIO->headerStatusWords().push_back( static_cast<uint32_t>( *it_statusData ) );
117  }
118  muCTPI_RIO->headerSourceId(rodId);
119  muCTPI_RIO->headerRunNumber(run_no);
120  muCTPI_RIO->headerLVL1ID(lvl1_id);
121  muCTPI_RIO->headerBCID(bcid);
122  muCTPI_RIO->headerLVL1TriggerType(lvl1_type);
123  muCTPI_RIO->headerDetectorEventType(detev_type);
124  muCTPI_RIO->headerNumberDataWords(ndata);
125  muCTPI_RIO->headerNumberStatusWords(nstatus);
126 
127  ATH_MSG_DEBUG(" Dumping MuCTPI words:");
128 
130  rob->rod_data( it_data );
131 
132  //First count mult words
133  int nMultWords = 0;
134  for( uint32_t i = 0; i < ndata; ++i ) {
135  if( ((*it_data) & 0x20000000) != 0 ) nMultWords++;
136  ++it_data;
137  }
138 
139  rob->rod_data( it_data );
140 
141  it_data+=(nMultWords-1)/2;//Goes to the central BC of the RO window
142 
143  ATH_MSG_DEBUG(" 0x" << MSG::hex << std::setw( 8 ) << *it_data
144  << " (candidate multiplicity)");
145 
146  // candidate multiplicities
148  for ( int i = 0; i < MuCTPI_RIO::N_SUM; ++i )
149  sum[ i ] = ( *it_data >> ( i * 3 ) ) & 0x1F;
150  muCTPI_RIO->setSum( sum );
151 
152  // BCID
153  uint16_t g_bcId = ( (*it_data) & 0x001C0000 ) >> 18;
154  muCTPI_RIO->setBCID( g_bcId );
155 
156  it_data+=(nMultWords+1)/2;//Goes to the first candidate word;
157 
158  // data words
159  for( uint32_t i = nMultWords; i < ndata; ++i, ++it_data ) {
160 
161  ATH_MSG_DEBUG(" 0x" << MSG::hex << std::setw( 8 ) << *it_data);
162 
163  // extract BCID
164  const uint32_t tmpWord = static_cast<uint32_t>( *it_data ); // The two types are the same right now, but it might change.
165  uint16_t bcId = ( tmpWord & 0x0001C000 ) >> 14;
166 
167  // accepted bit
168  bool accepted = true;
169  if ( ( tmpWord & 0x04000000 ) == 0 )
170  accepted = false;
171 
172  // make RoI word
173  uint32_t roiWord = ( tmpWord & 0x00003FFF ) + ( ( tmpWord & 0x03FE0000 ) >> 3 );
174 
175  ATH_MSG_DEBUG(MSG::hex << std::setw( 8 ) << *it_data
176  << " : ROI=" << std::setw( 8 ) << roiWord);
177 
178  // reconstruct
179  LVL1::RecMuonRoI thisRoI( roiWord, m_rpcRoITool.isSet() ? m_rpcRoITool.operator->() : 0,
180  m_tgcRoITool.isSet() ? m_tgcRoITool.operator->() : 0, l1menu );
181 
182  uint16_t pTVal = thisRoI.getThresholdValue();
183  uint16_t pTNumber = thisRoI.getThresholdNumber();
184  uint16_t roiNumber = thisRoI.getRoINumber();
185  uint16_t secId = thisRoI.sectorID();
186  uint16_t sysId = thisRoI.sysID();
187  uint16_t hemisphere = thisRoI.subsysID();
188  double eta = thisRoI.eta();
189  double phi = thisRoI.phi();
190  bool first = thisRoI.firstCandidate();
191  bool duplicatedRoI = thisRoI.padOverflow();
192  bool duplicatedSector = thisRoI.sectorOverflow();
193 
194  // fill
195  muCTPI_RIO->setRoI( bcId, pTVal,pTNumber, eta, phi, secId, sysId, hemisphere, roiNumber,
196  accepted, first, duplicatedRoI, duplicatedSector );
197  }
198 
199  /* set return value */
200  result = muCTPI_RIO;
201 
202  return StatusCode::SUCCESS;
203 
204  } else {
205 
206  ATH_MSG_WARNING("Expected source ID 0x" << MSG::hex << miRodId << " but found 0x"
207  << rodId << MSG::dec);
208  return StatusCode::FAILURE;
209 
210  }
211 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
MuCTPI_RIO::headerSourceId
void headerSourceId(uint32_t val)
Set the ROD ID specidied in the header.
Definition: MuCTPI_RIO.h:95
RecMuCTPIByteStreamTool::m_rpcRoITool
ToolHandle< LVL1::ITrigT1MuonRecRoiTool > m_rpcRoITool
Definition: RecMuCTPIByteStreamTool.h:59
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
MuCTPI_RIO::headerDetectorEventType
void headerDetectorEventType(uint32_t val)
Set the event type specified in the header.
Definition: MuCTPI_RIO.h:105
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
MuCTPI_RIO::headerNumberDataWords
void headerNumberDataWords(uint32_t val)
Set the number of data words as it was specified in the trailer
Definition: MuCTPI_RIO.h:107
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
MuCTPI_RIO::headerRunNumber
void headerRunNumber(uint32_t val)
Set the run number specified in the header.
Definition: MuCTPI_RIO.h:97
RecMuonRoI.h
TrigConf::L1Menu
L1 menu configuration.
Definition: L1Menu.h:28
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
RecMuCTPIByteStreamTool::convert
StatusCode convert(const ROBF *rob, MuCTPI_RIO *&cont)
Convert ROBFragment to MuCTPI_RIO.
Definition: RecMuCTPIByteStreamTool.cxx:70
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
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
MuCTPI_RIO::setRoI
void setRoI(const uint16_t bcId, const uint16_t pTval, const uint16_t pTnum, const double eta, const double phi, const uint16_t secID, const uint16_t sysId, const uint16_t hemisphere, const uint16_t roiNum, const bool accepted, const bool first, const bool duplicatedRoI, const bool duplicatedSector)
Add a muon RoI to the object
Definition: MuCTPI_RIO.cxx:69
RecMuCTPIByteStreamTool::RecMuCTPIByteStreamTool
RecMuCTPIByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
Default constructor.
Definition: RecMuCTPIByteStreamTool.cxx:32
xAOD::roiWord
roiWord
Definition: TrigMissingET_v1.cxx:36
MuCTPI_RIO
Reconstruction Input Object of the MuCTPI hardware and simulation.
Definition: MuCTPI_RIO.h:43
RecMuCTPIByteStreamTool::m_tgcRoITool
ToolHandle< LVL1::ITrigT1MuonRecRoiTool > m_tgcRoITool
Definition: RecMuCTPIByteStreamTool.h:62
OFFLINE_FRAGMENTS_NAMESPACE::PointerType
const DataType * PointerType
Definition: RawEvent.h:25
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
LVL1::RecMuonRoI
This class defines the reconstructed Muon ROI.
Definition: RecMuonRoI.h:60
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
eformat::ROBFragment
Definition: L1CaloBsDecoderUtil.h:12
lumiFormat.i
int i
Definition: lumiFormat.py:85
MuCTPI_RIO::headerNumberStatusWords
void headerNumberStatusWords(uint32_t val)
Set the number of status words as it was specified in the trailer
Definition: MuCTPI_RIO.h:109
MuCTPI_RIO::setSum
void setSum(const uint16_t *sum)
Set the multiplicity sum.
Definition: MuCTPI_RIO.cxx:34
RawEvent.h
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
MuCTPI_RIO.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuCTPI_RIO::headerLVL1ID
void headerLVL1ID(uint32_t val)
Set the LVL1 ID specified in the header.
Definition: MuCTPI_RIO.h:99
MuCTPI_RIO::headerStatusWords
std::vector< uint32_t > & headerStatusWords()
Get the status words from the payload.
Definition: MuCTPI_RIO.h:111
MuCTPI_RIO::N_SUM
@ N_SUM
Definition: MuCTPI_RIO.h:47
RecMuCTPIByteStreamTool::m_srcIdMap
MuCTPISrcIdMap m_srcIdMap
Object storing the various IDs of the MuCTPI fragment.
Definition: RecMuCTPIByteStreamTool.h:57
MuCTPI_RIO::headerBCID
void headerBCID(uint32_t val)
Set the BCID specified in the header.
Definition: MuCTPI_RIO.h:101
bcId
uint16_t bcId(uint32_t data)
Definition: TgcByteStreamData.h:326
RecMuCTPIByteStreamTool::interfaceID
static const InterfaceID & interfaceID()
AlgTool InterfaceID.
Definition: RecMuCTPIByteStreamTool.cxx:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
RecMuCTPIByteStreamTool::initialize
virtual StatusCode initialize() override
Function to initialise the tool.
Definition: RecMuCTPIByteStreamTool.cxx:45
xAOD::roiNumber
setTeId setLumiBlock setRoiId setRoiSubsystem roiNumber
Definition: L2StandAloneMuon_v1.cxx:339
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
MuCTPI_RIO::headerLVL1TriggerType
void headerLVL1TriggerType(uint32_t val)
Set the LVL1 trigger type specified in the header.
Definition: MuCTPI_RIO.h:103
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MuCTPI_RIO::setBCID
void setBCID(const uint16_t bcId)
Function setting the BCID of the object.
Definition: MuCTPI_RIO.h:55
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DeMoScan.first
bool first
Definition: DeMoScan.py:536
python.XMLReader.l1menu
l1menu
Definition: XMLReader.py:73
AthAlgTool
Definition: AthAlgTool.h:26
L1Menu.h
RecMuCTPIByteStreamTool.h