ATLAS Offline Software
Loading...
Searching...
No Matches
LVL1BS::CpByteStreamTool Class Reference

Tool to perform ROB fragments to CPM towers, CPM hits and CMM-CP hits, and CP container to raw data conversions. More...

#include <CpByteStreamTool.h>

Inheritance diagram for LVL1BS::CpByteStreamTool:
Collaboration diagram for LVL1BS::CpByteStreamTool:

Classes

struct  CmmHitsData
struct  CpByteStreamToolData
struct  CpmHitsData
struct  CpmTowerData
struct  LocalData

Public Member Functions

 CpByteStreamTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~CpByteStreamTool ()
virtual StatusCode initialize () override
StatusCode convert (const std::string &sgKey, const IROBDataProviderSvc::VROBFRAG &robFrags, DataVector< LVL1::CPMTower > *ttCollection) const
 Convert ROB fragments to CPM towers.
StatusCode convert (const std::string &sgKey, const IROBDataProviderSvc::VROBFRAG &robFrags, DataVector< LVL1::CPMHits > *hitCollection) const
 Convert ROB fragments to CPM hits.
StatusCode convert (const std::string &sgKey, const IROBDataProviderSvc::VROBFRAG &robFrags, DataVector< LVL1::CMMCPHits > *hitCollection) const
 Convert ROB fragments to CMM-CP hits.
StatusCode convert (const LVL1::CPBSCollection *cp) const
 Convert CP Container to bytestream.
const std::vector< uint32_t > & sourceIDs () const
 Return reference to vector with all possible Source Identifiers.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()
 AlgTool InterfaceID.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

enum  CollectionType { CPM_TOWERS , CPM_HITS , CMM_CP_HITS }
typedef DataVector< LVL1::CPMTowerCpmTowerCollection
typedef DataVector< LVL1::CPMHitsCpmHitsCollection
typedef DataVector< LVL1::CMMCPHitsCmmCpHitsCollection
typedef std::map< unsigned int, LVL1::CPMTower * > CpmTowerMap
typedef std::map< unsigned int, const LVL1::CPMTower * > ConstCpmTowerMap
typedef std::map< int, LVL1::CPMHits * > CpmHitsMap
typedef std::map< int, const LVL1::CPMHits * > ConstCpmHitsMap
typedef std::map< int, LVL1::CMMCPHits * > CmmCpHitsMap
typedef std::map< int, const LVL1::CMMCPHits * > ConstCmmCpHitsMap
typedef IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator
typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType ROBPointer
typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType RODPointer
typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

std::vector< uint32_t > makeSourceIDs () const
 Create list of all source IDs.
StatusCode convertBs (const std::string &sgKey, const IROBDataProviderSvc::VROBFRAG &robFrags, CpByteStreamToolData &data) const
 Convert bytestream to given container type.
void decodeCmmCp (CmmCpSubBlock *subBlock, int trigCmm, CmmHitsData &data, LocalData &ld) const
 Unpack CMM-CP sub-block.
void decodeCpm (CpmSubBlock *subBlock, int trigCpm, CpByteStreamToolData &data, LocalData &ld) const
 Unpack CPM sub-block.
const LVL1::CPMTowerfindCpmTower (unsigned int key, const ConstCpmTowerMap &ttMap) const
 Find a CPM tower for given key.
LVL1::CPMTowerfindCpmTower (const CpmTowerData &data, unsigned int key) const
const LVL1::CPMHitsfindCpmHits (int crate, int module, const ConstCpmHitsMap &hitsMap) const
 Find CPM hits for given crate, module.
LVL1::CPMHitsfindCpmHits (const CpmHitsData &data, int crate, int module) const
const LVL1::CMMCPHitsfindCmmCpHits (int crate, int dataID, const ConstCmmCpHitsMap &cmmHitsMap) const
 Find CMM-CP hits for given crate, data ID.
LVL1::CMMCPHitsfindCmmCpHits (const CmmHitsData &data, int crate, int dataID) const
void setupCpmTowerMap (const CpmTowerCollection *ttCollection, ConstCpmTowerMap &ttMap, LVL1::TriggerTowerKey &towerKey) const
 Set up CPM tower map.
void setupCpmHitsMap (const CpmHitsCollection *hitCollection, ConstCpmHitsMap &hitsMap) const
 Set up CPM hits map.
void setupCmmCpHitsMap (const CmmCpHitsCollection *hitCollection, ConstCmmCpHitsMap &cmmHitsMap) const
 Set up CMM-CP hits map.
bool slinkSlices (int crate, int module, int modulesPerSlink, int &timeslices, int &trigJem, const ConstCpmTowerMap &ttMap, const ConstCpmHitsMap &hitsMap, const ConstCmmCpHitsMap &cmmHitsMap, LVL1::TriggerTowerKey &towerKey) const
 Get number of slices and triggered slice offset for next slink.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ServiceHandle< IByteStreamCnvSvcm_byteStreamCnvSvc { this, "ByteStreamCnvSvc", "ByteStreamCnvSvc" }
ToolHandle< LVL1::IL1CaloMappingToolm_cpmMaps
 Property: Channel mapping tool.
ToolHandle< LVL1BS::L1CaloErrorByteStreamToolm_errorTool
 Error collection tool.
int m_crateOffsetHw
 Property: Hardware crate number offset.
int m_crateOffsetSw
 Property: Software crate number offset.
int m_version
 Property: Sub_block header version.
int m_dataFormat
 Property: Data compression format.
const int m_channels
 Number of channels per module.
const int m_crates
 Number of crates.
const int m_modules
 Number of CPM modules per crate.
int m_slinks
 Property: Number of slinks per crate when writing out bytestream.
int m_dfltSlices
 Property: Default number of slices in simulation.
int m_forceSlices
 Property: Force number of slices in bytestream.
std::vector< uint32_t > m_sourceIDsProp
 Property: ROB source IDs.
const eformat::SubDetector m_subDetector
 Sub-detector type.
const L1CaloSrcIdMap m_srcIdMap
 Source ID converter.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Tool to perform ROB fragments to CPM towers, CPM hits and CMM-CP hits, and CP container to raw data conversions.

Based on ROD document version 1_09h.

Author
Peter Faulkner

Definition at line 53 of file CpByteStreamTool.h.

Member Typedef Documentation

◆ CmmCpHitsCollection

◆ CmmCpHitsMap

Definition at line 123 of file CpByteStreamTool.h.

◆ ConstCmmCpHitsMap

typedef std::map<int, const LVL1::CMMCPHits*> LVL1BS::CpByteStreamTool::ConstCmmCpHitsMap
private

Definition at line 124 of file CpByteStreamTool.h.

◆ ConstCpmHitsMap

typedef std::map<int, const LVL1::CPMHits*> LVL1BS::CpByteStreamTool::ConstCpmHitsMap
private

Definition at line 122 of file CpByteStreamTool.h.

◆ ConstCpmTowerMap

typedef std::map<unsigned int, const LVL1::CPMTower*> LVL1BS::CpByteStreamTool::ConstCpmTowerMap
private

Definition at line 120 of file CpByteStreamTool.h.

◆ CpmHitsCollection

◆ CpmHitsMap

typedef std::map<int, LVL1::CPMHits*> LVL1BS::CpByteStreamTool::CpmHitsMap
private

Definition at line 121 of file CpByteStreamTool.h.

◆ CpmTowerCollection

◆ CpmTowerMap

typedef std::map<unsigned int, LVL1::CPMTower*> LVL1BS::CpByteStreamTool::CpmTowerMap
private

Definition at line 119 of file CpByteStreamTool.h.

◆ ROBIterator

typedef IROBDataProviderSvc::VROBFRAG::const_iterator LVL1BS::CpByteStreamTool::ROBIterator
private

Definition at line 125 of file CpByteStreamTool.h.

◆ ROBPointer

◆ RODPointer

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Member Enumeration Documentation

◆ CollectionType

Enumerator
CPM_TOWERS 
CPM_HITS 
CMM_CP_HITS 

Definition at line 114 of file CpByteStreamTool.h.

Constructor & Destructor Documentation

◆ CpByteStreamTool()

LVL1BS::CpByteStreamTool::CpByteStreamTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 48 of file CpByteStreamTool.cxx.

