diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/cmt/requirements b/Trigger/TrigT1/TrigT1CaloByteStream/cmt/requirements index edb12a3b19ea76f5067363096cd812c2d84a4d3d..57adcb89d4271cf5303d12e1e561a0c1a0553900 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/cmt/requirements +++ b/Trigger/TrigT1/TrigT1CaloByteStream/cmt/requirements @@ -24,6 +24,7 @@ use xAODTrigL1Calo xAODTrigL1Calo-* Event/xAOD private use AthenaBaseComps AthenaBaseComps-* Control use AthenaKernel AthenaKernel-* Control +use AthContainers AthContainers-* Control use ByteStreamCnvSvcBase ByteStreamCnvSvcBase-* Event use ByteStreamData ByteStreamData-* Event use StoreGate StoreGate-* Control diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/share/BS2xAOD.py b/Trigger/TrigT1/TrigT1CaloByteStream/share/BS2xAOD.py new file mode 100644 index 0000000000000000000000000000000000000000..7d3a055968b9ff88d80f0ee8023482043e015651 --- /dev/null +++ b/Trigger/TrigT1/TrigT1CaloByteStream/share/BS2xAOD.py @@ -0,0 +1,90 @@ +import re + +InFiles = [ + #"/afs/cern.ch/work/h/hristova/public/M9/256147/data15_cos.00256147.physics_L1Calo.merge.RAW._lb0500._SFO-ALL._0001.1" + #"/afs/cern.ch/work/v/vkousk/public/L1Calo/data15_cos.00255313.physics_CosmicCalo.merge.RAW._lb0700._SFO-ALL._0001.1" + # "/afs/cern.ch/user/t/tcorneli/public/PROC/extractedEvents8.data", + # "/afs/cern.ch/work/g/geisler/public/misc/l1caloruns/data15_calib.00252372.calibration_L1CaloPprPhos4ScanPars.daq.RAW._lb0000._SFO-1._0001.data", + "/afs/cern.ch/work/h/hmeyerzt/public/data/data15_cos.00252223.physics_CosmicCalo.merge.RAW._lb0025._SFO-ALL._0001.1", + # "/afs/cern.ch/user/r/rhowen/ppmData/ppmBcMuxRamp.data", + # "/afs/cern.ch/user/r/rhowen/ppmData/ppmBcMuxRamp_Compressed.data", + # "/afs/cern.ch/user/r/rhowen/ppmData/ppmnMCMRamp2_Compressed.data", + # "/afs/cern.ch/user/r/rhowen/ppmData/ppmnMCMRamp2.data", + # "/afs/cern.ch/user/r/rhowen/ppmData/ppmRandomData_Compressed.data", + #"/afs/cern.ch/user/r/rhowen/ppmData/ppmRandomData_take2.data", + #"/afs/cern.ch/user/r/rhowen/ppmData/ppmConstant123_Compressed.data", + #"/afs/cern.ch/user/r/rhowen/ppmData/ppmSparceRandom_compressed.data", + #"/afs/cern.ch/user/r/rhowen/ppmData/ppmConstant32_compressed.data" + #"/afs/cern.ch/work/j/juraj/public/2015/TileCIS/251619/data15_calib.00251619.calibration_L1CaloEnergyScan.daq.RAW._lb0000._SFO-1._0001.data", + # "/afs/cern.ch/work/g/geisler/public/misc/data09_1beam.00140370.physics_MinBias.merge.RAW._lb0236._0001.1", + #"/afs/cern.ch/work/h/hmeyerzt/public/data/data14_cos.00247548.physics_CosmicCalo.merge.RAW._lb0097._SFO-ALL._0001.1", + #"/afs/cern.ch/work/v/vscharf/public/splash/data09_1beam.00140370.physics_MinBias.merge.RAW._lb0002._0001.1", + #"/afs/cern.ch/work/h/hristova/public/M7/248370/data14_cos.00248370.physics_L1Calo.merge.RAW._lb0007._SFO-ALL._0001.1", + #"/afs/cern.ch/work/h/hristova/public/M7/248370/data14_cos.00248370.express_express.merge.RAW._lb0163._SFO-ALL._0001.1" + #"/afs/cern.ch/work/j/juraj/public/2015/TileCIS/data15_calib.00249297.calibration_L1CaloEnergyScan.daq.RAW._lb0000._SFO-1._0001.data", + #"/afs/cern.ch/work/j/juraj/public/2015/TileCIS/data15_calib.00249300.calibration_L1CaloEnergyScan.daq.RAW._lb0000._SFO-1._0001.data", + # "/afs/cern.ch/work/j/jfrost/public/R19testing/slice_rerun/data12_8TeV.00204158.express_express.merge.RAW._lb0958._SFO-ALL._0001.1", + #"/afs/cern.ch/work/j/jfrost/public/M8_tests/HLT_mcV5_rerunLvl1-1._0001.data" +] + +runNumberReg = re.compile('\d' * 8) +runNumber = "" +for i in InFiles: + res = runNumberReg.search(i) + if res: + runNumber += res.group(0) + "." + + +# configuration of globalflags... do this FIRST so that anything else you +# do that might load conddb will be ready for it +from AthenaCommon.GlobalFlags import globalflags +globalflags.DataSource = 'data' +globalflags.DatabaseInstance = 'CONDBR2' +globalflags.InputFormat = 'bytestream' +globalflags.DetDescrVersion = "ATLAS-R2-2015-02-00-00" +from IOVDbSvc.CondDB import conddb +conddb.setGlobalTag("CONDBR2-ES1PA-2015-01") + + +# Output file +OutFile = "xAOD.L1Calo." + runNumber + "pool.root" +from OutputStreamAthenaPool.MultipleStreamManager import MSMgr +xaodStream = MSMgr.NewPoolRootStream("StreamXAOD", OutFile) + +# Decorate trigger towers with Calo Cells? +# This should be setup better +decorateTT = True + +# Number of events (-1 == all events) + + +# Tell Athena about the input file(s) +from ByteStreamCnvSvc import ReadByteStream +svcMgr.ByteStreamInputSvc.FullFileName = InFiles + +topSequence = CfgMgr.AthSequencer("AthAlgSeq") + +# Add L1Calo xAOD to output +include("TrigT1CaloByteStream/ReadLVL1CaloBSRun2_jobOptions.py") + +xaodStream.AddItem("xAOD::EventInfo#*") +xaodStream.AddItem("xAOD::EventAuxInfo#*") + +xaod = [ + (True, "TriggerTower", "xAODTriggerTowers"), + (True, "CPMTower", "CPMTowers"), + (True, "CMXCPTob", "CMXCPTobs"), + (True, "CMXCPHits", "CMXCPHits") +] + +for enabled, prefix, key in xaod: + if not enabled: + continue + xaodStream.AddItem( "xAOD::%sContainer#%s" % (prefix, key)) + xaodStream.AddItem( "xAOD::%sAuxContainer#%sAux." % (prefix, key)) + + +# Do some additional tweaking: +theApp.EvtMax = 150 +#ServiceMgr.MessageSvc.OutputLevel = INFO +ServiceMgr.MessageSvc.defaultLimit = 1000000 diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/share/ReadLVL1CaloBSRun1_jobOptions.py b/Trigger/TrigT1/TrigT1CaloByteStream/share/ReadLVL1CaloBSRun1_jobOptions.py index 3a62838215c1fe42fc006831f9b88cad9bd73ed0..127a0513a86212a5850a33378c336e656d1d3f3b 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/share/ReadLVL1CaloBSRun1_jobOptions.py +++ b/Trigger/TrigT1/TrigT1CaloByteStream/share/ReadLVL1CaloBSRun1_jobOptions.py @@ -14,7 +14,7 @@ from TrigT1CaloByteStream.TrigT1CaloByteStreamConf import LVL1BS__CpmRoiByteStre from TrigT1CaloByteStream.TrigT1CaloByteStreamConf import LVL1BS__JepByteStreamV1Tool from TrigT1CaloByteStream.TrigT1CaloByteStreamConf import LVL1BS__JepRoiByteStreamV1Tool from TrigT1CaloByteStream.TrigT1CaloByteStreamConf import LVL1BS__PpmByteStreamV1Tool -from TrigT1CaloByteStream.TrigT1CaloByteStreamConf import LVL1BS__L1CaloByteStreamReadTool +from TrigT1CaloByteStream.TrigT1CaloByteStreamConf import LVL1BS__PpmByteStreamReadV1V2Tool from TrigT1CaloByteStream.TrigT1CaloByteStreamConf import LVL1BS__RodHeaderByteStreamTool from TrigT1CaloByteStream.TrigT1CaloByteStreamConf import LVL1BS__L1CaloErrorByteStreamTool @@ -26,7 +26,7 @@ ToolSvc += LVL1BS__JepRoiByteStreamV1Tool("JepRoiByteStreamV1Tool") ToolSvc += LVL1BS__PpmByteStreamV1Tool("PpmByteStreamV1Tool", PpmMappingTool="LVL1::PpmCoolOrBuiltinMappingTool/PpmCoolOrBuiltinMappingTool") -ToolSvc += LVL1BS__L1CaloByteStreamReadTool("L1CaloByteStreamReadTool") +ToolSvc += LVL1BS__PpmByteStreamReadV1V2Tool("PpmByteStreamReadV1V2Tool") ToolSvc += LVL1BS__RodHeaderByteStreamTool("RodHeaderByteStreamTool") ToolSvc += LVL1BS__L1CaloErrorByteStreamTool("L1CaloErrorByteStreamTool") @@ -58,7 +58,6 @@ ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::TriggerTowerContainer/xAODTri ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::TriggerTowerAuxContainer/xAODTriggerTowersMuonAux."] ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::TriggerTowerContainer/xAODTriggerTowersSpare"] ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::TriggerTowerAuxContainer/xAODTriggerTowersSpareAux."] -ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::CpmTowerContainer/xAODCpmTowers" ] ByteStreamAddressProviderSvc.TypeNames += [ "DataVector<LVL1::RODHeader>/RODHeaders" ] diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/share/ReadLVL1CaloBSRun2_jobOptions.py b/Trigger/TrigT1/TrigT1CaloByteStream/share/ReadLVL1CaloBSRun2_jobOptions.py index c832df3589ded3bbce32496e4aee698db335a2da..b44502a99973938c1ab7b2866f15e010650ac7df 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/share/ReadLVL1CaloBSRun2_jobOptions.py +++ b/Trigger/TrigT1/TrigT1CaloByteStream/share/ReadLVL1CaloBSRun2_jobOptions.py @@ -14,8 +14,7 @@ from TrigT1CaloByteStream.TrigT1CaloByteStreamConf import LVL1BS__CpmRoiByteStre from TrigT1CaloByteStream.TrigT1CaloByteStreamConf import LVL1BS__JepByteStreamV2Tool from TrigT1CaloByteStream.TrigT1CaloByteStreamConf import LVL1BS__JepRoiByteStreamV2Tool -from TrigT1CaloByteStream.TrigT1CaloByteStreamConf import LVL1BS__L1CaloByteStreamReadTool - +from TrigT1CaloByteStream.TrigT1CaloByteStreamConf import LVL1BS__PpmByteStreamReadV1V2Tool from TrigT1CaloByteStream.TrigT1CaloByteStreamConf import LVL1BS__RodHeaderByteStreamTool from TrigT1CaloByteStream.TrigT1CaloByteStreamConf import LVL1BS__L1CaloErrorByteStreamTool @@ -24,15 +23,11 @@ ToolSvc += LVL1BS__CpByteStreamV2Tool("CpByteStreamV2Tool") ToolSvc += LVL1BS__CpmRoiByteStreamV2Tool("CpmRoiByteStreamV2Tool") ToolSvc += LVL1BS__JepByteStreamV2Tool("JepByteStreamV2Tool") ToolSvc += LVL1BS__JepRoiByteStreamV2Tool("JepRoiByteStreamV2Tool") -ToolSvc += LVL1BS__L1CaloByteStreamReadTool("L1CaloByteStreamReadTool") +ToolSvc += LVL1BS__PpmByteStreamReadV1V2Tool("PpmByteStreamReadV1V2Tool") ToolSvc += LVL1BS__RodHeaderByteStreamTool("RodHeaderByteStreamTool") ToolSvc += LVL1BS__L1CaloErrorByteStreamTool("L1CaloErrorByteStreamTool") ByteStreamAddressProviderSvc = Service( "ByteStreamAddressProviderSvc" ) -ByteStreamAddressProviderSvc.TypeNames += [ "DataVector<LVL1::CPMTower>/CPMTowers" ] -ByteStreamAddressProviderSvc.TypeNames += [ "DataVector<LVL1::CPMTower>/CPMTowersOverlap" ] -ByteStreamAddressProviderSvc.TypeNames += [ "DataVector<LVL1::CMXCPTob>/CMXCPTobs" ] -ByteStreamAddressProviderSvc.TypeNames += [ "DataVector<LVL1::CMXCPHits>/CMXCPHits" ] ByteStreamAddressProviderSvc.TypeNames += [ "DataVector<LVL1::CPMTobRoI>/CPMTobRoIs" ] ByteStreamAddressProviderSvc.TypeNames += [ "DataVector<LVL1::CPMTobRoI>/CPMTobRoIsRoIB" ] ByteStreamAddressProviderSvc.TypeNames += [ "DataVector<LVL1::JetElement>/JetElements" ] @@ -46,13 +41,34 @@ ByteStreamAddressProviderSvc.TypeNames += [ "DataVector<LVL1::JEMTobRoI>/JEMTobR ByteStreamAddressProviderSvc.TypeNames += [ "LVL1::CMXRoI/CMXRoIs" ] ByteStreamAddressProviderSvc.TypeNames += [ "LVL1::CMXRoI/CMXRoIsRoIB" ] +# ============================================================================= +# PPM +# ============================================================================= ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::TriggerTowerContainer/xAODTriggerTowers"] ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::TriggerTowerAuxContainer/xAODTriggerTowersAux."] ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::TriggerTowerContainer/xAODTriggerTowersMuon"] ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::TriggerTowerAuxContainer/xAODTriggerTowersMuonAux."] ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::TriggerTowerContainer/xAODTriggerTowersSpare"] ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::TriggerTowerAuxContainer/xAODTriggerTowersSpareAux."] -ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::CPMTowerContainer/xAODCPMTowers" ] +# ============================================================================= +# CPM +# ============================================================================= +ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::CPMTowerContainer/CPMTowers" ] +ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::CPMTowerAuxContainer/CPMTowersAux." ] + +ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::CPMTowerAuxContainer/CPMTowersOverlap" ] +ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::CPMTowerAuxContainer/CPMTowersOverlapAux." ] +# ============================================================================= +# CMXCPTOB +# ============================================================================= +ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::CMXCPTobContainer/CMXCPTobs" ] +ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::CMXCPTobAuxContainer/CMXCPTobsAux." ] +# ============================================================================= +# CMXCPHITS +# ============================================================================= +ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::CMXCPHitsContainer/CMXCPHits" ] +ByteStreamAddressProviderSvc.TypeNames += [ "xAOD::CMXCPHitsAuxContainer/CMXCPHitsAux." ] +# ============================================================================= ByteStreamAddressProviderSvc.TypeNames += [ "DataVector<LVL1::RODHeader>/RODHeaders" ] ByteStreamAddressProviderSvc.TypeNames += [ "DataVector<LVL1::RODHeader>/RODHeadersPP" ] diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/share/xAODWrite_jobOptions.py b/Trigger/TrigT1/TrigT1CaloByteStream/share/xAODWrite_jobOptions.py index 438d9a3bb4e87b506fe91c311e31e52738b6e810..58e368eca367070b23e8fd6cf8ae3a06b33d5aa2 100644 --- a/Trigger/TrigT1/TrigT1CaloByteStream/share/xAODWrite_jobOptions.py +++ b/Trigger/TrigT1/TrigT1CaloByteStream/share/xAODWrite_jobOptions.py @@ -2,7 +2,9 @@ # ============================================================================== # Change the input file InputFiles = [ - "/afs/cern.ch/work/g/geisler/public/misc/l1caloruns/data15_calib.00252372.calibration_L1CaloPprPhos4ScanPars.daq.RAW._lb0000._SFO-1._0001.data", + "/afs/cern.ch/work/v/vkousk/public/L1Calo/data15_cos.00255313.physics_CosmicCalo.merge.RAW._lb0700._SFO-ALL._0001.1" +# "/afs/cern.ch/user/t/tcorneli/public/PROC/extractedEvents8.data", +# "/afs/cern.ch/work/g/geisler/public/misc/l1caloruns/data15_calib.00252372.calibration_L1CaloPprPhos4ScanPars.daq.RAW._lb0000._SFO-1._0001.data", # "/afs/cern.ch/work/h/hmeyerzt/public/data/data15_cos.00252223.physics_CosmicCalo.merge.RAW._lb0025._SFO-ALL._0001.1", # "/afs/cern.ch/user/r/rhowen/ppmData/ppmBcMuxRamp.data", # "/afs/cern.ch/user/r/rhowen/ppmData/ppmBcMuxRamp_Compressed.data", @@ -46,8 +48,8 @@ class PyTriggerTowerRef(PyAthena.Alg): return PyAthena.StatusCode.Success def execute(self): - tt = self.event_store["xAODTriggerTowers"] - # cpm = self.event_store["CPMTowers"] + #tt = self.event_store["xAODTriggerTowers"] + cpm = self.event_store["CPMTowers"] # je = self.event_store["JetElements"] # for j in je: # vv = j.hadEnergyVec() diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/CmxEnergySubBlock.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/CmxEnergySubBlock.cxx index 384af45046ba4b6a83d500406f9f9d45848b9afe..a341550679f74f3a8ce540e6a8747c306dacb276 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/CmxEnergySubBlock.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/CmxEnergySubBlock.cxx @@ -83,22 +83,22 @@ int CmxEnergySubBlock::error(const int slice, const int jem, if (slice >= 0 && slice < timeslices() && !m_sumsData.empty()) { if (jem >= 0 && jem < s_maxJems) { parity = (m_sumsData[index(slice, jem) + eType] >> s_errorBit) - & s_errorMask; + & s_errorMask; } } - return parity<<1; + return parity << 1; } // Return energy subsum for given source, sum type and energy type unsigned int CmxEnergySubBlock::energy(const int slice, const SourceType source, - const SumType sType, + const SumType sType, const EnergyType eType) const { unsigned int e = 0; if (slice >= 0 && slice < timeslices() && !m_sumsData.empty()) { - const int pos = s_maxJems + 2*source + sType; + const int pos = s_maxJems + 2 * source + sType; e = m_sumsData[index(slice, pos) + eType] & s_energySumMask; } return e; @@ -108,31 +108,31 @@ unsigned int CmxEnergySubBlock::energy(const int slice, int CmxEnergySubBlock::error(const int slice, const SourceType source, - const SumType sType, + const SumType sType, const EnergyType eType) const { int parity = 0; int overflow = 0; if (slice >= 0 && slice < timeslices() && !m_sumsData.empty()) { - const int pos = s_maxJems + 2*source + sType; + const int pos = s_maxJems + 2 * source + sType; const uint32_t word = m_sumsData[index(slice, pos) + eType]; overflow = (word >> s_overflowBit) & s_overflowMask; if (source == REMOTE) parity = (word >> s_errorBit) & s_errorMask; } - return (parity<<1) + overflow; + return (parity << 1) + overflow; } // Return hits map for given hits type and sum type unsigned int CmxEnergySubBlock::hits(const int slice, const HitsType hType, - const SumType sType) const + const SumType sType) const { unsigned int map = 0; if (slice >= 0 && slice < timeslices() && !m_sumsData.empty()) { - const int pos = s_maxJems + 2*TOTAL + sType; + const int pos = s_maxJems + 2 * TOTAL + sType; map = (m_sumsData[index(slice, pos) + hType] >> s_etHitsBit) - & s_etHitsMask; + & s_etHitsMask; } return map; } @@ -141,8 +141,8 @@ unsigned int CmxEnergySubBlock::hits(const int slice, void CmxEnergySubBlock::setSubsums(const int slice, const int jem, const unsigned int ex, const unsigned int ey, - const unsigned int et, const int exError, - const int eyError, const int etError) + const unsigned int et, const int exError, + const int eyError, const int etError) { if (slice >= 0 && slice < timeslices() && jem >= 0 && jem < s_maxJems) { resize(); @@ -154,13 +154,13 @@ void CmxEnergySubBlock::setSubsums(const int slice, const int jem, for (int eType = 0; eType < MAX_ENERGY_TYPE; ++eType) { if (eType == ENERGY_EX) { energy = ex; - error = exError; + error = exError; } else if (eType == ENERGY_EY) { energy = ey; - error = eyError; + error = eyError; } else { energy = et; - error = etError; + error = etError; } parity = (error >> 1) & s_errorMask; if (energy || parity) { @@ -180,12 +180,12 @@ void CmxEnergySubBlock::setSubsums(const int slice, const int jem, void CmxEnergySubBlock::setSubsums(const int slice, const SourceType source, const SumType sType, const unsigned int ex, const unsigned int ey, - const unsigned int et, const int exError, - const int eyError, const int etError) + const unsigned int et, const int exError, + const int eyError, const int etError) { if (slice >= 0 && slice < timeslices()) { resize(); - const int pos = s_maxJems + 2*source + sType; + const int pos = s_maxJems + 2 * source + sType; const int ix = index(slice, pos); unsigned int energy = 0; int error = 0; @@ -194,27 +194,27 @@ void CmxEnergySubBlock::setSubsums(const int slice, const SourceType source, uint32_t word = 0; uint32_t baseword = (CRATE_SYSTEM_ID << s_wordIdBit) + (source << s_sourceBit) + - (sType << s_sumTypeBit); + (sType << s_sumTypeBit); for (int eType = 0; eType < MAX_ENERGY_TYPE; ++eType) { if (eType == ENERGY_EX) { energy = ex; - error = exError; + error = exError; } else if (eType == ENERGY_EY) { energy = ey; - error = eyError; + error = eyError; } else { energy = et; - error = etError; + error = etError; } overflow = error & s_overflowMask; parity = (source == REMOTE) ? ((error >> 1) & s_errorMask) : 0; if (energy || overflow || parity) { - word = m_sumsData[ix + eType]; + word = m_sumsData[ix + eType]; word |= energy & s_energySumMask; - word |= overflow << s_overflowBit; + word |= overflow << s_overflowBit; word |= parity << s_errorBit; word |= eType << s_energyTypeBit; - word |= baseword; + word |= baseword; m_sumsData[ix + eType] = word; } } @@ -228,7 +228,7 @@ void CmxEnergySubBlock::setEtHits(const int slice, const HitsType hType, { if (map && slice >= 0 && slice < timeslices()) { resize(); - const int pos = s_maxJems + 2*TOTAL + sType; + const int pos = s_maxJems + 2 * TOTAL + sType; const int ix = index(slice, pos); uint32_t word = m_sumsData[ix + hType]; word |= (map & s_etHitsMask) << s_etHitsBit; @@ -246,20 +246,20 @@ bool CmxEnergySubBlock::pack() { bool rc = false; switch (version()) { - case 3: //<<== CHECK - switch (format()) { - case NEUTRAL: - rc = packNeutral(); - break; - case UNCOMPRESSED: - rc = packUncompressed(); - break; - default: - break; - } + case 3: //<<== CHECK + switch (format()) { + case NEUTRAL: + rc = packNeutral(); + break; + case UNCOMPRESSED: + rc = packUncompressed(); break; default: break; + } + break; + default: + break; } return rc; } @@ -267,23 +267,24 @@ bool CmxEnergySubBlock::pack() bool CmxEnergySubBlock::unpack() { bool rc = false; + switch (version()) { - case 3: //<<== CHECK - switch (format()) { - case NEUTRAL: - rc = unpackNeutral(); - break; - case UNCOMPRESSED: - rc = unpackUncompressed(); - break; - default: - setUnpackErrorCode(UNPACK_FORMAT); - break; - } + case 1: //<<== CHECK + switch (format()) { + case NEUTRAL: + rc = unpackNeutral(); + break; + case UNCOMPRESSED: + rc = unpackUncompressed(); break; default: - setUnpackErrorCode(UNPACK_VERSION); + setUnpackErrorCode(UNPACK_FORMAT); break; + } + break; + default: + setUnpackErrorCode(UNPACK_VERSION); + break; } return rc; } @@ -292,7 +293,7 @@ bool CmxEnergySubBlock::unpack() int CmxEnergySubBlock::index(const int slice, const int pos) const { - int ix = 3*pos; + int ix = 3 * pos; if (format() == NEUTRAL) ix += slice * s_maxSums; return ix; } @@ -319,13 +320,13 @@ bool CmxEnergySubBlock::packNeutral() // JEM energy sums (jem == pin); parity errors packerNeutral(pin, energy(slice, pin, ENERGY_EX), s_jemSumBits); packerNeutral(pin, 0, s_jemPaddingBits); - packerNeutral(pin, (error(slice, pin, ENERGY_EX)>>1), 1); + packerNeutral(pin, (error(slice, pin, ENERGY_EX) >> 1), 1); packerNeutral(pin, energy(slice, pin, ENERGY_EY), s_jemSumBits); packerNeutral(pin, 0, s_jemPaddingBits); - packerNeutral(pin, (error(slice, pin, ENERGY_EY)>>1), 1); + packerNeutral(pin, (error(slice, pin, ENERGY_EY) >> 1), 1); packerNeutral(pin, energy(slice, pin, ENERGY_ET), s_jemSumBits); packerNeutral(pin, 0, s_jemPaddingBits); - packerNeutral(pin, (error(slice, pin, ENERGY_ET)>>1), 1); + packerNeutral(pin, (error(slice, pin, ENERGY_ET) >> 1), 1); packerNeutral(pin, 0, s_jemSumBits); packerNeutral(pin, 0, s_jemPaddingBits); packerNeutral(pin, 0, 1); @@ -333,69 +334,69 @@ bool CmxEnergySubBlock::packNeutral() // Remote Ex, Ey, Et int pin = s_maxJems; packerNeutral(pin, energy(slice, REMOTE, STANDARD, ENERGY_EX), - s_sumBitsExEy); - packerNeutral(pin, (error(slice, REMOTE, STANDARD, ENERGY_EX)>>1), 1); + s_sumBitsExEy); + packerNeutral(pin, (error(slice, REMOTE, STANDARD, ENERGY_EX) >> 1), 1); packerNeutral(pin, energy(slice, REMOTE, RESTRICTED_WEIGHTED, ENERGY_EX), - s_sumBitsExEy); + s_sumBitsExEy); packerNeutral(pin, (error(slice, REMOTE, RESTRICTED_WEIGHTED, - ENERGY_EX)>>1), 1); - packerNeutral(pin, (error(slice, REMOTE, STANDARD, ENERGY_EX)&0x1), 1); // Seems inconsistent with SLink? + ENERGY_EX) >> 1), 1); + packerNeutral(pin, (error(slice, REMOTE, STANDARD, ENERGY_EX) & 0x1), 1); // Seems inconsistent with SLink? packerNeutral(pin, energy(slice, REMOTE, STANDARD, ENERGY_EY), - s_sumBitsExEy); - packerNeutral(pin, (error(slice, REMOTE, STANDARD, ENERGY_EY)>>1), 1); + s_sumBitsExEy); + packerNeutral(pin, (error(slice, REMOTE, STANDARD, ENERGY_EY) >> 1), 1); packerNeutral(pin, energy(slice, REMOTE, RESTRICTED_WEIGHTED, ENERGY_EY), - s_sumBitsExEy); + s_sumBitsExEy); packerNeutral(pin, (error(slice, REMOTE, RESTRICTED_WEIGHTED, - ENERGY_EY)>>1), 1); - packerNeutral(pin, (error(slice, REMOTE, STANDARD, ENERGY_EY)&0x1), 1); + ENERGY_EY) >> 1), 1); + packerNeutral(pin, (error(slice, REMOTE, STANDARD, ENERGY_EY) & 0x1), 1); packerNeutral(pin, energy(slice, REMOTE, STANDARD, ENERGY_ET), - s_sumBitsEtCrate); + s_sumBitsEtCrate); packerNeutral(pin, 0, 1); packerNeutral(pin, energy(slice, REMOTE, RESTRICTED_WEIGHTED, ENERGY_ET), - s_sumBitsEtCrate); - packerNeutral(pin, (error(slice, REMOTE, STANDARD, ENERGY_ET)&0x1), 1); + s_sumBitsEtCrate); + packerNeutral(pin, (error(slice, REMOTE, STANDARD, ENERGY_ET) & 0x1), 1); // Local Ex, Ey, Et ++pin; packerNeutral(pin, energy(slice, LOCAL, STANDARD, ENERGY_EX), - s_sumBitsExEy); + s_sumBitsExEy); packerNeutral(pin, 0, 1); packerNeutral(pin, energy(slice, LOCAL, RESTRICTED_WEIGHTED, ENERGY_EX), - s_sumBitsExEy); + s_sumBitsExEy); packerNeutral(pin, 0, 1); - packerNeutral(pin, (error(slice, LOCAL, STANDARD, ENERGY_EX)&0x1), 1); + packerNeutral(pin, (error(slice, LOCAL, STANDARD, ENERGY_EX) & 0x1), 1); packerNeutral(pin, energy(slice, LOCAL, STANDARD, ENERGY_EY), - s_sumBitsExEy); + s_sumBitsExEy); packerNeutral(pin, 0, 1); packerNeutral(pin, energy(slice, LOCAL, RESTRICTED_WEIGHTED, ENERGY_EY), - s_sumBitsExEy); + s_sumBitsExEy); packerNeutral(pin, 0, 1); - packerNeutral(pin, (error(slice, LOCAL, STANDARD, ENERGY_EY)&0x1), 1); + packerNeutral(pin, (error(slice, LOCAL, STANDARD, ENERGY_EY) & 0x1), 1); packerNeutral(pin, energy(slice, LOCAL, STANDARD, ENERGY_ET), - s_sumBitsEtCrate); + s_sumBitsEtCrate); packerNeutral(pin, 0, 1); packerNeutral(pin, energy(slice, LOCAL, RESTRICTED_WEIGHTED, ENERGY_ET), - s_sumBitsEtCrate); - packerNeutral(pin, (error(slice, LOCAL, STANDARD, ENERGY_ET)&0x1), 1); + s_sumBitsEtCrate); + packerNeutral(pin, (error(slice, LOCAL, STANDARD, ENERGY_ET) & 0x1), 1); // Total Ex, Ey, Et ++pin; packerNeutral(pin, energy(slice, TOTAL, STANDARD, ENERGY_EX), - s_sumBitsExEy); + s_sumBitsExEy); packerNeutral(pin, 0, 1); packerNeutral(pin, energy(slice, TOTAL, RESTRICTED_WEIGHTED, ENERGY_EX), - s_sumBitsExEy); + s_sumBitsExEy); packerNeutral(pin, 0, 1); - packerNeutral(pin, (error(slice, TOTAL, STANDARD, ENERGY_EX)&0x1), 1); + packerNeutral(pin, (error(slice, TOTAL, STANDARD, ENERGY_EX) & 0x1), 1); packerNeutral(pin, energy(slice, TOTAL, STANDARD, ENERGY_EY), - s_sumBitsExEy); + s_sumBitsExEy); packerNeutral(pin, 0, 1); packerNeutral(pin, energy(slice, TOTAL, RESTRICTED_WEIGHTED, ENERGY_EY), - s_sumBitsExEy); - packerNeutral(pin, (error(slice, TOTAL, STANDARD, ENERGY_ET)&0x1), 1); - packerNeutral(pin, (error(slice, TOTAL, STANDARD, ENERGY_EY)&0x1), 1); + s_sumBitsExEy); + packerNeutral(pin, (error(slice, TOTAL, STANDARD, ENERGY_ET) & 0x1), 1); + packerNeutral(pin, (error(slice, TOTAL, STANDARD, ENERGY_EY) & 0x1), 1); packerNeutral(pin, energy(slice, TOTAL, STANDARD, ENERGY_ET), - s_sumBitsEtSys); + s_sumBitsEtSys); packerNeutral(pin, energy(slice, TOTAL, RESTRICTED_WEIGHTED, ENERGY_ET), - s_sumBitsEtSys); + s_sumBitsEtSys); // Bunchcrossing number, Fifo overflow ++pin; packerNeutral(pin, bunchCrossing(), s_bunchCrossingBits); @@ -405,9 +406,9 @@ bool CmxEnergySubBlock::packNeutral() packerNeutral(pin, hits(slice, MISSING_ET, STANDARD), s_etHitMapsBits); packerNeutral(pin, hits(slice, MISSING_ET_SIG, STANDARD), s_etHitMapsBits); packerNeutral(pin, hits(slice, SUM_ET, RESTRICTED_WEIGHTED), - s_etHitMapsBits); + s_etHitMapsBits); packerNeutral(pin, hits(slice, MISSING_ET, RESTRICTED_WEIGHTED), - s_etHitMapsBits); + s_etHitMapsBits); packerNeutral(pin, 0, s_paddingBits); // G-Link parity errors for (int p = 0; p <= pin; ++p) packerNeutralParity(p); @@ -452,7 +453,7 @@ bool CmxEnergySubBlock::unpackNeutral() unpackerNeutral(pin, s_jemPaddingBits); unpackerNeutral(pin, 1); setSubsums(slice, pin, en[ENERGY_EX], en[ENERGY_EY], en[ENERGY_ET], - er[ENERGY_EX], er[ENERGY_EY], er[ENERGY_ET]); + er[ENERGY_EX], er[ENERGY_EY], er[ENERGY_ET]); } // Remote Ex, Ey, Et, parity, overflow int pin = s_maxJems; @@ -476,10 +477,10 @@ bool CmxEnergySubBlock::unpackNeutral() er[ENERGY_ET] |= unpackerNeutral(pin, 1); setSubsums(slice, REMOTE, STANDARD, en[ENERGY_EX], en[ENERGY_EY], en[ENERGY_ET], - er[ENERGY_EX], er[ENERGY_EY], er[ENERGY_ET]); + er[ENERGY_EX], er[ENERGY_EY], er[ENERGY_ET]); setSubsums(slice, REMOTE, RESTRICTED_WEIGHTED, rn[ENERGY_EX], rn[ENERGY_EY], rn[ENERGY_ET], - rr[ENERGY_EX], rr[ENERGY_EY], rr[ENERGY_ET]); + rr[ENERGY_EX], rr[ENERGY_EY], rr[ENERGY_ET]); // Local Ex, Ey, Et, overflow ++pin; en[ENERGY_EX] = unpackerNeutral(pin, s_sumBitsExEy); @@ -501,10 +502,10 @@ bool CmxEnergySubBlock::unpackNeutral() rr[ENERGY_ET] = 0; setSubsums(slice, LOCAL, STANDARD, en[ENERGY_EX], en[ENERGY_EY], en[ENERGY_ET], - er[ENERGY_EX], er[ENERGY_EY], er[ENERGY_ET]); + er[ENERGY_EX], er[ENERGY_EY], er[ENERGY_ET]); setSubsums(slice, LOCAL, RESTRICTED_WEIGHTED, rn[ENERGY_EX], rn[ENERGY_EY], rn[ENERGY_ET], - rr[ENERGY_EX], rr[ENERGY_EY], rr[ENERGY_ET]); + rr[ENERGY_EX], rr[ENERGY_EY], rr[ENERGY_ET]); // Total Ex, Ey, Et, overflow ++pin; en[ENERGY_EX] = unpackerNeutral(pin, s_sumBitsExEy); @@ -524,10 +525,10 @@ bool CmxEnergySubBlock::unpackNeutral() rn[ENERGY_ET] = unpackerNeutral(pin, s_sumBitsEtSys); setSubsums(slice, TOTAL, STANDARD, en[ENERGY_EX], en[ENERGY_EY], en[ENERGY_ET], - er[ENERGY_EX], er[ENERGY_EY], er[ENERGY_ET]); + er[ENERGY_EX], er[ENERGY_EY], er[ENERGY_ET]); setSubsums(slice, TOTAL, RESTRICTED_WEIGHTED, rn[ENERGY_EX], rn[ENERGY_EY], rn[ENERGY_ET], - rr[ENERGY_EX], rr[ENERGY_EY], rr[ENERGY_ET]); + rr[ENERGY_EX], rr[ENERGY_EY], rr[ENERGY_ET]); // Bunchcrossing number, Fifo overflow ++pin; bunchCrossing = unpackerNeutral(pin, s_bunchCrossingBits); @@ -570,7 +571,7 @@ bool CmxEnergySubBlock::unpackUncompressed() if (wordId == MODULE_ID) { const int jem = (word >> s_jemBit) & s_jemMask; const int eType = (word >> s_energyTypeJemBit) & s_energyTypeMask; - const int pos = 3*jem + eType; + const int pos = 3 * jem + eType; if (eType < MAX_ENERGY_TYPE && m_sumsData[pos] == 0) { m_sumsData[pos] = word; } else error = true; @@ -578,9 +579,9 @@ bool CmxEnergySubBlock::unpackUncompressed() const int source = (word >> s_sourceBit) & s_sourceMask; const int sType = (word >> s_sumTypeBit) & s_sumTypeMask; const int eType = (word >> s_energyTypeBit) & s_energyTypeMask; - const int pos = 3*(s_maxJems + 2*source + sType) + eType; + const int pos = 3 * (s_maxJems + 2 * source + sType) + eType; if (source < MAX_SOURCE_TYPE && eType < MAX_ENERGY_TYPE - && m_sumsData[pos] == 0) { + && m_sumsData[pos] == 0) { m_sumsData[pos] = word; } else error = true; } else error = true; diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/CmxJetSubBlock.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/CmxJetSubBlock.cxx index bb0ff2eac71507ac6e87410bbd136e808714cd73..952e9f4c8f63108fb3ee295d4d2d670998a2069e 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/CmxJetSubBlock.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/CmxJetSubBlock.cxx @@ -46,7 +46,7 @@ const int CmxJetSubBlock::s_presenceBits; const int CmxJetSubBlock::s_coordBits; const int CmxJetSubBlock::s_energyLgBits; //const int CmxJetSubBlock::s_energySmBits[8]; -const int CmxJetSubBlock::s_energySmBits[8] = {3,6,5,4,7,2,9,0}; +const int CmxJetSubBlock::s_energySmBits[8] = {3, 6, 5, 4, 7, 2, 9, 0}; const int CmxJetSubBlock::s_threshMainBits; const int CmxJetSubBlock::s_threshFwdLBits; const int CmxJetSubBlock::s_threshFwdHBits; @@ -87,7 +87,7 @@ void CmxJetSubBlock::clear() // Return presence map for given JEM unsigned int CmxJetSubBlock::presenceMap(const int slice, - const int jem) const + const int jem) const { unsigned int map = 0; const unsigned int ix = mapIndex(slice, jem); @@ -168,14 +168,14 @@ int CmxJetSubBlock::parityBits(const int slice, const int jem) const // Return hit/topo counts for given source ID and HL flag unsigned int CmxJetSubBlock::hits(const int slice, const int source, - const int flag) const + const int flag) const { unsigned int hits = 0; const unsigned int ix = hitIndex(slice, source, flag); if (ix < m_hitsData.size()) { uint32_t mask = s_threshMainMask; if (source == REMOTE_FORWARD || source == LOCAL_FORWARD - || source == TOTAL_FORWARD) { + || source == TOTAL_FORWARD) { mask = (flag) ? s_threshFwdHMask : s_threshFwdLMask; } else if (source == TOPO_CHECKSUM) mask = s_topoCheckMask; @@ -189,12 +189,12 @@ unsigned int CmxJetSubBlock::hits(const int slice, const int source, // Return hit error for given source ID and HL flag int CmxJetSubBlock::hitsError(const int slice, const int source, - const int flag) const + const int flag) const { int error = 0; if (source == REMOTE_MAIN || source == LOCAL_MAIN || source == TOTAL_MAIN || source == REMOTE_FORWARD || source == LOCAL_FORWARD || - source == TOTAL_FORWARD) { + source == TOTAL_FORWARD) { const unsigned int ix = hitIndex(slice, source, flag); if (ix < m_hitsData.size()) { error = (m_hitsData[ix] >> s_threshErrorBit) & s_errorMask; @@ -206,7 +206,7 @@ int CmxJetSubBlock::hitsError(const int slice, const int source, // Store presence map void CmxJetSubBlock::setPresenceMap(const int slice, const int jem, - const unsigned int map) + const unsigned int map) { resize(); if (map) { @@ -219,7 +219,7 @@ void CmxJetSubBlock::setPresenceMap(const int slice, const int jem, void CmxJetSubBlock::setTob(const int slice, const int jem, const int frame, const int loc, const int energyLarge, - const int energySmall, const int error) + const int energySmall, const int error) { resize(); if (energyLarge || energySmall || error) { @@ -236,15 +236,15 @@ void CmxJetSubBlock::setTob(const int slice, const int jem, const int frame, const unsigned int ix = tobIndex(slice, jem, tob); if (m_tobData[ix] == 0) { m_tobData[ix] = word; - break; + break; } else { - const int frameOld = (m_tobData[ix]>>s_tobFrameBit)&s_tobFrameMask; - if (frame < frameOld) { - for (int i = s_tobsPerModule-tob-1; i > 0; --i) { - m_tobData[ix + i] = m_tobData[ix + i - 1]; + const int frameOld = (m_tobData[ix] >> s_tobFrameBit)&s_tobFrameMask; + if (frame < frameOld) { + for (int i = s_tobsPerModule - tob - 1; i > 0; --i) { + m_tobData[ix + i] = m_tobData[ix + i - 1]; } - m_tobData[ix] = word; - break; + m_tobData[ix] = word; + break; } } } @@ -254,7 +254,7 @@ void CmxJetSubBlock::setTob(const int slice, const int jem, const int frame, // Store parity bits for neutral format void CmxJetSubBlock::setParityBits(const int slice, const int jem, - const int parity) + const int parity) { resize(); if (parity) { @@ -274,7 +274,7 @@ void CmxJetSubBlock::setHits(const int slice, const int source, const int flag, uint32_t word = m_hitsData[ix]; uint32_t mask = s_threshMainMask; if (source == REMOTE_FORWARD || source == LOCAL_FORWARD || - source == TOTAL_FORWARD) { + source == TOTAL_FORWARD) { mask = (flag) ? s_threshFwdHMask : s_threshFwdLMask; } else if (source == TOPO_CHECKSUM) mask = s_topoCheckMask; @@ -295,21 +295,21 @@ bool CmxJetSubBlock::pack() { bool rc = false; switch (version()) { - case 1: - case 2: // <<== CHECK - switch (format()) { - case NEUTRAL: - rc = packNeutral(); - break; - case UNCOMPRESSED: - rc = packUncompressed(); - break; - default: - break; - } + case 1: + case 2: // <<== CHECK + switch (format()) { + case NEUTRAL: + rc = packNeutral(); + break; + case UNCOMPRESSED: + rc = packUncompressed(); break; default: break; + } + break; + default: + break; } return rc; } @@ -318,23 +318,23 @@ bool CmxJetSubBlock::unpack() { bool rc = false; switch (version()) { - case 1: - case 2: // <<== CHECK - switch (format()) { - case NEUTRAL: - rc = unpackNeutral(); - break; - case UNCOMPRESSED: - rc = unpackUncompressed(); - break; - default: - setUnpackErrorCode(UNPACK_FORMAT); - break; - } + case 1: + case 2: // <<== CHECK + switch (format()) { + case NEUTRAL: + rc = unpackNeutral(); + break; + case UNCOMPRESSED: + rc = unpackUncompressed(); break; default: - setUnpackErrorCode(UNPACK_VERSION); + setUnpackErrorCode(UNPACK_FORMAT); break; + } + break; + default: + setUnpackErrorCode(UNPACK_VERSION); + break; } return rc; } @@ -362,7 +362,7 @@ unsigned int CmxJetSubBlock::parIndex(const int slice, // Return tob data index appropriate to format unsigned int CmxJetSubBlock::tobIndex(const int slice, const int jem, - const int tob) const + const int tob) const { unsigned int ix = jem * s_tobsPerModule + tob; if (format() == NEUTRAL) ix += slice * s_modules * s_tobsPerModule; @@ -372,9 +372,9 @@ unsigned int CmxJetSubBlock::tobIndex(const int slice, const int jem, // Return hits data index appropriate to format unsigned int CmxJetSubBlock::hitIndex(const int slice, const int source, - const int flag) const + const int flag) const { - unsigned int ix = (source<<1)|flag; + unsigned int ix = (source << 1) | flag; if (format() == NEUTRAL) ix += slice * 2 * MAX_SOURCE_ID; return ix; } @@ -413,60 +413,60 @@ bool CmxJetSubBlock::packNeutral() for (int slice = 0; slice < slices; ++slice) { for (int pin = 0; pin < s_glinkPins; ++pin) { if (pin < s_modules) { // TOB data - const int jem = pin; + const int jem = pin; // Presence map packerNeutral(pin, presenceMap(slice, jem), s_presenceBits); - // Get tob data for this jem - locVec.clear(); - energyLgVec.clear(); - energySmVec.clear(); - for (int tob = 0; tob < s_tobsPerModule; ++tob) { - locVec.push_back(localCoord(slice, jem, tob)); - energyLgVec.push_back(energyLarge(slice, jem, tob)); - energySmVec.push_back(energySmall(slice, jem, tob)); - } - const int parity = parityBits(slice, jem); - // And pack + // Get tob data for this jem + locVec.clear(); + energyLgVec.clear(); + energySmVec.clear(); for (int tob = 0; tob < s_tobsPerModule; ++tob) { - // Energy small window LSB - const int nbitsL = s_energySmBits[2*tob]; - packerNeutral(pin, energySmVec[tob], nbitsL); + locVec.push_back(localCoord(slice, jem, tob)); + energyLgVec.push_back(energyLarge(slice, jem, tob)); + energySmVec.push_back(energySmall(slice, jem, tob)); + } + const int parity = parityBits(slice, jem); + // And pack + for (int tob = 0; tob < s_tobsPerModule; ++tob) { + // Energy small window LSB + const int nbitsL = s_energySmBits[2 * tob]; + packerNeutral(pin, energySmVec[tob], nbitsL); // Local coordinates - packerNeutral(pin, locVec[tob], s_coordBits); - // Energy large window - packerNeutral(pin, energyLgVec[tob], s_energyLgBits); - // Backplane parity error - packerNeutral(pin, (parity>>tob), s_parityErrorBits); - // Energy small window HSB - const int nbitsH = s_energySmBits[2*tob+1]; - if (nbitsH > 0) { - packerNeutral(pin, (energySmVec[tob]>>nbitsL), nbitsH); - } + packerNeutral(pin, locVec[tob], s_coordBits); + // Energy large window + packerNeutral(pin, energyLgVec[tob], s_energyLgBits); + // Backplane parity error + packerNeutral(pin, (parity >> tob), s_parityErrorBits); + // Energy small window HSB + const int nbitsH = s_energySmBits[2 * tob + 1]; + if (nbitsH > 0) { + packerNeutral(pin, (energySmVec[tob] >> nbitsL), nbitsH); + } } } else { // Hits and Topo data - if (pin < s_glinkPins-1) { + if (pin < s_glinkPins - 1) { // Remote, local and total hits; parity error const int source1 = pin - s_modules + REMOTE_MAIN; const int source2 = pin - s_modules + REMOTE_FORWARD; packerNeutral(pin, hits(slice, source1, 0), s_threshMainBits); packerNeutral(pin, hitsError(slice, source1, 0), s_parityErrorBits); packerNeutral(pin, hits(slice, source1, 1), s_threshMainBits); - packerNeutral(pin, (hitsError(slice, source1, 1)>>1), s_parityErrorBits); + packerNeutral(pin, (hitsError(slice, source1, 1) >> 1), s_parityErrorBits); packerNeutral(pin, hits(slice, source2, 0), s_threshFwdLBits); packerNeutral(pin, hitsError(slice, source2, 0), s_parityErrorBits); packerNeutral(pin, hits(slice, source2, 1), s_threshFwdHBits); - packerNeutral(pin, (hitsError(slice, source2, 1)>>1), s_parityErrorBits); - packerNeutral(pin, (hitsError(slice, source1, 0)>>2), s_roiOverflowBits); - packerNeutral(pin, 0, s_paddingBits); + packerNeutral(pin, (hitsError(slice, source2, 1) >> 1), s_parityErrorBits); + packerNeutral(pin, (hitsError(slice, source1, 0) >> 2), s_roiOverflowBits); + packerNeutral(pin, 0, s_paddingBits); } else { // Bunch crossing number, Fifo overflow and Topo data packerNeutral(pin, bunchCrossing(), s_bunchCrossingBits); - packerNeutral(pin, daqOverflow(), s_fifoOverflowBits); - packerNeutral(pin, hits(slice, TOPO_CHECKSUM, 0), s_topoChecksumBits); - packerNeutral(pin, hits(slice, TOPO_OCCUPANCY_MAP, 0), s_topoMapBits); - packerNeutral(pin, hits(slice, TOPO_OCCUPANCY_COUNTS, 0), s_topoCountsBits); - packerNeutral(pin, hits(slice, TOPO_OCCUPANCY_COUNTS, 1), s_topoCountsBits); - packerNeutral(pin, 0, s_topoPaddingBits); + packerNeutral(pin, daqOverflow(), s_fifoOverflowBits); + packerNeutral(pin, hits(slice, TOPO_CHECKSUM, 0), s_topoChecksumBits); + packerNeutral(pin, hits(slice, TOPO_OCCUPANCY_MAP, 0), s_topoMapBits); + packerNeutral(pin, hits(slice, TOPO_OCCUPANCY_COUNTS, 0), s_topoCountsBits); + packerNeutral(pin, hits(slice, TOPO_OCCUPANCY_COUNTS, 1), s_topoCountsBits); + packerNeutral(pin, 0, s_topoPaddingBits); } } // G-Link parity @@ -507,74 +507,74 @@ bool CmxJetSubBlock::unpackNeutral() for (int pin = 0; pin < s_glinkPins; ++pin) { if (pin < s_modules) { // TOB data // Presence map - const unsigned int map = unpackerNeutral(pin, s_presenceBits); - locVec.assign(s_tobsPerModule, 0); - energyLgVec.assign(s_tobsPerModule, 0); - energySmVec.assign(s_tobsPerModule, 0); - int parity = 0; - for (int tob = 0; tob < s_tobsPerModule; ++tob) { - // Energy small window LSB - const int nbitsL = s_energySmBits[2*tob]; - energySmVec[tob] = unpackerNeutral(pin, nbitsL); - // Local coordinates - locVec[tob] = unpackerNeutral(pin, s_coordBits); - // Energy large window - energyLgVec[tob] = unpackerNeutral(pin, s_energyLgBits); - // Backplane parity error - parity |= (unpackerNeutral(pin, s_parityErrorBits) << tob); - // Energy small window HSB - const int nbitsH = s_energySmBits[2*tob+1]; - if (nbitsH > 0) { - energySmVec[tob] += (unpackerNeutral(pin, nbitsH) << nbitsL); + const unsigned int map = unpackerNeutral(pin, s_presenceBits); + locVec.assign(s_tobsPerModule, 0); + energyLgVec.assign(s_tobsPerModule, 0); + energySmVec.assign(s_tobsPerModule, 0); + int parity = 0; + for (int tob = 0; tob < s_tobsPerModule; ++tob) { + // Energy small window LSB + const int nbitsL = s_energySmBits[2 * tob]; + energySmVec[tob] = unpackerNeutral(pin, nbitsL); + // Local coordinates + locVec[tob] = unpackerNeutral(pin, s_coordBits); + // Energy large window + energyLgVec[tob] = unpackerNeutral(pin, s_energyLgBits); + // Backplane parity error + parity |= (unpackerNeutral(pin, s_parityErrorBits) << tob); + // Energy small window HSB + const int nbitsH = s_energySmBits[2 * tob + 1]; + if (nbitsH > 0) { + energySmVec[tob] += (unpackerNeutral(pin, nbitsH) << nbitsL); } } - const int error = (parity) ? 1 : 0; - int tob = 0; - const int jem = pin; - for (int frame = 0; frame < s_presenceBits && tob < s_tobsPerModule; ++frame) { // <<== CHECK - assuming bit==frame - if ((map>>frame)&1) { - setTob(slice, jem, frame, locVec[tob], energyLgVec[tob], - energySmVec[tob], error); - ++tob; + const int error = (parity) ? 1 : 0; + int tob = 0; + const int jem = pin; + for (int frame = 0; frame < s_presenceBits && tob < s_tobsPerModule; ++frame) { // <<== CHECK - assuming bit==frame + if ((map >> frame) & 1) { + setTob(slice, jem, frame, locVec[tob], energyLgVec[tob], + energySmVec[tob], error); + ++tob; } } setPresenceMap(slice, jem, map); - setParityBits(slice, jem, parity); + setParityBits(slice, jem, parity); } else { // Hits and Topo data - if (pin < s_glinkPins-1) { - // Remote, local and total hits; parity error, RoI overflow + if (pin < s_glinkPins - 1) { + // Remote, local and total hits; parity error, RoI overflow const int source1 = pin - s_modules + REMOTE_MAIN; const int source2 = pin - s_modules + REMOTE_FORWARD; - const unsigned int main0 = unpackerNeutral(pin, s_threshMainBits); - int errorMain = unpackerNeutral(pin, s_parityErrorBits); - const unsigned int main1 = unpackerNeutral(pin, s_threshMainBits); - errorMain |= (unpackerNeutral(pin, s_parityErrorBits)<<1); - const unsigned int fwd0 = unpackerNeutral(pin, s_threshFwdLBits); - int errorFwd = unpackerNeutral(pin, s_parityErrorBits); - const unsigned int fwd1 = unpackerNeutral(pin, s_threshFwdHBits); - errorFwd |= (unpackerNeutral(pin, s_parityErrorBits)<<1); - const int overflow = (unpackerNeutral(pin, s_roiOverflowBits)<<2); - errorMain |= overflow; - errorFwd |= overflow; - setHits(slice, source1, 0, main0, errorMain); - setHits(slice, source1, 1, main1, errorMain); - setHits(slice, source2, 0, fwd0, errorFwd); - setHits(slice, source2, 1, fwd1, errorFwd); - unpackerNeutral(pin, s_paddingBits); + const unsigned int main0 = unpackerNeutral(pin, s_threshMainBits); + int errorMain = unpackerNeutral(pin, s_parityErrorBits); + const unsigned int main1 = unpackerNeutral(pin, s_threshMainBits); + errorMain |= (unpackerNeutral(pin, s_parityErrorBits) << 1); + const unsigned int fwd0 = unpackerNeutral(pin, s_threshFwdLBits); + int errorFwd = unpackerNeutral(pin, s_parityErrorBits); + const unsigned int fwd1 = unpackerNeutral(pin, s_threshFwdHBits); + errorFwd |= (unpackerNeutral(pin, s_parityErrorBits) << 1); + const int overflow = (unpackerNeutral(pin, s_roiOverflowBits) << 2); + errorMain |= overflow; + errorFwd |= overflow; + setHits(slice, source1, 0, main0, errorMain); + setHits(slice, source1, 1, main1, errorMain); + setHits(slice, source2, 0, fwd0, errorFwd); + setHits(slice, source2, 1, fwd1, errorFwd); + unpackerNeutral(pin, s_paddingBits); } else { - // Bunch crossing number, Fifo overflow and Topo data - bunchCrossing = unpackerNeutral(pin, s_bunchCrossingBits); - fifoOverflow |= unpackerNeutral(pin, s_fifoOverflowBits); - unsigned int hits = unpackerNeutral(pin, s_topoChecksumBits); - int error = 0; - setHits(slice, TOPO_CHECKSUM, 0, hits, error); - hits = unpackerNeutral(pin, s_topoMapBits); - setHits(slice, TOPO_OCCUPANCY_MAP, 0, hits, error); - hits = unpackerNeutral(pin, s_topoCountsBits); - setHits(slice, TOPO_OCCUPANCY_COUNTS, 0, hits, error); - hits = unpackerNeutral(pin, s_topoCountsBits); - setHits(slice, TOPO_OCCUPANCY_COUNTS, 1, hits, error); - unpackerNeutral(pin, s_topoPaddingBits); + // Bunch crossing number, Fifo overflow and Topo data + bunchCrossing = unpackerNeutral(pin, s_bunchCrossingBits); + fifoOverflow |= unpackerNeutral(pin, s_fifoOverflowBits); + unsigned int hits = unpackerNeutral(pin, s_topoChecksumBits); + int error = 0; + setHits(slice, TOPO_CHECKSUM, 0, hits, error); + hits = unpackerNeutral(pin, s_topoMapBits); + setHits(slice, TOPO_OCCUPANCY_MAP, 0, hits, error); + hits = unpackerNeutral(pin, s_topoCountsBits); + setHits(slice, TOPO_OCCUPANCY_COUNTS, 0, hits, error); + hits = unpackerNeutral(pin, s_topoCountsBits); + setHits(slice, TOPO_OCCUPANCY_COUNTS, 1, hits, error); + unpackerNeutral(pin, s_topoPaddingBits); } } // G-Link parity errors @@ -604,21 +604,21 @@ bool CmxJetSubBlock::unpackUncompressed() if (id == s_tobWordId) { // TOB data const int index = jem(word); const int count = m_jemTobCount[index]; - const int index2 = index*s_tobsPerModule + count; + const int index2 = index * s_tobsPerModule + count; if (count < s_tobsPerModule) { m_tobData[index2] = word; ++m_jemTobCount[index]; } else { setUnpackErrorCode(UNPACK_EXCESS_TOBS); // New code. Check consequences - return false; + return false; } } else if (id == s_threshWordId) { // Hits and Topo data - const int index = (sourceId(word)<<1) | hlFlag(word); + const int index = (sourceId(word) << 1) | hlFlag(word); if (index < maxHits && m_hitsData[index] == 0) { m_hitsData[index] = word; } else { setUnpackErrorCode(UNPACK_SOURCE_ID); - return false; + return false; } } else { setUnpackErrorCode(UNPACK_DATA_ID); // New code diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/CmxJetSubBlock.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/CmxJetSubBlock.h index 0dbfe58d9668cadbe61e99514e0dde824d2ab96f..a3305f0f0401a4e9b2f601056eb41b1e664d7979 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/CmxJetSubBlock.h +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/CmxJetSubBlock.h @@ -22,138 +22,141 @@ namespace LVL1BS { class CmxJetSubBlock : public CmxSubBlock { - public: - enum SourceId { REMOTE_MAIN, LOCAL_MAIN, TOTAL_MAIN, - REMOTE_FORWARD, LOCAL_FORWARD, TOTAL_FORWARD, - TOPO_CHECKSUM, TOPO_OCCUPANCY_MAP, TOPO_OCCUPANCY_COUNTS, - MAX_SOURCE_ID }; - - CmxJetSubBlock(); - ~CmxJetSubBlock(); - - /// Clear all data - void clear(); - - /// Return presence map for given JEM - unsigned int presenceMap(int slice, int jem) const; - /// Return frame for given jem and tob - int frame(int slice, int jem, int tob) const; - /// Return Local coordinate for given jem and tob - int localCoord(int slice, int jem, int tob) const; - /// Return energy large window size for given jem and tob - int energyLarge(int slice, int jem, int tob) const; - /// Return energy small window size for given jem and tob - int energySmall(int slice, int jem, int tob) const; - /// Return error bit for given jem and tob - int tobError(int slice, int jem, int tob) const; - /// Return parity bits for given JEM - int parityBits(int slice, int jem) const; - /// Return hit/topo counts for given source ID and HL flag - unsigned int hits(int slice, int source, int flag) const; - /// Return hit error for given source ID and HL flag - int hitsError(int slice, int source, int flag) const; - - /// Store presence map - void setPresenceMap(int slice, int jem, unsigned int map); - /// Store TOB (RoI) data for given JEM, frame, local coord - void setTob(int slice, int jem, int frame, int loc, - int energyLarge, int energySmall, int error); - /// Store parity bits for neutral format - void setParityBits(int slice, int jem, int parity); - /// Store hit counts for given source ID and HL flag - void setHits(int slice, int source, int flag, unsigned int hits, int error); - - /// Pack data - bool pack(); - /// Unpack data - bool unpack(); - - private: - /// Data word length - static const int s_wordLength = 32; - // TOB bit positions and masks - static const int s_tobEnergyLgBit = 0; - static const int s_tobEnergySmBit = 10; - static const int s_tobErrorBit = 19; - static const int s_tobCoordBit = 20; - static const int s_tobFrameBit = 22; - static const int s_tobJemBit = 25; - static const int s_tobWordId = 0; - static const uint32_t s_tobEnergyLgMask = 0x3ff; - static const uint32_t s_tobEnergySmMask = 0x1ff; - static const uint32_t s_tobErrorMask = 0x1; - static const uint32_t s_tobCoordMask = 0x3; - static const uint32_t s_tobFrameMask = 0x7; - static const uint32_t s_tobJemMask = 0xf; - // Jet hit and topo counts bit positions and masks - static const int s_threshBit = 0; - static const int s_threshErrorBit = 16; - static const int s_hlFlagBit = 24; - static const int s_sourceIdBit = 25; - static const int s_dataWordIdBit = 29; - static const int s_threshWordId = 1; - static const uint32_t s_threshMainMask = 0x7fff; - static const uint32_t s_threshFwdLMask = 0xffff; - static const uint32_t s_threshFwdHMask = 0x3fff; - static const uint32_t s_errorMask = 0x7; // Includes RoI overflow - static const uint32_t s_topoCheckMask = 0xffff; - static const uint32_t s_topoMapMask = 0xffff; - static const uint32_t s_topoCountsMask = 0xffffff; - static const uint32_t s_hlFlagMask = 0x1; - static const uint32_t s_sourceIdMask = 0xf; - static const uint32_t s_dataWordIdMask = 0x7; - // Neutral format - static const int s_presenceBits = 8; - static const int s_coordBits = 2; - static const int s_energyLgBits = 10; - //static const int s_energySmBits[8] = {3,6,5,4,7,2,9,0}; - static const int s_energySmBits[8]; - static const int s_threshMainBits = 15; - static const int s_threshFwdLBits = 16; - static const int s_threshFwdHBits = 14; - static const int s_parityErrorBits = 1; - static const int s_roiOverflowBits = 1; - static const int s_paddingBits = 31; - static const int s_bunchCrossingBits = 12; - static const int s_fifoOverflowBits = 1; - static const int s_topoChecksumBits = 16; - static const int s_topoMapBits = 16; - static const int s_topoCountsBits = 24; - static const int s_topoPaddingBits = 3; - static const int s_glinkPins = 20; - static const int s_modules = 16; - static const int s_tobsPerModule = 4; - static const int s_muxPhases = 4; - - int dataWordId(uint32_t word) const; - int sourceId(uint32_t word) const; - int jem(uint32_t word) const; - int hlFlag(uint32_t word) const; - unsigned int mapIndex(int slice, int jem) const; - unsigned int parIndex(int slice, int jem) const; - unsigned int tobIndex(int slice, int jem, int tob) const; - unsigned int hitIndex(int slice, int source, int flag) const; - void resize(); - - /// Pack neutral data - bool packNeutral(); - /// Pack uncompressed data - bool packUncompressed(); - /// Unpack neutral data - bool unpackNeutral(); - /// Unpack uncompressed data - bool unpackUncompressed(); - - /// TOB data - std::vector<uint32_t> m_tobData; - /// Hits and topo data - std::vector<uint32_t> m_hitsData; - /// Presence maps - std::vector<unsigned int> m_presenceMaps; - /// Parity data for neutral format - std::vector<int> m_parityBits; - /// JEM TOB count vector for unpacking - std::vector<int> m_jemTobCount; +public: + enum SourceId { REMOTE_MAIN = 0, LOCAL_MAIN = 1, TOTAL_MAIN = 2, + REMOTE_FORWARD = 4, LOCAL_FORWARD = 5, TOTAL_FORWARD = 6, + TOPO_CHECKSUM = 8, TOPO_OCCUPANCY_MAP = 9, TOPO_OCCUPANCY_COUNTS = 10, + MAX_SOURCE_ID = 11 + }; + + CmxJetSubBlock(); + ~CmxJetSubBlock(); + + /// Clear all data + void clear(); + + /// Return presence map for given JEM + unsigned int presenceMap(int slice, int jem) const; + /// Return frame for given jem and tob + int frame(int slice, int jem, int tob) const; + /// Return Local coordinate for given jem and tob + int localCoord(int slice, int jem, int tob) const; + /// Return energy large window size for given jem and tob + int energyLarge(int slice, int jem, int tob) const; + /// Return energy small window size for given jem and tob + int energySmall(int slice, int jem, int tob) const; + /// Return error bit for given jem and tob + int tobError(int slice, int jem, int tob) const; + /// Return parity bits for given JEM + int parityBits(int slice, int jem) const; + /// Return hit/topo counts for given source ID and HL flag + unsigned int hits(int slice, int source, int flag) const; + /// Return hit error for given source ID and HL flag + int hitsError(int slice, int source, int flag) const; + + /// Store presence map + void setPresenceMap(int slice, int jem, unsigned int map); + /// Store TOB (RoI) data for given JEM, frame, local coord + void setTob(int slice, int jem, int frame, int loc, + int energyLarge, int energySmall, int error); + /// Store parity bits for neutral format + void setParityBits(int slice, int jem, int parity); + /// Store hit counts for given source ID and HL flag + void setHits(int slice, int source, int flag, unsigned int hits, int error); + + /// Pack data + bool pack(); + /// Unpack data + bool unpack(); + +private: + /// Data word length + static const int s_wordLength = 32; + // TOB bit positions and masks + static const int s_tobEnergyLgBit = 0; + static const int s_tobEnergySmBit = 10; + static const int s_tobErrorBit = 19; + static const int s_tobCoordBit = 20; + static const int s_tobFrameBit = 22; + static const int s_tobJemBit = 25; + static const int s_tobWordId = 0; + static const uint32_t s_tobEnergyLgMask = 0x3ff; + static const uint32_t s_tobEnergySmMask = 0x1ff; + static const uint32_t s_tobErrorMask = 0x1; + static const uint32_t s_tobCoordMask = 0x3; + static const uint32_t s_tobFrameMask = 0x7; + static const uint32_t s_tobJemMask = 0xf; + // Jet hit and topo counts bit positions and masks + static const int s_threshBit = 0; + static const int s_threshErrorBit = 16; + static const int s_threshHlFlagBit = 19; + static const int s_topoHlFlagBit = 24; + static const int s_hlFlagBit = 19; + static const int s_sourceIdBit = 25; + static const int s_dataWordIdBit = 29; + static const int s_threshWordId = 1; + static const uint32_t s_threshMainMask = 0x7fff; + static const uint32_t s_threshFwdLMask = 0xffff; + static const uint32_t s_threshFwdHMask = 0x3fff; + static const uint32_t s_errorMask = 0x7; // Includes RoI overflow + static const uint32_t s_topoCheckMask = 0xffff; + static const uint32_t s_topoMapMask = 0xffff; + static const uint32_t s_topoCountsMask = 0xffffff; + static const uint32_t s_hlFlagMask = 0x1; + static const uint32_t s_sourceIdMask = 0xf; + static const uint32_t s_dataWordIdMask = 0x7; + // Neutral format + static const int s_presenceBits = 8; + static const int s_coordBits = 2; + static const int s_energyLgBits = 10; + //static const int s_energySmBits[8] = {3,6,5,4,7,2,9,0}; + static const int s_energySmBits[8]; + static const int s_threshMainBits = 15; + static const int s_threshFwdLBits = 16; + static const int s_threshFwdHBits = 14; + static const int s_parityErrorBits = 1; + static const int s_roiOverflowBits = 1; + static const int s_paddingBits = 31; + static const int s_bunchCrossingBits = 12; + static const int s_fifoOverflowBits = 1; + static const int s_topoChecksumBits = 16; + static const int s_topoMapBits = 16; + static const int s_topoCountsBits = 24; + static const int s_topoPaddingBits = 3; + static const int s_glinkPins = 20; + static const int s_modules = 16; + static const int s_tobsPerModule = 4; + static const int s_muxPhases = 4; + + int dataWordId(uint32_t word) const; + int sourceId(uint32_t word) const; + int jem(uint32_t word) const; + int hlFlag(uint32_t word) const; + unsigned int mapIndex(int slice, int jem) const; + unsigned int parIndex(int slice, int jem) const; + unsigned int tobIndex(int slice, int jem, int tob) const; + unsigned int hitIndex(int slice, int source, int flag) const; + void resize(); + + /// Pack neutral data + bool packNeutral(); + /// Pack uncompressed data + bool packUncompressed(); + /// Unpack neutral data + bool unpackNeutral(); + /// Unpack uncompressed data + bool unpackUncompressed(); + + /// TOB data + std::vector<uint32_t> m_tobData; + /// Hits and topo data + std::vector<uint32_t> m_hitsData; + /// Presence maps + std::vector<unsigned int> m_presenceMaps; + /// Parity data for neutral format + std::vector<int> m_parityBits; + /// JEM TOB count vector for unpacking + std::vector<int> m_jemTobCount; }; @@ -174,9 +177,10 @@ inline int CmxJetSubBlock::jem(const uint32_t word) const inline int CmxJetSubBlock::hlFlag(const uint32_t word) const { - return (word >> s_hlFlagBit) & s_hlFlagMask; + uint8_t shift = (((word >> s_sourceIdBit) & s_sourceIdMask) < 7 ? s_threshHlFlagBit : s_topoHlFlagBit); + return (word >> shift) & s_hlFlagMask; } - +// ============================================================================ } // end namespace - +// ============================================================================ #endif diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamTool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamTool.cxx index a91f60534a3a92b7633ccde83108bd69011fe98c..39a3288281c14193f9aa5593d3567fa0cf7b7565 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamTool.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamTool.cxx @@ -313,7 +313,7 @@ StatusCode CpByteStreamTool::convert(const LVL1::CPBSCollection* const cp, // Pack and write the sub-blocks - DataVector<CpmSubBlock>::const_iterator pos; + DataVector<CpmSubBlock>::iterator pos; for (pos = m_cpmBlocks.begin(); pos != m_cpmBlocks.end(); ++pos) { CpmSubBlock* const subBlock = *pos; if ( !subBlock->pack()) { @@ -401,7 +401,7 @@ StatusCode CpByteStreamTool::convert(const LVL1::CPBSCollection* const cp, } } } - DataVector<CmmCpSubBlock>::const_iterator cos = m_cmmHit0Blocks.begin(); + DataVector<CmmCpSubBlock>::iterator cos = m_cmmHit0Blocks.begin(); for (; cos != m_cmmHit0Blocks.end(); ++cos) { CmmCpSubBlock* const subBlock = *cos; if ( !subBlock->pack()) { diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV1Tool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV1Tool.cxx index 39df3097db4387cfb101f2878765afadd37c6f08..cc4fbf6285d777964b4a4876ed853106b59a134d 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV1Tool.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV1Tool.cxx @@ -319,7 +319,7 @@ StatusCode CpByteStreamV1Tool::convert(const LVL1::CPBSCollectionV1* const cp, // Pack and write the sub-blocks - DataVector<CpmSubBlockV1>::const_iterator pos; + DataVector<CpmSubBlockV1>::iterator pos; for (pos = m_cpmBlocks.begin(); pos != m_cpmBlocks.end(); ++pos) { CpmSubBlockV1* const subBlock = *pos; if ( !subBlock->pack()) { @@ -407,7 +407,7 @@ StatusCode CpByteStreamV1Tool::convert(const LVL1::CPBSCollectionV1* const cp, } } } - DataVector<CmmCpSubBlock>::const_iterator cos = m_cmmHit0Blocks.begin(); + DataVector<CmmCpSubBlock>::iterator cos = m_cmmHit0Blocks.begin(); for (; cos != m_cmmHit0Blocks.end(); ++cos) { CmmCpSubBlock* const subBlock = *cos; if ( !subBlock->pack()) { diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV2Tool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV2Tool.cxx index 365231aec74fa58bbbdcfab6889280d025071d50..470051c41837fcef4d5cfbad8347f2b362ada1d8 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV2Tool.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV2Tool.cxx @@ -52,6 +52,7 @@ CpByteStreamV2Tool::CpByteStreamV2Tool(const std::string &type, : AthAlgTool(type, name, parent), m_cpmMaps("LVL1::CpmMappingTool/CpmMappingTool"), m_errorTool("LVL1BS::L1CaloErrorByteStreamTool/L1CaloErrorByteStreamTool"), + m_robDataProvider("ROBDataProviderSvc", name), m_channels(80), m_crates(4), m_modules(14), m_cmxs(2), m_maxTobs(5), m_chips(16), m_locs(4), m_coreOverlap(0), m_subDetector(eformat::TDAQ_CALO_CLUSTER_PROC_DAQ), @@ -109,28 +110,17 @@ StatusCode CpByteStreamV2Tool::initialize() msg(MSG::INFO) << "Initializing " << name() << " - package version " << PACKAGE_VERSION << endreq; - StatusCode sc = m_cpmMaps.retrieve(); - if (sc.isFailure()) - { - msg(MSG::ERROR) << "Failed to retrieve tool " << m_cpmMaps << endreq; - return sc; - } - else msg(MSG::INFO) << "Retrieved tool " << m_cpmMaps << endreq; - - sc = m_errorTool.retrieve(); - if (sc.isFailure()) - { - msg(MSG::ERROR) << "Failed to retrieve tool " << m_errorTool << endreq; - return sc; - } - else msg(MSG::INFO) << "Retrieved tool " << m_errorTool << endreq; - + CHECK(m_cpmMaps.retrieve()); + CHECK(m_errorTool.retrieve()); + CHECK(m_robDataProvider.retrieve()); + m_srcIdMap = new L1CaloSrcIdMap(); m_towerKey = new LVL1::TriggerTowerKey(); m_cpmSubBlock = new CpmSubBlockV2(); m_cmxCpSubBlock = new CmxCpSubBlock(); m_rodStatus = new std::vector<uint32_t>(2); m_fea = new FullEventAssembler<L1CaloSrcIdMap>(); + return StatusCode::SUCCESS; } @@ -148,6 +138,17 @@ StatusCode CpByteStreamV2Tool::finalize() } // Conversion bytestream to CPM towers +StatusCode CpByteStreamV2Tool::convert( + const std::string& sgKey, + DataVector<LVL1::CPMTower> *const ttCollection) +{ + const std::vector<uint32_t>& vID(sourceIDs(sgKey)); + // // get ROB fragments + IROBDataProviderSvc::VROBFRAG robFrags; + m_robDataProvider->getROBData(vID, robFrags, "CpByteStreamV2Tool"); + ATH_MSG_DEBUG("Number of ROB fragments:" << robFrags.size()); + return convert(robFrags, ttCollection); +} StatusCode CpByteStreamV2Tool::convert( const IROBDataProviderSvc::VROBFRAG &robFrags, @@ -159,6 +160,17 @@ StatusCode CpByteStreamV2Tool::convert( } // Conversion bytestream to CMX-CP TOBs +StatusCode CpByteStreamV2Tool::convert( + const std::string& sgKey, + DataVector<LVL1::CMXCPTob> *const tobCollection) +{ + const std::vector<uint32_t>& vID(sourceIDs(sgKey)); + // // get ROB fragments + IROBDataProviderSvc::VROBFRAG robFrags; + m_robDataProvider->getROBData(vID, robFrags, "CpByteStreamV2Tool"); + ATH_MSG_DEBUG("Number of ROB fragments:" << robFrags.size()); + return convert(robFrags, tobCollection); +} StatusCode CpByteStreamV2Tool::convert( const IROBDataProviderSvc::VROBFRAG &robFrags, @@ -170,6 +182,17 @@ StatusCode CpByteStreamV2Tool::convert( } // Conversion bytestream to CMX-CP hits +StatusCode CpByteStreamV2Tool::convert( + const std::string& sgKey, + DataVector<LVL1::CMXCPHits> *const hitCollection) +{ + const std::vector<uint32_t>& vID(sourceIDs(sgKey)); + // // get ROB fragments + IROBDataProviderSvc::VROBFRAG robFrags; + m_robDataProvider->getROBData(vID, robFrags, "CpByteStreamV2Tool"); + ATH_MSG_DEBUG("Number of ROB fragments:" << robFrags.size()); + return convert(robFrags, hitCollection); +} StatusCode CpByteStreamV2Tool::convert( const IROBDataProviderSvc::VROBFRAG &robFrags, @@ -336,7 +359,7 @@ StatusCode CpByteStreamV2Tool::convert(const LVL1::CPBSCollectionV2 *const cp, // Pack and write the sub-blocks - DataVector<CpmSubBlockV2>::const_iterator pos; + DataVector<CpmSubBlockV2>::iterator pos; for (pos = m_cpmBlocks.begin(); pos != m_cpmBlocks.end(); ++pos) { CpmSubBlockV2 *const subBlock = *pos; @@ -447,10 +470,8 @@ StatusCode CpByteStreamV2Tool::convert(const LVL1::CPBSCollectionV2 *const cp, } } } - DataVector<CmxCpSubBlock>::const_iterator cos = m_cmxBlocks.begin(); - for (; cos != m_cmxBlocks.end(); ++cos) + for (CmxCpSubBlock* subBlock : m_cmxBlocks) { - CmxCpSubBlock *const subBlock = *cos; if ( !subBlock->pack()) { msg(MSG::ERROR) << "CMX-Cp sub-block packing failed" << endreq; diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV2Tool.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV2Tool.h index 4ec2bb568c5b1f0de67ce79bbe74825d13d4eadd..30ece2c6aca9fb1af915bc65a219df2318663ad6 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV2Tool.h +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV2Tool.h @@ -14,7 +14,7 @@ #include "AthenaBaseComps/AthAlgTool.h" #include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" #include "ByteStreamData/RawEvent.h" -#include "DataModel/DataVector.h" +#include "AthContainers/DataVector.h" #include "eformat/SourceIdentifier.h" #include "GaudiKernel/ToolHandle.h" @@ -62,12 +62,17 @@ class CpByteStreamV2Tool : public AthAlgTool { virtual StatusCode finalize(); /// Convert ROB fragments to CPM towers + StatusCode convert(const std::string& sgKey, DataVector<LVL1::CPMTower>* ttCollection); StatusCode convert(const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::CPMTower>* ttCollection); /// Convert ROB fragments to CMX-CP TOBs + StatusCode convert(const std::string& sgKey, + DataVector<LVL1::CMXCPTob>* tobCollection); StatusCode convert(const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::CMXCPTob>* tobCollection); /// Convert ROB fragments to CMX-CP hits + StatusCode convert(const std::string& sgKey, + DataVector<LVL1::CMXCPHits>* hitCollection); StatusCode convert(const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::CMXCPHits>* hitCollection); @@ -127,7 +132,7 @@ class CpByteStreamV2Tool : public AthAlgTool { ToolHandle<LVL1::IL1CaloMappingTool> m_cpmMaps; /// Error collection tool ToolHandle<LVL1BS::L1CaloErrorByteStreamTool> m_errorTool; - + ServiceHandle<IROBDataProviderSvc> m_robDataProvider; /// Hardware crate number offset int m_crateOffsetHw; /// Software crate number offset @@ -222,7 +227,6 @@ class CpByteStreamV2Tool : public AthAlgTool { std::map<uint32_t, std::vector<uint32_t>* > m_rodStatusMap; /// Event assembler FullEventAssembler<L1CaloSrcIdMap>* m_fea; - }; } // end namespace diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/JemRoiSubBlockV2.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/JemRoiSubBlockV2.cxx index ed0f250d6adb06c1c093a4e0be398102f4f717a0..585efcffeda21fa2a0d0f262581be4a360296938 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/JemRoiSubBlockV2.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/JemRoiSubBlockV2.cxx @@ -42,7 +42,7 @@ void JemRoiSubBlockV2::clear() // Store header void JemRoiSubBlockV2::setRoiHeader(const int version, const int crate, - const int module) + const int module) { setHeader(s_wordIdVal, version, NEUTRAL, 0, crate, module, 0, 1); } @@ -74,17 +74,17 @@ bool JemRoiSubBlockV2::pack() { bool rc = false; switch (version()) { - case 1: //<< CHECK - switch (format()) { - case NEUTRAL: - rc = packNeutral(); - break; - default: - break; - } + case 1: //<< CHECK + switch (format()) { + case NEUTRAL: + rc = packNeutral(); break; default: break; + } + break; + default: + break; } return rc; } @@ -93,19 +93,19 @@ bool JemRoiSubBlockV2::unpack() { bool rc = false; switch (version()) { - case 2: //<< CHECK - switch (format()) { - case NEUTRAL: - rc = unpackNeutral(); - break; - default: - setUnpackErrorCode(UNPACK_FORMAT); - break; - } + case 2: //<< CHECK + switch (format()) { + case NEUTRAL: + rc = unpackNeutral(); break; default: - setUnpackErrorCode(UNPACK_VERSION); + setUnpackErrorCode(UNPACK_FORMAT); break; + } + break; + default: + setUnpackErrorCode(UNPACK_VERSION); + break; } return rc; } @@ -119,7 +119,7 @@ bool JemRoiSubBlockV2::packNeutral() // RoI data for (int frame = 0; frame < s_frames; ++frame) { const LVL1::JEMTobRoI& roi(m_roiData[frame]); - const int pin1 = frame/s_framesPerPin; + const int pin1 = frame / s_framesPerPin; const int pin2 = s_bunchCrossingPin + pin1 + 1; packerNeutral(pin1, roi.energyLarge(), s_energyLargeBits); packerNeutral(pin1, 0, 1); @@ -144,14 +144,14 @@ bool JemRoiSubBlockV2::unpackNeutral() int maxPin = 0; // RoI data for (int frame = 0; frame < s_frames; ++frame) { - const int pin1 = frame/s_framesPerPin; + const int pin1 = frame / s_framesPerPin; const int pin2 = s_bunchCrossingPin + pin1 + 1; const int enLarge = unpackerNeutral(pin1, s_energyLargeBits); - unpackerNeutral(pin1, 1); + unpackerNeutral(pin1, 1); const int enSmall = unpackerNeutral(pin2, s_energySmallBits); const int loc = unpackerNeutral(pin2, s_locationBits); m_roiData[frame] = LVL1::JEMTobRoI(crate(), module(), - frame, loc, enLarge, enSmall); + frame, loc, enLarge, enSmall); maxPin = pin2; } // Bunch Crossing number diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamTool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamTool.cxx index d25542f6b8bbbae0965a085d01e9a10e73cb759a..094af14d8ec3188e89c88183ad6adfba36d2a9d0 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamTool.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamTool.cxx @@ -51,7 +51,7 @@ const InterfaceID& JepByteStreamTool::interfaceID() JepByteStreamTool::JepByteStreamTool(const std::string& type, const std::string& name, - const IInterface* parent) + const IInterface* parent) : AthAlgTool(type, name, parent), m_jemMaps("LVL1::JemMappingTool/JemMappingTool"), m_errorTool("LVL1BS::L1CaloErrorByteStreamTool/L1CaloErrorByteStreamTool"), @@ -145,8 +145,8 @@ StatusCode JepByteStreamTool::finalize() // Conversion bytestream to jet elements StatusCode JepByteStreamTool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - DataVector<LVL1::JetElement>* const jeCollection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + DataVector<LVL1::JetElement>* const jeCollection) { m_jeCollection = jeCollection; m_jeMap.clear(); @@ -156,8 +156,8 @@ StatusCode JepByteStreamTool::convert( // Conversion bytestream to jet hits StatusCode JepByteStreamTool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - DataVector<LVL1::JEMHits>* const hitCollection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + DataVector<LVL1::JEMHits>* const hitCollection) { m_hitCollection = hitCollection; m_hitsMap.clear(); @@ -167,8 +167,8 @@ StatusCode JepByteStreamTool::convert( // Conversion bytestream to energy sums StatusCode JepByteStreamTool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - DataVector<LVL1::JEMEtSums>* const etCollection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + DataVector<LVL1::JEMEtSums>* const etCollection) { m_etCollection = etCollection; m_etMap.clear(); @@ -178,8 +178,8 @@ StatusCode JepByteStreamTool::convert( // Conversion bytestream to CMM hits StatusCode JepByteStreamTool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - DataVector<LVL1::CMMJetHits>* const hitCollection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + DataVector<LVL1::CMMJetHits>* const hitCollection) { m_cmmHitCollection = hitCollection; m_cmmHitsMap.clear(); @@ -189,8 +189,8 @@ StatusCode JepByteStreamTool::convert( // Conversion bytestream to CMM energy sums StatusCode JepByteStreamTool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - DataVector<LVL1::CMMEtSums>* const etCollection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + DataVector<LVL1::CMMEtSums>* const etCollection) { m_cmmEtCollection = etCollection; m_cmmEtMap.clear(); @@ -200,7 +200,7 @@ StatusCode JepByteStreamTool::convert( // Conversion of JEP container to bytestream StatusCode JepByteStreamTool::convert(const LVL1::JEPBSCollection* const jep, - RawEventWrite* const re) + RawEventWrite* const re) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -232,47 +232,47 @@ StatusCode JepByteStreamTool::convert(const LVL1::JEPBSCollection* const jep, int trigJem = 0; int timeslicesNew = 1; int trigJemNew = 0; - for (int crate=0; crate < m_crates; ++crate) { + for (int crate = 0; crate < m_crates; ++crate) { const int hwCrate = crate + m_crateOffsetHw; - for (int module=0; module < m_modules; ++module) { + for (int module = 0; module < m_modules; ++module) { // Pack required number of modules per slink - if (module%modulesPerSlink == 0) { - const int daqOrRoi = 0; - const int slink = module/modulesPerSlink; + if (module % modulesPerSlink == 0) { + const int daqOrRoi = 0; + const int slink = module / modulesPerSlink; if (debug) { msg() << "Treating crate " << hwCrate << " slink " << slink << endreq; } - // Get number of JEM slices and triggered slice offset - // for this slink - if ( ! slinkSlices(crate, module, modulesPerSlink, - timeslices, trigJem)) { - msg(MSG::ERROR) << "Inconsistent number of slices or " - << "triggered slice offsets in data for crate " - << hwCrate << " slink " << slink << endreq; - return StatusCode::FAILURE; + // Get number of JEM slices and triggered slice offset + // for this slink + if ( ! slinkSlices(crate, module, modulesPerSlink, + timeslices, trigJem)) { + msg(MSG::ERROR) << "Inconsistent number of slices or " + << "triggered slice offsets in data for crate " + << hwCrate << " slink " << slink << endreq; + return StatusCode::FAILURE; } - timeslicesNew = (m_forceSlices) ? m_forceSlices : timeslices; - trigJemNew = ModifySlices::peak(trigJem, timeslices, timeslicesNew); + timeslicesNew = (m_forceSlices) ? m_forceSlices : timeslices; + trigJemNew = ModifySlices::peak(trigJem, timeslices, timeslicesNew); if (debug) { - msg() << "Data Version/Format: " << m_version - << " " << m_dataFormat << endreq + msg() << "Data Version/Format: " << m_version + << " " << m_dataFormat << endreq << "Slices/offset: " << timeslices << " " << trigJem; - if (timeslices != timeslicesNew) { - msg() << " modified to " << timeslicesNew << " " << trigJemNew; + if (timeslices != timeslicesNew) { + msg() << " modified to " << timeslicesNew << " " << trigJemNew; } - msg() << endreq; + msg() << endreq; } L1CaloUserHeader userHeader; userHeader.setJem(trigJemNew); - const uint32_t rodIdJem = m_srcIdMap->getRodID(hwCrate, slink, daqOrRoi, - m_subDetector); - theROD = m_fea->getRodData(rodIdJem); - theROD->push_back(userHeader.header()); - m_rodStatusMap.insert(make_pair(rodIdJem, m_rodStatus)); + const uint32_t rodIdJem = m_srcIdMap->getRodID(hwCrate, slink, daqOrRoi, + m_subDetector); + theROD = m_fea->getRodData(rodIdJem); + theROD->push_back(userHeader.header()); + m_rodStatusMap.insert(make_pair(rodIdJem, m_rodStatus)); } if (debug) msg() << "Module " << module << endreq; @@ -281,42 +281,42 @@ StatusCode JepByteStreamTool::convert(const LVL1::JEPBSCollection* const jep, m_jemBlocks.clear(); for (int slice = 0; slice < timeslicesNew; ++slice) { JemSubBlock* const subBlock = new JemSubBlock(); - subBlock->setJemHeader(m_version, m_dataFormat, slice, - hwCrate, module, timeslicesNew); + subBlock->setJemHeader(m_version, m_dataFormat, slice, + hwCrate, module, timeslicesNew); m_jemBlocks.push_back(subBlock); - if (neutralFormat) break; + if (neutralFormat) break; } // Find jet elements corresponding to each eta/phi pair and fill // sub-blocks - for (int chan=0; chan < m_channels; ++chan) { - double eta = 0.; - double phi = 0.; - int layer = 0; - if (m_jemMaps->mapping(crate, module, chan, eta, phi, layer)) { + for (int chan = 0; chan < m_channels; ++chan) { + double eta = 0.; + double phi = 0.; + int layer = 0; + if (m_jemMaps->mapping(crate, module, chan, eta, phi, layer)) { const LVL1::JetElement* const je = findJetElement(eta, phi); - if (je ) { - std::vector<int> emData; - std::vector<int> hadData; - std::vector<int> emErrors; - std::vector<int> hadErrors; - ModifySlices::data(je->emEnergyVec(), emData, timeslicesNew); - ModifySlices::data(je->hadEnergyVec(), hadData, timeslicesNew); - ModifySlices::data(je->emErrorVec(), emErrors, timeslicesNew); - ModifySlices::data(je->hadErrorVec(), hadErrors, timeslicesNew); + if (je ) { + std::vector<int> emData; + std::vector<int> hadData; + std::vector<int> emErrors; + std::vector<int> hadErrors; + ModifySlices::data(je->emEnergyVec(), emData, timeslicesNew); + ModifySlices::data(je->hadEnergyVec(), hadData, timeslicesNew); + ModifySlices::data(je->emErrorVec(), emErrors, timeslicesNew); + ModifySlices::data(je->hadErrorVec(), hadErrors, timeslicesNew); for (int slice = 0; slice < timeslicesNew; ++slice) { - const LVL1::DataError emErrBits(emErrors[slice]); - const LVL1::DataError hadErrBits(hadErrors[slice]); - const int index = ( neutralFormat ) ? 0 : slice; + const LVL1::DataError emErrBits(emErrors[slice]); + const LVL1::DataError hadErrBits(hadErrors[slice]); + const int index = ( neutralFormat ) ? 0 : slice; JemSubBlock* const subBlock = m_jemBlocks[index]; - const JemJetElement jetEle(chan, emData[slice], hadData[slice], - emErrBits.get(LVL1::DataError::Parity), - hadErrBits.get(LVL1::DataError::Parity), - emErrBits.get(LVL1::DataError::LinkDown) + - (hadErrBits.get(LVL1::DataError::LinkDown) << 1)); + const JemJetElement jetEle(chan, emData[slice], hadData[slice], + emErrBits.get(LVL1::DataError::Parity), + hadErrBits.get(LVL1::DataError::Parity), + emErrBits.get(LVL1::DataError::LinkDown) + + (hadErrBits.get(LVL1::DataError::LinkDown) << 1)); subBlock->fillJetElement(slice, jetEle); - } + } } } } @@ -326,11 +326,11 @@ StatusCode JepByteStreamTool::convert(const LVL1::JEPBSCollection* const jep, const LVL1::JEMHits* const hits = findJetHits(crate, module); if (hits) { std::vector<unsigned int> vec; - ModifySlices::data(hits->JetHitsVec(), vec, timeslicesNew); + ModifySlices::data(hits->JetHitsVec(), vec, timeslicesNew); for (int slice = 0; slice < timeslicesNew; ++slice) { - const int index = ( neutralFormat ) ? 0 : slice; - JemSubBlock* const subBlock = m_jemBlocks[index]; - subBlock->setJetHits(slice, vec[slice]); + const int index = ( neutralFormat ) ? 0 : slice; + JemSubBlock* const subBlock = m_jemBlocks[index]; + subBlock->setJetHits(slice, vec[slice]); } } const LVL1::JEMEtSums* const et = findEnergySums(crate, module); @@ -338,31 +338,31 @@ StatusCode JepByteStreamTool::convert(const LVL1::JEPBSCollection* const jep, std::vector<unsigned int> exVec; std::vector<unsigned int> eyVec; std::vector<unsigned int> etVec; - ModifySlices::data(et->ExVec(), exVec, timeslicesNew); - ModifySlices::data(et->EyVec(), eyVec, timeslicesNew); - ModifySlices::data(et->EtVec(), etVec, timeslicesNew); - for (int slice = 0; slice < timeslicesNew; ++slice) { - const int index = ( neutralFormat ) ? 0 : slice; - JemSubBlock* const subBlock = m_jemBlocks[index]; - subBlock->setEnergySubsums(slice, exVec[slice], eyVec[slice], - etVec[slice]); + ModifySlices::data(et->ExVec(), exVec, timeslicesNew); + ModifySlices::data(et->EyVec(), eyVec, timeslicesNew); + ModifySlices::data(et->EtVec(), etVec, timeslicesNew); + for (int slice = 0; slice < timeslicesNew; ++slice) { + const int index = ( neutralFormat ) ? 0 : slice; + JemSubBlock* const subBlock = m_jemBlocks[index]; + subBlock->setEnergySubsums(slice, exVec[slice], eyVec[slice], + etVec[slice]); } } - + // Pack and write the sub-blocks - DataVector<JemSubBlock>::const_iterator pos; + DataVector<JemSubBlock>::iterator pos; for (pos = m_jemBlocks.begin(); pos != m_jemBlocks.end(); ++pos) { JemSubBlock* const subBlock = *pos; - if ( !subBlock->pack()) { - msg(MSG::ERROR) << "JEM sub-block packing failed" << endreq; - return StatusCode::FAILURE; - } - if (debug) { - msg() << "JEM sub-block data words: " - << subBlock->dataWords() << endreq; - } - subBlock->write(theROD); + if ( !subBlock->pack()) { + msg(MSG::ERROR) << "JEM sub-block packing failed" << endreq; + return StatusCode::FAILURE; + } + if (debug) { + msg() << "JEM sub-block data words: " + << subBlock->dataWords() << endreq; + } + subBlock->write(theROD); } } @@ -373,18 +373,18 @@ StatusCode JepByteStreamTool::convert(const LVL1::JEPBSCollection* const jep, m_cmmEnergyBlocks.clear(); m_cmmJetBlocks.clear(); const int summing = (crate == m_crates - 1) ? CmmSubBlock::SYSTEM - : CmmSubBlock::CRATE; + : CmmSubBlock::CRATE; for (int slice = 0; slice < timeslicesNew; ++slice) { CmmEnergySubBlock* const enBlock = new CmmEnergySubBlock(); const int cmmEnergyVersion = 2; // with Missing-ET-Sig enBlock->setCmmHeader(cmmEnergyVersion, m_dataFormat, slice, hwCrate, summing, CmmSubBlock::CMM_ENERGY, - CmmSubBlock::LEFT, timeslicesNew); + CmmSubBlock::LEFT, timeslicesNew); m_cmmEnergyBlocks.push_back(enBlock); CmmJetSubBlock* const jetBlock = new CmmJetSubBlock(); jetBlock->setCmmHeader(m_version, m_dataFormat, slice, hwCrate, summing, CmmSubBlock::CMM_JET, - CmmSubBlock::RIGHT, timeslicesNew); + CmmSubBlock::RIGHT, timeslicesNew); m_cmmJetBlocks.push_back(jetBlock); if (neutralFormat) break; } @@ -395,24 +395,27 @@ StatusCode JepByteStreamTool::convert(const LVL1::JEPBSCollection* const jep, for (int dataID = 0; dataID < maxDataID; ++dataID) { int source = dataID; if (dataID >= m_modules) { - if (summing == CmmSubBlock::CRATE && - dataID != LVL1::CMMEtSums::LOCAL) continue; - switch (dataID) { - case LVL1::CMMEtSums::LOCAL: - source = CmmEnergySubBlock::LOCAL; - break; - case LVL1::CMMEtSums::REMOTE: - source = CmmEnergySubBlock::REMOTE; - break; - case LVL1::CMMEtSums::TOTAL: - source = CmmEnergySubBlock::TOTAL; - break; - case LVL1::CMMEtSums::MISSING_ET_MAP: - case LVL1::CMMEtSums::SUM_ET_MAP: - case LVL1::CMMEtSums::MISSING_ET_SIG_MAP: - break; - default: - continue; + if (summing == CmmSubBlock::CRATE && + dataID != LVL1::CMMEtSums::LOCAL) continue; + // coverity[mixed_enums : FALSE] + // coverity[switch_on_enum : FALSE] + // coverity[first_enum_type : FALSE] + switch (dataID) { + case LVL1::CMMEtSums::LOCAL: + source = CmmEnergySubBlock::LOCAL; + break; + case LVL1::CMMEtSums::REMOTE: + source = CmmEnergySubBlock::REMOTE; + break; + case LVL1::CMMEtSums::TOTAL: + source = CmmEnergySubBlock::TOTAL; + break; + case LVL1::CMMEtSums::MISSING_ET_MAP: + case LVL1::CMMEtSums::SUM_ET_MAP: + case LVL1::CMMEtSums::MISSING_ET_SIG_MAP: + break; + default: + continue; } } const LVL1::CMMEtSums* const sums = findCmmSums(crate, dataID); @@ -423,53 +426,53 @@ StatusCode JepByteStreamTool::convert(const LVL1::JEPBSCollection* const jep, std::vector<int> exErr; std::vector<int> eyErr; std::vector<int> etErr; - ModifySlices::data(sums->ExVec(), ex, timeslicesNew); - ModifySlices::data(sums->EyVec(), ey, timeslicesNew); - ModifySlices::data(sums->EtVec(), et, timeslicesNew); - ModifySlices::data(sums->ExErrorVec(), exErr, timeslicesNew); - ModifySlices::data(sums->EyErrorVec(), eyErr, timeslicesNew); - ModifySlices::data(sums->EtErrorVec(), etErr, timeslicesNew); - for (int slice = 0; slice < timeslicesNew; ++slice) { - const LVL1::DataError exErrBits(exErr[slice]); - const LVL1::DataError eyErrBits(eyErr[slice]); - const LVL1::DataError etErrBits(etErr[slice]); - int exError = exErrBits.get(LVL1::DataError::Parity); - int eyError = eyErrBits.get(LVL1::DataError::Parity); - int etError = etErrBits.get(LVL1::DataError::Parity); - if (dataID == LVL1::CMMEtSums::LOCAL || - dataID == LVL1::CMMEtSums::REMOTE || - dataID == LVL1::CMMEtSums::TOTAL) { - exError = (exError << 1) + exErrBits.get(LVL1::DataError::Overflow); - eyError = (eyError << 1) + eyErrBits.get(LVL1::DataError::Overflow); - etError = (etError << 1) + etErrBits.get(LVL1::DataError::Overflow); - } - const int index = ( neutralFormat ) ? 0 : slice; - CmmEnergySubBlock* const subBlock = m_cmmEnergyBlocks[index]; - if (dataID == LVL1::CMMEtSums::MISSING_ET_MAP) { - subBlock->setMissingEtHits(slice, et[slice]); + ModifySlices::data(sums->ExVec(), ex, timeslicesNew); + ModifySlices::data(sums->EyVec(), ey, timeslicesNew); + ModifySlices::data(sums->EtVec(), et, timeslicesNew); + ModifySlices::data(sums->ExErrorVec(), exErr, timeslicesNew); + ModifySlices::data(sums->EyErrorVec(), eyErr, timeslicesNew); + ModifySlices::data(sums->EtErrorVec(), etErr, timeslicesNew); + for (int slice = 0; slice < timeslicesNew; ++slice) { + const LVL1::DataError exErrBits(exErr[slice]); + const LVL1::DataError eyErrBits(eyErr[slice]); + const LVL1::DataError etErrBits(etErr[slice]); + int exError = exErrBits.get(LVL1::DataError::Parity); + int eyError = eyErrBits.get(LVL1::DataError::Parity); + int etError = etErrBits.get(LVL1::DataError::Parity); + if (dataID == LVL1::CMMEtSums::LOCAL || + dataID == LVL1::CMMEtSums::REMOTE || + dataID == LVL1::CMMEtSums::TOTAL) { + exError = (exError << 1) + exErrBits.get(LVL1::DataError::Overflow); + eyError = (eyError << 1) + eyErrBits.get(LVL1::DataError::Overflow); + etError = (etError << 1) + etErrBits.get(LVL1::DataError::Overflow); + } + const int index = ( neutralFormat ) ? 0 : slice; + CmmEnergySubBlock* const subBlock = m_cmmEnergyBlocks[index]; + if (dataID == LVL1::CMMEtSums::MISSING_ET_MAP) { + subBlock->setMissingEtHits(slice, et[slice]); } else if (dataID == LVL1::CMMEtSums::SUM_ET_MAP) { - subBlock->setSumEtHits(slice, et[slice]); - } else if (dataID == LVL1::CMMEtSums::MISSING_ET_SIG_MAP) { - subBlock->setMissingEtSigHits(slice, et[slice]); + subBlock->setSumEtHits(slice, et[slice]); + } else if (dataID == LVL1::CMMEtSums::MISSING_ET_SIG_MAP) { + subBlock->setMissingEtSigHits(slice, et[slice]); } else { - subBlock->setSubsums(slice, source, - ex[slice], ey[slice], et[slice], - exError, eyError, etError); + subBlock->setSubsums(slice, source, + ex[slice], ey[slice], et[slice], + exError, eyError, etError); } } } } - DataVector<CmmEnergySubBlock>::const_iterator pos; + DataVector<CmmEnergySubBlock>::iterator pos; pos = m_cmmEnergyBlocks.begin(); for (; pos != m_cmmEnergyBlocks.end(); ++pos) { CmmEnergySubBlock* const subBlock = *pos; if ( !subBlock->pack()) { msg(MSG::ERROR) << "CMM-Energy sub-block packing failed" << endreq; - return StatusCode::FAILURE; + return StatusCode::FAILURE; } if (debug) { - msg() << "CMM-Energy sub-block data words: " - << subBlock->dataWords() << endreq; + msg() << "CMM-Energy sub-block data words: " + << subBlock->dataWords() << endreq; } subBlock->write(theROD); } @@ -480,64 +483,64 @@ StatusCode JepByteStreamTool::convert(const LVL1::JEPBSCollection* const jep, for (int dataID = 0; dataID < maxDataID; ++dataID) { int source = dataID; if (dataID >= m_modules) { - if (summing == CmmSubBlock::CRATE && - dataID != LVL1::CMMJetHits::LOCAL_MAIN && - dataID != LVL1::CMMJetHits::LOCAL_FORWARD) continue; - switch (dataID) { - case LVL1::CMMJetHits::LOCAL_MAIN: - source = CmmJetSubBlock::LOCAL_MAIN; - break; - case LVL1::CMMJetHits::REMOTE_MAIN: - source = CmmJetSubBlock::REMOTE_MAIN; - break; - case LVL1::CMMJetHits::TOTAL_MAIN: - source = CmmJetSubBlock::TOTAL_MAIN; - break; - case LVL1::CMMJetHits::LOCAL_FORWARD: - source = CmmJetSubBlock::LOCAL_FORWARD; - break; - case LVL1::CMMJetHits::REMOTE_FORWARD: - source = CmmJetSubBlock::REMOTE_FORWARD; - break; - case LVL1::CMMJetHits::TOTAL_FORWARD: - source = CmmJetSubBlock::TOTAL_FORWARD; - break; - case LVL1::CMMJetHits::ET_MAP: - break; - default: - continue; + if (summing == CmmSubBlock::CRATE && + dataID != LVL1::CMMJetHits::LOCAL_MAIN && + dataID != LVL1::CMMJetHits::LOCAL_FORWARD) continue; + switch (dataID) { + case LVL1::CMMJetHits::LOCAL_MAIN: + source = CmmJetSubBlock::LOCAL_MAIN; + break; + case LVL1::CMMJetHits::REMOTE_MAIN: + source = CmmJetSubBlock::REMOTE_MAIN; + break; + case LVL1::CMMJetHits::TOTAL_MAIN: + source = CmmJetSubBlock::TOTAL_MAIN; + break; + case LVL1::CMMJetHits::LOCAL_FORWARD: + source = CmmJetSubBlock::LOCAL_FORWARD; + break; + case LVL1::CMMJetHits::REMOTE_FORWARD: + source = CmmJetSubBlock::REMOTE_FORWARD; + break; + case LVL1::CMMJetHits::TOTAL_FORWARD: + source = CmmJetSubBlock::TOTAL_FORWARD; + break; + case LVL1::CMMJetHits::ET_MAP: + break; + default: + continue; } } const LVL1::CMMJetHits* const ch = findCmmHits(crate, dataID); if ( ch ) { std::vector<unsigned int> hits; std::vector<int> errs; - ModifySlices::data(ch->HitsVec(), hits, timeslicesNew); - ModifySlices::data(ch->ErrorVec(), errs, timeslicesNew); - for (int slice = 0; slice < timeslicesNew; ++slice) { - const LVL1::DataError errBits(errs[slice]); - const int index = ( neutralFormat ) ? 0 : slice; - CmmJetSubBlock* const subBlock = m_cmmJetBlocks[index]; - if (dataID == LVL1::CMMJetHits::ET_MAP) { - subBlock->setJetEtMap(slice, hits[slice]); + ModifySlices::data(ch->HitsVec(), hits, timeslicesNew); + ModifySlices::data(ch->ErrorVec(), errs, timeslicesNew); + for (int slice = 0; slice < timeslicesNew; ++slice) { + const LVL1::DataError errBits(errs[slice]); + const int index = ( neutralFormat ) ? 0 : slice; + CmmJetSubBlock* const subBlock = m_cmmJetBlocks[index]; + if (dataID == LVL1::CMMJetHits::ET_MAP) { + subBlock->setJetEtMap(slice, hits[slice]); } else { - subBlock->setJetHits(slice, source, hits[slice], - errBits.get(LVL1::DataError::Parity)); + subBlock->setJetHits(slice, source, hits[slice], + errBits.get(LVL1::DataError::Parity)); } } } } - DataVector<CmmJetSubBlock>::const_iterator jos; + DataVector<CmmJetSubBlock>::iterator jos; jos = m_cmmJetBlocks.begin(); for (; jos != m_cmmJetBlocks.end(); ++jos) { CmmJetSubBlock* const subBlock = *jos; if ( !subBlock->pack()) { msg(MSG::ERROR) << "CMM-Jet sub-block packing failed" << endreq; - return StatusCode::FAILURE; + return StatusCode::FAILURE; } if (debug) { - msg() << "CMM-Jet sub-block data words: " - << subBlock->dataWords() << endreq; + msg() << "CMM-Jet sub-block data words: " + << subBlock->dataWords() << endreq; } subBlock->write(theROD); } @@ -557,13 +560,13 @@ StatusCode JepByteStreamTool::convert(const LVL1::JEPBSCollection* const jep, // Return reference to vector with all possible Source Identifiers const std::vector<uint32_t>& JepByteStreamTool::sourceIDs( - const std::string& sgKey) + const std::string& sgKey) { // Check if overlap jet element channels wanted const std::string flag("Overlap"); const std::string::size_type pos = sgKey.find(flag); m_coreOverlap = - (pos == std::string::npos || pos != sgKey.length() - flag.length()) ? 0 : 1; + (pos == std::string::npos || pos != sgKey.length() - flag.length()) ? 0 : 1; if (m_sourceIDs.empty()) { const int maxCrates = m_crates + m_crateOffsetHw; @@ -572,7 +575,7 @@ const std::vector<uint32_t>& JepByteStreamTool::sourceIDs( for (int slink = 0; slink < maxSlinks; ++slink) { const int daqOrRoi = 0; const uint32_t rodId = m_srcIdMap->getRodID(hwCrate, slink, daqOrRoi, - m_subDetector); + m_subDetector); const uint32_t robId = m_srcIdMap->getRobID(rodId); m_sourceIDs.push_back(robId); } @@ -584,8 +587,8 @@ const std::vector<uint32_t>& JepByteStreamTool::sourceIDs( // Convert bytestream to given container type StatusCode JepByteStreamTool::convertBs( - const IROBDataProviderSvc::VROBFRAG& robFrags, - const CollectionType collection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + const CollectionType collection) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -611,8 +614,8 @@ StatusCode JepByteStreamTool::convertBs( (*rob)->status(robData); if (*robData != 0) { m_errorTool->robError(robid, *robData); - if (debug) msg() << "ROB status error - skipping fragment" << endreq; - continue; + if (debug) msg() << "ROB status error - skipping fragment" << endreq; + continue; } } @@ -641,21 +644,21 @@ StatusCode JepByteStreamTool::convertBs( const uint32_t sourceID = (*rob)->rod_source_id(); if (m_srcIdMap->getRobID(sourceID) != robid || m_srcIdMap->subDet(sourceID) != m_subDetector || - m_srcIdMap->daqOrRoi(sourceID) != 0 || - m_srcIdMap->slink(sourceID) >= m_slinks || - m_srcIdMap->crate(sourceID) < m_crateOffsetHw || - m_srcIdMap->crate(sourceID) >= m_crateOffsetHw + m_crates) { + m_srcIdMap->daqOrRoi(sourceID) != 0 || + m_srcIdMap->slink(sourceID) >= m_slinks || + m_srcIdMap->crate(sourceID) < m_crateOffsetHw || + m_srcIdMap->crate(sourceID) >= m_crateOffsetHw + m_crates) { m_errorTool->rodError(robid, L1CaloSubBlock::ERROR_ROD_ID); if (debug) { msg() << "Wrong source identifier in data: ROD " << MSG::hex << sourceID << " ROB " << robid - << MSG::dec << endreq; + << MSG::dec << endreq; } continue; } const int rodCrate = m_srcIdMap->crate(sourceID); if (debug) { - msg() << "Treating crate " << rodCrate + msg() << "Treating crate " << rodCrate << " slink " << m_srcIdMap->slink(sourceID) << endreq; } @@ -672,7 +675,7 @@ StatusCode JepByteStreamTool::convertBs( if (headerWords != 1) { m_errorTool->rodError(robid, L1CaloSubBlock::ERROR_USER_HEADER); if (debug) msg() << "Unexpected number of user header words: " - << headerWords << endreq; + << headerWords << endreq; continue; } for (int i = 0; i < headerWords; ++i) ++payload; @@ -696,73 +699,73 @@ StatusCode JepByteStreamTool::convertBs( m_rodErr = L1CaloSubBlock::ERROR_NONE; while (payload != payloadEnd) { - + if (L1CaloSubBlock::wordType(*payload) != L1CaloSubBlock::HEADER) { if (debug) msg() << "Unexpected data sequence" << endreq; - m_rodErr = L1CaloSubBlock::ERROR_MISSING_HEADER; - break; + m_rodErr = L1CaloSubBlock::ERROR_MISSING_HEADER; + break; } if (CmmSubBlock::cmmBlock(*payload)) { // CMMs - if (CmmSubBlock::cmmType(*payload) == CmmSubBlock::CMM_JET) { - m_cmmJetSubBlock->clear(); + if (CmmSubBlock::cmmType(*payload) == CmmSubBlock::CMM_JET) { + m_cmmJetSubBlock->clear(); payload = m_cmmJetSubBlock->read(payload, payloadEnd); - if (m_cmmJetSubBlock->crate() != rodCrate) { - if (debug) msg() << "Inconsistent crate number in ROD source ID" - << endreq; - m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; - break; + if (m_cmmJetSubBlock->crate() != rodCrate) { + if (debug) msg() << "Inconsistent crate number in ROD source ID" + << endreq; + m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; + break; } - if (collection == CMM_HITS) { - decodeCmmJet(m_cmmJetSubBlock, trigCmm); - if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { - if (debug) msg() << "decodeCmmJet failed" << endreq; - break; - } + if (collection == CMM_HITS) { + decodeCmmJet(m_cmmJetSubBlock, trigCmm); + if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { + if (debug) msg() << "decodeCmmJet failed" << endreq; + break; + } } } else if (CmmSubBlock::cmmType(*payload) == CmmSubBlock::CMM_ENERGY) { - m_cmmEnergySubBlock->clear(); - payload = m_cmmEnergySubBlock->read(payload, payloadEnd); - if (m_cmmEnergySubBlock->crate() != rodCrate) { - if (debug) msg() << "Inconsistent crate number in ROD source ID" - << endreq; - m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; - break; + m_cmmEnergySubBlock->clear(); + payload = m_cmmEnergySubBlock->read(payload, payloadEnd); + if (m_cmmEnergySubBlock->crate() != rodCrate) { + if (debug) msg() << "Inconsistent crate number in ROD source ID" + << endreq; + m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; + break; } - if (collection == CMM_SUMS) { - decodeCmmEnergy(m_cmmEnergySubBlock, trigCmm); - if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { - if (debug) msg() << "decodeCmmEnergy failed" << endreq; - break; - } + if (collection == CMM_SUMS) { + decodeCmmEnergy(m_cmmEnergySubBlock, trigCmm); + if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { + if (debug) msg() << "decodeCmmEnergy failed" << endreq; + break; + } } - } else { - if (debug) msg() << "Invalid CMM type in module field" << endreq; - m_rodErr = L1CaloSubBlock::ERROR_MODULE_NUMBER; - break; + } else { + if (debug) msg() << "Invalid CMM type in module field" << endreq; + m_rodErr = L1CaloSubBlock::ERROR_MODULE_NUMBER; + break; } } else { // JEM - m_jemSubBlock->clear(); + m_jemSubBlock->clear(); payload = m_jemSubBlock->read(payload, payloadEnd); - if (m_jemSubBlock->crate() != rodCrate) { - if (debug) msg() << "Inconsistent crate number in ROD source ID" - << endreq; - m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; - break; + if (m_jemSubBlock->crate() != rodCrate) { + if (debug) msg() << "Inconsistent crate number in ROD source ID" + << endreq; + m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; + break; } - if (collection == JET_ELEMENTS || collection == JET_HITS || - collection == ENERGY_SUMS) { - decodeJem(m_jemSubBlock, trigJem, collection); - if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { - if (debug) msg() << "decodeJem failed" << endreq; - break; - } + if (collection == JET_ELEMENTS || collection == JET_HITS || + collection == ENERGY_SUMS) { + decodeJem(m_jemSubBlock, trigJem, collection); + if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { + if (debug) msg() << "decodeJem failed" << endreq; + break; + } } } } if (m_rodErr != L1CaloSubBlock::ERROR_NONE) - m_errorTool->rodError(robid, m_rodErr); + m_errorTool->rodError(robid, m_rodErr); } return StatusCode::SUCCESS; @@ -771,7 +774,7 @@ StatusCode JepByteStreamTool::convertBs( // Unpack CMM-Energy sub-block void JepByteStreamTool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, - int trigCmm) + int trigCmm) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -785,21 +788,21 @@ void JepByteStreamTool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, if (debug) { msg() << "CMM-Energy: Crate " << hwCrate << " Module " << module - << " Firmware " << firmware - << " Summing " << summing + << " Firmware " << firmware + << " Summing " << summing << " Total slices " << timeslices << " Slice " << sliceNum << endreq; } if (timeslices <= trigCmm) { if (debug) msg() << "Triggered CMM slice from header " - << "inconsistent with number of slices: " - << trigCmm << ", " << timeslices << endreq; + << "inconsistent with number of slices: " + << trigCmm << ", " << timeslices << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; return; } if (timeslices <= sliceNum) { if (debug) msg() << "Total slices inconsistent with slice number: " - << timeslices << ", " << sliceNum << endreq; + << timeslices << ", " << sliceNum << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; return; } @@ -832,19 +835,19 @@ void JepByteStreamTool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, int dataID = source; if (source >= m_modules) { if (summing == CmmSubBlock::CRATE && - source != CmmEnergySubBlock::LOCAL) continue; - switch (source) { - case CmmEnergySubBlock::LOCAL: - dataID = LVL1::CMMEtSums::LOCAL; - break; - case CmmEnergySubBlock::REMOTE: - dataID = LVL1::CMMEtSums::REMOTE; - break; - case CmmEnergySubBlock::TOTAL: - dataID = LVL1::CMMEtSums::TOTAL; - break; - default: - continue; + source != CmmEnergySubBlock::LOCAL) continue; + switch (source) { + case CmmEnergySubBlock::LOCAL: + dataID = LVL1::CMMEtSums::LOCAL; + break; + case CmmEnergySubBlock::REMOTE: + dataID = LVL1::CMMEtSums::REMOTE; + break; + case CmmEnergySubBlock::TOTAL: + dataID = LVL1::CMMEtSums::TOTAL; + break; + default: + continue; } } const unsigned int ex = subBlock->ex(slice, source); @@ -858,13 +861,13 @@ void JepByteStreamTool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, LVL1::DataError etErrBits(ssError); if (dataID == LVL1::CMMEtSums::LOCAL || dataID == LVL1::CMMEtSums::REMOTE || - dataID == LVL1::CMMEtSums::TOTAL) { + dataID == LVL1::CMMEtSums::TOTAL) { exErrBits.set(LVL1::DataError::Overflow, exErr); - exErrBits.set(LVL1::DataError::Parity, exErr >> 1); + exErrBits.set(LVL1::DataError::Parity, exErr >> 1); eyErrBits.set(LVL1::DataError::Overflow, eyErr); - eyErrBits.set(LVL1::DataError::Parity, eyErr >> 1); + eyErrBits.set(LVL1::DataError::Parity, eyErr >> 1); etErrBits.set(LVL1::DataError::Overflow, etErr); - etErrBits.set(LVL1::DataError::Parity, etErr >> 1); + etErrBits.set(LVL1::DataError::Parity, etErr >> 1); } else { exErrBits.set(LVL1::DataError::Parity, exErr); eyErrBits.set(LVL1::DataError::Parity, eyErr); @@ -875,54 +878,54 @@ void JepByteStreamTool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, etErr = etErrBits.error(); if (ex || ey || et || exErr || eyErr || etErr) { LVL1::CMMEtSums* sums = findCmmSums(crate, dataID); - if ( ! sums ) { // create new CMM energy sums - m_exVec.assign(timeslices, 0); - m_eyVec.assign(timeslices, 0); - m_etVec.assign(timeslices, 0); - m_exErrVec.assign(timeslices, 0); - m_eyErrVec.assign(timeslices, 0); - m_etErrVec.assign(timeslices, 0); - m_exVec[slice] = ex; - m_eyVec[slice] = ey; - m_etVec[slice] = et; - m_exErrVec[slice] = exErr; - m_eyErrVec[slice] = eyErr; - m_etErrVec[slice] = etErr; - sums = new LVL1::CMMEtSums(swCrate, dataID, m_etVec, m_exVec, m_eyVec, - m_etErrVec, m_exErrVec, m_eyErrVec, trigCmm); - const int key = crate*100 + dataID; - m_cmmEtMap.insert(std::make_pair(key, sums)); - m_cmmEtCollection->push_back(sums); + if ( ! sums ) { // create new CMM energy sums + m_exVec.assign(timeslices, 0); + m_eyVec.assign(timeslices, 0); + m_etVec.assign(timeslices, 0); + m_exErrVec.assign(timeslices, 0); + m_eyErrVec.assign(timeslices, 0); + m_etErrVec.assign(timeslices, 0); + m_exVec[slice] = ex; + m_eyVec[slice] = ey; + m_etVec[slice] = et; + m_exErrVec[slice] = exErr; + m_eyErrVec[slice] = eyErr; + m_etErrVec[slice] = etErr; + sums = new LVL1::CMMEtSums(swCrate, dataID, m_etVec, m_exVec, m_eyVec, + m_etErrVec, m_exErrVec, m_eyErrVec, trigCmm); + const int key = crate * 100 + dataID; + m_cmmEtMap.insert(std::make_pair(key, sums)); + m_cmmEtCollection->push_back(sums); } else { - m_exVec = sums->ExVec(); - m_eyVec = sums->EyVec(); - m_etVec = sums->EtVec(); - m_exErrVec = sums->ExErrorVec(); - m_eyErrVec = sums->EyErrorVec(); - m_etErrVec = sums->EtErrorVec(); - const int nsl = m_exVec.size(); - if (timeslices != nsl) { - if (debug) msg() << "Inconsistent number of slices in sub-blocks" - << endreq; + m_exVec = sums->ExVec(); + m_eyVec = sums->EyVec(); + m_etVec = sums->EtVec(); + m_exErrVec = sums->ExErrorVec(); + m_eyErrVec = sums->EyErrorVec(); + m_etErrVec = sums->EtErrorVec(); + const int nsl = m_exVec.size(); + if (timeslices != nsl) { + if (debug) msg() << "Inconsistent number of slices in sub-blocks" + << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + return; } - if (m_exVec[slice] != 0 || m_eyVec[slice] != 0 || m_etVec[slice] != 0 || - m_exErrVec[slice] != 0 || m_eyErrVec[slice] != 0 || + if (m_exVec[slice] != 0 || m_eyVec[slice] != 0 || m_etVec[slice] != 0 || + m_exErrVec[slice] != 0 || m_eyErrVec[slice] != 0 || m_etErrVec[slice] != 0) { if (debug) msg() << "Duplicate data for slice " << slice << endreq; - m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; + return; } - m_exVec[slice] = ex; - m_eyVec[slice] = ey; - m_etVec[slice] = et; - m_exErrVec[slice] = exErr; - m_eyErrVec[slice] = eyErr; - m_etErrVec[slice] = etErr; - sums->addEx(m_exVec, m_exErrVec); - sums->addEy(m_eyVec, m_eyErrVec); - sums->addEt(m_etVec, m_etErrVec); + m_exVec[slice] = ex; + m_eyVec[slice] = ey; + m_etVec[slice] = et; + m_exErrVec[slice] = exErr; + m_eyErrVec[slice] = eyErr; + m_etErrVec[slice] = etErr; + sums->addEx(m_exVec, m_exErrVec); + sums->addEy(m_eyVec, m_eyErrVec); + sums->addEt(m_etVec, m_etErrVec); } } } @@ -935,36 +938,36 @@ void JepByteStreamTool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, const int dataID = LVL1::CMMEtSums::MISSING_ET_MAP; LVL1::CMMEtSums* map = findCmmSums(crate, dataID); if ( ! map ) { - m_etVec.assign(timeslices, 0); - m_etErrVec.assign(timeslices, 0); - m_etVec[slice] = missEt; - m_etErrVec[slice] = ssError; - map = new LVL1::CMMEtSums(swCrate, dataID, - m_etVec, m_etVec, m_etVec, - m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); - const int key = crate*100 + dataID; - m_cmmEtMap.insert(std::make_pair(key, map)); - m_cmmEtCollection->push_back(map); + m_etVec.assign(timeslices, 0); + m_etErrVec.assign(timeslices, 0); + m_etVec[slice] = missEt; + m_etErrVec[slice] = ssError; + map = new LVL1::CMMEtSums(swCrate, dataID, + m_etVec, m_etVec, m_etVec, + m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); + const int key = crate * 100 + dataID; + m_cmmEtMap.insert(std::make_pair(key, map)); + m_cmmEtCollection->push_back(map); } else { m_etVec = map->EtVec(); m_etErrVec = map->EtErrorVec(); - const int nsl = m_etVec.size(); - if (timeslices != nsl) { - if (debug) msg() << "Inconsistent number of slices in sub-blocks" - << endreq; + const int nsl = m_etVec.size(); + if (timeslices != nsl) { + if (debug) msg() << "Inconsistent number of slices in sub-blocks" + << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + return; } - if (m_etVec[slice] != 0 || m_etErrVec[slice] != 0) { - if (debug) msg() << "Duplicate data for slice " << slice << endreq; - m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + if (m_etVec[slice] != 0 || m_etErrVec[slice] != 0) { + if (debug) msg() << "Duplicate data for slice " << slice << endreq; + m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; + return; } - m_etVec[slice] = missEt; - m_etErrVec[slice] = ssError; - map->addEx(m_etVec, m_etErrVec); - map->addEy(m_etVec, m_etErrVec); - map->addEt(m_etVec, m_etErrVec); + m_etVec[slice] = missEt; + m_etErrVec[slice] = ssError; + map->addEx(m_etVec, m_etErrVec); + map->addEy(m_etVec, m_etErrVec); + map->addEt(m_etVec, m_etErrVec); } } const unsigned int sumEt = subBlock->sumEtHits(slice); @@ -974,34 +977,34 @@ void JepByteStreamTool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, if ( ! map ) { m_etVec.assign(timeslices, 0); m_etErrVec.assign(timeslices, 0); - m_etVec[slice] = sumEt; - m_etErrVec[slice] = ssError; - map = new LVL1::CMMEtSums(swCrate, dataID, - m_etVec, m_etVec, m_etVec, - m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); - const int key = crate*100 + dataID; - m_cmmEtMap.insert(std::make_pair(key, map)); - m_cmmEtCollection->push_back(map); + m_etVec[slice] = sumEt; + m_etErrVec[slice] = ssError; + map = new LVL1::CMMEtSums(swCrate, dataID, + m_etVec, m_etVec, m_etVec, + m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); + const int key = crate * 100 + dataID; + m_cmmEtMap.insert(std::make_pair(key, map)); + m_cmmEtCollection->push_back(map); } else { m_etVec = map->EtVec(); m_etErrVec = map->EtErrorVec(); - const int nsl = m_etVec.size(); - if (timeslices != nsl) { - if (debug) msg() << "Inconsistent number of slices in sub-blocks" - << endreq; + const int nsl = m_etVec.size(); + if (timeslices != nsl) { + if (debug) msg() << "Inconsistent number of slices in sub-blocks" + << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + return; } - if (m_etVec[slice] != 0 || m_etErrVec[slice] != 0) { - if (debug) msg() << "Duplicate data for slice " << slice << endreq; - m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + if (m_etVec[slice] != 0 || m_etErrVec[slice] != 0) { + if (debug) msg() << "Duplicate data for slice " << slice << endreq; + m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; + return; } - m_etVec[slice] = sumEt; - m_etErrVec[slice] = ssError; - map->addEx(m_etVec, m_etErrVec); - map->addEy(m_etVec, m_etErrVec); - map->addEt(m_etVec, m_etErrVec); + m_etVec[slice] = sumEt; + m_etErrVec[slice] = ssError; + map->addEx(m_etVec, m_etErrVec); + map->addEy(m_etVec, m_etErrVec); + map->addEt(m_etVec, m_etErrVec); } } if (subBlock->version() > 1) { @@ -1012,41 +1015,41 @@ void JepByteStreamTool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, if ( ! map ) { m_etVec.assign(timeslices, 0); m_etErrVec.assign(timeslices, 0); - m_etVec[slice] = missEtSig; - m_etErrVec[slice] = ssError; - map = new LVL1::CMMEtSums(swCrate, dataID, - m_etVec, m_etVec, m_etVec, - m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); - const int key = crate*100 + dataID; - m_cmmEtMap.insert(std::make_pair(key, map)); - m_cmmEtCollection->push_back(map); + m_etVec[slice] = missEtSig; + m_etErrVec[slice] = ssError; + map = new LVL1::CMMEtSums(swCrate, dataID, + m_etVec, m_etVec, m_etVec, + m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); + const int key = crate * 100 + dataID; + m_cmmEtMap.insert(std::make_pair(key, map)); + m_cmmEtCollection->push_back(map); } else { m_etVec = map->EtVec(); m_etErrVec = map->EtErrorVec(); - const int nsl = m_etVec.size(); - if (timeslices != nsl) { - if (debug) msg() << "Inconsistent number of slices in sub-blocks" - << endreq; + const int nsl = m_etVec.size(); + if (timeslices != nsl) { + if (debug) msg() << "Inconsistent number of slices in sub-blocks" + << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + return; } - if (m_etVec[slice] != 0 || m_etErrVec[slice] != 0) { - if (debug) msg() << "Duplicate data for slice " - << slice << endreq; - m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + if (m_etVec[slice] != 0 || m_etErrVec[slice] != 0) { + if (debug) msg() << "Duplicate data for slice " + << slice << endreq; + m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; + return; } - m_etVec[slice] = missEtSig; - m_etErrVec[slice] = ssError; - map->addEx(m_etVec, m_etErrVec); - map->addEy(m_etVec, m_etErrVec); - map->addEt(m_etVec, m_etErrVec); + m_etVec[slice] = missEtSig; + m_etErrVec[slice] = ssError; + map->addEx(m_etVec, m_etErrVec); + map->addEy(m_etVec, m_etErrVec); + map->addEt(m_etVec, m_etErrVec); } } } } } - + return; } @@ -1066,21 +1069,21 @@ void JepByteStreamTool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm) if (debug) { msg() << "CMM-Jet: Crate " << hwCrate << " Module " << module - << " Firmware " << firmware - << " Summing " << summing + << " Firmware " << firmware + << " Summing " << summing << " Total slices " << timeslices << " Slice " << sliceNum << endreq; } if (timeslices <= trigCmm) { if (debug) msg() << "Triggered CMM slice from header " - << "inconsistent with number of slices: " - << trigCmm << ", " << timeslices << endreq; + << "inconsistent with number of slices: " + << trigCmm << ", " << timeslices << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; return; } if (timeslices <= sliceNum) { if (debug) msg() << "Total slices inconsistent with slice number: " - << timeslices << ", " << sliceNum << endreq; + << timeslices << ", " << sliceNum << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; return; } @@ -1113,65 +1116,65 @@ void JepByteStreamTool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm) int dataID = source; if (source >= m_modules) { if (summing == CmmSubBlock::CRATE && - source != CmmJetSubBlock::LOCAL_MAIN && - source != CmmJetSubBlock::LOCAL_FORWARD) continue; - switch (source) { - case CmmJetSubBlock::LOCAL_MAIN: - dataID = LVL1::CMMJetHits::LOCAL_MAIN; - break; - case CmmJetSubBlock::REMOTE_MAIN: - dataID = LVL1::CMMJetHits::REMOTE_MAIN; - break; - case CmmJetSubBlock::TOTAL_MAIN: - dataID = LVL1::CMMJetHits::TOTAL_MAIN; - break; - case CmmJetSubBlock::LOCAL_FORWARD: - dataID = LVL1::CMMJetHits::LOCAL_FORWARD; - break; - case CmmJetSubBlock::REMOTE_FORWARD: - dataID = LVL1::CMMJetHits::REMOTE_FORWARD; - break; - case CmmJetSubBlock::TOTAL_FORWARD: - dataID = LVL1::CMMJetHits::TOTAL_FORWARD; - break; - default: - continue; + source != CmmJetSubBlock::LOCAL_MAIN && + source != CmmJetSubBlock::LOCAL_FORWARD) continue; + switch (source) { + case CmmJetSubBlock::LOCAL_MAIN: + dataID = LVL1::CMMJetHits::LOCAL_MAIN; + break; + case CmmJetSubBlock::REMOTE_MAIN: + dataID = LVL1::CMMJetHits::REMOTE_MAIN; + break; + case CmmJetSubBlock::TOTAL_MAIN: + dataID = LVL1::CMMJetHits::TOTAL_MAIN; + break; + case CmmJetSubBlock::LOCAL_FORWARD: + dataID = LVL1::CMMJetHits::LOCAL_FORWARD; + break; + case CmmJetSubBlock::REMOTE_FORWARD: + dataID = LVL1::CMMJetHits::REMOTE_FORWARD; + break; + case CmmJetSubBlock::TOTAL_FORWARD: + dataID = LVL1::CMMJetHits::TOTAL_FORWARD; + break; + default: + continue; } } const unsigned int hits = subBlock->jetHits(slice, source); LVL1::DataError errBits(ssError); errBits.set(LVL1::DataError::Parity, - subBlock->jetHitsError(slice, source)); + subBlock->jetHitsError(slice, source)); const int err = errBits.error(); if (hits || err) { LVL1::CMMJetHits* jh = findCmmHits(crate, dataID); - if ( ! jh ) { // create new CMM hits - m_hitsVec.assign(timeslices, 0); - m_errVec.assign(timeslices, 0); - m_hitsVec[slice] = hits; - m_errVec[slice] = err; - jh = new LVL1::CMMJetHits(swCrate, dataID, m_hitsVec, m_errVec, trigCmm); - const int key = crate*100 + dataID; - m_cmmHitsMap.insert(std::make_pair(key, jh)); - m_cmmHitCollection->push_back(jh); + if ( ! jh ) { // create new CMM hits + m_hitsVec.assign(timeslices, 0); + m_errVec.assign(timeslices, 0); + m_hitsVec[slice] = hits; + m_errVec[slice] = err; + jh = new LVL1::CMMJetHits(swCrate, dataID, m_hitsVec, m_errVec, trigCmm); + const int key = crate * 100 + dataID; + m_cmmHitsMap.insert(std::make_pair(key, jh)); + m_cmmHitCollection->push_back(jh); } else { - m_hitsVec = jh->HitsVec(); - m_errVec = jh->ErrorVec(); - const int nsl = m_hitsVec.size(); - if (timeslices != nsl) { - if (debug) msg() << "Inconsistent number of slices in sub-blocks" - << endreq; + m_hitsVec = jh->HitsVec(); + m_errVec = jh->ErrorVec(); + const int nsl = m_hitsVec.size(); + if (timeslices != nsl) { + if (debug) msg() << "Inconsistent number of slices in sub-blocks" + << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + return; } - if (m_hitsVec[slice] != 0 || m_errVec[slice] != 0) { - if (debug) msg() << "Duplicate data for slice " << slice << endreq; - m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + if (m_hitsVec[slice] != 0 || m_errVec[slice] != 0) { + if (debug) msg() << "Duplicate data for slice " << slice << endreq; + m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; + return; } - m_hitsVec[slice] = hits; - m_errVec[slice] = err; - jh->addHits(m_hitsVec, m_errVec); + m_hitsVec[slice] = hits; + m_errVec[slice] = err; + jh->addHits(m_hitsVec, m_errVec); } } } @@ -1186,42 +1189,42 @@ void JepByteStreamTool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm) if ( ! map ) { m_hitsVec.assign(timeslices, 0); m_errVec.assign(timeslices, 0); - m_hitsVec[slice] = etMap; - m_errVec[slice] = ssError; - map = new LVL1::CMMJetHits(swCrate, dataID, m_hitsVec, m_errVec, trigCmm); - const int key = crate*100 + dataID; - m_cmmHitsMap.insert(std::make_pair(key, map)); - m_cmmHitCollection->push_back(map); + m_hitsVec[slice] = etMap; + m_errVec[slice] = ssError; + map = new LVL1::CMMJetHits(swCrate, dataID, m_hitsVec, m_errVec, trigCmm); + const int key = crate * 100 + dataID; + m_cmmHitsMap.insert(std::make_pair(key, map)); + m_cmmHitCollection->push_back(map); } else { m_hitsVec = map->HitsVec(); m_errVec = map->ErrorVec(); - const int nsl = m_hitsVec.size(); - if (timeslices != nsl) { - if (debug) msg() << "Inconsistent number of slices in sub-blocks" - << endreq; + const int nsl = m_hitsVec.size(); + if (timeslices != nsl) { + if (debug) msg() << "Inconsistent number of slices in sub-blocks" + << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + return; } - if (m_hitsVec[slice] != 0 || m_errVec[slice] != 0) { - if (debug) msg() << "Duplicate data for slice " << slice << endreq; - m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + if (m_hitsVec[slice] != 0 || m_errVec[slice] != 0) { + if (debug) msg() << "Duplicate data for slice " << slice << endreq; + m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; + return; } - m_hitsVec[slice] = etMap; - m_errVec[slice] = ssError; - map->addHits(m_hitsVec, m_errVec); + m_hitsVec[slice] = etMap; + m_errVec[slice] = ssError; + map->addHits(m_hitsVec, m_errVec); } } } } - + return; } // Unpack JEM sub-block void JepByteStreamTool::decodeJem(JemSubBlock* subBlock, int trigJem, - const CollectionType collection) + const CollectionType collection) { const bool debug = msgLvl(MSG::DEBUG); const bool verbose = msgLvl(MSG::VERBOSE); @@ -1239,14 +1242,14 @@ void JepByteStreamTool::decodeJem(JemSubBlock* subBlock, int trigJem, } if (timeslices <= trigJem) { if (debug) msg() << "Triggered JEM slice from header " - << "inconsistent with number of slices: " - << trigJem << ", " << timeslices << endreq; + << "inconsistent with number of slices: " + << trigJem << ", " << timeslices << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; return; } if (timeslices <= sliceNum) { if (debug) msg() << "Total slices inconsistent with slice number: " - << timeslices << ", " << sliceNum << endreq; + << timeslices << ", " << sliceNum << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; return; } @@ -1280,60 +1283,60 @@ void JepByteStreamTool::decodeJem(JemSubBlock* subBlock, int trigJem, for (int chan = 0; chan < m_channels; ++chan) { const JemJetElement jetEle(subBlock->jetElement(slice, chan)); if (jetEle.data() || ssError) { - double eta = 0.; - double phi = 0.; - int layer = 0; - if (m_jemMaps->mapping(crate, module, chan, eta, phi, layer)) { - if (layer == m_coreOverlap) { - LVL1::JetElement* je = findJetElement(eta, phi); - if ( ! je ) { // create new jet element - const unsigned int key = m_elementKey->jeKey(phi, eta); - je = new LVL1::JetElement(phi, eta, dummy, dummy, key, - dummy, dummy, dummy, trigJem); - m_jeMap.insert(std::make_pair(key, je)); - m_jeCollection->push_back(je); + double eta = 0.; + double phi = 0.; + int layer = 0; + if (m_jemMaps->mapping(crate, module, chan, eta, phi, layer)) { + if (layer == m_coreOverlap) { + LVL1::JetElement* je = findJetElement(eta, phi); + if ( ! je ) { // create new jet element + const unsigned int key = m_elementKey->jeKey(phi, eta); + je = new LVL1::JetElement(phi, eta, dummy, dummy, key, + dummy, dummy, dummy, trigJem); + m_jeMap.insert(std::make_pair(key, je)); + m_jeCollection->push_back(je); } else { - const std::vector<int>& emEnergy(je->emEnergyVec()); - const std::vector<int>& hadEnergy(je->hadEnergyVec()); - const std::vector<int>& emError(je->emErrorVec()); - const std::vector<int>& hadError(je->hadErrorVec()); - const int nsl = emEnergy.size(); - if (timeslices != nsl) { - if (debug) { - msg() << "Inconsistent number of slices in sub-blocks" - << endreq; + const std::vector<int>& emEnergy(je->emEnergyVec()); + const std::vector<int>& hadEnergy(je->hadEnergyVec()); + const std::vector<int>& emError(je->emErrorVec()); + const std::vector<int>& hadError(je->hadErrorVec()); + const int nsl = emEnergy.size(); + if (timeslices != nsl) { + if (debug) { + msg() << "Inconsistent number of slices in sub-blocks" + << endreq; } - m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + m_rodErr = L1CaloSubBlock::ERROR_SLICES; + return; } - if (emEnergy[slice] != 0 || hadEnergy[slice] != 0 || - emError[slice] != 0 || hadError[slice] != 0) { + if (emEnergy[slice] != 0 || hadEnergy[slice] != 0 || + emError[slice] != 0 || hadError[slice] != 0) { if (debug) msg() << "Duplicate data for slice " - << slice << endreq; + << slice << endreq; m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + return; } } - LVL1::DataError emErrBits(ssError); - LVL1::DataError hadErrBits(ssError); - const int linkError = jetEle.linkError(); - emErrBits.set(LVL1::DataError::Parity, jetEle.emParity()); - emErrBits.set(LVL1::DataError::LinkDown, linkError); - hadErrBits.set(LVL1::DataError::Parity, jetEle.hadParity()); - hadErrBits.set(LVL1::DataError::LinkDown, linkError >> 1); - je->addSlice(slice, jetEle.emData(), jetEle.hadData(), - emErrBits.error(), hadErrBits.error(), - linkError); - } + LVL1::DataError emErrBits(ssError); + LVL1::DataError hadErrBits(ssError); + const int linkError = jetEle.linkError(); + emErrBits.set(LVL1::DataError::Parity, jetEle.emParity()); + emErrBits.set(LVL1::DataError::LinkDown, linkError); + hadErrBits.set(LVL1::DataError::Parity, jetEle.hadParity()); + hadErrBits.set(LVL1::DataError::LinkDown, linkError >> 1); + je->addSlice(slice, jetEle.emData(), jetEle.hadData(), + emErrBits.error(), hadErrBits.error(), + linkError); + } } else if (verbose && jetEle.data()) { - msg(MSG::VERBOSE) << "Non-zero data but no channel mapping for channel " - << chan << endreq; - msg(MSG::DEBUG); + msg(MSG::VERBOSE) << "Non-zero data but no channel mapping for channel " + << chan << endreq; + msg(MSG::DEBUG); } } else if (verbose) { - msg(MSG::VERBOSE) << "No jet element data for channel " - << chan << " slice " << slice << endreq; - msg(MSG::DEBUG); + msg(MSG::VERBOSE) << "No jet element data for channel " + << chan << " slice " << slice << endreq; + msg(MSG::DEBUG); } } } else if (collection == JET_HITS) { @@ -1343,37 +1346,37 @@ void JepByteStreamTool::decodeJem(JemSubBlock* subBlock, int trigJem, const unsigned int hits = subBlock->jetHits(slice); if (hits) { LVL1::JEMHits* jh = findJetHits(crate, module); - if ( ! jh ) { // create new jet hits - m_hitsVec.assign(timeslices, 0); - m_hitsVec[slice] = hits; - jh = new LVL1::JEMHits(swCrate, module, m_hitsVec, trigJem); - m_hitsMap.insert(std::make_pair(crate*m_modules+module, jh)); - m_hitCollection->push_back(jh); + if ( ! jh ) { // create new jet hits + m_hitsVec.assign(timeslices, 0); + m_hitsVec[slice] = hits; + jh = new LVL1::JEMHits(swCrate, module, m_hitsVec, trigJem); + m_hitsMap.insert(std::make_pair(crate * m_modules + module, jh)); + m_hitCollection->push_back(jh); } else { - m_hitsVec = jh->JetHitsVec(); - const int nsl = m_hitsVec.size(); - if (timeslices != nsl) { - if (debug) { - msg() << "Inconsistent number of slices in sub-blocks" - << endreq; - } + m_hitsVec = jh->JetHitsVec(); + const int nsl = m_hitsVec.size(); + if (timeslices != nsl) { + if (debug) { + msg() << "Inconsistent number of slices in sub-blocks" + << endreq; + } m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + return; } - if (m_hitsVec[slice] != 0) { - if (debug) msg() << "Duplicate data for slice " - << slice << endreq; + if (m_hitsVec[slice] != 0) { + if (debug) msg() << "Duplicate data for slice " + << slice << endreq; m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + return; } - m_hitsVec[slice] = hits; - jh->addJetHits(m_hitsVec); + m_hitsVec[slice] = hits; + jh->addJetHits(m_hitsVec); } } else if (verbose) { msg(MSG::VERBOSE) << "No jet hits data for crate/module/slice " << hwCrate << "/" << module << "/" << slice - << endreq; - msg(MSG::DEBUG); + << endreq; + msg(MSG::DEBUG); } } else if (collection == ENERGY_SUMS) { @@ -1383,49 +1386,49 @@ void JepByteStreamTool::decodeJem(JemSubBlock* subBlock, int trigJem, const unsigned int ey = subBlock->ey(slice); const unsigned int et = subBlock->et(slice); if (ex | ey | et) { - LVL1::JEMEtSums* sums = findEnergySums(crate, module); - if ( ! sums ) { // create new energy sums - m_exVec.assign(timeslices, 0); - m_eyVec.assign(timeslices, 0); - m_etVec.assign(timeslices, 0); - m_exVec[slice] = ex; - m_eyVec[slice] = ey; - m_etVec[slice] = et; - sums = new LVL1::JEMEtSums(swCrate, module, m_etVec, m_exVec, m_eyVec, - trigJem); - m_etMap.insert(std::make_pair(crate*m_modules+module, sums)); - m_etCollection->push_back(sums); + LVL1::JEMEtSums* sums = findEnergySums(crate, module); + if ( ! sums ) { // create new energy sums + m_exVec.assign(timeslices, 0); + m_eyVec.assign(timeslices, 0); + m_etVec.assign(timeslices, 0); + m_exVec[slice] = ex; + m_eyVec[slice] = ey; + m_etVec[slice] = et; + sums = new LVL1::JEMEtSums(swCrate, module, m_etVec, m_exVec, m_eyVec, + trigJem); + m_etMap.insert(std::make_pair(crate * m_modules + module, sums)); + m_etCollection->push_back(sums); } else { - m_exVec = sums->ExVec(); - m_eyVec = sums->EyVec(); - m_etVec = sums->EtVec(); - const int nsl = m_exVec.size(); - if (timeslices != nsl) { - if (debug) { - msg() << "Inconsistent number of slices in sub-blocks" - << endreq; - } + m_exVec = sums->ExVec(); + m_eyVec = sums->EyVec(); + m_etVec = sums->EtVec(); + const int nsl = m_exVec.size(); + if (timeslices != nsl) { + if (debug) { + msg() << "Inconsistent number of slices in sub-blocks" + << endreq; + } m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + return; } - if (m_exVec[slice] != 0 || m_eyVec[slice] != 0 || m_etVec[slice] != 0) { - if (debug) msg() << "Duplicate data for slice " - << slice << endreq; + if (m_exVec[slice] != 0 || m_eyVec[slice] != 0 || m_etVec[slice] != 0) { + if (debug) msg() << "Duplicate data for slice " + << slice << endreq; m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + return; } - m_exVec[slice] = ex; - m_eyVec[slice] = ey; - m_etVec[slice] = et; - sums->addEx(m_exVec); - sums->addEy(m_eyVec); - sums->addEt(m_etVec); + m_exVec[slice] = ex; + m_eyVec[slice] = ey; + m_etVec[slice] = et; + sums->addEx(m_exVec); + sums->addEy(m_eyVec); + sums->addEt(m_etVec); } } else if (verbose) { msg(MSG::VERBOSE) << "No energy sums data for crate/module/slice " << hwCrate << "/" << module << "/" << slice - << endreq; - msg(MSG::DEBUG); + << endreq; + msg(MSG::DEBUG); } } } @@ -1435,7 +1438,7 @@ void JepByteStreamTool::decodeJem(JemSubBlock* subBlock, int trigJem, // Find a jet element given eta, phi LVL1::JetElement* JepByteStreamTool::findJetElement(const double eta, - const double phi) + const double phi) { LVL1::JetElement* tt = 0; const unsigned int key = m_elementKey->jeKey(phi, eta); @@ -1448,11 +1451,11 @@ LVL1::JetElement* JepByteStreamTool::findJetElement(const double eta, // Find jet hits for given crate, module LVL1::JEMHits* JepByteStreamTool::findJetHits(const int crate, - const int module) + const int module) { LVL1::JEMHits* hits = 0; JetHitsMap::const_iterator mapIter; - mapIter = m_hitsMap.find(crate*m_modules + module); + mapIter = m_hitsMap.find(crate * m_modules + module); if (mapIter != m_hitsMap.end()) hits = mapIter->second; return hits; } @@ -1460,11 +1463,11 @@ LVL1::JEMHits* JepByteStreamTool::findJetHits(const int crate, // Find energy sums for given crate, module LVL1::JEMEtSums* JepByteStreamTool::findEnergySums(const int crate, - const int module) + const int module) { LVL1::JEMEtSums* sums = 0; EnergySumsMap::const_iterator mapIter; - mapIter = m_etMap.find(crate*m_modules + module); + mapIter = m_etMap.find(crate * m_modules + module); if (mapIter != m_etMap.end()) sums = mapIter->second; return sums; } @@ -1472,11 +1475,11 @@ LVL1::JEMEtSums* JepByteStreamTool::findEnergySums(const int crate, // Find CMM hits for given crate, dataID LVL1::CMMJetHits* JepByteStreamTool::findCmmHits(const int crate, - const int dataID) + const int dataID) { LVL1::CMMJetHits* hits = 0; CmmHitsMap::const_iterator mapIter; - mapIter = m_cmmHitsMap.find(crate*100 + dataID); + mapIter = m_cmmHitsMap.find(crate * 100 + dataID); if (mapIter != m_cmmHitsMap.end()) hits = mapIter->second; return hits; } @@ -1484,11 +1487,11 @@ LVL1::CMMJetHits* JepByteStreamTool::findCmmHits(const int crate, // Find CMM energy sums for given crate, module, dataID LVL1::CMMEtSums* JepByteStreamTool::findCmmSums(const int crate, - const int dataID) + const int dataID) { LVL1::CMMEtSums* sums = 0; CmmSumsMap::const_iterator mapIter; - mapIter = m_cmmEtMap.find(crate*100 + dataID); + mapIter = m_cmmEtMap.find(crate * 100 + dataID); if (mapIter != m_cmmEtMap.end()) sums = mapIter->second; return sums; } @@ -1496,7 +1499,7 @@ LVL1::CMMEtSums* JepByteStreamTool::findCmmSums(const int crate, // Set up jet element map void JepByteStreamTool::setupJeMap(const JetElementCollection* - const jeCollection) + const jeCollection) { m_jeMap.clear(); if (jeCollection) { @@ -1513,7 +1516,7 @@ void JepByteStreamTool::setupJeMap(const JetElementCollection* // Set up jet hits map void JepByteStreamTool::setupHitsMap(const JetHitsCollection* - const hitCollection) + const hitCollection) { m_hitsMap.clear(); if (hitCollection) { @@ -1531,7 +1534,7 @@ void JepByteStreamTool::setupHitsMap(const JetHitsCollection* // Set up energy sums map void JepByteStreamTool::setupEtMap(const EnergySumsCollection* - const etCollection) + const etCollection) { m_etMap.clear(); if (etCollection) { @@ -1549,7 +1552,7 @@ void JepByteStreamTool::setupEtMap(const EnergySumsCollection* // Set up CMM hits map void JepByteStreamTool::setupCmmHitsMap(const CmmHitsCollection* - const hitCollection) + const hitCollection) { m_cmmHitsMap.clear(); if (hitCollection) { @@ -1558,7 +1561,7 @@ void JepByteStreamTool::setupCmmHitsMap(const CmmHitsCollection* for (; pos != pose; ++pos) { LVL1::CMMJetHits* const hits = *pos; const int crate = hits->crate() - m_crateOffsetSw; - const int key = crate*100 + hits->dataID(); + const int key = crate * 100 + hits->dataID(); m_cmmHitsMap.insert(std::make_pair(key, hits)); } } @@ -1567,7 +1570,7 @@ void JepByteStreamTool::setupCmmHitsMap(const CmmHitsCollection* // Set up CMM energy sums map void JepByteStreamTool::setupCmmEtMap(const CmmSumsCollection* - const etCollection) + const etCollection) { m_cmmEtMap.clear(); if (etCollection) { @@ -1576,7 +1579,7 @@ void JepByteStreamTool::setupCmmEtMap(const CmmSumsCollection* for (; pos != pose; ++pos) { LVL1::CMMEtSums* const sums = *pos; const int crate = sums->crate() - m_crateOffsetSw; - const int key = crate*100 + sums->dataID(); + const int key = crate * 100 + sums->dataID(); m_cmmEtMap.insert(std::make_pair(key, sums)); } } @@ -1585,10 +1588,10 @@ void JepByteStreamTool::setupCmmEtMap(const CmmSumsCollection* // Get number of slices and triggered slice offset for next slink bool JepByteStreamTool::slinkSlices(const int crate, const int module, - const int modulesPerSlink, int& timeslices, int& trigJem) + const int modulesPerSlink, int& timeslices, int& trigJem) { int slices = -1; - int trigJ = m_dfltSlices/2; + int trigJ = m_dfltSlices / 2; for (int mod = module; mod < module + modulesPerSlink; ++mod) { for (int chan = 0; chan < m_channels; ++chan) { double eta = 0.; @@ -1619,21 +1622,21 @@ bool JepByteStreamTool::slinkSlices(const int crate, const int module, for (int i = 0; i < numdat; ++i) { if (sums[i] == 0) continue; if (slices < 0) { - slices = sizes[i]; - trigJ = peak; - } else if (slices != sizes[i] || trigJ != peak) return false; + slices = sizes[i]; + trigJ = peak; + } else if (slices != sizes[i] || trigJ != peak) return false; } } const LVL1::JEMHits* const hits = findJetHits(crate, mod); if (hits) { const unsigned int sum = std::accumulate((hits->JetHitsVec()).begin(), - (hits->JetHitsVec()).end(), 0); + (hits->JetHitsVec()).end(), 0); if (sum) { const int size = (hits->JetHitsVec()).size(); - const int peak = hits->peak(); + const int peak = hits->peak(); if (slices < 0) { - slices = size; - trigJ = peak; + slices = size; + trigJ = peak; } else if (slices != size || trigJ != peak) return false; } } @@ -1654,15 +1657,15 @@ bool JepByteStreamTool::slinkSlices(const int crate, const int module, const int peak = et->peak(); for (int i = 0; i < numdat; ++i) { if (sums[i] == 0) continue; - if (slices < 0) { - slices = sizes[i]; - trigJ = peak; + if (slices < 0) { + slices = sizes[i]; + trigJ = peak; } else if (slices != sizes[i] || trigJ != peak) return false; } } } // CMM last slink of crate - if (module/modulesPerSlink == m_slinks - 1) { + if (module / modulesPerSlink == m_slinks - 1) { const int maxDataID1 = LVL1::CMMJetHits::MAXID; const int maxDataID2 = LVL1::CMMEtSums::MAXID; const int maxDataID = (maxDataID1 > maxDataID2) ? maxDataID1 : maxDataID2; @@ -1674,17 +1677,17 @@ bool JepByteStreamTool::slinkSlices(const int crate, const int module, if (dataID < maxDataID1) hits = findCmmHits(crate, dataID); if (hits) { sums[0] = std::accumulate((hits->HitsVec()).begin(), - (hits->HitsVec()).end(), 0); + (hits->HitsVec()).end(), 0); sums[1] = std::accumulate((hits->ErrorVec()).begin(), - (hits->ErrorVec()).end(), 0); + (hits->ErrorVec()).end(), 0); sizes[0] = (hits->HitsVec()).size(); sizes[1] = (hits->ErrorVec()).size(); const int peak = hits->peak(); for (int i = 0; i < 2; ++i) { if (sums[i] == 0) continue; if (slices < 0) { - slices = sizes[i]; - trigJ = peak; + slices = sizes[i]; + trigJ = peak; } else if (slices != sizes[i] || trigJ != peak) return false; } } @@ -1692,7 +1695,7 @@ bool JepByteStreamTool::slinkSlices(const int crate, const int module, if (dataID < maxDataID2) et = findCmmSums(crate, dataID); if (et) { sums[0] = std::accumulate((et->ExVec()).begin(), - (et->ExVec()).end(), 0); + (et->ExVec()).end(), 0); sums[1] = std::accumulate((et->EyVec()).begin(), (et->EyVec()).end(), 0); sums[2] = std::accumulate((et->EtVec()).begin(), @@ -1712,9 +1715,9 @@ bool JepByteStreamTool::slinkSlices(const int crate, const int module, const int peak = et->peak(); for (int i = 0; i < numdat; ++i) { if (sums[i] == 0) continue; - if (slices < 0) { - slices = sizes[i]; - trigJ = peak; + if (slices < 0) { + slices = sizes[i]; + trigJ = peak; } else if (slices != sizes[i] || trigJ != peak) return false; } } diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV1Tool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV1Tool.cxx index 18c93477c36290bb224559da760e53eab1f08006..037e2015e0bbf72ec31cd0e5e3756974fddc6067 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV1Tool.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV1Tool.cxx @@ -50,8 +50,8 @@ const InterfaceID& JepByteStreamV1Tool::interfaceID() // Constructor JepByteStreamV1Tool::JepByteStreamV1Tool(const std::string& type, - const std::string& name, - const IInterface* parent) + const std::string& name, + const IInterface* parent) : AthAlgTool(type, name, parent), m_jemMaps("LVL1::JemMappingTool/JemMappingTool"), m_errorTool("LVL1BS::L1CaloErrorByteStreamTool/L1CaloErrorByteStreamTool"), @@ -90,7 +90,7 @@ JepByteStreamV1Tool::JepByteStreamV1Tool(const std::string& type, "If >0, the number of slices in bytestream"); declareProperty("CrateMin", m_crateMin = 0, "Minimum crate number, allows partial output"); - declareProperty("CrateMax", m_crateMax = m_crates-1, + declareProperty("CrateMax", m_crateMax = m_crates - 1, "Maximum crate number, allows partial output"); } @@ -151,8 +151,8 @@ StatusCode JepByteStreamV1Tool::finalize() // Conversion bytestream to jet elements StatusCode JepByteStreamV1Tool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - DataVector<LVL1::JetElement>* const jeCollection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + DataVector<LVL1::JetElement>* const jeCollection) { m_jeCollection = jeCollection; m_jeMap.clear(); @@ -162,8 +162,8 @@ StatusCode JepByteStreamV1Tool::convert( // Conversion bytestream to jet hits StatusCode JepByteStreamV1Tool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - DataVector<LVL1::JEMHits>* const hitCollection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + DataVector<LVL1::JEMHits>* const hitCollection) { m_hitCollection = hitCollection; m_hitsMap.clear(); @@ -173,8 +173,8 @@ StatusCode JepByteStreamV1Tool::convert( // Conversion bytestream to energy sums StatusCode JepByteStreamV1Tool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - DataVector<LVL1::JEMEtSums>* const etCollection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + DataVector<LVL1::JEMEtSums>* const etCollection) { m_etCollection = etCollection; m_etMap.clear(); @@ -184,8 +184,8 @@ StatusCode JepByteStreamV1Tool::convert( // Conversion bytestream to CMM hits StatusCode JepByteStreamV1Tool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - DataVector<LVL1::CMMJetHits>* const hitCollection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + DataVector<LVL1::CMMJetHits>* const hitCollection) { m_cmmHitCollection = hitCollection; m_cmmHitsMap.clear(); @@ -195,8 +195,8 @@ StatusCode JepByteStreamV1Tool::convert( // Conversion bytestream to CMM energy sums StatusCode JepByteStreamV1Tool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - DataVector<LVL1::CMMEtSums>* const etCollection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + DataVector<LVL1::CMMEtSums>* const etCollection) { m_cmmEtCollection = etCollection; m_cmmEtMap.clear(); @@ -206,7 +206,7 @@ StatusCode JepByteStreamV1Tool::convert( // Conversion of JEP container to bytestream StatusCode JepByteStreamV1Tool::convert(const LVL1::JEPBSCollectionV1* const jep, - RawEventWrite* const re) + RawEventWrite* const re) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -241,44 +241,44 @@ StatusCode JepByteStreamV1Tool::convert(const LVL1::JEPBSCollectionV1* const jep for (int crate = m_crateMin; crate <= m_crateMax; ++crate) { const int hwCrate = crate + m_crateOffsetHw; - for (int module=0; module < m_modules; ++module) { + for (int module = 0; module < m_modules; ++module) { // Pack required number of modules per slink - if (module%modulesPerSlink == 0) { - const int daqOrRoi = 0; - const int slink = module/modulesPerSlink; + if (module % modulesPerSlink == 0) { + const int daqOrRoi = 0; + const int slink = module / modulesPerSlink; if (debug) { msg() << "Treating crate " << hwCrate << " slink " << slink << endreq; } - // Get number of JEM slices and triggered slice offset - // for this slink - if ( ! slinkSlices(crate, module, modulesPerSlink, - timeslices, trigJem)) { - msg(MSG::ERROR) << "Inconsistent number of slices or " - << "triggered slice offsets in data for crate " - << hwCrate << " slink " << slink << endreq; - return StatusCode::FAILURE; + // Get number of JEM slices and triggered slice offset + // for this slink + if ( ! slinkSlices(crate, module, modulesPerSlink, + timeslices, trigJem)) { + msg(MSG::ERROR) << "Inconsistent number of slices or " + << "triggered slice offsets in data for crate " + << hwCrate << " slink " << slink << endreq; + return StatusCode::FAILURE; } - timeslicesNew = (m_forceSlices) ? m_forceSlices : timeslices; - trigJemNew = ModifySlices::peak(trigJem, timeslices, timeslicesNew); + timeslicesNew = (m_forceSlices) ? m_forceSlices : timeslices; + trigJemNew = ModifySlices::peak(trigJem, timeslices, timeslicesNew); if (debug) { - msg() << "Data Version/Format: " << m_version - << " " << m_dataFormat << endreq + msg() << "Data Version/Format: " << m_version + << " " << m_dataFormat << endreq << "Slices/offset: " << timeslices << " " << trigJem; - if (timeslices != timeslicesNew) { - msg() << " modified to " << timeslicesNew << " " << trigJemNew; + if (timeslices != timeslicesNew) { + msg() << " modified to " << timeslicesNew << " " << trigJemNew; } - msg() << endreq; + msg() << endreq; } L1CaloUserHeader userHeader; userHeader.setJem(trigJemNew); - const uint32_t rodIdJem = m_srcIdMap->getRodID(hwCrate, slink, daqOrRoi, - m_subDetector); - theROD = m_fea->getRodData(rodIdJem); - theROD->push_back(userHeader.header()); - m_rodStatusMap.insert(make_pair(rodIdJem, m_rodStatus)); + const uint32_t rodIdJem = m_srcIdMap->getRodID(hwCrate, slink, daqOrRoi, + m_subDetector); + theROD = m_fea->getRodData(rodIdJem); + theROD->push_back(userHeader.header()); + m_rodStatusMap.insert(make_pair(rodIdJem, m_rodStatus)); } if (debug) msg() << "Module " << module << endreq; @@ -287,42 +287,42 @@ StatusCode JepByteStreamV1Tool::convert(const LVL1::JEPBSCollectionV1* const jep m_jemBlocks.clear(); for (int slice = 0; slice < timeslicesNew; ++slice) { JemSubBlockV1* const subBlock = new JemSubBlockV1(); - subBlock->setJemHeader(m_version, m_dataFormat, slice, - hwCrate, module, timeslicesNew); + subBlock->setJemHeader(m_version, m_dataFormat, slice, + hwCrate, module, timeslicesNew); m_jemBlocks.push_back(subBlock); - if (neutralFormat) break; + if (neutralFormat) break; } // Find jet elements corresponding to each eta/phi pair and fill // sub-blocks - for (int chan=0; chan < m_channels; ++chan) { - double eta = 0.; - double phi = 0.; - int layer = 0; - if (m_jemMaps->mapping(crate, module, chan, eta, phi, layer)) { + for (int chan = 0; chan < m_channels; ++chan) { + double eta = 0.; + double phi = 0.; + int layer = 0; + if (m_jemMaps->mapping(crate, module, chan, eta, phi, layer)) { const LVL1::JetElement* const je = findJetElement(eta, phi); - if (je ) { - std::vector<int> emData; - std::vector<int> hadData; - std::vector<int> emErrors; - std::vector<int> hadErrors; - ModifySlices::data(je->emEnergyVec(), emData, timeslicesNew); - ModifySlices::data(je->hadEnergyVec(), hadData, timeslicesNew); - ModifySlices::data(je->emErrorVec(), emErrors, timeslicesNew); - ModifySlices::data(je->hadErrorVec(), hadErrors, timeslicesNew); + if (je ) { + std::vector<int> emData; + std::vector<int> hadData; + std::vector<int> emErrors; + std::vector<int> hadErrors; + ModifySlices::data(je->emEnergyVec(), emData, timeslicesNew); + ModifySlices::data(je->hadEnergyVec(), hadData, timeslicesNew); + ModifySlices::data(je->emErrorVec(), emErrors, timeslicesNew); + ModifySlices::data(je->hadErrorVec(), hadErrors, timeslicesNew); for (int slice = 0; slice < timeslicesNew; ++slice) { - const LVL1::DataError emErrBits(emErrors[slice]); - const LVL1::DataError hadErrBits(hadErrors[slice]); - const int index = ( neutralFormat ) ? 0 : slice; + const LVL1::DataError emErrBits(emErrors[slice]); + const LVL1::DataError hadErrBits(hadErrors[slice]); + const int index = ( neutralFormat ) ? 0 : slice; JemSubBlockV1* const subBlock = m_jemBlocks[index]; - const JemJetElement jetEle(chan, emData[slice], hadData[slice], - emErrBits.get(LVL1::DataError::Parity), - hadErrBits.get(LVL1::DataError::Parity), - emErrBits.get(LVL1::DataError::LinkDown) + - (hadErrBits.get(LVL1::DataError::LinkDown) << 1)); + const JemJetElement jetEle(chan, emData[slice], hadData[slice], + emErrBits.get(LVL1::DataError::Parity), + hadErrBits.get(LVL1::DataError::Parity), + emErrBits.get(LVL1::DataError::LinkDown) + + (hadErrBits.get(LVL1::DataError::LinkDown) << 1)); subBlock->fillJetElement(slice, jetEle); - } + } } } } @@ -332,11 +332,11 @@ StatusCode JepByteStreamV1Tool::convert(const LVL1::JEPBSCollectionV1* const jep const LVL1::JEMHits* const hits = findJetHits(crate, module); if (hits) { std::vector<unsigned int> vec; - ModifySlices::data(hits->JetHitsVec(), vec, timeslicesNew); + ModifySlices::data(hits->JetHitsVec(), vec, timeslicesNew); for (int slice = 0; slice < timeslicesNew; ++slice) { - const int index = ( neutralFormat ) ? 0 : slice; - JemSubBlockV1* const subBlock = m_jemBlocks[index]; - subBlock->setJetHits(slice, vec[slice]); + const int index = ( neutralFormat ) ? 0 : slice; + JemSubBlockV1* const subBlock = m_jemBlocks[index]; + subBlock->setJetHits(slice, vec[slice]); } } const LVL1::JEMEtSums* const et = findEnergySums(crate, module); @@ -344,31 +344,31 @@ StatusCode JepByteStreamV1Tool::convert(const LVL1::JEPBSCollectionV1* const jep std::vector<unsigned int> exVec; std::vector<unsigned int> eyVec; std::vector<unsigned int> etVec; - ModifySlices::data(et->ExVec(), exVec, timeslicesNew); - ModifySlices::data(et->EyVec(), eyVec, timeslicesNew); - ModifySlices::data(et->EtVec(), etVec, timeslicesNew); - for (int slice = 0; slice < timeslicesNew; ++slice) { - const int index = ( neutralFormat ) ? 0 : slice; - JemSubBlockV1* const subBlock = m_jemBlocks[index]; - subBlock->setEnergySubsums(slice, exVec[slice], eyVec[slice], - etVec[slice]); + ModifySlices::data(et->ExVec(), exVec, timeslicesNew); + ModifySlices::data(et->EyVec(), eyVec, timeslicesNew); + ModifySlices::data(et->EtVec(), etVec, timeslicesNew); + for (int slice = 0; slice < timeslicesNew; ++slice) { + const int index = ( neutralFormat ) ? 0 : slice; + JemSubBlockV1* const subBlock = m_jemBlocks[index]; + subBlock->setEnergySubsums(slice, exVec[slice], eyVec[slice], + etVec[slice]); } } - + // Pack and write the sub-blocks - DataVector<JemSubBlockV1>::const_iterator pos; + DataVector<JemSubBlockV1>::iterator pos; for (pos = m_jemBlocks.begin(); pos != m_jemBlocks.end(); ++pos) { JemSubBlockV1* const subBlock = *pos; - if ( !subBlock->pack()) { - msg(MSG::ERROR) << "JEM sub-block packing failed" << endreq; - return StatusCode::FAILURE; - } - if (debug) { - msg() << "JEM sub-block data words: " - << subBlock->dataWords() << endreq; - } - subBlock->write(theROD); + if ( !subBlock->pack()) { + msg(MSG::ERROR) << "JEM sub-block packing failed" << endreq; + return StatusCode::FAILURE; + } + if (debug) { + msg() << "JEM sub-block data words: " + << subBlock->dataWords() << endreq; + } + subBlock->write(theROD); } } @@ -379,18 +379,18 @@ StatusCode JepByteStreamV1Tool::convert(const LVL1::JEPBSCollectionV1* const jep m_cmmEnergyBlocks.clear(); m_cmmJetBlocks.clear(); const int summing = (crate == m_crates - 1) ? CmmSubBlock::SYSTEM - : CmmSubBlock::CRATE; + : CmmSubBlock::CRATE; for (int slice = 0; slice < timeslicesNew; ++slice) { CmmEnergySubBlock* const enBlock = new CmmEnergySubBlock(); const int cmmEnergyVersion = 2; // with Missing-ET-Sig enBlock->setCmmHeader(cmmEnergyVersion, m_dataFormat, slice, hwCrate, summing, CmmSubBlock::CMM_ENERGY, - CmmSubBlock::LEFT, timeslicesNew); + CmmSubBlock::LEFT, timeslicesNew); m_cmmEnergyBlocks.push_back(enBlock); CmmJetSubBlock* const jetBlock = new CmmJetSubBlock(); jetBlock->setCmmHeader(m_version, m_dataFormat, slice, hwCrate, summing, CmmSubBlock::CMM_JET, - CmmSubBlock::RIGHT, timeslicesNew); + CmmSubBlock::RIGHT, timeslicesNew); m_cmmJetBlocks.push_back(jetBlock); if (neutralFormat) break; } @@ -401,24 +401,27 @@ StatusCode JepByteStreamV1Tool::convert(const LVL1::JEPBSCollectionV1* const jep for (int dataID = 0; dataID < maxDataID; ++dataID) { int source = dataID; if (dataID >= m_modules) { - if (summing == CmmSubBlock::CRATE && - dataID != LVL1::CMMEtSums::LOCAL) continue; - switch (dataID) { - case LVL1::CMMEtSums::LOCAL: - source = CmmEnergySubBlock::LOCAL; - break; - case LVL1::CMMEtSums::REMOTE: - source = CmmEnergySubBlock::REMOTE; - break; - case LVL1::CMMEtSums::TOTAL: - source = CmmEnergySubBlock::TOTAL; - break; - case LVL1::CMMEtSums::MISSING_ET_MAP: - case LVL1::CMMEtSums::SUM_ET_MAP: - case LVL1::CMMEtSums::MISSING_ET_SIG_MAP: - break; - default: - continue; + if (summing == CmmSubBlock::CRATE && + dataID != LVL1::CMMEtSums::LOCAL) continue; + // coverity[mixed_enums : FALSE] + // coverity[switch_on_enum : FALSE] + // coverity[first_enum_type : FALSE] + switch (dataID) { + case LVL1::CMMEtSums::LOCAL: + source = CmmEnergySubBlock::LOCAL; + break; + case LVL1::CMMEtSums::REMOTE: + source = CmmEnergySubBlock::REMOTE; + break; + case LVL1::CMMEtSums::TOTAL: + source = CmmEnergySubBlock::TOTAL; + break; + case LVL1::CMMEtSums::MISSING_ET_MAP: + case LVL1::CMMEtSums::SUM_ET_MAP: + case LVL1::CMMEtSums::MISSING_ET_SIG_MAP: + break; + default: + continue; } } const LVL1::CMMEtSums* const sums = findCmmSums(crate, dataID); @@ -429,53 +432,53 @@ StatusCode JepByteStreamV1Tool::convert(const LVL1::JEPBSCollectionV1* const jep std::vector<int> exErr; std::vector<int> eyErr; std::vector<int> etErr; - ModifySlices::data(sums->ExVec(), ex, timeslicesNew); - ModifySlices::data(sums->EyVec(), ey, timeslicesNew); - ModifySlices::data(sums->EtVec(), et, timeslicesNew); - ModifySlices::data(sums->ExErrorVec(), exErr, timeslicesNew); - ModifySlices::data(sums->EyErrorVec(), eyErr, timeslicesNew); - ModifySlices::data(sums->EtErrorVec(), etErr, timeslicesNew); - for (int slice = 0; slice < timeslicesNew; ++slice) { - const LVL1::DataError exErrBits(exErr[slice]); - const LVL1::DataError eyErrBits(eyErr[slice]); - const LVL1::DataError etErrBits(etErr[slice]); - int exError = exErrBits.get(LVL1::DataError::Parity); - int eyError = eyErrBits.get(LVL1::DataError::Parity); - int etError = etErrBits.get(LVL1::DataError::Parity); - if (dataID == LVL1::CMMEtSums::LOCAL || - dataID == LVL1::CMMEtSums::REMOTE || - dataID == LVL1::CMMEtSums::TOTAL) { - exError = (exError << 1) + exErrBits.get(LVL1::DataError::Overflow); - eyError = (eyError << 1) + eyErrBits.get(LVL1::DataError::Overflow); - etError = (etError << 1) + etErrBits.get(LVL1::DataError::Overflow); - } - const int index = ( neutralFormat ) ? 0 : slice; - CmmEnergySubBlock* const subBlock = m_cmmEnergyBlocks[index]; - if (dataID == LVL1::CMMEtSums::MISSING_ET_MAP) { - subBlock->setMissingEtHits(slice, et[slice]); + ModifySlices::data(sums->ExVec(), ex, timeslicesNew); + ModifySlices::data(sums->EyVec(), ey, timeslicesNew); + ModifySlices::data(sums->EtVec(), et, timeslicesNew); + ModifySlices::data(sums->ExErrorVec(), exErr, timeslicesNew); + ModifySlices::data(sums->EyErrorVec(), eyErr, timeslicesNew); + ModifySlices::data(sums->EtErrorVec(), etErr, timeslicesNew); + for (int slice = 0; slice < timeslicesNew; ++slice) { + const LVL1::DataError exErrBits(exErr[slice]); + const LVL1::DataError eyErrBits(eyErr[slice]); + const LVL1::DataError etErrBits(etErr[slice]); + int exError = exErrBits.get(LVL1::DataError::Parity); + int eyError = eyErrBits.get(LVL1::DataError::Parity); + int etError = etErrBits.get(LVL1::DataError::Parity); + if (dataID == LVL1::CMMEtSums::LOCAL || + dataID == LVL1::CMMEtSums::REMOTE || + dataID == LVL1::CMMEtSums::TOTAL) { + exError = (exError << 1) + exErrBits.get(LVL1::DataError::Overflow); + eyError = (eyError << 1) + eyErrBits.get(LVL1::DataError::Overflow); + etError = (etError << 1) + etErrBits.get(LVL1::DataError::Overflow); + } + const int index = ( neutralFormat ) ? 0 : slice; + CmmEnergySubBlock* const subBlock = m_cmmEnergyBlocks[index]; + if (dataID == LVL1::CMMEtSums::MISSING_ET_MAP) { + subBlock->setMissingEtHits(slice, et[slice]); } else if (dataID == LVL1::CMMEtSums::SUM_ET_MAP) { - subBlock->setSumEtHits(slice, et[slice]); - } else if (dataID == LVL1::CMMEtSums::MISSING_ET_SIG_MAP) { - subBlock->setMissingEtSigHits(slice, et[slice]); + subBlock->setSumEtHits(slice, et[slice]); + } else if (dataID == LVL1::CMMEtSums::MISSING_ET_SIG_MAP) { + subBlock->setMissingEtSigHits(slice, et[slice]); } else { - subBlock->setSubsums(slice, source, - ex[slice], ey[slice], et[slice], - exError, eyError, etError); + subBlock->setSubsums(slice, source, + ex[slice], ey[slice], et[slice], + exError, eyError, etError); } } } } - DataVector<CmmEnergySubBlock>::const_iterator pos; + DataVector<CmmEnergySubBlock>::iterator pos; pos = m_cmmEnergyBlocks.begin(); for (; pos != m_cmmEnergyBlocks.end(); ++pos) { CmmEnergySubBlock* const subBlock = *pos; if ( !subBlock->pack()) { msg(MSG::ERROR) << "CMM-Energy sub-block packing failed" << endreq; - return StatusCode::FAILURE; + return StatusCode::FAILURE; } if (debug) { - msg() << "CMM-Energy sub-block data words: " - << subBlock->dataWords() << endreq; + msg() << "CMM-Energy sub-block data words: " + << subBlock->dataWords() << endreq; } subBlock->write(theROD); } @@ -486,64 +489,64 @@ StatusCode JepByteStreamV1Tool::convert(const LVL1::JEPBSCollectionV1* const jep for (int dataID = 0; dataID < maxDataID; ++dataID) { int source = dataID; if (dataID >= m_modules) { - if (summing == CmmSubBlock::CRATE && - dataID != LVL1::CMMJetHits::LOCAL_MAIN && - dataID != LVL1::CMMJetHits::LOCAL_FORWARD) continue; - switch (dataID) { - case LVL1::CMMJetHits::LOCAL_MAIN: - source = CmmJetSubBlock::LOCAL_MAIN; - break; - case LVL1::CMMJetHits::REMOTE_MAIN: - source = CmmJetSubBlock::REMOTE_MAIN; - break; - case LVL1::CMMJetHits::TOTAL_MAIN: - source = CmmJetSubBlock::TOTAL_MAIN; - break; - case LVL1::CMMJetHits::LOCAL_FORWARD: - source = CmmJetSubBlock::LOCAL_FORWARD; - break; - case LVL1::CMMJetHits::REMOTE_FORWARD: - source = CmmJetSubBlock::REMOTE_FORWARD; - break; - case LVL1::CMMJetHits::TOTAL_FORWARD: - source = CmmJetSubBlock::TOTAL_FORWARD; - break; - case LVL1::CMMJetHits::ET_MAP: - break; - default: - continue; + if (summing == CmmSubBlock::CRATE && + dataID != LVL1::CMMJetHits::LOCAL_MAIN && + dataID != LVL1::CMMJetHits::LOCAL_FORWARD) continue; + switch (dataID) { + case LVL1::CMMJetHits::LOCAL_MAIN: + source = CmmJetSubBlock::LOCAL_MAIN; + break; + case LVL1::CMMJetHits::REMOTE_MAIN: + source = CmmJetSubBlock::REMOTE_MAIN; + break; + case LVL1::CMMJetHits::TOTAL_MAIN: + source = CmmJetSubBlock::TOTAL_MAIN; + break; + case LVL1::CMMJetHits::LOCAL_FORWARD: + source = CmmJetSubBlock::LOCAL_FORWARD; + break; + case LVL1::CMMJetHits::REMOTE_FORWARD: + source = CmmJetSubBlock::REMOTE_FORWARD; + break; + case LVL1::CMMJetHits::TOTAL_FORWARD: + source = CmmJetSubBlock::TOTAL_FORWARD; + break; + case LVL1::CMMJetHits::ET_MAP: + break; + default: + continue; } } const LVL1::CMMJetHits* const ch = findCmmHits(crate, dataID); if ( ch ) { std::vector<unsigned int> hits; std::vector<int> errs; - ModifySlices::data(ch->HitsVec(), hits, timeslicesNew); - ModifySlices::data(ch->ErrorVec(), errs, timeslicesNew); - for (int slice = 0; slice < timeslicesNew; ++slice) { - const LVL1::DataError errBits(errs[slice]); - const int index = ( neutralFormat ) ? 0 : slice; - CmmJetSubBlock* const subBlock = m_cmmJetBlocks[index]; - if (dataID == LVL1::CMMJetHits::ET_MAP) { - subBlock->setJetEtMap(slice, hits[slice]); + ModifySlices::data(ch->HitsVec(), hits, timeslicesNew); + ModifySlices::data(ch->ErrorVec(), errs, timeslicesNew); + for (int slice = 0; slice < timeslicesNew; ++slice) { + const LVL1::DataError errBits(errs[slice]); + const int index = ( neutralFormat ) ? 0 : slice; + CmmJetSubBlock* const subBlock = m_cmmJetBlocks[index]; + if (dataID == LVL1::CMMJetHits::ET_MAP) { + subBlock->setJetEtMap(slice, hits[slice]); } else { - subBlock->setJetHits(slice, source, hits[slice], - errBits.get(LVL1::DataError::Parity)); + subBlock->setJetHits(slice, source, hits[slice], + errBits.get(LVL1::DataError::Parity)); } } } } - DataVector<CmmJetSubBlock>::const_iterator jos; + DataVector<CmmJetSubBlock>::iterator jos; jos = m_cmmJetBlocks.begin(); for (; jos != m_cmmJetBlocks.end(); ++jos) { CmmJetSubBlock* const subBlock = *jos; if ( !subBlock->pack()) { msg(MSG::ERROR) << "CMM-Jet sub-block packing failed" << endreq; - return StatusCode::FAILURE; + return StatusCode::FAILURE; } if (debug) { - msg() << "CMM-Jet sub-block data words: " - << subBlock->dataWords() << endreq; + msg() << "CMM-Jet sub-block data words: " + << subBlock->dataWords() << endreq; } subBlock->write(theROD); } @@ -563,13 +566,13 @@ StatusCode JepByteStreamV1Tool::convert(const LVL1::JEPBSCollectionV1* const jep // Return reference to vector with all possible Source Identifiers const std::vector<uint32_t>& JepByteStreamV1Tool::sourceIDs( - const std::string& sgKey) + const std::string& sgKey) { // Check if overlap jet element channels wanted const std::string flag("Overlap"); const std::string::size_type pos = sgKey.find(flag); m_coreOverlap = - (pos == std::string::npos || pos != sgKey.length() - flag.length()) ? 0 : 1; + (pos == std::string::npos || pos != sgKey.length() - flag.length()) ? 0 : 1; if (m_sourceIDs.empty()) { const int maxCrates = m_crates + m_crateOffsetHw; @@ -578,7 +581,7 @@ const std::vector<uint32_t>& JepByteStreamV1Tool::sourceIDs( for (int slink = 0; slink < maxSlinks; ++slink) { const int daqOrRoi = 0; const uint32_t rodId = m_srcIdMap->getRodID(hwCrate, slink, daqOrRoi, - m_subDetector); + m_subDetector); const uint32_t robId = m_srcIdMap->getRobID(rodId); m_sourceIDs.push_back(robId); } @@ -590,8 +593,8 @@ const std::vector<uint32_t>& JepByteStreamV1Tool::sourceIDs( // Convert bytestream to given container type StatusCode JepByteStreamV1Tool::convertBs( - const IROBDataProviderSvc::VROBFRAG& robFrags, - const CollectionType collection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + const CollectionType collection) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -617,8 +620,8 @@ StatusCode JepByteStreamV1Tool::convertBs( (*rob)->status(robData); if (*robData != 0) { m_errorTool->robError(robid, *robData); - if (debug) msg() << "ROB status error - skipping fragment" << endreq; - continue; + if (debug) msg() << "ROB status error - skipping fragment" << endreq; + continue; } } @@ -647,15 +650,15 @@ StatusCode JepByteStreamV1Tool::convertBs( const uint32_t sourceID = (*rob)->rod_source_id(); if (m_srcIdMap->getRobID(sourceID) != robid || m_srcIdMap->subDet(sourceID) != m_subDetector || - m_srcIdMap->daqOrRoi(sourceID) != 0 || - m_srcIdMap->slink(sourceID) >= m_slinks || - m_srcIdMap->crate(sourceID) < m_crateOffsetHw || - m_srcIdMap->crate(sourceID) >= m_crateOffsetHw + m_crates) { + m_srcIdMap->daqOrRoi(sourceID) != 0 || + m_srcIdMap->slink(sourceID) >= m_slinks || + m_srcIdMap->crate(sourceID) < m_crateOffsetHw || + m_srcIdMap->crate(sourceID) >= m_crateOffsetHw + m_crates) { m_errorTool->rodError(robid, L1CaloSubBlock::ERROR_ROD_ID); if (debug) { msg() << "Wrong source identifier in data: ROD " << MSG::hex << sourceID << " ROB " << robid - << MSG::dec << endreq; + << MSG::dec << endreq; } continue; } @@ -668,7 +671,7 @@ StatusCode JepByteStreamV1Tool::convertBs( } const int rodCrate = m_srcIdMap->crate(sourceID); if (debug) { - msg() << "Treating crate " << rodCrate + msg() << "Treating crate " << rodCrate << " slink " << m_srcIdMap->slink(sourceID) << endreq; } @@ -684,7 +687,7 @@ StatusCode JepByteStreamV1Tool::convertBs( if (headerWords != 1) { m_errorTool->rodError(robid, L1CaloSubBlock::ERROR_USER_HEADER); if (debug) msg() << "Unexpected number of user header words: " - << headerWords << endreq; + << headerWords << endreq; continue; } for (int i = 0; i < headerWords; ++i) ++payload; @@ -708,73 +711,73 @@ StatusCode JepByteStreamV1Tool::convertBs( m_rodErr = L1CaloSubBlock::ERROR_NONE; while (payload != payloadEnd) { - + if (L1CaloSubBlock::wordType(*payload) != L1CaloSubBlock::HEADER) { if (debug) msg() << "Unexpected data sequence" << endreq; - m_rodErr = L1CaloSubBlock::ERROR_MISSING_HEADER; - break; + m_rodErr = L1CaloSubBlock::ERROR_MISSING_HEADER; + break; } if (CmmSubBlock::cmmBlock(*payload)) { // CMMs - if (CmmSubBlock::cmmType(*payload) == CmmSubBlock::CMM_JET) { - m_cmmJetSubBlock->clear(); + if (CmmSubBlock::cmmType(*payload) == CmmSubBlock::CMM_JET) { + m_cmmJetSubBlock->clear(); payload = m_cmmJetSubBlock->read(payload, payloadEnd); - if (m_cmmJetSubBlock->crate() != rodCrate) { - if (debug) msg() << "Inconsistent crate number in ROD source ID" - << endreq; - m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; - break; + if (m_cmmJetSubBlock->crate() != rodCrate) { + if (debug) msg() << "Inconsistent crate number in ROD source ID" + << endreq; + m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; + break; } - if (collection == CMM_HITS) { - decodeCmmJet(m_cmmJetSubBlock, trigCmm); - if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { - if (debug) msg() << "decodeCmmJet failed" << endreq; - break; - } + if (collection == CMM_HITS) { + decodeCmmJet(m_cmmJetSubBlock, trigCmm); + if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { + if (debug) msg() << "decodeCmmJet failed" << endreq; + break; + } } } else if (CmmSubBlock::cmmType(*payload) == CmmSubBlock::CMM_ENERGY) { - m_cmmEnergySubBlock->clear(); - payload = m_cmmEnergySubBlock->read(payload, payloadEnd); - if (m_cmmEnergySubBlock->crate() != rodCrate) { - if (debug) msg() << "Inconsistent crate number in ROD source ID" - << endreq; - m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; - break; + m_cmmEnergySubBlock->clear(); + payload = m_cmmEnergySubBlock->read(payload, payloadEnd); + if (m_cmmEnergySubBlock->crate() != rodCrate) { + if (debug) msg() << "Inconsistent crate number in ROD source ID" + << endreq; + m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; + break; } - if (collection == CMM_SUMS) { - decodeCmmEnergy(m_cmmEnergySubBlock, trigCmm); - if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { - if (debug) msg() << "decodeCmmEnergy failed" << endreq; - break; - } + if (collection == CMM_SUMS) { + decodeCmmEnergy(m_cmmEnergySubBlock, trigCmm); + if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { + if (debug) msg() << "decodeCmmEnergy failed" << endreq; + break; + } } - } else { - if (debug) msg() << "Invalid CMM type in module field" << endreq; - m_rodErr = L1CaloSubBlock::ERROR_MODULE_NUMBER; - break; + } else { + if (debug) msg() << "Invalid CMM type in module field" << endreq; + m_rodErr = L1CaloSubBlock::ERROR_MODULE_NUMBER; + break; } } else { // JEM - m_jemSubBlock->clear(); + m_jemSubBlock->clear(); payload = m_jemSubBlock->read(payload, payloadEnd); - if (m_jemSubBlock->crate() != rodCrate) { - if (debug) msg() << "Inconsistent crate number in ROD source ID" - << endreq; - m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; - break; + if (m_jemSubBlock->crate() != rodCrate) { + if (debug) msg() << "Inconsistent crate number in ROD source ID" + << endreq; + m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; + break; } - if (collection == JET_ELEMENTS || collection == JET_HITS || - collection == ENERGY_SUMS) { - decodeJem(m_jemSubBlock, trigJem, collection); - if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { - if (debug) msg() << "decodeJem failed" << endreq; - break; - } + if (collection == JET_ELEMENTS || collection == JET_HITS || + collection == ENERGY_SUMS) { + decodeJem(m_jemSubBlock, trigJem, collection); + if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { + if (debug) msg() << "decodeJem failed" << endreq; + break; + } } } } if (m_rodErr != L1CaloSubBlock::ERROR_NONE) - m_errorTool->rodError(robid, m_rodErr); + m_errorTool->rodError(robid, m_rodErr); } return StatusCode::SUCCESS; @@ -783,7 +786,7 @@ StatusCode JepByteStreamV1Tool::convertBs( // Unpack CMM-Energy sub-block void JepByteStreamV1Tool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, - int trigCmm) + int trigCmm) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -797,21 +800,21 @@ void JepByteStreamV1Tool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, if (debug) { msg() << "CMM-Energy: Crate " << hwCrate << " Module " << module - << " Firmware " << firmware - << " Summing " << summing + << " Firmware " << firmware + << " Summing " << summing << " Total slices " << timeslices << " Slice " << sliceNum << endreq; } if (timeslices <= trigCmm) { if (debug) msg() << "Triggered CMM slice from header " - << "inconsistent with number of slices: " - << trigCmm << ", " << timeslices << endreq; + << "inconsistent with number of slices: " + << trigCmm << ", " << timeslices << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; return; } if (timeslices <= sliceNum) { if (debug) msg() << "Total slices inconsistent with slice number: " - << timeslices << ", " << sliceNum << endreq; + << timeslices << ", " << sliceNum << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; return; } @@ -844,19 +847,19 @@ void JepByteStreamV1Tool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, int dataID = source; if (source >= m_modules) { if (summing == CmmSubBlock::CRATE && - source != CmmEnergySubBlock::LOCAL) continue; - switch (source) { - case CmmEnergySubBlock::LOCAL: - dataID = LVL1::CMMEtSums::LOCAL; - break; - case CmmEnergySubBlock::REMOTE: - dataID = LVL1::CMMEtSums::REMOTE; - break; - case CmmEnergySubBlock::TOTAL: - dataID = LVL1::CMMEtSums::TOTAL; - break; - default: - continue; + source != CmmEnergySubBlock::LOCAL) continue; + switch (source) { + case CmmEnergySubBlock::LOCAL: + dataID = LVL1::CMMEtSums::LOCAL; + break; + case CmmEnergySubBlock::REMOTE: + dataID = LVL1::CMMEtSums::REMOTE; + break; + case CmmEnergySubBlock::TOTAL: + dataID = LVL1::CMMEtSums::TOTAL; + break; + default: + continue; } } const unsigned int ex = subBlock->ex(slice, source); @@ -870,13 +873,13 @@ void JepByteStreamV1Tool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, LVL1::DataError etErrBits(ssError); if (dataID == LVL1::CMMEtSums::LOCAL || dataID == LVL1::CMMEtSums::REMOTE || - dataID == LVL1::CMMEtSums::TOTAL) { + dataID == LVL1::CMMEtSums::TOTAL) { exErrBits.set(LVL1::DataError::Overflow, exErr); - exErrBits.set(LVL1::DataError::Parity, exErr >> 1); + exErrBits.set(LVL1::DataError::Parity, exErr >> 1); eyErrBits.set(LVL1::DataError::Overflow, eyErr); - eyErrBits.set(LVL1::DataError::Parity, eyErr >> 1); + eyErrBits.set(LVL1::DataError::Parity, eyErr >> 1); etErrBits.set(LVL1::DataError::Overflow, etErr); - etErrBits.set(LVL1::DataError::Parity, etErr >> 1); + etErrBits.set(LVL1::DataError::Parity, etErr >> 1); } else { exErrBits.set(LVL1::DataError::Parity, exErr); eyErrBits.set(LVL1::DataError::Parity, eyErr); @@ -887,54 +890,54 @@ void JepByteStreamV1Tool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, etErr = etErrBits.error(); if (ex || ey || et || exErr || eyErr || etErr) { LVL1::CMMEtSums* sums = findCmmSums(crate, dataID); - if ( ! sums ) { // create new CMM energy sums - m_exVec.assign(timeslices, 0); - m_eyVec.assign(timeslices, 0); - m_etVec.assign(timeslices, 0); - m_exErrVec.assign(timeslices, 0); - m_eyErrVec.assign(timeslices, 0); - m_etErrVec.assign(timeslices, 0); - m_exVec[slice] = ex; - m_eyVec[slice] = ey; - m_etVec[slice] = et; - m_exErrVec[slice] = exErr; - m_eyErrVec[slice] = eyErr; - m_etErrVec[slice] = etErr; - sums = new LVL1::CMMEtSums(swCrate, dataID, m_etVec, m_exVec, m_eyVec, - m_etErrVec, m_exErrVec, m_eyErrVec, trigCmm); - const int key = crate*100 + dataID; - m_cmmEtMap.insert(std::make_pair(key, sums)); - m_cmmEtCollection->push_back(sums); + if ( ! sums ) { // create new CMM energy sums + m_exVec.assign(timeslices, 0); + m_eyVec.assign(timeslices, 0); + m_etVec.assign(timeslices, 0); + m_exErrVec.assign(timeslices, 0); + m_eyErrVec.assign(timeslices, 0); + m_etErrVec.assign(timeslices, 0); + m_exVec[slice] = ex; + m_eyVec[slice] = ey; + m_etVec[slice] = et; + m_exErrVec[slice] = exErr; + m_eyErrVec[slice] = eyErr; + m_etErrVec[slice] = etErr; + sums = new LVL1::CMMEtSums(swCrate, dataID, m_etVec, m_exVec, m_eyVec, + m_etErrVec, m_exErrVec, m_eyErrVec, trigCmm); + const int key = crate * 100 + dataID; + m_cmmEtMap.insert(std::make_pair(key, sums)); + m_cmmEtCollection->push_back(sums); } else { - m_exVec = sums->ExVec(); - m_eyVec = sums->EyVec(); - m_etVec = sums->EtVec(); - m_exErrVec = sums->ExErrorVec(); - m_eyErrVec = sums->EyErrorVec(); - m_etErrVec = sums->EtErrorVec(); - const int nsl = m_exVec.size(); - if (timeslices != nsl) { - if (debug) msg() << "Inconsistent number of slices in sub-blocks" - << endreq; + m_exVec = sums->ExVec(); + m_eyVec = sums->EyVec(); + m_etVec = sums->EtVec(); + m_exErrVec = sums->ExErrorVec(); + m_eyErrVec = sums->EyErrorVec(); + m_etErrVec = sums->EtErrorVec(); + const int nsl = m_exVec.size(); + if (timeslices != nsl) { + if (debug) msg() << "Inconsistent number of slices in sub-blocks" + << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + return; } - if (m_exVec[slice] != 0 || m_eyVec[slice] != 0 || m_etVec[slice] != 0 || - m_exErrVec[slice] != 0 || m_eyErrVec[slice] != 0 || + if (m_exVec[slice] != 0 || m_eyVec[slice] != 0 || m_etVec[slice] != 0 || + m_exErrVec[slice] != 0 || m_eyErrVec[slice] != 0 || m_etErrVec[slice] != 0) { if (debug) msg() << "Duplicate data for slice " << slice << endreq; - m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; + return; } - m_exVec[slice] = ex; - m_eyVec[slice] = ey; - m_etVec[slice] = et; - m_exErrVec[slice] = exErr; - m_eyErrVec[slice] = eyErr; - m_etErrVec[slice] = etErr; - sums->addEx(m_exVec, m_exErrVec); - sums->addEy(m_eyVec, m_eyErrVec); - sums->addEt(m_etVec, m_etErrVec); + m_exVec[slice] = ex; + m_eyVec[slice] = ey; + m_etVec[slice] = et; + m_exErrVec[slice] = exErr; + m_eyErrVec[slice] = eyErr; + m_etErrVec[slice] = etErr; + sums->addEx(m_exVec, m_exErrVec); + sums->addEy(m_eyVec, m_eyErrVec); + sums->addEt(m_etVec, m_etErrVec); } } } @@ -947,36 +950,36 @@ void JepByteStreamV1Tool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, const int dataID = LVL1::CMMEtSums::MISSING_ET_MAP; LVL1::CMMEtSums* map = findCmmSums(crate, dataID); if ( ! map ) { - m_etVec.assign(timeslices, 0); - m_etErrVec.assign(timeslices, 0); - m_etVec[slice] = missEt; - m_etErrVec[slice] = ssError; - map = new LVL1::CMMEtSums(swCrate, dataID, - m_etVec, m_etVec, m_etVec, - m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); - const int key = crate*100 + dataID; - m_cmmEtMap.insert(std::make_pair(key, map)); - m_cmmEtCollection->push_back(map); + m_etVec.assign(timeslices, 0); + m_etErrVec.assign(timeslices, 0); + m_etVec[slice] = missEt; + m_etErrVec[slice] = ssError; + map = new LVL1::CMMEtSums(swCrate, dataID, + m_etVec, m_etVec, m_etVec, + m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); + const int key = crate * 100 + dataID; + m_cmmEtMap.insert(std::make_pair(key, map)); + m_cmmEtCollection->push_back(map); } else { m_etVec = map->EtVec(); m_etErrVec = map->EtErrorVec(); - const int nsl = m_etVec.size(); - if (timeslices != nsl) { - if (debug) msg() << "Inconsistent number of slices in sub-blocks" - << endreq; + const int nsl = m_etVec.size(); + if (timeslices != nsl) { + if (debug) msg() << "Inconsistent number of slices in sub-blocks" + << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + return; } - if (m_etVec[slice] != 0 || m_etErrVec[slice] != 0) { - if (debug) msg() << "Duplicate data for slice " << slice << endreq; - m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + if (m_etVec[slice] != 0 || m_etErrVec[slice] != 0) { + if (debug) msg() << "Duplicate data for slice " << slice << endreq; + m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; + return; } - m_etVec[slice] = missEt; - m_etErrVec[slice] = ssError; - map->addEx(m_etVec, m_etErrVec); - map->addEy(m_etVec, m_etErrVec); - map->addEt(m_etVec, m_etErrVec); + m_etVec[slice] = missEt; + m_etErrVec[slice] = ssError; + map->addEx(m_etVec, m_etErrVec); + map->addEy(m_etVec, m_etErrVec); + map->addEt(m_etVec, m_etErrVec); } } const unsigned int sumEt = subBlock->sumEtHits(slice); @@ -986,34 +989,34 @@ void JepByteStreamV1Tool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, if ( ! map ) { m_etVec.assign(timeslices, 0); m_etErrVec.assign(timeslices, 0); - m_etVec[slice] = sumEt; - m_etErrVec[slice] = ssError; - map = new LVL1::CMMEtSums(swCrate, dataID, - m_etVec, m_etVec, m_etVec, - m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); - const int key = crate*100 + dataID; - m_cmmEtMap.insert(std::make_pair(key, map)); - m_cmmEtCollection->push_back(map); + m_etVec[slice] = sumEt; + m_etErrVec[slice] = ssError; + map = new LVL1::CMMEtSums(swCrate, dataID, + m_etVec, m_etVec, m_etVec, + m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); + const int key = crate * 100 + dataID; + m_cmmEtMap.insert(std::make_pair(key, map)); + m_cmmEtCollection->push_back(map); } else { m_etVec = map->EtVec(); m_etErrVec = map->EtErrorVec(); - const int nsl = m_etVec.size(); - if (timeslices != nsl) { - if (debug) msg() << "Inconsistent number of slices in sub-blocks" - << endreq; + const int nsl = m_etVec.size(); + if (timeslices != nsl) { + if (debug) msg() << "Inconsistent number of slices in sub-blocks" + << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + return; } - if (m_etVec[slice] != 0 || m_etErrVec[slice] != 0) { - if (debug) msg() << "Duplicate data for slice " << slice << endreq; - m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + if (m_etVec[slice] != 0 || m_etErrVec[slice] != 0) { + if (debug) msg() << "Duplicate data for slice " << slice << endreq; + m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; + return; } - m_etVec[slice] = sumEt; - m_etErrVec[slice] = ssError; - map->addEx(m_etVec, m_etErrVec); - map->addEy(m_etVec, m_etErrVec); - map->addEt(m_etVec, m_etErrVec); + m_etVec[slice] = sumEt; + m_etErrVec[slice] = ssError; + map->addEx(m_etVec, m_etErrVec); + map->addEy(m_etVec, m_etErrVec); + map->addEt(m_etVec, m_etErrVec); } } if (subBlock->version() > 1) { @@ -1024,41 +1027,41 @@ void JepByteStreamV1Tool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, if ( ! map ) { m_etVec.assign(timeslices, 0); m_etErrVec.assign(timeslices, 0); - m_etVec[slice] = missEtSig; - m_etErrVec[slice] = ssError; - map = new LVL1::CMMEtSums(swCrate, dataID, - m_etVec, m_etVec, m_etVec, - m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); - const int key = crate*100 + dataID; - m_cmmEtMap.insert(std::make_pair(key, map)); - m_cmmEtCollection->push_back(map); + m_etVec[slice] = missEtSig; + m_etErrVec[slice] = ssError; + map = new LVL1::CMMEtSums(swCrate, dataID, + m_etVec, m_etVec, m_etVec, + m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); + const int key = crate * 100 + dataID; + m_cmmEtMap.insert(std::make_pair(key, map)); + m_cmmEtCollection->push_back(map); } else { m_etVec = map->EtVec(); m_etErrVec = map->EtErrorVec(); - const int nsl = m_etVec.size(); - if (timeslices != nsl) { - if (debug) msg() << "Inconsistent number of slices in sub-blocks" - << endreq; + const int nsl = m_etVec.size(); + if (timeslices != nsl) { + if (debug) msg() << "Inconsistent number of slices in sub-blocks" + << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + return; } - if (m_etVec[slice] != 0 || m_etErrVec[slice] != 0) { - if (debug) msg() << "Duplicate data for slice " - << slice << endreq; - m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + if (m_etVec[slice] != 0 || m_etErrVec[slice] != 0) { + if (debug) msg() << "Duplicate data for slice " + << slice << endreq; + m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; + return; } - m_etVec[slice] = missEtSig; - m_etErrVec[slice] = ssError; - map->addEx(m_etVec, m_etErrVec); - map->addEy(m_etVec, m_etErrVec); - map->addEt(m_etVec, m_etErrVec); + m_etVec[slice] = missEtSig; + m_etErrVec[slice] = ssError; + map->addEx(m_etVec, m_etErrVec); + map->addEy(m_etVec, m_etErrVec); + map->addEt(m_etVec, m_etErrVec); } } } } } - + return; } @@ -1078,21 +1081,21 @@ void JepByteStreamV1Tool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm) if (debug) { msg() << "CMM-Jet: Crate " << hwCrate << " Module " << module - << " Firmware " << firmware - << " Summing " << summing + << " Firmware " << firmware + << " Summing " << summing << " Total slices " << timeslices << " Slice " << sliceNum << endreq; } if (timeslices <= trigCmm) { if (debug) msg() << "Triggered CMM slice from header " - << "inconsistent with number of slices: " - << trigCmm << ", " << timeslices << endreq; + << "inconsistent with number of slices: " + << trigCmm << ", " << timeslices << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; return; } if (timeslices <= sliceNum) { if (debug) msg() << "Total slices inconsistent with slice number: " - << timeslices << ", " << sliceNum << endreq; + << timeslices << ", " << sliceNum << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; return; } @@ -1125,65 +1128,65 @@ void JepByteStreamV1Tool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm) int dataID = source; if (source >= m_modules) { if (summing == CmmSubBlock::CRATE && - source != CmmJetSubBlock::LOCAL_MAIN && - source != CmmJetSubBlock::LOCAL_FORWARD) continue; - switch (source) { - case CmmJetSubBlock::LOCAL_MAIN: - dataID = LVL1::CMMJetHits::LOCAL_MAIN; - break; - case CmmJetSubBlock::REMOTE_MAIN: - dataID = LVL1::CMMJetHits::REMOTE_MAIN; - break; - case CmmJetSubBlock::TOTAL_MAIN: - dataID = LVL1::CMMJetHits::TOTAL_MAIN; - break; - case CmmJetSubBlock::LOCAL_FORWARD: - dataID = LVL1::CMMJetHits::LOCAL_FORWARD; - break; - case CmmJetSubBlock::REMOTE_FORWARD: - dataID = LVL1::CMMJetHits::REMOTE_FORWARD; - break; - case CmmJetSubBlock::TOTAL_FORWARD: - dataID = LVL1::CMMJetHits::TOTAL_FORWARD; - break; - default: - continue; + source != CmmJetSubBlock::LOCAL_MAIN && + source != CmmJetSubBlock::LOCAL_FORWARD) continue; + switch (source) { + case CmmJetSubBlock::LOCAL_MAIN: + dataID = LVL1::CMMJetHits::LOCAL_MAIN; + break; + case CmmJetSubBlock::REMOTE_MAIN: + dataID = LVL1::CMMJetHits::REMOTE_MAIN; + break; + case CmmJetSubBlock::TOTAL_MAIN: + dataID = LVL1::CMMJetHits::TOTAL_MAIN; + break; + case CmmJetSubBlock::LOCAL_FORWARD: + dataID = LVL1::CMMJetHits::LOCAL_FORWARD; + break; + case CmmJetSubBlock::REMOTE_FORWARD: + dataID = LVL1::CMMJetHits::REMOTE_FORWARD; + break; + case CmmJetSubBlock::TOTAL_FORWARD: + dataID = LVL1::CMMJetHits::TOTAL_FORWARD; + break; + default: + continue; } } const unsigned int hits = subBlock->jetHits(slice, source); LVL1::DataError errBits(ssError); errBits.set(LVL1::DataError::Parity, - subBlock->jetHitsError(slice, source)); + subBlock->jetHitsError(slice, source)); const int err = errBits.error(); if (hits || err) { LVL1::CMMJetHits* jh = findCmmHits(crate, dataID); - if ( ! jh ) { // create new CMM hits - m_hitsVec.assign(timeslices, 0); - m_errVec.assign(timeslices, 0); - m_hitsVec[slice] = hits; - m_errVec[slice] = err; - jh = new LVL1::CMMJetHits(swCrate, dataID, m_hitsVec, m_errVec, trigCmm); - const int key = crate*100 + dataID; - m_cmmHitsMap.insert(std::make_pair(key, jh)); - m_cmmHitCollection->push_back(jh); + if ( ! jh ) { // create new CMM hits + m_hitsVec.assign(timeslices, 0); + m_errVec.assign(timeslices, 0); + m_hitsVec[slice] = hits; + m_errVec[slice] = err; + jh = new LVL1::CMMJetHits(swCrate, dataID, m_hitsVec, m_errVec, trigCmm); + const int key = crate * 100 + dataID; + m_cmmHitsMap.insert(std::make_pair(key, jh)); + m_cmmHitCollection->push_back(jh); } else { - m_hitsVec = jh->HitsVec(); - m_errVec = jh->ErrorVec(); - const int nsl = m_hitsVec.size(); - if (timeslices != nsl) { - if (debug) msg() << "Inconsistent number of slices in sub-blocks" - << endreq; + m_hitsVec = jh->HitsVec(); + m_errVec = jh->ErrorVec(); + const int nsl = m_hitsVec.size(); + if (timeslices != nsl) { + if (debug) msg() << "Inconsistent number of slices in sub-blocks" + << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + return; } - if (m_hitsVec[slice] != 0 || m_errVec[slice] != 0) { - if (debug) msg() << "Duplicate data for slice " << slice << endreq; - m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + if (m_hitsVec[slice] != 0 || m_errVec[slice] != 0) { + if (debug) msg() << "Duplicate data for slice " << slice << endreq; + m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; + return; } - m_hitsVec[slice] = hits; - m_errVec[slice] = err; - jh->addHits(m_hitsVec, m_errVec); + m_hitsVec[slice] = hits; + m_errVec[slice] = err; + jh->addHits(m_hitsVec, m_errVec); } } } @@ -1198,42 +1201,42 @@ void JepByteStreamV1Tool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm) if ( ! map ) { m_hitsVec.assign(timeslices, 0); m_errVec.assign(timeslices, 0); - m_hitsVec[slice] = etMap; - m_errVec[slice] = ssError; - map = new LVL1::CMMJetHits(swCrate, dataID, m_hitsVec, m_errVec, trigCmm); - const int key = crate*100 + dataID; - m_cmmHitsMap.insert(std::make_pair(key, map)); - m_cmmHitCollection->push_back(map); + m_hitsVec[slice] = etMap; + m_errVec[slice] = ssError; + map = new LVL1::CMMJetHits(swCrate, dataID, m_hitsVec, m_errVec, trigCmm); + const int key = crate * 100 + dataID; + m_cmmHitsMap.insert(std::make_pair(key, map)); + m_cmmHitCollection->push_back(map); } else { m_hitsVec = map->HitsVec(); m_errVec = map->ErrorVec(); - const int nsl = m_hitsVec.size(); - if (timeslices != nsl) { - if (debug) msg() << "Inconsistent number of slices in sub-blocks" - << endreq; + const int nsl = m_hitsVec.size(); + if (timeslices != nsl) { + if (debug) msg() << "Inconsistent number of slices in sub-blocks" + << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + return; } - if (m_hitsVec[slice] != 0 || m_errVec[slice] != 0) { - if (debug) msg() << "Duplicate data for slice " << slice << endreq; - m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + if (m_hitsVec[slice] != 0 || m_errVec[slice] != 0) { + if (debug) msg() << "Duplicate data for slice " << slice << endreq; + m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; + return; } - m_hitsVec[slice] = etMap; - m_errVec[slice] = ssError; - map->addHits(m_hitsVec, m_errVec); + m_hitsVec[slice] = etMap; + m_errVec[slice] = ssError; + map->addHits(m_hitsVec, m_errVec); } } } } - + return; } // Unpack JEM sub-block void JepByteStreamV1Tool::decodeJem(JemSubBlockV1* subBlock, int trigJem, - const CollectionType collection) + const CollectionType collection) { const bool debug = msgLvl(MSG::DEBUG); const bool verbose = msgLvl(MSG::VERBOSE); @@ -1251,14 +1254,14 @@ void JepByteStreamV1Tool::decodeJem(JemSubBlockV1* subBlock, int trigJem, } if (timeslices <= trigJem) { if (debug) msg() << "Triggered JEM slice from header " - << "inconsistent with number of slices: " - << trigJem << ", " << timeslices << endreq; + << "inconsistent with number of slices: " + << trigJem << ", " << timeslices << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; return; } if (timeslices <= sliceNum) { if (debug) msg() << "Total slices inconsistent with slice number: " - << timeslices << ", " << sliceNum << endreq; + << timeslices << ", " << sliceNum << endreq; m_rodErr = L1CaloSubBlock::ERROR_SLICES; return; } @@ -1292,60 +1295,60 @@ void JepByteStreamV1Tool::decodeJem(JemSubBlockV1* subBlock, int trigJem, for (int chan = 0; chan < m_channels; ++chan) { const JemJetElement jetEle(subBlock->jetElement(slice, chan)); if (jetEle.data() || ssError) { - double eta = 0.; - double phi = 0.; - int layer = 0; - if (m_jemMaps->mapping(crate, module, chan, eta, phi, layer)) { - if (layer == m_coreOverlap) { - LVL1::JetElement* je = findJetElement(eta, phi); - if ( ! je ) { // create new jet element - const unsigned int key = m_elementKey->jeKey(phi, eta); - je = new LVL1::JetElement(phi, eta, dummy, dummy, key, - dummy, dummy, dummy, trigJem); - m_jeMap.insert(std::make_pair(key, je)); - m_jeCollection->push_back(je); + double eta = 0.; + double phi = 0.; + int layer = 0; + if (m_jemMaps->mapping(crate, module, chan, eta, phi, layer)) { + if (layer == m_coreOverlap) { + LVL1::JetElement* je = findJetElement(eta, phi); + if ( ! je ) { // create new jet element + const unsigned int key = m_elementKey->jeKey(phi, eta); + je = new LVL1::JetElement(phi, eta, dummy, dummy, key, + dummy, dummy, dummy, trigJem); + m_jeMap.insert(std::make_pair(key, je)); + m_jeCollection->push_back(je); } else { - const std::vector<int>& emEnergy(je->emEnergyVec()); - const std::vector<int>& hadEnergy(je->hadEnergyVec()); - const std::vector<int>& emError(je->emErrorVec()); - const std::vector<int>& hadError(je->hadErrorVec()); - const int nsl = emEnergy.size(); - if (timeslices != nsl) { - if (debug) { - msg() << "Inconsistent number of slices in sub-blocks" - << endreq; + const std::vector<int>& emEnergy(je->emEnergyVec()); + const std::vector<int>& hadEnergy(je->hadEnergyVec()); + const std::vector<int>& emError(je->emErrorVec()); + const std::vector<int>& hadError(je->hadErrorVec()); + const int nsl = emEnergy.size(); + if (timeslices != nsl) { + if (debug) { + msg() << "Inconsistent number of slices in sub-blocks" + << endreq; } - m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + m_rodErr = L1CaloSubBlock::ERROR_SLICES; + return; } - if (emEnergy[slice] != 0 || hadEnergy[slice] != 0 || - emError[slice] != 0 || hadError[slice] != 0) { + if (emEnergy[slice] != 0 || hadEnergy[slice] != 0 || + emError[slice] != 0 || hadError[slice] != 0) { if (debug) msg() << "Duplicate data for slice " - << slice << endreq; + << slice << endreq; m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + return; } } - LVL1::DataError emErrBits(ssError); - LVL1::DataError hadErrBits(ssError); - const int linkError = jetEle.linkError(); - emErrBits.set(LVL1::DataError::Parity, jetEle.emParity()); - emErrBits.set(LVL1::DataError::LinkDown, linkError); - hadErrBits.set(LVL1::DataError::Parity, jetEle.hadParity()); - hadErrBits.set(LVL1::DataError::LinkDown, linkError >> 1); - je->addSlice(slice, jetEle.emData(), jetEle.hadData(), - emErrBits.error(), hadErrBits.error(), - linkError); - } + LVL1::DataError emErrBits(ssError); + LVL1::DataError hadErrBits(ssError); + const int linkError = jetEle.linkError(); + emErrBits.set(LVL1::DataError::Parity, jetEle.emParity()); + emErrBits.set(LVL1::DataError::LinkDown, linkError); + hadErrBits.set(LVL1::DataError::Parity, jetEle.hadParity()); + hadErrBits.set(LVL1::DataError::LinkDown, linkError >> 1); + je->addSlice(slice, jetEle.emData(), jetEle.hadData(), + emErrBits.error(), hadErrBits.error(), + linkError); + } } else if (verbose && jetEle.data()) { - msg(MSG::VERBOSE) << "Non-zero data but no channel mapping for channel " - << chan << endreq; - msg(MSG::DEBUG); + msg(MSG::VERBOSE) << "Non-zero data but no channel mapping for channel " + << chan << endreq; + msg(MSG::DEBUG); } } else if (verbose) { - msg(MSG::VERBOSE) << "No jet element data for channel " - << chan << " slice " << slice << endreq; - msg(MSG::DEBUG); + msg(MSG::VERBOSE) << "No jet element data for channel " + << chan << " slice " << slice << endreq; + msg(MSG::DEBUG); } } } else if (collection == JET_HITS) { @@ -1355,37 +1358,37 @@ void JepByteStreamV1Tool::decodeJem(JemSubBlockV1* subBlock, int trigJem, const unsigned int hits = subBlock->jetHits(slice); if (hits) { LVL1::JEMHits* jh = findJetHits(crate, module); - if ( ! jh ) { // create new jet hits - m_hitsVec.assign(timeslices, 0); - m_hitsVec[slice] = hits; - jh = new LVL1::JEMHits(swCrate, module, m_hitsVec, trigJem); - m_hitsMap.insert(std::make_pair(crate*m_modules+module, jh)); - m_hitCollection->push_back(jh); + if ( ! jh ) { // create new jet hits + m_hitsVec.assign(timeslices, 0); + m_hitsVec[slice] = hits; + jh = new LVL1::JEMHits(swCrate, module, m_hitsVec, trigJem); + m_hitsMap.insert(std::make_pair(crate * m_modules + module, jh)); + m_hitCollection->push_back(jh); } else { - m_hitsVec = jh->JetHitsVec(); - const int nsl = m_hitsVec.size(); - if (timeslices != nsl) { - if (debug) { - msg() << "Inconsistent number of slices in sub-blocks" - << endreq; - } + m_hitsVec = jh->JetHitsVec(); + const int nsl = m_hitsVec.size(); + if (timeslices != nsl) { + if (debug) { + msg() << "Inconsistent number of slices in sub-blocks" + << endreq; + } m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + return; } - if (m_hitsVec[slice] != 0) { - if (debug) msg() << "Duplicate data for slice " - << slice << endreq; + if (m_hitsVec[slice] != 0) { + if (debug) msg() << "Duplicate data for slice " + << slice << endreq; m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + return; } - m_hitsVec[slice] = hits; - jh->addJetHits(m_hitsVec); + m_hitsVec[slice] = hits; + jh->addJetHits(m_hitsVec); } } else if (verbose) { msg(MSG::VERBOSE) << "No jet hits data for crate/module/slice " << hwCrate << "/" << module << "/" << slice - << endreq; - msg(MSG::DEBUG); + << endreq; + msg(MSG::DEBUG); } } else if (collection == ENERGY_SUMS) { @@ -1395,49 +1398,49 @@ void JepByteStreamV1Tool::decodeJem(JemSubBlockV1* subBlock, int trigJem, const unsigned int ey = subBlock->ey(slice); const unsigned int et = subBlock->et(slice); if (ex | ey | et) { - LVL1::JEMEtSums* sums = findEnergySums(crate, module); - if ( ! sums ) { // create new energy sums - m_exVec.assign(timeslices, 0); - m_eyVec.assign(timeslices, 0); - m_etVec.assign(timeslices, 0); - m_exVec[slice] = ex; - m_eyVec[slice] = ey; - m_etVec[slice] = et; - sums = new LVL1::JEMEtSums(swCrate, module, m_etVec, m_exVec, m_eyVec, - trigJem); - m_etMap.insert(std::make_pair(crate*m_modules+module, sums)); - m_etCollection->push_back(sums); + LVL1::JEMEtSums* sums = findEnergySums(crate, module); + if ( ! sums ) { // create new energy sums + m_exVec.assign(timeslices, 0); + m_eyVec.assign(timeslices, 0); + m_etVec.assign(timeslices, 0); + m_exVec[slice] = ex; + m_eyVec[slice] = ey; + m_etVec[slice] = et; + sums = new LVL1::JEMEtSums(swCrate, module, m_etVec, m_exVec, m_eyVec, + trigJem); + m_etMap.insert(std::make_pair(crate * m_modules + module, sums)); + m_etCollection->push_back(sums); } else { - m_exVec = sums->ExVec(); - m_eyVec = sums->EyVec(); - m_etVec = sums->EtVec(); - const int nsl = m_exVec.size(); - if (timeslices != nsl) { - if (debug) { - msg() << "Inconsistent number of slices in sub-blocks" - << endreq; - } + m_exVec = sums->ExVec(); + m_eyVec = sums->EyVec(); + m_etVec = sums->EtVec(); + const int nsl = m_exVec.size(); + if (timeslices != nsl) { + if (debug) { + msg() << "Inconsistent number of slices in sub-blocks" + << endreq; + } m_rodErr = L1CaloSubBlock::ERROR_SLICES; - return; + return; } - if (m_exVec[slice] != 0 || m_eyVec[slice] != 0 || m_etVec[slice] != 0) { - if (debug) msg() << "Duplicate data for slice " - << slice << endreq; + if (m_exVec[slice] != 0 || m_eyVec[slice] != 0 || m_etVec[slice] != 0) { + if (debug) msg() << "Duplicate data for slice " + << slice << endreq; m_rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - return; + return; } - m_exVec[slice] = ex; - m_eyVec[slice] = ey; - m_etVec[slice] = et; - sums->addEx(m_exVec); - sums->addEy(m_eyVec); - sums->addEt(m_etVec); + m_exVec[slice] = ex; + m_eyVec[slice] = ey; + m_etVec[slice] = et; + sums->addEx(m_exVec); + sums->addEy(m_eyVec); + sums->addEt(m_etVec); } } else if (verbose) { msg(MSG::VERBOSE) << "No energy sums data for crate/module/slice " << hwCrate << "/" << module << "/" << slice - << endreq; - msg(MSG::DEBUG); + << endreq; + msg(MSG::DEBUG); } } } @@ -1447,7 +1450,7 @@ void JepByteStreamV1Tool::decodeJem(JemSubBlockV1* subBlock, int trigJem, // Find a jet element given eta, phi LVL1::JetElement* JepByteStreamV1Tool::findJetElement(const double eta, - const double phi) + const double phi) { LVL1::JetElement* tt = 0; const unsigned int key = m_elementKey->jeKey(phi, eta); @@ -1460,11 +1463,11 @@ LVL1::JetElement* JepByteStreamV1Tool::findJetElement(const double eta, // Find jet hits for given crate, module LVL1::JEMHits* JepByteStreamV1Tool::findJetHits(const int crate, - const int module) + const int module) { LVL1::JEMHits* hits = 0; JetHitsMap::const_iterator mapIter; - mapIter = m_hitsMap.find(crate*m_modules + module); + mapIter = m_hitsMap.find(crate * m_modules + module); if (mapIter != m_hitsMap.end()) hits = mapIter->second; return hits; } @@ -1472,11 +1475,11 @@ LVL1::JEMHits* JepByteStreamV1Tool::findJetHits(const int crate, // Find energy sums for given crate, module LVL1::JEMEtSums* JepByteStreamV1Tool::findEnergySums(const int crate, - const int module) + const int module) { LVL1::JEMEtSums* sums = 0; EnergySumsMap::const_iterator mapIter; - mapIter = m_etMap.find(crate*m_modules + module); + mapIter = m_etMap.find(crate * m_modules + module); if (mapIter != m_etMap.end()) sums = mapIter->second; return sums; } @@ -1484,11 +1487,11 @@ LVL1::JEMEtSums* JepByteStreamV1Tool::findEnergySums(const int crate, // Find CMM hits for given crate, dataID LVL1::CMMJetHits* JepByteStreamV1Tool::findCmmHits(const int crate, - const int dataID) + const int dataID) { LVL1::CMMJetHits* hits = 0; CmmHitsMap::const_iterator mapIter; - mapIter = m_cmmHitsMap.find(crate*100 + dataID); + mapIter = m_cmmHitsMap.find(crate * 100 + dataID); if (mapIter != m_cmmHitsMap.end()) hits = mapIter->second; return hits; } @@ -1496,11 +1499,11 @@ LVL1::CMMJetHits* JepByteStreamV1Tool::findCmmHits(const int crate, // Find CMM energy sums for given crate, module, dataID LVL1::CMMEtSums* JepByteStreamV1Tool::findCmmSums(const int crate, - const int dataID) + const int dataID) { LVL1::CMMEtSums* sums = 0; CmmSumsMap::const_iterator mapIter; - mapIter = m_cmmEtMap.find(crate*100 + dataID); + mapIter = m_cmmEtMap.find(crate * 100 + dataID); if (mapIter != m_cmmEtMap.end()) sums = mapIter->second; return sums; } @@ -1508,7 +1511,7 @@ LVL1::CMMEtSums* JepByteStreamV1Tool::findCmmSums(const int crate, // Set up jet element map void JepByteStreamV1Tool::setupJeMap(const JetElementCollection* - const jeCollection) + const jeCollection) { m_jeMap.clear(); if (jeCollection) { @@ -1525,7 +1528,7 @@ void JepByteStreamV1Tool::setupJeMap(const JetElementCollection* // Set up jet hits map void JepByteStreamV1Tool::setupHitsMap(const JetHitsCollection* - const hitCollection) + const hitCollection) { m_hitsMap.clear(); if (hitCollection) { @@ -1543,7 +1546,7 @@ void JepByteStreamV1Tool::setupHitsMap(const JetHitsCollection* // Set up energy sums map void JepByteStreamV1Tool::setupEtMap(const EnergySumsCollection* - const etCollection) + const etCollection) { m_etMap.clear(); if (etCollection) { @@ -1561,7 +1564,7 @@ void JepByteStreamV1Tool::setupEtMap(const EnergySumsCollection* // Set up CMM hits map void JepByteStreamV1Tool::setupCmmHitsMap(const CmmHitsCollection* - const hitCollection) + const hitCollection) { m_cmmHitsMap.clear(); if (hitCollection) { @@ -1570,7 +1573,7 @@ void JepByteStreamV1Tool::setupCmmHitsMap(const CmmHitsCollection* for (; pos != pose; ++pos) { LVL1::CMMJetHits* const hits = *pos; const int crate = hits->crate() - m_crateOffsetSw; - const int key = crate*100 + hits->dataID(); + const int key = crate * 100 + hits->dataID(); m_cmmHitsMap.insert(std::make_pair(key, hits)); } } @@ -1579,7 +1582,7 @@ void JepByteStreamV1Tool::setupCmmHitsMap(const CmmHitsCollection* // Set up CMM energy sums map void JepByteStreamV1Tool::setupCmmEtMap(const CmmSumsCollection* - const etCollection) + const etCollection) { m_cmmEtMap.clear(); if (etCollection) { @@ -1588,7 +1591,7 @@ void JepByteStreamV1Tool::setupCmmEtMap(const CmmSumsCollection* for (; pos != pose; ++pos) { LVL1::CMMEtSums* const sums = *pos; const int crate = sums->crate() - m_crateOffsetSw; - const int key = crate*100 + sums->dataID(); + const int key = crate * 100 + sums->dataID(); m_cmmEtMap.insert(std::make_pair(key, sums)); } } @@ -1597,10 +1600,10 @@ void JepByteStreamV1Tool::setupCmmEtMap(const CmmSumsCollection* // Get number of slices and triggered slice offset for next slink bool JepByteStreamV1Tool::slinkSlices(const int crate, const int module, - const int modulesPerSlink, int& timeslices, int& trigJem) + const int modulesPerSlink, int& timeslices, int& trigJem) { int slices = -1; - int trigJ = m_dfltSlices/2; + int trigJ = m_dfltSlices / 2; for (int mod = module; mod < module + modulesPerSlink; ++mod) { for (int chan = 0; chan < m_channels; ++chan) { double eta = 0.; @@ -1631,21 +1634,21 @@ bool JepByteStreamV1Tool::slinkSlices(const int crate, const int module, for (int i = 0; i < numdat; ++i) { if (sums[i] == 0) continue; if (slices < 0) { - slices = sizes[i]; - trigJ = peak; - } else if (slices != sizes[i] || trigJ != peak) return false; + slices = sizes[i]; + trigJ = peak; + } else if (slices != sizes[i] || trigJ != peak) return false; } } const LVL1::JEMHits* const hits = findJetHits(crate, mod); if (hits) { const unsigned int sum = std::accumulate((hits->JetHitsVec()).begin(), - (hits->JetHitsVec()).end(), 0); + (hits->JetHitsVec()).end(), 0); if (sum) { const int size = (hits->JetHitsVec()).size(); - const int peak = hits->peak(); + const int peak = hits->peak(); if (slices < 0) { - slices = size; - trigJ = peak; + slices = size; + trigJ = peak; } else if (slices != size || trigJ != peak) return false; } } @@ -1666,15 +1669,15 @@ bool JepByteStreamV1Tool::slinkSlices(const int crate, const int module, const int peak = et->peak(); for (int i = 0; i < numdat; ++i) { if (sums[i] == 0) continue; - if (slices < 0) { - slices = sizes[i]; - trigJ = peak; + if (slices < 0) { + slices = sizes[i]; + trigJ = peak; } else if (slices != sizes[i] || trigJ != peak) return false; } } } // CMM last slink of crate - if (module/modulesPerSlink == m_slinks - 1) { + if (module / modulesPerSlink == m_slinks - 1) { const int maxDataID1 = LVL1::CMMJetHits::MAXID; const int maxDataID2 = LVL1::CMMEtSums::MAXID; const int maxDataID = (maxDataID1 > maxDataID2) ? maxDataID1 : maxDataID2; @@ -1686,17 +1689,17 @@ bool JepByteStreamV1Tool::slinkSlices(const int crate, const int module, if (dataID < maxDataID1) hits = findCmmHits(crate, dataID); if (hits) { sums[0] = std::accumulate((hits->HitsVec()).begin(), - (hits->HitsVec()).end(), 0); + (hits->HitsVec()).end(), 0); sums[1] = std::accumulate((hits->ErrorVec()).begin(), - (hits->ErrorVec()).end(), 0); + (hits->ErrorVec()).end(), 0); sizes[0] = (hits->HitsVec()).size(); sizes[1] = (hits->ErrorVec()).size(); const int peak = hits->peak(); for (int i = 0; i < 2; ++i) { if (sums[i] == 0) continue; if (slices < 0) { - slices = sizes[i]; - trigJ = peak; + slices = sizes[i]; + trigJ = peak; } else if (slices != sizes[i] || trigJ != peak) return false; } } @@ -1704,7 +1707,7 @@ bool JepByteStreamV1Tool::slinkSlices(const int crate, const int module, if (dataID < maxDataID2) et = findCmmSums(crate, dataID); if (et) { sums[0] = std::accumulate((et->ExVec()).begin(), - (et->ExVec()).end(), 0); + (et->ExVec()).end(), 0); sums[1] = std::accumulate((et->EyVec()).begin(), (et->EyVec()).end(), 0); sums[2] = std::accumulate((et->EtVec()).begin(), @@ -1724,9 +1727,9 @@ bool JepByteStreamV1Tool::slinkSlices(const int crate, const int module, const int peak = et->peak(); for (int i = 0; i < numdat; ++i) { if (sums[i] == 0) continue; - if (slices < 0) { - slices = sizes[i]; - trigJ = peak; + if (slices < 0) { + slices = sizes[i]; + trigJ = peak; } else if (slices != sizes[i] || trigJ != peak) return false; } } diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV2Tool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV2Tool.cxx index 1036e4f8d146bab2de4369f40076436ac75391b5..9534f9d6b7cbccf9b9274256ec864c1d81992e3c 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV2Tool.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV2Tool.cxx @@ -361,7 +361,7 @@ StatusCode JepByteStreamV2Tool::convert(const LVL1::JEPBSCollectionV2* const jep // Pack and write the sub-blocks - DataVector<JemSubBlockV2>::const_iterator pos; + DataVector<JemSubBlockV2>::iterator pos; for (pos = m_jemBlocks.begin(); pos != m_jemBlocks.end(); ++pos) { JemSubBlockV2* const subBlock = *pos; if ( !subBlock->pack()) { @@ -456,7 +456,7 @@ StatusCode JepByteStreamV2Tool::convert(const LVL1::JEPBSCollectionV2* const jep } } } - DataVector<CmxEnergySubBlock>::const_iterator pos; + DataVector<CmxEnergySubBlock>::iterator pos; pos = m_cmxEnergyBlocks.begin(); for (; pos != m_cmxEnergyBlocks.end(); ++pos) { CmxEnergySubBlock* const subBlock = *pos; @@ -552,7 +552,7 @@ StatusCode JepByteStreamV2Tool::convert(const LVL1::JEPBSCollectionV2* const jep } } } - DataVector<CmxJetSubBlock>::const_iterator jos; + DataVector<CmxJetSubBlock>::iterator jos; jos = m_cmxJetBlocks.begin(); for (; jos != m_cmxJetBlocks.end(); ++jos) { CmxJetSubBlock* const subBlock = *jos; diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepRoiByteStreamTool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepRoiByteStreamTool.cxx index 53193184b2d903a634dbb44d3287e9a836c73229..f0fd0c9bee6b01ff98c26c875ad0c4e3a400f141 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepRoiByteStreamTool.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepRoiByteStreamTool.cxx @@ -35,7 +35,7 @@ namespace LVL1BS { // Interface ID static const InterfaceID IID_IJepRoiByteStreamTool("JepRoiByteStreamTool", - 1, 1); + 1, 1); const InterfaceID& JepRoiByteStreamTool::interfaceID() { @@ -45,8 +45,8 @@ const InterfaceID& JepRoiByteStreamTool::interfaceID() // Constructor JepRoiByteStreamTool::JepRoiByteStreamTool(const std::string& type, - const std::string& name, - const IInterface* parent) + const std::string& name, + const IInterface* parent) : AthAlgTool(type, name, parent), m_errorTool("LVL1BS::L1CaloErrorByteStreamTool/L1CaloErrorByteStreamTool"), m_crates(2), m_modules(16), m_srcIdMap(0), m_subBlock(0), m_rodStatus(0), @@ -120,8 +120,8 @@ StatusCode JepRoiByteStreamTool::finalize() // Conversion bytestream to JEM RoI StatusCode JepRoiByteStreamTool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - DataVector<LVL1::JEMRoI>* const jeCollection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + DataVector<LVL1::JEMRoI>* const jeCollection) { m_jeCollection = jeCollection; return convertBs(robFrags, JEM_ROI); @@ -130,8 +130,8 @@ StatusCode JepRoiByteStreamTool::convert( // Conversion bytestream to CMM RoI StatusCode JepRoiByteStreamTool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - LVL1::CMMRoI* const cmCollection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + LVL1::CMMRoI* const cmCollection) { m_cmCollection = cmCollection; return convertBs(robFrags, CMM_ROI); @@ -140,8 +140,8 @@ StatusCode JepRoiByteStreamTool::convert( // Conversion of JEP container to bytestream StatusCode JepRoiByteStreamTool::convert( - const LVL1::JEPRoIBSCollection* const jep, - RawEventWrite* const re) + const LVL1::JEPRoIBSCollection* const jep, + RawEventWrite* const re) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -171,30 +171,30 @@ StatusCode JepRoiByteStreamTool::convert( // Loop over JEM RoI data const int modulesPerSlink = m_modules / m_slinks; - for (int crate=0; crate < m_crates; ++crate) { + for (int crate = 0; crate < m_crates; ++crate) { const int hwCrate = crate + m_crateOffsetHw; - for (int module=0; module < m_modules; ++module) { + for (int module = 0; module < m_modules; ++module) { // Pack required number of modules per slink - if (module%modulesPerSlink == 0) { - const int daqOrRoi = 1; - const int slink = module/modulesPerSlink; + if (module % modulesPerSlink == 0) { + const int daqOrRoi = 1; + const int slink = module / modulesPerSlink; if (debug) { msg() << "Treating crate " << hwCrate - << " slink " << slink << endreq - << "Data Version/Format: " << m_version - << " " << m_dataFormat << endreq; + << " slink " << slink << endreq + << "Data Version/Format: " << m_version + << " " << m_dataFormat << endreq; } - const uint32_t rodIdJem = m_srcIdMap->getRodID(hwCrate, slink, daqOrRoi, - m_subDetector); - theROD = m_fea->getRodData(rodIdJem); + const uint32_t rodIdJem = m_srcIdMap->getRodID(hwCrate, slink, daqOrRoi, + m_subDetector); + theROD = m_fea->getRodData(rodIdJem); if (neutralFormat) { const L1CaloUserHeader userHeader; - theROD->push_back(userHeader.header()); + theROD->push_back(userHeader.header()); } - m_rodStatusMap.insert(make_pair(rodIdJem, m_rodStatus)); + m_rodStatusMap.insert(make_pair(rodIdJem, m_rodStatus)); } if (debug) msg() << "JEM Module " << module << endreq; if (!theROD) break; // for coverity, shouldn't happen @@ -203,20 +203,20 @@ StatusCode JepRoiByteStreamTool::convert( if (neutralFormat) { m_subBlock->clear(); - m_subBlock->setRoiHeader(m_version, hwCrate, module); + m_subBlock->setRoiHeader(m_version, hwCrate, module); } // Find JEM RoIs for this module for (; mapIter != mapIterEnd; ++mapIter) { const LVL1::JEMRoI* const roi = mapIter->second; - if (roi->crate() < crate) continue; - if (roi->crate() > crate) break; - if (roi->jem() < module) continue; - if (roi->jem() > module) break; - if (roi->hits() || roi->error()) { - if (neutralFormat) m_subBlock->fillRoi(*roi); - else theROD->push_back(roi->roiWord()); + if (roi->crate() < crate) continue; + if (roi->crate() > crate) break; + if (roi->jem() < module) continue; + if (roi->jem() > module) break; + if (roi->hits() || roi->error()) { + if (neutralFormat) m_subBlock->fillRoi(*roi); + else theROD->push_back(roi->roiWord()); } } @@ -224,14 +224,14 @@ StatusCode JepRoiByteStreamTool::convert( if (neutralFormat) { if ( !m_subBlock->pack()) { - msg(MSG::ERROR) << "JEM RoI sub-block packing failed" << endreq; - return StatusCode::FAILURE; + msg(MSG::ERROR) << "JEM RoI sub-block packing failed" << endreq; + return StatusCode::FAILURE; + } + if (debug) { + msg() << "JEM RoI sub-block data words: " + << m_subBlock->dataWords() << endreq; } - if (debug) { - msg() << "JEM RoI sub-block data words: " - << m_subBlock->dataWords() << endreq; - } - m_subBlock->write(theROD); + m_subBlock->write(theROD); } } if (!theROD) break; // for coverity, shouldn't happen @@ -252,27 +252,30 @@ StatusCode JepRoiByteStreamTool::convert( const int cmmEnergyVersion = 2; // with Missing-ET-Sig enBlock.setCmmHeader(cmmEnergyVersion, m_dataFormat, slice, hwCrate, CmmSubBlock::SYSTEM, CmmSubBlock::CMM_ENERGY, - CmmSubBlock::LEFT, timeslices); + CmmSubBlock::LEFT, timeslices); int maxDataID = static_cast<int>(LVL1::CMMEtSums::MAXID); for (int dataID = 0; dataID < maxDataID; ++dataID) { int source = dataID; if (dataID >= m_modules) { - switch (dataID) { - case LVL1::CMMEtSums::LOCAL: - source = CmmEnergySubBlock::LOCAL; - break; - case LVL1::CMMEtSums::REMOTE: - source = CmmEnergySubBlock::REMOTE; - break; - case LVL1::CMMEtSums::TOTAL: - source = CmmEnergySubBlock::TOTAL; - break; - case LVL1::CMMEtSums::MISSING_ET_MAP: - case LVL1::CMMEtSums::SUM_ET_MAP: - case LVL1::CMMEtSums::MISSING_ET_SIG_MAP: - break; - default: - continue; + // coverity[mixed_enums : FALSE] + // coverity[switch_on_enum : FALSE] + // coverity[first_enum_type : FALSE] + switch (dataID) { + case LVL1::CMMEtSums::LOCAL: + source = CmmEnergySubBlock::LOCAL; + break; + case LVL1::CMMEtSums::REMOTE: + source = CmmEnergySubBlock::REMOTE; + break; + case LVL1::CMMEtSums::TOTAL: + source = CmmEnergySubBlock::TOTAL; + break; + case LVL1::CMMEtSums::MISSING_ET_MAP: + case LVL1::CMMEtSums::SUM_ET_MAP: + case LVL1::CMMEtSums::MISSING_ET_SIG_MAP: + break; + default: + continue; } } const LVL1::CMMEtSums* const sums = findCmmSums(crate, dataID); @@ -283,24 +286,24 @@ StatusCode JepRoiByteStreamTool::convert( const int exErr = sums->ExError(); const int eyErr = sums->EyError(); const int etErr = sums->EtError(); - if (dataID == LVL1::CMMEtSums::MISSING_ET_MAP) { - enBlock.setMissingEtHits(slice, et); + if (dataID == LVL1::CMMEtSums::MISSING_ET_MAP) { + enBlock.setMissingEtHits(slice, et); } else if (dataID == LVL1::CMMEtSums::SUM_ET_MAP) { - enBlock.setSumEtHits(slice, et); - } else if (dataID == LVL1::CMMEtSums::MISSING_ET_SIG_MAP) { - enBlock.setMissingEtSigHits(slice, et); + enBlock.setSumEtHits(slice, et); + } else if (dataID == LVL1::CMMEtSums::MISSING_ET_SIG_MAP) { + enBlock.setMissingEtSigHits(slice, et); } else { - enBlock.setSubsums(slice, source, ex, ey, et, exErr, eyErr, etErr); + enBlock.setSubsums(slice, source, ex, ey, et, exErr, eyErr, etErr); } } } if ( !enBlock.pack()) { msg(MSG::ERROR) << "CMM-Energy sub-block packing failed" << endreq; - return StatusCode::FAILURE; + return StatusCode::FAILURE; } if (debug) { - msg() << "CMM-Energy sub-block data words: " - << enBlock.dataWords() << endreq; + msg() << "CMM-Energy sub-block data words: " + << enBlock.dataWords() << endreq; } enBlock.write(theROD); @@ -309,54 +312,54 @@ StatusCode JepRoiByteStreamTool::convert( CmmJetSubBlock jetBlock; jetBlock.setCmmHeader(m_version, m_dataFormat, slice, hwCrate, CmmSubBlock::SYSTEM, CmmSubBlock::CMM_JET, - CmmSubBlock::RIGHT, timeslices); + CmmSubBlock::RIGHT, timeslices); maxDataID = static_cast<int>(LVL1::CMMJetHits::MAXID); for (int dataID = 0; dataID < maxDataID; ++dataID) { int source = dataID; if (dataID >= m_modules) { - switch (dataID) { - case LVL1::CMMJetHits::LOCAL_MAIN: - source = CmmJetSubBlock::LOCAL_MAIN; - break; - case LVL1::CMMJetHits::REMOTE_MAIN: - source = CmmJetSubBlock::REMOTE_MAIN; - break; - case LVL1::CMMJetHits::TOTAL_MAIN: - source = CmmJetSubBlock::TOTAL_MAIN; - break; - case LVL1::CMMJetHits::LOCAL_FORWARD: - source = CmmJetSubBlock::LOCAL_FORWARD; - break; - case LVL1::CMMJetHits::REMOTE_FORWARD: - source = CmmJetSubBlock::REMOTE_FORWARD; - break; - case LVL1::CMMJetHits::TOTAL_FORWARD: - source = CmmJetSubBlock::TOTAL_FORWARD; - break; - case LVL1::CMMJetHits::ET_MAP: - break; - default: - continue; + switch (dataID) { + case LVL1::CMMJetHits::LOCAL_MAIN: + source = CmmJetSubBlock::LOCAL_MAIN; + break; + case LVL1::CMMJetHits::REMOTE_MAIN: + source = CmmJetSubBlock::REMOTE_MAIN; + break; + case LVL1::CMMJetHits::TOTAL_MAIN: + source = CmmJetSubBlock::TOTAL_MAIN; + break; + case LVL1::CMMJetHits::LOCAL_FORWARD: + source = CmmJetSubBlock::LOCAL_FORWARD; + break; + case LVL1::CMMJetHits::REMOTE_FORWARD: + source = CmmJetSubBlock::REMOTE_FORWARD; + break; + case LVL1::CMMJetHits::TOTAL_FORWARD: + source = CmmJetSubBlock::TOTAL_FORWARD; + break; + case LVL1::CMMJetHits::ET_MAP: + break; + default: + continue; } } const LVL1::CMMJetHits* const ch = findCmmHits(crate, dataID); if ( ch ) { const unsigned int hits = ch->Hits(); const int errs = ch->Error(); - if (dataID == LVL1::CMMJetHits::ET_MAP) { - jetBlock.setJetEtMap(slice, hits); + if (dataID == LVL1::CMMJetHits::ET_MAP) { + jetBlock.setJetEtMap(slice, hits); } else { - jetBlock.setJetHits(slice, source, hits, errs); + jetBlock.setJetHits(slice, source, hits, errs); } } } if ( !jetBlock.pack()) { msg(MSG::ERROR) << "CMM-Jet sub-block packing failed" << endreq; - return StatusCode::FAILURE; + return StatusCode::FAILURE; } if (debug) { - msg() << "CMM-Jet sub-block data words: " - << jetBlock.dataWords() << endreq; + msg() << "CMM-Jet sub-block data words: " + << jetBlock.dataWords() << endreq; } jetBlock.write(theROD); @@ -366,22 +369,22 @@ StatusCode JepRoiByteStreamTool::convert( const LVL1::CMMRoI* const roi = jep->CmmRoi(); if ( roi ) { - // Make sure word IDs are correct + // Make sure word IDs are correct const LVL1::CMMRoI roid(roi->jetEtHits(), roi->sumEtHits(), - roi->missingEtHits(), roi->missingEtSigHits(), - roi->ex(), roi->ey(), roi->et(), - roi->jetEtError(), roi->sumEtError(), - roi->missingEtError(), roi->missingEtSigError(), - roi->exError(), roi->eyError(), roi->etError()); + roi->missingEtHits(), roi->missingEtSigHits(), + roi->ex(), roi->ey(), roi->et(), + roi->jetEtError(), roi->sumEtError(), + roi->missingEtError(), roi->missingEtSigError(), + roi->exError(), roi->eyError(), roi->etError()); if (roid.jetEtHits() || roid.jetEtError()) { theROD->push_back(roid.jetEtRoiWord()); } // CMM-Energy RoIs are not zero-supressed unless all are zero - if (roid.sumEtHits() || roid.missingEtHits() || - roid.missingEtSigHits() || roid.ex() || roid.ey() || roid.et() || - roid.sumEtError() || roid.missingEtError() || - roid.missingEtSigError() || roid.exError() || roid.eyError() || - roid.etError()) { + if (roid.sumEtHits() || roid.missingEtHits() || + roid.missingEtSigHits() || roid.ex() || roid.ey() || roid.et() || + roid.sumEtError() || roid.missingEtError() || + roid.missingEtSigError() || roid.exError() || roid.eyError() || + roid.etError()) { theROD->push_back(roid.energyRoiWord0()); theROD->push_back(roid.energyRoiWord1()); theROD->push_back(roid.energyRoiWord2()); @@ -404,12 +407,12 @@ StatusCode JepRoiByteStreamTool::convert( // Return reference to vector with all possible Source Identifiers const std::vector<uint32_t>& JepRoiByteStreamTool::sourceIDs( - const std::string& sgKey) + const std::string& sgKey) { const std::string flag("RoIB"); const std::string::size_type pos = sgKey.find(flag); const bool roiDaq = - (pos == std::string::npos || pos != sgKey.length() - flag.length()); + (pos == std::string::npos || pos != sgKey.length() - flag.length()); const bool empty = (roiDaq) ? m_sourceIDs.empty() : m_sourceIDsRoIB.empty(); if (empty) { const int maxCrates = m_crates + m_crateOffsetHw; @@ -418,11 +421,11 @@ const std::vector<uint32_t>& JepRoiByteStreamTool::sourceIDs( for (int slink = 0; slink < maxSlinks; ++slink) { const int daqOrRoi = 1; const uint32_t rodId = m_srcIdMap->getRodID(hwCrate, slink, daqOrRoi, - m_subDetector); + m_subDetector); const uint32_t robId = m_srcIdMap->getRobID(rodId); - if (roiDaq) { - if (slink < 2) m_sourceIDs.push_back(robId); - } else if (slink >= 2) m_sourceIDsRoIB.push_back(robId); + if (roiDaq) { + if (slink < 2) m_sourceIDs.push_back(robId); + } else if (slink >= 2) m_sourceIDsRoIB.push_back(robId); } } } @@ -432,8 +435,8 @@ const std::vector<uint32_t>& JepRoiByteStreamTool::sourceIDs( // Convert bytestream to given container type StatusCode JepRoiByteStreamTool::convertBs( - const IROBDataProviderSvc::VROBFRAG& robFrags, - const CollectionType collection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + const CollectionType collection) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -460,8 +463,8 @@ StatusCode JepRoiByteStreamTool::convertBs( (*rob)->status(robData); if (*robData != 0) { m_errorTool->robError(robid, *robData); - if (debug) msg() << "ROB status error - skipping fragment" << endreq; - continue; + if (debug) msg() << "ROB status error - skipping fragment" << endreq; + continue; } } @@ -490,20 +493,20 @@ StatusCode JepRoiByteStreamTool::convertBs( const uint32_t sourceID = (*rob)->rod_source_id(); if (m_srcIdMap->getRobID(sourceID) != robid || m_srcIdMap->subDet(sourceID) != m_subDetector || - m_srcIdMap->daqOrRoi(sourceID) != 1 || - (m_srcIdMap->slink(sourceID) != 0 && m_srcIdMap->slink(sourceID) != 2) || + m_srcIdMap->daqOrRoi(sourceID) != 1 || + (m_srcIdMap->slink(sourceID) != 0 && m_srcIdMap->slink(sourceID) != 2) || m_srcIdMap->crate(sourceID) < m_crateOffsetHw || - m_srcIdMap->crate(sourceID) >= m_crateOffsetHw + m_crates) { + m_srcIdMap->crate(sourceID) >= m_crateOffsetHw + m_crates) { m_errorTool->rodError(robid, L1CaloSubBlock::ERROR_ROD_ID); if (debug) { msg() << "Wrong source identifier in data: " - << MSG::hex << sourceID << MSG::dec << endreq; + << MSG::hex << sourceID << MSG::dec << endreq; } continue; } const int rodCrate = m_srcIdMap->crate(sourceID); if (debug) { - msg() << "Treating crate " << rodCrate + msg() << "Treating crate " << rodCrate << " slink " << m_srcIdMap->slink(sourceID) << endreq; } @@ -516,7 +519,7 @@ StatusCode JepRoiByteStreamTool::convertBs( if (headerWords != 1) { m_errorTool->rodError(robid, L1CaloSubBlock::ERROR_USER_HEADER); if (debug) msg() << "Unexpected number of user header words: " - << headerWords << endreq; + << headerWords << endreq; continue; } for (int i = 0; i < headerWords; ++i) ++payload; @@ -526,128 +529,128 @@ StatusCode JepRoiByteStreamTool::convertBs( unsigned int rodErr = L1CaloSubBlock::ERROR_NONE; while (payload != payloadEnd) { - + if (L1CaloSubBlock::wordType(*payload) == L1CaloSubBlock::HEADER) { - const int slice = 0; + const int slice = 0; if (CmmSubBlock::cmmBlock(*payload)) { // CMMs - if (CmmSubBlock::cmmType(*payload) == CmmSubBlock::CMM_JET) { + if (CmmSubBlock::cmmType(*payload) == CmmSubBlock::CMM_JET) { CmmJetSubBlock subBlock; payload = subBlock.read(payload, payloadEnd); - if (collection == CMM_ROI) { - if (subBlock.dataWords() && !subBlock.unpack()) { - if (debug) { - std::string errMsg(subBlock.unpackErrorMsg()); - msg() << "CMM-Jet sub-block unpacking failed: " - << errMsg << endreq; - } - rodErr = m_subBlock->unpackErrorCode(); - break; + if (collection == CMM_ROI) { + if (subBlock.dataWords() && !subBlock.unpack()) { + if (debug) { + std::string errMsg(subBlock.unpackErrorMsg()); + msg() << "CMM-Jet sub-block unpacking failed: " + << errMsg << endreq; + } + rodErr = m_subBlock->unpackErrorCode(); + break; } - const LVL1::CMMRoI roi(subBlock.jetEtMap(slice), - 0,0,0,0,0,0,0,0,0,0,0,0,0); - m_cmCollection->setRoiWord(roi.jetEtRoiWord()); + const LVL1::CMMRoI roi(subBlock.jetEtMap(slice), + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + m_cmCollection->setRoiWord(roi.jetEtRoiWord()); } } else { - CmmEnergySubBlock subBlock; - payload = subBlock.read(payload, payloadEnd); - if (collection == CMM_ROI) { - if (subBlock.dataWords() && !subBlock.unpack()) { - if (debug) { - std::string errMsg(subBlock.unpackErrorMsg()); - msg() << "CMM-Energy sub-block unpacking failed: " - << errMsg << endreq; - } - rodErr = m_subBlock->unpackErrorCode(); - break; + CmmEnergySubBlock subBlock; + payload = subBlock.read(payload, payloadEnd); + if (collection == CMM_ROI) { + if (subBlock.dataWords() && !subBlock.unpack()) { + if (debug) { + std::string errMsg(subBlock.unpackErrorMsg()); + msg() << "CMM-Energy sub-block unpacking failed: " + << errMsg << endreq; + } + rodErr = m_subBlock->unpackErrorCode(); + break; } - const LVL1::CMMRoI roi(0, subBlock.sumEtHits(slice), - subBlock.missingEtHits(slice), - subBlock.missingEtSigHits(slice), - subBlock.ex(slice, CmmEnergySubBlock::TOTAL), - subBlock.ey(slice, CmmEnergySubBlock::TOTAL), - subBlock.et(slice, CmmEnergySubBlock::TOTAL), - 0, 0, 0, 0, - subBlock.exError(slice, CmmEnergySubBlock::TOTAL), - subBlock.eyError(slice, CmmEnergySubBlock::TOTAL), - subBlock.etError(slice, CmmEnergySubBlock::TOTAL)); - m_cmCollection->setRoiWord(roi.energyRoiWord0()); - m_cmCollection->setRoiWord(roi.energyRoiWord1()); - m_cmCollection->setRoiWord(roi.energyRoiWord2()); + const LVL1::CMMRoI roi(0, subBlock.sumEtHits(slice), + subBlock.missingEtHits(slice), + subBlock.missingEtSigHits(slice), + subBlock.ex(slice, CmmEnergySubBlock::TOTAL), + subBlock.ey(slice, CmmEnergySubBlock::TOTAL), + subBlock.et(slice, CmmEnergySubBlock::TOTAL), + 0, 0, 0, 0, + subBlock.exError(slice, CmmEnergySubBlock::TOTAL), + subBlock.eyError(slice, CmmEnergySubBlock::TOTAL), + subBlock.etError(slice, CmmEnergySubBlock::TOTAL)); + m_cmCollection->setRoiWord(roi.energyRoiWord0()); + m_cmCollection->setRoiWord(roi.energyRoiWord1()); + m_cmCollection->setRoiWord(roi.energyRoiWord2()); } - } + } } else { // JEM RoI JemRoiSubBlock subBlock; payload = subBlock.read(payload, payloadEnd); - if (collection == JEM_ROI) { - if (subBlock.dataWords() && !subBlock.unpack()) { - if (debug) { - std::string errMsg(subBlock.unpackErrorMsg()); - msg() << "JEM RoI sub-block unpacking failed: " - << errMsg << endreq; - } + if (collection == JEM_ROI) { + if (subBlock.dataWords() && !subBlock.unpack()) { + if (debug) { + std::string errMsg(subBlock.unpackErrorMsg()); + msg() << "JEM RoI sub-block unpacking failed: " + << errMsg << endreq; + } rodErr = m_subBlock->unpackErrorCode(); break; } - for (int frame = 0; frame < 8; ++frame) { - for (int forward = 0; forward < 2; ++forward) { - const LVL1::JEMRoI roi = subBlock.roi(frame, forward); - if (roi.hits() || roi.error()) { - m_jeCollection->push_back(new LVL1::JEMRoI(roi)); - } - } - } + for (int frame = 0; frame < 8; ++frame) { + for (int forward = 0; forward < 2; ++forward) { + const LVL1::JEMRoI roi = subBlock.roi(frame, forward); + if (roi.hits() || roi.error()) { + m_jeCollection->push_back(new LVL1::JEMRoI(roi)); + } + } + } } } } else { // Just RoI word - LVL1::JEMRoI jroi; - LVL1::CMMRoI croi; - if (jroi.setRoiWord(*payload)) { - if (collection == JEM_ROI) { - if (jroi.crate() != rodCrate - m_crateOffsetHw) { - if (debug) msg() << "Inconsistent RoI crate number: " - << jroi.crate() << endreq; + LVL1::JEMRoI jroi; + LVL1::CMMRoI croi; + if (jroi.setRoiWord(*payload)) { + if (collection == JEM_ROI) { + if (jroi.crate() != rodCrate - m_crateOffsetHw) { + if (debug) msg() << "Inconsistent RoI crate number: " + << jroi.crate() << endreq; rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; - break; + break; } - const uint32_t location = (*payload) & 0xfffc0000; - if (dupRoiCheck.insert(location).second) { - if (jroi.hits() || jroi.error()) { - m_jeCollection->push_back(new LVL1::JEMRoI(*payload)); - } - } else { - if (debug) msg() << "Duplicate RoI word " - << MSG::hex << *payload << MSG::dec << endreq; + const uint32_t location = (*payload) & 0xfffc0000; + if (dupRoiCheck.insert(location).second) { + if (jroi.hits() || jroi.error()) { + m_jeCollection->push_back(new LVL1::JEMRoI(*payload)); + } + } else { + if (debug) msg() << "Duplicate RoI word " + << MSG::hex << *payload << MSG::dec << endreq; rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - break; + break; } - } + } } else if (croi.setRoiWord(*payload)) { - if (collection == CMM_ROI) { - uint32_t roiType = (*payload) & 0xf0000000; - if ((roiType & 0xe0000000) == 0xa0000000) roiType = 0xa0000000; - if (dupRoiCheck.insert(roiType).second) { - m_cmCollection->setRoiWord(*payload); - } else { - if (debug) msg() << "Duplicate RoI word " - << MSG::hex << *payload << MSG::dec << endreq; + if (collection == CMM_ROI) { + uint32_t roiType = (*payload) & 0xf0000000; + if ((roiType & 0xe0000000) == 0xa0000000) roiType = 0xa0000000; + if (dupRoiCheck.insert(roiType).second) { + m_cmCollection->setRoiWord(*payload); + } else { + if (debug) msg() << "Duplicate RoI word " + << MSG::hex << *payload << MSG::dec << endreq; rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - break; + break; } - } + } } else { - if (debug) msg() << "Invalid RoI word " - << MSG::hex << *payload << MSG::dec << endreq; - rodErr = L1CaloSubBlock::ERROR_ROI_TYPE; - break; + if (debug) msg() << "Invalid RoI word " + << MSG::hex << *payload << MSG::dec << endreq; + rodErr = L1CaloSubBlock::ERROR_ROI_TYPE; + break; } - ++payload; + ++payload; } } if (rodErr != L1CaloSubBlock::ERROR_NONE) - m_errorTool->rodError(robid, rodErr); + m_errorTool->rodError(robid, rodErr); } return StatusCode::SUCCESS; @@ -656,11 +659,11 @@ StatusCode JepRoiByteStreamTool::convertBs( // Find CMM hits for given crate, dataID const LVL1::CMMJetHits* JepRoiByteStreamTool::findCmmHits(const int crate, - const int dataID) + const int dataID) { const LVL1::CMMJetHits* hits = 0; CmmHitsMap::const_iterator mapIter; - mapIter = m_cmmHitsMap.find(crate*100 + dataID); + mapIter = m_cmmHitsMap.find(crate * 100 + dataID); if (mapIter != m_cmmHitsMap.end()) hits = mapIter->second; return hits; } @@ -668,11 +671,11 @@ const LVL1::CMMJetHits* JepRoiByteStreamTool::findCmmHits(const int crate, // Find CMM energy sums for given crate, module, dataID const LVL1::CMMEtSums* JepRoiByteStreamTool::findCmmSums(const int crate, - const int dataID) + const int dataID) { const LVL1::CMMEtSums* sums = 0; CmmSumsMap::const_iterator mapIter; - mapIter = m_cmmEtMap.find(crate*100 + dataID); + mapIter = m_cmmEtMap.find(crate * 100 + dataID); if (mapIter != m_cmmEtMap.end()) sums = mapIter->second; return sums; } @@ -680,7 +683,7 @@ const LVL1::CMMEtSums* JepRoiByteStreamTool::findCmmSums(const int crate, // Set up JEM RoIs map void JepRoiByteStreamTool::setupJemRoiMap(const JemRoiCollection* - const jeCollection) + const jeCollection) { m_roiMap.clear(); if (jeCollection) { @@ -697,7 +700,7 @@ void JepRoiByteStreamTool::setupJemRoiMap(const JemRoiCollection* // Set up CMM hits map void JepRoiByteStreamTool::setupCmmHitsMap(const CmmHitsCollection* - const hitCollection) + const hitCollection) { m_cmmHitsMap.clear(); if (hitCollection) { @@ -706,7 +709,7 @@ void JepRoiByteStreamTool::setupCmmHitsMap(const CmmHitsCollection* for (; pos != pose; ++pos) { const LVL1::CMMJetHits* const hits = *pos; const int crate = hits->crate() - m_crateOffsetSw; - const int key = crate*100 + hits->dataID(); + const int key = crate * 100 + hits->dataID(); m_cmmHitsMap.insert(std::make_pair(key, hits)); } } @@ -715,7 +718,7 @@ void JepRoiByteStreamTool::setupCmmHitsMap(const CmmHitsCollection* // Set up CMM energy sums map void JepRoiByteStreamTool::setupCmmEtMap(const CmmSumsCollection* - const etCollection) + const etCollection) { m_cmmEtMap.clear(); if (etCollection) { @@ -724,7 +727,7 @@ void JepRoiByteStreamTool::setupCmmEtMap(const CmmSumsCollection* for (; pos != pose; ++pos) { const LVL1::CMMEtSums* const sums = *pos; const int crate = sums->crate() - m_crateOffsetSw; - const int key = crate*100 + sums->dataID(); + const int key = crate * 100 + sums->dataID(); m_cmmEtMap.insert(std::make_pair(key, sums)); } } diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepRoiByteStreamV1Tool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepRoiByteStreamV1Tool.cxx index 4e8ce822b5c1440a3d30b1785bfa69866e5857d3..30fbed0c7378c8f61bde2ea504c915ef74b4d73a 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepRoiByteStreamV1Tool.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepRoiByteStreamV1Tool.cxx @@ -35,7 +35,7 @@ namespace LVL1BS { // Interface ID static const InterfaceID IID_IJepRoiByteStreamV1Tool("JepRoiByteStreamV1Tool", - 1, 1); + 1, 1); const InterfaceID& JepRoiByteStreamV1Tool::interfaceID() { @@ -45,8 +45,8 @@ const InterfaceID& JepRoiByteStreamV1Tool::interfaceID() // Constructor JepRoiByteStreamV1Tool::JepRoiByteStreamV1Tool(const std::string& type, - const std::string& name, - const IInterface* parent) + const std::string& name, + const IInterface* parent) : AthAlgTool(type, name, parent), m_errorTool("LVL1BS::L1CaloErrorByteStreamTool/L1CaloErrorByteStreamTool"), m_crates(2), m_modules(16), m_srcIdMap(0), m_subBlock(0), m_rodStatus(0), @@ -76,7 +76,7 @@ JepRoiByteStreamV1Tool::JepRoiByteStreamV1Tool(const std::string& type, "The number of S-Links per crate"); declareProperty("CrateMin", m_crateMin = 0, "Minimum crate number, allows partial output"); - declareProperty("CrateMax", m_crateMax = m_crates-1, + declareProperty("CrateMax", m_crateMax = m_crates - 1, "Maximum crate number, allows partial output"); } @@ -126,8 +126,8 @@ StatusCode JepRoiByteStreamV1Tool::finalize() // Conversion bytestream to JEM RoI StatusCode JepRoiByteStreamV1Tool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - DataVector<LVL1::JEMRoI>* const jeCollection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + DataVector<LVL1::JEMRoI>* const jeCollection) { m_jeCollection = jeCollection; return convertBs(robFrags, JEM_ROI); @@ -136,8 +136,8 @@ StatusCode JepRoiByteStreamV1Tool::convert( // Conversion bytestream to CMM RoI StatusCode JepRoiByteStreamV1Tool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - LVL1::CMMRoI* const cmCollection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + LVL1::CMMRoI* const cmCollection) { m_cmCollection = cmCollection; return convertBs(robFrags, CMM_ROI); @@ -146,8 +146,8 @@ StatusCode JepRoiByteStreamV1Tool::convert( // Conversion of JEP container to bytestream StatusCode JepRoiByteStreamV1Tool::convert( - const LVL1::JEPRoIBSCollectionV1* const jep, - RawEventWrite* const re) + const LVL1::JEPRoIBSCollectionV1* const jep, + RawEventWrite* const re) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -180,27 +180,27 @@ StatusCode JepRoiByteStreamV1Tool::convert( for (int crate = m_crateMin; crate <= m_crateMax; ++crate) { const int hwCrate = crate + m_crateOffsetHw; - for (int module=0; module < m_modules; ++module) { + for (int module = 0; module < m_modules; ++module) { // Pack required number of modules per slink - if (module%modulesPerSlink == 0) { - const int daqOrRoi = 1; - const int slink = module/modulesPerSlink; + if (module % modulesPerSlink == 0) { + const int daqOrRoi = 1; + const int slink = module / modulesPerSlink; if (debug) { msg() << "Treating crate " << hwCrate - << " slink " << slink << endreq - << "Data Version/Format: " << m_version - << " " << m_dataFormat << endreq; + << " slink " << slink << endreq + << "Data Version/Format: " << m_version + << " " << m_dataFormat << endreq; } - const uint32_t rodIdJem = m_srcIdMap->getRodID(hwCrate, slink, daqOrRoi, - m_subDetector); - theROD = m_fea->getRodData(rodIdJem); + const uint32_t rodIdJem = m_srcIdMap->getRodID(hwCrate, slink, daqOrRoi, + m_subDetector); + theROD = m_fea->getRodData(rodIdJem); if (neutralFormat) { const L1CaloUserHeader userHeader; - theROD->push_back(userHeader.header()); + theROD->push_back(userHeader.header()); } - m_rodStatusMap.insert(make_pair(rodIdJem, m_rodStatus)); + m_rodStatusMap.insert(make_pair(rodIdJem, m_rodStatus)); } if (debug) msg() << "JEM Module " << module << endreq; if (!theROD) break; // for coverity, shouldn't happen @@ -209,20 +209,20 @@ StatusCode JepRoiByteStreamV1Tool::convert( if (neutralFormat) { m_subBlock->clear(); - m_subBlock->setRoiHeader(m_version, hwCrate, module); + m_subBlock->setRoiHeader(m_version, hwCrate, module); } // Find JEM RoIs for this module for (; mapIter != mapIterEnd; ++mapIter) { const LVL1::JEMRoI* const roi = mapIter->second; - if (roi->crate() < crate) continue; - if (roi->crate() > crate) break; - if (roi->jem() < module) continue; - if (roi->jem() > module) break; - if (roi->hits() || roi->error()) { - if (neutralFormat) m_subBlock->fillRoi(*roi); - else theROD->push_back(roi->roiWord()); + if (roi->crate() < crate) continue; + if (roi->crate() > crate) break; + if (roi->jem() < module) continue; + if (roi->jem() > module) break; + if (roi->hits() || roi->error()) { + if (neutralFormat) m_subBlock->fillRoi(*roi); + else theROD->push_back(roi->roiWord()); } } @@ -230,14 +230,14 @@ StatusCode JepRoiByteStreamV1Tool::convert( if (neutralFormat) { if ( !m_subBlock->pack()) { - msg(MSG::ERROR) << "JEM RoI sub-block packing failed" << endreq; - return StatusCode::FAILURE; + msg(MSG::ERROR) << "JEM RoI sub-block packing failed" << endreq; + return StatusCode::FAILURE; + } + if (debug) { + msg() << "JEM RoI sub-block data words: " + << m_subBlock->dataWords() << endreq; } - if (debug) { - msg() << "JEM RoI sub-block data words: " - << m_subBlock->dataWords() << endreq; - } - m_subBlock->write(theROD); + m_subBlock->write(theROD); } } if (!theROD) break; // for coverity, shouldn't happen @@ -258,27 +258,27 @@ StatusCode JepRoiByteStreamV1Tool::convert( const int cmmEnergyVersion = 2; // with Missing-ET-Sig enBlock.setCmmHeader(cmmEnergyVersion, m_dataFormat, slice, hwCrate, CmmSubBlock::SYSTEM, CmmSubBlock::CMM_ENERGY, - CmmSubBlock::LEFT, timeslices); + CmmSubBlock::LEFT, timeslices); int maxDataID = static_cast<int>(LVL1::CMMEtSums::MAXID); for (int dataID = 0; dataID < maxDataID; ++dataID) { int source = dataID; if (dataID >= m_modules) { - switch (dataID) { - case LVL1::CMMEtSums::LOCAL: - source = CmmEnergySubBlock::LOCAL; - break; - case LVL1::CMMEtSums::REMOTE: - source = CmmEnergySubBlock::REMOTE; - break; - case LVL1::CMMEtSums::TOTAL: - source = CmmEnergySubBlock::TOTAL; - break; - case LVL1::CMMEtSums::MISSING_ET_MAP: - case LVL1::CMMEtSums::SUM_ET_MAP: - case LVL1::CMMEtSums::MISSING_ET_SIG_MAP: - break; - default: - continue; + switch (dataID) { + case LVL1::CMMEtSums::LOCAL: + source = CmmEnergySubBlock::LOCAL; + break; + case LVL1::CMMEtSums::REMOTE: + source = CmmEnergySubBlock::REMOTE; + break; + case LVL1::CMMEtSums::TOTAL: + source = CmmEnergySubBlock::TOTAL; + break; + case LVL1::CMMEtSums::MISSING_ET_MAP: + case LVL1::CMMEtSums::SUM_ET_MAP: + case LVL1::CMMEtSums::MISSING_ET_SIG_MAP: + break; + default: + continue; } } const LVL1::CMMEtSums* const sums = findCmmSums(crate, dataID); @@ -289,24 +289,24 @@ StatusCode JepRoiByteStreamV1Tool::convert( const int exErr = sums->ExError(); const int eyErr = sums->EyError(); const int etErr = sums->EtError(); - if (dataID == LVL1::CMMEtSums::MISSING_ET_MAP) { - enBlock.setMissingEtHits(slice, et); + if (dataID == LVL1::CMMEtSums::MISSING_ET_MAP) { + enBlock.setMissingEtHits(slice, et); } else if (dataID == LVL1::CMMEtSums::SUM_ET_MAP) { - enBlock.setSumEtHits(slice, et); - } else if (dataID == LVL1::CMMEtSums::MISSING_ET_SIG_MAP) { - enBlock.setMissingEtSigHits(slice, et); + enBlock.setSumEtHits(slice, et); + } else if (dataID == LVL1::CMMEtSums::MISSING_ET_SIG_MAP) { + enBlock.setMissingEtSigHits(slice, et); } else { - enBlock.setSubsums(slice, source, ex, ey, et, exErr, eyErr, etErr); + enBlock.setSubsums(slice, source, ex, ey, et, exErr, eyErr, etErr); } } } if ( !enBlock.pack()) { msg(MSG::ERROR) << "CMM-Energy sub-block packing failed" << endreq; - return StatusCode::FAILURE; + return StatusCode::FAILURE; } if (debug) { - msg() << "CMM-Energy sub-block data words: " - << enBlock.dataWords() << endreq; + msg() << "CMM-Energy sub-block data words: " + << enBlock.dataWords() << endreq; } enBlock.write(theROD); @@ -315,54 +315,57 @@ StatusCode JepRoiByteStreamV1Tool::convert( CmmJetSubBlock jetBlock; jetBlock.setCmmHeader(m_version, m_dataFormat, slice, hwCrate, CmmSubBlock::SYSTEM, CmmSubBlock::CMM_JET, - CmmSubBlock::RIGHT, timeslices); + CmmSubBlock::RIGHT, timeslices); maxDataID = static_cast<int>(LVL1::CMMJetHits::MAXID); for (int dataID = 0; dataID < maxDataID; ++dataID) { int source = dataID; if (dataID >= m_modules) { - switch (dataID) { - case LVL1::CMMJetHits::LOCAL_MAIN: - source = CmmJetSubBlock::LOCAL_MAIN; - break; - case LVL1::CMMJetHits::REMOTE_MAIN: - source = CmmJetSubBlock::REMOTE_MAIN; - break; - case LVL1::CMMJetHits::TOTAL_MAIN: - source = CmmJetSubBlock::TOTAL_MAIN; - break; - case LVL1::CMMJetHits::LOCAL_FORWARD: - source = CmmJetSubBlock::LOCAL_FORWARD; - break; - case LVL1::CMMJetHits::REMOTE_FORWARD: - source = CmmJetSubBlock::REMOTE_FORWARD; - break; - case LVL1::CMMJetHits::TOTAL_FORWARD: - source = CmmJetSubBlock::TOTAL_FORWARD; - break; - case LVL1::CMMJetHits::ET_MAP: - break; - default: - continue; + // coverity[mixed_enums : FALSE] + // coverity[switch_on_enum : FALSE] + // coverity[first_enum_type : FALSE] + switch (dataID) { + case LVL1::CMMJetHits::LOCAL_MAIN: + source = CmmJetSubBlock::LOCAL_MAIN; + break; + case LVL1::CMMJetHits::REMOTE_MAIN: + source = CmmJetSubBlock::REMOTE_MAIN; + break; + case LVL1::CMMJetHits::TOTAL_MAIN: + source = CmmJetSubBlock::TOTAL_MAIN; + break; + case LVL1::CMMJetHits::LOCAL_FORWARD: + source = CmmJetSubBlock::LOCAL_FORWARD; + break; + case LVL1::CMMJetHits::REMOTE_FORWARD: + source = CmmJetSubBlock::REMOTE_FORWARD; + break; + case LVL1::CMMJetHits::TOTAL_FORWARD: + source = CmmJetSubBlock::TOTAL_FORWARD; + break; + case LVL1::CMMJetHits::ET_MAP: + break; + default: + continue; } } const LVL1::CMMJetHits* const ch = findCmmHits(crate, dataID); if ( ch ) { const unsigned int hits = ch->Hits(); const int errs = ch->Error(); - if (dataID == LVL1::CMMJetHits::ET_MAP) { - jetBlock.setJetEtMap(slice, hits); + if (dataID == LVL1::CMMJetHits::ET_MAP) { + jetBlock.setJetEtMap(slice, hits); } else { - jetBlock.setJetHits(slice, source, hits, errs); + jetBlock.setJetHits(slice, source, hits, errs); } } } if ( !jetBlock.pack()) { msg(MSG::ERROR) << "CMM-Jet sub-block packing failed" << endreq; - return StatusCode::FAILURE; + return StatusCode::FAILURE; } if (debug) { - msg() << "CMM-Jet sub-block data words: " - << jetBlock.dataWords() << endreq; + msg() << "CMM-Jet sub-block data words: " + << jetBlock.dataWords() << endreq; } jetBlock.write(theROD); @@ -372,22 +375,22 @@ StatusCode JepRoiByteStreamV1Tool::convert( const LVL1::CMMRoI* const roi = jep->CmmRoi(); if ( roi ) { - // Make sure word IDs are correct + // Make sure word IDs are correct const LVL1::CMMRoI roid(roi->jetEtHits(), roi->sumEtHits(), - roi->missingEtHits(), roi->missingEtSigHits(), - roi->ex(), roi->ey(), roi->et(), - roi->jetEtError(), roi->sumEtError(), - roi->missingEtError(), roi->missingEtSigError(), - roi->exError(), roi->eyError(), roi->etError()); + roi->missingEtHits(), roi->missingEtSigHits(), + roi->ex(), roi->ey(), roi->et(), + roi->jetEtError(), roi->sumEtError(), + roi->missingEtError(), roi->missingEtSigError(), + roi->exError(), roi->eyError(), roi->etError()); if (roid.jetEtHits() || roid.jetEtError()) { theROD->push_back(roid.jetEtRoiWord()); } // CMM-Energy RoIs are not zero-supressed unless all are zero - if (roid.sumEtHits() || roid.missingEtHits() || - roid.missingEtSigHits() || roid.ex() || roid.ey() || roid.et() || - roid.sumEtError() || roid.missingEtError() || - roid.missingEtSigError() || roid.exError() || roid.eyError() || - roid.etError()) { + if (roid.sumEtHits() || roid.missingEtHits() || + roid.missingEtSigHits() || roid.ex() || roid.ey() || roid.et() || + roid.sumEtError() || roid.missingEtError() || + roid.missingEtSigError() || roid.exError() || roid.eyError() || + roid.etError()) { theROD->push_back(roid.energyRoiWord0()); theROD->push_back(roid.energyRoiWord1()); theROD->push_back(roid.energyRoiWord2()); @@ -410,12 +413,12 @@ StatusCode JepRoiByteStreamV1Tool::convert( // Return reference to vector with all possible Source Identifiers const std::vector<uint32_t>& JepRoiByteStreamV1Tool::sourceIDs( - const std::string& sgKey) + const std::string& sgKey) { const std::string flag("RoIB"); const std::string::size_type pos = sgKey.find(flag); const bool roiDaq = - (pos == std::string::npos || pos != sgKey.length() - flag.length()); + (pos == std::string::npos || pos != sgKey.length() - flag.length()); const bool empty = (roiDaq) ? m_sourceIDs.empty() : m_sourceIDsRoIB.empty(); if (empty) { const int maxCrates = m_crates + m_crateOffsetHw; @@ -424,11 +427,11 @@ const std::vector<uint32_t>& JepRoiByteStreamV1Tool::sourceIDs( for (int slink = 0; slink < maxSlinks; ++slink) { const int daqOrRoi = 1; const uint32_t rodId = m_srcIdMap->getRodID(hwCrate, slink, daqOrRoi, - m_subDetector); + m_subDetector); const uint32_t robId = m_srcIdMap->getRobID(rodId); - if (roiDaq) { - if (slink < 2) m_sourceIDs.push_back(robId); - } else if (slink >= 2) m_sourceIDsRoIB.push_back(robId); + if (roiDaq) { + if (slink < 2) m_sourceIDs.push_back(robId); + } else if (slink >= 2) m_sourceIDsRoIB.push_back(robId); } } } @@ -438,8 +441,8 @@ const std::vector<uint32_t>& JepRoiByteStreamV1Tool::sourceIDs( // Convert bytestream to given container type StatusCode JepRoiByteStreamV1Tool::convertBs( - const IROBDataProviderSvc::VROBFRAG& robFrags, - const CollectionType collection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + const CollectionType collection) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -466,8 +469,8 @@ StatusCode JepRoiByteStreamV1Tool::convertBs( (*rob)->status(robData); if (*robData != 0) { m_errorTool->robError(robid, *robData); - if (debug) msg() << "ROB status error - skipping fragment" << endreq; - continue; + if (debug) msg() << "ROB status error - skipping fragment" << endreq; + continue; } } @@ -496,14 +499,14 @@ StatusCode JepRoiByteStreamV1Tool::convertBs( const uint32_t sourceID = (*rob)->rod_source_id(); if (m_srcIdMap->getRobID(sourceID) != robid || m_srcIdMap->subDet(sourceID) != m_subDetector || - m_srcIdMap->daqOrRoi(sourceID) != 1 || - (m_srcIdMap->slink(sourceID) != 0 && m_srcIdMap->slink(sourceID) != 2) || + m_srcIdMap->daqOrRoi(sourceID) != 1 || + (m_srcIdMap->slink(sourceID) != 0 && m_srcIdMap->slink(sourceID) != 2) || m_srcIdMap->crate(sourceID) < m_crateOffsetHw || - m_srcIdMap->crate(sourceID) >= m_crateOffsetHw + m_crates) { + m_srcIdMap->crate(sourceID) >= m_crateOffsetHw + m_crates) { m_errorTool->rodError(robid, L1CaloSubBlock::ERROR_ROD_ID); if (debug) { msg() << "Wrong source identifier in data: " - << MSG::hex << sourceID << MSG::dec << endreq; + << MSG::hex << sourceID << MSG::dec << endreq; } continue; } @@ -516,7 +519,7 @@ StatusCode JepRoiByteStreamV1Tool::convertBs( } const int rodCrate = m_srcIdMap->crate(sourceID); if (debug) { - msg() << "Treating crate " << rodCrate + msg() << "Treating crate " << rodCrate << " slink " << m_srcIdMap->slink(sourceID) << endreq; } @@ -528,7 +531,7 @@ StatusCode JepRoiByteStreamV1Tool::convertBs( if (headerWords != 1) { m_errorTool->rodError(robid, L1CaloSubBlock::ERROR_USER_HEADER); if (debug) msg() << "Unexpected number of user header words: " - << headerWords << endreq; + << headerWords << endreq; continue; } for (int i = 0; i < headerWords; ++i) ++payload; @@ -538,128 +541,128 @@ StatusCode JepRoiByteStreamV1Tool::convertBs( unsigned int rodErr = L1CaloSubBlock::ERROR_NONE; while (payload != payloadEnd) { - + if (L1CaloSubBlock::wordType(*payload) == L1CaloSubBlock::HEADER) { - const int slice = 0; + const int slice = 0; if (CmmSubBlock::cmmBlock(*payload)) { // CMMs - if (CmmSubBlock::cmmType(*payload) == CmmSubBlock::CMM_JET) { + if (CmmSubBlock::cmmType(*payload) == CmmSubBlock::CMM_JET) { CmmJetSubBlock subBlock; payload = subBlock.read(payload, payloadEnd); - if (collection == CMM_ROI) { - if (subBlock.dataWords() && !subBlock.unpack()) { - if (debug) { - std::string errMsg(subBlock.unpackErrorMsg()); - msg() << "CMM-Jet sub-block unpacking failed: " - << errMsg << endreq; - } - rodErr = m_subBlock->unpackErrorCode(); - break; + if (collection == CMM_ROI) { + if (subBlock.dataWords() && !subBlock.unpack()) { + if (debug) { + std::string errMsg(subBlock.unpackErrorMsg()); + msg() << "CMM-Jet sub-block unpacking failed: " + << errMsg << endreq; + } + rodErr = m_subBlock->unpackErrorCode(); + break; } - const LVL1::CMMRoI roi(subBlock.jetEtMap(slice), - 0,0,0,0,0,0,0,0,0,0,0,0,0); - m_cmCollection->setRoiWord(roi.jetEtRoiWord()); + const LVL1::CMMRoI roi(subBlock.jetEtMap(slice), + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + m_cmCollection->setRoiWord(roi.jetEtRoiWord()); } } else { - CmmEnergySubBlock subBlock; - payload = subBlock.read(payload, payloadEnd); - if (collection == CMM_ROI) { - if (subBlock.dataWords() && !subBlock.unpack()) { - if (debug) { - std::string errMsg(subBlock.unpackErrorMsg()); - msg() << "CMM-Energy sub-block unpacking failed: " - << errMsg << endreq; - } - rodErr = m_subBlock->unpackErrorCode(); - break; + CmmEnergySubBlock subBlock; + payload = subBlock.read(payload, payloadEnd); + if (collection == CMM_ROI) { + if (subBlock.dataWords() && !subBlock.unpack()) { + if (debug) { + std::string errMsg(subBlock.unpackErrorMsg()); + msg() << "CMM-Energy sub-block unpacking failed: " + << errMsg << endreq; + } + rodErr = m_subBlock->unpackErrorCode(); + break; } - const LVL1::CMMRoI roi(0, subBlock.sumEtHits(slice), - subBlock.missingEtHits(slice), - subBlock.missingEtSigHits(slice), - subBlock.ex(slice, CmmEnergySubBlock::TOTAL), - subBlock.ey(slice, CmmEnergySubBlock::TOTAL), - subBlock.et(slice, CmmEnergySubBlock::TOTAL), - 0, 0, 0, 0, - subBlock.exError(slice, CmmEnergySubBlock::TOTAL), - subBlock.eyError(slice, CmmEnergySubBlock::TOTAL), - subBlock.etError(slice, CmmEnergySubBlock::TOTAL)); - m_cmCollection->setRoiWord(roi.energyRoiWord0()); - m_cmCollection->setRoiWord(roi.energyRoiWord1()); - m_cmCollection->setRoiWord(roi.energyRoiWord2()); + const LVL1::CMMRoI roi(0, subBlock.sumEtHits(slice), + subBlock.missingEtHits(slice), + subBlock.missingEtSigHits(slice), + subBlock.ex(slice, CmmEnergySubBlock::TOTAL), + subBlock.ey(slice, CmmEnergySubBlock::TOTAL), + subBlock.et(slice, CmmEnergySubBlock::TOTAL), + 0, 0, 0, 0, + subBlock.exError(slice, CmmEnergySubBlock::TOTAL), + subBlock.eyError(slice, CmmEnergySubBlock::TOTAL), + subBlock.etError(slice, CmmEnergySubBlock::TOTAL)); + m_cmCollection->setRoiWord(roi.energyRoiWord0()); + m_cmCollection->setRoiWord(roi.energyRoiWord1()); + m_cmCollection->setRoiWord(roi.energyRoiWord2()); } - } + } } else { // JEM RoI JemRoiSubBlockV1 subBlock; payload = subBlock.read(payload, payloadEnd); - if (collection == JEM_ROI) { - if (subBlock.dataWords() && !subBlock.unpack()) { - if (debug) { - std::string errMsg(subBlock.unpackErrorMsg()); - msg() << "JEM RoI sub-block unpacking failed: " - << errMsg << endreq; - } + if (collection == JEM_ROI) { + if (subBlock.dataWords() && !subBlock.unpack()) { + if (debug) { + std::string errMsg(subBlock.unpackErrorMsg()); + msg() << "JEM RoI sub-block unpacking failed: " + << errMsg << endreq; + } rodErr = m_subBlock->unpackErrorCode(); break; } - for (int frame = 0; frame < 8; ++frame) { - for (int forward = 0; forward < 2; ++forward) { - const LVL1::JEMRoI roi = subBlock.roi(frame, forward); - if (roi.hits() || roi.error()) { - m_jeCollection->push_back(new LVL1::JEMRoI(roi)); - } - } - } + for (int frame = 0; frame < 8; ++frame) { + for (int forward = 0; forward < 2; ++forward) { + const LVL1::JEMRoI roi = subBlock.roi(frame, forward); + if (roi.hits() || roi.error()) { + m_jeCollection->push_back(new LVL1::JEMRoI(roi)); + } + } + } } } } else { // Just RoI word - LVL1::JEMRoI jroi; - LVL1::CMMRoI croi; - if (jroi.setRoiWord(*payload)) { - if (collection == JEM_ROI) { - if (jroi.crate() != rodCrate - m_crateOffsetHw) { - if (debug) msg() << "Inconsistent RoI crate number: " - << jroi.crate() << endreq; + LVL1::JEMRoI jroi; + LVL1::CMMRoI croi; + if (jroi.setRoiWord(*payload)) { + if (collection == JEM_ROI) { + if (jroi.crate() != rodCrate - m_crateOffsetHw) { + if (debug) msg() << "Inconsistent RoI crate number: " + << jroi.crate() << endreq; rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; - break; + break; } - const uint32_t location = (*payload) & 0xfffc0000; - if (dupRoiCheck.insert(location).second) { - if (jroi.hits() || jroi.error()) { - m_jeCollection->push_back(new LVL1::JEMRoI(*payload)); - } - } else { - if (debug) msg() << "Duplicate RoI word " - << MSG::hex << *payload << MSG::dec << endreq; + const uint32_t location = (*payload) & 0xfffc0000; + if (dupRoiCheck.insert(location).second) { + if (jroi.hits() || jroi.error()) { + m_jeCollection->push_back(new LVL1::JEMRoI(*payload)); + } + } else { + if (debug) msg() << "Duplicate RoI word " + << MSG::hex << *payload << MSG::dec << endreq; rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - break; + break; } - } + } } else if (croi.setRoiWord(*payload)) { - if (collection == CMM_ROI) { - uint32_t roiType = (*payload) & 0xf0000000; - if ((roiType & 0xe0000000) == 0xa0000000) roiType = 0xa0000000; - if (dupRoiCheck.insert(roiType).second) { - m_cmCollection->setRoiWord(*payload); - } else { - if (debug) msg() << "Duplicate RoI word " - << MSG::hex << *payload << MSG::dec << endreq; + if (collection == CMM_ROI) { + uint32_t roiType = (*payload) & 0xf0000000; + if ((roiType & 0xe0000000) == 0xa0000000) roiType = 0xa0000000; + if (dupRoiCheck.insert(roiType).second) { + m_cmCollection->setRoiWord(*payload); + } else { + if (debug) msg() << "Duplicate RoI word " + << MSG::hex << *payload << MSG::dec << endreq; rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - break; + break; } - } + } } else { - if (debug) msg() << "Invalid RoI word " - << MSG::hex << *payload << MSG::dec << endreq; - rodErr = L1CaloSubBlock::ERROR_ROI_TYPE; - break; + if (debug) msg() << "Invalid RoI word " + << MSG::hex << *payload << MSG::dec << endreq; + rodErr = L1CaloSubBlock::ERROR_ROI_TYPE; + break; } - ++payload; + ++payload; } } if (rodErr != L1CaloSubBlock::ERROR_NONE) - m_errorTool->rodError(robid, rodErr); + m_errorTool->rodError(robid, rodErr); } return StatusCode::SUCCESS; @@ -668,11 +671,11 @@ StatusCode JepRoiByteStreamV1Tool::convertBs( // Find CMM hits for given crate, dataID const LVL1::CMMJetHits* JepRoiByteStreamV1Tool::findCmmHits(const int crate, - const int dataID) + const int dataID) { const LVL1::CMMJetHits* hits = 0; CmmHitsMap::const_iterator mapIter; - mapIter = m_cmmHitsMap.find(crate*100 + dataID); + mapIter = m_cmmHitsMap.find(crate * 100 + dataID); if (mapIter != m_cmmHitsMap.end()) hits = mapIter->second; return hits; } @@ -680,11 +683,11 @@ const LVL1::CMMJetHits* JepRoiByteStreamV1Tool::findCmmHits(const int crate, // Find CMM energy sums for given crate, module, dataID const LVL1::CMMEtSums* JepRoiByteStreamV1Tool::findCmmSums(const int crate, - const int dataID) + const int dataID) { const LVL1::CMMEtSums* sums = 0; CmmSumsMap::const_iterator mapIter; - mapIter = m_cmmEtMap.find(crate*100 + dataID); + mapIter = m_cmmEtMap.find(crate * 100 + dataID); if (mapIter != m_cmmEtMap.end()) sums = mapIter->second; return sums; } @@ -692,7 +695,7 @@ const LVL1::CMMEtSums* JepRoiByteStreamV1Tool::findCmmSums(const int crate, // Set up JEM RoIs map void JepRoiByteStreamV1Tool::setupJemRoiMap(const JemRoiCollection* - const jeCollection) + const jeCollection) { m_roiMap.clear(); if (jeCollection) { @@ -709,7 +712,7 @@ void JepRoiByteStreamV1Tool::setupJemRoiMap(const JemRoiCollection* // Set up CMM hits map void JepRoiByteStreamV1Tool::setupCmmHitsMap(const CmmHitsCollection* - const hitCollection) + const hitCollection) { m_cmmHitsMap.clear(); if (hitCollection) { @@ -718,7 +721,7 @@ void JepRoiByteStreamV1Tool::setupCmmHitsMap(const CmmHitsCollection* for (; pos != pose; ++pos) { const LVL1::CMMJetHits* const hits = *pos; const int crate = hits->crate() - m_crateOffsetSw; - const int key = crate*100 + hits->dataID(); + const int key = crate * 100 + hits->dataID(); m_cmmHitsMap.insert(std::make_pair(key, hits)); } } @@ -727,7 +730,7 @@ void JepRoiByteStreamV1Tool::setupCmmHitsMap(const CmmHitsCollection* // Set up CMM energy sums map void JepRoiByteStreamV1Tool::setupCmmEtMap(const CmmSumsCollection* - const etCollection) + const etCollection) { m_cmmEtMap.clear(); if (etCollection) { @@ -736,7 +739,7 @@ void JepRoiByteStreamV1Tool::setupCmmEtMap(const CmmSumsCollection* for (; pos != pose; ++pos) { const LVL1::CMMEtSums* const sums = *pos; const int crate = sums->crate() - m_crateOffsetSw; - const int key = crate*100 + sums->dataID(); + const int key = crate * 100 + sums->dataID(); m_cmmEtMap.insert(std::make_pair(key, sums)); } } diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepRoiByteStreamV2Tool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepRoiByteStreamV2Tool.cxx index 56caeb77712bf530a391e3b737dfb356e289f16d..236a06da2e5190064eced29eae42a12cbebac3d3 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepRoiByteStreamV2Tool.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepRoiByteStreamV2Tool.cxx @@ -32,7 +32,7 @@ namespace LVL1BS { // Interface ID static const InterfaceID IID_IJepRoiByteStreamV2Tool("JepRoiByteStreamV2Tool", - 1, 1); + 1, 1); const InterfaceID& JepRoiByteStreamV2Tool::interfaceID() { @@ -42,8 +42,8 @@ const InterfaceID& JepRoiByteStreamV2Tool::interfaceID() // Constructor JepRoiByteStreamV2Tool::JepRoiByteStreamV2Tool(const std::string& type, - const std::string& name, - const IInterface* parent) + const std::string& name, + const IInterface* parent) : AthAlgTool(type, name, parent), m_errorTool("LVL1BS::L1CaloErrorByteStreamTool/L1CaloErrorByteStreamTool"), m_crates(2), m_modules(16), m_frames(8), m_maxRoiWords(6), @@ -73,7 +73,7 @@ JepRoiByteStreamV2Tool::JepRoiByteStreamV2Tool(const std::string& type, "The number of S-Links per crate"); declareProperty("CrateMin", m_crateMin = 0, "Minimum crate number, allows partial output"); - declareProperty("CrateMax", m_crateMax = m_crates-1, + declareProperty("CrateMax", m_crateMax = m_crates - 1, "Maximum crate number, allows partial output"); } @@ -123,8 +123,8 @@ StatusCode JepRoiByteStreamV2Tool::finalize() // Conversion bytestream to JEM RoI StatusCode JepRoiByteStreamV2Tool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - DataVector<LVL1::JEMTobRoI>* const jeCollection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + DataVector<LVL1::JEMTobRoI>* const jeCollection) { m_jeCollection = jeCollection; return convertBs(robFrags, JEM_ROI); @@ -133,8 +133,8 @@ StatusCode JepRoiByteStreamV2Tool::convert( // Conversion bytestream to CMX RoI StatusCode JepRoiByteStreamV2Tool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - LVL1::CMXRoI* const cmCollection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + LVL1::CMXRoI* const cmCollection) { m_cmCollection = cmCollection; return convertBs(robFrags, CMX_ROI); @@ -143,8 +143,8 @@ StatusCode JepRoiByteStreamV2Tool::convert( // Conversion of JEP container to bytestream StatusCode JepRoiByteStreamV2Tool::convert( - const LVL1::JEPRoIBSCollectionV2* const jep, - RawEventWrite* const re) + const LVL1::JEPRoIBSCollectionV2* const jep, + RawEventWrite* const re) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -176,27 +176,27 @@ StatusCode JepRoiByteStreamV2Tool::convert( for (int crate = m_crateMin; crate <= m_crateMax; ++crate) { const int hwCrate = crate + m_crateOffsetHw; - for (int module=0; module < m_modules; ++module) { + for (int module = 0; module < m_modules; ++module) { // Pack required number of modules per slink - if (module%modulesPerSlink == 0) { - const int daqOrRoi = 1; - const int slink = module/modulesPerSlink; + if (module % modulesPerSlink == 0) { + const int daqOrRoi = 1; + const int slink = module / modulesPerSlink; if (debug) { msg() << "Treating crate " << hwCrate - << " slink " << slink << endreq - << "Data Version/Format: " << m_version - << " " << m_dataFormat << endreq; + << " slink " << slink << endreq + << "Data Version/Format: " << m_version + << " " << m_dataFormat << endreq; } - const uint32_t rodIdJem = m_srcIdMap->getRodID(hwCrate, slink, daqOrRoi, - m_subDetector); - theROD = m_fea->getRodData(rodIdJem); + const uint32_t rodIdJem = m_srcIdMap->getRodID(hwCrate, slink, daqOrRoi, + m_subDetector); + theROD = m_fea->getRodData(rodIdJem); if (neutralFormat) { const L1CaloUserHeader userHeader; - theROD->push_back(userHeader.header()); + theROD->push_back(userHeader.header()); } - m_rodStatusMap.insert(make_pair(rodIdJem, m_rodStatus)); + m_rodStatusMap.insert(make_pair(rodIdJem, m_rodStatus)); } if (debug) msg() << "JEM Module " << module << endreq; if (!theROD) break; // for coverity, shouldn't happen @@ -205,20 +205,20 @@ StatusCode JepRoiByteStreamV2Tool::convert( if (neutralFormat) { m_subBlock->clear(); - m_subBlock->setRoiHeader(m_version, hwCrate, module); + m_subBlock->setRoiHeader(m_version, hwCrate, module); } // Find JEM RoIs for this module for (; mapIter != mapIterEnd; ++mapIter) { const LVL1::JEMTobRoI* const roi = mapIter->second; - if (roi->crate() < crate) continue; - if (roi->crate() > crate) break; - if (roi->jem() < module) continue; - if (roi->jem() > module) break; - if (roi->energyLarge() || roi->energySmall()) { - if (neutralFormat) m_subBlock->fillRoi(*roi); - else theROD->push_back(roi->roiWord()); + if (roi->crate() < crate) continue; + if (roi->crate() > crate) break; + if (roi->jem() < module) continue; + if (roi->jem() > module) break; + if (roi->energyLarge() || roi->energySmall()) { + if (neutralFormat) m_subBlock->fillRoi(*roi); + else theROD->push_back(roi->roiWord()); } } @@ -226,14 +226,14 @@ StatusCode JepRoiByteStreamV2Tool::convert( if (neutralFormat) { if ( !m_subBlock->pack()) { - msg(MSG::ERROR) << "JEM RoI sub-block packing failed" << endreq; - return StatusCode::FAILURE; + msg(MSG::ERROR) << "JEM RoI sub-block packing failed" << endreq; + return StatusCode::FAILURE; + } + if (debug) { + msg() << "JEM RoI sub-block data words: " + << m_subBlock->dataWords() << endreq; } - if (debug) { - msg() << "JEM RoI sub-block data words: " - << m_subBlock->dataWords() << endreq; - } - m_subBlock->write(theROD); + m_subBlock->write(theROD); } } if (!theROD) break; // for coverity, shouldn't happen @@ -254,7 +254,7 @@ StatusCode JepRoiByteStreamV2Tool::convert( const int cmxEnergyVersion = 3; //<<== CHECK subBlock.setCmxHeader(cmxEnergyVersion, m_dataFormat, slice, hwCrate, CmxSubBlock::SYSTEM, CmxSubBlock::CMX_ENERGY, - CmxSubBlock::LEFT, timeslices); + CmxSubBlock::LEFT, timeslices); int maxSource = static_cast<int>(LVL1::CMXEtSums::MAX_SOURCE); for (int source = 0; source < maxSource; ++source) { const LVL1::CMXEtSums* const sums = findCmxSums(crate, source); @@ -265,29 +265,29 @@ StatusCode JepRoiByteStreamV2Tool::convert( const int exErr = sums->ExError(); const int eyErr = sums->EyError(); const int etErr = sums->EtError(); - if (source < m_modules) { - subBlock.setSubsums(slice, source, ex, ey, et, exErr, eyErr, etErr); - } else { - CmxEnergySubBlock::SourceType srcType = CmxEnergySubBlock::MAX_SOURCE_TYPE; - CmxEnergySubBlock::SumType sumType = CmxEnergySubBlock::MAX_SUM_TYPE; - CmxEnergySubBlock::HitsType hitType = CmxEnergySubBlock::MAX_HITS_TYPE; - energySubBlockTypes(source, srcType, sumType, hitType); - if (srcType != CmxEnergySubBlock::MAX_SOURCE_TYPE) { - subBlock.setSubsums(slice, srcType, sumType, ex, ey, et, - exErr, eyErr, etErr); + if (source < m_modules) { + subBlock.setSubsums(slice, source, ex, ey, et, exErr, eyErr, etErr); + } else { + CmxEnergySubBlock::SourceType srcType = CmxEnergySubBlock::MAX_SOURCE_TYPE; + CmxEnergySubBlock::SumType sumType = CmxEnergySubBlock::MAX_SUM_TYPE; + CmxEnergySubBlock::HitsType hitType = CmxEnergySubBlock::MAX_HITS_TYPE; + energySubBlockTypes(source, srcType, sumType, hitType); + if (srcType != CmxEnergySubBlock::MAX_SOURCE_TYPE) { + subBlock.setSubsums(slice, srcType, sumType, ex, ey, et, + exErr, eyErr, etErr); } else if (hitType != CmxEnergySubBlock::MAX_HITS_TYPE) { - subBlock.setEtHits(slice, hitType, sumType, et); + subBlock.setEtHits(slice, hitType, sumType, et); } } } } if ( !subBlock.pack()) { msg(MSG::ERROR) << "CMX-Energy sub-block packing failed" << endreq; - return StatusCode::FAILURE; + return StatusCode::FAILURE; } if (debug) { - msg() << "CMX-Energy sub-block data words: " - << subBlock.dataWords() << endreq; + msg() << "CMX-Energy sub-block data words: " + << subBlock.dataWords() << endreq; } subBlock.write(theROD); @@ -298,7 +298,7 @@ StatusCode JepRoiByteStreamV2Tool::convert( const LVL1::CMXRoI* const roi = jep->CmxRoi(); if ( roi ) { // CMX-Energy RoIs are not zero-supressed unless all are zero - for (int word = 0; word < m_maxRoiWords; ++word) { + for (int word = 0; word < m_maxRoiWords; ++word) { theROD->push_back(roi->roiWord(word)); } } @@ -319,12 +319,12 @@ StatusCode JepRoiByteStreamV2Tool::convert( // Return reference to vector with all possible Source Identifiers const std::vector<uint32_t>& JepRoiByteStreamV2Tool::sourceIDs( - const std::string& sgKey) + const std::string& sgKey) { const std::string flag("RoIB"); const std::string::size_type pos = sgKey.find(flag); const bool roiDaq = - (pos == std::string::npos || pos != sgKey.length() - flag.length()); + (pos == std::string::npos || pos != sgKey.length() - flag.length()); const bool empty = (roiDaq) ? m_sourceIDs.empty() : m_sourceIDsRoIB.empty(); if (empty) { const int maxCrates = m_crates + m_crateOffsetHw; @@ -333,11 +333,11 @@ const std::vector<uint32_t>& JepRoiByteStreamV2Tool::sourceIDs( for (int slink = 0; slink < maxSlinks; ++slink) { const int daqOrRoi = 1; const uint32_t rodId = m_srcIdMap->getRodID(hwCrate, slink, daqOrRoi, - m_subDetector); + m_subDetector); const uint32_t robId = m_srcIdMap->getRobID(rodId); - if (roiDaq) { - if (slink < 2) m_sourceIDs.push_back(robId); - } else if (slink >= 2) m_sourceIDsRoIB.push_back(robId); + if (roiDaq) { + if (slink < 2) m_sourceIDs.push_back(robId); + } else if (slink >= 2) m_sourceIDsRoIB.push_back(robId); } } } @@ -347,8 +347,8 @@ const std::vector<uint32_t>& JepRoiByteStreamV2Tool::sourceIDs( // Convert bytestream to given container type StatusCode JepRoiByteStreamV2Tool::convertBs( - const IROBDataProviderSvc::VROBFRAG& robFrags, - const CollectionType collection) + const IROBDataProviderSvc::VROBFRAG& robFrags, + const CollectionType collection) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -375,8 +375,8 @@ StatusCode JepRoiByteStreamV2Tool::convertBs( (*rob)->status(robData); if (*robData != 0) { m_errorTool->robError(robid, *robData); - if (debug) msg() << "ROB status error - skipping fragment" << endreq; - continue; + if (debug) msg() << "ROB status error - skipping fragment" << endreq; + continue; } } @@ -405,14 +405,14 @@ StatusCode JepRoiByteStreamV2Tool::convertBs( const uint32_t sourceID = (*rob)->rod_source_id(); if (m_srcIdMap->getRobID(sourceID) != robid || m_srcIdMap->subDet(sourceID) != m_subDetector || - m_srcIdMap->daqOrRoi(sourceID) != 1 || - (m_srcIdMap->slink(sourceID) != 0 && m_srcIdMap->slink(sourceID) != 2) || + m_srcIdMap->daqOrRoi(sourceID) != 1 || + (m_srcIdMap->slink(sourceID) != 0 && m_srcIdMap->slink(sourceID) != 2) || m_srcIdMap->crate(sourceID) < m_crateOffsetHw || - m_srcIdMap->crate(sourceID) >= m_crateOffsetHw + m_crates) { + m_srcIdMap->crate(sourceID) >= m_crateOffsetHw + m_crates) { m_errorTool->rodError(robid, L1CaloSubBlock::ERROR_ROD_ID); if (debug) { msg() << "Wrong source identifier in data: " - << MSG::hex << sourceID << MSG::dec << endreq; + << MSG::hex << sourceID << MSG::dec << endreq; } continue; } @@ -425,7 +425,7 @@ StatusCode JepRoiByteStreamV2Tool::convertBs( } const int rodCrate = m_srcIdMap->crate(sourceID); if (debug) { - msg() << "Treating crate " << rodCrate + msg() << "Treating crate " << rodCrate << " slink " << m_srcIdMap->slink(sourceID) << endreq; } @@ -437,7 +437,7 @@ StatusCode JepRoiByteStreamV2Tool::convertBs( if (headerWords != 1) { m_errorTool->rodError(robid, L1CaloSubBlock::ERROR_USER_HEADER); if (debug) msg() << "Unexpected number of user header words: " - << headerWords << endreq; + << headerWords << endreq; continue; } for (int i = 0; i < headerWords; ++i) ++payload; @@ -447,145 +447,146 @@ StatusCode JepRoiByteStreamV2Tool::convertBs( unsigned int rodErr = L1CaloSubBlock::ERROR_NONE; while (payload != payloadEnd) { - + if (L1CaloSubBlock::wordType(*payload) == L1CaloSubBlock::HEADER) { - const int slice = 0; + const int slice = 0; if (CmxSubBlock::cmxBlock(*payload)) { // CMXs - if (CmxSubBlock::cmxType(*payload) == CmxSubBlock::CMX_ENERGY) { - CmxEnergySubBlock subBlock; - payload = subBlock.read(payload, payloadEnd); - if (collection == CMX_ROI) { - if (subBlock.dataWords() && !subBlock.unpack()) { - if (debug) { - std::string errMsg(subBlock.unpackErrorMsg()); - msg() << "CMX-Energy sub-block unpacking failed: " - << errMsg << endreq; - } - rodErr = m_subBlock->unpackErrorCode(); - break; + if (CmxSubBlock::cmxType(*payload) == CmxSubBlock::CMX_ENERGY) { + CmxEnergySubBlock subBlock; + payload = subBlock.read(payload, payloadEnd); + if (collection == CMX_ROI) { + if (subBlock.dataWords() && !subBlock.unpack()) { + if (debug) { + std::string errMsg(subBlock.unpackErrorMsg()); + msg() << "CMX-Energy sub-block unpacking failed: " + << errMsg << endreq; + } + rodErr = m_subBlock->unpackErrorCode(); + break; + } + const LVL1::CMXRoI roi( + subBlock.energy(slice, CmxEnergySubBlock::TOTAL, + CmxEnergySubBlock::STANDARD, + CmxEnergySubBlock::ENERGY_EX), + subBlock.energy(slice, CmxEnergySubBlock::TOTAL, + CmxEnergySubBlock::STANDARD, + CmxEnergySubBlock::ENERGY_EY), + subBlock.energy(slice, CmxEnergySubBlock::TOTAL, + CmxEnergySubBlock::STANDARD, + CmxEnergySubBlock::ENERGY_ET), + subBlock.error(slice, CmxEnergySubBlock::TOTAL, + CmxEnergySubBlock::STANDARD, + CmxEnergySubBlock::ENERGY_EX), + subBlock.error(slice, CmxEnergySubBlock::TOTAL, + CmxEnergySubBlock::STANDARD, + CmxEnergySubBlock::ENERGY_EY), + subBlock.error(slice, CmxEnergySubBlock::TOTAL, + CmxEnergySubBlock::STANDARD, + CmxEnergySubBlock::ENERGY_ET), + subBlock.hits(slice, CmxEnergySubBlock::SUM_ET, + CmxEnergySubBlock::STANDARD), + subBlock.hits(slice, CmxEnergySubBlock::MISSING_ET, + CmxEnergySubBlock::STANDARD), + subBlock.hits(slice, CmxEnergySubBlock::MISSING_ET_SIG, + CmxEnergySubBlock::STANDARD), + subBlock.energy(slice, CmxEnergySubBlock::TOTAL, + CmxEnergySubBlock::RESTRICTED_WEIGHTED, + CmxEnergySubBlock::ENERGY_EX), + subBlock.energy(slice, CmxEnergySubBlock::TOTAL, + CmxEnergySubBlock::RESTRICTED_WEIGHTED, + CmxEnergySubBlock::ENERGY_EY), + subBlock.energy(slice, CmxEnergySubBlock::TOTAL, + CmxEnergySubBlock::RESTRICTED_WEIGHTED, + CmxEnergySubBlock::ENERGY_ET), + subBlock.error(slice, CmxEnergySubBlock::TOTAL, + CmxEnergySubBlock::RESTRICTED_WEIGHTED, + CmxEnergySubBlock::ENERGY_EX), + subBlock.error(slice, CmxEnergySubBlock::TOTAL, + CmxEnergySubBlock::RESTRICTED_WEIGHTED, + CmxEnergySubBlock::ENERGY_EY), + subBlock.error(slice, CmxEnergySubBlock::TOTAL, + CmxEnergySubBlock::RESTRICTED_WEIGHTED, + CmxEnergySubBlock::ENERGY_ET), + subBlock.hits(slice, CmxEnergySubBlock::SUM_ET, + CmxEnergySubBlock::RESTRICTED_WEIGHTED), + subBlock.hits(slice, CmxEnergySubBlock::MISSING_ET, + CmxEnergySubBlock::RESTRICTED_WEIGHTED)); + for (int word = 0; word < m_maxRoiWords; ++word) { + m_cmCollection->setRoiWord(roi.roiWord(word)); } - const LVL1::CMXRoI roi( - subBlock.energy(slice, CmxEnergySubBlock::TOTAL, - CmxEnergySubBlock::STANDARD, - CmxEnergySubBlock::ENERGY_EX), - subBlock.energy(slice, CmxEnergySubBlock::TOTAL, - CmxEnergySubBlock::STANDARD, - CmxEnergySubBlock::ENERGY_EY), - subBlock.energy(slice, CmxEnergySubBlock::TOTAL, - CmxEnergySubBlock::STANDARD, - CmxEnergySubBlock::ENERGY_ET), - subBlock.error(slice, CmxEnergySubBlock::TOTAL, - CmxEnergySubBlock::STANDARD, - CmxEnergySubBlock::ENERGY_EX), - subBlock.error(slice, CmxEnergySubBlock::TOTAL, - CmxEnergySubBlock::STANDARD, - CmxEnergySubBlock::ENERGY_EY), - subBlock.error(slice, CmxEnergySubBlock::TOTAL, - CmxEnergySubBlock::STANDARD, - CmxEnergySubBlock::ENERGY_ET), - subBlock.hits(slice, CmxEnergySubBlock::SUM_ET, - CmxEnergySubBlock::STANDARD), - subBlock.hits(slice, CmxEnergySubBlock::MISSING_ET, - CmxEnergySubBlock::STANDARD), - subBlock.hits(slice, CmxEnergySubBlock::MISSING_ET_SIG, - CmxEnergySubBlock::STANDARD), - subBlock.energy(slice, CmxEnergySubBlock::TOTAL, - CmxEnergySubBlock::RESTRICTED_WEIGHTED, - CmxEnergySubBlock::ENERGY_EX), - subBlock.energy(slice, CmxEnergySubBlock::TOTAL, - CmxEnergySubBlock::RESTRICTED_WEIGHTED, - CmxEnergySubBlock::ENERGY_EY), - subBlock.energy(slice, CmxEnergySubBlock::TOTAL, - CmxEnergySubBlock::RESTRICTED_WEIGHTED, - CmxEnergySubBlock::ENERGY_ET), - subBlock.error(slice, CmxEnergySubBlock::TOTAL, - CmxEnergySubBlock::RESTRICTED_WEIGHTED, - CmxEnergySubBlock::ENERGY_EX), - subBlock.error(slice, CmxEnergySubBlock::TOTAL, - CmxEnergySubBlock::RESTRICTED_WEIGHTED, - CmxEnergySubBlock::ENERGY_EY), - subBlock.error(slice, CmxEnergySubBlock::TOTAL, - CmxEnergySubBlock::RESTRICTED_WEIGHTED, - CmxEnergySubBlock::ENERGY_ET), - subBlock.hits(slice, CmxEnergySubBlock::SUM_ET, - CmxEnergySubBlock::RESTRICTED_WEIGHTED), - subBlock.hits(slice, CmxEnergySubBlock::MISSING_ET, - CmxEnergySubBlock::RESTRICTED_WEIGHTED)); - for (int word = 0; word < m_maxRoiWords; ++word) { - m_cmCollection->setRoiWord(roi.roiWord(word)); - } } - } + } } else { // JEM RoI JemRoiSubBlockV2 subBlock; payload = subBlock.read(payload, payloadEnd); - if (collection == JEM_ROI) { - if (subBlock.dataWords() && !subBlock.unpack()) { - if (debug) { - std::string errMsg(subBlock.unpackErrorMsg()); - msg() << "JEM RoI sub-block unpacking failed: " - << errMsg << endreq; - } + if (collection == JEM_ROI) { + if (subBlock.dataWords() && !subBlock.unpack()) { + if (debug) { + std::string errMsg(subBlock.unpackErrorMsg()); + msg() << "JEM RoI sub-block unpacking failed: " + << errMsg << endreq; + } rodErr = m_subBlock->unpackErrorCode(); break; } - for (int frame = 0; frame < m_frames; ++frame) { - const LVL1::JEMTobRoI roi = subBlock.roi(frame); - if (roi.energyLarge() || roi.energySmall()) { - m_jeCollection->push_back(new LVL1::JEMTobRoI(roi)); - } - } + for (int frame = 0; frame < m_frames; ++frame) { + const LVL1::JEMTobRoI roi = subBlock.roi(frame); + if (roi.energyLarge() || roi.energySmall()) { + m_jeCollection->push_back(new LVL1::JEMTobRoI(roi)); + } + } } } } else { // Just RoI word - LVL1::JEMTobRoI jroi; - LVL1::CMXRoI croi; - if (jroi.setRoiWord(*payload)) { - if (collection == JEM_ROI) { - if (jroi.crate() != rodCrate - m_crateOffsetHw) { - if (debug) msg() << "Inconsistent RoI crate number: " - << jroi.crate() << endreq; + LVL1::JEMTobRoI jroi; + LVL1::CMXRoI croi; + if (jroi.setRoiWord(*payload)) { + if (collection == JEM_ROI) { + if (jroi.crate() != rodCrate - m_crateOffsetHw) { + if (debug) msg() << "Inconsistent RoI crate number: " + << jroi.crate() << endreq; rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; - break; + break; } - const uint32_t location = (*payload) & 0xfff80000; - if (dupRoiCheck.insert(location).second) { - if (jroi.energyLarge() || jroi.energySmall()) { - m_jeCollection->push_back(new LVL1::JEMTobRoI(*payload)); - } - } else { - if (debug) msg() << "Duplicate RoI word " - << MSG::hex << *payload << MSG::dec << endreq; + const uint32_t location = (*payload) & 0xfff80000; + if (dupRoiCheck.insert(location).second) { + if (jroi.energyLarge() || jroi.energySmall()) { + m_jeCollection->push_back(new LVL1::JEMTobRoI(*payload)); + } + } else { + if (debug) msg() << "Duplicate RoI word " + << MSG::hex << *payload << MSG::dec << endreq; rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - break; + break; } - } + } } else if (croi.setRoiWord(*payload)) { - if (collection == CMX_ROI) { - const uint32_t roiType = (*payload) & 0xf8000000; - if (dupRoiCheck.insert(roiType).second) { - m_cmCollection->setRoiWord(*payload); - } else { - if (debug) msg() << "Duplicate RoI word " - << MSG::hex << *payload << MSG::dec << endreq; + if (collection == CMX_ROI) { + const uint32_t roiType = (*payload) & 0xfc000000; + + if (dupRoiCheck.insert(roiType).second) { + m_cmCollection->setRoiWord(*payload); + } else { + if (debug) msg() << "Duplicate RoI word " + << MSG::hex << *payload << MSG::dec << endreq; rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - break; + break; } - } + } } else { - if (debug) msg() << "Invalid RoI word " - << MSG::hex << *payload << MSG::dec << endreq; - rodErr = L1CaloSubBlock::ERROR_ROI_TYPE; - break; + if (debug) msg() << "Invalid RoI word " + << MSG::hex << *payload << MSG::dec << endreq; + rodErr = L1CaloSubBlock::ERROR_ROI_TYPE; + break; } - ++payload; + ++payload; } } if (rodErr != L1CaloSubBlock::ERROR_NONE) - m_errorTool->rodError(robid, rodErr); + m_errorTool->rodError(robid, rodErr); } return StatusCode::SUCCESS; @@ -594,11 +595,11 @@ StatusCode JepRoiByteStreamV2Tool::convertBs( // Find CMX energy sums for given crate, source const LVL1::CMXEtSums* JepRoiByteStreamV2Tool::findCmxSums(const int crate, - const int source) + const int source) { const LVL1::CMXEtSums* sums = 0; CmxSumsMap::const_iterator mapIter; - mapIter = m_cmxEtMap.find(crate*100 + source); + mapIter = m_cmxEtMap.find(crate * 100 + source); if (mapIter != m_cmxEtMap.end()) sums = mapIter->second; return sums; } @@ -606,7 +607,7 @@ const LVL1::CMXEtSums* JepRoiByteStreamV2Tool::findCmxSums(const int crate, // Set up JEM RoIs map void JepRoiByteStreamV2Tool::setupJemRoiMap(const JemRoiCollection* - const jeCollection) + const jeCollection) { m_roiMap.clear(); if (jeCollection) { @@ -623,7 +624,7 @@ void JepRoiByteStreamV2Tool::setupJemRoiMap(const JemRoiCollection* // Set up CMX energy sums map void JepRoiByteStreamV2Tool::setupCmxEtMap(const CmxSumsCollection* - const etCollection) + const etCollection) { m_cmxEtMap.clear(); if (etCollection) { @@ -632,7 +633,7 @@ void JepRoiByteStreamV2Tool::setupCmxEtMap(const CmxSumsCollection* for (; pos != pose; ++pos) { const LVL1::CMXEtSums* const sums = *pos; const int crate = sums->crate() - m_crateOffsetSw; - const int key = crate*100 + sums->source(); + const int key = crate * 100 + sums->source(); m_cmxEtMap.insert(std::make_pair(key, sums)); } } @@ -641,57 +642,57 @@ void JepRoiByteStreamV2Tool::setupCmxEtMap(const CmxSumsCollection* // Get energy subBlock types from CMXEtSums source type void JepRoiByteStreamV2Tool::energySubBlockTypes(const int source, - CmxEnergySubBlock::SourceType& srcType, - CmxEnergySubBlock::SumType& sumType, - CmxEnergySubBlock::HitsType& hitType) + CmxEnergySubBlock::SourceType& srcType, + CmxEnergySubBlock::SumType& sumType, + CmxEnergySubBlock::HitsType& hitType) { switch (source) { - case LVL1::CMXEtSums::REMOTE_STANDARD: - srcType = CmxEnergySubBlock::REMOTE; - sumType = CmxEnergySubBlock::STANDARD; - break; - case LVL1::CMXEtSums::REMOTE_RESTRICTED: - srcType = CmxEnergySubBlock::REMOTE; - sumType = CmxEnergySubBlock::RESTRICTED_WEIGHTED; - break; - case LVL1::CMXEtSums::LOCAL_STANDARD: - srcType = CmxEnergySubBlock::LOCAL; - sumType = CmxEnergySubBlock::STANDARD; - break; - case LVL1::CMXEtSums::LOCAL_RESTRICTED: - srcType = CmxEnergySubBlock::LOCAL; - sumType = CmxEnergySubBlock::RESTRICTED_WEIGHTED; - break; - case LVL1::CMXEtSums::TOTAL_STANDARD: - srcType = CmxEnergySubBlock::TOTAL; - sumType = CmxEnergySubBlock::STANDARD; - break; - case LVL1::CMXEtSums::TOTAL_RESTRICTED: - srcType = CmxEnergySubBlock::TOTAL; - sumType = CmxEnergySubBlock::RESTRICTED_WEIGHTED; - break; - case LVL1::CMXEtSums::SUM_ET_STANDARD: - hitType = CmxEnergySubBlock::SUM_ET; - sumType = CmxEnergySubBlock::STANDARD; - break; - case LVL1::CMXEtSums::SUM_ET_RESTRICTED: - hitType = CmxEnergySubBlock::SUM_ET; - sumType = CmxEnergySubBlock::RESTRICTED_WEIGHTED; - break; - case LVL1::CMXEtSums::MISSING_ET_STANDARD: - hitType = CmxEnergySubBlock::MISSING_ET; - sumType = CmxEnergySubBlock::STANDARD; - break; - case LVL1::CMXEtSums::MISSING_ET_RESTRICTED: - hitType = CmxEnergySubBlock::MISSING_ET; - sumType = CmxEnergySubBlock::RESTRICTED_WEIGHTED; - break; - case LVL1::CMXEtSums::MISSING_ET_SIG_STANDARD: - hitType = CmxEnergySubBlock::MISSING_ET_SIG; - sumType = CmxEnergySubBlock::STANDARD; - break; - default: - break; + case LVL1::CMXEtSums::REMOTE_STANDARD: + srcType = CmxEnergySubBlock::REMOTE; + sumType = CmxEnergySubBlock::STANDARD; + break; + case LVL1::CMXEtSums::REMOTE_RESTRICTED: + srcType = CmxEnergySubBlock::REMOTE; + sumType = CmxEnergySubBlock::RESTRICTED_WEIGHTED; + break; + case LVL1::CMXEtSums::LOCAL_STANDARD: + srcType = CmxEnergySubBlock::LOCAL; + sumType = CmxEnergySubBlock::STANDARD; + break; + case LVL1::CMXEtSums::LOCAL_RESTRICTED: + srcType = CmxEnergySubBlock::LOCAL; + sumType = CmxEnergySubBlock::RESTRICTED_WEIGHTED; + break; + case LVL1::CMXEtSums::TOTAL_STANDARD: + srcType = CmxEnergySubBlock::TOTAL; + sumType = CmxEnergySubBlock::STANDARD; + break; + case LVL1::CMXEtSums::TOTAL_RESTRICTED: + srcType = CmxEnergySubBlock::TOTAL; + sumType = CmxEnergySubBlock::RESTRICTED_WEIGHTED; + break; + case LVL1::CMXEtSums::SUM_ET_STANDARD: + hitType = CmxEnergySubBlock::SUM_ET; + sumType = CmxEnergySubBlock::STANDARD; + break; + case LVL1::CMXEtSums::SUM_ET_RESTRICTED: + hitType = CmxEnergySubBlock::SUM_ET; + sumType = CmxEnergySubBlock::RESTRICTED_WEIGHTED; + break; + case LVL1::CMXEtSums::MISSING_ET_STANDARD: + hitType = CmxEnergySubBlock::MISSING_ET; + sumType = CmxEnergySubBlock::STANDARD; + break; + case LVL1::CMXEtSums::MISSING_ET_RESTRICTED: + hitType = CmxEnergySubBlock::MISSING_ET; + sumType = CmxEnergySubBlock::RESTRICTED_WEIGHTED; + break; + case LVL1::CMXEtSums::MISSING_ET_SIG_STANDARD: + hitType = CmxEnergySubBlock::MISSING_ET_SIG; + sumType = CmxEnergySubBlock::STANDARD; + break; + default: + break; } } diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmByteStreamV2Cnv.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmByteStreamV2Cnv.cxx deleted file mode 100644 index d2d05e7681ee64698fd9ad8f0df212209f2f5714..0000000000000000000000000000000000000000 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmByteStreamV2Cnv.cxx +++ /dev/null @@ -1,171 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include <vector> -#include <stdint.h> - -#include "ByteStreamCnvSvcBase/ByteStreamAddress.h" -#include "ByteStreamCnvSvcBase/IByteStreamEventAccess.h" -#include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" - -#include "ByteStreamData/RawEvent.h" -#include "ByteStreamData/ROBData.h" - -#include "DataModel/DataVector.h" - -#include "GaudiKernel/CnvFactory.h" -#include "GaudiKernel/DataObject.h" -#include "GaudiKernel/IOpaqueAddress.h" -#include "GaudiKernel/IRegistry.h" -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/StatusCode.h" - -#include "SGTools/ClassID_traits.h" -#include "SGTools/StorableConversions.h" - -#include "xAODTrigL1Calo/TriggerTower.h" -#include "xAODTrigL1Calo/TriggerTowerContainer.h" -#include "xAODTrigL1Calo/TriggerTowerAuxContainer.h" - -#include "PpmByteStreamV2Cnv.h" -#include "PpmByteStreamV2Tool.h" - -namespace LVL1BS { - -PpmByteStreamV2Cnv::PpmByteStreamV2Cnv(ISvcLocator* svcloc) : - Converter(ByteStream_StorageType, classID(), svcloc), - AthMessaging(svcloc != 0 ? msgSvc() : 0, "PpmByteStreamV2Cnv"), - m_name("PpmByteStreamV2Cnv"), - m_tool("LVL1BS::PpmByteStreamV2Tool/PpmByteStreamV2Tool"), - m_storeSvc("StoreGateSvc", m_name), - m_robDataProvider("ROBDataProviderSvc", m_name), - m_ByteStreamEventAccess("ByteStreamCnvSvc", m_name){ - - -} - -PpmByteStreamV2Cnv::~PpmByteStreamV2Cnv() { -} - -// CLID - -const CLID& PpmByteStreamV2Cnv::classID() { - return ClassID_traits < xAOD::TriggerTowerContainer > ::ID(); -} - -// Init method gets all necessary services etc. - -#ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "unknown" -#endif - -StatusCode PpmByteStreamV2Cnv::initialize() { - ATH_MSG_DEBUG( - "Initializing " << m_name << " - package version " - << PACKAGE_VERSION - ); - - StatusCode sc = Converter::initialize(); - if (sc.isFailure()) { - return sc; - } - - //Get ByteStreamCnvSvc - CHECK(m_ByteStreamEventAccess.retrieve()); - CHECK(m_tool.retrieve()); - - // Get ROBDataProvider - sc = m_robDataProvider.retrieve(); - if (sc.isFailure()) { - ATH_MSG_WARNING("Failed to retrieve service " << m_robDataProvider); - // return is disabled for Write BS which does not require ROBDataProviderSvc - // return sc ; - } else { - ATH_MSG_DEBUG("Retrieved service " << m_robDataProvider); - } - - sc = m_storeSvc.retrieve(); - if (sc.isFailure()) { - ATH_MSG_WARNING("Failed to retrieve service " << m_storeSvc); - // return is disabled for Write BS which does not require m_storeSvc - // return sc ; - } else { - ATH_MSG_DEBUG("Retrieved service " << m_storeSvc); - } - - return StatusCode::SUCCESS; -} - -// createObj should create the RDO from bytestream. - -StatusCode PpmByteStreamV2Cnv::createObj(IOpaqueAddress* pAddr, - DataObject*& pObj) { - ATH_MSG_DEBUG("createObj() called"); - // ------------------------------------------------------------------------- - ByteStreamAddress *pBS_Addr; - pBS_Addr = dynamic_cast<ByteStreamAddress *>(pAddr); - if (!pBS_Addr) { - ATH_MSG_DEBUG("Can not cast to ByteStreamAddress");; - return StatusCode::FAILURE; - } - // ------------------------------------------------------------------------- - const std::string nm = *(pBS_Addr->par()); - ATH_MSG_DEBUG("Creating Objects " << nm); - // ------------------------------------------------------------------------- - // // get SourceIDs - const std::vector<uint32_t>& vID(m_tool->sourceIDs(nm)); - // // get ROB fragments - IROBDataProviderSvc::VROBFRAG robFrags; - m_robDataProvider->getROBData(vID, robFrags); - // ------------------------------------------------------------------------- - // size check - xAOD::TriggerTowerAuxContainer* aux = new xAOD::TriggerTowerAuxContainer(); - xAOD::TriggerTowerContainer* const ttCollection = - new xAOD::TriggerTowerContainer(); - ttCollection->setStore(aux); - - ATH_MSG_DEBUG("Number of ROB fragments is " << robFrags.size()); - - if (!robFrags.size()) { - pObj = SG::asStorable(ttCollection); - return StatusCode::SUCCESS; - } - // ------------------------------------------------------------------------- - StatusCode sc = m_tool->convert(robFrags, ttCollection); - if (sc.isFailure()) { - ATH_MSG_ERROR("Failed to create Objects"); - delete ttCollection; - return sc; - } - - pObj = SG::asStorable(ttCollection); - CHECK(m_storeSvc->record(aux, nm + "Aux.")); - return sc; -} - -// createRep should create the bytestream from RDOs. - -StatusCode PpmByteStreamV2Cnv::createRep(DataObject* pObj, - IOpaqueAddress*& pAddr) { - //TODO: (Sasha) implement createRep - ATH_MSG_DEBUG("createRep() called"); - - RawEventWrite* re = m_ByteStreamEventAccess->getRawEvent(); - - xAOD::TriggerTowerContainer* ttCollection = 0; - if(!SG::fromStorable(pObj, ttCollection )) { - ATH_MSG_ERROR("Cannot cast to xAOD::TriggerTowerContainer"); - return StatusCode::FAILURE; - } - - const std::string nm = pObj->registry()->name(); - - ByteStreamAddress* addr = new ByteStreamAddress( classID(), nm, "" ); - pAddr = addr; - - // Convert to ByteStream - return m_tool->convert( ttCollection, re ); -} - -} // end namespace diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmByteStreamV2Tool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmByteStreamV2Tool.cxx deleted file mode 100644 index de1d0468a6d28a6f9a8c5eb2303c35ce807bc8ff..0000000000000000000000000000000000000000 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmByteStreamV2Tool.cxx +++ /dev/null @@ -1,868 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// =========================================================================== -// Includes -// =========================================================================== -// STD: -// =========================================================================== -#include <numeric> -#include <set> -#include <utility> -// =========================================================================== -// Athena -// =========================================================================== -#include "GaudiKernel/IInterface.h" -#include "GaudiKernel/MsgStream.h" -#include "GaudiKernel/StatusCode.h" -#include "StoreGate/SegMemSvc.h" -// =========================================================================== -// TrigT1 -// =========================================================================== -#include "xAODTrigL1Calo/TriggerTower.h" -#include "xAODTrigL1Calo/TriggerTowerAuxContainer.h" -#include "xAODTrigL1Calo/TriggerTowerContainer.h" - -#include "TrigT1CaloUtils/DataError.h" - -#include "L1CaloSrcIdMap.h" -#include "TrigT1CaloMappingToolInterfaces/IL1CaloMappingTool.h" -#include "L1CaloErrorByteStreamTool.h" -#include "PpmSubBlockV2.h" -#include "CmmSubBlock.h" -#include "L1CaloUserHeader.h" -// =========================================================================== -#include "PpmByteStreamV2Tool.h" -// =========================================================================== -namespace LVL1BS { -// =========================================================================== - -// Interface ID -static const InterfaceID IID_IPpmByteStreamV2Tool("PpmByteStreamV2Tool", 1, 1); - -const InterfaceID& PpmByteStreamV2Tool::interfaceID() { - return IID_IPpmByteStreamV2Tool; -} -// =========================================================================== -// Constructor -PpmByteStreamV2Tool::PpmByteStreamV2Tool(const std::string& type, - const std::string& name, const IInterface* parent) : - AthAlgTool(type, name, parent), - m_sms("SegMemSvc/SegMemSvc", name), - m_srcIdMap(0), - m_ppmMaps("LVL1::PpmMappingTool/PpmMappingTool"), - m_errorTool("LVL1BS::L1CaloErrorByteStreamTool/L1CaloErrorByteStreamTool"), - m_subDetector(eformat::TDAQ_CALO_PREPROC), - m_channelsType(ChannelsType::Data), - m_fea(0){ - - declareInterface<PpmByteStreamV2Tool>(this); - - declareProperty("PpmMappingTool", m_ppmMaps, - "Crate/Module/Channel to Eta/Phi/Layer mapping tool"); - - declareProperty("NCrates", m_crates = 8, "Number of crates"); - declareProperty("NModules", m_modules = 16, "Number of modules"); - declareProperty("NChannels", m_channels = 64, "Number of channels"); - declareProperty("DataSize", m_dataSize = 3584, "Data size"); - declareProperty("MaxSlinks", m_maxSlinks = 4, "Max slinks"); - - declareProperty("PrintCompStats", m_printCompStats = 0, - "Print compressed format statistics"); - declareProperty("FADCBaseline", m_fadcBaseline = 0, - "FADC baseline lower bound for compressed formats"); - - // Properties for writing bytestream only - declareProperty("DataFormat", m_dataFormat = 1, - "Format identifier (0-3) in sub-block header"); - declareProperty("SubHeaderVersion", m_subheaderVersion = 1, - "Version identifier (1-2) in sub-block header"); - -} -// =========================================================================== -// Destructor -PpmByteStreamV2Tool::~PpmByteStreamV2Tool() { -} -// =========================================================================== -// Initialize - -#ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "unknown" -#endif - -StatusCode PpmByteStreamV2Tool::initialize() { - ATH_MSG_INFO("Initializing " << name() << " - package version " - << PACKAGE_VERSION); - - StatusCode sc = m_sms.retrieve(); - if (sc.isFailure()) { - ATH_MSG_ERROR("Failed to retrieve service " << m_sms); - return sc; - } else { - ATH_MSG_INFO("Retrieved service " << m_sms); - } - - m_srcIdMap = new L1CaloSrcIdMap { }; - m_fea = new FullEventAssembler<L1CaloSrcIdMap> { }; - - return StatusCode::SUCCESS; -} -// =========================================================================== -// Finalize - -StatusCode PpmByteStreamV2Tool::finalize() { - delete m_srcIdMap; - return StatusCode::SUCCESS; -} -// =========================================================================== -void PpmByteStreamV2Tool::reserveMemory( xAOD::TriggerTowerContainer* const ttCollection) { - const int maxChannels = m_crates * m_modules * m_channels; - const int chanBitVecSize = maxChannels/32; - const int modBitVecSize = (m_crates * m_modules)/32; - - // TriggerTowerMap ttMap; - // TriggerTowerMap::iterator itt; - - int dataCount = 0; - - if (ttCollection->empty()) { - ttCollection->reserve(m_dataSize); - - m_dataChan.resize(chanBitVecSize); - m_chanLayer.resize(chanBitVecSize); - m_dataMod.resize(modBitVecSize); - m_ttPos.resize(maxChannels); - - for (int crate = 0; crate < m_crates; ++crate) { - for (int module = 0; module < m_modules; ++module) { - const int index2 = (crate << 4) + module; - const int word2 = index2 / 32; - const int bit2 = index2 % 32; - for (int channel = 0; channel < m_channels; ++channel) { - const int index = (crate << 10) + (module << 6) + channel; - const int word = index / 32; - const int bit = index % 32; - double eta = 0.; - double phi = 0.; - int layer = 0; - // unsigned int key = 0; - if (m_ppmMaps->mapping(crate, module, channel, eta, phi, layer)) { - xAOD::TriggerTower* tt = new xAOD::TriggerTower(); - ttCollection->push_back(tt); - - // tt->initialize( - // const uint_least32_t& coolId, - // const uint_least8_t& layer, - // const float& eta, - // const float& phi, - // const std::vector<uint_least8_t>& lut_cp, - // const std::vector<uint_least8_t>& lut_jep, - // const std::vector<int_least16_t>& correction, - // const std::vector<uint_least8_t>& correctionEnabled, - // const std::vector<uint_least8_t>& bcidVec, - // const std::vector<uint_least16_t>& adc, - // const std::vector<uint_least8_t>& bcidExt, - // const std::vector<uint_least8_t>& Sat80Vec, - // const uint_least16_t& error, - // const uint_least8_t& peak, - // const uint_least8_t& adcPeak - // ); - const std::vector<uint_least32_t> dummy_vector32 {0}; - const std::vector<int_least16_t> dummy_svector16 {0}; - const std::vector<uint_least16_t> dummy_vector16 {0}; - const std::vector<uint_least8_t> dummy_vector8 {0}; - tt->initialize( - 0, - eta, - phi, - dummy_vector8, - dummy_vector8, - dummy_svector16, - dummy_vector8, - dummy_vector8, - dummy_vector16, - dummy_vector8, - dummy_vector8, - 0, - 0, - 0 - ); - - - - m_ttPos[index] = dataCount++; - // ttMap.insert(std::make_pair(key,count)); - m_chanLayer[word] |= (layer << bit); - m_dataChan[word] |= (1 << bit); - m_dataMod[word2] |= (1 << bit2); - } - } - } - } - } -} - -void PpmByteStreamV2Tool::collectTriggerTowers( - const IROBDataProviderSvc::VROBFRAG& robFrags, - xAOD::TriggerTowerContainer* const ttCollection -) -{ - // const bool debug = msgLvl(MSG::DEBUG); - // const bool verbose = msgLvl(MSG::VERBOSE); - // if (debug) msg(MSG::DEBUG); - - // TriggerTowerVector& ttColRef = m_ttData; - ChannelBitVector& colChan = m_dataChan; - ChannelBitVector& colMod = m_dataMod; - - const int maxChannels = m_crates * m_modules * m_channels; - const int chanBitVecSize = maxChannels/32; - m_foundChan.assign(chanBitVecSize, 0); - - int ttCount = 0; - - // Vectors to unpack into - std::vector<uint_least8_t> lutCp; - std::vector<uint_least8_t> lutJep; - std::vector<uint_least16_t> fadc; - - std::vector<uint_least8_t> bcidLutCp; - std::vector<uint_least8_t> satLutJep; - std::vector<uint_least8_t> bcidFadc; - std::vector<int_least16_t> correction; - std::vector<uint_least8_t> correctionEnabled; - - // ========================================================================= - // Loop over ROB fragments - // ========================================================================= - int robCount = 0; - std::set<uint32_t> dupCheck; - ROBIterator rob = robFrags.begin(); - ROBIterator robEnd = robFrags.end(); - - for (; rob != robEnd; ++rob) { - ATH_MSG_DEBUG("Treating ROB fragment " << robCount); - ++robCount; - - // Skip fragments with ROB status errors - uint32_t robid = (*rob)->source_id(); - - if ((*rob)->nstatus() > 0) { - ROBPointer robData; - (*rob)->status(robData); - if (*robData != 0) { - m_errorTool->robError(robid, *robData); - ATH_MSG_WARNING("ROB status error - skipping fragment"); - continue; - } - } - // ----------------------------------------------------------------------- - // Unpack ROD data (slinks) - // ----------------------------------------------------------------------- - RODPointer payloadBeg; - RODPointer payload; - RODPointer payloadEnd; - (*rob)->rod_data(payloadBeg); - payloadEnd = payloadBeg + (*rob)->rod_ndata(); - payload = payloadBeg; - - if (payload == payloadEnd) { - ATH_MSG_DEBUG("ROB fragment empty"); - continue; - } - // ----------------------------------------------------------------------- - const uint32_t sourceID = (*rob)->rod_source_id(); - const int rodCrate = m_srcIdMap->crate(sourceID); - const int rodSlink = m_srcIdMap->slink(sourceID); - // ----------------------------------------------------------------------- - // Check identifier - // Sasha: why we need this check: ROD == ROB - // ----------------------------------------------------------------------- - // if ( - // m_srcIdMap->getRobID(sourceID) != robid || - // m_srcIdMap->subDet(sourceID) != m_subDetector || - // m_srcIdMap->daqOrRoi(sourceID) != 0 || - // rodSlink >= m_maxSlinks || - // rodCrate >= m_crates) { - // m_errorTool->rodError(robid, L1CaloSubBlock::ERROR_ROD_ID); - // if (debug) { - // msg(MSG::DEBUG) << "Wrong source identifier in data: ROD " - // << MSG::hex << sourceID << " ROB " << robid - // << MSG::dec << endreq; - // } - // continue; - // } - // Skip duplicate fragments - if (!dupCheck.insert(robid).second) { - m_errorTool->rodError(robid, L1CaloSubBlock::ERROR_DUPLICATE_ROB); - ATH_MSG_DEBUG("Skipping duplicate ROB fragment"); - continue; - } - // ----------------------------------------------------------------------- - // Check minor version - // ----------------------------------------------------------------------- - - const int majorVersion = (*rob)->rod_version() >> 16; - const int minorVersion = (*rob)->rod_version() & 0xffff; - - - // std::cout << "++> ROD version " << std::hex << (*rob)->rod_version() << std::dec << std::endl; - // if (minorVersion > m_srcIdMap->minorVersionPreLS1()) { - // if (debug) msg() << "Skipping post-LS1 data" << endreq; - // continue; - // } - // ----------------------------------------------------------------------- - - ATH_MSG_DEBUG("Treating crate " << rodCrate << " slink " << rodSlink); - - // First word should be User Header - if ( !L1CaloUserHeader::isValid(*payload) ) { - m_errorTool->rodError(robid, L1CaloSubBlock::ERROR_USER_HEADER); - ATH_MSG_DEBUG("Invalid or missing user header"); - continue; - } - - L1CaloUserHeader userHeader(*payload); - userHeader.setVersion(minorVersion); - - ++payload; // Skip word - - // triggered slice offsets - const uint_least8_t trigLut = userHeader.ppmLut(); - const uint_least8_t trigFadc = userHeader.ppmFadc(); - // FADC baseline lower bound - m_fadcBaseline = userHeader.lowerBound(); - - ATH_MSG_DEBUG( - "Major format version number: " - << MSG::hex << majorVersion << MSG::dec << endreq - << "Minor format version number: " - << MSG::hex << minorVersion << MSG::dec << endreq - << "LUT triggered slice offset: " << int(trigLut) << endreq - << "FADC triggered slice offset: " << int(trigFadc) << endreq - << "FADC baseline lower bound: " << m_fadcBaseline); - - const int runNumber = (*rob)->rod_run_no() & 0xffffff; - - // -------------------------------------------------------------------- - int chanPerSubBlock = 0; - bool firstBlock = false; // Sasha: not used. delete? - uint32_t firstWord = 0; // Sasha: not used. delete? - RODPointer payloadFirst; - if (payload != payloadEnd) { - // -------------------------------------------------------------------- - if ( - L1CaloSubBlock::wordType(*payload) != L1CaloSubBlock::HEADER || - CmmSubBlock::cmmBlock(*payload) - ) { - m_errorTool->rodError(robid, L1CaloSubBlock::ERROR_MISSING_HEADER); - ATH_MSG_DEBUG("Missing Sub-block header"); - continue; - } - // -------------------------------------------------------------------- - firstBlock = true; - firstWord = *payload; - // -------------------------------------------------------------------- - // Sasha: Check first sublock for errors? - // -------------------------------------------------------------------- - if (m_ppmBlocks.empty()) { - m_ppmBlocks.push_back(new PpmSubBlockV2()); - } - // -------------------------------------------------------------------- - PpmSubBlockV2* const subBlock = m_ppmBlocks[0]; - subBlock->clear(); - payloadFirst = subBlock->read(payload, payloadEnd); - - chanPerSubBlock = subBlock->channelsPerSubBlock(); - if (chanPerSubBlock == 0) { - m_errorTool->rodError(robid, subBlock->unpackErrorCode()); - ATH_MSG_DEBUG("Unsupported version/data format: " - << subBlock->version() << "/" - << subBlock->format()); - continue; - } - - ATH_MSG_DEBUG("Channels per sub-block: " << chanPerSubBlock); - } else { - ATH_MSG_DEBUG("ROB fragment contains user header only"); - continue; - } - - const int numSubBlocks = m_channels/chanPerSubBlock; - const int size = m_ppmBlocks.size(); - if (numSubBlocks > size) { - // Sasha: Insert empty subblocks? - for (int i = size; i < numSubBlocks; ++i) { - m_ppmBlocks.push_back(new PpmSubBlockV2()); - } - } - // ----------------------------------------------------------------------- - // Loop over PPMs - // ----------------------------------------------------------------------- - payload = payloadBeg; - ++payload; - unsigned int rodErr = L1CaloSubBlock::ERROR_NONE; - // ----------------------------------------------------------------------- - // Sasha: Why we separetly check first block? Rewrite! - // ----------------------------------------------------------------------- - while (payload != payloadEnd) { - - // Get all sub-blocks for one PPM (first already read in above) - int crate = 0; - int module = 0; - int nPpmBlocks = 0; - - for (int block = 0; block < numSubBlocks; ++block) { - const uint32_t word = (firstBlock) ? firstWord : *payload; - if ( L1CaloSubBlock::wordType(word) != L1CaloSubBlock::HEADER || - CmmSubBlock::cmmBlock(word) || - PpmSubBlockV2::errorBlock(word)) { - ATH_MSG_DEBUG("Unexpected data sequence"); - rodErr = L1CaloSubBlock::ERROR_MISSING_HEADER; - break; - } - - if ( chanPerSubBlock != m_channels && - L1CaloSubBlock::seqno(word) != block * chanPerSubBlock) { - ATH_MSG_DEBUG("Unexpected channel sequence number: " - << L1CaloSubBlock::seqno(word) << " expected " - << block * chanPerSubBlock); - rodErr = L1CaloSubBlock::ERROR_MISSING_SUBBLOCK; - break; - } - - PpmSubBlockV2* const subBlock = m_ppmBlocks[block]; - nPpmBlocks++; - - if (firstBlock) { - payload = payloadFirst; - firstBlock = false; - } else { - subBlock->clear(); - payload = subBlock->read(payload, payloadEnd); - } - - if (block == 0) { - crate = subBlock->crate(); - module = subBlock->module(); - ATH_MSG_DEBUG("Crate " << crate << " Module " << module); - if (crate != rodCrate) { - ATH_MSG_DEBUG("Inconsistent crate number in ROD source ID"); - rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; - break; - } - } else { - if (subBlock->crate() != crate) { - ATH_MSG_DEBUG("Inconsistent crate number in sub-blocks"); - rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; - break; - } - if (subBlock->module() != module) { - ATH_MSG_DEBUG("Inconsistent module number in sub-blocks"); - rodErr = L1CaloSubBlock::ERROR_MODULE_NUMBER; - break; - } - } - if (payload == payloadEnd && block != numSubBlocks - 1) { - ATH_MSG_DEBUG("Premature end of data"); - rodErr = L1CaloSubBlock::ERROR_MISSING_SUBBLOCK; - break; - } - - } // for - - if (rodErr != L1CaloSubBlock::ERROR_NONE) break; - // Is there an error block? - bool isErrBlock = false; - if (payload != payloadEnd) { - if ( - L1CaloSubBlock::wordType(*payload) == L1CaloSubBlock::HEADER && - !CmmSubBlock::cmmBlock(*payload) && - PpmSubBlockV2::errorBlock(*payload)) { - ATH_MSG_DEBUG("Error block found"); - - if (PpmSubBlockV2::isRun2(minorVersion)) { - ATH_MSG_WARNING("TODO: Handle error blocks in RUN2 (alaexander.mazurov@cern.ch)"); - ++payload; - break; - } - - if (!m_errorBlock) { - m_errorBlock = new PpmSubBlockV2(); - } else { - m_errorBlock->clear(); - } - isErrBlock = true; - payload = m_errorBlock->read(payload, payloadEnd); - if (m_errorBlock->crate() != crate) { - ATH_MSG_DEBUG("Inconsistent crate number in error block"); - rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; - break; - } - if (m_errorBlock->module() != module) { - ATH_MSG_DEBUG("Inconsistent module number in error block"); - rodErr = L1CaloSubBlock::ERROR_MODULE_NUMBER; - break; - } - if (m_errorBlock->dataWords() && !m_errorBlock->unpack()) { - std::string errMsg(m_errorBlock->unpackErrorMsg()); - ATH_MSG_DEBUG("Unpacking error block failed: " << errMsg); - rodErr = m_errorBlock->unpackErrorCode(); - break; - } - } - } - - - - const int index2 = (crate << 4) + module; - const int word2 = index2 / 32; - const int bit2 = index2 % 32; - if (!((colMod[word2] >> bit2) & 1)) continue; - - // Loop over sub-blocks and fill trigger towers - - for (int block = 0; block < nPpmBlocks; ++block) { - PpmSubBlockV2* const subBlock = m_ppmBlocks[block]; - - // Don't bother unpacking modules that aren't used for required collection - if (!isErrBlock && !subBlock->dataWords()){ - ATH_MSG_DEBUG("Don't handle error blocks in RUN2. Need to be fixed (alexander.mazurov@cern.ch)"); - break; - } - - subBlock->setLutOffset(trigLut); - subBlock->setFadcOffset(trigFadc); - subBlock->setPedestal(m_pedestal); - subBlock->setFadcBaseline(m_fadcBaseline); - subBlock->setRunNumber(runNumber); - subBlock->setRodVersion((*rob)->rod_version()); - - msg(MSG::DEBUG) << "Unpacking sub-block version/format/seqno: " - << subBlock->version() << "/" << subBlock->format() << "/" - << subBlock->seqno() << endreq; - - if (subBlock->dataWords() && !subBlock->unpack()) { - std::string errMsg(subBlock->unpackErrorMsg()); - ATH_MSG_DEBUG("Unpacking PPM sub-block failed: " << errMsg); - rodErr = subBlock->unpackErrorCode(); - break; - } - if (m_printCompStats) { - addCompStats(subBlock->compStats()); - } - - for (int chan = 0; chan < chanPerSubBlock; ++chan) { - const int channel = block*chanPerSubBlock + chan; - const int index = (crate << 10) + (module << 6) + channel; - const int word = index / 32; - const int bit = index % 32; - - if ( !((colChan[word] >> bit) & 1)) continue; // skip unwanted channels - if (((m_foundChan[word] >> bit) & 1)) { - ATH_MSG_DEBUG("Duplicate data for crate/module/channel: " - << crate << "/" << module << "/" << channel); - rodErr = L1CaloSubBlock::ERROR_DUPLICATE_DATA; - break; - } - // Get data - subBlock->ppmData(channel, lutCp, lutJep, fadc, bcidLutCp, satLutJep, - bcidFadc, correction, correctionEnabled); - - if (lutCp.size() < size_t(trigLut + 1)) { - ATH_MSG_DEBUG("Triggered LUT slice from header " - << "inconsistent with number of slices: " - << trigLut << ", " << lutCp.size()); - - rodErr = L1CaloSubBlock::ERROR_SLICES; - break; - } - - if (fadc.size() < size_t(trigFadc + 1)) { - ATH_MSG_DEBUG("Triggered FADC slice from header " - << "inconsistent with number of slices: " - << trigFadc << ", " << fadc.size()); - rodErr = L1CaloSubBlock::ERROR_SLICES; - break; - } - - LVL1::DataError errorBits(0); - if (isErrBlock) { - errorBits.set(LVL1::DataError::PPMErrorWord, - m_errorBlock->ppmError(channel)); - errorBits.set(LVL1::DataError::SubStatusWord, - m_errorBlock->subStatus()); - } else { - errorBits.set(LVL1::DataError::PPMErrorWord, - subBlock->ppmError(channel)); - const PpmSubBlockV2* const lastBlock = - m_ppmBlocks[nPpmBlocks - 1]; - errorBits.set(LVL1::DataError::SubStatusWord, - lastBlock->subStatus()); - } - // Wrong bit set for compressed formats 1.01 to 1.03 - if (subBlock->format() > 1 && subBlock->seqno() < 4) { - errorBits.set(LVL1::DataError::ModuleError, - (errorBits.error() >> (LVL1::DataError::ModuleError+1)) & 0x1); - } - - const int error = errorBits.error(); - - // Save to TriggerTower - // const int layer = ((m_chanLayer[word] >> bit) & 1); - const int coolid = coolId(crate, module, channel); - - ATH_MSG_VERBOSE( - "|coolid:" << coolid << "(0x" << MSG::hex << coolid << MSG::dec << ")/" << std::endl - << "crate:" << crate << "/" << std::endl - << "module:" << module << "/" << std::endl - << "channel:" << channel << "/" << std::endl - << "lut_cp:" << vectorToString(lutCp) << std::endl - << "lut_jep:" << vectorToString(lutJep) << std::endl - << "fadc:" << vectorToString(fadc) << std::endl - << "bcid_lutcp:" << vectorToString(bcidLutCp) << std::endl - << "sat_lutjep:" << vectorToString(satLutJep) << std::endl - << "bcid_fadc:" << vectorToString(bcidFadc) << std::endl - << "correction:" << vectorToString(correction) << std::endl - << "correction_enabled:" << vectorToString(correctionEnabled) << std::endl - << "error:" << MSG::hex << error << MSG::dec << "|"); - - m_foundChan[word] |= (1 << bit); - ++ttCount; - xAOD::TriggerTower* tt = (*ttCollection)[m_ttPos[index]]; - - // ================================================================= - // Update Trigger Towers objects - // ================================================================= - - tt->setCoolId(coolid); - tt->setLut_cp(lutCp); - tt->setLut_jep(lutJep); - tt->setAdc(fadc); - - tt->setBcidVec(bcidLutCp); - tt->setBcidExt(bcidFadc); - - tt->setCorrection(correction); - tt->setCorrectionEnabled(correctionEnabled); - - tt->setPeak(trigLut); - tt->setAdcPeak(trigFadc); - // ================================================================= - - } // for chan - if (rodErr != L1CaloSubBlock::ERROR_NONE) break; - } // for block - - if (rodErr != L1CaloSubBlock::ERROR_NONE) break; - } //while - - if (rodErr != L1CaloSubBlock::ERROR_NONE) { - m_errorTool->rodError(robid, rodErr); - } - - // TODO: (sasha) Reset any missing channels (should be rare) - // ----------------------------------------------------------------------- - // Reset any missing channels (should be rare) - // ----------------------------------------------------------------------- - // if (ttCount != colSize) { - // if (debug) { - // msg(MSG::DEBUG) << "Found " << ttCount << " channels, expected " << colSize << endreq; - // } - - // std::vector<int> dummy(1); - // for (int word = 0; word < chanBitVecSize; ++word) { - // if (m_foundChan[word] != colChan[word]) { - // for (int bit = 0; bit < 32; ++bit) { - // if (((m_foundChan[word]>>bit)&1) != ((colChan[word]>>bit)&1)) { - // const int index = word*32 + bit; - // xAOD::TriggerTower* tt = ttColRef[m_ttPos[index]]; - // const int layer = ((m_chanLayer[word] >> bit) & 1); - // tt->setLayer(layer); - // tt->setAdc(fadc); - // tt->setPeak(trigLut); - // tt->setAdcPeak(trigFadc); - - // } // if - // } // for - // } // if - // } // for - // } // if - - // --------------------------------------------------------------------- - } // for - -} - -uint_least32_t PpmByteStreamV2Tool::coolId(int crate, int module, - int channel) const { - const int pin = channel % 16; - const int asic = channel / 16; - return (crate << 24) | (1 << 20) | (module << 16) | (pin << 8) | asic; -} - -// Conversion bytestream to trigger towers -StatusCode PpmByteStreamV2Tool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - xAOD::TriggerTowerContainer* const ttCollection) { - - reserveMemory(ttCollection); - collectTriggerTowers(robFrags, ttCollection); - std::remove_if( - ttCollection->begin(), - ttCollection->end(), - [](const xAOD::TriggerTower* tt){ return tt->coolId() == 0; }); - - return StatusCode::SUCCESS; -} -// =========================================================================== -// Conversion of trigger towers to bytestream - -StatusCode PpmByteStreamV2Tool::convert( - const xAOD::TriggerTowerContainer* const ttCollection, - RawEventWrite* const /*re*/) { - - // Clear the event assembler - - m_fea->clear(); - - const uint16_t minorVersion = m_srcIdMap->minorVersionPreLS1(); - m_fea->setRodMinorVersion(minorVersion); - m_rodStatusMap.clear(); - - // Pointer to ROD data vector - - //FullEventAssembler<L1CaloSrcIdMap>::RODDATA* theROD = 0; - - // Set up trigger tower maps - - setupSourceTowers(ttCollection); - // Create the sub-blocks to do the packing - - PpmSubBlockV2 subBlock; - const int chanPerSubBlock = subBlock.channelsPerSubBlock(m_subheaderVersion, - m_dataFormat); - if (chanPerSubBlock == 0) { - ATH_MSG_ERROR("Unsupported version/data format: " - << m_subheaderVersion << "/" << m_dataFormat); - return StatusCode::FAILURE; - } - - //TODO: Sasha implement - ATH_MSG_ERROR("Convert xaod trigger towers to the new uncompressed ROD format"\ - " is not ready. Write to alexander.mazurov@cern.ch that you need it"); - return StatusCode::FAILURE; -} -// =========================================================================== - -// Return reference to vector with all possible Source Identifiers - -const std::vector<uint32_t>& PpmByteStreamV2Tool::sourceIDs( - const std::string& sgKey) { - // ------------------------------------------------------------------------- - const std::string SPARE_FLAG("Spare"); - const std::string MUON_FLAG("Muon"); - - // Check if spare channels wanted - std::string::size_type pos = sgKey.find(SPARE_FLAG); - if (pos != std::string::npos - && pos == (sgKey.length() - SPARE_FLAG.length())) { - m_channelsType = ChannelsType::Spare; - } else { - // Check if muon channels wanted - pos = sgKey.find(MUON_FLAG); - if (pos != std::string::npos - && pos == (sgKey.length() - MUON_FLAG.length())) { - m_channelsType = ChannelsType::Muon; - } else { - // Default - all channels - m_channelsType = ChannelsType::Data; - } - } - // ------------------------------------------------------------------------- - if (m_sourceIDs.empty()) { - for (int crate = 0; crate < m_crates; ++crate) { - for (int slink = 0; slink < m_srcIdMap->maxSlinks(); ++slink) { - // const int daqOrRoi = 0; - const uint32_t rodId = m_srcIdMap->getRodID(crate, slink, 0, - m_subDetector); - // In principle rodId === robId - const uint32_t robId = m_srcIdMap->getRobID(rodId); - - // In m_sourceIDs we store all ROB Ids from L1Calo - m_sourceIDs.push_back(robId); - - // Spare IDs in crates 2,3,4,5 - if (m_channelsType != ChannelsType::Data) { - const int BEGIN_SPARE_CRATE { 2 }; - const int END_SPARE_CRATE { 5 }; - - if (crate >= BEGIN_SPARE_CRATE && crate < END_SPARE_CRATE) { - if (m_channelsType == ChannelsType::Spare) { - m_sourceIDsSpare.push_back(robId); - } - // Muon ids in create 2,3 and slink=0 - const int END_MUON_CRATE { 3 }; - const int SLINK_MUON { 0 }; - - if (m_channelsType == ChannelsType::Muon && crate <= END_MUON_CRATE - && slink == SLINK_MUON) { - m_sourceIDsMuon.push_back(robId); - } - } - } - } - } - } - // ------------------------------------------------------------------------- - switch (m_channelsType) { - case ChannelsType::Spare: - return m_sourceIDsSpare; - case ChannelsType::Muon: - return m_sourceIDsMuon; - default: - return m_sourceIDs; - } -} - -// Add compression stats to totals -void PpmByteStreamV2Tool::addCompStats(const std::vector<uint32_t>& stats) -{ - if (stats.empty()) return; - const int n = stats.size(); - if (m_compStats.empty()) m_compStats.resize(n); - for (int i = 0; i < n; ++i) m_compStats[i] += stats[i]; -} - -// Print compression stats -void PpmByteStreamV2Tool::printCompStats() const -{ - msg() << "Compression stats format/count: "; - const int n = m_compStats.size(); - for (int i = 0; i < n; ++i) { - msg() << " " << i << "/" << m_compStats[i]; - } - msg() << endreq; -} - - -void PpmByteStreamV2Tool::setupSourceTowers( - const xAOD::TriggerTowerContainer* ttCollection) { - using std::accumulate; - for(auto* tt: *ttCollection) { - if ( - accumulate(tt->lut_cp().begin(), tt->lut_cp().end(), 0) - || - accumulate(tt->lut_jep().begin(), tt->lut_jep().end(), 0) - ) { - // Collect only non empty towers - m_source_towers.push_back(tt); - } - - } -} - - -// =========================================================================== -}// end namespace diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmByteStreamV2Tool.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmByteStreamV2Tool.h deleted file mode 100644 index a77493007705b891833b6368e55f3d3f7193e602..0000000000000000000000000000000000000000 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmByteStreamV2Tool.h +++ /dev/null @@ -1,199 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef TRIGT1CALOBYTESTREAM_PPMBYTESTREAMV2TOOL_H -#define TRIGT1CALOBYTESTREAM_PPMBYTESTREAMV2TOOL2_H -// =========================================================================== -// Includes -// =========================================================================== -// STD: -// =========================================================================== -#include <stdint.h> - -#include <map> -#include <string> -#include <vector> -#include <sstream> -// =========================================================================== -// Athena: -// =========================================================================== -#include "AthenaBaseComps/AthAlgTool.h" -#include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" -#include "ByteStreamData/RawEvent.h" -#include "DataModel/DataVector.h" -#include "eformat/SourceIdentifier.h" - -#include "GaudiKernel/ServiceHandle.h" -#include "GaudiKernel/ToolHandle.h" - - -#include "xAODTrigL1Calo/TriggerTower.h" -#include "xAODTrigL1Calo/TriggerTowerContainer.h" - -// =========================================================================== -// Forward declarations -// =========================================================================== -class IInterface; -class InterfaceID; -class SegMemSvc; -template <class T> class FullEventAssembler; - -namespace xAOD { - class TriggerTower_v2; -} - -namespace LVL1 { - class IL1CaloMappingTool; -} - -// =========================================================================== -namespace LVL1BS { -// =========================================================================== -class L1CaloErrorByteStreamTool; -class L1CaloSrcIdMap; -class PpmSubBlockV2; - -/** Tool to perform ROB fragments to trigger towers and trigger towers - * to raw data conversions. - * - * - * @author alexander.mazurov@cern.ch - * @author Peter Faulkner - */ - -class PpmByteStreamV2Tool: public AthAlgTool { - -public: - PpmByteStreamV2Tool(const std::string& type, const std::string& name, - const IInterface* parent); - virtual ~PpmByteStreamV2Tool(); - - /// AlgTool InterfaceID - static const InterfaceID& interfaceID(); - - virtual StatusCode initialize(); - virtual StatusCode finalize(); - - /// Convert ROB fragments to trigger towers - StatusCode convert(const IROBDataProviderSvc::VROBFRAG& robFrags, - xAOD::TriggerTowerContainer* const ttCollection); - - /// Convert trigger towers to bytestream - StatusCode convert(const xAOD::TriggerTowerContainer* ttCollection, - RawEventWrite* re); - - /// Return reference to vector with all possible Source Identifiers - const std::vector<uint32_t>& sourceIDs(const std::string& sgKey); - -private: - void reserveMemory(xAOD::TriggerTowerContainer* const ttCollection); - void collectTriggerTowers(const IROBDataProviderSvc::VROBFRAG& robFrags, - xAOD::TriggerTowerContainer* const ttCollection); - uint_least32_t coolId(int crate, int module, int channel) const; - /// Add compression stats to totals - void addCompStats(const std::vector<uint32_t>& stats); - /// Print compression stats - void printCompStats() const; - /// Print a vector - template <typename T> - std::string vectorToString(const std::vector<T>& vec) const; - -private: - // Private functions for encoding - void setupSourceTowers(const xAOD::TriggerTowerContainer* ttCollection); - -private: - // typedef DataVector<LVL1::TriggerTower2> TriggerTowerCollection; - typedef std::vector<const xAOD::TriggerTower*> TriggerTowerVector; - typedef std::map<unsigned int, int> TriggerTowerMap; - typedef std::vector<uint32_t> ChannelBitVector; - - typedef IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator; - typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType ROBPointer; - typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType RODPointer; - - typedef enum { - Data, Spare, Muon - } ChannelsType; - /// Services - ServiceHandle<SegMemSvc> m_sms; - /// Source ID converter - L1CaloSrcIdMap* m_srcIdMap; - /// Channel mapping tool - ToolHandle<LVL1::IL1CaloMappingTool> m_ppmMaps; - // Error collection tool - ToolHandle<LVL1BS::L1CaloErrorByteStreamTool> m_errorTool; - /// Current error block - PpmSubBlockV2* m_errorBlock; - /// Vector for current PPM sub-blocks - DataVector<PpmSubBlockV2> m_ppmBlocks; - /// Vector for compression statistics - std::vector<uint32_t> m_compStats; - - - /// Sub-detector type - const eformat::SubDetector m_subDetector; - int m_crates; - int m_modules; - int m_channels; - int m_dataSize; - int m_maxSlinks; - - ChannelsType m_channelsType; - ChannelBitVector m_dataChan; - ChannelBitVector m_dataMod; - ChannelBitVector m_chanLayer; - ChannelBitVector m_foundChan; - - - /// ROB source IDs - std::vector<uint32_t> m_sourceIDs; - std::vector<uint32_t> m_sourceIDsSpare; - std::vector<uint32_t> m_sourceIDsMuon; - - - /// TriggerTower pool vectors - TriggerTowerVector m_ttData; - // TriggerTowerVector m_ttSpare; - // TriggerTowerVector m_ttMuon; - std::vector<int> m_ttPos; - - - /// Compression statistics print flag - int m_printCompStats; - /// Pedestal value - int m_pedestal; - /// FADC baseline lower bound - int m_fadcBaseline; - -private: - // For writing to bytestream - /// ROD status map - std::map<uint32_t, std::vector<uint32_t>* > m_rodStatusMap; - // Event assembler - FullEventAssembler<L1CaloSrcIdMap>* m_fea; - - TriggerTowerVector m_source_towers; - - short m_dataFormat; - short m_subheaderVersion; - -}; -// =========================================================================== -template<typename T> -std::string PpmByteStreamV2Tool::vectorToString(const std::vector<T>& vec) const -{ - std::stringstream res; - for (auto pos = vec.cbegin(); pos != vec.cend(); ++pos) { - if (pos != vec.begin()) - res << ","; - res << int(*pos); - } - res << "/" ; - return res.str(); -} -// =========================================================================== -}// end namespace -// =========================================================================== -#endif diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmCompressionV2.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmCompressionV2.cxx deleted file mode 100644 index 47ba0d823d9bad70ff9a3c1afdd66a5803fbf42c..0000000000000000000000000000000000000000 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmCompressionV2.cxx +++ /dev/null @@ -1,664 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -#include <stdint.h> -#include <algorithm> -#include <vector> - -#include "L1CaloSubBlock.h" -#include "PpmCompressionV2.h" -#include "PpmSubBlockV2.h" - -namespace LVL1BS { - -// Static constants - -const int PpmCompressionV2::s_formatsV0; -const int PpmCompressionV2::s_lowerRange; -const int PpmCompressionV2::s_upperRange; -const int PpmCompressionV2::s_formats; -const int PpmCompressionV2::s_fadcRange; -const int PpmCompressionV2::s_peakOnly; -const int PpmCompressionV2::s_lutDataBits; -const int PpmCompressionV2::s_lutBcidBits; -const int PpmCompressionV2::s_fadcDataBits; -const int PpmCompressionV2::s_glinkPins; -const int PpmCompressionV2::s_statusBits; -const int PpmCompressionV2::s_errorBits; -const int PpmCompressionV2::s_statusMask; - -// Pack data - -bool PpmCompressionV2::pack(PpmSubBlockV2& /*subBlock*/) -{ - // TODO: (sasha) implement packs - // const int dataFormat = subBlock.format(); - // if (dataFormat != L1CaloSubBlock::COMPRESSED && - // dataFormat != L1CaloSubBlock::SUPERCOMPRESSED) return false; - // const int sliceL = subBlock.slicesLut(); - // const int sliceF = subBlock.slicesFadc(); - // if (sliceL != 1 || sliceF != 5) return false; - // const int trigOffset = subBlock.fadcOffset() - subBlock.lutOffset(); - // const int fadcBaseline = subBlock.fadcBaseline(); - // const int fadcThreshold = subBlock.fadcThreshold(); - // const int channels = subBlock.channelsPerSubBlock(); - // subBlock.setStreamed(); - // std::vector<uint32_t> compStats(s_formats); - // std::vector<uint_least16_t> fadcDout(sliceF-1); - // std::vector<uint_least16_t> fadcLens(sliceF-1); - - // for (int chan = 0; chan < channels; ++chan) { - // std::vector<uint_least8_t> lutCpData; - // std::vector<uint_least8_t> lutJepData; - // std::vector<int> lutCpBcid; - - // std::vector<uint_least16_t> fadcData; - // std::vector<int> fadcBcid; - - // subBlock.ppmData(chan, lutData, fadcData, lutBcid, fadcBcid); - // if (dataFormat == L1CaloSubBlock::SUPERCOMPRESSED) { - // int dataPresent = lutData[0] || lutBcid[0]; - // if ( !dataPresent ) { - // for (int sl = 0; sl < sliceF; ++sl) { - // if (fadcData[sl] >= fadcThreshold || fadcBcid[sl]) { - // dataPresent = 1; - // break; - // } - // } - // } - // subBlock.packer(dataPresent, 1); - // if ( !dataPresent ) continue; - // } - // const int lutLen = subBlock.minBits(lutData[0]); - // int minFadc = 0; - // int minOffset = 0; - // bool fadcSame = true; - // for (int sl = 0; sl < sliceF; ++sl) { - // if (sl == 0) minFadc = fadcData[sl]; - // if (fadcData[sl] < minFadc) { - // minFadc = fadcData[sl]; - // minOffset = sl; - // } - // if (fadcData[sl] != fadcData[0] || fadcBcid[sl] != 0) fadcSame = false; - // } - // if (minOffset) std::swap(fadcData[0], fadcData[minOffset]); - - // int format = 0; - // if (lutData[0] == 0 && lutBcid[0] == 0 && fadcSame) { // format 6 - // const int header = 15; - // subBlock.packer(header, 4); - // if (fadcData[0]) { - // subBlock.packer(1, 1); - // subBlock.packer(fadcData[0], s_fadcDataBits); - // } else subBlock.packer(0, 1); - // format = 6; - // } else { - // const bool minFadcInRange = minFadc >= fadcBaseline && - // minFadc <= fadcBaseline + s_fadcRange; - // int anyFadcBcid = 0; - // int maxFadcLen = 0; - // int idx = 0; - // for (int sl = 0; sl < sliceF; ++sl) { - // if (sl != 0) { - // fadcDout[idx] = fadcData[sl] - minFadc; - // fadcLens[idx] = subBlock.minBits(fadcDout[idx]); - // if (idx == 0 || fadcLens[idx] > maxFadcLen) { - // maxFadcLen = fadcLens[idx]; - // } - // ++idx; - // } - // if (sl != trigOffset) anyFadcBcid |= fadcBcid[sl]; - // else if (fadcBcid[sl] != (lutBcid[0] & 0x1)) anyFadcBcid |= 1; - // } - // if (lutData[0] == 0 && lutBcid[0] == 0 && - // !anyFadcBcid && minFadcInRange && maxFadcLen < 4) { - // // formats 0,1 - // int header = minOffset; - // if (maxFadcLen == 3) header += 5; - // subBlock.packer(header, 4); - // minFadc -= fadcBaseline; - // subBlock.packer(minFadc, 4); - // if (maxFadcLen < 2) maxFadcLen = 2; - // for (int idx = 0; idx < sliceF-1; ++idx) { - // subBlock.packer(fadcDout[idx], maxFadcLen); - // } - // format = maxFadcLen - 2; - // } else if (lutLen <= 3 && ((lutData[0] == 0 && lutBcid[0] == 0) || - // (lutData[0] > 0 && lutBcid[0] == s_peakOnly)) - // && !anyFadcBcid && minFadcInRange && maxFadcLen <= 4) { - // // format 2 - // const int header = minOffset + 10; - // subBlock.packer(header, 4); - // format = 2; - // subBlock.packer(format - 2, 2); - // if (lutData[0]) { - // subBlock.packer(1, 1); - // subBlock.packer(lutData[0], 3); - // } else subBlock.packer(0, 1); - // minFadc -= fadcBaseline; - // subBlock.packer(minFadc, 4); - // for (int idx = 0; idx < sliceF-1; ++idx) { - // subBlock.packer(fadcDout[idx], 4); - // } - // } else { - // // formats 3,4,5 - // const int header = minOffset + 10; - // subBlock.packer(header, 4); - // if ( !minFadcInRange) { - // const int minFadcLen = subBlock.minBits(minFadc); - // if (minFadcLen > maxFadcLen) maxFadcLen = minFadcLen; - // } - // format = 5; - // if (maxFadcLen <= 8) format = 4; - // if (maxFadcLen <= 6) format = 3; - // subBlock.packer(format - 2, 2); - // if (lutData[0] || lutBcid[0]) subBlock.packer(1, 1); - // else subBlock.packer(0, 1); - // subBlock.packer(anyFadcBcid, 1); - // if (lutData[0] || lutBcid[0]) { - // subBlock.packer(lutData[0], s_lutDataBits); - // subBlock.packer(lutBcid[0], s_lutBcidBits); - // } - // if (anyFadcBcid) { - // for (int idx = 0; idx < sliceF; ++idx) { - // subBlock.packer(fadcBcid[idx], 1); - // } - // } - // if (minFadcInRange) { - // subBlock.packer(0, 1); - // minFadc -= fadcBaseline; - // subBlock.packer(minFadc, 4); - // } else { - // subBlock.packer(1, 1); - // subBlock.packer(minFadc, format * 2); - // } - // for (int idx = 0; idx < sliceF-1; ++idx) { - // if (fadcLens[idx] <= 4) { - // subBlock.packer(0, 1); - // subBlock.packer(fadcDout[idx], 4); - // } else { - // subBlock.packer(1, 1); - // subBlock.packer(fadcDout[idx], format * 2); - // } - // } - // } - // } - // ++compStats[format]; - // } - // // Errors - // std::vector<int> status(s_glinkPins); - // std::vector<int> error(s_glinkPins); - // int statusBit = 0; - // int errorBit = 0; - // for (int pin = 0; pin < s_glinkPins; ++pin) { - // const int errorWord = subBlock.ppmPinError(pin); - // status[pin] = errorWord & s_statusMask; - // error[pin] = errorWord >> s_statusBits; - // if (status[pin]) statusBit = 1; - // if (error[pin]) errorBit = 1; - // } - // subBlock.packer(statusBit, 1); - // subBlock.packer(errorBit, 1); - // if (statusBit || errorBit) { - // for (int pin = 0; pin < s_glinkPins; ++pin) { - // if (status[pin] || error[pin]) subBlock.packer(1, 1); - // else subBlock.packer(0, 1); - // } - // for (int pin = 0; pin < s_glinkPins; ++pin) { - // if (status[pin] || error[pin]) { - // if (statusBit) subBlock.packer(status[pin], s_statusBits); - // if (errorBit) subBlock.packer(error[pin], s_errorBits); - // } - // } - // } - // subBlock.packerFlush(); - // subBlock.setCompStats(compStats); - return true; -} - -// Unpack data - -bool PpmCompressionV2::unpack(PpmSubBlockV2& subBlock) -{ - bool rc = false; - switch (subBlock.seqno()) { - case 0: - rc = unpackV100(subBlock); - break; - case 1: - rc = unpackV101(subBlock); - break; - case 2: - case 3: - case 4: - case 5: // runs 88701-24 only - rc = unpackV104(subBlock); - break; - default: - subBlock.setUnpackErrorCode(L1CaloSubBlock::UNPACK_COMPRESSION_VERSION); - break; - } - return rc; -} - -// Unpack data - version 1.00 - -bool PpmCompressionV2::unpackV100(PpmSubBlockV2& subBlock) -{ - if (subBlock.format() != L1CaloSubBlock::COMPRESSED) { - subBlock.setUnpackErrorCode(L1CaloSubBlock::UNPACK_FORMAT); - return false; - } - const int sliceL = subBlock.slicesLut(); - const int sliceF = subBlock.slicesFadc(); - if (sliceL != 1 || sliceF != 5) { - subBlock.setUnpackErrorCode(L1CaloSubBlock::UNPACK_COMPRESSION_SLICES); - return false; - } - const int trigOffset = subBlock.fadcOffset(); - const int pedestal = subBlock.pedestal(); - const int channels = subBlock.channelsPerSubBlock(); - subBlock.setStreamed(); - subBlock.unpackerInit(); - std::vector<uint32_t> compStats(s_formatsV0); - std::vector<uint_least8_t> lutData; - std::vector<int> lutBcid; - std::vector<uint_least16_t> fadcData; - std::vector<int> fadcBcid; - for (int chan = 0; chan < channels; ++chan) { - lutData.clear(); - lutBcid.clear(); - fadcData.clear(); - fadcBcid.clear(); - int format = 0; - const int header = subBlock.unpacker(4); - if (header < 10) { - // formats 0,1 - LUT zero, FADC around pedestal - const int minOffset = header % 5; - format = header / 5; - // LUT = 0 - lutData.push_back(0); - lutBcid.push_back(0); - // FADC - const uint32_t minFadc = subBlock.unpacker(4) + pedestal - s_lowerRange; - for (int sl = 0; sl < sliceF; ++sl) { - if (sl == minOffset) fadcData.push_back(minFadc); - else fadcData.push_back(subBlock.unpacker(format + 2) + minFadc); - fadcBcid.push_back(0); - } - } else { - // formats 2-5 - const int minOffset = header - 10; - format = subBlock.unpacker(2) + 2; - const int anyLut = subBlock.unpacker(1); - int lut = 0; - int bcid = 0; - if (format == 2) { - // LUT - if (anyLut) { - lut = subBlock.unpacker(3); - bcid = s_peakOnly; // just peak-finding BCID set - } - lutData.push_back(lut); - lutBcid.push_back(bcid); - // FADC as formats 0,1 - const int minFadc = subBlock.unpacker(4) + pedestal - s_lowerRange; - for (int sl = 0; sl < sliceF; ++sl) { - if (sl == minOffset) fadcData.push_back(minFadc); - else fadcData.push_back(subBlock.unpacker(format + 2) + minFadc); - fadcBcid.push_back(0); - } - } else { - // formats 3,4,5 - full LUT word, variable FADC - const int anyBcid = subBlock.unpacker(1); - // LUT - if (anyLut) { - lut = subBlock.unpacker(s_lutDataBits); - bcid = subBlock.unpacker(s_lutBcidBits); - } - lutData.push_back(lut); - lutBcid.push_back(bcid); - // FADC - for (int sl = 0; sl < sliceF; ++sl) { - int fbcid = 0; - if (sl == trigOffset) fbcid = bcid & 0x1; // take from LUT word - else if (anyBcid) fbcid = subBlock.unpacker(1); - fadcBcid.push_back(fbcid); - } - int minFadc = 0; - if (subBlock.unpacker(1)) minFadc = subBlock.unpacker(format * 2); - else minFadc = subBlock.unpacker(4) + pedestal - s_lowerRange; - for (int sl = 0; sl < sliceF; ++sl) { - int fadc = minFadc; - if (sl != minOffset) { - if (subBlock.unpacker(1)) fadc += subBlock.unpacker(format * 2); - else fadc += subBlock.unpacker(4); - } - fadcData.push_back(fadc); - } - } - } - subBlock.fillPpmData(chan, lutData, fadcData, lutBcid, fadcBcid); - ++compStats[format]; - } - subBlock.setCompStats(compStats); - const bool rc = subBlock.unpackerSuccess(); - if (!rc) subBlock.setUnpackErrorCode(L1CaloSubBlock::UNPACK_DATA_TRUNCATED); - return rc; -} - -// Unpack data - version 1.01 - -bool PpmCompressionV2::unpackV101(PpmSubBlockV2& subBlock) -{ - if (subBlock.format() != L1CaloSubBlock::COMPRESSED) { - subBlock.setUnpackErrorCode(L1CaloSubBlock::UNPACK_FORMAT); - return false; - } - const int sliceL = subBlock.slicesLut(); - const int sliceF = subBlock.slicesFadc(); - if (sliceL != 1 || sliceF != 5) { - subBlock.setUnpackErrorCode(L1CaloSubBlock::UNPACK_COMPRESSION_SLICES); - return false; - } - const int trigOffset = subBlock.fadcOffset(); - const int pedestal = subBlock.pedestal(); - const int channels = subBlock.channelsPerSubBlock(); - subBlock.setStreamed(); - subBlock.unpackerInit(); - std::vector<uint32_t> compStats(s_formats); - std::vector<uint_least8_t> lutData; - std::vector<int> lutBcid; - std::vector<uint_least16_t> fadcData; - std::vector<int> fadcBcid; - for (int chan = 0; chan < channels; ++chan) { - lutData.clear(); - lutBcid.clear(); - fadcData.clear(); - fadcBcid.clear(); - int format = 0; - const int header = subBlock.unpacker(4); - if (header < 10) { - // formats 0,1 - LUT zero, FADC around pedestal - const int minOffset = header % 5; - format = header / 5; - // LUT = 0 - lutData.push_back(0); - lutBcid.push_back(0); - // FADC - const int minFadc = subBlock.unpacker(4) + pedestal - s_lowerRange; - fadcData.push_back(minFadc); - fadcBcid.push_back(0); - for (int sl = 1; sl < sliceF; ++sl) { - fadcData.push_back(subBlock.unpacker(format + 2) + minFadc); - fadcBcid.push_back(0); - } - if (minOffset) std::swap(fadcData[0], fadcData[minOffset]); - } else if (header < 15) { - // formats 2-5 - const int minOffset = header - 10; - format = subBlock.unpacker(2) + 2; - const int anyLut = subBlock.unpacker(1); - int lut = 0; - int bcid = 0; - if (format == 2) { - // LUT - if (anyLut) { - lut = subBlock.unpacker(3); - bcid = s_peakOnly; // just peak-finding BCID set - } - lutData.push_back(lut); - lutBcid.push_back(bcid); - // FADC as formats 0,1 - const int minFadc = subBlock.unpacker(4) + pedestal - s_lowerRange; - fadcData.push_back(minFadc); - fadcBcid.push_back(0); - for (int sl = 1; sl < sliceF; ++sl) { - fadcData.push_back(subBlock.unpacker(format + 2) + minFadc); - fadcBcid.push_back(0); - } - if (minOffset) std::swap(fadcData[0], fadcData[minOffset]); - } else { - // formats 3,4,5 - full LUT word, variable FADC - const int anyBcid = subBlock.unpacker(1); - // LUT - if (anyLut) { - lut = subBlock.unpacker(s_lutDataBits); - bcid = subBlock.unpacker(s_lutBcidBits); - } - lutData.push_back(lut); - lutBcid.push_back(bcid); - // FADC - for (int sl = 0; sl < sliceF; ++sl) { - int fbcid = 0; - if (sl == trigOffset) fbcid = bcid & 0x1; // take from LUT word - else if (anyBcid) fbcid = subBlock.unpacker(1); - fadcBcid.push_back(fbcid); - } - int minFadc = 0; - if (subBlock.unpacker(1)) minFadc = subBlock.unpacker(format * 2); - else minFadc = subBlock.unpacker(4) + pedestal - s_lowerRange; - fadcData.push_back(minFadc); - for (int sl = 1; sl < sliceF; ++sl) { - int len = 4; - if (subBlock.unpacker(1)) len = format * 2; - fadcData.push_back(subBlock.unpacker(len) + minFadc); - } - if (minOffset) std::swap(fadcData[0], fadcData[minOffset]); - } - } else { - // format 6 - LUT zero, FADC all equal - format = 6; - // LUT - lutData.push_back(0); - lutBcid.push_back(0); - // FADC - int fadc = 0; - if (subBlock.unpacker(1)) fadc = subBlock.unpacker(s_fadcDataBits); - for (int sl = 0; sl < sliceF; ++sl) { - fadcData.push_back(fadc); - fadcBcid.push_back(0); - } - } - subBlock.fillPpmData(chan, lutData, fadcData, lutBcid, fadcBcid); - ++compStats[format]; - } - // Errors - const int statusBit = subBlock.unpacker(1); - const int errorBit = subBlock.unpacker(1); - if (statusBit || errorBit) { - std::vector<int> err(s_glinkPins); - for (int pin = 0; pin < s_glinkPins; ++pin) { - err[pin] = subBlock.unpacker(1); - } - for (int pin = 0; pin < s_glinkPins; ++pin) { - if (err[pin]) { - int status = 0; - int error = 0; - if (statusBit) status = subBlock.unpacker(s_statusBits-1); - if (errorBit) error = subBlock.unpacker(s_errorBits+1); - subBlock.fillPpmPinError(pin, (error << (s_statusBits-1)) | status); - } - } - } - subBlock.setCompStats(compStats); - const bool rc = subBlock.unpackerSuccess(); - if (!rc) subBlock.setUnpackErrorCode(L1CaloSubBlock::UNPACK_DATA_TRUNCATED); - return rc; -} - -// Unpack data - versions 1.02, 1.03, 1.04, 1.05 (by mistake for a few runs) - -bool PpmCompressionV2::unpackV104(PpmSubBlockV2& subBlock) -{ - const int dataFormat = subBlock.format(); - if (dataFormat != L1CaloSubBlock::COMPRESSED && - dataFormat != L1CaloSubBlock::SUPERCOMPRESSED) { - subBlock.setUnpackErrorCode(L1CaloSubBlock::UNPACK_FORMAT); - return false; - } - const int compressionVersion = subBlock.seqno(); - if (compressionVersion == 2 && dataFormat != L1CaloSubBlock::COMPRESSED) { - subBlock.setUnpackErrorCode(L1CaloSubBlock::UNPACK_FORMAT); - return false; - } - if (compressionVersion == 5) { - const int run = subBlock.runNumber(); - if (run < 88701 || run > 88724) { - subBlock.setUnpackErrorCode(L1CaloSubBlock::UNPACK_COMPRESSION_VERSION); - return false; - } - } - const int sliceL = subBlock.slicesLut(); - const int sliceF = subBlock.slicesFadc(); - if (sliceL != 1 || sliceF != 5) { - subBlock.setUnpackErrorCode(L1CaloSubBlock::UNPACK_COMPRESSION_SLICES); - return false; - } - const int trigOffset = subBlock.fadcOffset() - subBlock.lutOffset(); - const int fadcBaseline = subBlock.fadcBaseline(); - const int channels = subBlock.channelsPerSubBlock(); - subBlock.setStreamed(); - subBlock.unpackerInit(); - std::vector<uint32_t> compStats(s_formats); - std::vector<uint_least8_t> lutData; - std::vector<int> lutBcid; - std::vector<uint_least16_t> fadcData; - std::vector<int> fadcBcid; - for (int chan = 0; chan < channels; ++chan) { - if (dataFormat == L1CaloSubBlock::SUPERCOMPRESSED) { - if ( !subBlock.unpacker(1) ) continue; - } - lutData.clear(); - lutBcid.clear(); - fadcData.clear(); - fadcBcid.clear(); - int format = 0; - const int header = subBlock.unpacker(4); - if (header < 10) { - // formats 0,1 - LUT zero, FADC around pedestal - const int minOffset = header % 5; - format = header / 5; - // LUT = 0 - lutData.push_back(0); - lutBcid.push_back(0); - // FADC - const int minFadc = subBlock.unpacker(4) + fadcBaseline; - fadcData.push_back(minFadc); - fadcBcid.push_back(0); - for (int sl = 1; sl < sliceF; ++sl) { - fadcData.push_back(subBlock.unpacker(format + 2) + minFadc); - fadcBcid.push_back(0); - } - if (minOffset) std::swap(fadcData[0], fadcData[minOffset]); - } else if (header < 15) { - // formats 2-5 - const int minOffset = header - 10; - format = subBlock.unpacker(2) + 2; - const int anyLut = subBlock.unpacker(1); - int lut = 0; - int bcid = 0; - if (format == 2) { - // LUT - if (anyLut) { - lut = subBlock.unpacker(3); - bcid = s_peakOnly; // just peak-finding BCID set - } - lutData.push_back(lut); - lutBcid.push_back(bcid); - // FADC as formats 0,1 - const int minFadc = subBlock.unpacker(4) + fadcBaseline; - fadcData.push_back(minFadc); - fadcBcid.push_back(0); - for (int sl = 1; sl < sliceF; ++sl) { - fadcData.push_back(subBlock.unpacker(format + 2) + minFadc); - fadcBcid.push_back(0); - } - if (minOffset) std::swap(fadcData[0], fadcData[minOffset]); - } else { - // formats 3,4,5 - full LUT word, variable FADC - const int anyBcid = subBlock.unpacker(1); - // LUT - if (anyLut) { - lut = subBlock.unpacker(s_lutDataBits); - bcid = subBlock.unpacker(s_lutBcidBits); - } - lutData.push_back(lut); - lutBcid.push_back(bcid); - // FADC - for (int sl = 0; sl < sliceF; ++sl) { - int fbcid = 0; - if (anyBcid) fbcid = subBlock.unpacker(1); - else if (sl == trigOffset) fbcid = bcid & 0x1; // take from LUT word - fadcBcid.push_back(fbcid); - } - int minFadc = 0; - if (subBlock.unpacker(1)) minFadc = subBlock.unpacker(format * 2); - else minFadc = subBlock.unpacker(4) + fadcBaseline; - fadcData.push_back(minFadc); - for (int sl = 1; sl < sliceF; ++sl) { - int len = 4; - if (subBlock.unpacker(1)) len = format * 2; - fadcData.push_back(subBlock.unpacker(len) + minFadc); - } - if (minOffset) std::swap(fadcData[0], fadcData[minOffset]); - } - } else { - // format 6 - LUT zero, FADC all equal - format = 6; - // LUT - lutData.push_back(0); - lutBcid.push_back(0); - // FADC - int fadc = 0; - if (subBlock.unpacker(1)) fadc = subBlock.unpacker(s_fadcDataBits); - for (int sl = 0; sl < sliceF; ++sl) { - fadcData.push_back(fadc); - fadcBcid.push_back(0); - } - } - subBlock.fillPpmData(chan, lutData, fadcData, lutBcid, fadcBcid); - ++compStats[format]; - } - // Errors - const int statusBit = subBlock.unpacker(1); - const int errorBit = subBlock.unpacker(1); - const bool mcmAbsentIsError = compressionVersion < 4; - const int sBits = (mcmAbsentIsError) ? s_statusBits - 1 : s_statusBits; - const int eBits = (mcmAbsentIsError) ? s_errorBits + 1 : s_errorBits; - if (statusBit || errorBit) { - std::vector<int> err(s_glinkPins); - for (int pin = 0; pin < s_glinkPins; ++pin) { - err[pin] = subBlock.unpacker(1); - } - for (int pin = 0; pin < s_glinkPins; ++pin) { - if (err[pin]) { - int status = 0; - int error = 0; - if (statusBit) status = subBlock.unpacker(sBits); - if (errorBit) error = subBlock.unpacker(eBits); - subBlock.fillPpmPinError(pin, (error << sBits) | status); - } - } - // There is a bug in versions < 4 but if I've understood it correctly - // it is not possible to detect it reliably in data. - } - subBlock.setCompStats(compStats); - bool rc = subBlock.unpackerSuccess(); - if (!rc) subBlock.setUnpackErrorCode(L1CaloSubBlock::UNPACK_DATA_TRUNCATED); - else { - // Check no more non-zero data - indicates corruption - while (subBlock.unpackerSuccess()) { - if (subBlock.unpacker(31)) { - subBlock.setUnpackErrorCode(L1CaloSubBlock::UNPACK_EXCESS_DATA); - rc = false; - break; - } - } - } - return rc; -} - -} // end namespace diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmSubBlockV1.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmSubBlockV1.cxx index b5a94d0efc046464929f8193cc79e75a5a1e191f..3377ab851aa656dbcce6b0d9106a7f9e6186f324 100644 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmSubBlockV1.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmSubBlockV1.cxx @@ -41,9 +41,9 @@ const int PpmSubBlockV1::s_mcmAbsentBit; const int PpmSubBlockV1::s_channelDisabledBit; PpmSubBlockV1::PpmSubBlockV1() : m_globalError(0), m_globalDone(false), - m_lutOffset(-1), m_fadcOffset(-1), - m_pedestal(10), m_fadcBaseline(0), - m_fadcThreshold(0), m_runNumber(0) + m_lutOffset(-1), m_fadcOffset(-1), + m_pedestal(10), m_fadcBaseline(0), + m_fadcThreshold(0), m_runNumber(0) { } @@ -67,22 +67,22 @@ void PpmSubBlockV1::clear() // Store PPM header void PpmSubBlockV1::setPpmHeader(const int version, const int format, - const int seqno, const int crate, - const int module, const int slicesFadc, - const int slicesLut) + const int seqno, const int crate, + const int module, const int slicesFadc, + const int slicesLut) { setHeader(s_wordIdVal, version, format, seqno, crate, module, - slicesFadc, slicesLut); + slicesFadc, slicesLut); } // Store PPM error block header void PpmSubBlockV1::setPpmErrorHeader(const int version, const int format, - const int crate, const int module, - const int slicesFadc, const int slicesLut) + const int crate, const int module, + const int slicesFadc, const int slicesLut) { setHeader(s_wordIdVal, version, format, s_errorMarker, crate, module, - slicesFadc, slicesLut); + slicesFadc, slicesLut); } // Return the number of FADC slices @@ -91,7 +91,7 @@ int PpmSubBlockV1::slicesFadc() const { int slices = slices2(); if (slices == 0 && format() == NEUTRAL) { - slices = dataWords()/(s_asicChannels*s_dataBits) - slicesLut(); + slices = dataWords() / (s_asicChannels * s_dataBits) - slicesLut(); } if (slices <= 0) slices = 1; return slices; @@ -109,9 +109,9 @@ int PpmSubBlockV1::slicesLut() const // Store PPM data for later packing void PpmSubBlockV1::fillPpmData(const int chan, const std::vector<int>& lut, - const std::vector<int>& fadc, - const std::vector<int>& bcidLut, - const std::vector<int>& bcidFadc) + const std::vector<int>& fadc, + const std::vector<int>& bcidLut, + const std::vector<int>& bcidFadc) { const int sliceL = slicesLut(); const int sliceF = slicesFadc(); @@ -122,6 +122,7 @@ void PpmSubBlockV1::fillPpmData(const int chan, const std::vector<int>& lut, dataSize = slices * chanPerSubBlock; m_datamap.resize(dataSize); } + // coverity[divide_by_zero : FALSE] int offset = (chan % chanPerSubBlock) * slices; if (offset + slices <= dataSize) { for (int pos = 0; pos < sliceL; ++pos) { @@ -142,9 +143,9 @@ void PpmSubBlockV1::fillPpmData(const int chan, const std::vector<int>& lut, // Return unpacked data for given channel void PpmSubBlockV1::ppmData(const int chan, std::vector<int>& lut, - std::vector<int>& fadc, - std::vector<int>& bcidLut, - std::vector<int>& bcidFadc) + std::vector<int>& fadc, + std::vector<int>& bcidLut, + std::vector<int>& bcidFadc) { lut.clear(); fadc.clear(); @@ -152,6 +153,7 @@ void PpmSubBlockV1::ppmData(const int chan, std::vector<int>& lut, bcidFadc.clear(); const int sliceL = slicesLut(); const int sliceF = slicesFadc(); + // coverity[divide_by_zero : FALSE] int beg = (chan % channelsPerSubBlock()) * (sliceL + sliceF); int end = beg + sliceL; if (size_t(end + sliceF) <= m_datamap.size()) { @@ -183,7 +185,7 @@ void PpmSubBlockV1::fillPpmError(const int chan, const int errorWord) // Expand one ASIC channel disabled bit to four const uint32_t chanDisabled = (errorWord & 0x1) << asic(chan); m_errormap[pin(chan)] |= (((errorWord >> 1) << s_asicChannels) - | chanDisabled) & s_errorMask; + | chanDisabled) & s_errorMask; } // Store an error word corresponding to a G-Link pin @@ -203,7 +205,7 @@ int PpmSubBlockV1::ppmError(const int chan) const // Replace the four ASIC channel disabled bits with just the one // corresponding to the data channel err = (((m_errormap[pin(chan)] & s_errorMask) >> s_asicChannels) << 1) - | channelDisabled(chan); + | channelDisabled(chan); } return err; } @@ -237,31 +239,31 @@ bool PpmSubBlockV1::pack() { bool rc = false; switch (version()) { - case 1: - switch (format()) { - case NEUTRAL: - rc = packNeutral(); - break; - case UNCOMPRESSED: - switch (seqno()) { - case s_errorMarker: - rc = packUncompressedErrors(); - break; - default: - rc = packUncompressedData(); - break; - } - break; - case COMPRESSED: - case SUPERCOMPRESSED: - rc = PpmCompressionV1::pack(*this); - break; - default: - break; + case 1: + switch (format()) { + case NEUTRAL: + rc = packNeutral(); + break; + case UNCOMPRESSED: + switch (seqno()) { + case s_errorMarker: + rc = packUncompressedErrors(); + break; + default: + rc = packUncompressedData(); + break; } break; + case COMPRESSED: + case SUPERCOMPRESSED: + rc = PpmCompressionV1::pack(*this); + break; default: break; + } + break; + default: + break; } return rc; } @@ -270,33 +272,33 @@ bool PpmSubBlockV1::unpack() { bool rc = false; switch (version()) { - case 1: - switch (format()) { - case NEUTRAL: - rc = unpackNeutral(); - break; - case UNCOMPRESSED: - switch (seqno()) { - case s_errorMarker: - rc = unpackUncompressedErrors(); - break; - default: - rc = unpackUncompressedData(); - break; - } - break; - case COMPRESSED: - case SUPERCOMPRESSED: - rc = PpmCompressionV1::unpack(*this); - break; - default: - setUnpackErrorCode(UNPACK_FORMAT); - break; + case 1: + switch (format()) { + case NEUTRAL: + rc = unpackNeutral(); + break; + case UNCOMPRESSED: + switch (seqno()) { + case s_errorMarker: + rc = unpackUncompressedErrors(); + break; + default: + rc = unpackUncompressedData(); + break; } break; + case COMPRESSED: + case SUPERCOMPRESSED: + rc = PpmCompressionV1::unpack(*this); + break; default: - setUnpackErrorCode(UNPACK_VERSION); + setUnpackErrorCode(UNPACK_FORMAT); break; + } + break; + default: + setUnpackErrorCode(UNPACK_VERSION); + break; } return rc; } @@ -320,7 +322,7 @@ bool PpmSubBlockV1::packNeutral() for (int pin = 0; pin < s_glinkPins; ++pin) { for (int sl = 0; sl < slices; ++sl) { packerNeutral(pin, *pos, s_dataBits); - ++pos; + ++pos; } } } @@ -344,7 +346,7 @@ bool PpmSubBlockV1::packUncompressedData() if (m_datamap.empty()) m_datamap.resize(slices * channels); for (int sl = 0; sl < slices; ++sl) { for (int chan = 0; chan < channels; ++chan) { - packer(m_datamap[sl + chan*slices], s_wordLen); + packer(m_datamap[sl + chan * slices], s_wordLen); } } packerFlush(); @@ -406,7 +408,7 @@ bool PpmSubBlockV1::unpackUncompressedData() unpackerInit(); for (int sl = 0; sl < slices; ++sl) { for (int chan = 0; chan < channels; ++chan) { - m_datamap[sl + chan*slices] = unpacker(s_wordLen); + m_datamap[sl + chan * slices] = unpacker(s_wordLen); } } bool rc = unpackerSuccess(); @@ -416,8 +418,8 @@ bool PpmSubBlockV1::unpackUncompressedData() while (unpackerSuccess()) { if (unpacker(s_wordLen)) { setUnpackErrorCode(UNPACK_EXCESS_DATA); - rc = false; - break; + rc = false; + break; } } } @@ -439,8 +441,8 @@ bool PpmSubBlockV1::unpackUncompressedErrors() while (unpackerSuccess()) { if (unpacker(s_wordLen)) { setUnpackErrorCode(UNPACK_EXCESS_DATA); - rc = false; - break; + rc = false; + break; } } } @@ -453,24 +455,24 @@ int PpmSubBlockV1::channelsPerSubBlock(const int version, const int format) { int chan = 0; switch (version) { - case 1: - switch (format) { - case UNCOMPRESSED: - chan = s_channels/s_asicChannels; - break; - case NEUTRAL: - case COMPRESSED: - case SUPERCOMPRESSED: - chan = s_channels; - break; - default: - setUnpackErrorCode(UNPACK_FORMAT); - break; - } + case 1: + switch (format) { + case UNCOMPRESSED: + chan = s_channels / s_asicChannels; + break; + case NEUTRAL: + case COMPRESSED: + case SUPERCOMPRESSED: + chan = s_channels; break; default: - setUnpackErrorCode(UNPACK_VERSION); + setUnpackErrorCode(UNPACK_FORMAT); break; + } + break; + default: + setUnpackErrorCode(UNPACK_VERSION); + break; } return chan; } @@ -485,8 +487,8 @@ int PpmSubBlockV1::channelsPerSubBlock() bool PpmSubBlockV1::errorBlock(const uint32_t word) { bool rc = false; - if (format(word) == UNCOMPRESSED && - seqno(word) == s_errorMarker) rc = true; + if (format(word) == UNCOMPRESSED && + seqno(word) == s_errorMarker) rc = true; return rc; } diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmSubBlockV2.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmSubBlockV2.cxx deleted file mode 100755 index 57753e9aa7ad93c8f25e2606f829d50de9dec35e..0000000000000000000000000000000000000000 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmSubBlockV2.cxx +++ /dev/null @@ -1,676 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -#include "PpmCompressionV2.h" -#include "PpmSubBlockV2.h" - -namespace LVL1BS -{ - -// Constant definitions - -const uint32_t PpmSubBlockV2::s_wordIdVal; -const int PpmSubBlockV2::s_errorMarker; - -const int PpmSubBlockV2::s_wordLen; -const int PpmSubBlockV2::s_lutBit; -const int PpmSubBlockV2::s_bcidLutBit; -const int PpmSubBlockV2::s_fadcBit; -const int PpmSubBlockV2::s_fadcBitV2; -const int PpmSubBlockV2::s_bcidFadcBit; -const int PpmSubBlockV2::s_bcidFadcBitV2; -const uint32_t PpmSubBlockV2::s_lutMask; -const uint32_t PpmSubBlockV2::s_bcidLutMask; -const uint32_t PpmSubBlockV2::s_fadcMask; -const uint32_t PpmSubBlockV2::s_bcidFadcMask; - -const int PpmSubBlockV2::s_channels; -const int PpmSubBlockV2::s_glinkPins; -const int PpmSubBlockV2::s_asicChannels; -const int PpmSubBlockV2::s_dataBits; -const int PpmSubBlockV2::s_errorBits; -const int PpmSubBlockV2::s_bunchCrossingBits; - -const uint32_t PpmSubBlockV2::s_errorMask; -const int PpmSubBlockV2::s_glinkPinParityBit; -const int PpmSubBlockV2::s_fpgaCorruptBit; -const int PpmSubBlockV2::s_bunchMismatchBit; -const int PpmSubBlockV2::s_eventMismatchBit; -const int PpmSubBlockV2::s_asicFullBit; -const int PpmSubBlockV2::s_timeoutBit; -const int PpmSubBlockV2::s_mcmAbsentBit; -const int PpmSubBlockV2::s_channelDisabledBit; - -const uint16_t PpmSubBlockV2::s_run2minorVersion; - -PpmSubBlockV2::PpmSubBlockV2() : m_globalError(0), m_globalDone(false), - m_lutOffset(-1), m_fadcOffset(-1), - m_pedestal(10), m_fadcBaseline(0), - m_fadcThreshold(0), m_runNumber(0) -{ -} - -PpmSubBlockV2::~PpmSubBlockV2() -{ -} - -// Clear all data - -void PpmSubBlockV2::clear() -{ - L1CaloSubBlock::clear(); - m_globalError = 0; - m_globalDone = false; - m_lutOffset = -1; - m_fadcOffset = -1; - m_datamap.clear(); - m_errormap.clear(); -} - -// Store PPM header - -void PpmSubBlockV2::setPpmHeader(const int version, const int format, - const int seqno, const int crate, - const int module, const int slicesFadc, - const int slicesLut) -{ - setHeader(s_wordIdVal, version, format, seqno, crate, module, - slicesFadc, slicesLut); -} - -// Store PPM error block header - -void PpmSubBlockV2::setPpmErrorHeader(const int version, const int format, - const int crate, const int module, - const int slicesFadc, const int slicesLut) -{ - setHeader(s_wordIdVal, version, format, s_errorMarker, crate, module, - slicesFadc, slicesLut); -} - -// Return the number of FADC slices - -int PpmSubBlockV2::slicesFadc() const -{ - int slices = slices2(); - if (slices == 0 && format() == NEUTRAL) - { - slices = dataWords() / (s_asicChannels * s_dataBits) - slicesLut(); - } - if (slices <= 0) slices = 1; - return slices; -} - -// Return the number of LUT slices - -int PpmSubBlockV2::slicesLut() const -{ - int slices = slices1(); - if (slices == 0) slices = 1; - return slices; -} - -// Store PPM data for later packing - -void PpmSubBlockV2::fillPpmData(const int chan, - const std::vector<uint_least8_t> &lut, - const std::vector<uint_least16_t> &fadc, - const std::vector<int> &bcidLut, - const std::vector<int> &bcidFadc) -{ - const int sliceL = slicesLut(); - const int sliceF = slicesFadc(); - const int slices = sliceL + sliceF; - const int chanPerSubBlock = channelsPerSubBlock(); - int dataSize = m_datamap.size(); - if (dataSize == 0) - { - dataSize = slices * chanPerSubBlock; - m_datamap.resize(dataSize); - } - int offset = (chan % chanPerSubBlock) * slices; - if (offset + slices <= dataSize) - { - for (int pos = 0; pos < sliceL; ++pos) - { - uint32_t datum = (lut[pos] & s_lutMask) << s_lutBit; - datum |= (bcidLut[pos] & s_bcidLutMask) << s_bcidLutBit; - m_datamap[offset + pos] = datum; - } - offset += sliceL; - for (int pos = 0; pos < sliceF; ++pos) - { - const int adc = (fadc[pos] > 0) ? fadc[pos] : 0; - uint32_t datum = (adc & s_fadcMask) << s_fadcBit; - datum |= (bcidFadc[pos] & s_bcidFadcMask) << s_bcidFadcBit; - m_datamap[offset + pos] = datum; - } - } -} - -// Return unpacked data for given channel - -void PpmSubBlockV2::ppmData( - const int chan, - std::vector<uint_least8_t> &lutCp, - std::vector<uint_least8_t> &lutJep, - std::vector<uint_least16_t> &fadc, - std::vector<uint_least8_t> &bcidLutCp, - std::vector<uint_least8_t> &satLutJep, - std::vector<uint_least8_t> &bcidFadc, - std::vector<int_least16_t> &correction, - std::vector<uint_least8_t> &correctionEnabled - -) -{ - lutCp.clear(); - lutJep.clear(); - fadc.clear(); - - bcidLutCp.clear(); - satLutJep.clear(); - bcidFadc.clear(); - - correction.clear(); - correctionEnabled.clear(); - - if (isRun2()) - { - ppmDataRun2(chan, lutCp, lutJep, fadc, bcidLutCp, satLutJep, - bcidFadc, correction, correctionEnabled); - } - else // MCM - { - ppmDataRun1(chan, lutCp, fadc, bcidLutCp, bcidFadc); - } -} - - -void PpmSubBlockV2::ppmDataRun2( - const int chan, - std::vector<uint_least8_t> &lutCp, - std::vector<uint_least8_t> &lutJep, - std::vector<uint_least16_t> &fadc, - std::vector<uint_least8_t> &bcidLutCp, - std::vector<uint_least8_t> &satLutJep, - std::vector<uint_least8_t> &bcidFadc, - std::vector<int_least16_t> &correction, - std::vector<uint_least8_t> &correctionEnabled - -) -{ - const int sliceL = slicesLut(); - const int sliceF = slicesFadc(); - - int pos = (chan % channelsPerSubBlock()) * (3 * sliceL + sliceF); - - uint_least32_t word; - for (int i = 0; i < sliceL; ++i) - { - word = m_datamap[pos++]; - lutCp.push_back((word >> s_lutBit) & s_lutMask); - bcidLutCp.push_back((word >> s_bcidLutBit) & s_bcidLutMask); - } - - for (int i = 0; i < sliceL; ++i) - { - word = m_datamap[pos++]; - lutJep.push_back((word >> s_lutBit) & s_lutMask); - satLutJep.push_back((word >> s_bcidLutBit) & s_bcidLutMask); - } - - for (int i = 0; i < sliceF; i++) - { - word = m_datamap[pos++]; - fadc.push_back((word >> s_fadcBitV2) & s_fadcMask); - bcidFadc.push_back((word >> s_bcidFadcBitV2) & s_bcidFadcMask); - } - - for (int i = 0; i < sliceL; i++) - { - word = m_datamap[pos++]; - correction.push_back((word >> s_fadcBitV2) & s_fadcMask); - correctionEnabled.push_back((word >> s_bcidFadcBitV2) & s_bcidFadcMask); - } -} - -void PpmSubBlockV2::ppmDataRun1(int chan, - std::vector<uint_least8_t> &lut, - std::vector<uint_least16_t> &fadc, - std::vector<uint_least8_t> &bcidLut, - std::vector<uint_least8_t> &bcidFadc - ) -{ - const int sliceL = slicesLut(); - const int sliceF = slicesFadc(); - - int pos = (chan % channelsPerSubBlock()) * (sliceL + sliceF); - - uint32_t word; - for (int i = 0; i < sliceL; ++i) - { - word = m_datamap[pos++]; - lut.push_back((word >> s_lutBit) & s_lutMask); - bcidLut.push_back((word >> s_bcidLutBit) & s_bcidLutMask); - } - - for (int i = 0; i < sliceF; i++) - { - word = m_datamap[pos++]; - fadc.push_back((word >> s_fadcBit) & s_fadcMask); - bcidFadc.push_back((word >> s_bcidFadcBit) & s_bcidFadcMask); - } -} - -// Store an error word corresponding to a data channel - -void PpmSubBlockV2::fillPpmError(const int chan, const int errorWord) -{ - if (m_errormap.empty()) m_errormap.resize(s_glinkPins); - // Expand one ASIC channel disabled bit to four - const uint32_t chanDisabled = (errorWord & 0x1) << asic(chan); - m_errormap[pin(chan)] |= (((errorWord >> 1) << s_asicChannels) - | chanDisabled) & s_errorMask; -} - -// Store an error word corresponding to a G-Link pin - -void PpmSubBlockV2::fillPpmPinError(const int pin, const int errorWord) -{ - if (m_errormap.empty()) m_errormap.resize(s_glinkPins); - m_errormap[pin] = errorWord & s_errorMask; -} - -// Return the error word for a data channel - -int PpmSubBlockV2::ppmError(const int chan) const -{ - int err = 0; - if ( !m_errormap.empty()) - { - // Replace the four ASIC channel disabled bits with just the one - // corresponding to the data channel - err = (((m_errormap[pin(chan)] & s_errorMask) >> s_asicChannels) << 1) - | channelDisabled(chan); - } - return err; -} - -// Return the error word for a G-Link pin - -int PpmSubBlockV2::ppmPinError(const int pin) const -{ - int err = 0; - if ( !m_errormap.empty()) err = m_errormap[pin] & s_errorMask; - return err; -} - -// Return global error bit - -bool PpmSubBlockV2::errorBit(const int bit) const -{ - if ( ! m_globalDone) - { - std::vector<uint32_t>::const_iterator pos; - for (pos = m_errormap.begin(); pos != m_errormap.end(); ++pos) - { - m_globalError |= *pos; - } - m_globalDone = true; - } - return m_globalError & (0x1 << bit); -} - -// Packing/Unpacking routines - -bool PpmSubBlockV2::pack() -{ - bool rc = false; - switch (format()) - { - case NEUTRAL: - rc = packNeutral(); - break; - case UNCOMPRESSED: - switch (seqno()) - { - case s_errorMarker: - rc = packUncompressedErrors(); - break; - default: - rc = packUncompressedData(); - break; - } - break; - case COMPRESSED: - case SUPERCOMPRESSED: - rc = PpmCompressionV2::pack(*this); - break; - default: - break; - } - return rc; -} - -bool PpmSubBlockV2::unpack() -{ - bool rc = false; - // TODO: (sasha) We can check subblock header here (ask experts) - // Now we verify only ROD version - switch (version()) - { - case 1: case 2: - switch (format()) - { - case NEUTRAL: - rc = unpackNeutral(); - break; - case UNCOMPRESSED: - switch (seqno()) - { - case s_errorMarker: - rc = unpackUncompressedErrors(); - break; - default: - rc = unpackUncompressedData(); - break; - } - break; - case COMPRESSED: - case SUPERCOMPRESSED: - rc = PpmCompressionV2::unpack(*this); - break; - default: - setUnpackErrorCode(UNPACK_FORMAT); - break; - } - break; - default: - setUnpackErrorCode(UNPACK_VERSION); - break; - } - return rc; -} - -// Pack neutral data - -bool PpmSubBlockV2::packNeutral() -{ - const int slices = slicesLut() + slicesFadc(); - const int channels = channelsPerSubBlock(); - if (m_datamap.empty()) m_datamap.resize(slices * channels); - // Bunch crossing number - for (int pin = 0; pin < s_glinkPins; ++pin) - { - uint32_t bc = 0; - if (pin < s_bunchCrossingBits) bc = (bunchCrossing() >> pin) & 0x1; - packerNeutral(pin, bc, 1); - } - // Data - std::vector<uint32_t>::const_iterator pos = m_datamap.begin(); - for (int asic = 0; asic < s_asicChannels; ++asic) - { - for (int pin = 0; pin < s_glinkPins; ++pin) - { - for (int sl = 0; sl < slices; ++sl) - { - packerNeutral(pin, *pos, s_dataBits); - ++pos; - } - } - } - // Errors, including GP - if (m_errormap.empty()) m_errormap.resize(s_glinkPins); - pos = m_errormap.begin(); - for (int pin = 0; pin < s_glinkPins; ++pin) - { - packerNeutral(pin, *pos, s_errorBits); - packerNeutralParity(pin); - ++pos; - } - return true; -} - -// Pack uncompressed data - -bool PpmSubBlockV2::packUncompressedData() -{ - const int slices = slicesLut() + slicesFadc(); - const int channels = channelsPerSubBlock(); - if (m_datamap.empty()) m_datamap.resize(slices * channels); - for (int sl = 0; sl < slices; ++sl) - { - for (int chan = 0; chan < channels; ++chan) - { - packer(m_datamap[sl + chan * slices], s_wordLen); - } - } - packerFlush(); - return true; -} - -// Pack uncompressed error data - -bool PpmSubBlockV2::packUncompressedErrors() -{ - if (m_errormap.empty()) m_errormap.resize(s_glinkPins); - for (int pin = 0; pin < s_glinkPins; ++pin) - { - packer(m_errormap[pin], s_wordLen); - } - packerFlush(); - return true; -} - -// Unpack neutral data - -bool PpmSubBlockV2::unpackNeutral() -{ - const int slices = isRun2() - ? 3 * slicesLut() + slicesFadc() - : slicesLut() + slicesFadc(); - m_datamap.clear(); - // Bunch Crossing number - int bunchCrossing = 0; - for (int pin = 0; pin < s_glinkPins; ++pin) - { - const int bc = unpackerNeutral(pin, 1); - if (pin < s_bunchCrossingBits) bunchCrossing |= bc << pin; - } - setBunchCrossing(bunchCrossing); - // Data - for (int asic = 0; asic < s_asicChannels; ++asic) - { - for (int pin = 0; pin < s_glinkPins; ++pin) - { - for (int sl = 0; sl < slices; ++sl) - { - m_datamap.push_back(unpackerNeutral(pin, s_dataBits)); - } - } - } - const bool rc = unpackerSuccess(); - if (!rc) setUnpackErrorCode(UNPACK_DATA_TRUNCATED); - // Errors - m_errormap.clear(); - for (int pin = 0; pin < s_glinkPins; ++pin) - { - uint32_t error = unpackerNeutral(pin, s_errorBits); - error |= unpackerNeutralParityError(pin) << s_errorBits; - m_errormap.push_back(error); - } - return rc; -} - -// Unpack uncompressed data - -bool PpmSubBlockV2::unpackUncompressedData() -{ - const int slices = isRun2() - ? 3 * slicesLut() + slicesFadc() - : slicesLut() + slicesFadc(); - const int channels = channelsPerSubBlock(); - if (isRun2()) { - setStreamed(); - } - - m_datamap.resize(slices * channels); - unpackerInit(); - // for (int sl = 0; sl < slices; ++sl) - // { - // for (int chan = 0; chan < channels; ++chan) - // { - // m_datamap[sl + chan * slices] = unpacker(wordLen()); - // std::cout << "SASHA3 wordLen=" << wordLen() << " slice=" << sl << " channel=" << chan << " OK?=" << unpackerSuccess() << " value=" << std::hex << (m_datamap[sl + chan * slices]) << std::endl; - // } - // } - for (int chan = 0; chan < channels; ++chan) - { - for (int sl = 0; sl < slices; ++sl) - { - m_datamap[sl + chan * slices] = unpacker(wordLen()); - // std::cout << "SASHA3 wordLen=" << wordLen() << " slice=" << sl << " channel=" << chan << " OK?=" << unpackerSuccess() << " value=" << std::hex << (m_datamap[sl + chan * slices]) << std::endl; - } - } - bool rc = unpackerSuccess(); - if (!rc) setUnpackErrorCode(UNPACK_DATA_TRUNCATED); - else - { - // Check no more non-zero data - while (unpackerSuccess()) - { - if (unpacker(wordLen())) - { - setUnpackErrorCode(UNPACK_EXCESS_DATA); - rc = false; - break; - } - } - } - return rc; -} - -// Unpack uncompressed error data - -bool PpmSubBlockV2::unpackUncompressedErrors() -{ - unpackerInit(); - m_errormap.clear(); - for (int pin = 0; pin < s_glinkPins; ++pin) - { - m_errormap.push_back(unpacker(wordLen())); - } - bool rc = unpackerSuccess(); - if (!rc) setUnpackErrorCode(UNPACK_DATA_TRUNCATED); - else - { - while (unpackerSuccess()) - { - if (unpacker(wordLen())) - { - setUnpackErrorCode(UNPACK_EXCESS_DATA); - rc = false; - break; - } - } - } - return rc; -} - -// Return the number of channels per sub-block - -int PpmSubBlockV2::channelsPerSubBlock(const int version, const int format) -{ - int chan = 0; - switch (version) - { - case 1: - switch (format) - { - case UNCOMPRESSED: - chan = s_channels / s_asicChannels; - break; - case NEUTRAL: - case COMPRESSED: - case SUPERCOMPRESSED: - chan = s_channels; - break; - default: - setUnpackErrorCode(UNPACK_FORMAT); - break; - } - break; - case 2: - switch (format) - { - case UNCOMPRESSED: - case NEUTRAL: - case COMPRESSED: - case SUPERCOMPRESSED: - chan = s_channels; - break; - default: - setUnpackErrorCode(UNPACK_FORMAT); - break; - } - break; - default: - setUnpackErrorCode(UNPACK_VERSION); - break; - } - return chan; -} - -int PpmSubBlockV2::channelsPerSubBlock() -{ - return channelsPerSubBlock(version(), format()); -} - -int PpmSubBlockV2::wordLen(const int version, const int format) -{ - int chan = 0; - switch (version) - { - case 1: - return s_wordLen; - break; - case 2: - switch (format) - { - case UNCOMPRESSED: - return 11; - case NEUTRAL: - case COMPRESSED: - case SUPERCOMPRESSED: - return s_wordLen; - break; - default: - setUnpackErrorCode(UNPACK_FORMAT); - break; - } - break; - default: - setUnpackErrorCode(UNPACK_VERSION); - break; - } - return chan; -} - -int PpmSubBlockV2::wordLen() -{ - return wordLen(version(), format()); -} - -// Check if a header word is for an error block - -bool PpmSubBlockV2::errorBlock(const uint32_t word) -{ - if (format(word) == UNCOMPRESSED) { - return seqno(word) == s_errorMarker; - } - return false; -} - -} // end namespace diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmSubBlockV2.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmSubBlockV2.h deleted file mode 100755 index ba540260e3a3112cf1a71ed2c52b0d13ac2d3d92..0000000000000000000000000000000000000000 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmSubBlockV2.h +++ /dev/null @@ -1,464 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef TRIGT1CALOBYTESTREAM_PPMSUBBLOCKV2_H -#define TRIGT1CALOBYTESTREAM_PPMSUBBLOCKV2_H - -#include <stdint.h> -#include <vector> - -#include "L1CaloSubBlock.h" - -namespace LVL1BS { - -/** Sub-Block class for PPM data. - * - * @author Peter Faulkner - */ - -class PpmSubBlockV2 : public L1CaloSubBlock { - - public: - PpmSubBlockV2(); - ~PpmSubBlockV2(); - - /// Clear all data - void clear(); - - /// Store PPM header - void setPpmHeader(int version, int format, int seqno, int crate, - int module, int slicesFadc, int slicesLut); - /// Store PPM error block header - void setPpmErrorHeader(int version, int format, int crate, - int module, int slicesFadc, int slicesLut); - - // Return PPM-specific header data - int slicesFadc() const; - int slicesLut() const; - - /// Store PPM data for later packing - void fillPpmData(int chan, const std::vector<uint_least8_t>& lut, - const std::vector<uint_least16_t>& fadc, - const std::vector<int>& bcidLut, - const std::vector<int>& bcidFadc); - /// Return unpacked data for given channel - void ppmData(int chan, - std::vector<uint_least8_t>& lutCp, - std::vector<uint_least8_t>& lutJep, - std::vector<uint_least16_t>& fadc, - std::vector<uint_least8_t>& bcidCp, - std::vector<uint_least8_t>& satJep, - std::vector<uint_least8_t>& bcidFadc, - std::vector<int_least16_t>& correction, - std::vector<uint_least8_t>& correctionEnabled - ); - - /// Store an error word corresponding to a data channel - void fillPpmError(int chan, int errorWord); - /// Store an error word corresponding to a G-Link pin - void fillPpmPinError(int pin, int errorWord); - - /// Return the error word for a data channel - int ppmError(int chan) const; - /// Return the error word for a G-Link pin - int ppmPinError(int pin) const; - - // Return individual error bits - bool glinkPinParity(int chan) const; - bool fpgaCorrupt(int chan) const; - bool bunchMismatch(int chan) const; - bool eventMismatch(int chan) const; - bool asicFull(int chan) const; - bool timeout(int chan) const; - bool mcmAbsent(int chan) const; - bool channelDisabled(int chan) const; - bool channelDisabledA(int pin) const; - bool channelDisabledB(int pin) const; - bool channelDisabledC(int pin) const; - bool channelDisabledD(int pin) const; - // Ditto ORed over all pins - bool glinkPinParity() const; - bool fpgaCorrupt() const; - bool bunchMismatch() const; - bool eventMismatch() const; - bool asicFull() const; - bool timeout() const; - bool mcmAbsent() const; - bool channelDisabledA() const; - bool channelDisabledB() const; - bool channelDisabledC() const; - bool channelDisabledD() const; - - // Set triggered slice offsets, pedestal value - void setLutOffset(int offset); - void setFadcOffset(int offset); - void setPedestal(int pedval); - void setFadcBaseline(int baseline); - void setFadcThreshold(int threshold); - void setRunNumber(int run); - void setRodVersion(uint32_t rodVersion); - - // Return triggered slice offsets, pedestal value - int lutOffset() const; - int fadcOffset() const; - int pedestal() const; - int fadcBaseline() const; - int fadcThreshold() const; - int runNumber() const; - uint16_t rodMinorVersion() const; - bool isRun2() const; - - /// Pack data - bool pack(); - /// Unpack data - bool unpack(); - - /// Return the number of channels per sub-block - int channelsPerSubBlock(int version, int format); - int channelsPerSubBlock(); - - /// Return the size of word - int wordLen(int version, int format); - int wordLen(); - - /// Check if a header word is for an error block - static bool errorBlock(uint32_t word); - - /// Check if a header word is for an error block - static bool isRun2(uint16_t rodMinorVersion); - - /// Set compression stats - void setCompStats(const std::vector<uint32_t>& stats); - /// Return reference to compression stats - const std::vector<uint32_t>& compStats() const; - - private: - // Header word data - static const uint32_t s_wordIdVal = 0xc; - static const int s_errorMarker = 63; - // Data word positions and masks - static const int s_wordLen = 16; - static const int s_lutBit = 0; - static const int s_bcidLutBit = 8; - - static const int s_fadcBit = 1; - static const int s_fadcBitV2 = 0; - - static const int s_bcidFadcBit = 0; - static const int s_bcidFadcBitV2 = 10; - - static const uint32_t s_lutMask = 0xff; - static const uint32_t s_bcidLutMask = 0x7; - static const uint32_t s_fadcMask = 0x3ff; - static const uint32_t s_bcidFadcMask = 0x1; - // For neutral format - static const int s_channels = 64; - static const int s_glinkPins = 16; - static const int s_asicChannels = 4; - static const int s_dataBits = 11; - static const int s_errorBits = 10; - static const int s_bunchCrossingBits = 12; - // Error word masks and bit positions - static const uint32_t s_errorMask = 0x7ff; - static const int s_glinkPinParityBit = 10; - static const int s_fpgaCorruptBit = 9; - static const int s_bunchMismatchBit = 8; - static const int s_eventMismatchBit = 7; - static const int s_asicFullBit = 6; - static const int s_timeoutBit = 5; - static const int s_mcmAbsentBit = 4; - static const int s_channelDisabledBit = 0; - - static const uint16_t s_run2minorVersion = 0x1004; - - /// Return the ASIC channel corresponding to a data channel - int asic(int chan) const; - /// Return the G-Link pin corresponding to a data channel - int pin(int chan) const; - - /// Error bit extraction - bool errorBit(int pin, int bit) const; - /// Global error bit extraction - bool errorBit(int bit) const; - - // Packing/unpacking for specific formats - /// Pack neutral data - bool packNeutral(); - /// Pack uncompressed data - bool packUncompressedData(); - /// Pack uncompressed error data - bool packUncompressedErrors(); - /// Unpack neutral data - bool unpackNeutral(); - /// Unpack uncompressed data - bool unpackUncompressedData(); - /// Unpack uncompressed error data - bool unpackUncompressedErrors(); - - // Global error flags - mutable uint32_t m_globalError; - mutable bool m_globalDone; - - // Triggered slice offsets, pedestal value - int m_lutOffset; - int m_fadcOffset; - int m_pedestal; - int m_fadcBaseline; - int m_fadcThreshold; - int m_runNumber; - uint32_t m_rodVersion; - - /// Vector for compression statistics - std::vector<uint32_t> m_compStats; - - /// Vector for intermediate data - std::vector<uint32_t> m_datamap; - - /// Vector for intermediate error data - std::vector<uint32_t> m_errormap; - - /// Return unpacked data for given channel - void ppmDataRun1(int chan, - std::vector<uint_least8_t>& lut, - std::vector<uint_least16_t>& fadc, - std::vector<uint_least8_t>& bcidLut, - std::vector<uint_least8_t>& bcidFadc - ); - - void ppmDataRun2( - const int chan, - std::vector<uint_least8_t>& lutCp, - std::vector<uint_least8_t>& lutJep, - std::vector<uint_least16_t>& fadc, - std::vector<uint_least8_t>& bcidLutCp, - std::vector<uint_least8_t>& satLutJep, - std::vector<uint_least8_t>& bcidFadc, - std::vector<int_least16_t>& correction, - std::vector<uint_least8_t>& correctionEnabled - ); -}; - -inline bool PpmSubBlockV2::glinkPinParity(const int chan) const -{ - return errorBit(pin(chan), s_glinkPinParityBit); -} - -inline bool PpmSubBlockV2::fpgaCorrupt(const int chan) const -{ - return errorBit(pin(chan), s_fpgaCorruptBit); -} - -inline bool PpmSubBlockV2::bunchMismatch(const int chan) const -{ - return errorBit(pin(chan), s_bunchMismatchBit); -} - -inline bool PpmSubBlockV2::eventMismatch(const int chan) const -{ - return errorBit(pin(chan), s_eventMismatchBit); -} - -inline bool PpmSubBlockV2::asicFull(const int chan) const -{ - return errorBit(pin(chan), s_asicFullBit); -} - -inline bool PpmSubBlockV2::timeout(const int chan) const -{ - return errorBit(pin(chan), s_timeoutBit); -} - -inline bool PpmSubBlockV2::mcmAbsent(const int chan) const -{ - return errorBit(pin(chan), s_mcmAbsentBit); -} - -inline bool PpmSubBlockV2::channelDisabled(const int chan) const -{ - return errorBit(pin(chan), s_channelDisabledBit + asic(chan)); -} - -inline bool PpmSubBlockV2::channelDisabledA(const int pin) const -{ - return errorBit(pin, s_channelDisabledBit); -} - -inline bool PpmSubBlockV2::channelDisabledB(const int pin) const -{ - return errorBit(pin, s_channelDisabledBit + 1); -} - -inline bool PpmSubBlockV2::channelDisabledC(const int pin) const -{ - return errorBit(pin, s_channelDisabledBit + 2); -} - -inline bool PpmSubBlockV2::channelDisabledD(const int pin) const -{ - return errorBit(pin, s_channelDisabledBit + 3); -} - -inline bool PpmSubBlockV2::glinkPinParity() const -{ - return errorBit(s_glinkPinParityBit); -} - -inline bool PpmSubBlockV2::fpgaCorrupt() const -{ - return errorBit(s_fpgaCorruptBit); -} - -inline bool PpmSubBlockV2::bunchMismatch() const -{ - return errorBit(s_bunchMismatchBit); -} - -inline bool PpmSubBlockV2::eventMismatch() const -{ - return errorBit(s_eventMismatchBit); -} - -inline bool PpmSubBlockV2::asicFull() const -{ - return errorBit(s_asicFullBit); -} - -inline bool PpmSubBlockV2::timeout() const -{ - return errorBit(s_timeoutBit); -} - -inline bool PpmSubBlockV2::mcmAbsent() const -{ - return errorBit(s_mcmAbsentBit); -} - -inline bool PpmSubBlockV2::channelDisabledA() const -{ - return errorBit(s_channelDisabledBit); -} - -inline bool PpmSubBlockV2::channelDisabledB() const -{ - return errorBit(s_channelDisabledBit + 1); -} - -inline bool PpmSubBlockV2::channelDisabledC() const -{ - return errorBit(s_channelDisabledBit + 2); -} - -inline bool PpmSubBlockV2::channelDisabledD() const -{ - return errorBit(s_channelDisabledBit + 3); -} - -inline void PpmSubBlockV2::setLutOffset(const int offset) -{ - m_lutOffset = offset; -} - -inline void PpmSubBlockV2::setFadcOffset(const int offset) -{ - m_fadcOffset = offset; -} - -inline void PpmSubBlockV2::setPedestal(const int pedval) -{ - m_pedestal = pedval; -} - -inline void PpmSubBlockV2::setFadcBaseline(const int baseline) -{ - m_fadcBaseline = baseline; -} - -inline void PpmSubBlockV2::setFadcThreshold(const int threshold) -{ - m_fadcThreshold = threshold; -} - -inline void PpmSubBlockV2::setRunNumber(const int run) -{ - m_runNumber = run; -} - -inline void PpmSubBlockV2::setRodVersion(const uint32_t rodVersion) -{ - m_rodVersion = rodVersion; -} - -inline uint16_t PpmSubBlockV2::rodMinorVersion() const -{ - return m_rodVersion & 0xffff; -} - -inline bool PpmSubBlockV2::isRun2() const -{ - return PpmSubBlockV2::isRun2(rodMinorVersion()); -} - -inline bool PpmSubBlockV2::isRun2(uint16_t rodMinorVersion) { - return rodMinorVersion >= s_run2minorVersion; -} - - -inline int PpmSubBlockV2::lutOffset() const -{ - return (m_lutOffset < 0) ? slicesLut()/2 : m_lutOffset; -} - -inline int PpmSubBlockV2::fadcOffset() const -{ - return (m_fadcOffset < 0) ? slicesFadc()/2 : m_fadcOffset; -} - -inline int PpmSubBlockV2::pedestal() const -{ - return m_pedestal; -} - -inline int PpmSubBlockV2::fadcBaseline() const -{ - return m_fadcBaseline; -} - -inline int PpmSubBlockV2::fadcThreshold() const -{ - return m_fadcThreshold; -} - -inline int PpmSubBlockV2::runNumber() const -{ - return m_runNumber; -} - -inline const std::vector<uint32_t>& PpmSubBlockV2::compStats() const -{ - return m_compStats; -} - -inline void PpmSubBlockV2::setCompStats(const std::vector<uint32_t>& stats) -{ - m_compStats = stats; -} - -inline int PpmSubBlockV2::asic(const int chan) const -{ - return chan / s_glinkPins; -} - -inline int PpmSubBlockV2::pin(const int chan) const -{ - return chan % s_glinkPins; -} - -inline bool PpmSubBlockV2::errorBit(const int pin, const int bit) const -{ - return m_errormap[pin] & (0x1 << bit); -} - -} // end namespace - -#endif diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/ToString.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/ToString.cxx index ffb486bf2e84ee06705910edefbc568f3787e18e..0560c4444220aacde2c18ebeeea880b3061da187 100644 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/ToString.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/ToString.cxx @@ -27,6 +27,7 @@ std::string LVL1BS::ToString(const xAOD::TriggerTower& tt){ } else { o << "xAOD::TriggerTower, coolId=" << std::hex << tt.coolId() << std::dec << ", layer=" << int(tt.layer()) + << ", sampling=" << int(tt.sampling()) << ", eta=" << tt.eta() << ", phi=" << tt.phi() << ", lut_cp=" << ::ToString(tt.lut_cp()) @@ -36,7 +37,7 @@ std::string LVL1BS::ToString(const xAOD::TriggerTower& tt){ << ", bcidVec=" << ::ToString(tt.bcidVec()) << ", adc=" << ::ToString(tt.adc()) << ", bcidExt=" << ::ToString(tt.bcidExt()) - << ", error=" << tt.error() + << ", errorWord=" << tt.errorWord() << ", peak=" << int(tt.peak()) << ", adcPeak=" << int(tt.adcPeak()); if (!tt.lut_cp().empty()) { diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/TrigT1CaloDataAccessV2.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/TrigT1CaloDataAccessV2.cxx index a4c139c1a39df56513a12bfd2fd871b1d40d1d2c..d89c2a223701397d5f4d6bcadea3aca40c4a0594 100644 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/TrigT1CaloDataAccessV2.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/TrigT1CaloDataAccessV2.cxx @@ -5,7 +5,7 @@ #include "GaudiKernel/MsgStream.h" #include "GaudiKernel/StatusCode.h" -#include "xaod/L1CaloByteStreamReadTool.h" +#include "xaod/PpmByteStreamReadV1V2Tool.h" #include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" #include "TrigT1CaloDataAccessV2.h" @@ -16,9 +16,9 @@ namespace LVL1BS { // Constructor -TrigT1CaloDataAccessV2::TrigT1CaloDataAccessV2(const std::string& name="TrigT1CaloDataAccessV2") +TrigT1CaloDataAccessV2::TrigT1CaloDataAccessV2(const std::string& name /*="TrigT1CaloDataAccessV2"*/) : AsgTool(name), - m_tool("LVL1BS::L1CaloByteStreamReadTool/L1CaloByteStreamReadTool") + m_tool("LVL1BS::PpmByteStreamReadV1V2Tool/PpmByteStreamReadV1V2Tool") { } diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/TrigT1CaloDataAccessV2.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/TrigT1CaloDataAccessV2.h index 79219cea0ae2527ef0fb97175591eb8f608aff75..bf71e7c0d96ef9bdb25599f184c248d0702b0558 100644 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/TrigT1CaloDataAccessV2.h +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/TrigT1CaloDataAccessV2.h @@ -14,7 +14,7 @@ namespace LVL1BS { -class L1CaloByteStreamReadTool; +class PpmByteStreamReadV1V2Tool; /** Tool to retrieve all TriggerTowers * from bytestream. @@ -37,7 +37,7 @@ class TrigT1CaloDataAccessV2 : public asg::AsgTool, private: std::string m_message; /// Tool that does the actual work - ToolHandle<LVL1BS::L1CaloByteStreamReadTool> m_tool; + ToolHandle<LVL1BS::PpmByteStreamReadV1V2Tool> m_tool; }; } // end namespace diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/components/TrigT1CaloByteStream_entries.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/components/TrigT1CaloByteStream_entries.cxx index 71635e5a8023b3ac7f23147c4bd3f6fc54c82c73..fb1f39db6b4ab51463c6c2375dbb81e3a1f24f3d 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/components/TrigT1CaloByteStream_entries.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/components/TrigT1CaloByteStream_entries.cxx @@ -3,13 +3,13 @@ #include "DataModel/DataVector.h" // Post-LS1 -#include "TrigT1CaloEvent/CMXCPTob.h" -#include "TrigT1CaloEvent/CMXCPHits.h" + #include "TrigT1CaloEvent/CMXEtSums.h" #include "TrigT1CaloEvent/CMXJetTob.h" #include "TrigT1CaloEvent/CMXJetHits.h" #include "TrigT1CaloEvent/CMXRoI.h" #include "TrigT1CaloEvent/JEMTobRoI.h" + // Pre-LS1 #include "TrigT1CaloEvent/CPMHits.h" #include "TrigT1CaloEvent/CMMCPHits.h" @@ -24,9 +24,9 @@ #include "TrigT1CaloEvent/JetElement.h" // Post-LS1 -#include "../CpByteStreamV2Cnv.h" +//#include "../CpByteStreamV2Cnv.h" #include "../CpmRoiByteStreamV2Cnv.h" -#include "../CpReadByteStreamV2Cnv.h" +//#include "../CpReadByteStreamV2Cnv.h" #include "../JepByteStreamV2Cnv.h" #include "../JepReadByteStreamV2Cnv.h" #include "../JepRoiByteStreamV2Cnv.h" @@ -39,40 +39,61 @@ #include "../JepReadByteStreamV1Cnv.h" #include "../JepRoiByteStreamV1Cnv.h" #include "../JepRoiReadByteStreamV1Cnv.h" + // Both -#include "../CpReadByteStreamV1V2Cnv.h" +//#include "../CpReadByteStreamV1V2Cnv.h" #include "../JepReadByteStreamV1V2Cnv.h" // ============================================================================ // Ppm // ============================================================================ #include "TrigT1CaloEvent/TriggerTower.h" - #include "xAODTrigL1Calo/TriggerTowerContainer.h" #include "xAODTrigL1Calo/TriggerTowerAuxContainer.h" #include "../PpmByteStreamV1Cnv.h" -#include "../PpmByteStreamV2Cnv.h" #include "../PpmByteStreamV1Tool.h" -#include "../PpmByteStreamV2Tool.h" +#include "../xaod/PpmByteStreamReadV1V2Tool.h" +#include "../xaod/PpmByteStreamAuxCnv.h" +#include "../xaod/PpmByteStreamxAODCnv.h" // ============================================================================ -#include "xAODTrigL1Calo/TriggerTower.h" -#include "xAODTrigL1Calo/TriggerTowerContainer.h" +// CPM +// ============================================================================ +#include "../CpByteStreamV2Tool.h" + #include "xAODTrigL1Calo/CPMTower.h" #include "xAODTrigL1Calo/CPMTowerContainer.h" #include "xAODTrigL1Calo/CPMTowerAuxContainer.h" -#include "../xaod/PpmByteStreamAuxCnv.h" -#include "../xaod/PpmByteStreamxAODCnv.h" +#include "../xaod/CpmTowerByteStreamAuxCnv.h" +#include "../xaod/CpmTowerByteStreamxAODCnv.h" +// ============================================================================ +// CMXCPTOB +// ============================================================================ +#include "TrigT1CaloEvent/CMXCPTob.h" +#include "xAODTrigL1Calo/CMXCPTob.h" +#include "xAODTrigL1Calo/CMXCPTobContainer.h" +#include "xAODTrigL1Calo/CMXCPTobAuxContainer.h" + +#include "../xaod/CmxCpTobByteStreamAuxCnv.h" +#include "../xaod/CmxCpTobByteStreamxAODCnv.h" +// ============================================================================ +// CMXCPHITS +// ============================================================================ +#include "TrigT1CaloEvent/CMXCPHits.h" +#include "xAODTrigL1Calo/CMXCPHits.h" +#include "xAODTrigL1Calo/CMXCPHitsContainer.h" +#include "xAODTrigL1Calo/CMXCPHitsAuxContainer.h" -#include "../xaod/L1CaloByteStreamReadTool.h" +#include "../xaod/CmxCpHitsByteStreamAuxCnv.h" +#include "../xaod/CmxCpHitsByteStreamxAODCnv.h" // ============================================================================ #include "../RodHeaderByteStreamCnv.h" #include "../L1CaloErrorByteStreamCnv.h" // Post-LS1 -#include "../CpByteStreamV2Tool.h" + #include "../CpmRoiByteStreamV2Tool.h" #include "../JepByteStreamV2Tool.h" #include "../JepRoiByteStreamV2Tool.h" @@ -117,8 +138,8 @@ typedef DataVector<LVL1::JetElement> JetElementCollection; typedef DataVector<LVL1::JEMEtSums> JEMEtSumsCollection; // Post-LS1 -typedef CpReadByteStreamV2Cnv<CMXCPTobCollection> CpReadCRByteStreamV2CnvT; -typedef CpReadByteStreamV2Cnv<CMXCPHitsCollection> CpReadCCByteStreamV2CnvT; +//typedef CpReadByteStreamV2Cnv<CMXCPTobCollection> CpReadCRByteStreamV2CnvT; +//typedef CpReadByteStreamV2Cnv<CMXCPHitsCollection> CpReadCCByteStreamV2CnvT; typedef JepReadByteStreamV2Cnv<CMXJetTobCollection> JepReadCTByteStreamV2CnvT; typedef JepReadByteStreamV2Cnv<CMXJetHitsCollection> JepReadCJByteStreamV2CnvT; typedef JepReadByteStreamV2Cnv<CMXEtSumsCollection> JepReadCEByteStreamV2CnvT; @@ -144,10 +165,10 @@ typedef JepReadByteStreamV1V2Cnv<JEMEtSumsCollection> JepReadESByteStreamV1V2Cn // declare // Post-LS1 -DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, CpByteStreamV2Cnv ) +//DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, CpByteStreamV2Cnv ) DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, CpmRoiByteStreamV2Cnv ) -DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, CpReadCRByteStreamV2CnvT ) -DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, CpReadCCByteStreamV2CnvT ) +//DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, CpReadCRByteStreamV2CnvT ) +//DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, CpReadCCByteStreamV2CnvT ) DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, JepByteStreamV2Cnv ) DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, JepRoiByteStreamV2Cnv ) DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, JepReadCTByteStreamV2CnvT ) @@ -168,22 +189,40 @@ DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, JepReadJHByteStreamV1CnvT ) DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, JepRoiReadJRByteStreamV1CnvT ) DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, JepRoiReadCRByteStreamV1CnvT ) // Both -DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, CpReadByteStreamV1V2Cnv ) +//DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, CpReadByteStreamV1V2Cnv ) DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, JepReadJEByteStreamV1V2CnvT ) DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, JepReadESByteStreamV1V2CnvT ) DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, RodHeaderByteStreamCnv ) DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, L1CaloErrorByteStreamCnv ) - // ============================================================================ -DECLARE_NAMESPACE_TOOL_FACTORY( LVL1BS, PpmByteStreamV1Tool ) -DECLARE_NAMESPACE_TOOL_FACTORY( LVL1BS, L1CaloByteStreamReadTool ) +// PPM // ============================================================================ +DECLARE_NAMESPACE_TOOL_FACTORY( LVL1BS, PpmByteStreamV1Tool ) +DECLARE_NAMESPACE_TOOL_FACTORY( LVL1BS, PpmByteStreamReadV1V2Tool ) + DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, PpmByteStreamV1Cnv ) DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, PpmByteStreamxAODCnv) DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, PpmByteStreamAuxCnv) // ============================================================================ -// Post-LS1 +// CPM +// ============================================================================ DECLARE_NAMESPACE_TOOL_FACTORY( LVL1BS, CpByteStreamV2Tool ) + +DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, CpmTowerByteStreamxAODCnv) +DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, CpmTowerByteStreamAuxCnv) +// ============================================================================ +// CMXCPTOB +// ============================================================================ +DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, CmxCpTobByteStreamxAODCnv) +DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, CmxCpTobByteStreamAuxCnv) +// ============================================================================ +// CMXCPHITS +// ============================================================================ +DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, CmxCpHitsByteStreamxAODCnv) +DECLARE_NAMESPACE_CONVERTER_FACTORY( LVL1BS, CmxCpHitsByteStreamAuxCnv) +// ============================================================================ +// Post-LS1 + DECLARE_NAMESPACE_TOOL_FACTORY( LVL1BS, CpmRoiByteStreamV2Tool ) DECLARE_NAMESPACE_TOOL_FACTORY( LVL1BS, JepByteStreamV2Tool ) DECLARE_NAMESPACE_TOOL_FACTORY( LVL1BS, JepRoiByteStreamV2Tool ) @@ -205,10 +244,10 @@ DECLARE_NAMESPACE_TOOL_FACTORY( LVL1BS, TrigT1CaloDataAccessV2 ) DECLARE_FACTORY_ENTRIES( TrigT1CaloByteStream ) { // Post-LS1 - DECLARE_NAMESPACE_CONVERTER( LVL1BS, CpByteStreamV2Cnv ) + //DECLARE_NAMESPACE_CONVERTER( LVL1BS, CpByteStreamV2Cnv ) DECLARE_NAMESPACE_CONVERTER( LVL1BS, CpmRoiByteStreamV2Cnv ) - DECLARE_NAMESPACE_CONVERTER( LVL1BS, CpReadCRByteStreamV2CnvT ) - DECLARE_NAMESPACE_CONVERTER( LVL1BS, CpReadCCByteStreamV2CnvT ) + // DECLARE_NAMESPACE_CONVERTER( LVL1BS, CpReadCRByteStreamV2CnvT ) + // DECLARE_NAMESPACE_CONVERTER( LVL1BS, CpReadCCByteStreamV2CnvT ) DECLARE_NAMESPACE_CONVERTER( LVL1BS, JepByteStreamV2Cnv ) DECLARE_NAMESPACE_CONVERTER( LVL1BS, JepRoiByteStreamV2Cnv ) DECLARE_NAMESPACE_CONVERTER( LVL1BS, JepReadCTByteStreamV2CnvT ) @@ -229,22 +268,40 @@ DECLARE_FACTORY_ENTRIES( TrigT1CaloByteStream ) DECLARE_NAMESPACE_CONVERTER( LVL1BS, JepRoiReadJRByteStreamV1CnvT ) DECLARE_NAMESPACE_CONVERTER( LVL1BS, JepRoiReadCRByteStreamV1CnvT ) // Both - DECLARE_NAMESPACE_CONVERTER( LVL1BS, CpReadByteStreamV1V2Cnv ) +// DECLARE_NAMESPACE_CONVERTER( LVL1BS, CpReadByteStreamV1V2Cnv ) DECLARE_NAMESPACE_CONVERTER( LVL1BS, JepReadJEByteStreamV1V2CnvT ) DECLARE_NAMESPACE_CONVERTER( LVL1BS, JepReadESByteStreamV1V2CnvT ) // ========================================================================== - // Ppm + // PPM + // ========================================================================== DECLARE_NAMESPACE_CONVERTER( LVL1BS, PpmByteStreamV1Cnv ) - // V2 is named xAOD DECLARE_NAMESPACE_CONVERTER( LVL1BS, PpmByteStreamxAODCnv ) DECLARE_NAMESPACE_CONVERTER( LVL1BS, PpmByteStreamAuxCnv) - DECLARE_NAMESPACE_TOOL(LVL1BS, L1CaloByteStreamReadTool) + DECLARE_NAMESPACE_TOOL(LVL1BS, PpmByteStreamV1V2ReadTool) + // ========================================================================== + // CPM + // ========================================================================== + DECLARE_NAMESPACE_TOOL( LVL1BS, CpByteStreamV2Tool ) + + DECLARE_NAMESPACE_CONVERTER( LVL1BS, CpmTowerByteStreamxAODCnv ) + DECLARE_NAMESPACE_CONVERTER( LVL1BS, CpmTowerByteStreamAuxCnv) // ========================================================================== + // CMXCPTOB + // ========================================================================== + DECLARE_NAMESPACE_CONVERTER( LVL1BS, CmxCpTobByteStreamxAODCnv ) + DECLARE_NAMESPACE_CONVERTER( LVL1BS, CmxCpTobByteStreamAuxCnv) + // ========================================================================== + // CMXCPHITS + // ========================================================================== + DECLARE_NAMESPACE_CONVERTER( LVL1BS, CmxCpHitsByteStreamxAODCnv ) + DECLARE_NAMESPACE_CONVERTER( LVL1BS, CmxCpHitsByteStreamAuxCnv) + // ========================================================================== + DECLARE_NAMESPACE_CONVERTER( LVL1BS, RodHeaderByteStreamCnv ) DECLARE_NAMESPACE_CONVERTER( LVL1BS, L1CaloErrorByteStreamCnv ) // Post-LS1 - DECLARE_NAMESPACE_TOOL( LVL1BS, CpByteStreamV2Tool ) + DECLARE_NAMESPACE_TOOL( LVL1BS, CpmRoiByteStreamV2Tool ) DECLARE_NAMESPACE_TOOL( LVL1BS, JepByteStreamV2Tool ) DECLARE_NAMESPACE_TOOL( LVL1BS, JepRoiByteStreamV2Tool ) diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpHitsByteStreamAuxCnv.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpHitsByteStreamAuxCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7a7f5aa3d359cfe41a8b8a2ef8efcbb4d1fed06a --- /dev/null +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpHitsByteStreamAuxCnv.cxx @@ -0,0 +1,131 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ============================================================================ +// Includes +// ============================================================================ +// STD +// ============================================================================ +#include <vector> +#include <cstdint> +#include <memory> +#include <algorithm> +// ============================================================================ +// Athena +// ============================================================================ +#include "ByteStreamCnvSvcBase/ByteStreamAddress.h" +#include "ByteStreamCnvSvcBase/IByteStreamEventAccess.h" +#include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" + +#include "ByteStreamData/RawEvent.h" +#include "ByteStreamData/ROBData.h" + +#include "AthenaKernel/errorcheck.h" +#include "GaudiKernel/CnvFactory.h" +#include "GaudiKernel/DataObject.h" +#include "GaudiKernel/IOpaqueAddress.h" +#include "GaudiKernel/IRegistry.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/StatusCode.h" + +#include "SGTools/ClassID_traits.h" +#include "SGTools/StorableConversions.h" +#include "StoreGate/StoreGateSvc.h" + +// ============================================================================ +// TrigT1 +// ============================================================================ +#include "TrigT1CaloEvent/CMXCPHits.h" +// ============================================================================ +// xAOD +// ============================================================================ +#include "xAODTrigL1Calo/CMXCPHits.h" +#include "xAODTrigL1Calo/CMXCPHitsContainer.h" +#include "xAODTrigL1Calo/CMXCPHitsAuxContainer.h" +// ============================================================================ +// Local +// ============================================================================ +#include "CmxCpHitsByteStreamAuxCnv.h" +#include "../CpByteStreamV2Tool.h" +#include "../ToString.h" +// ============================================================================ + +namespace LVL1BS { +CmxCpHitsByteStreamAuxCnv::CmxCpHitsByteStreamAuxCnv(ISvcLocator* svcloc) : + Converter(ByteStream_StorageType, classID(), svcloc), + AthMessaging(svcloc != 0 ? msgSvc() : 0, "CmxCpHitsByteStreamAuxCnv"), + m_name("CmxCpHitsByteStreamAuxCnv"), + m_cpmReadTool("LVL1BS::CpByteStreamV2Tool/CpByteStreamV2Tool") +{ +} + +const CLID& CmxCpHitsByteStreamAuxCnv::classID() { + return ClassID_traits<xAOD::CMXCPHitsAuxContainer>::ID(); +} + +// Init method gets all necessary services etc. + +#ifndef PACKAGE_VERSION +#define PACKAGE_VERSION "unknown" +#endif +StatusCode CmxCpHitsByteStreamAuxCnv::initialize() { + ATH_MSG_DEBUG( + "Initializing " << m_name << " - package version " << PACKAGE_VERSION); + + CHECK(Converter::initialize()); + CHECK(m_cpmReadTool.retrieve()); + + return StatusCode::SUCCESS; +} + +// createObj should create the RDO from bytestream. +StatusCode CmxCpHitsByteStreamAuxCnv::createObj(IOpaqueAddress* pAddr, + DataObject*& pObj) { + ATH_MSG_DEBUG("createObj() called"); + // ------------------------------------------------------------------------- + ByteStreamAddress *pBS_Addr = dynamic_cast<ByteStreamAddress *>(pAddr); + CHECK(pBS_Addr != nullptr); + // ------------------------------------------------------------------------- + const std::string nm = *(pBS_Addr->par()); + ATH_MSG_DEBUG("Creating Objects " << nm); + + auto aux = new xAOD::CMXCPHitsAuxContainer; + xAOD::CMXCPHitsContainer cmxCpHitsContainer; + cmxCpHitsContainer.setStore(aux); + // ------------------------------------------------------------------------- + DataVector<LVL1::CMXCPHits> cmxCpHitsVector; + StatusCode sc = m_cpmReadTool->convert(nm, &cmxCpHitsVector); + if (sc.isFailure()) { + ATH_MSG_ERROR("Failed to create objects"); + delete aux; + return sc; + } + + for (auto ch : cmxCpHitsVector) { + xAOD::CMXCPHits* item = new xAOD::CMXCPHits(); + cmxCpHitsContainer.push_back(item); + std::vector<uint8_t> hitsVec0(ch->hitsVec0().begin(), ch->hitsVec0().end()); + std::vector<uint8_t> hitsVec1(ch->hitsVec1().begin(), ch->hitsVec1().end()); + std::vector<uint8_t> errorVec0(ch->errorVec0().begin(), ch->errorVec0().end()); + std::vector<uint8_t> errorVec1(ch->errorVec1().begin(), ch->errorVec1().end()); + + item->initialize(ch->crate(), ch->cmx(), ch->source(), + hitsVec0, hitsVec1, errorVec0, errorVec1, ch->peak()); + } + + // ------------------------------------------------------------------------- + //ATH_MSG_VERBOSE(ToString(cpmCollection)); + ATH_MSG_DEBUG("Number of readed CMXCpHits: " << aux->size()); + // ------------------------------------------------------------------------- + pObj = SG::asStorable(aux); + return StatusCode::SUCCESS; +} + +// createRep should create the bytestream from RDOs. +StatusCode CmxCpHitsByteStreamAuxCnv::createRep(DataObject* /*pObj*/, + IOpaqueAddress*& /*pAddr*/) { + return StatusCode::FAILURE; +} + +} // end namespace diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmByteStreamV2Cnv.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpHitsByteStreamAuxCnv.h similarity index 61% rename from Trigger/TrigT1/TrigT1CaloByteStream/src/PpmByteStreamV2Cnv.h rename to Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpHitsByteStreamAuxCnv.h index a6ae8825c7e1f6017ad80193d9230f1895d462eb..33b59efe95c1baf1bdf8f0d51b258709d7994512 100644 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/PpmByteStreamV2Cnv.h +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpHitsByteStreamAuxCnv.h @@ -2,8 +2,8 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#ifndef TRIGT1CALOBYTESTREAM_PPMBYTESTREAMV2CNV_H -#define TRIGT1CALOBYTESTREAM_PPMBYTESTREAMV2CNV_H +#ifndef TRIGT1CALOBYTESTREAM_CMXCPHITSBYTESTREAMAUXCNV_H +#define TRIGT1CALOBYTESTREAM_CMXCPHITSBYTESTREAMXAUXCNV_H #include <string> @@ -23,36 +23,30 @@ class ISvcLocator; class StatusCode; template <typename> class CnvFactory; -class StoreGateSvc; - // Externals extern long ByteStream_StorageType; - - namespace LVL1BS { - -class PpmByteStreamV2Tool; +class CpByteStreamV2Tool; /** ByteStream converter for Pre-processor Module DAQ data / TriggerTowers. * * @author alexander.mazurov@cern.ch - * @author Peter Faulkner */ -class PpmByteStreamV2Cnv: public Converter, public ::AthMessaging { +class CmxCpHitsByteStreamAuxCnv: public Converter, public ::AthMessaging { - friend class CnvFactory<PpmByteStreamV2Cnv>; + friend class CnvFactory<CmxCpHitsByteStreamAuxCnv>; protected: - PpmByteStreamV2Cnv(ISvcLocator* svcloc); + CmxCpHitsByteStreamAuxCnv(ISvcLocator* svcloc); public: - virtual ~PpmByteStreamV2Cnv(); + virtual ~CmxCpHitsByteStreamAuxCnv(){}; virtual StatusCode initialize(); /// Create TriggerTowers from ByteStream @@ -63,28 +57,17 @@ public: // Storage type and class ID virtual long repSvcType() const { return ByteStream_StorageType;} static long storageType(){ return ByteStream_StorageType; } - static const CLID& classID(); - -private: - void _reserveMemory(); + static const CLID& classID(); private: - /// Converter name std::string m_name; - /// Tool that does the actual work - ToolHandle<LVL1BS::PpmByteStreamV2Tool> m_tool; + /// Do the main job - retrieve xAOD TriggerTowers from robs + ToolHandle<CpByteStreamV2Tool> m_cpmReadTool; +}; - /// ServiceHandle to the data store service to store aux objects - ServiceHandle<StoreGateSvc> m_storeSvc; - /// Service for reading bytestream - ServiceHandle<IROBDataProviderSvc> m_robDataProvider; - /// Service for writing bytestream - ServiceHandle<IByteStreamEventAccess> m_ByteStreamEventAccess; -}; } // end namespace - #endif diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpHitsByteStreamxAODCnv.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpHitsByteStreamxAODCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9d65dd2b3a4adfbf4774a27f78d6f544e07a88e9 --- /dev/null +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpHitsByteStreamxAODCnv.cxx @@ -0,0 +1,101 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include <vector> +#include <stdint.h> + +#include "ByteStreamCnvSvcBase/ByteStreamAddress.h" +#include "ByteStreamCnvSvcBase/IByteStreamEventAccess.h" +#include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" + +#include "ByteStreamData/RawEvent.h" +#include "ByteStreamData/ROBData.h" + +#include "AthenaKernel/errorcheck.h" +#include "GaudiKernel/CnvFactory.h" +#include "GaudiKernel/DataObject.h" +#include "GaudiKernel/IOpaqueAddress.h" +#include "GaudiKernel/IRegistry.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/StatusCode.h" + +#include "SGTools/ClassID_traits.h" +#include "SGTools/StorableConversions.h" +#include "StoreGate/StoreGateSvc.h" + +#include "xAODTrigL1Calo/CMXCPHits.h" +#include "xAODTrigL1Calo/CMXCPHitsContainer.h" +#include "xAODTrigL1Calo/CMXCPHitsAuxContainer.h" + +#include "CmxCpHitsByteStreamxAODCnv.h" + +namespace LVL1BS { + +CmxCpHitsByteStreamxAODCnv::CmxCpHitsByteStreamxAODCnv(ISvcLocator* svcloc) : + Converter(ByteStream_StorageType, classID(), svcloc), + AthMessaging(svcloc != 0 ? msgSvc() : 0, "CmxCpHitsByteStreamxAODCnv"), + m_name("CmxCpHitsByteStreamxAODCnv") +{ + +} + +// CLID + +const CLID& CmxCpHitsByteStreamxAODCnv::classID() { + return ClassID_traits<xAOD::CMXCPHitsContainer>::ID(); +} + +// Init method gets all necessary services etc. + +#ifndef PACKAGE_VERSION +#define PACKAGE_VERSION "unknown" +#endif + +StatusCode CmxCpHitsByteStreamxAODCnv::initialize() { + ATH_MSG_DEBUG( + "Initializing " << m_name << " - package version " << PACKAGE_VERSION); + + CHECK(Converter::initialize()); + return StatusCode::SUCCESS; +} + +// createObj should create the RDO from bytestream. + +StatusCode CmxCpHitsByteStreamxAODCnv::createObj(IOpaqueAddress* pAddr, + DataObject*& pObj) { + ATH_MSG_DEBUG("createObj() called"); + // ------------------------------------------------------------------------- + ByteStreamAddress *pBS_Addr = dynamic_cast<ByteStreamAddress *>(pAddr); + CHECK(pBS_Addr != nullptr); + // ------------------------------------------------------------------------- + const std::string nm = *(pBS_Addr->par()); + const std::string nmAux = nm + "Aux."; + ATH_MSG_DEBUG("Creating xAOD::CMXCPHits interface objects '" << nm << "'"); + + xAOD::CMXCPHitsContainer* const cphitsCollection = + new xAOD::CMXCPHitsContainer; + + // Create link with AUX container + DataLink<xAOD::CMXCPHitsAuxContainer> link(nmAux); + ATH_MSG_DEBUG("Creating store with data link to '" << nmAux); + + for(size_t i=0; i < link->size(); ++i){ + cphitsCollection->push_back(new xAOD::CMXCPHits()); + } + // ========================================================================== + cphitsCollection->setStore(link); + pObj = SG::asStorable(cphitsCollection); + ATH_MSG_DEBUG("Number of xAOD CPM Towers created: " << cphitsCollection->size()); + + return StatusCode::SUCCESS; +} + +// createRep should create the bytestream from RDOs. + +StatusCode CmxCpHitsByteStreamxAODCnv::createRep(DataObject* /*pObj*/, + IOpaqueAddress*& /*pAddr*/) { + return StatusCode::FAILURE; +} + +} // end namespace diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpHitsByteStreamxAODCnv.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpHitsByteStreamxAODCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..6d54a60787eee96e57395db883455358e88e74bb --- /dev/null +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpHitsByteStreamxAODCnv.h @@ -0,0 +1,65 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT1CALOBYTESTREAM_CMXCPHITSBYTESTREAMXAODCNV_H +#define TRIGT1CALOBYTESTREAM_CMXCPHITSBYTESTREAMXAODCNV_H + +#include <string> + +#include "GaudiKernel/ClassID.h" +#include "GaudiKernel/Converter.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ToolHandle.h" + +#include "AthenaBaseComps/AthMessaging.h" + +class DataObject; +class IOpaqueAddress; +class ISvcLocator; +class StatusCode; + +template <typename> class CnvFactory; +class StoreGateSvc; +// Externals +extern long ByteStream_StorageType; + +namespace LVL1BS { +/** ByteStream converter for CmxTob. + * + * @author alexander.mazurov@cern.ch + */ + +class CmxCpHitsByteStreamxAODCnv: public Converter, public ::AthMessaging { + + friend class CnvFactory<CmxCpHitsByteStreamxAODCnv>; + +protected: + + CmxCpHitsByteStreamxAODCnv(ISvcLocator* svcloc); + +public: + + virtual ~CmxCpHitsByteStreamxAODCnv(){}; + + virtual StatusCode initialize(); + /// Create TriggerTowers from ByteStream + virtual StatusCode createObj(IOpaqueAddress* pAddr, DataObject*& pObj); + /// Create ByteStream from TriggerTowers + virtual StatusCode createRep(DataObject* pObj, IOpaqueAddress*& pAddr); + + // Storage type and class ID + virtual long repSvcType() const { return ByteStream_StorageType;} + static long storageType(){ return ByteStream_StorageType; } + + static const CLID& classID(); + +private: + /// Converter name + std::string m_name; +}; + +} // end namespace + +#endif diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpTobByteStreamAuxCnv.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpTobByteStreamAuxCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7133d9b1552a0e60bf9a097d74b349e07fade5ec --- /dev/null +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpTobByteStreamAuxCnv.cxx @@ -0,0 +1,136 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ============================================================================ +// Includes +// ============================================================================ +// STD +// ============================================================================ +#include <vector> +#include <cstdint> +#include <memory> +#include <algorithm> +// ============================================================================ +// Athena +// ============================================================================ +#include "ByteStreamCnvSvcBase/ByteStreamAddress.h" +#include "ByteStreamCnvSvcBase/IByteStreamEventAccess.h" +#include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" + +#include "ByteStreamData/RawEvent.h" +#include "ByteStreamData/ROBData.h" + +#include "AthenaKernel/errorcheck.h" +#include "GaudiKernel/CnvFactory.h" +#include "GaudiKernel/DataObject.h" +#include "GaudiKernel/IOpaqueAddress.h" +#include "GaudiKernel/IRegistry.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/StatusCode.h" + +#include "SGTools/ClassID_traits.h" +#include "SGTools/StorableConversions.h" +#include "StoreGate/StoreGateSvc.h" + +// ============================================================================ +// TrigT1 +// ============================================================================ +#include "TrigT1CaloEvent/CMXCPTob.h" +// ============================================================================ +// xAOD +// ============================================================================ +#include "xAODTrigL1Calo/CMXCPTob.h" +#include "xAODTrigL1Calo/CMXCPTobContainer.h" +#include "xAODTrigL1Calo/CMXCPTobAuxContainer.h" +// ============================================================================ +// Local +// ============================================================================ +#include "CmxCpTobByteStreamAuxCnv.h" +#include "../CpByteStreamV2Tool.h" +#include "../ToString.h" +// ============================================================================ + +namespace LVL1BS { +CmxCpTobByteStreamAuxCnv::CmxCpTobByteStreamAuxCnv(ISvcLocator* svcloc) : + Converter(ByteStream_StorageType, classID(), svcloc), + AthMessaging(svcloc != 0 ? msgSvc() : 0, "CmxCpTobByteStreamAuxCnv"), + m_name("CmxCpTobByteStreamAuxCnv"), + m_cpmReadTool("LVL1BS::CpByteStreamV2Tool/CpByteStreamV2Tool") +{ +} + +const CLID& CmxCpTobByteStreamAuxCnv::classID() { + return ClassID_traits<xAOD::CMXCPTobAuxContainer>::ID(); +} + +// Init method gets all necessary services etc. + +#ifndef PACKAGE_VERSION +#define PACKAGE_VERSION "unknown" +#endif +StatusCode CmxCpTobByteStreamAuxCnv::initialize() { + ATH_MSG_DEBUG( + "Initializing " << m_name << " - package version " << PACKAGE_VERSION); + + CHECK(Converter::initialize()); + CHECK(m_cpmReadTool.retrieve()); + + return StatusCode::SUCCESS; +} + +// createObj should create the RDO from bytestream. +StatusCode CmxCpTobByteStreamAuxCnv::createObj(IOpaqueAddress* pAddr, + DataObject*& pObj) { + ATH_MSG_DEBUG("createObj() called"); + // ------------------------------------------------------------------------- + ByteStreamAddress *pBS_Addr = dynamic_cast<ByteStreamAddress *>(pAddr); + CHECK(pBS_Addr != nullptr); + // ------------------------------------------------------------------------- + const std::string nm = *(pBS_Addr->par()); + ATH_MSG_DEBUG("Creating Objects " << nm); + + auto aux = new xAOD::CMXCPTobAuxContainer; + xAOD::CMXCPTobContainer cpmCollection; + cpmCollection.setStore(aux); + // ------------------------------------------------------------------------- + DataVector<LVL1::CMXCPTob> cmxCpTobVector; + StatusCode sc = m_cpmReadTool->convert(nm, &cmxCpTobVector); + if (sc.isFailure()) { + ATH_MSG_ERROR("Failed to create objects"); + delete aux; + return sc; + } + + for (auto ct : cmxCpTobVector) { + xAOD::CMXCPTob* item = new xAOD::CMXCPTob(); + cpmCollection.push_back(item); + std::vector<uint8_t> energyVec(ct->energyVec().begin(), ct->energyVec().end()); + std::vector<uint8_t> isolationVec(ct->isolationVec().begin(), ct->isolationVec().end()); + std::vector<uint8_t> errorVec(ct->errorVec().begin(), ct->errorVec().end()); + std::vector<uint16_t> presenceMapVec(ct->presenceMapVec().begin(), ct->presenceMapVec().end()); + + item->initialize(ct->crate(), ct->cmx(), + ct->cpm(), ct->chip(), ct->location(), + energyVec, + isolationVec, + errorVec, + presenceMapVec, + ct->peak()); + } + + // ------------------------------------------------------------------------- + //ATH_MSG_VERBOSE(ToString(cpmCollection)); + ATH_MSG_DEBUG("Number of readed CMXCpTob: " << aux->size()); + // ------------------------------------------------------------------------- + pObj = SG::asStorable(aux); + return StatusCode::SUCCESS; +} + +// createRep should create the bytestream from RDOs. +StatusCode CmxCpTobByteStreamAuxCnv::createRep(DataObject* /*pObj*/, + IOpaqueAddress*& /*pAddr*/) { + return StatusCode::FAILURE; +} + +} // end namespace diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpTobByteStreamAuxCnv.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpTobByteStreamAuxCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..0dc7b37ea9097d482f338b35f4f9db6b5c3cad1e --- /dev/null +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpTobByteStreamAuxCnv.h @@ -0,0 +1,73 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT1CALOBYTESTREAM_XMXCPTOBBYTESTREAMAUXCNV_H +#define TRIGT1CALOBYTESTREAM_XMXCPTOBBYTESTREAMXAUXCNV_H + +#include <string> + +#include "GaudiKernel/ClassID.h" +#include "GaudiKernel/Converter.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ToolHandle.h" + +#include "AthenaBaseComps/AthMessaging.h" + +class DataObject; +class IByteStreamEventAccess; +class IOpaqueAddress; +class IROBDataProviderSvc; +class ISvcLocator; +class StatusCode; + +template <typename> class CnvFactory; + +// Externals +extern long ByteStream_StorageType; + + +namespace LVL1BS { +class CpByteStreamV2Tool; + +/** ByteStream converter for Pre-processor Module DAQ data / TriggerTowers. + * + * @author alexander.mazurov@cern.ch + */ + +class CmxCpTobByteStreamAuxCnv: public Converter, public ::AthMessaging { + + friend class CnvFactory<CmxCpTobByteStreamAuxCnv>; + +protected: + + CmxCpTobByteStreamAuxCnv(ISvcLocator* svcloc); + +public: + + virtual ~CmxCpTobByteStreamAuxCnv(){}; + + virtual StatusCode initialize(); + /// Create TriggerTowers from ByteStream + virtual StatusCode createObj(IOpaqueAddress* pAddr, DataObject*& pObj); + /// Create ByteStream from TriggerTowers + virtual StatusCode createRep(DataObject* pObj, IOpaqueAddress*& pAddr); + + // Storage type and class ID + virtual long repSvcType() const { return ByteStream_StorageType;} + static long storageType(){ return ByteStream_StorageType; } + + static const CLID& classID(); +private: + /// Converter name + std::string m_name; + + /// Do the main job - retrieve xAOD TriggerTowers from robs + ToolHandle<CpByteStreamV2Tool> m_cpmReadTool; +}; + + + +} // end namespace +#endif diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpTobByteStreamxAODCnv.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpTobByteStreamxAODCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2cc13bbcd4c0bb57556c3c1486fb0e65a574b781 --- /dev/null +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpTobByteStreamxAODCnv.cxx @@ -0,0 +1,102 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include <vector> +#include <stdint.h> + +#include "ByteStreamCnvSvcBase/ByteStreamAddress.h" +#include "ByteStreamCnvSvcBase/IByteStreamEventAccess.h" +#include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" + +#include "ByteStreamData/RawEvent.h" +#include "ByteStreamData/ROBData.h" + +#include "AthenaKernel/errorcheck.h" +#include "GaudiKernel/CnvFactory.h" +#include "GaudiKernel/DataObject.h" +#include "GaudiKernel/IOpaqueAddress.h" +#include "GaudiKernel/IRegistry.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/StatusCode.h" + +#include "SGTools/ClassID_traits.h" +#include "SGTools/StorableConversions.h" +#include "StoreGate/StoreGateSvc.h" + +#include "xAODTrigL1Calo/CMXCPTob.h" +#include "xAODTrigL1Calo/CMXCPTobContainer.h" +#include "xAODTrigL1Calo/CMXCPTobAuxContainer.h" + +#include "CmxCpTobByteStreamxAODCnv.h" + +namespace LVL1BS { + +CmxCpTobByteStreamxAODCnv::CmxCpTobByteStreamxAODCnv(ISvcLocator* svcloc) : + Converter(ByteStream_StorageType, classID(), svcloc), + AthMessaging(svcloc != 0 ? msgSvc() : 0, "CmxCpTobByteStreamxAODCnv"), + m_name("CmxCpTobByteStreamxAODCnv") +{ + +} + +// CLID + +const CLID& CmxCpTobByteStreamxAODCnv::classID() { + return ClassID_traits<xAOD::CMXCPTobContainer>::ID(); +} + +// Init method gets all necessary services etc. + +#ifndef PACKAGE_VERSION +#define PACKAGE_VERSION "unknown" +#endif + +StatusCode CmxCpTobByteStreamxAODCnv::initialize() { + ATH_MSG_DEBUG( + "Initializing " << m_name << " - package version " << PACKAGE_VERSION); + + CHECK(Converter::initialize()); + //CHECK(m_readTool.retrieve()); + return StatusCode::SUCCESS; +} + +// createObj should create the RDO from bytestream. + +StatusCode CmxCpTobByteStreamxAODCnv::createObj(IOpaqueAddress* pAddr, + DataObject*& pObj) { + ATH_MSG_DEBUG("createObj() called"); + // ------------------------------------------------------------------------- + ByteStreamAddress *pBS_Addr = dynamic_cast<ByteStreamAddress *>(pAddr); + CHECK(pBS_Addr != nullptr); + // ------------------------------------------------------------------------- + const std::string nm = *(pBS_Addr->par()); + const std::string nmAux = nm + "Aux."; + ATH_MSG_DEBUG("Creating xAOD::CMXCPTob interface objects '" << nm << "'"); + + xAOD::CMXCPTobContainer* const cpmCollection = + new xAOD::CMXCPTobContainer; + + // Create link with AUX container + DataLink<xAOD::CMXCPTobAuxContainer> link(nmAux); + ATH_MSG_DEBUG("Creating store with data link to '" << nmAux); + + for(size_t i=0; i < link->size(); ++i){ + cpmCollection->push_back(new xAOD::CMXCPTob()); + } + // ========================================================================== + cpmCollection->setStore(link); + pObj = SG::asStorable(cpmCollection); + ATH_MSG_DEBUG("Number of xAOD CPM Towers created: " << cpmCollection->size()); + + return StatusCode::SUCCESS; +} + +// createRep should create the bytestream from RDOs. + +StatusCode CmxCpTobByteStreamxAODCnv::createRep(DataObject* /*pObj*/, + IOpaqueAddress*& /*pAddr*/) { + return StatusCode::FAILURE; +} + +} // end namespace diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpTobByteStreamxAODCnv.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpTobByteStreamxAODCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..145e726c4590adcf0b8c1672682f95c0f132bce2 --- /dev/null +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CmxCpTobByteStreamxAODCnv.h @@ -0,0 +1,65 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT1CALOBYTESTREAM_CMXCPTOBBYTESTREAMXAODCNV_H +#define TRIGT1CALOBYTESTREAM_CMXCPTOBBYTESTREAMXAODCNV_H + +#include <string> + +#include "GaudiKernel/ClassID.h" +#include "GaudiKernel/Converter.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ToolHandle.h" + +#include "AthenaBaseComps/AthMessaging.h" + +class DataObject; +class IOpaqueAddress; +class ISvcLocator; +class StatusCode; + +template <typename> class CnvFactory; +class StoreGateSvc; +// Externals +extern long ByteStream_StorageType; + +namespace LVL1BS { +/** ByteStream converter for CmxTob. + * + * @author alexander.mazurov@cern.ch + */ + +class CmxCpTobByteStreamxAODCnv: public Converter, public ::AthMessaging { + + friend class CnvFactory<CmxCpTobByteStreamxAODCnv>; + +protected: + + CmxCpTobByteStreamxAODCnv(ISvcLocator* svcloc); + +public: + + virtual ~CmxCpTobByteStreamxAODCnv(){}; + + virtual StatusCode initialize(); + /// Create TriggerTowers from ByteStream + virtual StatusCode createObj(IOpaqueAddress* pAddr, DataObject*& pObj); + /// Create ByteStream from TriggerTowers + virtual StatusCode createRep(DataObject* pObj, IOpaqueAddress*& pAddr); + + // Storage type and class ID + virtual long repSvcType() const { return ByteStream_StorageType;} + static long storageType(){ return ByteStream_StorageType; } + + static const CLID& classID(); + +private: + /// Converter name + std::string m_name; +}; + +} // end namespace + +#endif diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmTowerByteStreamAuxCnv.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmTowerByteStreamAuxCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..41eace4f3a9b859868c58d3b49a44e59d4ef6e9b --- /dev/null +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmTowerByteStreamAuxCnv.cxx @@ -0,0 +1,137 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ============================================================================ +// Includes +// ============================================================================ +// STD +// ============================================================================ +#include <vector> +#include <cstdint> +#include <memory> +#include <algorithm> +// ============================================================================ +// Athena +// ============================================================================ +#include "ByteStreamCnvSvcBase/ByteStreamAddress.h" +#include "ByteStreamCnvSvcBase/IByteStreamEventAccess.h" +#include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" + +#include "ByteStreamData/RawEvent.h" +#include "ByteStreamData/ROBData.h" + +#include "AthenaKernel/errorcheck.h" +#include "GaudiKernel/CnvFactory.h" +#include "GaudiKernel/DataObject.h" +#include "GaudiKernel/IOpaqueAddress.h" +#include "GaudiKernel/IRegistry.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/StatusCode.h" + +#include "SGTools/ClassID_traits.h" +#include "SGTools/StorableConversions.h" +#include "StoreGate/StoreGateSvc.h" + +// ============================================================================ +// TrigT1 +// ============================================================================ +#include "TrigT1CaloEvent/CMXCPHits.h" +#include "TrigT1CaloEvent/CMXCPTob.h" +#include "TrigT1CaloEvent/CPMTower.h" +// ============================================================================ +// xAOD +// ============================================================================ +#include "xAODTrigL1Calo/CPMTower.h" +#include "xAODTrigL1Calo/CPMTowerContainer.h" +#include "xAODTrigL1Calo/CPMTowerAuxContainer.h" +// ============================================================================ +// Local +// ============================================================================ +#include "CpmTowerByteStreamAuxCnv.h" +#include "../CpByteStreamV2Tool.h" +#include "../ToString.h" +// ============================================================================ + +namespace LVL1BS { +CpmTowerByteStreamAuxCnv::CpmTowerByteStreamAuxCnv(ISvcLocator* svcloc) : + Converter(ByteStream_StorageType, classID(), svcloc), + AthMessaging(svcloc != 0 ? msgSvc() : 0, "CpmTowerByteStreamAuxCnv"), + m_name("CpmTowerByteStreamAuxCnv"), + m_cpmReadTool("LVL1BS::CpByteStreamV2Tool/CpByteStreamV2Tool") +{ +} + +const CLID& CpmTowerByteStreamAuxCnv::classID() { + return ClassID_traits<xAOD::CPMTowerAuxContainer>::ID(); +} + +// Init method gets all necessary services etc. + +#ifndef PACKAGE_VERSION +#define PACKAGE_VERSION "unknown" +#endif +StatusCode CpmTowerByteStreamAuxCnv::initialize() { + ATH_MSG_DEBUG( + "Initializing " << m_name << " - package version " << PACKAGE_VERSION); + + CHECK(Converter::initialize()); + CHECK(m_cpmReadTool.retrieve()); + + return StatusCode::SUCCESS; +} + +// createObj should create the RDO from bytestream. +StatusCode CpmTowerByteStreamAuxCnv::createObj(IOpaqueAddress* pAddr, + DataObject*& pObj) { + ATH_MSG_DEBUG("createObj() called"); + // ------------------------------------------------------------------------- + ByteStreamAddress *pBS_Addr = dynamic_cast<ByteStreamAddress *>(pAddr); + CHECK(pBS_Addr != nullptr); + // ------------------------------------------------------------------------- + const std::string nm = *(pBS_Addr->par()); + ATH_MSG_DEBUG("Creating Objects " << nm); + + auto aux = new xAOD::CPMTowerAuxContainer; + xAOD::CPMTowerContainer cpmCollection; + cpmCollection.setStore(aux); + // ------------------------------------------------------------------------- + DataVector<LVL1::CPMTower> cpmTowerVector; + StatusCode sc = m_cpmReadTool->convert(nm, &cpmTowerVector); + if (sc.isFailure()) { + ATH_MSG_ERROR("Failed to create objects"); + delete aux; + return sc; + } + + for (auto ct : cpmTowerVector) { + xAOD::CPMTower* item = new xAOD::CPMTower(); + cpmCollection.push_back(item); + std::vector<uint8_t> emEnergyVec(ct->emEnergyVec().begin(), ct->emEnergyVec().end()); + std::vector<uint8_t> hadEnergyVec(ct->hadEnergyVec().begin(), ct->hadEnergyVec().end()); + std::vector<uint8_t> emErrorVec(ct->emErrorVec().begin(), ct->emErrorVec().end()); + std::vector<uint8_t> hadErrorVec(ct->hadErrorVec().begin(), ct->hadErrorVec().end()); + + item->initialize(ct->eta(), ct->phi(), + emEnergyVec, + hadEnergyVec, + emErrorVec, + hadErrorVec, + uint8_t(ct->peak())); + } + + // ------------------------------------------------------------------------- + //ATH_MSG_VERBOSE(ToString(cpmCollection)); + ATH_MSG_DEBUG("Number of readed CPM towers: " << aux->size()); + // ------------------------------------------------------------------------- + pObj = SG::asStorable(aux); + return StatusCode::SUCCESS; +} + +// createRep should create the bytestream from RDOs. +StatusCode CpmTowerByteStreamAuxCnv::createRep(DataObject* /*pObj*/, + IOpaqueAddress*& /*pAddr*/) { + return StatusCode::FAILURE; +} + +} // end namespace diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmTowerByteStreamAuxCnv.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmTowerByteStreamAuxCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..ad73a527a08b88b54f6270b5e30cbaf99059f12e --- /dev/null +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmTowerByteStreamAuxCnv.h @@ -0,0 +1,73 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT1CALOBYTESTREAM_CPMBYTESTREAMAUXCNV_H +#define TRIGT1CALOBYTESTREAM_CPMBYTESTREAMXAUXCNV_H + +#include <string> + +#include "GaudiKernel/ClassID.h" +#include "GaudiKernel/Converter.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ToolHandle.h" + +#include "AthenaBaseComps/AthMessaging.h" + +class DataObject; +class IByteStreamEventAccess; +class IOpaqueAddress; +class IROBDataProviderSvc; +class ISvcLocator; +class StatusCode; + +template <typename> class CnvFactory; + +// Externals +extern long ByteStream_StorageType; + + +namespace LVL1BS { +class CpByteStreamV2Tool; + +/** ByteStream converter for Pre-processor Module DAQ data / TriggerTowers. + * + * @author alexander.mazurov@cern.ch + */ + +class CpmTowerByteStreamAuxCnv: public Converter, public ::AthMessaging { + + friend class CnvFactory<CpmTowerByteStreamAuxCnv>; + +protected: + + CpmTowerByteStreamAuxCnv(ISvcLocator* svcloc); + +public: + + virtual ~CpmTowerByteStreamAuxCnv(){}; + + virtual StatusCode initialize(); + /// Create TriggerTowers from ByteStream + virtual StatusCode createObj(IOpaqueAddress* pAddr, DataObject*& pObj); + /// Create ByteStream from TriggerTowers + virtual StatusCode createRep(DataObject* pObj, IOpaqueAddress*& pAddr); + + // Storage type and class ID + virtual long repSvcType() const { return ByteStream_StorageType;} + static long storageType(){ return ByteStream_StorageType; } + + static const CLID& classID(); +private: + /// Converter name + std::string m_name; + + /// Do the main job - retrieve xAOD TriggerTowers from robs + ToolHandle<CpByteStreamV2Tool> m_cpmReadTool; +}; + + + +} // end namespace +#endif diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmTowerByteStreamxAODCnv.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmTowerByteStreamxAODCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..90784ba5e3eb7b553c0ff2e740f7bace7851d684 --- /dev/null +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmTowerByteStreamxAODCnv.cxx @@ -0,0 +1,102 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include <vector> +#include <stdint.h> + +#include "ByteStreamCnvSvcBase/ByteStreamAddress.h" +#include "ByteStreamCnvSvcBase/IByteStreamEventAccess.h" +#include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" + +#include "ByteStreamData/RawEvent.h" +#include "ByteStreamData/ROBData.h" + +#include "AthenaKernel/errorcheck.h" +#include "GaudiKernel/CnvFactory.h" +#include "GaudiKernel/DataObject.h" +#include "GaudiKernel/IOpaqueAddress.h" +#include "GaudiKernel/IRegistry.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/StatusCode.h" + +#include "SGTools/ClassID_traits.h" +#include "SGTools/StorableConversions.h" +#include "StoreGate/StoreGateSvc.h" + +#include "xAODTrigL1Calo/CPMTower.h" +#include "xAODTrigL1Calo/CPMTowerContainer.h" +#include "xAODTrigL1Calo/CPMTowerAuxContainer.h" + +#include "CpmTowerByteStreamxAODCnv.h" + +namespace LVL1BS { + +CpmTowerByteStreamxAODCnv::CpmTowerByteStreamxAODCnv(ISvcLocator* svcloc) : + Converter(ByteStream_StorageType, classID(), svcloc), + AthMessaging(svcloc != 0 ? msgSvc() : 0, "CpmTowerByteStreamxAODCnv"), + m_name("CpmTowerByteStreamxAODCnv") +{ + +} + +// CLID + +const CLID& CpmTowerByteStreamxAODCnv::classID() { + return ClassID_traits<xAOD::CPMTowerContainer>::ID(); +} + +// Init method gets all necessary services etc. + +#ifndef PACKAGE_VERSION +#define PACKAGE_VERSION "unknown" +#endif + +StatusCode CpmTowerByteStreamxAODCnv::initialize() { + ATH_MSG_DEBUG( + "Initializing " << m_name << " - package version " << PACKAGE_VERSION); + + CHECK(Converter::initialize()); + //CHECK(m_readTool.retrieve()); + return StatusCode::SUCCESS; +} + +// createObj should create the RDO from bytestream. + +StatusCode CpmTowerByteStreamxAODCnv::createObj(IOpaqueAddress* pAddr, + DataObject*& pObj) { + ATH_MSG_DEBUG("createObj() called"); + // ------------------------------------------------------------------------- + ByteStreamAddress *pBS_Addr = dynamic_cast<ByteStreamAddress *>(pAddr); + CHECK(pBS_Addr != nullptr); + // ------------------------------------------------------------------------- + const std::string nm = *(pBS_Addr->par()); + const std::string nmAux = nm + "Aux."; + ATH_MSG_DEBUG("Creating xAOD::CPMTower interface objects '" << nm << "'"); + + xAOD::CPMTowerContainer* const cpmCollection = + new xAOD::CPMTowerContainer; + + // Create link with AUX container + DataLink<xAOD::CPMTowerAuxContainer> link(nmAux); + ATH_MSG_DEBUG("Creating store with data link to '" << nmAux); + + for(size_t i=0; i < link->size(); ++i){ + cpmCollection->push_back(new xAOD::CPMTower()); + } + // ========================================================================== + cpmCollection->setStore(link); + pObj = SG::asStorable(cpmCollection); + ATH_MSG_DEBUG("Number of xAOD CPM Towers created: " << cpmCollection->size()); + + return StatusCode::SUCCESS; +} + +// createRep should create the bytestream from RDOs. + +StatusCode CpmTowerByteStreamxAODCnv::createRep(DataObject* /*pObj*/, + IOpaqueAddress*& /*pAddr*/) { + return StatusCode::FAILURE; +} + +} // end namespace diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmTowerByteStreamxAODCnv.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmTowerByteStreamxAODCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..174c9e24f9763a9790b4d4b945bb180bd79c8b7b --- /dev/null +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmTowerByteStreamxAODCnv.h @@ -0,0 +1,65 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT1CALOBYTESTREAM_CPMTOWERBYTESTREAMXAODCNV_H +#define TRIGT1CALOBYTESTREAM_CPMTOWERBYTESTREAMXAODCNV_H + +#include <string> + +#include "GaudiKernel/ClassID.h" +#include "GaudiKernel/Converter.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ToolHandle.h" + +#include "AthenaBaseComps/AthMessaging.h" + +class DataObject; +class IOpaqueAddress; +class ISvcLocator; +class StatusCode; + +template <typename> class CnvFactory; +class StoreGateSvc; +// Externals +extern long ByteStream_StorageType; + +namespace LVL1BS { +/** ByteStream converter for CpmTowers. + * + * @author alexander.mazurov@cern.ch + */ + +class CpmTowerByteStreamxAODCnv: public Converter, public ::AthMessaging { + + friend class CnvFactory<CpmTowerByteStreamxAODCnv>; + +protected: + + CpmTowerByteStreamxAODCnv(ISvcLocator* svcloc); + +public: + + virtual ~CpmTowerByteStreamxAODCnv(){}; + + virtual StatusCode initialize(); + /// Create TriggerTowers from ByteStream + virtual StatusCode createObj(IOpaqueAddress* pAddr, DataObject*& pObj); + /// Create ByteStream from TriggerTowers + virtual StatusCode createRep(DataObject* pObj, IOpaqueAddress*& pAddr); + + // Storage type and class ID + virtual long repSvcType() const { return ByteStream_StorageType;} + static long storageType(){ return ByteStream_StorageType; } + + static const CLID& classID(); + +private: + /// Converter name + std::string m_name; +}; + +} // end namespace + +#endif diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmWord.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmWord.cxx deleted file mode 100644 index deacd51b7d465d3d5e12654323158d9e57c1f81f..0000000000000000000000000000000000000000 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmWord.cxx +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "CpmWord.h" -#include "WordDecoder.h" - -using namespace LVL1BS; - -namespace { - WordDecoder cpmWordDecoder( - { - BitField("Tower1 Et", 0, 8), - BitField("P1", 8, 1), - BitField("Tower0 Et", 9, 8), - BitField("P0", 17, 1), - BitField("LinkDown", 19, 2), - BitField("TTPair", 21, 2), - BitField("Serializer", 23, 5) - }); -} - - -CpmWord::CpmWord(uint32_t word): - m_word(word){ -} - - -uint8_t CpmWord::tower1Et() const { - return ::cpmWordDecoder.get<uint8_t>(m_word, 0); } - -uint8_t CpmWord::p1() const { - return ::cpmWordDecoder.get<uint8_t>(m_word, 1); -} -uint8_t CpmWord::tower0Et() const { - return ::cpmWordDecoder.get<uint8_t>(m_word,2); -} -uint8_t CpmWord::p0() const { - return ::cpmWordDecoder.get<uint8_t>(m_word, 3); -} -uint8_t CpmWord::linkDown() const { - return ::cpmWordDecoder.get<uint8_t>(m_word, 4); -} -uint8_t CpmWord::ttPair() const { - return ::cpmWordDecoder.get<uint8_t>(m_word, 5); -} -uint8_t CpmWord::serialiser() const { - return ::cpmWordDecoder.get<uint8_t>(m_word, 6); -} - - -bool CpmWord::isValid() const { - return BitField::mask(m_word, 28, 0xc) != 0; -} - -bool CpmWord::isValid(uint32_t word) { - return CpmWord(word).isValid(); -} diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmWord.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmWord.h deleted file mode 100644 index 866938ee55ef2cc7a7d02f4553418acfb69410ed..0000000000000000000000000000000000000000 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/CpmWord.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef TRIGT1CALOBYTESTREAM_CPMWORD_H -#define TRIGT1CALOBYTESTREAM_CPMWORD_H - -#include <cstdint> - -namespace LVL1BS { - -/** L1Calo User Header class. - * - * The User Header is the first word of the ROD data and contains - * Triggered slice offsets for all the sub-detector types. - * - * @author alexander.mazurov@cern.ch - */ - -class CpmWord { -private: - uint32_t m_word; -public: - /// Constructor - default just sets word ID and number of header words - CpmWord(uint32_t header = 0x0); - uint8_t tower1Et() const; - uint8_t p1() const; - uint8_t tower0Et() const; - uint8_t p0() const; - uint8_t linkDown() const; - uint8_t ttPair() const; - uint8_t serialiser() const; - bool isValid() const; - - static bool isValid(uint32_t word); -}; - - - -} // end namespace - -#endif diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamAuxCnv.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamAuxCnv.cxx index 08414eeebbbc17e458fe2c7825a236a07778173c..c7cc6c14e85c58867eb8d893c4b69f994214e4f6 100644 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamAuxCnv.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamAuxCnv.cxx @@ -31,14 +31,14 @@ #include "PpmByteStreamAuxCnv.h" #include "../ToString.h" -#include "L1CaloByteStreamReadTool.h" +#include "PpmByteStreamReadV1V2Tool.h" namespace LVL1BS { PpmByteStreamAuxCnv::PpmByteStreamAuxCnv(ISvcLocator* svcloc) : Converter(ByteStream_StorageType, classID(), svcloc), AthMessaging(svcloc != 0 ? msgSvc() : 0, "PpmByteStreamAuxCnv"), m_name("PpmByteStreamAuxCnv"), - m_readTool("LVL1BS::L1CaloByteStreamReadTool/L1CaloByteStreamReadTool") { + m_readTool("LVL1BS::PpmByteStreamReadV1V2Tool/PpmByteStreamReadV1V2Tool") { } diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamAuxCnv.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamAuxCnv.h index 26c11c683ad79a0415969e11c1c7caf1c01037a7..ce9fc2213c6d4cd3ae4877d0d76e571eb80ca703 100644 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamAuxCnv.h +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamAuxCnv.h @@ -3,7 +3,7 @@ */ #ifndef TRIGT1CALOBYTESTREAM_PPMBYTESTREAMAUXCNV_H -#define TRIGT1CALOBYTESTREAM_PPMBYTESTREAMXAUXCNV_H +#define TRIGT1CALOBYTESTREAM_PPMBYTESTREAMAUXCNV_H #include <string> @@ -16,9 +16,7 @@ #include "AthenaBaseComps/AthMessaging.h" class DataObject; -class IByteStreamEventAccess; class IOpaqueAddress; -class IROBDataProviderSvc; class ISvcLocator; class StatusCode; @@ -29,7 +27,7 @@ extern long ByteStream_StorageType; namespace LVL1BS { -class L1CaloByteStreamReadTool; +class PpmByteStreamReadV1V2Tool; /** ByteStream converter for Pre-processor Module DAQ data / TriggerTowers. * @@ -67,10 +65,10 @@ private: std::string m_name; /// Do the main job - retrieve xAOD TriggerTowers from robs - ToolHandle<L1CaloByteStreamReadTool> m_readTool; + ToolHandle<PpmByteStreamReadV1V2Tool> m_readTool; }; } // end namespace -#endif +#endif // not TRIGT1CALOBYTESTREAM_PPMBYTESTREAMAUXCNV_H diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/L1CaloByteStreamReadTool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamReadV1V2Tool.cxx similarity index 82% rename from Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/L1CaloByteStreamReadTool.cxx rename to Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamReadV1V2Tool.cxx index 157c114c3c1c7dff488b705ff48c88bf45c9fbd7..d1405d07867989f98fa3d5a9ad65fc610d4a5cd2 100644 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/L1CaloByteStreamReadTool.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamReadV1V2Tool.cxx @@ -18,10 +18,11 @@ #include "SubBlockHeader.h" #include "SubBlockStatus.h" #include "WordDecoder.h" -#include "CpmWord.h" + +#include "../L1CaloSubBlock.h" // Only for error codes #include "../L1CaloSrcIdMap.h" -#include "L1CaloByteStreamReadTool.h" +#include "PpmByteStreamReadV1V2Tool.h" // =========================================================================== namespace { @@ -39,25 +40,26 @@ int16_t pedCorrection(uint16_t twoBytePedCor) { return twoBytePedCor > 511? (twoBytePedCor - 1024): twoBytePedCor; } +#if 0 std::string noAuxSuffix(const std::string& name) { if ((name.size() > 4) && (name.substr(name.size()-4, 4) == "Aux.")) { return name.substr(0, name.size() - 4); } return name; } +#endif } // =========================================================================== namespace LVL1BS { // =========================================================================== // Constructor -L1CaloByteStreamReadTool::L1CaloByteStreamReadTool(const std::string& name = - "PpmByteStreamxAODReadTool") : - AsgTool(name), m_sms("SegMemSvc/SegMemSvc", name), +PpmByteStreamReadV1V2Tool::PpmByteStreamReadV1V2Tool(const std::string& name /*= + "PpmByteStreamxAODReadTool"*/) : + AsgTool(name), m_errorTool("LVL1BS::L1CaloErrorByteStreamTool/L1CaloErrorByteStreamTool"), m_ppmMaps("LVL1::PpmMappingTool/PpmMappingTool"), - m_cpmMaps("LVL1::CpmMappingTool/CpmMappingTool"), m_robDataProvider("ROBDataProviderSvc", name) { - declareInterface<L1CaloByteStreamReadTool>(this); + declareInterface<PpmByteStreamReadV1V2Tool>(this); declareProperty("PpmMappingTool", m_ppmMaps, "Crate/Module/Channel to Eta/Phi/Layer mapping tool"); declareProperty("ROBDataProviderSvc", m_robDataProvider, @@ -71,14 +73,13 @@ L1CaloByteStreamReadTool::L1CaloByteStreamReadTool(const std::string& name = #define PACKAGE_VERSION "unknown" #endif -StatusCode L1CaloByteStreamReadTool::initialize() { +StatusCode PpmByteStreamReadV1V2Tool::initialize() { ATH_MSG_INFO( "Initializing " << name() << " - package version " << PACKAGE_VERSION); m_srcIdMap = new L1CaloSrcIdMap(); CHECK(m_errorTool.retrieve()); CHECK(m_ppmMaps.retrieve()); - CHECK(m_cpmMaps.retrieve()); CHECK(m_robDataProvider.retrieve()); ServiceHandle<IIncidentSvc> incidentSvc("IncidentSvc", name()); @@ -90,20 +91,20 @@ StatusCode L1CaloByteStreamReadTool::initialize() { // =========================================================================== // Finalize -StatusCode L1CaloByteStreamReadTool::finalize() { +StatusCode PpmByteStreamReadV1V2Tool::finalize() { delete m_srcIdMap; return StatusCode::SUCCESS; } -void L1CaloByteStreamReadTool::handle( const Incident& inc ) +void PpmByteStreamReadV1V2Tool::handle( const Incident& inc ) { if ( inc.type() == IncidentType::EndEvent) { } } // Conversion bytestream to trigger towers -StatusCode L1CaloByteStreamReadTool::convert( +StatusCode PpmByteStreamReadV1V2Tool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, xAOD::TriggerTowerContainer* const ttCollection) { @@ -126,38 +127,13 @@ StatusCode L1CaloByteStreamReadTool::convert( return StatusCode::SUCCESS; } -// Conversion bytestream to trigger towers -StatusCode L1CaloByteStreamReadTool::convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - xAOD::CPMTowerContainer* const cpmCollection) { - ATH_MSG_DEBUG("Start converting CPM towers"); - ATH_MSG_DEBUG("Number of Calo Cluster Processor fragments: " << robFrags.size()); - - m_cpmTowers = cpmCollection; - m_subDetectorID = eformat::TDAQ_CALO_CLUSTER_PROC_DAQ; - m_requestedType = RequestType::CPM; - ROBIterator rob = robFrags.begin(); - ROBIterator robEnd = robFrags.end(); - - int robCounter = 1; - for (; rob != robEnd; ++rob, ++robCounter) { - - StatusCode sc = processRobFragment_(rob, RequestType::CPM); - if (!sc.isSuccess()) { - - } - } - m_cpmTowers = nullptr; - return StatusCode::SUCCESS; -} - -StatusCode L1CaloByteStreamReadTool::convert( +StatusCode PpmByteStreamReadV1V2Tool::convert( xAOD::TriggerTowerContainer* const ttCollection) { return convert(LVL1::TrigT1CaloDefs::xAODTriggerTowerLocation, ttCollection); } -StatusCode L1CaloByteStreamReadTool::convert(const std::string& sgKey, +StatusCode PpmByteStreamReadV1V2Tool::convert(const std::string& sgKey, xAOD::TriggerTowerContainer* const ttCollection) { m_triggerTowers = ttCollection; @@ -172,27 +148,8 @@ StatusCode L1CaloByteStreamReadTool::convert(const std::string& sgKey, return StatusCode::SUCCESS; } -StatusCode L1CaloByteStreamReadTool::convert( - xAOD::CPMTowerContainer* const cpmCollection) { - // TODO: replace key with TrigT1CaloDefs::xAODCPMTriggerTowerLocation - return convert("xAODCPMTriggerTowers", cpmCollection); -} - -StatusCode L1CaloByteStreamReadTool::convert(const std::string& /*sgKey*/, - xAOD::CPMTowerContainer* const cpmCollection) { - const std::vector<uint32_t>& vID(cpSourceIDs()); - // get ROB fragments - IROBDataProviderSvc::VROBFRAG robFrags; - m_robDataProvider->getROBData(vID, robFrags, "L1CaloByteStreamReadTool"); - ATH_MSG_DEBUG("Number of ROB fragments:" << robFrags.size()); - - CHECK(convert(robFrags, cpmCollection)); - - return StatusCode::SUCCESS; -} - // =========================================================================== -StatusCode L1CaloByteStreamReadTool::processRobFragment_( +StatusCode PpmByteStreamReadV1V2Tool::processRobFragment_( const ROBIterator& robIter, const RequestType& /*requestedType*/) { auto rob = **robIter; @@ -201,10 +158,11 @@ StatusCode L1CaloByteStreamReadTool::processRobFragment_( "Treating ROB fragment source id #" << MSG::hex << rob.rob_source_id()); - const auto robSourceID = rob.rod_source_id(); - const auto sourceID = (robSourceID >> 16) & 0xff; - const auto rodCrate = m_srcIdMap->crate(sourceID); - const auto rodSlink = m_srcIdMap->slink(sourceID); + m_rodSourceId = rob.rod_source_id(); + m_robSourceId = rob.source_id(); + const auto sourceID = (m_rodSourceId >> 16) & 0xff; + const auto rodCrate = m_srcIdMap->crate(m_rodSourceId); + const auto rodSlink = m_srcIdMap->slink(m_rodSourceId); // ------------------------------------------------------------------------- // Check Rob status if (rob.nstatus() > 0) { @@ -212,7 +170,7 @@ StatusCode L1CaloByteStreamReadTool::processRobFragment_( rob.status(robData); if (*robData != 0) { ATH_MSG_WARNING("ROB status error - skipping fragment"); - m_errorTool->robError(robSourceID, *robData); + m_errorTool->robError(m_rodSourceId, *robData); return StatusCode::FAILURE; } } @@ -238,7 +196,7 @@ StatusCode L1CaloByteStreamReadTool::processRobFragment_( if (sourceID != m_subDetectorID) { - ATH_MSG_ERROR("Wrong subdetector source id for requested objects: " << sourceID); + ATH_MSG_ERROR("Wrong subdetector source id for requested objects: " << m_rodSourceId); return StatusCode::FAILURE; } @@ -294,9 +252,6 @@ StatusCode L1CaloByteStreamReadTool::processRobFragment_( case eformat::TDAQ_CALO_PREPROC: CHECK(processPpmWord_(*payload, indata)); break; - case eformat::TDAQ_CALO_CLUSTER_PROC_DAQ: - CHECK(processCpWord_(*payload)); - break; default: break; } @@ -307,7 +262,7 @@ StatusCode L1CaloByteStreamReadTool::processRobFragment_( return StatusCode::SUCCESS; } -StatusCode L1CaloByteStreamReadTool::processPpmWord_(uint32_t word, +StatusCode PpmByteStreamReadV1V2Tool::processPpmWord_(uint32_t word, int indata) { if ( (m_subBlockHeader.format() == 0) || (m_subBlockHeader.format() >= 2) @@ -324,35 +279,8 @@ StatusCode L1CaloByteStreamReadTool::processPpmWord_(uint32_t word, return StatusCode::SUCCESS; } -StatusCode L1CaloByteStreamReadTool::processCpWord_(uint32_t word) { - if ((m_requestedType == RequestType::CPM) && CpmWord::isValid(word)) { - switch(m_verCode){ - case 0x41: - CHECK(processCpmWordR4V1_(word)); - break; - case 0x31: - // TODO - return StatusCode::FAILURE; - break; - default: - break; - } - } - - return StatusCode::SUCCESS; -} - -StatusCode L1CaloByteStreamReadTool::processCpmWordR4V1_(uint32_t word) { - CpmWord cpm(word); - - CHECK(cpm.isValid()); - CHECK(addCpmTower_(m_subBlockHeader.crate(), m_subBlockHeader.module(), - word)); - - return StatusCode::SUCCESS; -} -StatusCode L1CaloByteStreamReadTool::processPpmBlock_() { +StatusCode PpmByteStreamReadV1V2Tool::processPpmBlock_() { if (m_ppBlock.size() > 0) { m_ppPointer = 0; if (m_subBlockHeader.format() == 0) { @@ -395,7 +323,7 @@ StatusCode L1CaloByteStreamReadTool::processPpmBlock_() { return StatusCode::SUCCESS; } -StatusCode L1CaloByteStreamReadTool::processPpmNeutral_() { +StatusCode PpmByteStreamReadV1V2Tool::processPpmNeutral_() { uint8_t numLut = m_subBlockHeader.nSlice1(); uint8_t numFadc = m_subBlockHeader.nSlice2(); uint8_t totSlice = 3 * numLut + numFadc; @@ -477,7 +405,7 @@ StatusCode L1CaloByteStreamReadTool::processPpmNeutral_() { return StatusCode::SUCCESS; } -StatusCode L1CaloByteStreamReadTool::processPpmCompressedR3V1_() { +StatusCode PpmByteStreamReadV1V2Tool::processPpmCompressedR3V1_() { uint8_t chan = 0; m_ppPointer = 0; m_ppMaxBit = 31 * m_ppBlock.size(); @@ -554,13 +482,13 @@ StatusCode L1CaloByteStreamReadTool::processPpmCompressedR3V1_() { chan++; } }catch (const std::out_of_range& ex) { - ATH_MSG_ERROR("Failed to decode ppm block " << ex.what()); - return StatusCode::FAILURE; + ATH_MSG_WARNING("Excess Data in Sub-block"); + m_errorTool->rodError(m_rodSourceId, L1CaloSubBlock::UNPACK_EXCESS_DATA); } return StatusCode::SUCCESS; } -std::vector<uint16_t> L1CaloByteStreamReadTool::getPpmAdcSamplesR3_( +std::vector<uint16_t> PpmByteStreamReadV1V2Tool::getPpmAdcSamplesR3_( uint8_t format, uint8_t minIndex) { std::vector<uint16_t> adc = {0, 0, 0, 0, 0}; @@ -597,7 +525,7 @@ std::vector<uint16_t> L1CaloByteStreamReadTool::getPpmAdcSamplesR3_( -StatusCode L1CaloByteStreamReadTool::processPpmStandardR3V1_(uint32_t word, +StatusCode PpmByteStreamReadV1V2Tool::processPpmStandardR3V1_(uint32_t word, int inData){ bool error = false; if (m_subBlockHeader.seqNum() == 63) { // Error block @@ -633,7 +561,7 @@ StatusCode L1CaloByteStreamReadTool::processPpmStandardR3V1_(uint32_t word, return !error; } -StatusCode L1CaloByteStreamReadTool::processPpmBlockR4V1_() { +StatusCode PpmByteStreamReadV1V2Tool::processPpmBlockR4V1_() { if (m_subBlockHeader.format() == 1) { CHECK(processPpmStandardR4V1_()); return StatusCode::SUCCESS; @@ -645,7 +573,7 @@ StatusCode L1CaloByteStreamReadTool::processPpmBlockR4V1_() { return StatusCode::FAILURE; } -StatusCode L1CaloByteStreamReadTool::processPpmCompressedR4V1_() { +StatusCode PpmByteStreamReadV1V2Tool::processPpmCompressedR4V1_() { m_ppPointer = 0; m_ppMaxBit = 31 * m_ppBlock.size(); @@ -784,14 +712,14 @@ StatusCode L1CaloByteStreamReadTool::processPpmCompressedR4V1_() { pedEn)); } } catch (const std::out_of_range& ex) { - ATH_MSG_ERROR("Failed to decode ppm block " << ex.what()); - return StatusCode::FAILURE; + ATH_MSG_WARNING("Excess Data in Sub-block"); + m_errorTool->rodError(m_rodSourceId, L1CaloSubBlock::UNPACK_EXCESS_DATA); } return StatusCode::SUCCESS; } -void L1CaloByteStreamReadTool::interpretPpmHeaderR4V1_(uint8_t numAdc, +void PpmByteStreamReadV1V2Tool::interpretPpmHeaderR4V1_(uint8_t numAdc, int8_t& encoding, int8_t& minIndex) { uint8_t minHeader = 0; @@ -840,7 +768,7 @@ void L1CaloByteStreamReadTool::interpretPpmHeaderR4V1_(uint8_t numAdc, } } -std::vector<uint16_t> L1CaloByteStreamReadTool::getPpmAdcSamplesR4_( +std::vector<uint16_t> PpmByteStreamReadV1V2Tool::getPpmAdcSamplesR4_( uint8_t encoding, uint8_t minIndex) { uint8_t numAdc = m_subBlockHeader.nSlice2(); @@ -872,7 +800,7 @@ std::vector<uint16_t> L1CaloByteStreamReadTool::getPpmAdcSamplesR4_( } } -StatusCode L1CaloByteStreamReadTool::processPpmBlockR3V1_() { +StatusCode PpmByteStreamReadV1V2Tool::processPpmBlockR3V1_() { if (m_subBlockHeader.format() == 1) { CHECK(processPpmStandardR3V1_()); return StatusCode::SUCCESS; @@ -883,7 +811,7 @@ StatusCode L1CaloByteStreamReadTool::processPpmBlockR3V1_() { return StatusCode::FAILURE; } -StatusCode L1CaloByteStreamReadTool::processPpmStandardR4V1_() { +StatusCode PpmByteStreamReadV1V2Tool::processPpmStandardR4V1_() { uint8_t numAdc = m_subBlockHeader.nSlice2(); uint8_t numLut = m_subBlockHeader.nSlice1(); uint8_t crate = m_subBlockHeader.crate(); @@ -929,8 +857,8 @@ StatusCode L1CaloByteStreamReadTool::processPpmStandardR4V1_() { pedEn.push_back(getPpmBytestreamField_(1)); } } catch (const std::out_of_range& ex) { - ATH_MSG_ERROR("Failed to decode ppm block " << ex.what()); - return StatusCode::FAILURE; + ATH_MSG_WARNING("Excess Data in Sub-block"); + m_errorTool->rodError(m_rodSourceId, L1CaloSubBlock::UNPACK_EXCESS_DATA); } CHECK( addTriggerTowerV2_(crate, module, chan, lcpVal, lcpBcidVec, @@ -940,7 +868,7 @@ StatusCode L1CaloByteStreamReadTool::processPpmStandardR4V1_() { return StatusCode::SUCCESS; } -StatusCode L1CaloByteStreamReadTool::processPpmStandardR3V1_() { +StatusCode PpmByteStreamReadV1V2Tool::processPpmStandardR3V1_() { for(auto lut : m_ppLuts) { CHECK(addTriggerTowerV1_( m_subBlockHeader.crate(), @@ -952,7 +880,7 @@ StatusCode L1CaloByteStreamReadTool::processPpmStandardR3V1_() { return StatusCode::SUCCESS; } -StatusCode L1CaloByteStreamReadTool::addTriggerTowerV2_( +StatusCode PpmByteStreamReadV1V2Tool::addTriggerTowerV2_( uint8_t crate, uint8_t module, uint8_t channel, @@ -1011,7 +939,7 @@ StatusCode L1CaloByteStreamReadTool::addTriggerTowerV2_( return StatusCode::SUCCESS; } -StatusCode L1CaloByteStreamReadTool::addTriggerTowerV1_( +StatusCode PpmByteStreamReadV1V2Tool::addTriggerTowerV1_( uint8_t crate, uint8_t module, uint8_t channel, @@ -1021,19 +949,19 @@ StatusCode L1CaloByteStreamReadTool::addTriggerTowerV1_( const std::vector<uint8_t>& bcidExt ) { - std::vector<uint8_t> ljeVal; std::vector<uint8_t> ljeSat80Vec; std::vector<int16_t> pedCor; std::vector<uint8_t> pedEn; CHECK(addTriggerTowerV2_(crate, module, channel, luts, lcpBcidVec, - ljeVal, ljeSat80Vec, fadc, bcidExt, pedCor, pedEn)); + luts , ljeSat80Vec, fadc, bcidExt, pedCor, pedEn) + ); return StatusCode::SUCCESS; } -StatusCode L1CaloByteStreamReadTool::addTriggerTowerV1_( +StatusCode PpmByteStreamReadV1V2Tool::addTriggerTowerV1_( uint8_t crate, uint8_t module, uint8_t channel, @@ -1063,43 +991,10 @@ StatusCode L1CaloByteStreamReadTool::addTriggerTowerV1_( return StatusCode::SUCCESS; } -StatusCode L1CaloByteStreamReadTool::addCpmTower_( - uint8_t crate, - uint8_t module, - const CpmWord& word) { - // TODO: Handle slices - - std::vector<uint8_t> emEnergy { word.tower0Et()}; - std::vector<uint8_t> hadEnergy { word.tower1Et()}; - std::vector<uint8_t> emError { 0 }; - std::vector<uint8_t> hadError { 0 }; - - - - uint8_t channel = word.ttPair(); // TODO: fix - double eta = 0.; - double phi = 0.; - int layer = 0; - int peak = 0; - m_cpmMaps->mapping(crate, module, channel, eta, phi, layer); - - xAOD::CPMTower *cpm = new xAOD::CPMTower(); - m_cpmTowers->push_back(cpm); - - cpm->setEmEnergyVec(emEnergy); - cpm->setHadEnergyVec(hadEnergy); - cpm->setEmErrorVec(emError); - cpm->setHadErrorVec(hadError); - cpm->setEta(eta); - cpm->setPhi(phi); - cpm->setPeak(peak); - - return StatusCode::SUCCESS; -} // Return reference to vector with all possible Source Identifiers -const std::vector<uint32_t>& L1CaloByteStreamReadTool::ppmSourceIDs( +const std::vector<uint32_t>& PpmByteStreamReadV1V2Tool::ppmSourceIDs( const std::string& sgKey) { const int crates = 8; @@ -1142,31 +1037,8 @@ const std::vector<uint32_t>& L1CaloByteStreamReadTool::ppmSourceIDs( } -const std::vector<uint32_t>& L1CaloByteStreamReadTool::cpSourceIDs() { - const int creates = 4; - const int crateOffsetHw = 8; - - if (m_cpSourceIDs.empty()) - { - const int maxCrates = creates + crateOffsetHw; - const int maxSlinks = m_srcIdMap->maxSlinks(); - for (int hwCrate = crateOffsetHw; hwCrate < maxCrates; ++hwCrate) - { - for (int slink = 0; slink < maxSlinks; ++slink) - { - const int daqOrRoi = 0; - const uint32_t rodId = m_srcIdMap->getRodID(hwCrate, slink, - daqOrRoi, eformat::TDAQ_CALO_CLUSTER_PROC_DAQ); - const uint32_t robId = m_srcIdMap->getRobID(rodId); - m_cpSourceIDs.push_back(robId); - } - } - } - return m_cpSourceIDs; -} - -uint32_t L1CaloByteStreamReadTool::getPpmBytestreamField_(const uint8_t numBits) { +uint32_t PpmByteStreamReadV1V2Tool::getPpmBytestreamField_(const uint8_t numBits) { if ((m_ppPointer + numBits) <= m_ppMaxBit) { uint32_t iWord = m_ppPointer / 31; uint8_t iBit = m_ppPointer % 31; diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/L1CaloByteStreamReadTool.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamReadV1V2Tool.h similarity index 71% rename from Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/L1CaloByteStreamReadTool.h rename to Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamReadV1V2Tool.h index bc58f0b3f66fba4ca5fb049ddf4d1eb0f3b81f93..d5b5e66c87bafb2e98eee6c5a22b0806fc014348 100644 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/L1CaloByteStreamReadTool.h +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamReadV1V2Tool.h @@ -2,8 +2,8 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#ifndef TRIGT1CALOBYTESTREAM_L1CALOBYTESTREAMREADTOOL_H -#define TRIGT1CALOBYTESTREAM_L1CALOBYTESTREAMREADTOOL_H +#ifndef TRIGT1CALOBYTESTREAM_PPMBYTESTREAMREADV1V2TOOL_H +#define TRIGT1CALOBYTESTREAM_PPMBYTESTREAMREADV1V2TOOL_H // =========================================================================== // Includes // =========================================================================== @@ -25,13 +25,9 @@ #include "xAODTrigL1Calo/TriggerTower.h" #include "xAODTrigL1Calo/TriggerTowerContainer.h" -#include "xAODTrigL1Calo/CPMTower.h" -#include "xAODTrigL1Calo/CPMTowerContainer.h" - #include "CaloUserHeader.h" #include "SubBlockHeader.h" #include "SubBlockStatus.h" -#include "CpmWord.h" #include "../L1CaloErrorByteStreamTool.h" @@ -45,7 +41,6 @@ namespace LVL1BS { // Forward declarations class L1CaloSrcIdMap; -class CpmWord; class L1CaloErrorByteStreamTool; // =========================================================================== @@ -56,12 +51,12 @@ class L1CaloErrorByteStreamTool; * @author alexander.mazurov@cern.ch */ -class L1CaloByteStreamReadTool: public asg::AsgTool, virtual public IIncidentListener { - ASG_TOOL_INTERFACE(L1CaloByteStreamReadTool) - ASG_TOOL_CLASS0(L1CaloByteStreamReadTool) +class PpmByteStreamReadV1V2Tool: public asg::AsgTool, virtual public IIncidentListener { + ASG_TOOL_INTERFACE(PpmByteStreamReadV1V2Tool) + ASG_TOOL_CLASS0(PpmByteStreamReadV1V2Tool) public: - L1CaloByteStreamReadTool(const std::string& name); - virtual ~L1CaloByteStreamReadTool(){}; + PpmByteStreamReadV1V2Tool(const std::string& name); + virtual ~PpmByteStreamReadV1V2Tool() {}; virtual StatusCode initialize(); virtual StatusCode finalize(); @@ -76,17 +71,8 @@ public: StatusCode convert(xAOD::TriggerTowerContainer* const ttCollection); StatusCode convert(const std::string& sgKey, xAOD::TriggerTowerContainer* const ttCollection); // ========================================================================= - StatusCode convert( - const IROBDataProviderSvc::VROBFRAG& robFrags, - xAOD::CPMTowerContainer* const cpmCollection - ); - StatusCode convert(xAOD::CPMTowerContainer* const cpmCollection); - StatusCode convert(const std::string& sgKey, - xAOD::CPMTowerContainer* const cpmCollection); - // ========================================================================= /// Return reference to vector with all possible Source Identifiers const std::vector<uint32_t>& ppmSourceIDs(const std::string& sgKey); - const std::vector<uint32_t>& cpSourceIDs(); private: enum class RequestType { PPM, CPM, CMX }; @@ -97,14 +83,14 @@ private: private: StatusCode processRobFragment_(const ROBIterator& robFrag, - const RequestType& requestedType); - + const RequestType& requestedType); + // ========================================================================== // PPM // ========================================================================== StatusCode processPpmWord_(uint32_t word, int indata); StatusCode processPpmBlock_(); - + StatusCode processPpmBlockR4V1_(); StatusCode processPpmBlockR3V1_(); StatusCode processPpmStandardR4V1_(); @@ -114,25 +100,25 @@ private: std::vector<uint16_t> getPpmAdcSamplesR3_(uint8_t format, uint8_t minIndex); StatusCode processPpmCompressedR4V1_(); void interpretPpmHeaderR4V1_(uint8_t numAdc, int8_t& encoding, - int8_t& minIndex); + int8_t& minIndex); std::vector<uint16_t> getPpmAdcSamplesR4_(uint8_t encoding, uint8_t minIndex); StatusCode processPpmNeutral_(); uint32_t getPpmBytestreamField_(uint8_t numBits); - + StatusCode addTriggerTowerV2_( - uint8_t crate, - uint8_t module, - uint8_t channel, - const std::vector<uint8_t>& lcpVal, - const std::vector<uint8_t>& lcpBcidVec, + uint8_t crate, + uint8_t module, + uint8_t channel, + const std::vector<uint8_t>& lcpVal, + const std::vector<uint8_t>& lcpBcidVec, - const std::vector<uint8_t>& ljeVal, - const std::vector<uint8_t>& ljeSat80Vec, + const std::vector<uint8_t>& ljeVal, + const std::vector<uint8_t>& ljeSat80Vec, - const std::vector<uint16_t>& adcVal, - const std::vector<uint8_t>& adcExt, - const std::vector<int16_t>& pedCor, - const std::vector<uint8_t>& pedEn); + const std::vector<uint16_t>& adcVal, + const std::vector<uint8_t>& adcExt, + const std::vector<int16_t>& pedCor, + const std::vector<uint8_t>& pedEn); StatusCode addTriggerTowerV1_( uint8_t crate, @@ -152,20 +138,10 @@ private: const std::vector<uint8_t>& bcidExt ); - // ========================================================================== - // CPM - // ========================================================================== - StatusCode processCpWord_(uint32_t word); - StatusCode processCpmWordR4V1_(uint32_t word); - // ========================================================================== - - StatusCode addCpmTower_(uint8_t crate, uint8_t module, const CpmWord& word); private: - ServiceHandle<SegMemSvc> m_sms; ToolHandle<LVL1BS::L1CaloErrorByteStreamTool> m_errorTool; /// Channel mapping tool ToolHandle<LVL1::IL1CaloMappingTool> m_ppmMaps; - ToolHandle<LVL1::IL1CaloMappingTool> m_cpmMaps; /// Service for reading bytestream ServiceHandle<IROBDataProviderSvc> m_robDataProvider; @@ -176,7 +152,7 @@ private: uint8_t m_subDetectorID; RequestType m_requestedType; - + std::set<uint32_t> m_coolIds; std::vector<uint32_t> m_ppmSourceIDs; bool m_ppmIsRetMuon; @@ -186,13 +162,12 @@ private: std::vector<uint32_t> m_cpSourceIDs; L1CaloSrcIdMap* m_srcIdMap; + uint32_t m_rodSourceId; + uint32_t m_robSourceId; uint32_t m_rodRunNumber; uint16_t m_rodVer; uint8_t m_verCode; - // ========================================================================== - // PPM related structures - // ========================================================================== // For RUN2 std::vector<uint32_t> m_ppBlock; uint32_t m_ppPointer; @@ -203,7 +178,6 @@ private: // ========================================================================== private: xAOD::TriggerTowerContainer* m_triggerTowers; - xAOD::CPMTowerContainer* m_cpmTowers; }; // =========================================================================== diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamxAODCnv.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamxAODCnv.cxx index 387ddf2155969571f8058b84016b6ca083532040..14c96277037b2ca70811f184f5c7c10657634330 100644 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamxAODCnv.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamxAODCnv.cxx @@ -36,8 +36,7 @@ namespace LVL1BS { PpmByteStreamxAODCnv::PpmByteStreamxAODCnv(ISvcLocator* svcloc) : Converter(ByteStream_StorageType, classID(), svcloc), AthMessaging(svcloc != 0 ? msgSvc() : 0, "PpmByteStreamxAODCnv"), - m_name("PpmByteStreamxAODCnv"), - m_readTool("LVL1BS::L1CaloByteStreamReadTool/L1CaloByteStreamReadTool") + m_name("PpmByteStreamxAODCnv") { } @@ -59,7 +58,6 @@ StatusCode PpmByteStreamxAODCnv::initialize() { "Initializing " << m_name << " - package version " << PACKAGE_VERSION); CHECK(Converter::initialize()); - CHECK(m_readTool.retrieve()); return StatusCode::SUCCESS; } diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamxAODCnv.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamxAODCnv.h index b444a0f85cbece28f793b9d9ecc412ebc887a2bd..4c04ae8ce60762ed753895cb41f8e544ee4507b7 100644 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamxAODCnv.h +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/xaod/PpmByteStreamxAODCnv.h @@ -14,7 +14,6 @@ #include "GaudiKernel/ToolHandle.h" #include "AthenaBaseComps/AthMessaging.h" -#include "L1CaloByteStreamReadTool.h" class DataObject; class IByteStreamEventAccess; @@ -34,7 +33,6 @@ extern long ByteStream_StorageType; namespace LVL1BS { -class L1CaloByteStreamReadTool; /** ByteStream converter for Pre-processor Module DAQ data / TriggerTowers. * @@ -68,8 +66,7 @@ public: private: /// Converter name std::string m_name; - /// Do the main job - retrieve xAOD TriggerTowers from robs - ToolHandle<L1CaloByteStreamReadTool> m_readTool; + }; } // end namespace