@@ -44,7 +44,8 @@ class CTFCoder : public o2::ctf::CTFCoderBase
4444 o2::ctf::CTFIOSize encode (VEC& buff, const gsl::span<const TriggerRecord>& trigData, const gsl::span<const CellCompressed>& cellData);
4545
4646 // repack energy old format -> new format
47- template <typename T, typename U> T repackE (T packedE, U packedStatus);
47+ template <typename T, typename U>
48+ T repackE (T packedE, U packedStatus);
4849
4950 // / entropy decode data from buffer with CTF
5051 template <typename VTRG, typename VCELL>
@@ -136,35 +137,37 @@ o2::ctf::CTFIOSize CTFCoder::encode_impl(VEC& buff, const gsl::span<const Trigge
136137}
137138
138139// repack cell energy (needed for old version of CTF (subversion 1)
139- template <typename T, typename U> T CTFCoder::repackE (T packedE, U packedStatus){
140- T repackedE = packedE;
141- double energyTmp = packedE * CellCompressed::ENERGY_RESOLUTION_OLD;
142- double truncatedEnergyTmp = energyTmp;
143- if (truncatedEnergyTmp < 0 .) {
144- truncatedEnergyTmp = 0 .;
145- } else if (truncatedEnergyTmp > CellCompressed::ENERGY_TRUNCATION) {
146- truncatedEnergyTmp = CellCompressed::ENERGY_TRUNCATION;
140+ template <typename T, typename U>
141+ T CTFCoder::repackE (T packedE, U packedStatus)
142+ {
143+ T repackedE = packedE;
144+ double energyTmp = packedE * CellCompressed::ENERGY_RESOLUTION_OLD;
145+ double truncatedEnergyTmp = energyTmp;
146+ if (truncatedEnergyTmp < 0 .) {
147+ truncatedEnergyTmp = 0 .;
148+ } else if (truncatedEnergyTmp > CellCompressed::ENERGY_TRUNCATION) {
149+ truncatedEnergyTmp = CellCompressed::ENERGY_TRUNCATION;
150+ }
151+ switch (static_cast <o2::emcal::ChannelType_t>(packedStatus)) {
152+ case o2::emcal::ChannelType_t::HIGH_GAIN: {
153+ repackedE = static_cast <T>(std::round (truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_HG));
154+ break ;
147155 }
148- switch (static_cast <o2::emcal::ChannelType_t>(packedStatus)) {
149- case o2::emcal::ChannelType_t::HIGH_GAIN: {
150- repackedE = static_cast <T>(std::round (truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_HG));
151- break ;
152- }
153- case o2::emcal::ChannelType_t::LOW_GAIN: {
154- repackedE = static_cast <T>(std::round (truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_LG));
155- break ;
156- }
157- case o2::emcal::ChannelType_t::TRU: {
158- repackedE = static_cast <T>(std::round (truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_TRU));
159- break ;
160- }
161- case o2::emcal::ChannelType_t::LEDMON: {
162- repackedE = static_cast <T>(std::round (truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_LEDMON));
163- break ;
164- }
156+ case o2::emcal::ChannelType_t::LOW_GAIN: {
157+ repackedE = static_cast <T>(std::round (truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_LG));
158+ break ;
159+ }
160+ case o2::emcal::ChannelType_t::TRU: {
161+ repackedE = static_cast <T>(std::round (truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_TRU));
162+ break ;
163+ }
164+ case o2::emcal::ChannelType_t::LEDMON: {
165+ repackedE = static_cast <T>(std::round (truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_LEDMON));
166+ break ;
165167 }
166- return repackedE;
167- }
168+ }
169+ return repackedE;
170+ }
168171
169172// / decode entropy-encoded clusters to standard compact clusters
170173template <typename VTRG, typename VCELL>
@@ -227,13 +230,12 @@ o2::ctf::CTFIOSize CTFCoder::decode(const CTF::base& ec, VTRG& trigVec, VCELL& c
227230
228231 firstEntry = cellVec.size ();
229232
230-
231233 for (uint16_t ic = 0 ; ic < entries[itrig]; ic++) {
232234 // if old verion of CTF, do conversion to energy and then repack before setting packed content
233- if (isVersion1){
234- packedEnergy = repackE (energy[cellCount],status[cellCount]);
235- } else { // new CTFs don't require any repacking
236- packedEnergy = energy[cellCount];
235+ if (isVersion1) {
236+ packedEnergy = repackE (energy[cellCount], status[cellCount]);
237+ } else { // new CTFs don't require any repacking
238+ packedEnergy = energy[cellCount];
237239 }
238240 cellCompressed.setPacked (tower[cellCount], cellTime[cellCount], packedEnergy, status[cellCount], chi2[cellCount]);
239241 cell.setAll (cellCompressed.getTower (), cellCompressed.getEnergy (), cellCompressed.getTimeStamp (), cellCompressed.getType (), cellCompressed.getChi2 ());
0 commit comments