diff --git a/TileCalorimeter/TileSvc/TileByteStream/CMakeLists.txt b/TileCalorimeter/TileSvc/TileByteStream/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..51ce129f102e3cb17a503c5a5165da77036283c7 --- /dev/null +++ b/TileCalorimeter/TileSvc/TileByteStream/CMakeLists.txt @@ -0,0 +1,48 @@ +################################################################################ +# Package: TileByteStream +################################################################################ + +# Declare the package name: +atlas_subdir( TileByteStream ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthenaBaseComps + Control/AthenaKernel + Event/ByteStreamCnvSvcBase + Event/ByteStreamData + GaudiKernel + TileCalorimeter/TileEvent + TileCalorimeter/TileIdentifier + PRIVATE + Calorimeter/CaloDetDescr + Calorimeter/CaloIdentifier + Control/CLIDSvc + Control/SGTools + Control/StoreGate + Event/ByteStreamCnvSvc + TileCalorimeter/TileCalib/TileCalibBlobObjs + TileCalorimeter/TileConditions + TileCalorimeter/TileDetDescr + TileCalorimeter/TileL2Algs + TileCalorimeter/TileRecUtils ) + +# External dependencies: +find_package( tdaq-common ) + +# Component(s) in the package: +atlas_add_library( TileByteStreamLib + src/Tile*.cxx + PUBLIC_HEADERS TileByteStream + INCLUDE_DIRS ${TDAQ-COMMON_INCLUDE_DIRS} + LINK_LIBRARIES ${TDAQ-COMMON_LIBRARIES} AthenaBaseComps AthenaKernel ByteStreamData GaudiKernel TileEvent TileIdentifier ByteStreamCnvSvcBaseLib ByteStreamData_test CaloDetDescrLib StoreGateLib SGtests ByteStreamCnvSvcLib TileConditionsLib TileL2AlgsLib TileRecUtilsLib + PRIVATE_LINK_LIBRARIES CaloIdentifier SGTools TileCalibBlobObjs TileDetDescr ) + +atlas_add_component( TileByteStream + src/components/*.cxx + INCLUDE_DIRS ${TDAQ-COMMON_INCLUDE_DIRS} + LINK_LIBRARIES ${TDAQ-COMMON_LIBRARIES} AthenaBaseComps AthenaKernel ByteStreamCnvSvcBaseLib ByteStreamData ByteStreamData_test GaudiKernel TileEvent TileIdentifier CaloDetDescrLib CaloIdentifier SGTools StoreGateLib SGtests ByteStreamCnvSvcLib TileCalibBlobObjs TileConditionsLib TileDetDescr TileL2AlgsLib TileRecUtilsLib TileByteStreamLib ) + +# Install files from the package: +atlas_install_joboptions( share/*.py ) + diff --git a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileMuRcvContByteStreamTool.h b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileMuRcvContByteStreamTool.h index 96ae77313509fbf98fd9baf1362a40a203891703..f4686d3e5dec5e3a45d2eaf35c1b4d1cb55aa8ed 100755 --- a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileMuRcvContByteStreamTool.h +++ b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileMuRcvContByteStreamTool.h @@ -62,7 +62,7 @@ class TileMuRcvContByteStreamTool: public AthAlgTool { TileHid2RESrcID m_hid2re; - bool m_verbose; + //bool m_verbose; FullEventAssembler<TileHid2RESrcID> m_fea; }; diff --git a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Decoder.h b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Decoder.h index 8ba0337f93e71a536a342372140bbd28cf520aad..b999abf2d0fc3c4e8200bec623d42db26faa8961 100755 --- a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Decoder.h +++ b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Decoder.h @@ -167,7 +167,14 @@ class TileROD_Decoder: public AthAlgTool { m_list_of_masked_drawers.push_back(vec[i]); } + void setUseFrag0 (bool f) { m_useFrag0 = f; } + void setUseFrag1 (bool f) { m_useFrag1 = f; } + void setUseFrag4 (bool f) { m_useFrag4 = f; } + void setUseFrag5Raw (bool f) { m_useFrag5Raw = f; } + void setUseFrag5Reco (bool f) { m_useFrag5Reco = f; } + private: + friend class TileHid2RESrcID; typedef std::vector<TileCell *> pCellVec; typedef std::vector<TileDigits *> pDigiVec; diff --git a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileRawChannel2Bytes.h b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileRawChannel2Bytes.h index 2cbd0395315b9485b6a6500a6f2fa826ec125cfe..90a0d3dd18c06ddb577daeb12d3317f3c6a8badf 100755 --- a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileRawChannel2Bytes.h +++ b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileRawChannel2Bytes.h @@ -94,21 +94,21 @@ inline int TileRawChannel2Bytes::gain(short s) const { inline float TileRawChannel2Bytes::amplitude(short s) const { // s >>= AMPLITUDE_SHIFT; - float a = (s & AMPLITUDE_RANGE) / AMPLITUDE_FACTOR; + float a = (s & AMPLITUDE_RANGE) * (1./AMPLITUDE_FACTOR); if (s & AMPLITUDE_SIGN) a = -a; return a; } inline float TileRawChannel2Bytes::time(short s) const { // s >>= TIME_SHIFT; - float t = (s & TIME_RANGE) / TIME_FACTOR; + float t = (s & TIME_RANGE) * (1./TIME_FACTOR); if (s & TIME_SIGN) t = -t; return t; } inline float TileRawChannel2Bytes::quality(short s) const { // s >>= QUALITY_SHIFT; - float q = (s & QUALITY_RANGE) / QUALITY_FACTOR; + float q = (s & QUALITY_RANGE) * (1./QUALITY_FACTOR); if (s & QUALITY_SIGN) q = -q; return q; } diff --git a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileRawChannel2Bytes2.h b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileRawChannel2Bytes2.h index 21c49b0eec98aec743812349e06f89f52fafeeb3..8dfda514d1de5ce0f51aea5147d72fbd77df5a4c 100755 --- a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileRawChannel2Bytes2.h +++ b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileRawChannel2Bytes2.h @@ -96,18 +96,18 @@ inline int TileRawChannel2Bytes2::gain(unsigned int w) const { } inline float TileRawChannel2Bytes2::amplitude(unsigned int w) const { - float a = ((w >> AMPLITUDE_SHIFT2) & AMPLITUDE_RANGE2) / AMPLITUDE_FACTOR2 - AMPLITUDE_OFFSET2; + float a = ((w >> AMPLITUDE_SHIFT2) & AMPLITUDE_RANGE2) * (1. / AMPLITUDE_FACTOR2) - AMPLITUDE_OFFSET2; if (a < AMPLITUDE_MINVALUE) a += 2 * AMPLITUDE_OFFSET2; return a; } inline float TileRawChannel2Bytes2::time(unsigned int w) const { - float t = ((w >> TIME_SHIFT2) & TIME_RANGE2) / TIME_FACTOR2 - TIME_OFFSET2; + float t = ((w >> TIME_SHIFT2) & TIME_RANGE2) * (1./TIME_FACTOR2) - TIME_OFFSET2; return t; } inline float TileRawChannel2Bytes2::quality(unsigned int w) const { - float q = ((w >> QUALITY_SHIFT2) & QUALITY_RANGE2) / QUALITY_FACTOR2 - QUALITY_OFFSET2; + float q = ((w >> QUALITY_SHIFT2) & QUALITY_RANGE2) * (1./QUALITY_FACTOR2) - QUALITY_OFFSET2; return q; } diff --git a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileRawChannel2Bytes4.h b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileRawChannel2Bytes4.h index 884c81c42a1524bd8010629676218b8036b5a8e3..95596c7b7dfa1daee712004f6998fe1cf1549310 100755 --- a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileRawChannel2Bytes4.h +++ b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileRawChannel2Bytes4.h @@ -119,12 +119,12 @@ inline float TileRawChannel2Bytes4::amplitude(unsigned int w) const { } inline float TileRawChannel2Bytes4::time(unsigned int w) const { - float t = (((w >> TIME_SHIFT4) & TIME_RANGE4) - TIME_OFFSET4) / TIME_FACTOR4; + float t = (((w >> TIME_SHIFT4) & TIME_RANGE4) - TIME_OFFSET4) * (1./TIME_FACTOR4); return t; } inline float TileRawChannel2Bytes4::quality(unsigned int w) const { - float q = (((w >> QUALITY_SHIFT4) & QUALITY_RANGE4) - QUALITY_OFFSET4) / QUALITY_FACTOR4; + float q = (((w >> QUALITY_SHIFT4) & QUALITY_RANGE4) - QUALITY_OFFSET4) * (1./QUALITY_FACTOR4); return q; } diff --git a/TileCalorimeter/TileSvc/TileByteStream/src/TileCellCont.cxx b/TileCalorimeter/TileSvc/TileByteStream/src/TileCellCont.cxx index 8f515ab48fa3ee7e6fdffaa2b90f35eb6af89200..e1a61870e1923a4b5f66e9e9d87e7722e411ded7 100755 --- a/TileCalorimeter/TileSvc/TileByteStream/src/TileCellCont.cxx +++ b/TileCalorimeter/TileSvc/TileByteStream/src/TileCellCont.cxx @@ -25,8 +25,7 @@ typedef std::pair<int, int> int_pair; -bool sort_pred(const int_pair& left, const int_pair& right) -{ +bool sort_pred(const int_pair& left, const int_pair& right) { return left.second < right.second; } @@ -34,37 +33,35 @@ TileCellCont::TileCellCont() : m_it(0) , m_event(0) , m_MBTS(0) - , m_MBTS_channel(0) -{ + , m_MBTS_channel(0) { } -StatusCode -TileCellCont::initialize() { +StatusCode TileCellCont::initialize() { #ifndef NDEBUG std::cout << "TileCellCont\t\t DEBUG \t constructor" << std::endl; #endif - ISvcLocator* svcLoc = Gaudi::svcLocator( ); + ISvcLocator* svcLoc = Gaudi::svcLocator(); StoreGateSvc* detStore = 0; - if(svcLoc->service("DetectorStore", detStore).isFailure()){ + if (svcLoc->service("DetectorStore", detStore).isFailure()) { std::cout << "Could not locate DetectorStore" << std::endl; return StatusCode::FAILURE; } // Get the TileID helper from the detector store const TileID* tileID; - if( detStore->retrieve(tileID, "TileID").isFailure()){ + if (detStore->retrieve(tileID, "TileID").isFailure()) { std::cout << "Could not get TileID helper !" << std::endl; return StatusCode::FAILURE; - } + } // Get the TileHWID helper from the detector store const TileHWID* tileHWID; - if( detStore->retrieve(tileHWID, "TileHWID").isFailure()){ + if (detStore->retrieve(tileHWID, "TileHWID").isFailure()) { std::cout << "Could not get TileHWID helper !" << std::endl; return StatusCode::FAILURE; - } + } // Get pointer to TileDetDescrManager const TileDetDescrManager* tileMgr; @@ -80,15 +77,15 @@ TileCellCont::initialize() { mbtsMgr = 0; } - ToolHandle<ITileBadChanTool> m_masker("TileBadChanTool"); - if(m_masker.retrieve().isFailure()){ - std::cout << "TileCellCont:initialize ERROR: Can not retrieve TileBadChanTool" << std::endl; - return StatusCode::FAILURE; + ToolHandle<ITileBadChanTool> badChanTool("TileBadChanTool"); + if (badChanTool.retrieve().isFailure()) { + std::cout << "TileCellCont:initialize ERROR: Can not retrieve TileBadChanTool" << std::endl; + return StatusCode::FAILURE; } - if ( (m_masker->initialize()).isFailure() ) { - std::cout << "TileCellCont:initialize ERROR: Can not initialize TileBadChanTool" << std::endl; - return StatusCode::FAILURE; + if ((badChanTool->initialize()).isFailure()) { + std::cout << "TileCellCont:initialize ERROR: Can not initialize TileBadChanTool" << std::endl; + return StatusCode::FAILURE; } // Get pointer to TileCablingService @@ -97,99 +94,97 @@ TileCellCont::initialize() { m_hash.initialize(0); m_mbts_rods.clear(); m_mbts_IDs.clear(); - int mbts_count=0; - int ID_of_Col=0; - TileHid2RESrcID src( tileHWID ); - m_MBTS = new TileCellCollection(ID_of_Col,SG::OWN_ELEMENTS); - for(int section=1; section<=4; ++section){ - for(int drawer=0; drawer<64; ++drawer){ - int frag=tileHWID->frag(section,drawer); - m_mapMBTS[frag]=0xFFFF; + int mbts_count = 0; + int ID_of_Col = 0; + TileHid2RESrcID src(tileHWID); + m_MBTS = new TileCellCollection(ID_of_Col, SG::OWN_ELEMENTS); + for (int section = 1; section <= 4; ++section) { + for (int drawer = 0; drawer < 64; ++drawer) { + int frag = tileHWID->frag(section, drawer); + m_mapMBTS[frag] = 0xFFFF; // One event number per collection m_eventNumber.push_back(0xFFFFFFFF); - + // Tries to find the TileRawChannel -> TileCell correpondence - int index,pmt,cell_hash; - std::vector<int> Rw2Pmt; Rw2Pmt.resize(48,-1); - std::vector<int> Rw2Cell; Rw2Cell.resize(48,-1); + int index, pmt, cell_hash; + std::vector<int> Rw2Pmt; + Rw2Pmt.resize(48, -1); + std::vector<int> Rw2Cell; + Rw2Cell.resize(48, -1); std::vector<int_pair> tmp; - - bool one_good=false; - for(int channel=0; channel<48; ++channel){ - HWIdentifier channelID = tileHWID->channel_id(section,drawer,channel); - Identifier cell_id = cabling->h2s_cell_id_index(channelID,index,pmt); - if (index==-2) { // MBTS cell, only one per drawer + + bool one_good = false; + for (int channel = 0; channel < 48; ++channel) { + HWIdentifier channelID = tileHWID->channel_id(section, drawer, channel); + Identifier cell_id = cabling->h2s_cell_id_index(channelID, index, pmt); + if (index == -2) { // MBTS cell, only one per drawer m_mbts_rods.push_back(src.getRodID(frag)); - m_mbts_IDs.push_back(((section-1)*64+drawer)); + m_mbts_IDs.push_back(((section - 1) * 64 + drawer)); CaloDetDescrElement * caloDDE = (mbtsMgr) ? mbtsMgr->get_element(cell_id) : NULL; - TileCell* myMBTSCell = new TileCell(caloDDE,cell_id,0.0,0.0,0,0,CaloGain::TILEONELOW); + TileCell* myMBTSCell = new TileCell(caloDDE, cell_id, 0.0, 0.0, 0, 0, CaloGain::TILEONELOW); m_MBTS->push_back(myMBTSCell); - m_mapMBTS[frag]=mbts_count; + m_mapMBTS[frag] = mbts_count; mbts_count++; - m_MBTS_channel=channel; + m_MBTS_channel = channel; } else if (index >= 0) { // normal cell - one_good = one_good || (!m_masker->getChannelStatus(channelID).isBad()); - Rw2Pmt[channel]=pmt; + one_good = one_good || (!badChanTool->getChannelStatus(channelID).isBad()); + Rw2Pmt[channel] = pmt; if (channel > 0 || section != 2) { // ignoring D0 (first channel) in negative barrel cell_hash = tileID->cell_hash(cell_id); - tmp.push_back(int_pair(channel,cell_hash)); + tmp.push_back(int_pair(channel, cell_hash)); } } } // End of for over TileRawChannel // create new cell collection which will own all elements - TileCellCollection* newColl = new TileCellCollection(frag,SG::OWN_ELEMENTS); + TileCellCollection* newColl = new TileCellCollection(frag, SG::OWN_ELEMENTS); this->push_back(newColl); - if ( !one_good ) m_masked.push_back(frag); + if (!one_good) m_masked.push_back(frag); // sort index according to cell hash and put it in Rw2Cell vector // create TileCells in appropriate order and put them in newColl if (tmp.size() > 0) { std::sort(tmp.begin(), tmp.end(), sort_pred); // sort according to cell hash index - index=-1; cell_hash=-1; - for(unsigned int i=0; i<tmp.size(); ++i) { + index = -1; + cell_hash = -1; + for (unsigned int i = 0; i < tmp.size(); ++i) { if (cell_hash != tmp[i].second) { cell_hash = tmp[i].second; ++index; - CaloDetDescrElement * caloDDE = tileMgr->get_cell_element((IdentifierHash)cell_hash); - TileCell * pCell = new TileCell(caloDDE,0.0,0.0,0,0,CaloGain::TILELOWLOW); + CaloDetDescrElement * caloDDE = tileMgr->get_cell_element((IdentifierHash) cell_hash); + TileCell * pCell = new TileCell(caloDDE, 0.0, 0.0, 0, 0, CaloGain::TILELOWLOW); newColl->push_back(pCell); } - Rw2Cell[tmp[i].first]=index; + Rw2Cell[tmp[i].first] = index; } } - if (drawer == 0 || section==3 || section==4 ){ + if (drawer == 0 || section == 3 || section == 4) { #ifndef NDEBUG - int idxraw = 0; - for(std::vector<int>::iterator i=Rw2Cell.begin(); i!=Rw2Cell.end(); ++i){ - if ( (*i) != -1 ) - std::cout << "Channel : " << idxraw++ << - " connected to cell " << (*i) << std::endl; - } + int idxraw = 0; + for (std::vector<int>::iterator i = Rw2Cell.begin(); i != Rw2Cell.end(); ++i) { + if ((*i) != -1) std::cout << "Channel : " << idxraw++ << " connected to cell " << (*i) << std::endl; + } #endif - // One needs to keep track of Rw2Cell - for(std::vector<int>::iterator i=Rw2Cell.begin();i!=Rw2Cell.end();++i) - m_Rw2Cell[section-1].push_back(*i); - for(std::vector<int>::iterator i=Rw2Pmt.begin();i!=Rw2Pmt.end();++i) - m_Rw2Pmt[section-1].push_back(*i); + // One needs to keep track of Rw2Cell + for (std::vector<int>::iterator i = Rw2Cell.begin(); i != Rw2Cell.end(); ++i) + m_Rw2Cell[section - 1].push_back(*i); + for (std::vector<int>::iterator i = Rw2Pmt.begin(); i != Rw2Pmt.end(); ++i) + m_Rw2Pmt[section - 1].push_back(*i); } // End of if first drawer of Barrel or Ext } // end of drawer for } // end of section for #ifndef NDEBUG std::cout << "Number of RODs is : " << m_mbts_rods.size() << std::endl; - for(unsigned int k=0;k<m_mbts_rods.size();k++) - std::cout << " MBTS RODs : " << m_mbts_rods[k] << std::endl; + for (unsigned int k = 0; k < m_mbts_rods.size(); k++) + std::cout << " MBTS RODs : " << m_mbts_rods[k] << std::endl; #endif - #ifndef NDEBUG - for(int i=0; i<m_hash.max(); ++i){ - std::cout << "TileCellCont\t\t DEBUG \t" - << i << " " << std::hex << m_hash.identifier(i) << std::dec - << std::endl; - // A collection per ROD/ROB/HashId + for (int i = 0; i < m_hash.max(); ++i) { + std::cout << "TileCellCont\t\t DEBUG \t" << i << " " << std::hex << m_hash.identifier(i) << std::dec << std::endl; + // A collection per ROD/ROB/HashId } // end of for id #endif m_it = new std::vector<TileCellCollection*>::const_iterator(); @@ -199,39 +194,39 @@ TileCellCont::initialize() { // This WILL NOT trigger BSCNV. This assumes BSCNV was done before const std::vector<TileCellCollection*>::const_iterator& -TileCellCont::find(const unsigned int& rodid) const{ - *m_it = (std::vector<TileCellCollection*>::const_iterator)((*this).begin()+rodid); +TileCellCont::find(const unsigned int& rodid) const { + *m_it = (std::vector<TileCellCollection*>::const_iterator) ((*this).begin() + rodid); return *m_it; } -StatusCode -TileCellCont::finalize(){ - - // delete the pointer to collection - delete m_it; - - // Delete m_RwCells - for(int i=0;i<4;i++) m_Rw2Cell[i].clear(); - for(int i=0;i<4;i++) m_Rw2Pmt[i].clear(); - - // Delete Collections and cells - for(unsigned int i=0; i<this->size(); i++){ - // Delete collections. Own cells -> also destroyed - delete ((TileCellCollection*)((*this)[i])); - } - // Destroy also MBTS collection - delete m_MBTS; - m_mapMBTS.clear(); - m_mbts_rods.clear(); - m_mbts_IDs.clear(); - m_masked.clear(); - this->clear(); - return StatusCode::SUCCESS; +StatusCode TileCellCont::finalize() { + + // delete the pointer to collection + delete m_it; + + // Delete m_RwCells + for (int i = 0; i < 4; i++) + m_Rw2Cell[i].clear(); + for (int i = 0; i < 4; i++) + m_Rw2Pmt[i].clear(); + + // Delete Collections and cells + for (unsigned int i = 0; i < this->size(); i++) { + // Delete collections. Own cells -> also destroyed + delete ((TileCellCollection*) ((*this)[i])); + } + // Destroy also MBTS collection + delete m_MBTS; + m_mapMBTS.clear(); + m_mbts_rods.clear(); + m_mbts_IDs.clear(); + m_masked.clear(); + this->clear(); + return StatusCode::SUCCESS; } -unsigned int -TileCellCont::find_rod(const unsigned int& rodid) const{ +unsigned int TileCellCont::find_rod(const unsigned int& rodid) const { unsigned int rodidx = m_hash.identifier(rodid); return rodidx; } diff --git a/TileCalorimeter/TileSvc/TileByteStream/src/TileHid2RESrcID.cxx b/TileCalorimeter/TileSvc/TileByteStream/src/TileHid2RESrcID.cxx index 96dc05f3228a84953fe403626b8e30b563aa2df3..65d12c8735bc8bffdc4593c04baa925ea67524b1 100755 --- a/TileCalorimeter/TileSvc/TileByteStream/src/TileHid2RESrcID.cxx +++ b/TileCalorimeter/TileSvc/TileByteStream/src/TileHid2RESrcID.cxx @@ -5,14 +5,9 @@ #include <iostream> #include <cassert> -#define protected public -#define private public #include "TileByteStream/TileROD_Decoder.h" #include "TileRecUtils/TileRawChannelBuilder.h" #include "TileRecUtils/TileCellBuilder.h" -#undef protected -#undef private - #include "TileByteStream/TileHid2RESrcID.h" #include "TileIdentifier/TileHWID.h" #include "TileIdentifier/TileTBFrag.h" @@ -305,9 +300,9 @@ void TileHid2RESrcID::setROD2ROBmap (const eformat::FullEventFragment<const uint int unit = flags5 >> 14; if (nDataFrag[0]+nDataFrag[1]==0) { - rodDecoder->m_useFrag0 = false; - rodDecoder->m_useFrag1 = false; - rodDecoder->m_useFrag5Raw = true; + rodDecoder->setUseFrag0 (false); + rodDecoder->setUseFrag1 (false); + rodDecoder->setUseFrag5Raw (true); log << MSG::INFO << "Setting TileROD_Decoder->useFrag5Raw to true, unit is " << unit << endreq; std::vector<int>::const_iterator itr=fragIDs.begin(); std::vector<int>::const_iterator end=fragIDs.end(); @@ -319,8 +314,8 @@ void TileHid2RESrcID::setROD2ROBmap (const eformat::FullEventFragment<const uint } if (nDataFrag[2]+nDataFrag[3]+nDataFrag[4]==0) { - rodDecoder->m_useFrag4 = false; - rodDecoder->m_useFrag5Reco = true; + rodDecoder->setUseFrag4 (false); + rodDecoder->setUseFrag5Reco (true); log << MSG::INFO << "Setting TileROD_Decoder->useFrag5Reco to true, unit is " << unit << endreq; } if (toolSvc->releaseTool(rodDecoder).isFailure()) @@ -359,10 +354,15 @@ void TileHid2RESrcID::setROD2ROBmap (const eformat::FullEventFragment<const uint return; } + const Property& rawChannelCnt_prop = cellBuilder->getProperty ("TileRawChannelContainer"); + const Property& dspRawChannelContainer_prop = cellBuilder->getProperty ("TileDSPRawChannelContainer"); + const PropertyWithValue<bool>& mergeChannels_prop = + dynamic_cast<const PropertyWithValue<bool>&> (cellBuilder->getProperty ("mergeChannels")); + // Get any RawChannel Builder if (debug) log << MSG::DEBUG << " looking for TileRawChannelBuilder tool which provides container with name " - << cellBuilder->m_rawChannelContainer << endreq; + << rawChannelCnt_prop.toString() << endreq; TileRawChannelBuilder* channelBuilder=0; std::string toolType[6] = { "TileRawChannelBuilderOpt2Filter", "TileRawChannelBuilderOptFilter", "TileRawChannelBuilderFitFilter", "TileRawChannelBuilderFitFilterCool", @@ -379,8 +379,8 @@ void TileHid2RESrcID::setROD2ROBmap (const eformat::FullEventFragment<const uint log << MSG::DEBUG << " full name " << toolName[j] << " - using " << name << endreq; if (toolSvc->retrieveTool(name,channelBuilder).isSuccess()) { if (debug) - log << MSG::DEBUG << " it provides " << channelBuilder->m_TileRawChannelContainerID << endreq; - if (cellBuilder->m_rawChannelContainer == channelBuilder->m_TileRawChannelContainerID) { + log << MSG::DEBUG << " it provides " << channelBuilder->getTileRawChannelContainerID() << endreq; + if (rawChannelCnt_prop.toString() == channelBuilder->getTileRawChannelContainerID()) { break; } else { if (toolSvc->releaseTool(channelBuilder).isFailure()) @@ -394,14 +394,17 @@ void TileHid2RESrcID::setROD2ROBmap (const eformat::FullEventFragment<const uint } if (do_merge) { // frag1 in the data - should merge offline and dsp reco - if (cellBuilder->m_rawChannelContainer != cellBuilder->m_dspRawChannelContainer && - !cellBuilder->m_mergeChannels) { + if (rawChannelCnt_prop.toString() != dspRawChannelContainer_prop.toString() && + !mergeChannels_prop.value()) { if (nDataFrag[1] > 0) log << MSG::INFO << "TileHid2RESrcID: only frag1 digi found, changing properties for TileCellBuilder"; else log << MSG::INFO << "TileHid2RESrcID: no TileCal digits found, but still changing properties for TileCellBuilder"; log << " mergeChannels=True" << endreq; - cellBuilder->m_mergeChannels=true; + sc=cellBuilder->setProperty ("mergeChannels", true); + if (sc.isFailure()) { + log << MSG::ERROR << "Failed to set mergeChannels property in TileCellBuilder" << endreq; + } if (channelBuilder && cellBuilder->m_noiseFilterTools.size() != channelBuilder->m_noiseFilterTools.size()) { log << MSG::INFO << " and number of NoiseFilterTools from " << cellBuilder->m_noiseFilterTools.size() << " to " << channelBuilder->m_noiseFilterTools.size() @@ -419,11 +422,14 @@ void TileHid2RESrcID::setROD2ROBmap (const eformat::FullEventFragment<const uint } } else { // neither frag0 nor frag1 in the data // make sure that we read raw channels from BS, because offline reco will not work without digits anyhow - if (cellBuilder->m_rawChannelContainer != cellBuilder->m_dspRawChannelContainer) { + if (rawChannelCnt_prop.toString() != dspRawChannelContainer_prop.toString()) { log << MSG::INFO << "TileHid2RESrcID: no digi frags found, changing properties for TileCellBuilder"; - log << " TileRawChannelContainer='" << cellBuilder->m_dspRawChannelContainer - << "' instead of '" << cellBuilder->m_rawChannelContainer << "'"; - cellBuilder->m_rawChannelContainer = cellBuilder->m_dspRawChannelContainer; + log << " TileRawChannelContainer='" << dspRawChannelContainer_prop.toString() + << "' instead of '" << rawChannelCnt_prop.toString() << "'"; + sc=cellBuilder->setProperty ("TileRawChannelContainer",dspRawChannelContainer_prop.toString()); + if (sc.isFailure()) { + log << MSG::ERROR << "Failed to set TileRawChannelContainer property in TileCellBuilder" << endreq; + } flags = (flags>>8) & 0x3; // this is number of iterations if (flags == 0) { // no iterations - assume best phase was used, just need amplitude correction log << " and correctAmplitude=True"; diff --git a/TileCalorimeter/TileSvc/TileByteStream/src/TileMuRcvContByteStreamTool.cxx b/TileCalorimeter/TileSvc/TileByteStream/src/TileMuRcvContByteStreamTool.cxx index 781987aefa92b0381bafc59049f7f97b8bd1f5f2..272994dbac8c94952965a3c2948b0e53155e4ba3 100755 --- a/TileCalorimeter/TileSvc/TileByteStream/src/TileMuRcvContByteStreamTool.cxx +++ b/TileCalorimeter/TileSvc/TileByteStream/src/TileMuRcvContByteStreamTool.cxx @@ -44,8 +44,9 @@ const InterfaceID& TileMuRcvContByteStreamTool::interfaceID() { TileMuRcvContByteStreamTool::TileMuRcvContByteStreamTool(const std::string& type, const std::string& name, const IInterface* parent) - : AthAlgTool(type, name, parent), - m_verbose(false) + : AthAlgTool(type, name, parent) + , m_tileHWID(0) + //, m_verbose(false) { declareInterface<TileMuRcvContByteStreamTool>(this); } @@ -96,8 +97,8 @@ StatusCode TileMuRcvContByteStreamTool::convert(TileMuonReceiverContainer* cont, frag_id = (*it_cont)->identify(); reid = m_hid2re.getRodTileMuRcvID(frag_id); mapEncoder[reid].setTileHWID(m_tileHWID); - const TileMuonReceiverObj* m_tileMuRcv = *it_cont; - mapEncoder[reid].addTileMuRcvObj(m_tileMuRcv); + const TileMuonReceiverObj* tileMuRcv = *it_cont; + mapEncoder[reid].addTileMuRcvObj(tileMuRcv); } ATH_MSG_DEBUG( " Number of TileMuonReceiverObj objects counted " << n << " out of the possible " << cont->size()-1 ); diff --git a/TileCalorimeter/TileSvc/TileByteStream/src/TileOFC.cxx b/TileCalorimeter/TileSvc/TileByteStream/src/TileOFC.cxx index 5dd232af93d6061996e1d715778c11cd8bac33ce..219e60c20d6ffd237e88fbeceafa44660d5d0da4 100644 --- a/TileCalorimeter/TileSvc/TileByteStream/src/TileOFC.cxx +++ b/TileCalorimeter/TileSvc/TileByteStream/src/TileOFC.cxx @@ -24,7 +24,7 @@ void Double2Int_calib( double calib, unsigned int &scale, unsigned int &offset, // Get Scale scale = 0; double max = fabs(calib); - if (max!=0) scale = (unsigned int) truncf(log((pow(2.,NumberBits)-1.)/max)/log(2.)); + if (max!=0) scale = (unsigned int) truncf(log((pow(2.,NumberBits)-1.)/max)*(1./log(2.))); // Convert to integer offset = (unsigned int) roundf(calib*pow(2.,(int)scale)); @@ -56,7 +56,7 @@ void Double2Int_ofc( int w_off_size, vector<double> w_off, vector<int> &w_dsp, i // Get Scale at Maximum scale = 0; - if (max!=0) scale = (int) truncf(log((pow(2.,NumberBits)-1.)/max)/log(2.)); + if (max!=0) scale = (int) truncf(log((pow(2.,NumberBits)-1.)/max)*(1./log(2.))); // Convert to Integer the weights and the sum for (int i=0; i<w_off_size; i++) w_dsp.push_back( (int) roundf(w_off[i]*pow(2.,scale)) ); @@ -95,7 +95,7 @@ bool ConvertOFC( vector<vector<vector<vector<double> > > > w_off, vector<vector< float dsp_step = 1. ; float dsp_min_phase = -100.; float dsp_max_phase = -dsp_min_phase; - int dsp_phases = (int) roundf( (dsp_max_phase - dsp_min_phase)/dsp_step +1. ); + int dsp_phases = (int) roundf( (dsp_max_phase - dsp_min_phase)*(1./dsp_step) +1. ); if (1) { @@ -107,10 +107,10 @@ bool ConvertOFC( vector<vector<vector<vector<double> > > > w_off, vector<vector< } // Number of phases and step of the offline Opt. filte constants - float off_step = 0.1; + const float off_step = 0.1; float off_min_phase = -100.; float off_max_phase = -off_min_phase; - int off_phases = (int) roundf( (off_max_phase - off_min_phase)/off_step + 1. ); + int off_phases = (int) roundf( (off_max_phase - off_min_phase)*(1./off_step) + 1. ); if (verbose) { cout<<"----- OFFLINE -----"<<endl; @@ -200,10 +200,11 @@ bool ConvertOFC( vector<vector<vector<vector<double> > > > w_off, vector<vector< float current_phase; // bln + const float inv_off_step = 1. / off_step; for (int i=0; i<dsp_phases; i++){ current_phase = dsp_min_phase + i*dsp_step; - index = (int) roundf((current_phase - off_min_phase)/off_step); + index = (int) roundf((current_phase - off_min_phase)*inv_off_step); if (verbose) cout<<"["<<index<<"]: Phase "<<current_phase<<" ns"<<endl; for (int is=0; is<nsamples; is++) { diff --git a/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Decoder.cxx b/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Decoder.cxx index d65a4717c3f67bde7097c1693ff12ca523ac57e7..c99ebd63abc37128af2f2d78cbe99d78d70260b6 100755 --- a/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Decoder.cxx +++ b/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Decoder.cxx @@ -2,12 +2,7 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -// small hack to enable datapool usage -#define private public -#define protected public #include "TileEvent/TileCell.h" -#undef private -#undef protected #include <algorithm> #include <iomanip> @@ -103,8 +98,8 @@ TileROD_Decoder::TileROD_Decoder(const std::string& type, const std::string& nam void TileROD_Decoder::updateAmpThreshold(float ampMinThresh) { m_ampMinThresh = ampMinThresh; - m_ampMinThresh_pC = m_ampMinThresh * 12.5 / 1023.; - m_ampMinThresh_MeV = m_ampMinThresh * 12.5 / 1023. / 1.05 * 1000.; + m_ampMinThresh_pC = m_ampMinThresh * (12.5 / 1023.); + m_ampMinThresh_MeV = m_ampMinThresh * (12.5 / 1023. / 1.05 * 1000.); } /** destructor @@ -1859,9 +1854,9 @@ void TileROD_Decoder::unpack_frag16(uint32_t version, const uint32_t* p, rmsPed_diode1 = *pData & 0xFFFF; meanPed_diode1 = (*pData >> 16) & 0xFFFF; - MeanPed_diode1 = static_cast<double>(meanPed_diode1) / 10; + MeanPed_diode1 = static_cast<double>(meanPed_diode1) * 0.1; - RmsPed_diode1 = static_cast<double>(rmsPed_diode1) / 100; + RmsPed_diode1 = static_cast<double>(rmsPed_diode1) * 0.01; ++pData; @@ -1874,9 +1869,9 @@ void TileROD_Decoder::unpack_frag16(uint32_t version, const uint32_t* p, rmsPed_diode2 = *pData & 0xFFFF; meanPed_diode2 = (*pData >> 16) & 0xFFFF; - MeanPed_diode2 = static_cast<double>(meanPed_diode2) / 10; + MeanPed_diode2 = static_cast<double>(meanPed_diode2) * 0.1; - RmsPed_diode2 = static_cast<double>(rmsPed_diode2) / 100; + RmsPed_diode2 = static_cast<double>(rmsPed_diode2) * 0.01; ++pData; @@ -1889,9 +1884,9 @@ void TileROD_Decoder::unpack_frag16(uint32_t version, const uint32_t* p, rmsPed_diode3 = *pData & 0xFFFF; meanPed_diode3 = (*pData >> 16) & 0xFFFF; - MeanPed_diode3 = static_cast<double>(meanPed_diode3) / 10; + MeanPed_diode3 = static_cast<double>(meanPed_diode3) * 0.1; - RmsPed_diode3 = static_cast<double>(rmsPed_diode3) / 100; + RmsPed_diode3 = static_cast<double>(rmsPed_diode3) * 0.01; ++pData; @@ -1904,9 +1899,9 @@ void TileROD_Decoder::unpack_frag16(uint32_t version, const uint32_t* p, rmsPed_diode4 = *pData & 0xFFFF; meanPed_diode4 = (*pData >> 16) & 0xFFFF; - MeanPed_diode4 = static_cast<double>(meanPed_diode4) / 10; + MeanPed_diode4 = static_cast<double>(meanPed_diode4) * 0.1; - RmsPed_diode4 = static_cast<double>(rmsPed_diode4) / 100; + RmsPed_diode4 = static_cast<double>(rmsPed_diode4) * 0.01; ++pData; @@ -1919,9 +1914,9 @@ void TileROD_Decoder::unpack_frag16(uint32_t version, const uint32_t* p, rmsPed_pmt1 = *pData & 0xFFFF; meanPed_pmt1 = (*pData >> 16) & 0xFFFF; - MeanPed_pmt1 = static_cast<double>(meanPed_pmt1) / 10; + MeanPed_pmt1 = static_cast<double>(meanPed_pmt1) * 0.1; - RmsPed_pmt1 = static_cast<double>(rmsPed_pmt1) / 100; + RmsPed_pmt1 = static_cast<double>(rmsPed_pmt1) * 0.01; ++pData; @@ -1934,9 +1929,9 @@ void TileROD_Decoder::unpack_frag16(uint32_t version, const uint32_t* p, rmsPed_pmt2 = *pData & 0xFFFF; meanPed_pmt2 = (*pData >> 16) & 0xFFFF; - MeanPed_pmt2 = static_cast<double>(meanPed_pmt2) / 10; + MeanPed_pmt2 = static_cast<double>(meanPed_pmt2) * 0.1; - RmsPed_pmt2 = static_cast<double>(rmsPed_pmt2) / 100; + RmsPed_pmt2 = static_cast<double>(rmsPed_pmt2) * 0.01; ++pData; @@ -1956,9 +1951,9 @@ void TileROD_Decoder::unpack_frag16(uint32_t version, const uint32_t* p, rmsAlpha_diode1 = *pData & 0xFFFF; meanAlpha_diode1 = (*pData >> 16) & 0xFFFF; - MeanAlpha_diode1 = static_cast<double>(meanAlpha_diode1) / 10; + MeanAlpha_diode1 = static_cast<double>(meanAlpha_diode1) * 0.1; - RmsAlpha_diode1 = static_cast<double>(rmsAlpha_diode1) / 100; + RmsAlpha_diode1 = static_cast<double>(rmsAlpha_diode1) * 0.01; ++pData; @@ -1971,9 +1966,9 @@ void TileROD_Decoder::unpack_frag16(uint32_t version, const uint32_t* p, rmsAlpha_diode2 = *pData & 0xFFFF; meanAlpha_diode2 = (*pData >> 16) & 0xFFFF; - MeanAlpha_diode2 = static_cast<float>(meanAlpha_diode2) / 10; + MeanAlpha_diode2 = static_cast<float>(meanAlpha_diode2) * 0.1; - RmsAlpha_diode2 = static_cast<float>(rmsAlpha_diode2) / 100; + RmsAlpha_diode2 = static_cast<float>(rmsAlpha_diode2) * 0.01; ++pData; @@ -1988,9 +1983,9 @@ void TileROD_Decoder::unpack_frag16(uint32_t version, const uint32_t* p, rmsAlpha_diode3 = *pData & 0xFFFF; meanAlpha_diode3 = (*pData >> 16) & 0xFFFF; - MeanAlpha_diode3 = static_cast<double>(meanAlpha_diode3) / 10; + MeanAlpha_diode3 = static_cast<double>(meanAlpha_diode3) * 0.1; - RmsAlpha_diode3 = static_cast<double>(rmsAlpha_diode3) / 100; + RmsAlpha_diode3 = static_cast<double>(rmsAlpha_diode3) * 0.01; ++pData; @@ -2003,9 +1998,9 @@ void TileROD_Decoder::unpack_frag16(uint32_t version, const uint32_t* p, rmsAlpha_diode4 = *pData & 0xFFFF; meanAlpha_diode4 = (*pData >> 16) & 0xFFFF; - MeanAlpha_diode4 = static_cast<double>(meanAlpha_diode4) / 10; + MeanAlpha_diode4 = static_cast<double>(meanAlpha_diode4) * 0.1; - RmsAlpha_diode4 = static_cast<double>(rmsAlpha_diode4) / 100; + RmsAlpha_diode4 = static_cast<double>(rmsAlpha_diode4) * 0.01; ++pData; @@ -2091,7 +2086,7 @@ void TileROD_Decoder::unpack_frag16(uint32_t version, const uint32_t* p, diodeTemp = *pData & 0xFFF; seconds1 = (*pData >> 12) & 0xFFFFF; - DiodeTemp = static_cast<double>(diodeTemp) / 10; + DiodeTemp = static_cast<double>(diodeTemp) * 0.1; ++pData; @@ -2103,7 +2098,7 @@ void TileROD_Decoder::unpack_frag16(uint32_t version, const uint32_t* p, boxTemp = *pData & 0xFFF; seconds2 = (*pData >> 12) & 0xFFFFF; - BoxTemp = static_cast<double>(boxTemp) / 10; + BoxTemp = static_cast<double>(boxTemp) * 0.1; ++pData; @@ -2115,7 +2110,7 @@ void TileROD_Decoder::unpack_frag16(uint32_t version, const uint32_t* p, hum = *pData & 0xFFF; seconds3 = (*pData >> 12) & 0xFFFFF; - Hum = static_cast<double>(hum) / 10; + Hum = static_cast<double>(hum) * 0.1; ++pData; @@ -2127,7 +2122,7 @@ void TileROD_Decoder::unpack_frag16(uint32_t version, const uint32_t* p, gasFlow = *pData & 0xFFF; seconds4 = (*pData >> 12) & 0xFFFFF; - GasFlow = static_cast<double>(gasFlow) / 10; + GasFlow = static_cast<double>(gasFlow) * 0.1; ++pData; @@ -2228,7 +2223,7 @@ void TileROD_Decoder::unpack_frag17(uint32_t /* version */, const uint32_t* p, ++word; } // TDC word immediately after ADC words - // aa aa bb bb aaaa = TDC N°1 bbbb = TDC N°0 + // aa aa bb bb aaaa = TDC N1 bbbb = TDC N0 int TDC0 = (*word) & 0xFFFF; int TDC1 = (*word) >> 16; @@ -2768,12 +2763,12 @@ void TileROD_Decoder::fillCollectionL2(const ROBData * rob, TileL2Container & v) void TileROD_Decoder::fillCollectionL2ROS(const ROBData * rob, TileL2Container & v) { uint32_t size = data_size(rob); const uint32_t * p = get_data(rob); - const uint32_t m_ROB_to_decode = ((*p) & 0xFFFF); // Multiply by two - const uint32_t m_virtualROBJump = ((*p) >> 16) >> 2; // Divide by four (four drawer-1ROB) - if (size < m_ROB_to_decode * m_virtualROBJump + 1) { + const uint32_t ROB_to_decode = ((*p) & 0xFFFF); // Multiply by two + const uint32_t virtualROBJump = ((*p) >> 16) >> 2; // Divide by four (four drawer-1ROB) + if (size < ROB_to_decode * virtualROBJump + 1) { ATH_MSG_ERROR( "Declared size =" << size - << "; m_virtualROBJump=" << m_virtualROBJump - << "; m_ROB_to_decode=" << m_ROB_to_decode ); + << "; virtualROBJump=" << virtualROBJump + << "; ROB_to_decode=" << ROB_to_decode ); return; } p++; // Jump first word @@ -2782,8 +2777,8 @@ void TileROD_Decoder::fillCollectionL2ROS(const ROBData * rob, TileL2Container & uint32_t idAndType; int frag, hash, unit; - for (size_t irob = 0; irob < m_ROB_to_decode; ++irob) { - for (size_t drawInRob = 0; drawInRob < m_virtualROBJump; ++drawInRob) { + for (size_t irob = 0; irob < ROB_to_decode; ++irob) { + for (size_t drawInRob = 0; drawInRob < virtualROBJump; ++drawInRob) { idAndType = *(p++); frag = idAndType & 0xFFF; @@ -3235,7 +3230,7 @@ void TileROD_Decoder::make_copyHLT(pFRwChVec & pChannel, TileCellCollection & v, pCell->addEnergy(0., 1-m_Rw2Pmt[sec][5], 1); } - if (m_MBTS != NULL) { + if (m_MBTS != NULL && MBTS_chan >= 0) { unsigned int idx = m_mapMBTS[frag_id]; if (idx < (*m_MBTS).size()) { // MBTS present (always last channel) TileCell* pCell = (*m_MBTS)[idx]; @@ -3919,10 +3914,10 @@ StatusCode TileROD_Decoder::convertTMDBDecision(const RawEvent* re, TileMuonRece //eformat::helper::SourceIdentifier id = eformat::helper::SourceIdentifier(robFrag.source_id()); uint32_t sourceid = robFrag.source_id(); - uint32_t modid = sourceid>>16; + uint32_t modid = sourceid >> 16; //msg(MSG::VERBOSE) <<MSG::hex<<" sourceId: 0x"<< robFrag.source_id() <<MSG::dec<< endmsg; - if ( (modid==0x51 || modid==0x52 || modid==0x53 || modid==0x54) && sourceid&0xf00 ) { + if ((modid == 0x51 || modid == 0x52 || modid == 0x53 || modid == 0x54) && (sourceid & 0xf00)) { fillContainer_TileMuRcv_Decision(&robFrag, *tileMuRcv); } } @@ -3951,43 +3946,53 @@ void TileROD_Decoder::fillContainer_TileMuRcv_Decision(const ROBData* rob ,TileM std::vector<const uint32_t *> pFragTmdb; m_sizeOverhead = 3; - ATH_MSG_DEBUG( " Trying DECODER over source ID: " <<MSG::hex<< " 0x" << sourceid <<MSG::dec<< " full fragment size " << size ); + ATH_MSG_DEBUG( " Trying DECODER over source ID: " << MSG::hex + << " 0x" << sourceid << MSG::dec + << " full fragment size " << size ); while ( wc < size ) { // iterator over all words in a ROD // first word is the start of the tile subfragment in v3format it is 0xff1234ff if ((*p) == 0xff1234ff) b_sof=true; - ATH_MSG_DEBUG( " start of sub-fragment word : " <<MSG::hex<< (*p) <<MSG::dec<< " false/true : " << b_sof ); + ATH_MSG_DEBUG( " start of sub-fragment word : " << MSG::hex << (*p) << MSG::dec << " false/true : " << b_sof ); if (b_sof) { // second word is frag size - sfrag_size = *(p+1); + sfrag_size = *(p + 1); // third word is frag version [31-16] and type [15-0] - sfrag_version = *(p+2) & 0xFFFF; - sfrag_type = *(p+2) >> 16; - b_sof=false; + sfrag_version = *(p + 2) & 0xFFFF; + sfrag_type = *(p + 2) >> 16; + b_sof = false; } // for tmdb we will start to have three sub-fragments ordered as 0x40 0x41 0x42 // we investigate if there are any of type 0x40,0x41 before going on 0x42 // like this the loop is faster since we can access the size of this two sub-fragments - if (sfrag_type==0x40) { - ATH_MSG_DEBUG(MSG::hex<<" DECODER sub-fragment VERSION="<<sfrag_version<<" TYPE="<<sfrag_type<<MSG::dec<<" SIZE="<<sfrag_size<<" FOUND! Keep on looking for 0x42."); + if (sfrag_type == 0x40) { + ATH_MSG_DEBUG( MSG::hex << " DECODER sub-fragment VERSION=" << sfrag_version + << " TYPE=" << sfrag_type << MSG::dec + << " SIZE=" << sfrag_size + << " FOUND! Keep on looking for 0x42."); offset = sfrag_size; wc += offset; - p += offset; - } else if (sfrag_type==0x41) { - ATH_MSG_DEBUG(MSG::hex<<" DECODER sub-fragment VERSION="<<sfrag_version<<" TYPE="<<sfrag_type<<MSG::dec<<" SIZE="<<sfrag_size<<" FOUND! Keep on looking for 0x42."); + p += offset; + } else if (sfrag_type == 0x41) { + ATH_MSG_DEBUG( MSG::hex << " DECODER sub-fragment VERSION=" << sfrag_version + << " TYPE=" << sfrag_type << MSG::dec + <<" SIZE=" << sfrag_size + << " FOUND! Keep on looking for 0x42."); offset = sfrag_size; wc += offset; - p += offset; - } else if (sfrag_type==0x42) { + p += offset; + } else if (sfrag_type == 0x42) { b_deciTmdb = true; - ATH_MSG_DEBUG(MSG::hex<<" DECODER sub-fragment VERSION="<<sfrag_version<<" TYPE="<<sfrag_type<<MSG::dec<<" SIZE="<<sfrag_size<<" FOUND!" ); - wc+=size-wc; - p+=3; + ATH_MSG_DEBUG( MSG::hex << " DECODER sub-fragment VERSION=" << sfrag_version + << " TYPE=" << sfrag_type << MSG::dec + << " SIZE=" <<sfrag_size << " FOUND!"); + wc += size - wc; + p += 3; } else { - ++p ; - ++wc; + ++p; + ++wc; } } // the TMDB result 0x42 @@ -3997,17 +4002,18 @@ void TileROD_Decoder::fillContainer_TileMuRcv_Decision(const ROBData* rob ,TileM return; } -void TileROD_Decoder::unpack_frag40( uint32_t collid, uint32_t version, const uint32_t* p, int datasize, TileDigitsCollection &coll ){ +void TileROD_Decoder::unpack_frag40(uint32_t collid, uint32_t version, const uint32_t* p, int datasize, + TileDigitsCollection &coll) { - int ros=(collid>>8); - int drawer=collid&0xff; - HWIdentifier drawerID = m_tileHWID->drawer_id(ros,drawer); + int ros = (collid >> 8); + int drawer = collid & 0xff; + HWIdentifier drawerID = m_tileHWID->drawer_id(ros, drawer); int nsamp = 7; // assume fixed number of samples for the moment - int nmod = (ros>2)?8:4; // we have 8 modules per fragment in ext.barrel, 4 modules in barrel + int nmod = (ros > 2) ? 8 : 4; // we have 8 modules per fragment in ext.barrel, 4 modules in barrel int nchan = 4 * datasize / nmod / nsamp; // factor 4 because in one 32-bit word we have 4 samples - int nsamp1 = nsamp-1; - + int nsamp1 = nsamp - 1; + std::vector<float> digits(nsamp); // Each 32 bit word is made of four 8-bit words each a ADC of a sample like @@ -4018,13 +4024,13 @@ void TileROD_Decoder::unpack_frag40( uint32_t collid, uint32_t version, const ui // Note that order of samples is inversed with respect to time line, // i.e. first sample from data should go to the last sample in TileDigits vector - int wpos=(collid%nmod)*nchan; // location of first sample for given channel in given module - int jump = nchan*nmod; // distance between samples for one channel in number of bytes + int wpos = (collid % nmod) * nchan; // location of first sample for given channel in given module + int jump = nchan * nmod; // distance between samples for one channel in number of bytes const unsigned char * adc = reinterpret_cast<const unsigned char *>(p); - for (int i=0; i<nchan; ++i) { - for (int j=0; j<nsamp; ++j) { - digits[nsamp1-j] = adc[wpos+jump*j]; + for (int i = 0; i < nchan; ++i) { + for (int j = 0; j < nsamp; ++j) { + digits[nsamp1 - j] = adc[wpos + jump * j]; } ++wpos; HWIdentifier adcID = m_tileHWID->adc_id(drawerID, i, TileID::LOWGAIN); @@ -4033,21 +4039,23 @@ void TileROD_Decoder::unpack_frag40( uint32_t collid, uint32_t version, const ui } if (msgLvl(MSG::DEBUG)) { - msg(MSG::DEBUG) << "TileROD_Decoder::unpack_frag40 frag: 0x" - <<MSG::hex<<collid<<MSG::dec<<" version: "<<version << endreq; - int pos=coll.size()-nchan; - const char * strchannel[5] = {" d5L "," d5R "," d6L "," d6R "," xxx "}; - for (int i=0;i<nchan;++i) { - const std::vector<float> & sample = coll.at(pos+i)->samples(); + msg(MSG::DEBUG) << "TileROD_Decoder::unpack_frag40 frag: 0x" << MSG::hex << collid << MSG::dec + << " version: " << version << endmsg; + + int pos = coll.size() - nchan; + const char * strchannel[5] = { " d5L ", " d5R ", " d6L ", " d6R ", " xxx " }; + for (int i = 0; i < nchan; ++i) { + const std::vector<float> & sample = coll.at(pos + i)->samples(); std::stringstream ss; for (const auto & val : sample) { - ss<<std::setw(5)<<int(val); + ss << std::setw(5) << int(val); } - msg(MSG::DEBUG) << " ros:" << ros << " drawer:" << drawer <<" ch:" << i - << strchannel[std::min(i,4)] << ss.str() << endreq; + msg(MSG::DEBUG) << " ros:" << ros + << " drawer:" << drawer + << " ch:" << i << strchannel[std::min(i, 4)] << ss.str() << endmsg; } } - + return; } @@ -4061,7 +4069,7 @@ void TileROD_Decoder::unpack_frag41( uint32_t collid, uint32_t version, const ui int nmod = (ros>2)?8:4; // we have 8 modules per fragment in ext.barrel, 4 modules in barrel int nchan = datasize / nmod; - int wpos=(collid%nmod)*nchan; + int wpos = (collid % nmod) * nchan; if (version == 0) { @@ -4075,10 +4083,10 @@ void TileROD_Decoder::unpack_frag41( uint32_t collid, uint32_t version, const ui // Each 4 words respect a module. const int32_t * pp = reinterpret_cast<const int32_t *>(p); - pp+=wpos; - for (int i=0; i<nchan; ++i) { + pp += wpos; + for (int i = 0; i < nchan; ++i) { HWIdentifier adcID = m_tileHWID->adc_id(drawerID, i, TileID::LOWGAIN); - TileRawChannel *rctmp = new TileRawChannel(adcID,(*pp)*calFactorADC2MeV,0.,0.); + TileRawChannel *rctmp = new TileRawChannel(adcID, (*pp) * calFactorADC2MeV, 0., 0.); coll.push_back(rctmp); ++pp; } @@ -4092,27 +4100,29 @@ void TileROD_Decoder::unpack_frag41( uint32_t collid, uint32_t version, const ui // // Each 2 words respect a module. - nchan*=2; // change number of channels calculated before assuming 16 bits for channel + nchan *= 2; // change number of channels calculated before assuming 16 bits for channel const int16_t * pp = reinterpret_cast<const int16_t *>(p); - pp+=wpos; - for (int i=0; i<nchan; ++i) { + pp += wpos; + for (int i = 0; i < nchan; ++i) { HWIdentifier adcID = m_tileHWID->adc_id(drawerID, i, TileID::LOWGAIN); - TileRawChannel *rctmp = new TileRawChannel(adcID,(*pp)*calFactorADC2MeV,0.,0.); + TileRawChannel *rctmp = new TileRawChannel(adcID, (*pp) * calFactorADC2MeV, 0., 0.); coll.push_back(rctmp); ++pp; } } if (msgLvl(MSG::DEBUG)) { - msg(MSG::DEBUG) << " TileROD_Decoder::unpack_frag41 frag: 0x" - <<MSG::hex<<collid<<MSG::dec<<" version: "<<version << endreq; - int nbits=(version==0)?32:16; - msg(MSG::DEBUG) << " position of " << nbits << "-bit word inside sub-fragment 0x41: " << wpos << endreq; - int pos=coll.size()-nchan; - const char * strchannel[5] = {" d5L "," d5R "," d6L "," d6R "," xxx "}; - for (int i=0;i<nchan;++i) { - msg(MSG::DEBUG) << " ros:" << ros << " drawer:" << drawer <<" ch:" << i - << strchannel[std::min(i,4)] << coll.at(pos+i)->amplitude() << endreq; + msg(MSG::DEBUG) << " TileROD_Decoder::unpack_frag41 frag: 0x" << MSG::hex << collid << MSG::dec + << " version: " << version << endmsg; + + int nbits = (version == 0) ? 32 : 16; + msg(MSG::DEBUG) << " position of " << nbits << "-bit word inside sub-fragment 0x41: " << wpos << endmsg; + int pos = coll.size() - nchan; + const char * strchannel[5] = { " d5L ", " d5R ", " d6L ", " d6R ", " xxx " }; + for (int i = 0; i < nchan; ++i) { + msg(MSG::DEBUG) << " ros:" << ros + << " drawer:" << drawer + << " ch:" << i << strchannel[std::min(i, 4)] << coll.at(pos + i)->amplitude() << endmsg; } } @@ -4139,33 +4149,45 @@ void TileROD_Decoder::unpack_frag42( uint32_t sourceid, uint32_t version, const // bit-1 . // bit-0 -> result.at(3) - int drawer = ((sourceid & 0xf0000) >> 8) | ((sourceid & 0x0000f) << 3); - uint32_t word = (datasize>1) ? (p[1]<<20) | ((p[0]>>8) & 0xff000) | ((p[0]>>4) & 0xfff) : 0 ; - std::vector<bool> result(4); + 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 { + nbit = 4; + nmod = 8; + drawer |= ((sourceid & 0x0000f) << 3); + word = (datasize > 1) ? (p[1] << 20) | ((p[0] >> 8) & 0xff000) | ((p[0] >> 4) & 0xfff) : 0; + } - for (int j=0; j<8; ++j) { // loop over 8 modules - for (int k=0; k<4; ++k) { // loop over 4 bits of one module - result[3-k] = ((word&1) != 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; } - TileMuonReceiverObj * obj = new TileMuonReceiverObj(drawer,result); + TileMuonReceiverObj * obj = new TileMuonReceiverObj(drawer, result); v.push_back(obj); ++drawer; } if (msgLvl(MSG::DEBUG)) { - msg(MSG::DEBUG) << " TileROD_Decoder::unpack_frag42 source ID: 0x" - <<MSG::hex<<sourceid<<MSG::dec<<" version: "<<version << endreq; - for (size_t j=v.size()-8; j<v.size(); ++j) { + msg(MSG::DEBUG) << " TileROD_Decoder::unpack_frag42 source ID: 0x" << MSG::hex << sourceid << MSG::dec + << " version: " << version << endmsg; + + for (size_t j = v.size() - nmod; j < v.size(); ++j) { const std::vector<bool> & r = v[j]->GetDecision(); std::stringstream ss; for (const auto & val : r) { - ss<<std::setw(2)<<val; + ss << std::setw(2) << val; } - msg(MSG::DEBUG) << MSG::hex<<"0x"<<v[j]->GetID() <<MSG::dec - << ss.str() << endreq; + msg(MSG::DEBUG) << MSG::hex << "0x" << v[j]->GetID() << MSG::dec << ss.str() << endmsg; } }