diff --git a/Trigger/TrigT1/L1CaloFEX/L1CaloFEXByteStream/python/L1CaloFEXByteStreamConfig.py b/Trigger/TrigT1/L1CaloFEX/L1CaloFEXByteStream/python/L1CaloFEXByteStreamConfig.py index 744e24704c8be6a3232afb53114684b97ed7ffa8..14076ddb9f47770d1e12f0d885e452cebb9f50a2 100644 --- a/Trigger/TrigT1/L1CaloFEX/L1CaloFEXByteStream/python/L1CaloFEXByteStreamConfig.py +++ b/Trigger/TrigT1/L1CaloFEX/L1CaloFEXByteStream/python/L1CaloFEXByteStreamConfig.py @@ -14,6 +14,7 @@ def jFexByteStreamToolCfg(name, flags, writeBS=False): tool.jJRoIContainerReadKey ="L1_jFexSRJetRoI" tool.jLJRoIContainerReadKey ="L1_jFexLRJetRoI" tool.jTauRoIContainerReadKey ="L1_jFexTauRoI" + tool.jEMRoIContainerReadKey ="L1_jFexFwdElRoI" tool.jTERoIContainerReadKey ="L1_jFexSumETRoI" tool.jXERoIContainerReadKey ="L1_jFexMETRoI" @@ -21,6 +22,7 @@ def jFexByteStreamToolCfg(name, flags, writeBS=False): tool.jJRoIContainerWriteKey ="" tool.jLJRoIContainerWriteKey ="" tool.jTauRoIContainerWriteKey="" + tool.jEMRoIContainerWriteKey ="" tool.jTERoIContainerWriteKey ="" tool.jXERoIContainerWriteKey ="" else: @@ -28,6 +30,7 @@ def jFexByteStreamToolCfg(name, flags, writeBS=False): tool.jJRoIContainerReadKey ="" tool.jLJRoIContainerReadKey ="" tool.jTauRoIContainerReadKey ="" + tool.jEMRoIContainerReadKey ="" tool.jTERoIContainerReadKey ="" tool.jXERoIContainerReadKey ="" @@ -35,6 +38,7 @@ def jFexByteStreamToolCfg(name, flags, writeBS=False): tool.jJRoIContainerWriteKey ="L1_jFexSRJetRoI" tool.jLJRoIContainerWriteKey ="L1_jFexLRJetRoI" tool.jTauRoIContainerWriteKey="L1_jFexTauRoI" + tool.jEMRoIContainerWriteKey ="L1_jFexFwdElRoI" tool.jTERoIContainerWriteKey ="L1_jFexSumETRoI" tool.jXERoIContainerWriteKey ="L1_jFexMETRoI" diff --git a/Trigger/TrigT1/L1CaloFEX/L1CaloFEXByteStream/src/jFexByteStreamTool.cxx b/Trigger/TrigT1/L1CaloFEX/L1CaloFEXByteStream/src/jFexByteStreamTool.cxx index 86828e9a8741622c1ce86aa7cda9d43d2c677054..51c73c881963f65b63939d7c91f6d795a380fd46 100644 --- a/Trigger/TrigT1/L1CaloFEX/L1CaloFEXByteStream/src/jFexByteStreamTool.cxx +++ b/Trigger/TrigT1/L1CaloFEX/L1CaloFEXByteStream/src/jFexByteStreamTool.cxx @@ -34,7 +34,7 @@ struct color { std::string B_GRAY ="\033[1;100m"; std::string B_RED ="\033[1;41m"; std::string B_GREEN ="\033[1;42m"; -} /*C*/; +} const C; jFexByteStreamTool::jFexByteStreamTool(const std::string& type, const std::string& name, @@ -66,6 +66,14 @@ StatusCode jFexByteStreamTool::initialize() { ATH_MSG_DEBUG((jTaumode==ConversionMode::Encoding ? "Encoding" : "Decoding") << " jTau ROB IDs: " << MSG::hex << m_robIds.value() << MSG::dec); + // Conversion mode for jEM TOBs + ConversionMode jEMmode = getConversionMode(m_jEMReadKey, m_jEMWriteKey, msg()); + ATH_CHECK(jEMmode!=ConversionMode::Undefined); + ATH_CHECK(m_jEMWriteKey.initialize(jEMmode==ConversionMode::Decoding)); + ATH_CHECK(m_jEMReadKey.initialize(jEMmode==ConversionMode::Encoding)); + ATH_MSG_DEBUG((jEMmode==ConversionMode::Encoding ? "Encoding" : "Decoding") << " jEM ROB IDs: " + << MSG::hex << m_robIds.value() << MSG::dec); + // Conversion mode for jTE TOBs ConversionMode jTEmode = getConversionMode(m_jTEReadKey, m_jTEWriteKey, msg()); ATH_CHECK(jTEmode!=ConversionMode::Undefined); @@ -83,7 +91,7 @@ StatusCode jFexByteStreamTool::initialize() { << MSG::hex << m_robIds.value() << MSG::dec); //checking all Conversion modes.. avoid misconfigurations - const std::array modes{jLJmode,jTaumode,jTEmode,jXEmode}; + const std::array modes{jLJmode,jTaumode,jEMmode,jTEmode,jXEmode}; if (std::any_of(modes.begin(),modes.end(),[&jJmode](ConversionMode m) { return m!=jJmode; } )) { ATH_MSG_ERROR("Inconsistent conversion modes"); return StatusCode::FAILURE; @@ -99,7 +107,6 @@ StatusCode jFexByteStreamTool::convertFromBS(const std::vector& vro //std::cout<& vro ATH_CHECK(jTauContainer.record(std::make_unique(), std::make_unique())); ATH_MSG_DEBUG("Recorded jFexTauRoIContainer with key " << jTauContainer.key()); + //---EM EDM + SG::WriteHandle jEMContainer(m_jEMWriteKey, ctx); + ATH_CHECK(jEMContainer.record(std::make_unique(), std::make_unique())); + ATH_MSG_DEBUG("Recorded jFexFwdElRoIContainer with key " << jEMContainer.key()); + //---SumET EDM SG::WriteHandle jTEContainer(m_jTEWriteKey, ctx); ATH_CHECK(jTEContainer.record(std::make_unique(), std::make_unique())); @@ -137,10 +149,16 @@ StatusCode jFexByteStreamTool::convertFromBS(const std::vector& vro //ATH_MSG_DEBUG("Starting to decode " << ndata << " ROD words from ROB 0x" << std::hex << rob->rob_source_id() << std::dec); //std::cout<< "Starting to decode " << rob->rod_ndata() << " ROD words from ROB 0x" << std::hex << rob->rob_source_id() << std::dec << std::endl; + //There is no data to decode.. not even the ROD trailers + if(rob->rod_ndata() <= 0){ + //printf("ERROR No ROD words read. rob->rod_ndata() =%3d \n",rob->rod_ndata()); + continue; + } + const auto dataArray = CxxUtils::span{rob->rod_data(), rob->rod_ndata()}; std::vector vec_words(dataArray.begin(),dataArray.end()); -/* for debug +/* int aux = 1; //delete, for debug for (const uint32_t word : vec_words) { @@ -163,8 +181,23 @@ StatusCode jFexByteStreamTool::convertFromBS(const std::vector& vro const auto [n_xjJ, n_xjLJ, n_xjTau, n_xjEM] = xTOBCounterTrailer( vec_words.at(trailers_pos-3) ); const auto [n_jJ, n_jLJ, n_jTau, n_jEM, n_jTE, n_jXE] = TOBCounterTrailer ( vec_words.at(trailers_pos-4) ); //printf("----------> trailer_pos:%3d payload:%3d fpga:%3d jfex:%3d\n",trailers_pos,payload,fpga,jfex); - //printf("xTOBs: xjJ:%3d xjLJ:%3d xjTau:%3d xjEM:%3d\n",n_xjJ,n_xjLJ,n_xjTau,n_xjEM); - //printf(" TOBs: jJ:%3d jLJ:%3d jTau:%3d jEM:%3d jTE:%3d jXE:%3d\n",n_jJ,n_jLJ,n_jTau,n_jEM,n_jTE,n_jXE); + //printf(" TOBs(0x%08x): jJ:%3d jLJ:%3d jTau:%3d jEM:%3d jTE:%3d jXE:%3d\n",vec_words.at(trailers_pos-4),n_jJ,n_jLJ,n_jTau,n_jEM,n_jTE,n_jXE); + //printf("xTOBs(0x%08x): xjJ:%3d xjLJ:%3d xjTau:%3d xjEM:%3d\n",vec_words.at(trailers_pos-3),n_xjJ,n_xjLJ,n_xjTau,n_xjEM); + + if(jfex == 5 or jfex == 0){ + trailers_pos -= (payload+2); + if(trailers_pos == 0) { + READ_TOBS = false; + } + continue; + } + + //The minimum number for the payload should be 2 (The TOB/xTOB counters). If lower send an error message + if(payload < jBits::TOB_TRAILERS){ + //printf("ERROR Payload is lower than the TOB/xTOB trailers. (Payload = %3d < %3d = TOB Trailer) \n",payload,jBits::TOB_TRAILERS); + break; + } + //There can be a padding word, even number in the payload, but odd number of xTOB and TOB.. need to check and remove the extra word. unsigned int total_tobs = n_xjJ + n_xjLJ + n_xjTau + n_xjEM + n_jJ + n_jLJ + n_jTau + n_jEM + n_jTE + n_jXE; @@ -181,10 +214,12 @@ StatusCode jFexByteStreamTool::convertFromBS(const std::vector& vro /************************************************** DECODING xTOBS **************************************************/ //saving xjEM into the EDM container //printf("**** %7s: %3d ****\n","n_xjEM",n_xjEM); -/* for(unsigned int i=tobIndex; i>tobIndex-n_xjEM; i--){ + for(unsigned int i=tobIndex; i>tobIndex-n_xjEM; i--){ //printf(" N.:%3d raw word: 0x%08x with index:%3d\n",tobIndex-i,vec_words.at(i-1),i); + jEMContainer->push_back( std::make_unique() ); + jEMContainer->back()->initialize(jfex, fpga, vec_words.at(i-1) ,0 , 200, -99, -99); } -*/ //removing xjEM counter from TOBs + //removing xjEM counter from TOBs tobIndex -= n_xjEM; //saving xjTau into the EDM container @@ -252,10 +287,12 @@ StatusCode jFexByteStreamTool::convertFromBS(const std::vector& vro //saving jEM into the EDM container //printf("**** %7s: %3d ****\n","n_jEM",n_jEM); -/* for(unsigned int i=tobIndex; i>tobIndex-n_jEM; i--){ + for(unsigned int i=tobIndex; i>tobIndex-n_jEM; i--){ //printf(" N.:%3d raw word: 0x%08x with index:%3d\n",tobIndex-i,vec_words.at(i-1),i); + jEMContainer->push_back( std::make_unique() ); + jEMContainer->back()->initialize(jfex, fpga, vec_words.at(i-1) ,0 , 200, -99, -99); } -*/ //removing jEM counter from TOBs + //removing jEM counter from TOBs tobIndex -= n_jEM; //saving jTau into the EDM container diff --git a/Trigger/TrigT1/L1CaloFEX/L1CaloFEXByteStream/src/jFexByteStreamTool.h b/Trigger/TrigT1/L1CaloFEX/L1CaloFEXByteStream/src/jFexByteStreamTool.h index 3ad750ca457f01184a0740521d3d5bdc3d7f37fc..52d9bbcd94220d1261e09f2b5d8037bf39e02659 100644 --- a/Trigger/TrigT1/L1CaloFEX/L1CaloFEXByteStream/src/jFexByteStreamTool.h +++ b/Trigger/TrigT1/L1CaloFEX/L1CaloFEXByteStream/src/jFexByteStreamTool.h @@ -21,6 +21,8 @@ #include "xAODTrigger/jFexLRJetRoIAuxContainer.h" #include "xAODTrigger/jFexTauRoIContainer.h" #include "xAODTrigger/jFexTauRoIAuxContainer.h" +#include "xAODTrigger/jFexFwdElRoIContainer.h" +#include "xAODTrigger/jFexFwdElRoIAuxContainer.h" #include "xAODTrigger/jFexMETRoIContainer.h" #include "xAODTrigger/jFexMETRoIAuxContainer.h" #include "xAODTrigger/jFexSumETRoIContainer.h" @@ -62,18 +64,20 @@ class jFexByteStreamTool : public extends Gaudi::Property> m_robIds {this, "ROBIDs", {}, "List of ROB IDs required for conversion to/from xAOD RoI"}; // Write handle keys for the L1Calo EDMs for BS->xAOD mode of operation - SG::WriteHandleKey< xAOD::jFexSRJetRoIContainer> m_jJWriteKey {this,"jJRoIContainerWriteKey" ,"L1_jFexSRJetRoI","Write jFexEM container"}; - SG::WriteHandleKey< xAOD::jFexLRJetRoIContainer> m_jLJWriteKey {this,"jLJRoIContainerWriteKey" ,"L1_jFexLRJetRoI","Write jFexEM container"}; + SG::WriteHandleKey< xAOD::jFexSRJetRoIContainer> m_jJWriteKey {this,"jJRoIContainerWriteKey" ,"L1_jFexSRJetRoI","Write jFexEDM SRjet container"}; + SG::WriteHandleKey< xAOD::jFexLRJetRoIContainer> m_jLJWriteKey {this,"jLJRoIContainerWriteKey" ,"L1_jFexLRJetRoI","Write jFexEDM LRjet container"}; SG::WriteHandleKey< xAOD::jFexTauRoIContainer > m_jTauWriteKey {this,"jTauRoIContainerWriteKey","L1_jFexTauRoI" ,"Write jFexEDM tau container"}; SG::WriteHandleKey< xAOD::jFexSumETRoIContainer> m_jTEWriteKey {this,"jTERoIContainerWriteKey" ,"L1_jFexSumETRoI","Write jFexEDM SumET container"}; SG::WriteHandleKey< xAOD::jFexMETRoIContainer > m_jXEWriteKey {this,"jXERoIContainerWriteKey" ,"L1_jFexMETRoI" ,"Write jFexEDM Met container"}; + SG::WriteHandleKey< xAOD::jFexFwdElRoIContainer> m_jEMWriteKey {this,"jEMRoIContainerWriteKey" ,"L1_jFexFwdElRoI","Write jFexEDM fwdEl container"}; // Read handle keys for the L1Calo EDMs for xAOD->BS mode of operation - SG::ReadHandleKey< xAOD::jFexSRJetRoIContainer> m_jJReadKey {this,"jJRoIContainerReadKey" ,"L1_jFexSRJetRoI","Read jFexEM container"}; - SG::ReadHandleKey< xAOD::jFexLRJetRoIContainer> m_jLJReadKey {this,"jLJRoIContainerReadKey" ,"L1_jFexLRJetRoI","Read jFexEM container"}; + SG::ReadHandleKey< xAOD::jFexSRJetRoIContainer> m_jJReadKey {this,"jJRoIContainerReadKey" ,"L1_jFexSRJetRoI","Read jFexEDM SRjet container"}; + SG::ReadHandleKey< xAOD::jFexLRJetRoIContainer> m_jLJReadKey {this,"jLJRoIContainerReadKey" ,"L1_jFexLRJetRoI","Read jFexEDM LRjet container"}; SG::ReadHandleKey< xAOD::jFexTauRoIContainer > m_jTauReadKey {this,"jTauRoIContainerReadKey","L1_jFexTauRoI" ,"Read jFexEDM tau container"}; SG::ReadHandleKey< xAOD::jFexSumETRoIContainer> m_jTEReadKey {this,"jTERoIContainerReadKey" ,"L1_jFexSumETRoI","Read jFexEDM SumET container"}; - SG::ReadHandleKey< xAOD::jFexMETRoIContainer > m_jXEReadKey {this,"jXERoIContainerReadKey" ,"L1_jFexMETRoI" ,"Read jFexEDM Met container"}; + SG::ReadHandleKey< xAOD::jFexMETRoIContainer > m_jXEReadKey {this,"jXERoIContainerReadKey" ,"L1_jFexMETRoI" ,"Read jFexEDM Met container"}; + SG::ReadHandleKey< xAOD::jFexFwdElRoIContainer> m_jEMReadKey {this,"jEMRoIContainerReadKey" ,"L1_jFexFwdElRoI","Read jFexEDM fwdEl container"}; std::array TOBCounterTrailer (uint32_t word) const; std::array xTOBCounterTrailer(uint32_t word) const; diff --git a/Trigger/TrigT1/TrigT1ResultByteStream/python/TrigT1ResultByteStreamConfig.py b/Trigger/TrigT1/TrigT1ResultByteStream/python/TrigT1ResultByteStreamConfig.py index 3793cafc6e7bbfa4b4f21537b147c01cab9d7f37..a5ddeaeef250661ac043742bb5de2c8d48bd3f7d 100644 --- a/Trigger/TrigT1/TrigT1ResultByteStream/python/TrigT1ResultByteStreamConfig.py +++ b/Trigger/TrigT1/TrigT1ResultByteStream/python/TrigT1ResultByteStreamConfig.py @@ -237,6 +237,7 @@ if __name__ == '__main__': outputEDM += addEDM('xAOD::jFexSRJetRoIContainer', jFexTool.jJRoIContainerWriteKey.Path) outputEDM += addEDM('xAOD::jFexLRJetRoIContainer', jFexTool.jLJRoIContainerWriteKey.Path) outputEDM += addEDM('xAOD::jFexTauRoIContainer' , jFexTool.jTauRoIContainerWriteKey.Path) + outputEDM += addEDM('xAOD::jFexFwdElRoIContainer', jFexTool.jEMRoIContainerWriteKey.Path) outputEDM += addEDM('xAOD::jFexSumETRoIContainer', jFexTool.jTERoIContainerWriteKey.Path) outputEDM += addEDM('xAOD::jFexMETRoIContainer' , jFexTool.jXERoIContainerWriteKey.Path)