Skip to content

Commit 98d0a21

Browse files
dstoccoshahor02
authored andcommitted
Merge digits coming from in-bunch pile-up
1 parent 9ccd319 commit 98d0a21

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

Detectors/MUON/MID/Simulation/include/MIDSimulation/DigitsMerger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace mid
2929
class DigitsMerger
3030
{
3131
public:
32-
void process(const std::vector<ColumnDataMC>& inDigitStore, const o2::dataformats::MCTruthContainer<MCLabel>& inMCContainer, const std::vector<ROFRecord>& inROFRecords);
32+
void process(const std::vector<ColumnDataMC>& inDigitStore, const o2::dataformats::MCTruthContainer<MCLabel>& inMCContainer, const std::vector<ROFRecord>& inROFRecords, bool mergeInBunchPileup = true);
3333

3434
/// Gets the merged column data
3535
const std::vector<ColumnData>& getColumnData() const { return mDigitStore; }

Detectors/MUON/MID/Simulation/src/DigitsMerger.cxx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,41 @@ void DigitsMerger::mergeDigit(size_t idigit, const std::vector<ColumnDataMC>& in
3333
mDigitsLabels.emplace_back(std::make_pair(inDigitStore[idigit], vec));
3434
}
3535

36-
void DigitsMerger::process(const std::vector<ColumnDataMC>& inDigitStore, const o2::dataformats::MCTruthContainer<MCLabel>& inMCContainer, const std::vector<ROFRecord>& inROFRecords)
36+
void DigitsMerger::process(const std::vector<ColumnDataMC>& inDigitStore, const o2::dataformats::MCTruthContainer<MCLabel>& inMCContainer, const std::vector<ROFRecord>& inROFRecords, bool mergeInBunchPileup)
3737
{
3838
/// Merges the MC digits that are provided per hit
3939
/// into the format that we expect from data
4040
/// \param inDigitStore Vector of input MC digits
4141
/// \param inMCContainer Container with MC labels for input MC digits
4242
/// \param inROFRecords Vector with RO frame records
43+
/// \param mergeInBunchPileup Merge the digits coming from in-bunch pileup
4344
mDigitStore.clear();
4445
mMCContainer.clear();
4546
mROFRecords.clear();
47+
mDigitsLabels.clear();
4648

47-
for (auto& rofRecord : inROFRecords) {
48-
mDigitsLabels.clear();
49-
for (size_t idigit = rofRecord.firstEntry; idigit < rofRecord.firstEntry + rofRecord.nEntries; ++idigit) {
49+
for (auto rofIt = inROFRecords.begin(); rofIt != inROFRecords.end(); ++rofIt) {
50+
auto nextRofIt = rofIt + 1;
51+
bool mergeInteractions = mergeInBunchPileup && nextRofIt != inROFRecords.end() && rofIt->interactionRecord == nextRofIt->interactionRecord;
52+
53+
for (size_t idigit = rofIt->firstEntry; idigit < rofIt->firstEntry + rofIt->nEntries; ++idigit) {
5054
mergeDigit(idigit, inDigitStore);
5155
}
5256

57+
if (mergeInteractions) {
58+
continue;
59+
}
60+
5361
auto firstEntry = mDigitStore.size();
54-
mROFRecords.emplace_back(rofRecord.interactionRecord, rofRecord.eventType, firstEntry, mDigitsLabels.size());
62+
mROFRecords.emplace_back(rofIt->interactionRecord, rofIt->eventType, firstEntry, mDigitsLabels.size());
5563

5664
for (auto pair : mDigitsLabels) {
5765
mDigitStore.emplace_back(pair.first);
5866
for (auto labelIdx : pair.second) {
5967
mMCContainer.addElements(mDigitStore.size() - 1, inMCContainer.getLabels(labelIdx));
6068
}
6169
}
70+
mDigitsLabels.clear();
6271
}
6372
}
6473
} // namespace mid

Detectors/MUON/MID/Simulation/test/testSimulation.cxx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <boost/test/data/test_case.hpp>
1616
#include <sstream>
1717
#include "MathUtils/Cartesian3D.h"
18+
#include "CommonConstants/LHCConstants.h"
1819
#include "DataFormatsMID/Cluster2D.h"
1920
#include "DataFormatsMID/Cluster3D.h"
2021
#include "DataFormatsMID/ColumnData.h"
@@ -303,7 +304,7 @@ BOOST_DATA_TEST_CASE(MID_DigitMerger, boost::unit_test::data::make(getDEList()),
303304
digitsCollection.push_back({});
304305
mcContainerCollection.push_back({});
305306
simDigitizer.digitizer.process(hits, digitsCollection.back(), mcContainerCollection.back());
306-
rofRecords.emplace_back(10 * ievent, EventType::Standard, digits.size(), digitsCollection.back().size());
307+
rofRecords.emplace_back(o2::constants::lhc::LHCBunchSpacingNS * ievent, EventType::Standard, digits.size(), digitsCollection.back().size());
307308
std::copy(digitsCollection.back().begin(), digitsCollection.back().end(), std::back_inserter(digits));
308309
mcContainer.mergeAtBack(mcContainerCollection.back());
309310
}
@@ -392,7 +393,7 @@ BOOST_DATA_TEST_CASE(MID_SingleCluster, boost::unit_test::data::make(getDEList()
392393
int nGenClusters = 1, nRecoClusters = 0;
393394
simDigitizer.digitizer.process(hits, digitStoreMC, digitLabelsMC);
394395
rofRecords.clear();
395-
rofRecords.emplace_back(10 * ievent, EventType::Standard, 0, digitStoreMC.size());
396+
rofRecords.emplace_back(o2::constants::lhc::LHCBunchSpacingNS * ievent, EventType::Standard, 0, digitStoreMC.size());
396397
simDigitizer.digitsMerger.process(digitStoreMC, digitLabelsMC, rofRecords);
397398
simClustering.preClusterizer.process(simDigitizer.digitsMerger.getColumnData(), simDigitizer.digitsMerger.getROFRecords());
398399
simClustering.clusterizer.process(simClustering.preClusterizer.getPreClusters(), simClustering.preClusterizer.getROFRecords());
@@ -432,7 +433,7 @@ BOOST_DATA_TEST_CASE(MID_SimClusters, boost::unit_test::data::make(getDEList()),
432433
auto hits = generateHits(10, deId, simBase.mapping, simBase.geoTrans);
433434
hitsCollection.emplace_back(hits);
434435
simDigitizer.digitizer.process(hits, digitStoreMC, digitLabelsMC);
435-
digitsROF.emplace_back(ievent, EventType::Standard, digitsAccum.size(), digitStoreMC.size());
436+
digitsROF.emplace_back(o2::constants::lhc::LHCBunchSpacingNS * ievent, EventType::Standard, digitsAccum.size(), digitStoreMC.size());
436437
std::copy(digitStoreMC.begin(), digitStoreMC.end(), std::back_inserter(digitsAccum));
437438
digitLabelsAccum.mergeAtBack(digitLabelsMC);
438439
}
@@ -505,7 +506,7 @@ BOOST_DATA_TEST_CASE(MID_SimTracks, boost::unit_test::data::make({1, 2, 3, 4, 5,
505506
// In the tracking algorithm, if we have two tracks that are compatible within uncertainties
506507
// we keep only one of the two. This is done to avoid duplicated tracks.
507508
// In this test we can have many tracks in the same event.
508-
// If two tracks are close, they can give two reconstucted tracks compatible among each others,
509+
// If two tracks are close, they can give two reconstructed tracks compatible among each others,
509510
// within their uncertainties. One of the two is therefore rejected.
510511
// However, the track might not be compatible with the (rejected) generated track that has no uncertainty.
511512
// To avoid this, compare adding a factor 2 in the sigma cut.
@@ -525,7 +526,7 @@ BOOST_DATA_TEST_CASE(MID_SimTracks, boost::unit_test::data::make({1, 2, 3, 4, 5,
525526
genTrackCollection.emplace_back(genTracks);
526527

527528
simDigitizer.digitizerNoClusterSize.process(hits, digitStoreMC, digitLabelsMC);
528-
digitsROF.emplace_back(ievent, EventType::Standard, digitsAccum.size(), digitStoreMC.size());
529+
digitsROF.emplace_back(o2::constants::lhc::LHCBunchSpacingNS * ievent, EventType::Standard, digitsAccum.size(), digitStoreMC.size());
529530
std::copy(digitStoreMC.begin(), digitStoreMC.end(), std::back_inserter(digitsAccum));
530531
digitLabelsAccum.mergeAtBack(digitLabelsMC);
531532
}

0 commit comments

Comments
 (0)