Skip to content
Draft
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 @@ -12,17 +12,17 @@
#ifndef ALICEO2_EMCAL_ANALYSISCLUSTER_H_
#define ALICEO2_EMCAL_ANALYSISCLUSTER_H_

#include "MathUtils/Cartesian.h" // IWYU pragma: keep

#include <Rtypes.h>
#include <TLorentzVector.h>

#include <fairlogger/Logger.h>
#include <gsl/span>
#include <array>
#include "Rtypes.h"
#include "MathUtils/Cartesian.h"
#include "TLorentzVector.h"

namespace o2
{
#include <array>

namespace emcal
namespace o2::emcal
{

/// \class AnalysisCluster
Expand All @@ -45,8 +45,7 @@ class AnalysisCluster
public:
/// \brief Constructor, setting cell wrong cell index raising the exception
/// \param cellIndex Cell index raising the exception
CellOutOfRangeException(Int_t cellIndex) : std::exception(),
mCellIndex(cellIndex),
CellOutOfRangeException(Int_t cellIndex) : mCellIndex(cellIndex),
mMessage("Cell index " + std::to_string(mCellIndex) + " out of range.")
{
}
Expand All @@ -56,11 +55,11 @@ class AnalysisCluster

/// \brief Access to cell ID raising the exception
/// \return Cell ID
Int_t getCellIndex() const noexcept { return mCellIndex; }
[[nodiscard]] Int_t getCellIndex() const noexcept { return mCellIndex; }

/// \brief Access to error message of the exception
/// \return Error message
const char* what() const noexcept final { return mMessage.data(); }
[[nodiscard]] const char* what() const noexcept final { return mMessage.data(); }

private:
Int_t mCellIndex; ///< Cell index raising the exception
Expand All @@ -76,55 +75,55 @@ class AnalysisCluster
// Common EMCAL/PHOS/FMD/PMD

void setID(int id) { mID = id; }
int getID() const { return mID; }
[[nodiscard]] int getID() const { return mID; }

void setE(float ene) { mEnergy = ene; }
float E() const { return mEnergy; }
[[nodiscard]] float E() const { return mEnergy; }

void setChi2(float chi2) { mChi2 = chi2; }
float Chi2() const { return mChi2; }
[[nodiscard]] float Chi2() const { return mChi2; }

///
/// Set the cluster global position.
void setGlobalPosition(math_utils::Point3D<float> x);
math_utils::Point3D<float> getGlobalPosition() const
void setGlobalPosition(const math_utils::Point3D<float>& x);
[[nodiscard]] math_utils::Point3D<float> getGlobalPosition() const
{
return mGlobalPos;
}

void setLocalPosition(math_utils::Point3D<float> x);
math_utils::Point3D<float> getLocalPosition() const
void setLocalPosition(const math_utils::Point3D<float>& x);
[[nodiscard]] math_utils::Point3D<float> getLocalPosition() const
{
return mLocalPos;
}

void setDispersion(float disp) { mDispersion = disp; }
float getDispersion() const { return mDispersion; }
[[nodiscard]] float getDispersion() const { return mDispersion; }

void setM20(float m20) { mM20 = m20; }
float getM20() const { return mM20; }
[[nodiscard]] float getM20() const { return mM20; }

void setM02(float m02) { mM02 = m02; }
float getM02() const { return mM02; }
[[nodiscard]] float getM02() const { return mM02; }

void setNExMax(unsigned char nExMax) { mNExMax = nExMax; }
unsigned char getNExMax() const { return mNExMax; }
[[nodiscard]] unsigned char getNExMax() const { return mNExMax; }

void setEmcCpvDistance(float dEmcCpv) { mEmcCpvDistance = dEmcCpv; }
float getEmcCpvDistance() const { return mEmcCpvDistance; }
[[nodiscard]] float getEmcCpvDistance() const { return mEmcCpvDistance; }
void setTrackDistance(float dx, float dz)
{
mTrackDx = dx;
mTrackDz = dz;
}
float getTrackDx() const { return mTrackDx; }
float getTrackDz() const { return mTrackDz; }
[[nodiscard]] float getTrackDx() const { return mTrackDx; }
[[nodiscard]] float getTrackDz() const { return mTrackDz; }

void setDistanceToBadChannel(float dist) { mDistToBadChannel = dist; }
float getDistanceToBadChannel() const { return mDistToBadChannel; }
[[nodiscard]] float getDistanceToBadChannel() const { return mDistToBadChannel; }

void setNCells(int n) { mNCells = n; }
int getNCells() const { return mNCells; }
[[nodiscard]] int getNCells() const { return mNCells; }

///
/// Set the array of cell indices.
Expand All @@ -133,7 +132,7 @@ class AnalysisCluster
mCellsIndices = array;
}

const std::vector<unsigned short>& getCellsIndices() const { return mCellsIndices; }
[[nodiscard]] const std::vector<unsigned short>& getCellsIndices() const { return mCellsIndices; }

///
/// Set the array of cell amplitude fractions.
Expand All @@ -143,53 +142,51 @@ class AnalysisCluster
{
mCellsAmpFraction = array;
}
const std::vector<float>& getCellsAmplitudeFraction() const { return mCellsAmpFraction; }
[[nodiscard]] const std::vector<float>& getCellsAmplitudeFraction() const { return mCellsAmpFraction; }

int getCellIndex(int i) const
[[nodiscard]] int getCellIndex(int i) const
{
if (i >= 0 && i < mNCells) {
return mCellsIndices[i];
} else {
throw CellOutOfRangeException(i);
}
throw CellOutOfRangeException(i);
}

float getCellAmplitudeFraction(int i) const
[[nodiscard]] float getCellAmplitudeFraction(int i) const
{
if (i >= 0 && i < mNCells) {
return mCellsAmpFraction[i];
} else {
throw CellOutOfRangeException(i);
}
throw CellOutOfRangeException(i);
}

bool getIsExotic() const { return mIsExotic; }
[[nodiscard]] bool getIsExotic() const { return mIsExotic; }
void setIsExotic(bool b) { mIsExotic = b; }

void setClusterTime(float time)
{
mTime = time;
}

float getClusterTime() const
[[nodiscard]] float getClusterTime() const
{
return mTime;
}

int getIndMaxInput() const { return mInputIndMax; }
[[nodiscard]] int getIndMaxInput() const { return mInputIndMax; }
void setIndMaxInput(const int ind) { mInputIndMax = ind; }

float getCoreEnergy() const { return mCoreEnergy; }
[[nodiscard]] float getCoreEnergy() const { return mCoreEnergy; }
void setCoreEnergy(float energy) { mCoreEnergy = energy; }

float getFCross() const { return mFCross; }
[[nodiscard]] float getFCross() const { return mFCross; }
void setFCross(float fCross) { mFCross = fCross; }

///
/// Returns TLorentzVector with momentum of the cluster. Only valid for clusters
/// identified as photons or pi0 (overlapped gamma) produced on the vertex
/// Vertex can be recovered with esd pointer doing:
TLorentzVector getMomentum(std::array<const float, 3> vertexPosition) const;
[[nodiscard]] TLorentzVector getMomentum(std::array<const float, 3> vertexPosition) const;

protected:
/// TODO to replace later by o2::MCLabel when implementing the MC handling
Expand Down Expand Up @@ -230,9 +227,8 @@ class AnalysisCluster

int mInputIndMax = -1; ///< index of digit/cell with max energy

ClassDefNV(AnalysisCluster, 2);
ClassDefNV(AnalysisCluster, 3);
};

} // namespace emcal
} // namespace o2
} // namespace o2::emcal
#endif // ANALYSISCLUSTER_H
43 changes: 20 additions & 23 deletions DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/Cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
#ifndef ALICEO2_EMCAL_CELL_H_
#define ALICEO2_EMCAL_CELL_H_