51 : AthAlgTool(type, name, parent),
52 m_cpmMaps("LVL1::CpmMappingTool/CpmMappingTool"),
53 m_errorTool("LVL1BS::L1CaloErrorByteStreamTool/L1CaloErrorByteStreamTool"),
54 m_channels(80), m_crates(4), m_modules(14),
55 m_subDetector(eformat::TDAQ_CALO_CLUSTER_PROC_DAQ)
56{
57 declareInterface<CpByteStreamTool>(this);
58
59 declareProperty("CpmMappingTool", m_cpmMaps,
60 "Crate/Module/Channel to Eta/Phi/Layer mapping tool");
61
62 declareProperty("CrateOffsetHw", m_crateOffsetHw = 8,
63 "Offset of CP crate numbers in bytestream");
64 declareProperty("CrateOffsetSw", m_crateOffsetSw = 0,
65 "Offset of CP crate numbers in RDOs");
66
67 // Properties for reading bytestream only
68 declareProperty("ROBSourceIDs", m_sourceIDsProp,
69 "ROB fragment source identifiers");
70
71 // Properties for writing bytestream only
72 declareProperty("DataVersion", m_version = 1,
73 "Format version number in sub-block header");
74 declareProperty("DataFormat", m_dataFormat = 1,
75 "Format identifier (0-1) in sub-block header");
76 declareProperty("SlinksPerCrate", m_slinks = 2,
77 "The number of S-Links per crate");
78 declareProperty("SimulSlices", m_dfltSlices = 1,
79 "The number of slices in the simulation");
80 declareProperty("ForceSlices", m_forceSlices = 0,
81 "If >0, the number of slices in bytestream");
82
83}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::vector< uint32_t > m_sourceIDsProp
Property: ROB source IDs.
int m_dataFormat
Property: Data compression format.
int m_dfltSlices
Property: Default number of slices in simulation.
ToolHandle< LVL1::IL1CaloMappingTool > m_cpmMaps
Property: Channel mapping tool.
int m_slinks
Property: Number of slinks per crate when writing out bytestream.
const eformat::SubDetector m_subDetector
Sub-detector type.
int m_version
Property: Sub_block header version.
int m_crateOffsetSw
Property: Software crate number offset.
int m_forceSlices
Property: Force number of slices in bytestream.
const int m_channels
Number of channels per module.
ToolHandle< LVL1BS::L1CaloErrorByteStreamTool > m_errorTool
Error collection tool.
int m_crateOffsetHw
Property: Hardware crate number offset.
const int m_crates
Number of crates.
const int m_modules
Number of CPM modules per crate.

◆ ~CpByteStreamTool()

LVL1BS::CpByteStreamTool::~CpByteStreamTool ( )
virtual

Definition at line 87 of file CpByteStreamTool.cxx.

88{
89}

Member Function Documentation

◆ convert() [1/4]

StatusCode LVL1BS::CpByteStreamTool::convert ( const LVL1::CPBSCollection * cp) const

Convert CP Container to bytestream.

Vector for current CMM-CP hit0 sub-blocks

Vector for current CMM-CP hit1 sub-blocks

Definition at line 140 of file CpByteStreamTool.cxx.

