Skip to content
Merged
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
4 changes: 3 additions & 1 deletion DataFormats/Detectors/CPV/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ o2_add_library(DataFormatsCPV
src/Digit.cxx
src/Cluster.cxx
src/TriggerRecord.cxx
src/CTF.cxx
PUBLIC_LINK_LIBRARIES O2::CommonDataFormat
O2::Headers
O2::MathUtils
Expand All @@ -25,4 +26,5 @@ o2_target_root_dictionary(DataFormatsCPV
HEADERS include/DataFormatsCPV/CPVBlockHeader.h
include/DataFormatsCPV/Digit.h
include/DataFormatsCPV/Cluster.h
include/DataFormatsCPV/TriggerRecord.h)
include/DataFormatsCPV/TriggerRecord.h
include/DataFormatsCPV/CTF.h)
57 changes: 57 additions & 0 deletions DataFormats/Detectors/CPV/include/DataFormatsCPV/CTF.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// \file CTF.h
/// \author ruben.shahoyan@cern.ch
/// \brief Definitions for CPV CTF data

#ifndef O2_CPV_CTF_H
#define O2_CPV_CTF_H

#include <vector>
#include <Rtypes.h>
#include "DetectorsCommonDataFormats/EncodedBlocks.h"
#include "DataFormatsCPV/TriggerRecord.h"
#include "DataFormatsCPV/Cluster.h"

namespace o2
{
namespace cpv
{

/// Header for a single CTF
struct CTFHeader {
uint32_t nTriggers = 0; /// number of triggers
uint32_t nClusters = 0; /// number of referred cells
uint32_t firstOrbit = 0; /// orbit of 1st trigger
uint16_t firstBC = 0; /// bc of 1st trigger

ClassDefNV(CTFHeader, 1);
};

/// wrapper for the Entropy-encoded triggers and cells of the TF
struct CTF : public o2::ctf::EncodedBlocks<CTFHeader, 7, uint32_t> {

static constexpr size_t N = getNBlocks();
enum Slots { BLC_bcIncTrig,
BLC_orbitIncTrig,
BLC_entriesTrig,
BLC_posX,
BLC_posZ,
BLC_energy,
BLC_status
};
ClassDefNV(CTF, 1);
};

} // namespace cpv
} // namespace o2

#endif
64 changes: 50 additions & 14 deletions DataFormats/Detectors/CPV/include/DataFormatsCPV/Cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,27 @@ class Geometry;
/// \class Cluster
/// \brief Contains CPV cluster parameters

constexpr float kMinX = -72.32; // Minimal coordinate in X direction
constexpr float kStepX = 0.0025; // digitization step in X direction
constexpr float kMinZ = -63.3; // Minimal coordinate in Z direction
constexpr float kStepZ = 0.002; // digitization step in Z direction
constexpr float kStepE = 1.; // Amplitude digitization step

