Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void mchCathodeSegmentationForOneDetectionElementOfEachSegmentationType(MchDetec
O2MCHMAPPINGIMPL3_EXPORT
int mchCathodeSegmentationIsPadValid(MchCathodeSegmentationHandle segHandle, int catPadIndex)
{
return catPadIndex != segHandle->impl->InvalidCatPadIndex;
return segHandle->impl->isValid(catPadIndex);
}

O2MCHMAPPINGIMPL3_EXPORT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ std::vector<int> CathodeSegmentation::getNeighbouringCatPadIndexs(int catPadInde
return pads;
}

bool CathodeSegmentation::isValid(int catPadIndex) const
{
return catPadIndex >= 0 && catPadIndex < static_cast<int>(mCatPadIndex2PadGroupIndex.size());
}

double CathodeSegmentation::squaredDistance(int catPadIndex, double x, double y) const
{
double px = padPositionX(catPadIndex) - x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class CathodeSegmentation

int padDualSampaChannel(int catPadIndex) const;

bool isValid(int catPadIndex) const;

private:
int dualSampaIndex(int dualSampaId) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ O2MCHMAPPINGIMPL4_EXPORT void
O2MCHMAPPINGIMPL4_EXPORT int mchCathodeSegmentationIsPadValid(
MchCathodeSegmentationHandle segHandle, int catPadIndex)
{
return catPadIndex != segHandle->impl->InvalidCatPadIndex;
return segHandle->impl->isValid(catPadIndex);
}

O2MCHMAPPINGIMPL4_EXPORT void mchCathodeSegmentationForEachPadInDualSampa(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ std::vector<int> CathodeSegmentation::getNeighbouringCatPadIndexs(
return pads;
}

bool CathodeSegmentation::isValid(int catPadIndex) const
{
return catPadIndex >= 0 && catPadIndex < static_cast<int>(mCatPadIndex2PadGroupIndex.size());
}

double CathodeSegmentation::squaredDistance(int catPadIndex, double x,
double y) const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class CathodeSegmentation

int padDualSampaChannel(int catPadIndex) const;

bool isValid(int catPadIndex) const;

private:
int dualSampaIndex(int dualSampaId) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ inline int Segmentation::findPadByFEE(int dualSampaId, int dualSampaChannel) con

inline bool Segmentation::isValid(int dePadIndex) const
{
if (dePadIndex < mPadIndexOffset) {
return mBending.isValid(dePadIndex);
}
return mNonBending.isValid(dePadIndex - mPadIndexOffset);
return dePadIndex >= 0 && dePadIndex < nofPads();
}

inline int Segmentation::padC2DE(int catPadIndex, bool isBending) const
Expand Down Expand Up @@ -99,7 +96,9 @@ inline bool Segmentation::findPadPairByPosition(double x, double y, int& b, int&
b = mBending.findPadByPosition(x, y);
nb = mNonBending.findPadByPosition(x, y);
if (!mBending.isValid(b)) {
nb = padC2DE(nb, false);
if (mNonBending.isValid(nb)) {
nb = padC2DE(nb, false);
}
return false;
}
if (!mNonBending.isValid(nb)) {
Expand Down
15 changes: 15 additions & 0 deletions 15 Detectors/MUON/MCH/Mapping/test/src/CathodeSegmentation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <fstream>
#include <iostream>
#include "TestParameters.h"
#include <fmt/format.h>

using namespace o2::mch::mapping;
namespace bdata = boost::unit_test::data;
Expand Down Expand Up @@ -299,6 +300,20 @@ BOOST_AUTO_TEST_CASE(ThrowsIfDualSampaChannelIsNotBetween0And63)
BOOST_CHECK_THROW(seg.findPadByFEE(102, 64), std::out_of_range);
}

BOOST_AUTO_TEST_CASE(ReturnsFalseIfCatPadIdIsOutOfRange)
{
forOneDetectionElementOfEachSegmentationType([](int detElemId) {
for (auto plane : {true, false}) {
CathodeSegmentation seg{detElemId, plane};
BOOST_TEST_INFO_SCOPE(fmt::format("DeId {} Bending {}", detElemId, plane));
BOOST_CHECK_EQUAL(seg.isValid(0), true);
BOOST_CHECK_EQUAL(seg.isValid(seg.nofPads() - 1), true);
BOOST_CHECK_EQUAL(seg.isValid(-1), false);
BOOST_CHECK_EQUAL(seg.isValid(seg.nofPads()), false);
}
});
}

BOOST_AUTO_TEST_CASE(ReturnsTrueIfPadIsConnected)
{
BOOST_CHECK_EQUAL(seg.isValid(seg.findPadByFEE(102, 3)), true);
Expand Down
69 changes: 66 additions & 3 deletions 69 Detectors/MUON/MCH/Mapping/test/src/Segmentation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <fstream>
#include <iostream>
#include "TestParameters.h"
#include <fmt/format.h>

using namespace o2::mch::mapping;
namespace bdata = boost::unit_test::data;
Expand Down Expand Up @@ -186,7 +187,7 @@ BOOST_AUTO_TEST_CASE(CheckPadOffsetsAfterCopy)
});
}

struct SEG {
struct SEG100 {
Segmentation seg{100};
};

Expand All @@ -210,9 +211,60 @@ BOOST_AUTO_TEST_CASE(TestForEachPadAndPadIndexRange)
});
}

// All the remaining tests of this file are using seg (DE100).
BOOST_AUTO_TEST_CASE(CheckOnePadPositionPresentOnOnlyBendingPlaneDE600)
{
Segmentation de600(600);
double x = 54.34;
double y = -12.40;
int b, nb;
bool ok = de600.findPadPairByPosition(x, y, b, nb);
TestParameters params;
int testChannel = 12;
if (params.isSegmentationRun3) {
testChannel = 44;
}
BOOST_CHECK_EQUAL(ok, false);
int p = de600.findPadByFEE(307, testChannel);
BOOST_CHECK_EQUAL(p, b);
BOOST_CHECK_EQUAL(de600.isValid(b), true);
BOOST_CHECK_EQUAL(de600.isValid(nb), false);
}

BOOST_AUTO_TEST_CASE(CheckOnePadPositionPresentOnOnlyBendingPlaneDE825)
{
Segmentation de825(825);
double x = 110.09;
double y = -1.25;
int b, nb;
bool ok = de825.findPadPairByPosition(x, y, b, nb);
TestParameters params;
int testChannel{55};
if (params.isSegmentationRun3) {
testChannel = 23;
}
BOOST_CHECK_EQUAL(ok, false);
int p = de825.findPadByFEE(1333, testChannel);
BOOST_CHECK_EQUAL(p, nb);
BOOST_CHECK_EQUAL(de825.isValid(b), false);
BOOST_CHECK_EQUAL(de825.isValid(nb), true);
}

BOOST_AUTO_TEST_CASE(CheckOnePadPositionTotallyAbsentDE604)
{
Segmentation de604(604);
double x = -19.25;
double y = 20.04;
int b, nb;
bool ok = de604.findPadPairByPosition(x, y, b, nb);
BOOST_CHECK_EQUAL(ok, false);
BOOST_CHECK_EQUAL(de604.isValid(nb), false);
BOOST_CHECK_EQUAL(de604.isValid(b), false);
}

BOOST_FIXTURE_TEST_SUITE(DE100, SEG)
// All the remaining tests of this file are using specific
// detection elements DE100

BOOST_FIXTURE_TEST_SUITE(DE100, SEG100)

BOOST_TEST_DECORATOR(*boost::unit_test::tolerance(1E-3))
BOOST_AUTO_TEST_CASE(CheckOnePosition)
Expand Down Expand Up @@ -373,6 +425,17 @@ BOOST_AUTO_TEST_CASE(ReturnsFalseIfPadIsNotConnected)
BOOST_CHECK_EQUAL(seg.isValid(seg.findPadByFEE(214, testChannel)), false);
}

BOOST_AUTO_TEST_CASE(ReturnsFalseIfCatPadIdIsOutOfRange)
{
forOneDetectionElementOfEachSegmentationType([](int detElemId) {
Segmentation seg{detElemId};
BOOST_TEST_INFO_SCOPE(fmt::format("DeId {}", detElemId));
BOOST_CHECK_EQUAL(seg.isValid(0), true);
BOOST_CHECK_EQUAL(seg.isValid(seg.nofPads() - 1), true);
BOOST_CHECK_EQUAL(seg.isValid(-1), false);
BOOST_CHECK_EQUAL(seg.isValid(seg.nofPads()), false);
});
}
BOOST_AUTO_TEST_CASE(HasPadByPosition)
{
int b, nb;
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.