141{
142 const bool debug = msgLvl(MSG::DEBUG);
143 if (debug) msg(MSG::DEBUG);
144
145 // Get the event assembler
146 FullEventAssembler<L1CaloSrcIdMap>* fea = nullptr;
147 ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler (fea,
148 "CpByteStream") );
149 const uint16_t minorVersion = m_srcIdMap.minorVersion();
150 fea->setRodMinorVersion(minorVersion);
151
152 // Pointer to ROD data vector
153
155
156 // Set up the container maps
157
158 LVL1::TriggerTowerKey towerKey;
159
160 // CPM tower map
161 ConstCpmTowerMap ttMap;
162 setupCpmTowerMap(cp->towers(), ttMap, towerKey);
163
164 // CPM hits map
165 ConstCpmHitsMap hitsMap;
166 setupCpmHitsMap(cp->hits(), hitsMap);
167
168 // CMM-CP hits map
169 ConstCmmCpHitsMap cmmHitsMap;
170 setupCmmCpHitsMap(cp->cmmHits(), cmmHitsMap);
171
172 // Loop over data
173
174 const bool neutralFormat = m_dataFormat == L1CaloSubBlock::NEUTRAL;
175 const int modulesPerSlink = m_modules / m_slinks;
176 int timeslices = 1;
177 int trigCpm = 0;
178 int timeslicesNew = 1;
179 int trigCpmNew = 0;
180 for (int crate=0; crate < m_crates; ++crate) {
181 const int hwCrate = crate + m_crateOffsetHw;
182
183 // CPM modules are numbered 1 to m_modules
184 for (int module=1; module <= m_modules; ++module) {
185 const int mod = module - 1;
186
187 // Pack required number of modules per slink
188
189 if (mod%modulesPerSlink == 0) {
190 const int daqOrRoi = 0;
191 const int slink = (m_slinks == 2) ? 2*(mod/modulesPerSlink)
192 : mod/modulesPerSlink;
193 if (debug) {
194 msg() << "Treating crate " << hwCrate
195 << " slink " << slink << endmsg;
196 }
197 // Get number of CPM slices and triggered slice offset
198 // for this slink
199 if ( ! slinkSlices(crate, module, modulesPerSlink,
200 timeslices, trigCpm,
201 ttMap,
202 hitsMap,
203 cmmHitsMap,
204 towerKey))
205 {
206 msg(MSG::ERROR) << "Inconsistent number of slices or "
207 << "triggered slice offsets in data for crate "
208 << hwCrate << " slink " << slink << endmsg;
209 return StatusCode::FAILURE;
210 }
211 timeslicesNew = (m_forceSlices) ? m_forceSlices : timeslices;
212 trigCpmNew = ModifySlices::peak(trigCpm, timeslices, timeslicesNew);
213 if (debug) {
214 msg() << "Data Version/Format: " << m_version
215 << " " << m_dataFormat << endmsg
216 << "Slices/offset: " << timeslices << " " << trigCpm;
217 if (timeslices != timeslicesNew) {
218 msg() << " modified to " << timeslicesNew << " " << trigCpmNew;
219 }
220 msg() << endmsg;
221 }
222 L1CaloUserHeader userHeader;
223 userHeader.setCpm(trigCpmNew);
224 const uint32_t rodIdCpm = m_srcIdMap.getRodID(hwCrate, slink, daqOrRoi,
226 theROD = fea->getRodData(rodIdCpm);
227 theROD->push_back(userHeader.header());
228 }
229 if (debug) msg() << "Module " << module << endmsg;
230
231 // Create a sub-block for each slice (except Neutral format)
232
233 // Vector for current CPM sub-blocks
234 DataVector<CpmSubBlock> cpmBlocks;
235
236 for (int slice = 0; slice < timeslicesNew; ++slice) {
237 CpmSubBlock* const subBlock = new CpmSubBlock();
238 subBlock->setCpmHeader(m_version, m_dataFormat, slice,
239 hwCrate, module, timeslicesNew);
240 cpmBlocks.push_back(subBlock);
241 if (neutralFormat) break;
242 }
243
244 // Find CPM towers corresponding to each eta/phi pair and fill
245 // sub-blocks
246
247 for (int chan=0; chan < m_channels; ++chan) {
248 double eta = 0.;
249 double phi = 0.;
250 int layer = 0;
251 if (m_cpmMaps->mapping(crate, module, chan, eta, phi, layer)) {
252 const unsigned int key = towerKey.ttKey(phi, eta);
253 const LVL1::CPMTower* const tt = findCpmTower(key, ttMap);
254 if (tt ) {
255 std::vector<int> emData;
256 std::vector<int> hadData;
257 std::vector<int> emError;
258 std::vector<int> hadError;
259 ModifySlices::data(tt->emEnergyVec(), emData, timeslicesNew);
260 ModifySlices::data(tt->hadEnergyVec(), hadData, timeslicesNew);
261 ModifySlices::data(tt->emErrorVec(), emError, timeslicesNew);
262 ModifySlices::data(tt->hadErrorVec(), hadError, timeslicesNew);
263 for (int slice = 0; slice < timeslicesNew; ++slice) {
264 const LVL1::DataError emErrBits(emError[slice]);
265 const LVL1::DataError hadErrBits(hadError[slice]);
266 const int emErr =
267 (emErrBits.get(LVL1::DataError::LinkDown) << 1) |
268 emErrBits.get(LVL1::DataError::Parity);
269 const int hadErr =
270 (hadErrBits.get(LVL1::DataError::LinkDown) << 1) |
271 hadErrBits.get(LVL1::DataError::Parity);
272 const int index = ( neutralFormat ) ? 0 : slice;
273 CpmSubBlock* const subBlock = cpmBlocks[index];
274 subBlock->fillTowerData(slice, chan, emData[slice],
275 hadData[slice], emErr, hadErr);
276 }
277 }
278 }
279 }
280
281 // Add CPM hits
282
283 const LVL1::CPMHits* const hits = findCpmHits(crate, module, hitsMap);
284 if (hits) {
285 std::vector<unsigned int> vec0;
286 std::vector<unsigned int> vec1;
287 ModifySlices::data(hits->HitsVec0(), vec0, timeslicesNew);
288 ModifySlices::data(hits->HitsVec1(), vec1, timeslicesNew);
289 for (int slice = 0; slice < timeslicesNew; ++slice) {
290 const int index = ( neutralFormat ) ? 0 : slice;
291 CpmSubBlock* const subBlock = cpmBlocks[index];
292 subBlock->setHits(slice, vec0[slice], vec1[slice]);
293 }
294 }
295
296 // Pack and write the sub-blocks
297
299 for (pos = cpmBlocks.begin(); pos != cpmBlocks.end(); ++pos) {
300 CpmSubBlock* const subBlock = *pos;
301 if ( !subBlock->pack()) {
302 msg(MSG::ERROR) << "CPM sub-block packing failed" << endmsg;
303 return StatusCode::FAILURE;
304 }
305 if (debug) {
306 msg() << "CPM sub-block data words: "
307 << subBlock->dataWords() << endmsg;
308 }
309 subBlock->write(theROD);
310 }
311 }
312
313 // Append CMMs to last S-Link of the crate
314
315 // Create a sub-block for each slice (except Neutral format)
316
318 DataVector<CmmCpSubBlock> cmmHit0Blocks;
320 DataVector<CmmCpSubBlock> cmmHit1Blocks;
321
322 const int summing = (crate == m_crates - 1) ? CmmSubBlock::SYSTEM
323 : CmmSubBlock::CRATE;
324 for (int slice = 0; slice < timeslicesNew; ++slice) {
325 CmmCpSubBlock* const h0Block = new CmmCpSubBlock();
326 h0Block->setCmmHeader(m_version, m_dataFormat, slice, hwCrate,
327 summing, CmmSubBlock::CMM_CP,
328 CmmSubBlock::RIGHT, timeslicesNew);
329 cmmHit0Blocks.push_back(h0Block);
330 CmmCpSubBlock* const h1Block = new CmmCpSubBlock();
331 h1Block->setCmmHeader(m_version, m_dataFormat, slice, hwCrate,
332 summing, CmmSubBlock::CMM_CP,
333 CmmSubBlock::LEFT, timeslicesNew);
334 cmmHit1Blocks.push_back(h1Block);
335 if (neutralFormat) break;
336 }
337
338 // CMM-CP
339
340 const int maxDataID = LVL1::CMMCPHits::MAXID;
341 for (int dataID = 1; dataID < maxDataID; ++dataID) {
342 int source = dataID;
343 if (dataID > m_modules) {
344 if (summing == CmmSubBlock::CRATE &&
345 dataID != LVL1::CMMCPHits::LOCAL) continue;
346 switch (dataID) {
349 break;
352 break;
355 break;
358 break;
361 break;
362 default:
363 continue;
364 }
365 }
366 const LVL1::CMMCPHits* const ch = findCmmCpHits(crate, dataID, cmmHitsMap);
367 if ( ch ) {
368 std::vector<unsigned int> hits0;
369 std::vector<unsigned int> hits1;
370 std::vector<int> err0;
371 std::vector<int> err1;
372 ModifySlices::data(ch->HitsVec0(), hits0, timeslicesNew);
373 ModifySlices::data(ch->HitsVec1(), hits1, timeslicesNew);
374 ModifySlices::data(ch->ErrorVec0(), err0, timeslicesNew);
375 ModifySlices::data(ch->ErrorVec1(), err1, timeslicesNew);
376 for (int slice = 0; slice < timeslicesNew; ++slice) {
377 const LVL1::DataError err0Bits(err0[slice]);
378 const LVL1::DataError err1Bits(err1[slice]);
379 const int index = ( neutralFormat ) ? 0 : slice;
380 CmmCpSubBlock* subBlock = cmmHit0Blocks[index];
381 subBlock->setHits(slice, source, hits0[slice],
382 err0Bits.get(LVL1::DataError::Parity));
383 subBlock = cmmHit1Blocks[index];
384 subBlock->setHits(slice, source, hits1[slice],
385 err1Bits.get(LVL1::DataError::Parity));
386 }
387 }
388 }
390 for (; cos != cmmHit0Blocks.end(); ++cos) {
391 CmmCpSubBlock* const subBlock = *cos;
392 if ( !subBlock->pack()) {
393 msg(MSG::ERROR) << "CMM-Cp sub-block packing failed" << endmsg;
394 return StatusCode::FAILURE;
395 }
396 if (debug) {
397 msg() << "CMM-Cp sub-block data words: "
398 << subBlock->dataWords() << endmsg;
399 }
400 subBlock->write(theROD);
401 }
402 cos = cmmHit1Blocks.begin();
403 for (; cos != cmmHit1Blocks.end(); ++cos) {
404 CmmCpSubBlock* const subBlock = *cos;
405 if ( !subBlock->pack()) {
406 msg(MSG::ERROR) << "CMM-Cp sub-block packing failed" << endmsg;
407 return StatusCode::FAILURE;
408 }
409 if (debug) {
410 msg() << "CMM-Cp sub-block data words: "
411 << subBlock->dataWords() << endmsg;
412 }
413 subBlock->write(theROD);
414 }
415 }
416
417 return StatusCode::SUCCESS;
418}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
const bool debug
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataModel_detail::iterator< DataVector > iterator
Standard iterator.
Definition DataVector.h:842
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
void setRodMinorVersion(uint16_t m)
change the ROD minor version
std::vector< uint32_t > RODDATA
ROD data as a vector of unsigned int.
RODDATA * getRodData(uint32_t id)
get a block of ROD data
void setupCmmCpHitsMap(const CmmCpHitsCollection *hitCollection, ConstCmmCpHitsMap &cmmHitsMap) const
Set up CMM-CP hits map.
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
const LVL1::CMMCPHits * findCmmCpHits(int crate, int dataID, const ConstCmmCpHitsMap &cmmHitsMap) const
Find CMM-CP hits for given crate, data ID.
const LVL1::CPMTower * findCpmTower(unsigned int key, const ConstCpmTowerMap &ttMap) const
Find a CPM tower for given key.
bool slinkSlices(int crate, int module, int modulesPerSlink, int &timeslices, int &trigJem, const ConstCpmTowerMap &ttMap, const ConstCpmHitsMap &hitsMap, const ConstCmmCpHitsMap &cmmHitsMap, LVL1::TriggerTowerKey &towerKey) const
Get number of slices and triggered slice offset for next slink.
void setupCpmTowerMap(const CpmTowerCollection *ttCollection, ConstCpmTowerMap &ttMap, LVL1::TriggerTowerKey &towerKey) const
Set up CPM tower map.
const L1CaloSrcIdMap m_srcIdMap
Source ID converter.
void setupCpmHitsMap(const CpmHitsCollection *hitCollection, ConstCpmHitsMap &hitsMap) const
Set up CPM hits map.
const LVL1::CPMHits * findCpmHits(int crate, int module, const ConstCpmHitsMap &hitsMap) const
Find CPM hits for given crate, module.
std::map< int, const LVL1::CPMHits * > ConstCpmHitsMap
std::map< int, const LVL1::CMMCPHits * > ConstCmmCpHitsMap
std::map< unsigned int, const LVL1::CPMTower * > ConstCpmTowerMap
static void data(const std::vector< int > &oldVec, std::vector< int > &newVec, int newSlices)
Return modified data vector<int>
static int peak(int oldPeak, int oldSlices, int newSlices)
Return new triggered slice offset.
virtual unsigned int ttKey(const TriggerTower &tower)
returns the key of the passed tower
str index
Definition DeMoScan.py:362
@ layer
Definition HitInfo.h:79
setWord1 uint16_t
setEventNumber uint32_t

