diff --git a/DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/CellCompressed.h b/DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/CellCompressed.h index 6164c80973e9f..8cf51bcdec9c7 100644 --- a/DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/CellCompressed.h +++ b/DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/CellCompressed.h @@ -60,19 +60,19 @@ class CellCompressed public: // constants static constexpr float TIME_SHIFT = 600., - TIME_RANGE = 1500., - TIME_RESOLUTION = TIME_RANGE / 2047., - ENERGY_BITS = static_cast(0x3FFF), - HGLGTRANSITION = o2::emcal::constants::EMCAL_HGLGTRANSITION * o2::emcal::constants::EMCAL_ADCENERGY, - ENERGY_TRUNCATION = 250., - ENERGY_RESOLUTION_LG = (ENERGY_TRUNCATION - HGLGTRANSITION) / ENERGY_BITS, - ENERGY_RESOLUTION_HG = HGLGTRANSITION / ENERGY_BITS, - ENERGY_RESOLUTION_TRU = ENERGY_TRUNCATION / ENERGY_BITS, - ENERGY_RESOLUTION_LEDMON = ENERGY_TRUNCATION / ENERGY_BITS, - CHI2_TRUNCATION = 10., - CHI_2BITS = static_cast(0x3F), - CHI2_RESOLUTION = CHI2_TRUNCATION / CHI_2BITS, - ENERGY_RESOLUTION_OLD = ENERGY_TRUNCATION / 16383.; + TIME_RANGE = 1500., + TIME_RESOLUTION = TIME_RANGE / 2047., + ENERGY_BITS = static_cast(0x3FFF), + HGLGTRANSITION = o2::emcal::constants::EMCAL_HGLGTRANSITION * o2::emcal::constants::EMCAL_ADCENERGY, + ENERGY_TRUNCATION = 250., + ENERGY_RESOLUTION_LG = (ENERGY_TRUNCATION - HGLGTRANSITION) / ENERGY_BITS, + ENERGY_RESOLUTION_HG = HGLGTRANSITION / ENERGY_BITS, + ENERGY_RESOLUTION_TRU = ENERGY_TRUNCATION / ENERGY_BITS, + ENERGY_RESOLUTION_LEDMON = ENERGY_TRUNCATION / ENERGY_BITS, + CHI2_TRUNCATION = 10., + CHI_2BITS = static_cast(0x3F), + CHI2_RESOLUTION = CHI2_TRUNCATION / CHI_2BITS, + ENERGY_RESOLUTION_OLD = ENERGY_TRUNCATION / 16383.; CellCompressed(); CellCompressed(short tower, float energy, float time, ChannelType_t ctype = ChannelType_t::LOW_GAIN, float chi2 = 10.); ~CellCompressed() = default; // override diff --git a/DataFormats/Detectors/EMCAL/src/Cell.cxx b/DataFormats/Detectors/EMCAL/src/Cell.cxx index a5ad42e039d03..9fc4fb28d8afa 100644 --- a/DataFormats/Detectors/EMCAL/src/Cell.cxx +++ b/DataFormats/Detectors/EMCAL/src/Cell.cxx @@ -33,7 +33,6 @@ Cell::Cell(short tower, float energy, float time, ChannelType_t type, float chi2 mtime = time; mtype = type; mchi2 = chi2; - } void Cell::setAll(short tower, float energy, float time, ChannelType_t type, float chi2) diff --git a/Detectors/EMCAL/reconstruction/include/EMCALReconstruction/CTFCoder.h b/Detectors/EMCAL/reconstruction/include/EMCALReconstruction/CTFCoder.h index 63fe4ee53c6bd..2c3277c71102e 100644 --- a/Detectors/EMCAL/reconstruction/include/EMCALReconstruction/CTFCoder.h +++ b/Detectors/EMCAL/reconstruction/include/EMCALReconstruction/CTFCoder.h @@ -44,7 +44,8 @@ class CTFCoder : public o2::ctf::CTFCoderBase o2::ctf::CTFIOSize encode(VEC& buff, const gsl::span& trigData, const gsl::span& cellData); // repack energy old format -> new format - template T repackE(T packedE, U packedStatus); + template + T repackE(T packedE, U packedStatus); /// entropy decode data from buffer with CTF template @@ -136,35 +137,37 @@ o2::ctf::CTFIOSize CTFCoder::encode_impl(VEC& buff, const gsl::span T CTFCoder::repackE(T packedE, U packedStatus){ - T repackedE = packedE; - double energyTmp = packedE * CellCompressed::ENERGY_RESOLUTION_OLD; - double truncatedEnergyTmp = energyTmp; - if (truncatedEnergyTmp < 0.) { - truncatedEnergyTmp = 0.; - } else if (truncatedEnergyTmp > CellCompressed::ENERGY_TRUNCATION) { - truncatedEnergyTmp = CellCompressed::ENERGY_TRUNCATION; +template +T CTFCoder::repackE(T packedE, U packedStatus) +{ + T repackedE = packedE; + double energyTmp = packedE * CellCompressed::ENERGY_RESOLUTION_OLD; + double truncatedEnergyTmp = energyTmp; + if (truncatedEnergyTmp < 0.) { + truncatedEnergyTmp = 0.; + } else if (truncatedEnergyTmp > CellCompressed::ENERGY_TRUNCATION) { + truncatedEnergyTmp = CellCompressed::ENERGY_TRUNCATION; + } + switch (static_cast(packedStatus)) { + case o2::emcal::ChannelType_t::HIGH_GAIN: { + repackedE = static_cast(std::round(truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_HG)); + break; } - switch (static_cast(packedStatus)) { - case o2::emcal::ChannelType_t::HIGH_GAIN: { - repackedE = static_cast(std::round(truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_HG)); - break; - } - case o2::emcal::ChannelType_t::LOW_GAIN: { - repackedE = static_cast(std::round(truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_LG)); - break; - } - case o2::emcal::ChannelType_t::TRU: { - repackedE = static_cast(std::round(truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_TRU)); - break; - } - case o2::emcal::ChannelType_t::LEDMON: { - repackedE = static_cast(std::round(truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_LEDMON)); - break; - } + case o2::emcal::ChannelType_t::LOW_GAIN: { + repackedE = static_cast(std::round(truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_LG)); + break; + } + case o2::emcal::ChannelType_t::TRU: { + repackedE = static_cast(std::round(truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_TRU)); + break; + } + case o2::emcal::ChannelType_t::LEDMON: { + repackedE = static_cast(std::round(truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_LEDMON)); + break; } - return repackedE; - } + } + return repackedE; +} /// decode entropy-encoded clusters to standard compact clusters template @@ -227,13 +230,12 @@ o2::ctf::CTFIOSize CTFCoder::decode(const CTF::base& ec, VTRG& trigVec, VCELL& c firstEntry = cellVec.size(); - for (uint16_t ic = 0; ic < entries[itrig]; ic++) { // if old verion of CTF, do conversion to energy and then repack before setting packed content - if(isVersion1){ - packedEnergy = repackE(energy[cellCount],status[cellCount]); - } else{ // new CTFs don't require any repacking - packedEnergy = energy[cellCount]; + if (isVersion1) { + packedEnergy = repackE(energy[cellCount], status[cellCount]); + } else { // new CTFs don't require any repacking + packedEnergy = energy[cellCount]; } cellCompressed.setPacked(tower[cellCount], cellTime[cellCount], packedEnergy, status[cellCount], chi2[cellCount]); cell.setAll(cellCompressed.getTower(), cellCompressed.getEnergy(), cellCompressed.getTimeStamp(), cellCompressed.getType(), cellCompressed.getChi2());