#include <bitset>
#include "DataFormatsEMCAL/Constants.h"

#include <cfloat>
#include <climits>
#include "DataFormatsEMCAL/Constants.h"

namespace o2
{
namespace emcal
namespace o2::emcal
{

/// \class Cell
Expand Down Expand Up @@ -90,72 +88,72 @@ class Cell

/// \brief Get the tower ID
/// \return Tower ID
short getTower() const { return mTowerID; }
[[nodiscard]] short getTower() const { return mTowerID; }

/// \brief Set the time stamp
/// \param timestamp Time in ns
void setTimeStamp(float timestamp) { mTimestamp = timestamp; }

/// \brief Get the time stamp
/// \return Time in ns
float getTimeStamp() const { return mTimestamp; }
[[nodiscard]] float getTimeStamp() const { return mTimestamp; }

/// \brief Set the energy of the cell
/// \brief Energy of the cell in GeV
void setEnergy(float energy) { mEnergy = energy; }

/// \brief Get the energy of the cell
/// \return Energy of the cell
float getEnergy() const { return mEnergy; }
[[nodiscard]] float getEnergy() const { return mEnergy; }

/// \brief Set the amplitude of the cell
/// \param amplitude Cell amplitude
void setAmplitude(float amplitude) { setEnergy(amplitude); }

/// \brief Get cell amplitude
/// \return Cell amplitude in GeV
float getAmplitude() const { return getEnergy(); }
[[nodiscard]] float getAmplitude() const { return getEnergy(); }

/// \brief Set the type of the cell
/// \param ctype Type of the cell (HIGH_GAIN, LOW_GAIN, LEDMON, TRU)
void setType(ChannelType_t ctype) { mChannelType = ctype; }

/// \brief Get the type of the cell
/// \return Type of the cell (HIGH_GAIN, LOW_GAIN, LEDMON, TRU)
ChannelType_t getType() const { return mChannelType; }
[[nodiscard]] ChannelType_t getType() const { return mChannelType; }

/// \brief Check whether the cell is of a given type
/// \param ctype Type of the cell (HIGH_GAIN, LOW_GAIN, LEDMON, TRU)
/// \return True if the type of the cell matches the requested type, false otherwise
bool isChannelType(ChannelType_t ctype) const { return mChannelType == ctype; }
[[nodiscard]] bool isChannelType(ChannelType_t ctype) const { return mChannelType == ctype; }

/// \brief Mark cell as low gain cell
void setLowGain() { setType(ChannelType_t::LOW_GAIN); }

/// \brief Check whether the cell is a low gain cell
/// \return True if the cell type is low gain, false otherwise
Bool_t getLowGain() const { return isChannelType(ChannelType_t::LOW_GAIN); }
[[nodiscard]] Bool_t getLowGain() const { return isChannelType(ChannelType_t::LOW_GAIN); }

/// \brief Mark cell as high gain cell
void setHighGain() { setType(ChannelType_t::HIGH_GAIN); }

/// \brief Check whether the cell is a high gain cell
/// \return True if the cell type is high gain, false otherwise
Bool_t getHighGain() const { return isChannelType(ChannelType_t::HIGH_GAIN); };
[[nodiscard]] Bool_t getHighGain() const { return isChannelType(ChannelType_t::HIGH_GAIN); };

/// \brief Mark cell as LED monitor cell
void setLEDMon() { setType(ChannelType_t::LEDMON); }

/// \brief Check whether the cell is a LED monitor cell
/// \return True if the cell type is LED monitor, false otherwise
Bool_t getLEDMon() const { return isChannelType(ChannelType_t::LEDMON); }
[[nodiscard]] Bool_t getLEDMon() const { return isChannelType(ChannelType_t::LEDMON); }

/// \brief Mark cell as TRU cell
void setTRU() { setType(ChannelType_t::TRU); }

/// \brief Check whether the cell is a TRU cell
/// \return True if the cell type is TRU, false otherwise
Bool_t getTRU() const { return isChannelType(ChannelType_t::TRU); }
[[nodiscard]] Bool_t getTRU() const { return isChannelType(ChannelType_t::TRU); }

/// \brief Apply compression as done during writing to / reading from CTF
/// \param version Encoder version
Expand All @@ -181,7 +179,7 @@ class Cell
/// \return Encoded bit representation
///
/// Same as getTower - no compression applied for tower ID
uint16_t getTowerIDEncoded() const;
[[nodiscard]] uint16_t getTowerIDEncoded() const;

/// \brief Get encoded bit representation of timestamp (for CTF)
/// \return Encoded bit representation
Expand All @@ -191,7 +189,7 @@ class Cell
/// be stored is from -1023 to 1023 ns. In case the
/// range is exceeded the time is set to the limit
/// of the range.
uint16_t getTimeStampEncoded() const;
[[nodiscard]] uint16_t getTimeStampEncoded() const;

/// \brief Get encoded bit representation of energy (for CTF)
/// \param version Encoding verions
Expand All @@ -203,11 +201,11 @@ class Cell
/// the limits is provided the energy is
/// set to the limits (0 in case of negative
/// energy, 250. in case of energies > 250 GeV)
uint16_t getEnergyEncoded(EncoderVersion version = EncoderVersion::EncodingV2) const;
[[nodiscard]] uint16_t getEnergyEncoded(EncoderVersion version = EncoderVersion::EncodingV2) const;

/// \brief Get encoded bit representation of cell type (for CTF)
/// \return Encoded bit representation
uint16_t getCellTypeEncoded() const;
[[nodiscard]] uint16_t getCellTypeEncoded() const;

void initializeFromPackedBitfieldV0(const char* bitfield);

Expand All @@ -231,8 +229,8 @@ class Cell
private:
/// \brief Set cell energy from encoded bit representation (from CTF)
/// \param energyBits Bit representation of energy
/// \param cellTypeBits Bit representation of cell type
void setEnergyEncoded(uint16_t energyBits, uint16_t cellTypeBits, EncoderVersion version = EncoderVersion::EncodingV1);
/// \param channelTypeBits Bit representation of cell type
void setEnergyEncoded(uint16_t energyBits, uint16_t channelTypeBits, EncoderVersion version = EncoderVersion::EncodingV1);

/// \brief Set cell time from encoded bit representation (from CTF)
/// \param timestampBits Bit representation of timestamp
Expand All @@ -259,7 +257,6 @@ class Cell
/// \param cell Cell to be printed
/// \return Stream after printing
std::ostream& operator<<(std::ostream& stream, const Cell& cell);
} // namespace emcal
} // namespace o2
} // namespace o2::emcal

#endif
Loading