◆ convert() [2/4]

StatusCode LVL1BS::CpByteStreamTool::convert ( const std::string & sgKey,
const IROBDataProviderSvc::VROBFRAG & robFrags,
DataVector< LVL1::CMMCPHits > * hitCollection ) const

Convert ROB fragments to CMM-CP hits.

Definition at line 129 of file CpByteStreamTool.cxx.

133{
134 CmmHitsData data (hitCollection);
135 return convertBs(sgKey, robFrags, data);
136}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
StatusCode convertBs(const std::string &sgKey, const IROBDataProviderSvc::VROBFRAG &robFrags, CpByteStreamToolData &data) const
Convert bytestream to given container type.

◆ convert() [3/4]

StatusCode LVL1BS::CpByteStreamTool::convert ( const std::string & sgKey,
const IROBDataProviderSvc::VROBFRAG & robFrags,
DataVector< LVL1::CPMHits > * hitCollection ) const

Convert ROB fragments to CPM hits.

Definition at line 118 of file CpByteStreamTool.cxx.

122{
123 CpmHitsData data (hitCollection);
124 return convertBs(sgKey, robFrags, data);
125}

◆ convert() [4/4]

StatusCode LVL1BS::CpByteStreamTool::convert ( const std::string & sgKey,
const IROBDataProviderSvc::VROBFRAG & robFrags,
DataVector< LVL1::CPMTower > * ttCollection ) const

Convert ROB fragments to CPM towers.

Definition at line 107 of file CpByteStreamTool.cxx.

111{
112 CpmTowerData data (ttCollection);
113 return convertBs(sgKey, robFrags, data);
114}

◆ convertBs()

StatusCode LVL1BS::CpByteStreamTool::convertBs ( const std::string & sgKey,
const IROBDataProviderSvc::VROBFRAG & robFrags,
CpByteStreamToolData & data ) const
private

Convert bytestream to given container type.

Definition at line 455 of file CpByteStreamTool.cxx.

459{
461
462 // Check if overlap tower channels wanted
463 const static std::string flag("Overlap");
464 const std::string::size_type pos = sgKey.find(flag);
465 ld.coreOverlap =
466 (pos == std::string::npos || pos != sgKey.length() - flag.length()) ? 0 : 1;
467
468 const bool debug = msgLvl(MSG::DEBUG);
469 if (debug) msg(MSG::DEBUG);
470
471 // Loop over ROB fragments
472
473 CmmCpSubBlock cmmCpSubBlock;
474 CpmSubBlock cpmSubBlock;
475
476 int robCount = 0;
477 std::set<uint32_t> dupCheck;
478 ROBIterator rob = robFrags.begin();
479 ROBIterator robEnd = robFrags.end();
480 for (; rob != robEnd; ++rob) {
481
482 if (debug) {
483 ++robCount;
484 msg() << "Treating ROB fragment " << robCount << endmsg;
485 }
486
487 // Skip fragments with ROB status errors
488
489 uint32_t robid = (*rob)->source_id();
490 if ((*rob)->nstatus() > 0) {
491 ROBPointer robData;
492 (*rob)->status(robData);
493 if (*robData != 0) {
494 m_errorTool->robError(robid, *robData);
495 if (debug) msg() << "ROB status error - skipping fragment" << endmsg;
496 continue;
497 }
498 }
499
500 // Skip duplicate fragments
501
502 if (!dupCheck.insert(robid).second) {
504 if (debug) msg() << "Skipping duplicate ROB fragment" << endmsg;
505 continue;
506 }
507
508 // Unpack ROD data (slinks)
509
510 RODPointer payloadBeg;
512 RODPointer payloadEnd;
513 (*rob)->rod_data(payloadBeg);
514 payloadEnd = payloadBeg + (*rob)->rod_ndata();
515 payload = payloadBeg;
516 if (payload == payloadEnd) {
517 if (debug) msg() << "ROB fragment empty" << endmsg;
518 continue;
519 }
520
521 // Check identifier
522 const uint32_t sourceID = (*rob)->rod_source_id();
523 if (m_srcIdMap.getRobID(sourceID) != robid ||
524 m_srcIdMap.subDet(sourceID) != m_subDetector ||
525 m_srcIdMap.daqOrRoi(sourceID) != 0 ||
526 (m_srcIdMap.slink(sourceID) != 0 && m_srcIdMap.slink(sourceID) != 2) ||
527 m_srcIdMap.crate(sourceID) < m_crateOffsetHw ||
528 m_srcIdMap.crate(sourceID) >= m_crateOffsetHw + m_crates) {
530 if (debug) {
531 msg() << "Wrong source identifier in data: ROD "
532 << MSG::hex << sourceID << " ROB " << robid
533 << MSG::dec << endmsg;
534 }
535 continue;
536 }
537 const int rodCrate = m_srcIdMap.crate(sourceID);
538 if (debug) {
539 msg() << "Treating crate " << rodCrate
540 << " slink " << m_srcIdMap.slink(sourceID) << endmsg;
541 }
542
543 // First word should be User Header
544 if ( !L1CaloUserHeader::isValid(*payload) ) {
546 if (debug) msg() << "Invalid or missing user header" << endmsg;
547 continue;
548 }
549 L1CaloUserHeader userHeader(*payload);
550 const int minorVersion = (*rob)->rod_version() & 0xffff;
551 userHeader.setVersion(minorVersion);
552 const int headerWords = userHeader.words();
553 if (headerWords != 1) {
555 if (debug) msg() << "Unexpected number of user header words: "
556 << headerWords << endmsg;
557 continue;
558 }
559 for (int i = 0; i < headerWords; ++i) ++payload;
560 // triggered slice offsets
561 int trigCpm = userHeader.cpm();
562 int trigCmm = userHeader.cpCmm();
563 if (debug) {
564 msg() << "Minor format version number: " << MSG::hex
565 << minorVersion << MSG::dec << endmsg
566 << "CPM triggered slice offset: " << trigCpm << endmsg
567 << "CMM triggered slice offset: " << trigCmm << endmsg;
568 }
569 if (trigCpm != trigCmm) {
570 const int newTrig = (trigCpm > trigCmm) ? trigCpm : trigCmm;
571 trigCpm = newTrig;
572 trigCmm = newTrig;
573 if (debug) msg() << "Changed both offsets to " << newTrig << endmsg;
574 }
575
576 // Loop over sub-blocks
577
579 while (payload != payloadEnd) {
580
582 if (debug) msg() << "Unexpected data sequence" << endmsg;
584 break;
585 }
586 if (CmmSubBlock::cmmBlock(*payload)) {
587 // CMM
588 if (CmmSubBlock::cmmType(*payload) == CmmSubBlock::CMM_CP) {
589 cmmCpSubBlock.clear();
590 payload = cmmCpSubBlock.read(payload, payloadEnd);
591 if (cmmCpSubBlock.crate() != rodCrate) {
592 if (debug) msg() << "Inconsistent crate number in ROD source ID"
593 << endmsg;
595 break;
596 }
597 if (data.m_collection == CMM_CP_HITS) {
598 decodeCmmCp(&cmmCpSubBlock, trigCmm, static_cast<CmmHitsData&>(data),
599 ld);
600 if (ld.rodErr != L1CaloSubBlock::ERROR_NONE) {
601 if (debug) msg() << "decodeCmmCp failed" << endmsg;
602 break;
603 }
604 }
605 } else {
606 if (debug) msg() << "Invalid CMM type in module field" << endmsg;
608 break;
609 }
610 } else {
611 // CPM
612 CpmSubBlock subBlock;
613 cpmSubBlock.clear();
614 payload = cpmSubBlock.read(payload, payloadEnd);
615 if (cpmSubBlock.crate() != rodCrate) {
616 if (debug) msg() << "Inconsistent crate number in ROD source ID"
617 << endmsg;
619 break;
620 }
621 if (data.m_collection == CPM_TOWERS || data.m_collection == CPM_HITS) {
622 decodeCpm(&cpmSubBlock, trigCpm, data, ld);
623 if (ld.rodErr != L1CaloSubBlock::ERROR_NONE) {
624 if (debug) msg() << "decodeCpm failed" << endmsg;
625 break;
626 }
627 }
628 }
629 }
630 if (ld.rodErr != L1CaloSubBlock::ERROR_NONE)
631 m_errorTool->rodError(robid, ld.rodErr);
632 }
633
634 return StatusCode::SUCCESS;
635}
static bool cmmBlock(uint32_t word)
Determine if header word corresponds to CMM.
static CmmFirmwareCode cmmType(uint32_t word)
CMM differentiation (CMM_CP, CMM_JET, or CMM_ENERGY)
void decodeCmmCp(CmmCpSubBlock *subBlock, int trigCmm, CmmHitsData &data, LocalData &ld) const
Unpack CMM-CP sub-block.
OFFLINE_FRAGMENTS_NAMESPACE::PointerType ROBPointer
OFFLINE_FRAGMENTS_NAMESPACE::PointerType RODPointer
IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator
void decodeCpm(CpmSubBlock *subBlock, int trigCpm, CpByteStreamToolData &data, LocalData &ld) const
Unpack CPM sub-block.
static SubBlockWordType wordType(uint32_t word)
Word identification.
static bool isValid(uint32_t word)
Test for valid header word.
bool flag
Definition master.py:29

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ decodeCmmCp()

