ATLAS Offline Software
Loading...
Searching...
No Matches
RecMuCTPIByteStreamTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 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
16static const InterfaceID IID_IRecMuCTPIByteStreamTool( "RecMuCTPIByteStreamTool", 1, 1 );
17
23
25
26}
27
32RecMuCTPIByteStreamTool::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;
76 ATH_CHECK( detStore()->retrieve(l1menu) );
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
147 uint16_t sum[ MuCTPI_RIO::N_SUM ];
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.get() : 0,
180 m_tgcRoITool.isSet() ? m_tgcRoITool.get() : 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}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
static const InterfaceID IID_IRecMuCTPIByteStreamTool("RecMuCTPIByteStreamTool", 1, 1)
Unique interface ID of the tool that identifies it to the framweork.
uint16_t bcId(uint32_t data)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
This class defines the reconstructed Muon ROI.
Definition RecMuonRoI.h:60
virtual double eta() const
returns eta coord of ROI
Definition RecMuonRoI.h:117
unsigned int sectorID() const
returns sector ID ROI
Definition RecMuonRoI.h:111
virtual double phi() const
returns phi coord of ROI
Definition RecMuonRoI.h:114
bool firstCandidate() const
returns true if this was the highest pt candidate in this sector
Definition RecMuonRoI.h:132
unsigned int getThresholdNumber() const
returns the Threshold Number (1 to 6) associated with this RecRoI
Definition RecMuonRoI.h:120
unsigned int sysID() const
returns system ID ROI (Barrel=0, Endcap=1, Forward=2)
Definition RecMuonRoI.h:105
unsigned int subsysID() const
returns sub-system ID ROI (0=-z,1=+z)
Definition RecMuonRoI.h:108
bool sectorOverflow() const
returns true if there were > 2 candidates in this sector
Definition RecMuonRoI.h:135
bool padOverflow() const
returns true if there were > 1 candidates in this pad
Definition RecMuonRoI.h:138
unsigned int getThresholdValue() const
returns the Threshold Value (in GeV) associated with this RecRoI
Definition RecMuonRoI.h:123
unsigned int getRoINumber() const
return RoI number in hardware numbering scheme
Definition RecMuonRoI.h:126
Reconstruction Input Object of the MuCTPI hardware and simulation.
Definition MuCTPI_RIO.h:43
void headerBCID(uint32_t val)
Set the BCID specified in the header.
Definition MuCTPI_RIO.h:101
void headerLVL1ID(uint32_t val)
Set the LVL1 ID specified in the header.
Definition MuCTPI_RIO.h:99
void headerNumberStatusWords(uint32_t val)
Set the number of status words as it was specified in the trailer
Definition MuCTPI_RIO.h:109
void headerRunNumber(uint32_t val)
Set the run number specified in the header.
Definition MuCTPI_RIO.h:97
std::vector< uint32_t > & headerStatusWords()
Get the status words from the payload.
Definition MuCTPI_RIO.h:111
void headerSourceId(uint32_t val)
Set the ROD ID specidied in the header.
Definition MuCTPI_RIO.h:95
void headerDetectorEventType(uint32_t val)
Set the event type specified in the header.
Definition MuCTPI_RIO.h:105
void setSum(const uint16_t *sum)
Set the multiplicity sum.
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
void setBCID(const uint16_t bcId)
Function setting the BCID of the object.
Definition MuCTPI_RIO.h:55
void headerNumberDataWords(uint32_t val)
Set the number of data words as it was specified in the trailer
Definition MuCTPI_RIO.h:107
void headerLVL1TriggerType(uint32_t val)
Set the LVL1 trigger type specified in the header.
Definition MuCTPI_RIO.h:103
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment ROBF
StatusCode convert(const ROBF *rob, MuCTPI_RIO *&cont)
Convert ROBFragment to MuCTPI_RIO.
ToolHandle< LVL1::ITrigT1MuonRecRoiTool > m_tgcRoITool
static const InterfaceID & interfaceID()
AlgTool InterfaceID.
ToolHandle< LVL1::ITrigT1MuonRecRoiTool > m_rpcRoITool
MuCTPISrcIdMap m_srcIdMap
Object storing the various IDs of the MuCTPI fragment.
virtual StatusCode initialize() override
Function to initialise the tool.
RecMuCTPIByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
Default constructor.
L1 menu configuration.
Definition L1Menu.h:28
const DataType * PointerType
Definition RawEvent.h:25