Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(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<float>(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<float>(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<float>(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
Expand Down
1 change: 0 additions & 1 deletion DataFormats/Detectors/EMCAL/src/Cell.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class CTFCoder : public o2::ctf::CTFCoderBase
o2::ctf::CTFIOSize encode(VEC& buff, const gsl::span<const TriggerRecord>& trigData, const gsl::span<const CellCompressed>& cellData);

// repack energy old format -> new format
template <typename T, typename U> T repackE(T packedE, U packedStatus);
template <typename T, typename U>
T repackE(T packedE, U packedStatus);

/// entropy decode data from buffer with CTF
template <typename VTRG, typename VCELL>
Expand Down Expand Up @@ -136,35 +137,37 @@ o2::ctf::CTFIOSize CTFCoder::encode_impl(VEC& buff, const gsl::span<const Trigge
}

// repack cell energy (needed for old version of CTF (subversion 1)
template <typename T, typename U> 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 <typename T, typename U>
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<o2::emcal::ChannelType_t>(packedStatus)) {
case o2::emcal::ChannelType_t::HIGH_GAIN: {
repackedE = static_cast<T>(std::round(truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_HG));
break;
}
switch (static_cast<o2::emcal::ChannelType_t>(packedStatus)) {
case o2::emcal::ChannelType_t::HIGH_GAIN: {
repackedE = static_cast<T>(std::round(truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_HG));
break;
}
case o2::emcal::ChannelType_t::LOW_GAIN: {
repackedE = static_cast<T>(std::round(truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_LG));
break;
}
case o2::emcal::ChannelType_t::TRU: {
repackedE = static_cast<T>(std::round(truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_TRU));
break;
}
case o2::emcal::ChannelType_t::LEDMON: {
repackedE = static_cast<T>(std::round(truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_LEDMON));
break;
}
case o2::emcal::ChannelType_t::LOW_GAIN: {
repackedE = static_cast<T>(std::round(truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_LG));
break;
}
case o2::emcal::ChannelType_t::TRU: {
repackedE = static_cast<T>(std::round(truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_TRU));
break;
}
case o2::emcal::ChannelType_t::LEDMON: {
repackedE = static_cast<T>(std::round(truncatedEnergyTmp / CellCompressed::ENERGY_RESOLUTION_LEDMON));
break;
}
return repackedE;
}
}
return repackedE;
}

/// decode entropy-encoded clusters to standard compact clusters
template <typename VTRG, typename VCELL>
Expand Down Expand Up @@ -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());
Expand Down