void LVL1BS::CpByteStreamTool::decodeCmmCp ( CmmCpSubBlock * subBlock,
int trigCmm,
CmmHitsData & data,
LocalData & ld ) const
private

Unpack CMM-CP sub-block.

Definition at line 639 of file CpByteStreamTool.cxx.

642{
643 const bool debug = msgLvl(MSG::DEBUG);
644 if (debug) msg(MSG::DEBUG);
645
646 const int hwCrate = subBlock->crate();
647 const int module = subBlock->cmmPosition();
648 const int firmware = subBlock->cmmFirmware();
649 const int summing = subBlock->cmmSumming();
650 const int timeslices = subBlock->timeslices();
651 const int sliceNum = subBlock->slice();
652 if (debug) {
653 msg() << "CMM-CP: Crate " << hwCrate
654 << " Module " << module
655 << " Firmware " << firmware
656 << " Summing " << summing
657 << " Total slices " << timeslices
658 << " Slice " << sliceNum << endmsg;
659 }
660 if (timeslices <= trigCmm) {
661 if (debug) msg() << "Triggered CMM slice from header "
662 << "inconsistent with number of slices: "
663 << trigCmm << ", " << timeslices << endmsg;
665 return;
666 }
667 if (timeslices <= sliceNum) {
668 if (debug) msg() << "Total slices inconsistent with slice number: "
669 << timeslices << ", " << sliceNum << endmsg;
671 return;
672 }
673 // Unpack sub-block
674 if (subBlock->dataWords() && !subBlock->unpack()) {
675 if (debug) {
676 std::string errMsg(subBlock->unpackErrorMsg());
677 msg() << "CMM-CP sub-block unpacking failed: " << errMsg << endmsg;
678 }
679 ld.rodErr = subBlock->unpackErrorCode();
680 return;
681 }
682
683 // Retrieve required data
684
685 const bool neutralFormat = subBlock->format() == L1CaloSubBlock::NEUTRAL;
686 const uint32_t subStatus = subBlock->subStatus();
687 const int crate = hwCrate - m_crateOffsetHw;
688 const int swCrate = crate + m_crateOffsetSw;
689 const int maxSid = CmmCpSubBlock::MAX_SOURCE_ID;
690 const int sliceBeg = ( neutralFormat ) ? 0 : sliceNum;
691 const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1;
692 for (int slice = sliceBeg; slice < sliceEnd; ++slice) {
693
694 // Jet hit counts
695
696 for (int source = 1; source < maxSid; ++source) {
697 int dataID = source;
698 if (source > m_modules) {
699 if (summing == CmmSubBlock::CRATE &&
700 source != CmmCpSubBlock::LOCAL) continue;
701 switch (source) {
703 dataID = LVL1::CMMCPHits::LOCAL;
704 break;
707 break;
710 break;
713 break;
715 dataID = LVL1::CMMCPHits::TOTAL;
716 break;
717 default:
718 continue;
719 }
720 }
721 const unsigned int hits = subBlock->hits(slice, source);
722 int err = subBlock->hitsError(slice, source);
723 LVL1::DataError errorBits;
724 errorBits.set(LVL1::DataError::Parity, err & 0x1);
725 errorBits.set(LVL1::DataError::SubStatusWord, subStatus);
726 err = errorBits.error();
727 if (hits || err) {
728 LVL1::CMMCPHits* ch = findCmmCpHits(data, crate, dataID);
729 if ( ! ch ) { // create new CMM hits
730 ld.hitsVec0.assign(timeslices, 0);
731 ld.hitsVec1.assign(timeslices, 0);
732 ld.errVec0.assign(timeslices, 0);
733 ld.errVec1.assign(timeslices, 0);
734 if (module == CmmSubBlock::RIGHT) {
735 ld.hitsVec0[slice] = hits;
736 ld.errVec0[slice] = err;
737 } else {
738 ld.hitsVec1[slice] = hits;
739 ld.errVec1[slice] = err;
740 }
741 auto chp =
742 std::make_unique<LVL1::CMMCPHits>(swCrate, dataID, ld.hitsVec0, ld.hitsVec1,
743 ld.errVec0, ld.errVec1, trigCmm);
744 const int key = crate*100 + dataID;
745 data.m_cmmHitsMap.insert(std::make_pair(key, chp.get()));
746 data.m_cmmHitCollection->push_back(std::move(chp));
747 } else {
748 ld.hitsVec0 = ch->HitsVec0();
749 ld.hitsVec1 = ch->HitsVec1();
750 ld.errVec0 = ch->ErrorVec0();
751 ld.errVec1 = ch->ErrorVec1();
752 const int nsl = ld.hitsVec0.size();
753 if (timeslices != nsl) {
754 if (debug) msg() << "Inconsistent number of slices in sub-blocks"
755 << endmsg;
757 return;
758 }
759 if ((module == CmmSubBlock::RIGHT && (ld.hitsVec0[slice] != 0 ||
760 ld.errVec0[slice] != 0)) || (module == CmmSubBlock::LEFT &&
761 (ld.hitsVec1[slice] != 0 || ld.errVec1[slice] != 0))) {
762 if (debug) msg() << "Duplicate data for slice " << slice << endmsg;
764 return;
765 }
766 if (module == CmmSubBlock::RIGHT) {
767 ld.hitsVec0[slice] = hits;
768 ld.errVec0[slice] = err;
769 } else {
770 ld.hitsVec1[slice] = hits;
771 ld.errVec1[slice] = err;
772 }
773 ch->addHits(ld.hitsVec0, ld.hitsVec1, ld.errVec0, ld.errVec1);
774 }
775 }
776 }
777 }
778
779 return;
780}
int error() const
Return the full error word.
Definition DataError.h:78
void set(ErrorBit bit, int value=1)
Set an error bit or data.
Definition DataError.cxx:28

◆ decodeCpm()

void LVL1BS::CpByteStreamTool::decodeCpm ( CpmSubBlock * subBlock,
int trigCpm,
CpByteStreamToolData & data,
LocalData & ld ) const
private

Unpack CPM sub-block.

Definition at line 784 of file CpByteStreamTool.cxx.