class Cluster
{

union CluStatus {
uint8_t mBits;
struct {
uint8_t multiplicity : 5; // Pad multiplicty, bits 0-4
uint8_t module : 2; // module number, bits 5-6
uint8_t unfolded : 1; // unfolded bit, bit 7
};
};

public:
Cluster() = default;
Cluster(char mult, char mod, char exMax, float x, float z, float e) : mMulDigit(mult), mModule(mod), mNExMax(exMax), mLocalPosX(x), mLocalPosZ(z), mEnergy(e) {}
Cluster(const Cluster& clu) = default;

~Cluster() = default;
Expand All @@ -42,13 +58,6 @@ class Cluster
void setEnergy(float e) { mEnergy = e; }
float getEnergy() const { return mEnergy; }

void getPosition(float& posX, float& posY, float& posZ) const
{
posX = mPosX;
posX = mPosY;
posZ = mPosZ;
}

void getLocalPosition(float& posX, float& posZ) const
{
posX = mLocalPosX;
Expand All @@ -58,24 +67,51 @@ class Cluster
// 0: was no unfolging, -1: unfolding failed
char getModule() const { return mModule; } // CPV module of a current cluster

int getLabel() const { return mLabel; } //Index in MCContainer entry
void setLabel(int l) { mLabel = l; }

// 0: was no unfolging, -1: unfolding failed
void setNExMax(char nmax = 1) { mNExMax = nmax; }
char getNExMax() const { return mNExMax; } // Number of maxima found in cluster in unfolding:
// 0: was no unfolging, -1: unfolding failed

// raw access for CTF encoding
uint16_t getPackedPosX() const { return uint16_t((mLocalPosX - kMinX) / kStepX); }
void setPackedPosX(uint16_t v) { mLocalPosX = kMinX + kStepX * v; }

uint16_t getPackedPosZ() const { return uint16_t((mLocalPosZ - kMinZ) / kStepZ); }
void setPackedPosZ(uint16_t v) { mLocalPosZ = kMinZ + kStepZ * v; }

uint8_t getPackedEnergy() const { return uint8_t(std::min(255, int(mEnergy / kStepE))); }
void setPackedEnergy(uint16_t v) { mEnergy = v * kStepE; }

uint8_t getPackedClusterStatus() const
{
CluStatus s = {0};
s.multiplicity = mMulDigit;
s.module = mModule;
s.unfolded = mNExMax > 1;
return s.mBits;
}
void setPackedClusterStatus(uint8_t v)
{
CluStatus s = {v};
mMulDigit = s.multiplicity;
mModule = s.module;
mNExMax = s.unfolded ? 1 : 2;
}

void setPacked(uint16_t posX, uint16_t posZ, uint8_t en, uint8_t status)
{
setPackedPosX(posX);
setPackedPosZ(posZ);
setPackedEnergy(en);
setPackedClusterStatus(status);
}

protected:
char mMulDigit = 0; ///< Digit nultiplicity
char mModule = 0; ///< Module number
char mNExMax = -1; ///< number of (Ex-)maxima before unfolding
int mLabel = -1; ///< Ref to entry in MCTruthContainer with list of labels
float mLocalPosX = 0.; ///< Center of gravity position in local module coordunates (phi direction)
float mLocalPosZ = 0.; ///< Center of gravity position in local module coordunates (z direction)
float mPosX = 0.; ///< Center of gravity position in global coordinates
float mPosY = 0.; ///< Center of gravity position in global coordinates
float mPosZ = 0.; ///< Center of gravity position in global coordinates
float mEnergy = 0.; ///< full energy of a cluster

ClassDefNV(Cluster, 1);
Expand Down
12 changes: 6 additions & 6 deletions DataFormats/Detectors/CPV/include/DataFormatsCPV/Digit.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Digit : public DigitBase
/// \brief Main Digit constructor
/// \param cell absId of a cell, amplitude energy deposited in a cell, time time measured in cell, label label of a
/// particle in case of MC \return constructed Digit
Digit(short cell, float amplitude, int label);
Digit(unsigned short cell, float amplitude, int label);

/// \brief Digit constructor from Hit
/// \param CPV Hit
Expand Down Expand Up @@ -93,8 +93,8 @@ class Digit : public DigitBase
Digit& operator+=(const Digit& other); //

/// \brief Absolute sell id
short getAbsId() const { return mAbsId; }
void setAbsId(short cellId) { mAbsId = cellId; }
unsigned short getAbsId() const { return mAbsId; }
void setAbsId(unsigned short cellId) { mAbsId = cellId; }

/// \brief Energy deposited in a cell
float getAmplitude() const { return mAmplitude; }
Expand All @@ -109,9 +109,9 @@ class Digit : public DigitBase
private:
// friend class boost::serialization::access;

short mAbsId = 0; ///< pad index (absolute pad ID)
int mLabel = -1; ///< Index of the corresponding entry/entries in the MC label array
float mAmplitude = 0; ///< Amplitude
unsigned short mAbsId = 0; ///< pad index (absolute pad ID)
int mLabel = -1; ///< Index of the corresponding entry/entries in the MC label array
float mAmplitude = 0; ///< Amplitude

ClassDefNV(Digit, 2);
};
Expand Down
63 changes: 63 additions & 0 deletions DataFormats/Detectors/CPV/include/DataFormatsCPV/RawFormats.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#ifndef ALICEO2_CPV_RAWFORMATS_H
#define ALICEO2_CPV_RAWFORMATS_H

namespace o2
{

namespace cpv
{

union PadWord {
uint32_t mDataWord;
struct {
uint32_t charge : 11; ///< Bits 0 - 10 : charge
uint32_t address : 6; ///< Bits 12 - 17 : address (0..47)
uint32_t dilogic : 4; ///< Bits 18 - 21 : dilogic (1..10)
uint32_t row : 6; ///< Bits 22 - 26 : raw (1..24)
uint32_t zero : 1; ///< Bits 27 - 27 : zeroed so we can distinguish it from the EoE
};
};

union EoEWord {
uint32_t mDataWord;
struct {
uint32_t nword : 7; ///< Bits 0 - 6 : word counter (0...47)
uint32_t en : 11; ///< Bits 7 - 17 : event number -- not used
uint32_t dilogic : 4; ///< Bits 18 - 21 : dilogic (1..10)
uint32_t row : 6; ///< Bits 22 - 26 : raw (1..24)
uint32_t checkbit : 1; ///< Bits 27 - 27 : bit 27 is always 1 by definition of EoE
};
};

union SegMarkerWord {
uint32_t mDataWord;
struct {
uint32_t row : 8; ///< Bits 0 - 7 : segment 0,1,2 charge
uint32_t nwords : 12; ///< Bits 8 - 19 : number of words in the segment
uint32_t marker : 12; ///< Bits 20 - 31: ab0 the segment marker word
};
};

union RowMarkerWord {
uint32_t mDataWord;
struct {
uint32_t marker : 16; ///< Bits 0,15); //the marker word
uint32_t nwords : 16; ///< Bits 16 - 31 : number of words written after row marker (digits and EoE)
};
};

} // namespace cpv

} // namespace o2

#endif
15 changes: 15 additions & 0 deletions DataFormats/Detectors/CPV/src/CTF.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#include <stdexcept>
#include <cstring>
#include "DataFormatsCPV/CTF.h"

using namespace o2::cpv;
4 changes: 4 additions & 0 deletions DataFormats/Detectors/CPV/src/DataFormatsCPVLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@
#pragma link C++ class std::vector < o2::cpv::Cluster> + ;
#pragma link C++ class std::vector < o2::cpv::TriggerRecord> + ;

#pragma link C++ struct o2::cpv::CTFHeader + ;
#pragma link C++ struct o2::cpv::CTF + ;
#pragma link C++ class o2::ctf::EncodedBlocks < o2::cpv::CTFHeader, 7, uint32_t> + ;

#endif
2 changes: 1 addition & 1 deletion DataFormats/Detectors/CPV/src/Digit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using namespace o2::cpv;

ClassImp(Digit);

Digit::Digit(short absId, float amplitude, int label)
Digit::Digit(unsigned short absId, float amplitude, int label)
: DigitBase(0), mAmplitude(amplitude), mAbsId(absId), mLabel(label)
{
}
Expand Down
9 changes: 7 additions & 2 deletions Detectors/CPV/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@
# submit itself to any jurisdiction.

o2_add_library(CPVBase
SOURCES src/Geometry.cxx src/Hit.cxx src/CPVSimParams.cxx
SOURCES src/Geometry.cxx
src/Hit.cxx
src/CPVSimParams.cxx
src/RCUTrailer.cxx
PUBLIC_LINK_LIBRARIES O2::SimulationDataFormat)

o2_target_root_dictionary(CPVBase
HEADERS include/CPVBase/Geometry.h
include/CPVBase/Hit.h include/CPVBase/CPVSimParams.h)
include/CPVBase/Hit.h
include/CPVBase/CPVSimParams.h
include/CPVBase/RCUTrailer.h)
6 changes: 3 additions & 3 deletions Detectors/CPV/base/include/CPVBase/CPVSimParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ struct CPVSimParams : public o2::conf::ConfigurableParamHelper<CPVSimParams> {

//Parameters used in electronic noise calculation and thresholds (Digitizer)
bool mApplyDigitization = true; ///< if energy digitization should be applied
float mZSthreshold = 0.005; ///< Zero Suppression threshold
float mZSthreshold = 0.01; ///< Zero Suppression threshold
float mADCWidth = 0.005; ///< Widht of ADC channel used for energy digitization
float mNoise = 0.03; ///< charge noise in one pad
float mNoise = 0.01; ///< charge noise in one pad
float mCoeffToNanoSecond = 1.e+9; ///< Conversion for time units
float mSortingDelta = 0.1; ///< used in sorting clusters inverse sorting band in cm

//Parameters used in clusterization
float mDigitMinEnergy = 0.005; ///< Minimal amplitude of a digit to be used in cluster
float mDigitMinEnergy = 0.01; ///< Minimal amplitude of a digit to be used in cluster
float mClusteringThreshold = 0.050; ///< Seed digit minimal amplitude
float mUnfogingEAccuracy = 1.e-3; ///< Accuracy of energy calculation in unfoding prosedure (GeV)
float mUnfogingXZAccuracy = 1.e-1; ///< Accuracy of position calculation in unfolding procedure (cm)
Expand Down
35 changes: 27 additions & 8 deletions Detectors/CPV/base/include/CPVBase/Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ class Geometry
static constexpr short kNumberOfCPVPadsZ = 60;
static constexpr float kCPVPadSizePhi = 1.13;
static constexpr float kCPVPadSizeZ = 2.1093;
//for hwaddress
static constexpr short kNPAD = 48;
static constexpr short kNDilogic = 10;
static constexpr short kNRow = 16;
static constexpr short kNDDL = 4;

/// Available numbering schems:
/// relative pad coordinates
/// relId[3]={Module, phi col, z row} where Module=1..3, phi col=0..127, z row=0..59
/// Absolute pad coordunate
/// absId=0..128*60*3=23040
/// Raw addresses:
/// DDL corresponds to one module: ddl=Module-1
/// each module consist of 16 columns of width 8 pads: row=0..15
/// Each column consists of 10 dilogics (in z direction) dilogic=0...9
/// Ecah dilogic contains 8*6 pads: hwaddress=0...48

///
/// Default constructor.
Expand Down Expand Up @@ -55,7 +71,7 @@ class Geometry
// = 1 are neighbour
// = 2 are not neighbour but do not continue searching
// =-1 are not neighbour, continue searching, but do not look before d2 next time
static int areNeighbours(short absId1, short absId2);
static short areNeighbours(unsigned short absId1, unsigned short absId2);

///
/// \return AbsId index of the CPV cell
Expand All @@ -64,14 +80,17 @@ class Geometry
/// \param strip: strip number
// \param cell: cell in strip number
///
static short relToAbsId(char moduleNumber, int iphi, int iz);
static bool absToRelNumbering(short absId, short* relid);
static char absIdToModule(short absId);
static void absIdToRelPosInModule(short absId, float& x, float& z);
static bool relToAbsNumbering(const short* relId, short& absId);
static unsigned short relToAbsId(short moduleNumber, short iphi, short iz);
static bool absToRelNumbering(unsigned short absId, short* relid);
static short absIdToModule(unsigned short absId);
static void absIdToRelPosInModule(unsigned short absId, float& x, float& z);
static bool relToAbsNumbering(const short* relId, unsigned short& absId);

static void hwaddressToAbsId(short ddl, short row, short dilogic, short hw, unsigned short& absId);
static void absIdToHWaddress(unsigned short absId, short& ddl, short& row, short& dilogic, short& hw);

static int getTotalNPads() { return kNumberOfCPVPadsPhi * kNumberOfCPVPadsZ * 3; }
static bool IsPadExists(short absId)
static unsigned short getTotalNPads() { return kNumberOfCPVPadsPhi * kNumberOfCPVPadsZ * 4; }
static bool IsPadExists(unsigned short absId)
{
return absId > 0 && absId <= getTotalNPads();
} // TODO: evaluate from real geometry
Expand Down
Loading