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
8 changes: 4 additions & 4 deletions Detectors/CPV/base/include/CPVBase/CPVSimParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ struct CPVSimParams : public o2::conf::ConfigurableParamHelper<CPVSimParams> {
std::string mCCDBPath = "localtest"; ///< use "localtest" to avoid connecting ccdb server, otherwise use ccdb-test.cern.ch

//Parameters used in conversion of deposited energy to APD response
int mnCellZ = 128;
int mnCellX = 60;
float mPadSizeZ = 1.13; ///< overall size of CPV active size
float mPadSizeX = 2.1093; ///< in phi and z directions
int mnCellX = 128;
int mnCellZ = 60;
float mPadSizeX = 1.13; ///< overall size of CPV active size
float mPadSizeZ = 2.1093; ///< in phi and z directions
float mDetR = 0.1; ///< Relative energy fluctuation in track for 100 e-
float mdEdx = 4.0; ///< Average energy loss in CPV;
int mNgamz = 5; ///< Ionization size in Z
Expand Down
8 changes: 4 additions & 4 deletions Detectors/CPV/base/include/CPVBase/Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ class Geometry
static constexpr short kNPAD = 48;
static constexpr short kNDilogic = 10;
static constexpr short kNRow = 16;
static constexpr short kNDDL = 3;
static constexpr short kNMod = 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
/// relId[3]={Module, phi col, z row} where Module=2..4, phi col=0..127, z row=0..59
/// Absolute pad coordunate
/// absId=0..128*60*3=23040
/// absId=0..128*60*3-1=23039
/// Raw addresses:
/// DDL corresponds to one module: ddl=Module-1
/// DDL corresponds to one module: ddl=Module
/// 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
Expand Down
31 changes: 17 additions & 14 deletions Detectors/CPV/base/src/Geometry.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ClassImp(Geometry);
unsigned short Geometry::relToAbsId(short moduleNumber, short iphi, short iz)
{
//converts module number, phi and z coordunates to absId
return kNumberOfCPVPadsPhi * kNumberOfCPVPadsZ * (moduleNumber - 1) + kNumberOfCPVPadsZ * iz + iphi;
return kNumberOfCPVPadsPhi * kNumberOfCPVPadsZ * (moduleNumber - 2) + kNumberOfCPVPadsZ * iphi + iz;
}

bool Geometry::absToRelNumbering(unsigned short absId, short* relid)
Expand All @@ -29,8 +29,8 @@ bool Geometry::absToRelNumbering(unsigned short absId, short* relid)
// relid[2] = Row number inside a CPV module (Z coordinate)

const short nCPV = kNumberOfCPVPadsPhi * kNumberOfCPVPadsZ;
relid[0] = absId / nCPV + 1;
absId -= (relid[0] - 1) * nCPV;
relid[0] = absId / nCPV + 2;
absId -= (relid[0] - 2) * nCPV;
relid[1] = absId / kNumberOfCPVPadsZ;
relid[2] = absId % kNumberOfCPVPadsZ;

Expand All @@ -39,7 +39,7 @@ bool Geometry::absToRelNumbering(unsigned short absId, short* relid)
short Geometry::absIdToModule(unsigned short absId)
{

return 1 + absId / (kNumberOfCPVPadsPhi * kNumberOfCPVPadsZ);
return 2 + absId / (kNumberOfCPVPadsPhi * kNumberOfCPVPadsZ);
}

short Geometry::areNeighbours(unsigned short absId1, unsigned short absId2)
Expand Down Expand Up @@ -95,29 +95,31 @@ bool Geometry::relToAbsNumbering(const short* relId, unsigned short& absId)
{

absId =
(relId[0] - 1) * kNumberOfCPVPadsPhi * kNumberOfCPVPadsZ + // the offset of PHOS modules
(relId[0] - 2) * kNumberOfCPVPadsPhi * kNumberOfCPVPadsZ + // the offset of PHOS modules
relId[1] * kNumberOfCPVPadsZ + // the offset along phi
relId[2]; // the offset along z

return true;
}
void Geometry::hwaddressToAbsId(short ddl, short row, short dilog, short hw, unsigned short& absId)
void Geometry::hwaddressToAbsId(short /*ddl*/, short row, short dilog, short hw, unsigned short& absId)
{

short relid[3] = {short(ddl + 1), short(8 * row + hw % 8), short(6 * dilog + hw / 8)};
short mod = row / 16;
row = row % 16;
short relid[3] = {short(mod + 2), short(8 * row + hw % 8), short(6 * dilog + hw / 8)};

relToAbsNumbering(relid, absId);
}

void Geometry::absIdToHWaddress(unsigned short absId, short& ddl, short& row, short& dilogic, short& hw)
void Geometry::absIdToHWaddress(unsigned short absId, short& mod, short& row, short& dilogic, short& hw)
{
// Convert absId to hw address
// Arguments: w32,ddl,row,dilogic,address where to write the results
// Arguments: w32,mod,row,dilogic,address where to write the results
// return row in range 0...47, packing rows from all modules in common numeration

short relid[3];
absToRelNumbering(absId, relid);

ddl = relid[0] - 1; // DDL# 0..2
mod = relid[0]; // DDL# 2..4
row = relid[1] / 8; // row# 0..16
dilogic = relid[2] / 6; // Dilogic# 0..10
hw = relid[1] % 8 + 8 * (relid[2] % 6); // Address 0..47
Expand All @@ -127,23 +129,24 @@ void Geometry::absIdToHWaddress(unsigned short absId, short& ddl, short& row, sh
hw = 0;
dilogic = 0;
row = 0;
ddl = 0;
mod = 0;
return;
}
if (dilogic < 0 || dilogic > kNDilogic) {
LOG(ERROR) << "Wrong dilogic address: dilogic=" << dilogic << " > kNDilogic=" << kNDilogic;
hw = 0;
dilogic = 0;
row = 0;
ddl = 0;
mod = 0;
return;
}
if (row < 0 || row > kNRow) {
LOG(ERROR) << "Wrong row address: row=" << row << " > kNRow=" << kNRow;
hw = 0;
dilogic = 0;
row = 0;
ddl = 0;
mod = 0;
return;
}
row += (mod - 2) * 16;
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ void CPVGainCalibDevice::run(o2::framework::ProcessingContext& ctx)
auto& header = rawreader.getRawHeader();
auto triggerBC = o2::raw::RDHUtils::getTriggerBC(header);
auto triggerOrbit = o2::raw::RDHUtils::getTriggerOrbit(header);
auto ddl = o2::raw::RDHUtils::getFEEID(header);
//
if (ddl > o2::cpv::Geometry::kNDDL) { //only 4 correct DDLs
LOG(ERROR) << "DDL=" << ddl;
continue; //skip STU ddl
}
// use the altro decoder to decode the raw data, and extract the RCU trailer
o2::cpv::RawDecoder decoder(rawreader);
RawErrorType_t err = decoder.decode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ void CPVPedestalCalibDevice::run(o2::framework::ProcessingContext& ctx)
auto& header = rawreader.getRawHeader();
auto triggerBC = o2::raw::RDHUtils::getTriggerBC(header);
auto triggerOrbit = o2::raw::RDHUtils::getTriggerOrbit(header);
auto ddl = o2::raw::RDHUtils::getFEEID(header);
if (ddl > o2::cpv::Geometry::kNDDL) { //only 4 correct DDLs
LOG(ERROR) << "DDL=" << ddl;
continue; //skip STU ddl
}
// use the decoder to decode the raw data, and extract signals
o2::cpv::RawDecoder decoder(rawreader);
RawErrorType_t err = decoder.decode();
Expand Down
52 changes: 23 additions & 29 deletions Detectors/CPV/reconstruction/src/RawDecoder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ RawErrorType_t RawDecoder::decode()
{

auto& header = mRawReader.getRawHeader();
short ddl = o2::raw::RDHUtils::getFEEID(header);
short mod = o2::raw::RDHUtils::getFEEID(header);
mDigits.clear();

auto payloadwords = mRawReader.getPayload();
if (payloadwords.size() == 0) {
mErrors.emplace_back(ddl, 0, 0, 0, kNO_PAYLOAD); //add error
LOG(ERROR) << "Empty payload for DDL=" << ddl;
mErrors.emplace_back(mod, 0, 0, 0, kNO_PAYLOAD); //add error
LOG(ERROR) << "Empty payload for DDL=" << mod;
return kNO_PAYLOAD;
}

Expand All @@ -56,47 +56,41 @@ RawErrorType_t RawDecoder::readChannels()
{
mChannelsInitialized = false;
auto& header = mRawReader.getRawHeader();
short ddl = o2::raw::RDHUtils::getFEEID(header); //Current fee/ddl
short mod = o2::raw::RDHUtils::getLinkID(header) + 2; //Current module

auto& payloadwords = mRawReader.getPayload();
//start reading from the end
auto currentWord = payloadwords.rbegin();
while (currentWord != payloadwords.rend()) {
SegMarkerWord sw = {*currentWord++}; //first get value, then increment
if (sw.marker != 2736) { //error
mErrors.emplace_back(ddl, 17, 2, 0, kSEGMENT_HEADER_ERROR); //add error for non-existing row
SegMarkerWord sw = {*currentWord++}; //first get value, then increment
if (sw.marker != 2736) { //error
LOG(ERROR) << "Seg. marker word not in place: marker=" << sw.marker << " expected " << 2736 << " word=" << sw.mDataWord;
mErrors.emplace_back(mod, 17, 2, 0, kSEGMENT_HEADER_ERROR); //add error for non-existing row
//try adding this as padWord
addDigit(sw.mDataWord, ddl);
addDigit(sw.mDataWord, mod);
continue;
}
short nSegWords = sw.nwords;
short currentRow = sw.row;
short nEoE = 0;
while (nSegWords > 0 && currentWord != payloadwords.rend()) {
EoEWord ew = {*currentWord++};
short currentRow = ew.row;
nSegWords--;
if (ew.checkbit != 1) { //error
LOG(ERROR) << " error EoE, ddl" << ddl << " row " << currentRow;
mErrors.emplace_back(ddl, currentRow, 11, 0, kEOE_HEADER_ERROR); //add error
LOG(ERROR) << " error EoE, mod" << mod << " row " << currentRow;
mErrors.emplace_back(mod, currentRow, 11, 0, kEOE_HEADER_ERROR); //add error
//try adding this as padWord
addDigit(ew.mDataWord, ddl);
addDigit(ew.mDataWord, mod);
continue;
}
nEoE++;
short nEoEwords = ew.nword;
short currentDilogic = ew.dilogic;
if (ew.row != currentRow) {
LOG(ERROR) << "Row in EoE=" << ew.row << " != expected row " << currentRow;
mErrors.emplace_back(ddl, currentRow, currentDilogic, 0, kEOE_HEADER_ERROR); //add error
//try adding this as padWord
addDigit(ew.mDataWord, ddl);
continue;
}
if (currentDilogic < 0 || currentDilogic > 10) {
LOG(ERROR) << "wrong Dilogic in EoE=" << currentDilogic;
mErrors.emplace_back(ddl, currentRow, currentDilogic, 0, kEOE_HEADER_ERROR); //add error
mErrors.emplace_back(mod, currentRow, currentDilogic, 0, kEOE_HEADER_ERROR); //add error
//try adding this as padWord
addDigit(ew.mDataWord, ddl);
addDigit(ew.mDataWord, mod);
continue;
}
while (nEoEwords > 0 && currentWord != payloadwords.rend()) {
Expand All @@ -105,27 +99,27 @@ RawErrorType_t RawDecoder::readChannels()
nSegWords--;
if (pad.zero != 0) {
LOG(ERROR) << "bad pad, word=" << pad.mDataWord;
mErrors.emplace_back(ddl, currentRow, currentDilogic, 49, kPADERROR); //add error and skip word
mErrors.emplace_back(mod, currentRow, currentDilogic, 49, kPADERROR); //add error and skip word
continue;
}
//check paw/pad indexes
if (pad.row != currentRow || pad.dilogic != currentDilogic) {
LOG(ERROR) << "RawPad " << pad.row << " != currentRow=" << currentRow << "dilogicPad=" << pad.dilogic << "!= currentDilogic=" << currentDilogic;
mErrors.emplace_back(ddl, short(pad.row), short(pad.dilogic), short(pad.address), kPadAddress); //add error and skip word
mErrors.emplace_back(mod, short(pad.row), short(pad.dilogic), short(pad.address), kPadAddress); //add error and skip word
//do not skip, try adding using info from pad
}
addDigit(pad.mDataWord, ddl);
addDigit(pad.mDataWord, mod);
} //pads in EoE
if (nEoE % 10 == 0) { // kNDilogic = 10; ///< Number of dilogic per row
if (currentWord != payloadwords.rend()) { //Read row HEader
RowMarkerWord rw = {*currentWord++};
nSegWords--;
currentRow--;
if (rw.marker != 13992) {
LOG(ERROR) << "Error in row marker:" << rw.marker << "row header word=" << rw.mDataWord;
mErrors.emplace_back(ddl, currentRow, 11, 0, kPadAddress); //add error and skip word
LOG(ERROR) << "Error in row marker: " << rw.marker << "!=13992, row header word=" << rw.mDataWord;
mErrors.emplace_back(mod, currentRow, 11, 0, kPadAddress); //add error and skip word
//try adding digit assuming this is pad word
addDigit(rw.mDataWord, ddl);
addDigit(rw.mDataWord, mod);
}
}
}
Expand All @@ -151,7 +145,7 @@ const std::vector<uint32_t>& RawDecoder::getDigits() const
return mDigits;
}

void RawDecoder::addDigit(uint32_t w, short ddl)
void RawDecoder::addDigit(uint32_t w, short mod)
{

PadWord pad = {w};
Expand All @@ -162,7 +156,7 @@ void RawDecoder::addDigit(uint32_t w, short ddl)
short dilogicPad = pad.dilogic;
short hw = pad.address;
unsigned short absId;
o2::cpv::Geometry::hwaddressToAbsId(ddl, rowPad, dilogicPad, hw, absId);
o2::cpv::Geometry::hwaddressToAbsId(mod, rowPad, dilogicPad, hw, absId);

AddressCharge ac = {0};
ac.Address = absId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class Detector : public o2::base::DetImpl<Detector>
void defineSensitiveVolumes();

// Geometry parameters
Bool_t mActiveModule[6]; // list of modules to create
Bool_t mActiveModule[5]; // list of modules to create

// Simulation
std::vector<Hit>* mHits = nullptr; //! Collection of CPV hits
Expand Down
19 changes: 10 additions & 9 deletions Detectors/CPV/simulation/include/CPVSimulation/RawWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ namespace o2
namespace cpv
{

static constexpr short kNDDL = 3; ///< Total number of DDLs
static constexpr short kNMod = 3; ///< Total number of modules
static constexpr short kFirstMod = 2; ///< First available module
static constexpr short kNPAD = 48; ///< Nuber of pads per dilogic
static constexpr short kNDilogic = 10; ///< Number of dilogic per row
static constexpr short kNRow = 16; ///< number of rows per dddl
static constexpr short kNRow = 48; ///< number of rows 16*3 mod

struct padCharge {
short charge;
Expand Down Expand Up @@ -73,13 +74,13 @@ class RawWriter
std::vector<char>& trailer, std::vector<char>& header) const;

private:
std::vector<padCharge> mPadCharge[kNDDL][kNRow][kNDilogic]; ///< list of signals per event
FileFor_t mFileFor = FileFor_t::kFullDet; ///< Granularity of the output files
std::string mOutputLocation = "./"; ///< Rawfile name
std::unique_ptr<CalibParams> mCalibParams; ///< CPV calibration
std::vector<uint32_t> mPayload; ///< Payload to be written
gsl::span<o2::cpv::Digit> mDigits; ///< Digits input vector - must be in digitized format including the time response
std::unique_ptr<o2::raw::RawFileWriter> mRawWriter; ///< Raw writer
std::vector<padCharge> mPadCharge[kNRow][kNDilogic]; ///< list of signals per event
FileFor_t mFileFor = FileFor_t::kFullDet; ///< Granularity of the output files
std::string mOutputLocation = "./"; ///< Rawfile name
std::unique_ptr<CalibParams> mCalibParams; ///< CPV calibration
std::vector<uint32_t> mPayload; ///< Payload to be written
gsl::span<o2::cpv::Digit> mDigits; ///< Digits input vector - must be in digitized format including the time response
std::unique_ptr<o2::raw::RawFileWriter> mRawWriter; ///< Raw writer

ClassDefNV(RawWriter, 1);
};
Expand Down
10 changes: 6 additions & 4 deletions Detectors/CPV/simulation/src/Detector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,10 @@ void Detector::ConstructGeometry()
// Configure geometry So far we have only one: Run3
{
mActiveModule[0] = kFALSE;
mActiveModule[1] = kTRUE;
mActiveModule[1] = kFALSE;
mActiveModule[2] = kTRUE;
mActiveModule[3] = kTRUE;
mActiveModule[4] = kFALSE;
mActiveModule[5] = kFALSE;
mActiveModule[4] = kTRUE;
}

// First create necessary materials
Expand All @@ -375,7 +374,7 @@ void Detector::ConstructGeometry()
int iXYZ, iAngle;
char im[5];
for (int iModule = 0; iModule < 5; iModule++) {
if (!mActiveModule[iModule + 1]) {
if (!mActiveModule[iModule]) {
continue;
}
float angle[3][2] = {0};
Expand Down Expand Up @@ -565,6 +564,9 @@ void Detector::addAlignableVolumes() const

for (Int_t iModule = 0; iModule < geom->GetNModules(); iModule++) {

if (!mActiveModule[iModule]) {
continue;
}
TString volPath(physModulePath);
volPath += iModule;

Expand Down
4 changes: 2 additions & 2 deletions Detectors/CPV/simulation/src/Digitizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ void Digitizer::processHits(const std::vector<Hit>* hits, const std::vector<Digi
digitsOut.push_back(digit);
}

//Add noisy channels to the end of PHOS
//Add noisy channels to the end of CPV
if (addNoise) {
addNoisyChannels(currentId, 56 * 64 * 4, digitsOut);
addNoisyChannels(currentId, 128 * 60 * 3, digitsOut);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Detectors/CPV/simulation/src/GeometryParams.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ GeometryParams* GeometryParams::sGeomParam = nullptr;
GeometryParams::GeometryParams(const std::string_view name)
: // Set zeros to the variables: most of them should be calculated
// and it is more clear to set them in the text
mNModules(3),
mNModules(5),
mNumberOfCPVPadsPhi(128),
mNumberOfCPVPadsZ(60),
mCPVPadSizePhi(1.13),
Expand Down Expand Up @@ -70,8 +70,8 @@ GeometryParams::GeometryParams(const std::string_view name)
double const kRADDEG = 180.0 / TMath::Pi();

double r = mIPtoCPVSurface + mCPVBoxSize[1];
for (Int_t iModule = 0; iModule < mNModules; iModule++) {
double angle = moduleAngle * (iModule - 2); //Module 3 just below IP
for (Int_t iModule = 2; iModule < mNModules; iModule++) {
double angle = moduleAngle * (iModule - 2); //Module 2 just below IP
mCPVAngle[iModule] = -angle;
mModuleCenter[iModule][0] = r * TMath::Sin(-angle / kRADDEG);
mModuleCenter[iModule][1] = -r * TMath::Cos(-angle / kRADDEG);
Expand Down
Loading