787{
788 const bool debug = msgLvl(MSG::DEBUG);
789 const bool verbose = msgLvl(MSG::VERBOSE);
790 if (debug) msg(MSG::DEBUG);
791
792 const int hwCrate = subBlock->crate();
793 const int module = subBlock->module();
794 const int timeslices = subBlock->timeslices();
795 const int sliceNum = subBlock->slice();
796 if (debug) {
797 msg() << "CPM: Crate " << hwCrate
798 << " Module " << module
799 << " Total slices " << timeslices
800 << " Slice " << sliceNum << endmsg;
801 }
802 if (module < 1 || module > m_modules) {
803 if (debug) msg() << "Unexpected module number: " << module << endmsg;
805 return;
806 }
807 if (timeslices <= trigCpm) {
808 if (debug) msg() << "Triggered CPM slice from header "
809 << "inconsistent with number of slices: "
810 << trigCpm << ", " << timeslices << endmsg;
812 return;
813 }
814 if (timeslices <= sliceNum) {
815 if (debug) msg() << "Total slices inconsistent with slice number: "
816 << timeslices << ", " << sliceNum << endmsg;
818 return;
819 }
820 // Unpack sub-block
821 if (subBlock->dataWords() && !subBlock->unpack()) {
822 if (debug) {
823 std::string errMsg(subBlock->unpackErrorMsg());
824 msg() << "CPM sub-block unpacking failed: " << errMsg << endmsg;
825 }
826 ld.rodErr = subBlock->unpackErrorCode();
827 return;
828 }
829
830 // Retrieve required data
831
832 const bool neutralFormat = subBlock->format() == L1CaloSubBlock::NEUTRAL;
833 LVL1::DataError dErr;
834 dErr.set(LVL1::DataError::SubStatusWord, subBlock->subStatus());
835 const int ssError = dErr.error();
836 const int crate = hwCrate - m_crateOffsetHw;
837 const int swCrate = crate + m_crateOffsetSw;
838 const int sliceBeg = ( neutralFormat ) ? 0 : sliceNum;
839 const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1;
840 for (int slice = sliceBeg; slice < sliceEnd; ++slice) {
841
842 if (data.m_collection == CPM_TOWERS) {
843 CpmTowerData& tdata = static_cast<CpmTowerData&> (data);
844
845 // Loop over tower channels and fill CPM towers
846
847 for (int chan = 0; chan < m_channels; ++chan) {
848 if (!ssError && !subBlock->anyTowerData(chan)) continue;
849 const int em = subBlock->emData(slice, chan);
850 const int had = subBlock->hadData(slice, chan);
851 const int emErr = subBlock->emError(slice, chan);
852 const int hadErr = subBlock->hadError(slice, chan);
853 int emErr1 = ssError;
854 if (emErr) {
855 LVL1::DataError emErrBits(emErr1);
856 emErrBits.set(LVL1::DataError::Parity, emErr & 0x1);
857 emErrBits.set(LVL1::DataError::LinkDown, (emErr >> 1) & 0x1);
858 emErr1 = emErrBits.error();
859 }
860 int hadErr1 = ssError;
861 if (hadErr) {
862 LVL1::DataError hadErrBits(hadErr1);
863 hadErrBits.set(LVL1::DataError::Parity, hadErr & 0x1);
864 hadErrBits.set(LVL1::DataError::LinkDown, (hadErr >> 1) & 0x1);
865 hadErr1 = hadErrBits.error();
866 }
867 if (em || had || emErr1 || hadErr1) {
868 double eta = 0.;
869 double phi = 0.;
870 int layer = 0;
871 if (m_cpmMaps->mapping(crate, module, chan, eta, phi, layer)) {
872 if (layer == ld.coreOverlap) {
873 const unsigned int key = ld.towerKey->ttKey(phi, eta);
874 LVL1::CPMTower* tt = findCpmTower(tdata, key);
875 if ( ! tt ) { // create new CPM tower
876 ld.emVec.assign(timeslices, 0);
877 ld.hadVec.assign(timeslices, 0);
878 ld.emErrVec.assign(timeslices, 0);
879 ld.hadErrVec.assign(timeslices, 0);
880 ld.emVec[slice] = em;
881 ld.hadVec[slice] = had;
882 ld.emErrVec[slice] = emErr1;
883 ld.hadErrVec[slice] = hadErr1;
884 auto ttp =
885 std::make_unique<LVL1::CPMTower>(phi, eta, ld.emVec, ld.emErrVec,
886 ld.hadVec, ld.hadErrVec, trigCpm);
887 tdata.m_ttMap.insert(std::make_pair(key, ttp.get()));
888 tdata.m_ttCollection->push_back(std::move(ttp));
889 } else {
890 ld.emVec = tt->emEnergyVec();
891 ld.hadVec = tt->hadEnergyVec();
892 ld.emErrVec = tt->emErrorVec();
893 ld.hadErrVec = tt->hadErrorVec();
894 const int nsl = ld.emVec.size();
895 if (timeslices != nsl) {
896 if (debug) {
897 msg() << "Inconsistent number of slices in sub-blocks"
898 << endmsg;
899 }
901 return;
902 }
903 if (ld.emVec[slice] != 0 || ld.hadVec[slice] != 0 ||
904 ld.emErrVec[slice] != 0 || ld.hadErrVec[slice] != 0) {
905 if (debug) msg() << "Duplicate data for slice "
906 << slice << endmsg;
908 return;
909 }
910 ld.emVec[slice] = em;
911 ld.hadVec[slice] = had;
912 ld.emErrVec[slice] = emErr1;
913 ld.hadErrVec[slice] = hadErr1;
914 tt->fill(ld.emVec, ld.emErrVec, ld.hadVec, ld.hadErrVec, trigCpm);
915 }
916 }
917 } else if (verbose && (em || had || emErr || hadErr)) {
918 msg(MSG::VERBOSE) << "Non-zero data but no channel mapping for channel "
919 << chan << endmsg;
920 msg(MSG::DEBUG);
921 }
922 } else if (verbose) {
923 msg(MSG::VERBOSE) << "No CPM tower data for channel "
924 << chan << " slice " << slice << endmsg;
925 msg(MSG::DEBUG);
926 }
927 }
928 } else if (data.m_collection == CPM_HITS) {
929 CpmHitsData& hdata = static_cast<CpmHitsData&> (data);
930
931 // Get CPM hits
932
933 const unsigned int hits0 = subBlock->hits0(slice);
934 const unsigned int hits1 = subBlock->hits1(slice);
935 if (hits0 || hits1) {
936 LVL1::CPMHits* ch = findCpmHits(hdata, crate, module);
937 if ( ! ch ) { // create new CPM hits
938 ld.hitsVec0.assign(timeslices, 0);
939 ld.hitsVec1.assign(timeslices, 0);
940 ld.hitsVec0[slice] = hits0;
941 ld.hitsVec1[slice] = hits1;
942 auto chp =
943 std::make_unique<LVL1::CPMHits>(swCrate, module, ld.hitsVec0, ld.hitsVec1, trigCpm);
944 hdata.m_hitsMap.insert(std::make_pair(crate*m_modules+module-1, chp.get()));
945 hdata.m_hitCollection->push_back(std::move(chp));
946 } else {
947 ld.hitsVec0 = ch->HitsVec0();
948 ld.hitsVec1 = ch->HitsVec1();
949 const int nsl = ld.hitsVec0.size();
950 if (timeslices != nsl) {
951 if (debug) msg() << "Inconsistent number of slices in sub-blocks"
952 << endmsg;
954 return;
955 }
956 if (ld.hitsVec0[slice] != 0 || ld.hitsVec1[slice] != 0) {
957 if (debug) msg() << "Duplicate data for slice " << slice << endmsg;
959 return;
960 }
961 ld.hitsVec0[slice] = hits0;
962 ld.hitsVec1[slice] = hits1;
963 ch->addHits(ld.hitsVec0, ld.hitsVec1);
964 }
965 } else if (verbose) {
966 msg(MSG::VERBOSE) << "No CPM hits data for crate/module/slice "
967 << hwCrate << "/" << module << "/" << slice
968 << endmsg;
969 msg(MSG::DEBUG);
970 }
971 }
972 }
973 return;
974}
bool verbose
Definition hcg.cxx:73

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ findCmmCpHits() [1/2]

LVL1::CMMCPHits * LVL1BS::CpByteStreamTool::findCmmCpHits ( const CmmHitsData & data,
int crate,
int dataID ) const
private

Definition at line 1029 of file CpByteStreamTool.cxx.

