diff --git a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Decoder.h b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Decoder.h index 0102cb6a2df27fca1477f2a3099a112a5870a7cb..a836a909b1ecb42f936393516b212e2ab477dd50 100644 --- a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Decoder.h +++ b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Decoder.h @@ -255,7 +255,7 @@ class TileROD_Decoder: public AthAlgTool { The phase is encoded in ns. <p> The subfragment type 0x4 contains the reconstructed parameters from the 48 read-out channels of a tilecal module. */ - void unpack_frag4(uint32_t version, const uint32_t* p, pRwChVec & pChannel); + void unpack_frag4(uint32_t version, unsigned int unit, const uint32_t* p, pRwChVec & pChannel); /** unpack_frag5 decodes tile subfragment type 0x4. This subfragment contains the reconstructed amplitude and phase from the tilecal digitized pulse and a @@ -306,7 +306,7 @@ class TileROD_Decoder: public AthAlgTool { The phase is encoded in ns. <p> The subfragment type 0x4 contains the reconstructed parameters from the 48 read-out channels of a tilecal module. */ - void unpack_frag4HLT(uint32_t version, const uint32_t* p, pFRwChVec & pChannel); + void unpack_frag4HLT(uint32_t version, unsigned int unit, const uint32_t* p, pFRwChVec & pChannel); /** unpack_frag5HLT decodes tile subfragment type 0x5 for the high level trigger (HLT). This subfragment contains the @@ -983,7 +983,6 @@ void TileROD_Decoder::fillCollection(const ROBData * rob, COLLECTION & v) { if (m_useFrag4) { m_bsflags = idAndType & 0xFFFF0000; // ignore frag num, keep all the rest int unit = (idAndType & 0xC0000000) >> 30; - m_rc2bytes4.setUnit(unit); int DataType = (idAndType & 0x30000000) >> 28; @@ -1010,7 +1009,7 @@ void TileROD_Decoder::fillCollection(const ROBData * rob, COLLECTION & v) { m_rChUnit = (TileRawChannelUnit::UNIT) (unit); // Offline units in simulated data } - unpack_frag4(version, p, pChannel); + unpack_frag4(version, unit, p, pChannel); } break; diff --git a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Encoder.h b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Encoder.h index e2ba74d2b85ab2b1e53372d131fff9bf0433d5f0..1d9ac11be66ced4e0d3f32a81a948cb4b50e5109 100644 --- a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Encoder.h +++ b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileROD_Encoder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #ifndef TILEBYTESTREAM_TILEROD_ENCODER_H @@ -148,6 +148,7 @@ class TileROD_Encoder { bool m_verbose; unsigned int m_type; unsigned int m_unitType; + unsigned int m_rChUnit; mutable Athena::MsgStreamMember m_msg; int m_maxChannels; diff --git a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileRawChannel2Bytes4.h b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileRawChannel2Bytes4.h index 95596c7b7dfa1daee712004f6998fe1cf1549310..587066214e3f41b615318566e391aee907f25442 100644 --- a/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileRawChannel2Bytes4.h +++ b/TileCalorimeter/TileSvc/TileByteStream/TileByteStream/TileRawChannel2Bytes4.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #ifndef TILEBYTESTREAM_TILERAWCHANNEL2BYTES4_H @@ -66,41 +66,30 @@ class TileFastRawChannel; class TileRawChannel2Bytes4 { public: TileRawChannel2Bytes4() - : m_verbose(false), m_rChUnit(0) { + { } /** Adds an entry to the vector<int> v for this TileRawChannel. The entry is the single 32-bit word generated using TileRawChannel2Bytes4::getWord() method.<p> Returns 1 which is the number of entries added to the vector. */ - int getBytes(const TileFastRawChannel* rc, int gain, std::vector<unsigned int>& v); + int getBytes(const TileFastRawChannel& rc, unsigned int unit, + int gain, std::vector<unsigned int>& v) const; /** Returns a single 32-bit word which encodes the TileRawChannel information (gain,amplitude,phase and quality) for a single read-out channel. */ - unsigned int getWord(const TileFastRawChannel* rc, int gain); + unsigned int getWord(const TileFastRawChannel& rc, unsigned int unit, int gain) const; /** Returns the gain unpacked from the single 32-bit word w. */ inline int gain(unsigned int w) const; /** Returns the amplitude in the corresponding units, unpacked from the single 32-bit word w. */ - inline float amplitude(unsigned int w) const; + inline float amplitude(unsigned int w, unsigned int unit) const; /** Returns the phase of the pulse in ns, unpacked from the single 32-bit word w. */ inline float time(unsigned int w) const; /** Returns the quality factor unpacked from the single 32-bit word w. */ inline float quality(unsigned int w) const; /** Sets verbose mode true or false. */ - inline void setVerbose(bool verbose) { - m_verbose = verbose; + inline void setVerbose(bool /*verbose*/) { } - - /** Sets the energy units value (TileRawChannel2Bytes4::m_rChUnit). */ - inline void setUnit(unsigned int unit) { - m_rChUnit = unit; - } - - private: - /** Verbose flag. */ - bool m_verbose; - /** Energy units. */ - unsigned int m_rChUnit; }; // inline functions @@ -110,11 +99,11 @@ inline int TileRawChannel2Bytes4::gain(unsigned int w) const { return g; } -inline float TileRawChannel2Bytes4::amplitude(unsigned int w) const { +inline float TileRawChannel2Bytes4::amplitude(unsigned int w, unsigned int unit) const { int g = (w >> GAIN_SHIFT4) & GAIN_RANGE4; float a = (((w >> AMPLITUDE_SHIFT4) & AMPLITUDE_RANGE4) - AMPLITUDE_OFFSET4[g]) - / AMPLITUDE_FACTOR4[m_rChUnit]; - if (m_rChUnit != 0 && g == 1) a = a / 64.0F; + / AMPLITUDE_FACTOR4[unit]; + if (unit != 0 && g == 1) a = a / 64.0F; return a; } diff --git a/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Decoder.cxx b/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Decoder.cxx index 509bbd900aa65454d285ef97c999b357a9ca0078..f736700fd5859ee5c4225be9b843f4c6628fbc6d 100644 --- a/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Decoder.cxx +++ b/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Decoder.cxx @@ -153,7 +153,6 @@ int TileROD_Decoder::getErrorCounter() { StatusCode TileROD_Decoder::initialize() { m_rc2bytes5.setVerbose(m_verbose); - m_rc2bytes4.setVerbose(m_verbose); m_rc2bytes2.setVerbose(m_verbose); m_rc2bytes.setVerbose(m_verbose); m_d2Bytes.setVerbose(m_verbose); @@ -897,7 +896,9 @@ void TileROD_Decoder::unpack_frag3(uint32_t /* version */, const uint32_t* p, return; } -void TileROD_Decoder::unpack_frag4(uint32_t /* version */, const uint32_t* p, +void TileROD_Decoder::unpack_frag4(uint32_t /* version */, + unsigned int unit, + const uint32_t* p, pRwChVec & pChannel) { // first word is frag size int count = *(p); @@ -928,7 +929,7 @@ void TileROD_Decoder::unpack_frag4(uint32_t /* version */, const uint32_t* p, if (w != 0) { // skip invalid channels if (all00) all00 = TileFragStatus::ALL_OK; rc = new TileRawChannel(adcID - , m_rc2bytes4.amplitude(w) + , m_rc2bytes4.amplitude(w, unit) , m_rc2bytes4.time(w) , m_rc2bytes4.quality(w)); } else { @@ -1864,7 +1865,7 @@ void TileROD_Decoder::unpack_frag14(uint32_t /* version */, const uint32_t* p, nDrawer[0] = frag & 0x3F; nDrawer[1] = (frag & 0xFC0) >> 6; - p += 2; // 2 words so far + p += 2; // 2 words somethingm far std::vector<float> sumE(1); @@ -3296,7 +3297,6 @@ uint32_t TileROD_Decoder::fillCollectionHLT(const ROBData * rob, TileCellCollect if (!m_ignoreFrag4HLT && !fragFound) { fragFound = true; int unit = (idAndType & 0xC0000000) >> 30; - m_rc2bytes4.setUnit(unit); int DataType = (idAndType & 0x30000000) >> 28; @@ -3314,7 +3314,7 @@ uint32_t TileROD_Decoder::fillCollectionHLT(const ROBData * rob, TileCellCollect m_rChUnit = (TileRawChannelUnit::UNIT) (unit); // Offline units in simulated data } - unpack_frag4HLT(version, p, m_pRwChVec); + unpack_frag4HLT(version, unit, p, m_pRwChVec); } break; @@ -3680,7 +3680,9 @@ void TileROD_Decoder::unpack_frag3HLT(uint32_t /* version */, const uint32_t* p, return; } -void TileROD_Decoder::unpack_frag4HLT(uint32_t /* version */, const uint32_t* p, +void TileROD_Decoder::unpack_frag4HLT(uint32_t /* version */, + unsigned int unit, + const uint32_t* p, pFRwChVec & pChannel) { // first word is frag size int count = *(p); @@ -3693,7 +3695,7 @@ void TileROD_Decoder::unpack_frag4HLT(uint32_t /* version */, const uint32_t* p, if (w != 0) { // skip invalid channels pChannel[ch]->set(ch , m_rc2bytes4.gain(w) - , m_rc2bytes4.amplitude(w) + , m_rc2bytes4.amplitude(w, unit) , m_rc2bytes4.time(w) , m_rc2bytes4.quality(w)); diff --git a/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Encoder.cxx b/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Encoder.cxx index 96350c5f1eabdb172219f56b3c13edf6a128f299..fb6067863d26a3b1f652cccc51b56b4039d3b2fd 100644 --- a/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Encoder.cxx +++ b/TileCalorimeter/TileSvc/TileByteStream/src/TileROD_Encoder.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ // Implementation of TileROD_Encoder class @@ -25,7 +25,8 @@ TileROD_Encoder::TileROD_Encoder(): m_tileHWID(0), m_verbose(false), m_type(0), - m_unitType(0), + m_unitType(0), + m_rChUnit(0), m_msg("TileROD_Encoder"), m_maxChannels(TileCalibUtils::MAX_CHAN) { } @@ -86,7 +87,7 @@ void TileROD_Encoder::setTypeAndUnit(TileFragHash::TYPE type, TileRawChannelUnit // 24,25,26 - OF type // next 8 bits - frag type ( 2,3,4, ... ) m_unitType = (rChUnit << 30) | (3 << 28) | (0 << 27) | (OFType << 24) | (m_type << 16); - m_rc2bytes4.setUnit(rChUnit); + m_rChUnit = rChUnit; } else if (m_type == 5) { // 8 upper bits: // UULLLTTT @@ -416,7 +417,7 @@ void TileROD_Encoder::fillROD4(std::vector<uint32_t>& v) { int chan = rc->channel(); int gain = rc->adc(); if (chan < m_maxChannels) { - v[start + chan] = m_rc2bytes4.getWord(rc, gain); + v[start + chan] = m_rc2bytes4.getWord(*rc, m_rChUnit, gain); } } // end of all TileRawChannel diff --git a/TileCalorimeter/TileSvc/TileByteStream/src/TileRawChannel2Bytes4.cxx b/TileCalorimeter/TileSvc/TileByteStream/src/TileRawChannel2Bytes4.cxx index c3ee735a83a1c9ef696ea9dadd29807820f01bf8..8efa7835f43c9b326a8bb1274273313c6c755cfe 100644 --- a/TileCalorimeter/TileSvc/TileByteStream/src/TileRawChannel2Bytes4.cxx +++ b/TileCalorimeter/TileSvc/TileByteStream/src/TileRawChannel2Bytes4.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #include "TileByteStream/TileRawChannel2Bytes4.h" @@ -7,28 +7,33 @@ #include <algorithm> #include <cmath> -int TileRawChannel2Bytes4::getBytes(const TileFastRawChannel* rc, int gain, - std::vector<unsigned int>& v) { +int TileRawChannel2Bytes4::getBytes(const TileFastRawChannel& rc, + unsigned int unit, + int gain, + std::vector<unsigned int>& v) const +{ // pack raw data into one 32-bits integer - v.push_back(getWord(rc, gain)); + v.push_back(getWord(rc, unit, gain)); return 1; // one int added to vector } -unsigned int TileRawChannel2Bytes4::getWord(const TileFastRawChannel* rc, int gain) { - +unsigned int TileRawChannel2Bytes4::getWord(const TileFastRawChannel& rc, + unsigned int unit, + int gain) const +{ // pack raw data into one 32-bits integer - float tmp = rc->amplitude(); - if (m_rChUnit != 0 && gain == 1) tmp = tmp * 64.0F; + float tmp = rc.amplitude(); + if (unit != 0 && gain == 1) tmp = tmp * 64.0F; unsigned int a = std::max(0, std::min(AMPLITUDE_RANGE4 - , (int) lround(tmp * AMPLITUDE_FACTOR4[m_rChUnit] + AMPLITUDE_OFFSET4[gain]))); + , (int) lround(tmp * AMPLITUDE_FACTOR4[unit] + AMPLITUDE_OFFSET4[gain]))); unsigned int t = std::max(0,std::min(TIME_RANGE4 - , (int) lround(rc->time() * TIME_FACTOR4 + TIME_OFFSET4))); + , (int) lround(rc.time() * TIME_FACTOR4 + TIME_OFFSET4))); unsigned int q = std::max(0, std::min(QUALITY_RANGE4_NOFLAG, - (int) lround(rc->quality() * QUALITY_FACTOR4 + QUALITY_OFFSET4))); + (int) lround(rc.quality() * QUALITY_FACTOR4 + QUALITY_OFFSET4))); unsigned int w = (a << AMPLITUDE_SHIFT4) | (t << TIME_SHIFT4) | (q << QUALITY_SHIFT4); diff --git a/TileCalorimeter/TileSvc/TileByteStream/test/TileRawChannel2Bytes4_test.cxx b/TileCalorimeter/TileSvc/TileByteStream/test/TileRawChannel2Bytes4_test.cxx index b0dd9315c29a8023da2ea09d3965609a0165c444..10990ad3302e62ac4f21ed727dfa354b55948f7b 100644 --- a/TileCalorimeter/TileSvc/TileByteStream/test/TileRawChannel2Bytes4_test.cxx +++ b/TileCalorimeter/TileSvc/TileByteStream/test/TileRawChannel2Bytes4_test.cxx @@ -21,22 +21,20 @@ void test1() TileRawChannel2Bytes4 rch; TileFastRawChannel fch; fch.set (0, 0, 0, 120.5, 1.25, 5); - rch.setUnit (0); - unsigned int w = rch.getWord (&fch, 0); + unsigned int w = rch.getWord (fch, 0, 0); assert (w == (2440<<16) + (1044<<5) + 5); assert (rch.gain(w) == 0); - assert (rch.amplitude(w) == 120.5); + assert (rch.amplitude(w, 0) == 120.5); assert (rch.time(w) == 1.25); assert (rch.quality(w) == 5); std::vector<unsigned int> v; fch.set (0, 0, 0, -0.5, 1.25, 3); - rch.setUnit (1); - assert (rch.getBytes (&fch, 1, v) == 1); + assert (rch.getBytes (fch, 1, 1, v) == 1); assert (v.size() == 1); assert (v[0] == (1024u<<16) + (1044u<<5) + 3u + (1u<<31)); assert (rch.gain(v[0]) == 1); - assert (rch.amplitude(v[0]) == -0.5); + assert (rch.amplitude(v[0], 1) == -0.5); assert (rch.time(v[0]) == 1.25); assert (rch.quality(v[0]) == 3); } diff --git a/TileCalorimeter/TileTBRec/TileTBRec/TileTBDump.h b/TileCalorimeter/TileTBRec/TileTBRec/TileTBDump.h index b4f1f84da438a24324e09bb42230543bb68739e5..4fabe352d2d0e57664e84a41062fbd780ada05f1 100755 --- a/TileCalorimeter/TileTBRec/TileTBRec/TileTBDump.h +++ b/TileCalorimeter/TileTBRec/TileTBRec/TileTBDump.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ //**************************************************************************** @@ -203,7 +203,9 @@ class TileTBDump: public AthAlgorithm { , unsigned int version, int verbosity, int* ngain, int* nchannel); int tile_unpack_reco_calib(T_RodDataFrag* frag, T_TileRecoCalib* recocalib, int nchannel_max - , unsigned int version, int verbosity, int* ngain, int* nchannel); // Baxo + , unsigned int version + , unsigned int unit + , int verbosity, int* ngain, int* nchannel); // Baxo int tile_unpack_quality(T_RodDataFrag* frag, T_TileRecoQuality & DQword); diff --git a/TileCalorimeter/TileTBRec/src/TileTBDump.cxx b/TileCalorimeter/TileTBRec/src/TileTBDump.cxx index 0e87be69622e983913a486758cb0dc12024f14a3..a64e8fec7c6a36e63488a27d57042fd260bcd846 100755 --- a/TileCalorimeter/TileTBRec/src/TileTBDump.cxx +++ b/TileCalorimeter/TileTBRec/src/TileTBDump.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ //***************************************************************************** @@ -1549,8 +1549,7 @@ void TileTBDump::dump_digi(unsigned int subdet_id, const uint32_t* roddata, unsi case 4: // fragment with gain/amp/time/bad/quality in 32 bit words m_unit = unit; - m_rc2bytes4.setUnit(unit); - tile_unpack_reco_calib(frag[f], recocalib, MAX_DIGI_CHAN, version, verbosity, &ngain, + tile_unpack_reco_calib(frag[f], recocalib, MAX_DIGI_CHAN, version, unit, verbosity, &ngain, &nchan); std::cout << "\nReco calibrated energy fragment 0x" << std::hex << id << std::dec << ", " << size << " words found:" @@ -2025,6 +2024,7 @@ int TileTBDump::tile_unpack_reco(T_RodDataFrag *frag, T_TileRecoChannel * channe /*--------------------------------------------------------------------------*/ int TileTBDump::tile_unpack_reco_calib(T_RodDataFrag* frag, T_TileRecoCalib* recocalib , int nchannel_max, unsigned int /* version */ + , unsigned int unit , int /* verbosity */, int *ngain, int *nchannel) {// Baxo /*--------------------------------------------------------------------------*/ @@ -2043,7 +2043,7 @@ int TileTBDump::tile_unpack_reco_calib(T_RodDataFrag* frag, T_TileRecoCalib* rec recocalib[ch].time = (w >> TIME_SHIFT4) & TIME_RANGE4; recocalib[ch].bad = ((w >> QUALITY_SHIFT4) & QUALITY_RANGE4 & 0x10) >> 4; recocalib[ch].quality = ((w >> QUALITY_SHIFT4) & QUALITY_RANGE4 & 0xF); - recocalib[ch].d_amp = m_rc2bytes4.amplitude(w); + recocalib[ch].d_amp = m_rc2bytes4.amplitude(w, unit); recocalib[ch].d_time = m_rc2bytes4.time(w); recocalib[ch].d_quality = m_rc2bytes4.quality(w); }