diff --git a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileDigitsContByteStreamTool.h b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileDigitsContByteStreamTool.h index 288f01833424c58455b8132252f6e718fbe2911b..46a14fb572374351e3c9864562fb9b50e8373568 100644 --- a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileDigitsContByteStreamTool.h +++ b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileDigitsContByteStreamTool.h @@ -59,6 +59,7 @@ class TileDigitsContByteStreamTool: public AthAlgTool { bool m_verbose; bool m_doFragType1; bool m_doFragType5; + int m_runPeriod; }; #endif diff --git a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileMuRcvContByteStreamTool.h b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileMuRcvContByteStreamTool.h index 5aa481e6928e6c5fd8e58695f2df7207c345e874..2347ea923c2c621ab401c47165e37613ac1fd942 100644 --- a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileMuRcvContByteStreamTool.h +++ b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileMuRcvContByteStreamTool.h @@ -62,7 +62,7 @@ class TileMuRcvContByteStreamTool: public AthAlgTool { const TileHid2RESrcID* m_hid2re; - //bool m_verbose; + int m_runPeriod; }; #endif diff --git a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Decoder.h b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Decoder.h index fb00fc0f4ab96eb5465c64881e6a1efe825ff12e..f724cb0807e4367b2f37c823977f0d2d6e2deea5 100644 --- a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Decoder.h +++ b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Decoder.h @@ -578,6 +578,7 @@ class TileROD_Decoder: public AthAlgTool { unsigned int m_maxChannels; bool m_checkMaskedDrawers; + int m_runPeriod; const uint32_t * get_data(const ROBData * rob) const { const uint32_t * p; diff --git a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Encoder.h b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Encoder.h index a5395dd9dcd602dafd008d105b4d3599cdd4852d..92485ba25fb93c9a41dc705d04e385137033c898 100644 --- a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Encoder.h +++ b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Encoder.h @@ -53,7 +53,7 @@ class TileROD_Encoder /** set all necessary parameters for the encoder */ void setTileHWID(const TileHWID* tileHWID, bool verbose, unsigned int type = 4); - void setTileHWID(const TileHWID* tileHWID); + void setTileHWID(const TileHWID* tileHWID, int m_runPeriod); /** set OF algorigtm type and amplitude units for a drawer */ @@ -147,6 +147,7 @@ class TileROD_Encoder unsigned int m_rChUnit; int m_maxChannels; + int m_runPeriod; }; #endif diff --git a/TileCalorimeter/TileSvc/TileByteStream/src/TileDigitsContByteStreamTool.cxx b/TileCalorimeter/TileSvc/TileByteStream/src/TileDigitsContByteStreamTool.cxx index b4338560885265252374c177bdedfb4f6c8b04ac..63184382aaa0c757e37dc1a163ce0f2efe6ffeac 100644 --- a/TileCalorimeter/TileSvc/TileByteStream/src/TileDigitsContByteStreamTool.cxx +++ b/TileCalorimeter/TileSvc/TileByteStream/src/TileDigitsContByteStreamTool.cxx @@ -36,6 +36,7 @@ TileDigitsContByteStreamTool::TileDigitsContByteStreamTool( const std::string& t , m_tileHWID(0) , m_hid2re(0) , m_verbose(false) + , m_runPeriod(0) { declareInterface< TileDigitsContByteStreamTool >( this ); declareProperty("DoFragType1", m_doFragType1 = false); @@ -56,6 +57,8 @@ StatusCode TileDigitsContByteStreamTool::initialize() { ATH_CHECK( dec.retrieve() ); m_hid2re = dec->getHid2reHLT(); + TileCablingService *cabling = TileCablingService::getInstance(); + m_runPeriod = cabling->runPeriod(); return StatusCode::SUCCESS; } @@ -85,7 +88,7 @@ StatusCode TileDigitsContByteStreamTool::convert(DIGITS* digitsContainer, FullEv if (isTMDB){ reid = m_hid2re->getRodTileMuRcvID(frag_id); - mapEncoder[reid].setTileHWID(m_tileHWID); + mapEncoder[reid].setTileHWID(m_tileHWID,m_runPeriod); } else { reid = m_hid2re->getRodID(frag_id); mapEncoder[reid].setTileHWID(m_tileHWID, m_verbose, 1); diff --git a/TileCalorimeter/TileSvc/TileByteStream/src/TileMuRcvContByteStreamTool.cxx b/TileCalorimeter/TileSvc/TileByteStream/src/TileMuRcvContByteStreamTool.cxx index 7c17a17b6de0a0eeb17d60fd7a7f9b442dcf5e84..a81d7fb48185dcd6447e91e502d18c1696ce4227 100644 --- a/TileCalorimeter/TileSvc/TileByteStream/src/TileMuRcvContByteStreamTool.cxx +++ b/TileCalorimeter/TileSvc/TileByteStream/src/TileMuRcvContByteStreamTool.cxx @@ -47,7 +47,7 @@ TileMuRcvContByteStreamTool::TileMuRcvContByteStreamTool(const std::string& type : AthAlgTool(type, name, parent) , m_tileHWID(0) , m_hid2re(0) - //, m_verbose(false) + , m_runPeriod(0) { declareInterface<TileMuRcvContByteStreamTool>(this); } @@ -67,6 +67,8 @@ StatusCode TileMuRcvContByteStreamTool::initialize() { ATH_CHECK( dec.retrieve() ); m_hid2re = dec->getHid2reHLT(); + TileCablingService *cabling = TileCablingService::getInstance(); + m_runPeriod = cabling->runPeriod(); return StatusCode::SUCCESS; } @@ -98,7 +100,7 @@ StatusCode TileMuRcvContByteStreamTool::convert(TileMuonReceiverContainer* cont, n++; frag_id = (*it_cont)->identify(); reid = m_hid2re->getRodTileMuRcvID(frag_id); - mapEncoder[reid].setTileHWID(m_tileHWID); + mapEncoder[reid].setTileHWID(m_tileHWID,m_runPeriod); const TileMuonReceiverObj* tileMuRcv = *it_cont; mapEncoder[reid].addTileMuRcvObj(tileMuRcv); } diff --git a/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Decoder.cxx b/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Decoder.cxx index c327a68020480d7ad3dadb60ecc36d35d423cd3b..022f301511933147e857e5dd99d7cd149342fe2f 100644 --- a/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Decoder.cxx +++ b/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Decoder.cxx @@ -43,8 +43,12 @@ TileROD_Decoder::TileROD_Decoder(const std::string& type, const std::string& nam , m_hid2reHLT(nullptr) , m_maxChannels(TileCalibUtils::MAX_CHAN) , m_checkMaskedDrawers(false) -{ + , m_runPeriod(0){ + declareInterface<TileROD_Decoder>(this); + + m_WarningCounter = 0; + m_ErrorCounter = 0; for (std::atomic<const uint32_t*>& p : m_OFPtrs) { p = nullptr; @@ -130,7 +134,9 @@ StatusCode TileROD_Decoder::initialize() { ATH_CHECK( m_tileBadChanTool.retrieve() ); } - m_maxChannels = TileCablingService::getInstance()->getMaxChannels(); + const TileCablingService *cablingService = TileCablingService::getInstance(); + m_maxChannels = cablingService->getMaxChannels(); + m_runPeriod = cablingService->runPeriod(); m_Rw2Cell[0].reserve(m_maxChannels); m_Rw2Cell[1].reserve(m_maxChannels); @@ -4469,6 +4475,7 @@ void TileROD_Decoder::unpack_frag41( uint32_t collid, uint32_t version, const ui void TileROD_Decoder::unpack_frag42( uint32_t sourceid, uint32_t version, const uint32_t* p, int datasize, TileMuonReceiverContainer &v ) const { + // == RUN 2 == // results are hold in 3 16-bit words. // // 32nd bit -> | results2 || results1 | <- 1st bit @@ -4486,36 +4493,67 @@ void TileROD_Decoder::unpack_frag42( uint32_t sourceid, uint32_t version, const // bit-2 . // bit-1 . // bit-0 -> result.at(3) + // + // == RUN 3 == + // results are hold in 3 16-bit words. + // + // 32nd bit -> | results2 [16:31] || results1 [0:15] | <- 1st bit + // 32nd bit -> | 0x0 [16:31] || results3 [0:15] | <- 1st bit + // + // 32nd bit -> | 0x0 [12:15] | m-5 | m-4 | m-3 | m-2 || 0x0 [12:15] | m-3 | m-2 | m-1 | m-0 | <- 1st bit + // | 0x0 [16:31] || 0x0 [12:15] | m-7 | m-6 | m-5 | m-4 | + // + // For each module m-X there is a 3-bit word with the results for a threshold + // + // | d5+d6 | d6 | d5 | + // | bit2 | bit1 | bit0 | + // + + int nbit=0; + int nmod=0; + uint32_t word=0x0; - int nbit,nmod; - uint32_t word; int drawer = (sourceid & 0xf0000) >> 8; // get ROS number from source ID if (drawer<0x300) { // barrel nbit = 4; nmod = 4; drawer |= ((sourceid & 0x0000f) << 2); word = (datasize > 0) ? p[0] : 0; // just use first word, although expect all zeros for the moment - } else { + } else { // extended barrel nbit = 4; nmod = 8; drawer |= ((sourceid & 0x0000f) << 3); - word = (datasize > 1) ? (p[1] << 20) | ((p[0] >> 8) & 0xff000) | ((p[0] >> 4) & 0xfff) : 0; + if (m_runPeriod<=2) { + word = (datasize > 1) ? (p[1] << 20) | ((p[0] >> 8) & 0xff000) | ((p[0] >> 4) & 0xfff) : 0; + } else { + word = (datasize > 1) ? (p[1] << 12) | (p[0] & 0xfff) : 0; + } } std::vector<bool> result(nbit); for (int j = 0; j < nmod; ++j) { // loop over modules for (int k = nbit-1; k >= 0; --k) { // loop over bits of one module in inversed order - result[k] = ((word & 1) != 0); - word >>= 1; + if (m_runPeriod<=2) { + result[k] = (word & 1); + word >>= 1; + } else { + if (k==0) { + result[k]=0; + } else { + result[k] = (word & 1); + word >>= 1; + } + } } - TileMuonReceiverObj * obj = new TileMuonReceiverObj(drawer, result); v.push_back(obj); - ++drawer; } - + if (msgLvl(MSG::DEBUG)) { + if (m_runPeriod<=2) msg(MSG::DEBUG) << "TMDB version for RUN2 simulation (2014)" <<endmsg; + else msg(MSG::DEBUG) << "TMDB version for RUN3 simulation (2020)" <<endmsg; + msg(MSG::DEBUG) << " TileROD_Decoder::unpack_frag42 source ID: 0x" << MSG::hex << sourceid << MSG::dec << " version: " << version << endmsg; diff --git a/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Encoder.cxx b/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Encoder.cxx index 937d2dba637ed6fbe79d9432048c2660451fddf2..f46c6aa53b82372af5dad19ff9b86c3e6826f991 100644 --- a/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Encoder.cxx +++ b/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Encoder.cxx @@ -28,7 +28,8 @@ TileROD_Encoder::TileROD_Encoder(): m_type(0), m_unitType(0), m_rChUnit(0), - m_maxChannels(TileCalibUtils::MAX_CHAN) { + m_maxChannels(TileCalibUtils::MAX_CHAN), + m_runPeriod(0){ } @@ -56,8 +57,9 @@ void TileROD_Encoder::setTileHWID(const TileHWID* tileHWID, bool verbose, unsign } } -void TileROD_Encoder::setTileHWID(const TileHWID* tileHWID) { +void TileROD_Encoder::setTileHWID(const TileHWID* tileHWID, int runPeriod) { m_tileHWID = tileHWID; + m_runPeriod = runPeriod; } void TileROD_Encoder::setTypeAndUnit(TileFragHash::TYPE type, TileRawChannelUnit::UNIT unit) { @@ -764,23 +766,20 @@ void TileROD_Encoder::fillRODTileMuRcvObj(std::vector<uint32_t>& v) { // this is the subfragment type 0x42 - ATH_MSG_DEBUG( "TMDB encoding sub-fragment 0x42: loop over " << m_vTileMuRcvObj.size() << " objects" ); + ATH_MSG_INFO( "TMDB encoding sub-fragment 0x42: loop over " << m_vTileMuRcvObj.size() << " objects" ); // sub-fragment marker // v.push_back(0xff1234ff); - // sub-fragment size + // type & version // v.push_back(5); uint savepos = v.size()-1; - - // type & version - // uint32_t verfrag = 0x500; uint32_t type_version = (0x42 << 16) + verfrag; v.push_back(type_version); - + // counters and temporary words // int wc = 0; @@ -789,71 +788,141 @@ void TileROD_Encoder::fillRODTileMuRcvObj(std::vector<uint32_t>& v) { uint32_t result2 = 0x0; uint32_t result3 = 0x0; - for (const TileMuonReceiverObj* tmurcv : m_vTileMuRcvObj) { - - // results are hold in 3 16-bit words. - // - // 32nd bit -> | results2 || results1 | <- 1st bit - // | 0x0 || results3 | - // - // 32nd bit -> | m-5 | m-4 | m-3 | m-2 || m-2 | m-1 | m-0 | 0x0 | <- 1st bit - // | 0x0 || 0x0 | m-7 | m-6 | m-5 | - // - // each 4 bit word is - // - // 0 1 2 3 <-- in Obj - // | d56h | d56l | d6h | d6l | - // bit3 bit2 bit1 bit0 - // + switch (m_runPeriod) { + + case 2:// RUN2 - int modid = tmurcv->identify() & 0xff; - - const std::vector<bool> & slin = tmurcv->GetDecision(); - int imax = std::min((int)slin.size(),4); - uint32_t word4b = 0x0; - for (int i=0;i<imax;++i){ - // slin d56h d56l d6h d6l - // word4b bit3 bit2 bit1 bit0 - if (slin[i]) word4b |= 1 << (3-i); - } + msg(MSG::INFO) << "Going trough RUN2 encoding procedure for TMDB data" << endmsg; + + for (const TileMuonReceiverObj* tmurcv : m_vTileMuRcvObj) { + + // VERSION RUN2: results are hold in 3 16-bit words. Two 32 bit words. + // + // 32nd bit -> | results2 || results1 | <- 1st bit + // | 0x0 || results3 | + // + // 32nd bit -> | m-5 | m-4 | m-3 | m-2 || m-2 | m-1 | m-0 | 0x0 | <- 1st bit + // | 0x0 || 0x0 | m-7 | m-6 | m-5 | + // + // each 4 bit word is + // + // 0 1 2 3 <-- in Obj + // | d56h | d56l | d6h | d6l | + // bit3 bit2 bit1 bit0 + // + + int modid = tmurcv->identify() & 0xff; + + const std::vector<bool> & slin = tmurcv->GetDecision(); + int imax = std::min((int)slin.size(),4); + uint32_t word4b = 0x0; + for (int i=0;i<imax;++i){ + if (slin[i]) word4b |= 1 << (3-i); + } - if (msgLvl(MSG::DEBUG)) { - std::stringstream ss; - for (const auto & val : slin) { - ss<<std::setw(2)<<val; - } - msg(MSG::DEBUG) << "Result for module: "<<modid<<" in TMDB board "<<modid%8<<MSG::hex<<": 0x"<<word4b<<MSG::dec<<" from "<<ss.str() << endmsg; - } + if (msgLvl(MSG::INFO)) { + std::stringstream ss; + for (const auto & val : slin) { + ss<<std::setw(2)<<val; + } + msg(MSG::INFO) << "Result for module: "<<modid<<" in TMDB board "<<modid%8<<MSG::hex<<": 0x"<<word4b<<MSG::dec<<" from "<<ss.str() << endmsg; + } - switch (modid%8) { - case 0: result1 |= word4b << 4 ; break; - case 1: result1 |= word4b << 8 ; break; - case 2: result1 |= word4b << 12 ; result2 |= word4b; break; - case 3: result2 |= word4b << 4 ; break; - case 4: result2 |= word4b << 8 ; break; - case 5: result2 |= word4b << 12 ; result3 |= word4b; break; - case 6: result3 |= word4b << 4 ; break; - case 7: result3 |= word4b << 8 ; break; - } - ++chc; - } - - ATH_MSG_DEBUG( "Summary : "<<MSG::hex<<" Results 1: 0x"<<result1<<" Results 2: 0x"<<result2<<" Results 3: 0x"<<result3<< MSG::dec ); - - v.push_back( result1 | (result2 << 16) ); ++wc;// | 5 4 3 2 | 2 1 0 - | - v.push_back( result3 ); ++wc; // | - - - - | - 7 6 5 | '-' means free/not set/0x0 - v.at(savepos)=3+wc; + switch (modid%8) { + case 0: result1 |= word4b << 4 ; break; + case 1: result1 |= word4b << 8 ; break; + case 2: result1 |= word4b << 12 ; result2 |= word4b; break; + case 3: result2 |= word4b << 4 ; break; + case 4: result2 |= word4b << 8 ; break; + case 5: result2 |= word4b << 12 ; result3 |= word4b; break; + case 6: result3 |= word4b << 4 ; break; + case 7: result3 |= word4b << 8 ; break; + } + ++chc; + } + + ATH_MSG_INFO( "Summary : "<<MSG::hex<<" Results 1: 0x"<<result1<<" Results 2: 0x"<<result2<<" Results 3: 0x"<<result3<< MSG::dec ); + + v.push_back( result1 | (result2 << 16) ); ++wc;// | 5 4 3 2 | 2 1 0 - | + v.push_back( result3 ); ++wc; // | - - - - | - 7 6 5 | '-' means free/not set/0x0 + v.at(savepos)=3+wc; + + break; + + case 3:// RUN3 + + msg(MSG::INFO) << "Going trough RUN3 encoding procedure for TMDB data" << endmsg; + + for (const TileMuonReceiverObj* tmurcv : m_vTileMuRcvObj) { + // VERSION RUN3: results are hold in two 32-bit word to cover a TMDB board holding 8 TileCal modules. + // + // 32nd bit -> | results2 [16:31] || results1 [0:15] | <- 1st bit + // 32nd bit -> | 0x0 [16:31] || results3 [0:15] | <- 1st bit + // + // 32nd bit -> | 0x0 [12:15] | m-5 | m-4 | m-3 | m-2 || 0x0 [12:15] | m-3 | m-2 | m-1 | m-0 | <- 1st bit + // | 0x0 [16:31] || 0x0 [12:15] | m-7 | m-6 | m-5 | m-4 | + // + // For each module m-X there is a 3-bit word with the result for a threshold + // + // | d5+d6 | d6 | d5 | + // | bit2 | bit1 | bit0 | + // + + // counters and temporary words + // - ATH_MSG_DEBUG( "Check version and counters: "<<MSG::hex<< verfrag <<MSG::dec<<" "<< chc <<" "<< wc <<" save in position: "<< savepos ); - - if (msgLvl(MSG::VERBOSE)) { - msg(MSG::VERBOSE) << "Check content of ROD fragment after including sub-fragment (0x42)... " << v.size() << endmsg; - for (size_t i=0; i<v.size(); ++i) { - msg(MSG::VERBOSE) << i << "\t" << v.at(i) << MSG::hex << " 0x" << v.at(i) << MSG::dec << endmsg; - } - } - - return; +/* + * + * Comment on implementation... + * In Athena the container size is kept to 4. It is fully used for run2 but for run3 the first position is left empty. + * The most significative bit is placed in first position [0] of a container so the position reverse while encoding. + * + * */ + + int modid = tmurcv->identify() & 0xff; + const std::vector<bool> & slin = tmurcv->GetDecision(); + int imax = std::min((int)slin.size(),4); + uint32_t word3b = 0x0; + for (int i=1;i<imax;++i) { + // slin d56 d6 d5 + // word3b bit2 bit1 bit0 + // bit 4 is always 0 since iteration starts at 1 + if (slin[i]) word3b |= 1 << (3-i); + } + + switch (modid%8) { + case 0: result1 |= word3b ; break; + case 1: result1 |= word3b << 3 ; break; + case 2: result1 |= word3b << 6 ; result2 |= word3b ; break; + case 3: result1 |= word3b << 9 ; result2 |= word3b << 3 ; break; + case 4: result2 |= word3b << 6 ; result3 |= word3b ; break; + case 5: result2 |= word3b << 9 ; result3 |= word3b << 3 ; break; + case 6: result3 |= word3b << 6 ; break; + case 7: result3 |= word3b << 9 ; break; + } + ++chc; + } + + ATH_MSG_INFO( "Summary : "<<MSG::hex<<" Results 1: 0x"<<result1<<" Results 2: 0x"<<result2<<" Results 3: 0x"<<result3<< MSG::dec ); + + v.push_back( result1 | (result2 << 16) ); ++wc; + v.push_back( result3 ); ++wc; + v.at(savepos) = 3+wc; + + break; + + case 0://not defined + ATH_MSG_INFO("Tile Muon Decision Board (TMDB) fragment versions are only available for RUN2 and RUN3"); + break; + } + if (msgLvl(MSG::INFO)){ + msg(MSG::INFO) << "Check version and counters: "<<MSG::hex<<verfrag<<MSG::dec<<" "<<chc<<" "<<wc<<" save in position: "<<savepos<<endmsg; + msg(MSG::INFO) << "Check content of ROD fragment after including sub-fragment (0x42)... " << v.size() << endmsg; + for (size_t i=0; i<v.size(); ++i) { + msg(MSG::INFO) << i << "\t" << v.at(i) << MSG::hex << " 0x" << v.at(i) << MSG::dec << endmsg; + } + } + return; } // == END of TMDB Encoders