1032{
1033 CmmCpHitsMap::const_iterator mapIter = data.m_cmmHitsMap.find(crate*100 + dataID);
1034 if (mapIter != data.m_cmmHitsMap.end()) return mapIter->second;
1035 return nullptr;
1036}

◆ findCmmCpHits() [2/2]

const LVL1::CMMCPHits * LVL1BS::CpByteStreamTool::findCmmCpHits ( int crate,
int dataID,
const ConstCmmCpHitsMap & cmmHitsMap ) const
private

Find CMM-CP hits for given crate, data ID.

Definition at line 1020 of file CpByteStreamTool.cxx.

1023{
1024 ConstCmmCpHitsMap::const_iterator mapIter = cmmHitsMap.find(crate*100 + dataID);
1025 if (mapIter != cmmHitsMap.end()) return mapIter->second;
1026 return nullptr;
1027}

◆ findCpmHits() [1/2]

LVL1::CPMHits * LVL1BS::CpByteStreamTool::findCpmHits ( const CpmHitsData & data,
int crate,
int module ) const
private

Definition at line 1008 of file CpByteStreamTool.cxx.

1010{
1011 CpmHitsMap::const_iterator mapIter =
1012 data.m_hitsMap.find(crate*m_modules + module - 1);
1013 if (mapIter != data.m_hitsMap.end()) return mapIter->second;
1014 return nullptr;
1015}

◆ findCpmHits() [2/2]

const LVL1::CPMHits * LVL1BS::CpByteStreamTool::findCpmHits ( int crate,
int module,
const ConstCpmHitsMap & hitsMap ) const
private

Find CPM hits for given crate, module.

Definition at line 998 of file CpByteStreamTool.cxx.

1001{
1002 ConstCpmHitsMap::const_iterator mapIter =
1003 hitsMap.find(crate*m_modules + module - 1);
1004 if (mapIter != hitsMap.end()) return mapIter->second;
1005 return nullptr;
1006}

◆ findCpmTower() [1/2]

LVL1::CPMTower * LVL1BS::CpByteStreamTool::findCpmTower ( const CpmTowerData & data,
unsigned int key ) const
private

Definition at line 987 of file CpByteStreamTool.cxx.

989{
990 CpmTowerMap::const_iterator mapIter = data.m_ttMap.find(key);
991 if (mapIter != data.m_ttMap.end()) return mapIter->second;
992 return nullptr;
993}

◆ findCpmTower() [2/2]

const LVL1::CPMTower * LVL1BS::CpByteStreamTool::findCpmTower ( unsigned int key,
const ConstCpmTowerMap & ttMap ) const
private

Find a CPM tower for given key.

Definition at line 979 of file CpByteStreamTool.cxx.

981{
982 ConstCpmTowerMap::const_iterator mapIter = ttMap.find(key);
983 if (mapIter != ttMap.end()) return mapIter->second;
984 return nullptr;
985}

◆ initialize()

StatusCode LVL1BS::CpByteStreamTool::initialize ( )
overridevirtual

Definition at line 94 of file CpByteStreamTool.cxx.

95{
96 ATH_MSG_INFO( "Initializing " << name() );
97
98 ATH_CHECK( m_cpmMaps.retrieve() );
99 ATH_CHECK( m_errorTool.retrieve() );
100 ATH_CHECK( m_byteStreamCnvSvc.retrieve() );
101
102 return StatusCode::SUCCESS;
103}
#define ATH_MSG_INFO(x)

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & LVL1BS::CpByteStreamTool::interfaceID ( )
static

AlgTool InterfaceID.

Definition at line 41 of file CpByteStreamTool.cxx.

42{
44}
static const InterfaceID IID_ICpByteStreamTool("CpByteStreamTool", 1, 1)

◆ makeSourceIDs()

std::vector< uint32_t > LVL1BS::CpByteStreamTool::makeSourceIDs ( ) const
private

Create list of all source IDs.

Definition at line 422 of file CpByteStreamTool.cxx.

