Skip to content

Commit 7368424

Browse files
sawenzelclaude
andcommitted
Fix MC labels carried over between sectors in the TPC digitizer
This fixes a problem in the TPC DigitContainer reset and adds a unit test. - With DigiParams.maxOrbitsToDigitize set, time bins beyond the timeframe end stay in the container after the final flush. - reset() cleared only their charges, so their MC labels were attached to digits of the next sector processed by the same lane. - reset() now deletes all remaining time bins, and the destructor frees them. - testTPCDigitContainerReset checks that no label of one sector reaches the next. https://its.cern.ch/jira/browse/O2-7310 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent bc5ed44 commit 7368424

3 files changed

Lines changed: 87 additions & 5 deletions

File tree

‎Detectors/TPC/simulation/include/TPCSimulation/DigitContainer.h‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ class DigitContainer
4545
DigitContainer();
4646

4747
/// Destructor
48-
~DigitContainer() = default;
48+
~DigitContainer()
49+
{
50+
for (auto time : mTimeBins) {
51+
delete time;
52+
}
53+
}
4954

5055
/// Reset the container
5156
void reset();
@@ -115,11 +120,11 @@ inline void DigitContainer::reset()
115120
{
116121
mFirstTimeBin = 0;
117122
mEffectiveTimeBin = 0;
118-
for (auto& time : mTimeBins) {
119-
if (time) {
120-
time->reset();
121-
}
123+
// drop all time bins, including those beyond the timeframe limit, so that no MC labels survive
124+
for (auto time : mTimeBins) {
125+
delete time;
122126
}
127+
mTimeBins.assign(mOffset, nullptr);
123128
if (mPrevDigArr) {
124129
std::fill(mPrevDigArr->begin(), mPrevDigArr->end(), PrevDigitInfo{});
125130
}

‎Detectors/TPC/simulation/test/CMakeLists.txt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ o2_add_test(DigitContainer
1616
SOURCES testTPCDigitContainer.cxx
1717
ENVIRONMENT O2_ROOT=${CMAKE_BINARY_DIR}/stage)
1818

19+
o2_add_test(DigitContainerReset
20+
LABELS tpc
21+
PUBLIC_LINK_LIBRARIES O2::TPCSimulation
22+
COMPONENT_NAME tpc
23+
SOURCES testTPCDigitContainerReset.cxx
24+
ENVIRONMENT O2_ROOT=${CMAKE_BINARY_DIR}/stage)
25+
1926
o2_add_test(ElectronTransport
2027
LABELS tpc
2128
PUBLIC_LINK_LIBRARIES O2::TPCSimulation
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file testTPCDigitContainerReset.cxx
13+
/// \brief Test that DigitContainer::reset() leaves no MC labels behind for the next sector
14+
15+
#define BOOST_TEST_MODULE Test TPC DigitContainer reset
16+
#define BOOST_TEST_MAIN
17+
#define BOOST_TEST_DYN_LINK
18+
#include <boost/test/unit_test.hpp>
19+
#include <vector>
20+
#include <fmt/format.h>
21+
#include "DataFormatsTPC/Digit.h"
22+
#include "TPCSimulation/DigitContainer.h"
23+
#include "TPCSimulation/SAMPAProcessing.h"
24+
#include "TPCBaseRecSim/CDBInterface.h"
25+
26+
namespace o2::tpc
27+
{
28+
29+
// A sector whose last time bins lie beyond the timeframe limit must not pass their labels to the next sector
30+
BOOST_AUTO_TEST_CASE(DigitContainer_noLabelCarryOver)
31+
{
32+
auto& cdb = CDBInterface::instance();
33+
cdb.setUseDefaults();
34+
// limit the flush to one orbit (time bin 447) and propagate the ADC values unchanged
35+
o2::conf::ConfigurableParam::updateFromString(fmt::format("DigiParams.maxOrbitsToDigitize=1;TPCEleParam.DigiMode={}", (int)DigitzationMode::PropagateADC));
36+
const Mapper& mapper = Mapper::instance();
37+
SAMPAProcessing::instance();
38+
39+
const GlobalPadNumber globalPad = mapper.getPadNumberInROC(PadROCPos(CRU(0).roc(), PadPos(10, 10)));
40+
const MCCompLabel labelFirst(1, 1, 0, false);
41+
const MCCompLabel labelSecond(2, 2, 0, false);
42+
43+
DigitContainer digitContainer;
44+
digitContainer.reset();
45+
46+
// first sector: a signal beyond the timeframe limit, which the final flush does not reach
47+
digitContainer.addDigit(labelFirst, CRU(0), 600, globalPad, 100);
48+
std::vector<Digit> digits;
49+
dataformats::MCTruthContainer<MCCompLabel> labels;
50+
std::vector<CommonMode> commonMode;
51+
digitContainer.fillOutputContainer(digits, labels, commonMode, Sector(0), 0, true, true);
52+
BOOST_CHECK(digits.empty());
53+
54+
// second sector, as after Digitizer::setSector(): same pad, early time bin
55+
digitContainer.reset();
56+
digits.clear();
57+
labels.clear();
58+
commonMode.clear();
59+
digitContainer.addDigit(labelSecond, CRU(10), 153, globalPad, 100);
60+
digitContainer.fillOutputContainer(digits, labels, commonMode, Sector(1), 0, true, true);
61+
62+
BOOST_REQUIRE(digits.size() == 1);
63+
const auto digitLabels = labels.getLabels(0);
64+
BOOST_CHECK_EQUAL(digitLabels.size(), 1);
65+
for (const auto& label : digitLabels) {
66+
BOOST_CHECK(label == labelSecond);
67+
}
68+
}
69+
70+
} // namespace o2::tpc

0 commit comments

Comments
 (0)