423{
424 std::vector<uint32_t> sourceIDs;
425
426 if (!m_sourceIDsProp.empty()) {
428 }
429 else {
430 const int maxCrates = m_crates + m_crateOffsetHw;
431 const int maxSlinks = m_srcIdMap.maxSlinks();
432 for (int hwCrate = m_crateOffsetHw; hwCrate < maxCrates; ++hwCrate)
433 {
434 for (int slink = 0; slink < maxSlinks; ++slink)
435 {
436 const int daqOrRoi = 0;
437 const uint32_t rodId = m_srcIdMap.getRodID(hwCrate, slink, daqOrRoi,
439 const uint32_t robId = m_srcIdMap.getRobID(rodId);
440 sourceIDs.push_back(robId);
441 }
442 }
443 }
444 return sourceIDs;
445}
const std::vector< uint32_t > & sourceIDs() const
Return reference to vector with all possible Source Identifiers.

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setupCmmCpHitsMap()

void LVL1BS::CpByteStreamTool::setupCmmCpHitsMap ( const CmmCpHitsCollection * hitCollection,
ConstCmmCpHitsMap & cmmHitsMap ) const
private

Set up CMM-CP hits map.

Definition at line 1078 of file CpByteStreamTool.cxx.

1081{
1082 cmmHitsMap.clear();
1083 if (hitCollection) {
1084 CmmCpHitsCollection::const_iterator pos = hitCollection->begin();
1085 CmmCpHitsCollection::const_iterator pose = hitCollection->end();
1086 for (; pos != pose; ++pos) {
1087 const LVL1::CMMCPHits* const hits = *pos;
1088 const int crate = hits->crate() - m_crateOffsetSw;
1089 const int key = crate*100 + hits->dataID();
1090 cmmHitsMap.insert(std::make_pair(key, hits));
1091 }
1092 }
1093}
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838

◆ setupCpmHitsMap()

void LVL1BS::CpByteStreamTool::setupCpmHitsMap ( const CpmHitsCollection * hitCollection,
ConstCpmHitsMap & hitsMap ) const
private

Set up CPM hits map.

Definition at line 1059 of file CpByteStreamTool.cxx.

1062{
1063 hitsMap.clear();
1064 if (hitCollection) {
1065 CpmHitsCollection::const_iterator pos = hitCollection->begin();
1066 CpmHitsCollection::const_iterator pose = hitCollection->end();
1067 for (; pos != pose; ++pos) {
1068 const LVL1::CPMHits* const hits = *pos;
1069 const int crate = hits->crate() - m_crateOffsetSw;
1070 const int key = m_modules * crate + hits->module() - 1;
1071 hitsMap.insert(std::make_pair(key, hits));
1072 }
1073 }
1074}

◆ setupCpmTowerMap()

void LVL1BS::CpByteStreamTool::setupCpmTowerMap ( const CpmTowerCollection * ttCollection,
ConstCpmTowerMap & ttMap,
LVL1::TriggerTowerKey & towerKey ) const
private

Set up CPM tower map.

Definition at line 1040 of file CpByteStreamTool.cxx.

1044{
1045 ttMap.clear();
1046 if (ttCollection) {
1047 CpmTowerCollection::const_iterator pos = ttCollection->begin();
1048 CpmTowerCollection::const_iterator pose = ttCollection->end();
1049 for (; pos != pose; ++pos) {
1050 const LVL1::CPMTower* const tt = *pos;
1051 const unsigned int key = towerKey.ttKey(tt->phi(), tt->eta());
1052 ttMap.insert(std::make_pair(key, tt));
1053 }
1054 }
1055}

◆ slinkSlices()

bool LVL1BS::CpByteStreamTool::slinkSlices ( int crate,
int module,
int modulesPerSlink,
int & timeslices,
int & trigJem,
const ConstCpmTowerMap & ttMap,
const ConstCpmHitsMap & hitsMap,
const ConstCmmCpHitsMap & cmmHitsMap,
LVL1::TriggerTowerKey & towerKey ) const
private

Get number of slices and triggered slice offset for next slink.

Definition at line 1097 of file CpByteStreamTool.cxx.

1105{
1106 int slices = -1;
1107 int trigC = m_dfltSlices/2;
1108 for (int mod = module; mod < module + modulesPerSlink; ++mod) {
1109 for (int chan = 0; chan < m_channels; ++chan) {
1110 double eta = 0.;
1111 double phi = 0.;
1112 int layer = 0;
1113 if ( !m_cpmMaps->mapping(crate, mod, chan, eta, phi, layer)) continue;
1114 const unsigned int key = towerKey.ttKey(phi, eta);
1115 const LVL1::CPMTower* const tt = findCpmTower(key, ttMap);
1116 if ( !tt ) continue;
1117 const int numdat = 4;
1118 std::vector<int> sums(numdat);
1119 std::vector<int> sizes(numdat);
1120 sums[0] = std::accumulate((tt->emEnergyVec()).begin(),
1121 (tt->emEnergyVec()).end(), 0);
1122 sums[1] = std::accumulate((tt->hadEnergyVec()).begin(),
1123 (tt->hadEnergyVec()).end(), 0);
1124 sums[2] = std::accumulate((tt->emErrorVec()).begin(),
1125 (tt->emErrorVec()).end(), 0);
1126 sums[3] = std::accumulate((tt->hadErrorVec()).begin(),
1127 (tt->hadErrorVec()).end(), 0);
1128 sizes[0] = (tt->emEnergyVec()).size();
1129 sizes[1] = (tt->hadEnergyVec()).size();
1130 sizes[2] = (tt->emErrorVec()).size();
1131 sizes[3] = (tt->hadErrorVec()).size();
1132 const int peak = tt->peak();
1133 for (int i = 0; i < numdat; ++i) {
1134 if (sums[i] == 0) continue;
1135 if (slices < 0) {
1136 slices = sizes[i];
1137 trigC = peak;
1138 } else if (slices != sizes[i] || trigC != peak) return false;
1139 }
1140 }
1141 const LVL1::CPMHits* const hits = findCpmHits(crate, mod, hitsMap);
1142 if (hits) {
1143 const int numdat = 2;
1144 std::vector<unsigned int> sums(numdat);
1145 std::vector<int> sizes(numdat);
1146 sums[0] = std::accumulate((hits->HitsVec0()).begin(),
1147 (hits->HitsVec0()).end(), 0);
1148 sums[1] = std::accumulate((hits->HitsVec1()).begin(),
1149 (hits->HitsVec1()).end(), 0);
1150 sizes[0] = (hits->HitsVec0()).size();
1151 sizes[1] = (hits->HitsVec1()).size();
1152 const int peak = hits->peak();
1153 for (int i = 0; i < numdat; ++i) {
1154 if (sums[i] == 0) continue;
1155 if (slices < 0) {
1156 slices = sizes[i];
1157 trigC = peak;
1158 } else if (slices != sizes[i] || trigC != peak) return false;
1159 }
1160 }
1161 }
1162 // CMM last slink of crate
1163 if (module/modulesPerSlink == m_slinks - 1) {
1164 const int maxDataID = LVL1::CMMCPHits::MAXID;
1165 for (int dataID = 0; dataID < maxDataID; ++dataID) {
1166 const int numdat = 4;
1167 std::vector<unsigned int> sums(numdat);
1168 std::vector<int> sizes(numdat);
1169 const LVL1::CMMCPHits* const hits = findCmmCpHits(crate, dataID, cmmHitsMap);
1170 if (hits) {
1171 sums[0] = std::accumulate((hits->HitsVec0()).begin(),
1172 (hits->HitsVec0()).end(), 0);
1173 sums[1] = std::accumulate((hits->HitsVec1()).begin(),
1174 (hits->HitsVec1()).end(), 0);
1175 sums[2] = std::accumulate((hits->ErrorVec0()).begin(),
1176 (hits->ErrorVec0()).end(), 0);
1177 sums[3] = std::accumulate((hits->ErrorVec1()).begin(),
1178 (hits->ErrorVec1()).end(), 0);
1179 sizes[0] = (hits->HitsVec0()).size();
1180 sizes[1] = (hits->HitsVec1()).size();
1181 sizes[2] = (hits->ErrorVec0()).size();
1182 sizes[3] = (hits->ErrorVec1()).size();
1183 const int peak = hits->peak();
1184 for (int i = 0; i < numdat; ++i) {
1185 if (sums[i] == 0) continue;
1186 if (slices < 0) {
1187 slices = sizes[i];
1188 trigC = peak;
1189 } else if (slices != sizes[i] || trigC != peak) return false;
1190 }
1191 }
1192 }
1193 }
1194 if (slices < 0) slices = m_dfltSlices;
1195 timeslices = slices;
1196 trigCpm = trigC;
1197 return true;
1198}

◆ sourceIDs()

const std::vector< uint32_t > & LVL1BS::CpByteStreamTool::sourceIDs ( ) const

Return reference to vector with all possible Source Identifiers.

Definition at line 447 of file CpByteStreamTool.cxx.

448{
449 static const std::vector<uint32_t> sourceIDs = makeSourceIDs();
450 return sourceIDs;
451}
std::vector< uint32_t > makeSourceIDs() const
Create list of all source IDs.

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_byteStreamCnvSvc

ServiceHandle<IByteStreamCnvSvc> LVL1BS::CpByteStreamTool::m_byteStreamCnvSvc { this, "ByteStreamCnvSvc", "ByteStreamCnvSvc" }
private

Definition at line 85 of file CpByteStreamTool.h.

86{ this, "ByteStreamCnvSvc", "ByteStreamCnvSvc" };

◆ m_channels

const int LVL1BS::CpByteStreamTool::m_channels
private

Number of channels per module.

Definition at line 218 of file CpByteStreamTool.h.

◆ m_cpmMaps

ToolHandle<LVL1::IL1CaloMappingTool> LVL1BS::CpByteStreamTool::m_cpmMaps
private

Property: Channel mapping tool.

Definition at line 205 of file CpByteStreamTool.h.

◆ m_crateOffsetHw

int LVL1BS::CpByteStreamTool::m_crateOffsetHw
private

Property: Hardware crate number offset.

Definition at line 210 of file CpByteStreamTool.h.

◆ m_crateOffsetSw

int LVL1BS::CpByteStreamTool::m_crateOffsetSw
private

Property: Software crate number offset.

Definition at line 212 of file CpByteStreamTool.h.

◆ m_crates

const int LVL1BS::CpByteStreamTool::m_crates
private

Number of crates.

Definition at line 220 of file CpByteStreamTool.h.

◆ m_dataFormat

int LVL1BS::CpByteStreamTool::m_dataFormat
private

Property: Data compression format.

Definition at line 216 of file CpByteStreamTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_dfltSlices

int LVL1BS::CpByteStreamTool::m_dfltSlices
private

Property: Default number of slices in simulation.

Definition at line 226 of file CpByteStreamTool.h.

◆ m_errorTool

ToolHandle<LVL1BS::L1CaloErrorByteStreamTool> LVL1BS::CpByteStreamTool::m_errorTool
private

Error collection tool.

Definition at line 207 of file CpByteStreamTool.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_forceSlices

int LVL1BS::CpByteStreamTool::m_forceSlices
private

Property: Force number of slices in bytestream.

Definition at line 228 of file CpByteStreamTool.h.

◆ m_modules

const int LVL1BS::CpByteStreamTool::m_modules
private

Number of CPM modules per crate.

Definition at line 222 of file CpByteStreamTool.h.

◆ m_slinks

int LVL1BS::CpByteStreamTool::m_slinks
private

Property: Number of slinks per crate when writing out bytestream.

Definition at line 224 of file CpByteStreamTool.h.

◆ m_sourceIDsProp

std::vector<uint32_t> LVL1BS::CpByteStreamTool::m_sourceIDsProp
private

Property: ROB source IDs.

Definition at line 230 of file CpByteStreamTool.h.

◆ m_srcIdMap

const L1CaloSrcIdMap LVL1BS::CpByteStreamTool::m_srcIdMap
private

Source ID converter.

Definition at line 234 of file CpByteStreamTool.h.

◆ m_subDetector

const eformat::SubDetector LVL1BS::CpByteStreamTool::m_subDetector
private

Sub-detector type.

Definition at line 232 of file CpByteStreamTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_version

int LVL1BS::CpByteStreamTool::m_version
private

Property: Sub_block header version.

Definition at line 214 of file CpByteStreamTool.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: