Skip to content

Commit 2ab49d2

Browse files
committed
filter trackable ROFs at clustering level
1 parent 4bd0da6 commit 2ab49d2

6 files changed

Lines changed: 94 additions & 6 deletions

File tree

Detectors/MUON/MCH/Base/include/MCHBase/Trackable.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,21 @@ bool isTrackable(std::array<int, 10> itemsPerChamber,
3838
/** Return the number of items per chamber.
3939
*
4040
* @tparam T the type of items : implementation exists so far
41-
* only for mch::Digit (clusters and pre-clusters to come next)
41+
* for deIds (int) and mch::Digit
4242
*/
4343
template <typename T>
4444
std::array<int, 10> perChamber(gsl::span<const T> items);
4545

46+
/** Return the number of items per chamber.
47+
*
48+
* @tparam T1 the type of items : implementation exists so far
49+
* for mch::PreCluster
50+
* @tparam T2 the type of subitems pointed to by items,
51+
* e.g. mch::Digit attached to mch::PreCluster
52+
*/
53+
template <typename T1, typename T2>
54+
std::array<int, 10> perChamber(gsl::span<const T1> items, gsl::span<const T2> subitems);
55+
4656
/** Return the number of items per station (1 station==2 chambers). */
4757
template <typename T>
4858
std::array<int, 5> perStation(gsl::span<const T> items)

Detectors/MUON/MCH/Base/src/Trackable.cxx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
// or submit itself to any jurisdiction.
1111

1212
#include "MCHBase/Trackable.h"
13+
1314
#include "DataFormatsMCH/Digit.h"
15+
#include "MCHBase/PreCluster.h"
1416

1517
namespace o2::mch
1618
{
@@ -59,7 +61,27 @@ std::array<int, 10> perChamber(gsl::span<const Digit> digits)
5961
for (const auto& digit : digits) {
6062
nofDigits[digit.getDetID() / 100 - 1]++;
6163
}
64+
// do not count isolated digits (at least 2 are required for a cluster)
65+
for (auto i = 0; i < 10; ++i) {
66+
if (nofDigits[i] == 1) {
67+
nofDigits[i] = 0;
68+
}
69+
}
6270
return nofDigits;
6371
}
6472

73+
/** Specialization of perChamber for PreClusters */
74+
template <>
75+
std::array<int, 10> perChamber(gsl::span<const PreCluster> preclusters, gsl::span<const Digit> digits)
76+
{
77+
std::array<int, 10> nofPreclusters{};
78+
for (const auto& precluster : preclusters) {
79+
// only consider preclusters made of at least 2 digits
80+
if (precluster.nDigits > 1) {
81+
nofPreclusters[digits[precluster.firstDigit].getDetID() / 100 - 1]++;
82+
}
83+
}
84+
return nofPreclusters;
85+
}
86+
6587
} // namespace o2::mch

Detectors/MUON/MCH/Clustering/include/MCHClustering/ClusterizerParam.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ struct ClusterizerParam : public o2::conf::ConfigurableParamHelper<ClusterizerPa
3737

3838
bool legacy = true; ///< use original (run2) clustering
3939

40+
bool onlyTrackable = true; ///< clusterize only ROFs that match the trackable condition @see MCHROFFiltering/TrackableFilter
41+
4042
O2ParamDef(ClusterizerParam, "MCHClustering");
4143
};
4244

Detectors/MUON/MCH/ROFFiltering/include/MCHROFFiltering/TrackableFilter.h

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ namespace o2::mch
3333
*
3434
* @tparam : the type of the items pointed to by the ROFRecords
3535
*/
36-
3736
template <typename T>
3837
ROFFilter
3938
createTrackableFilter(gsl::span<const T> items,
@@ -46,6 +45,33 @@ ROFFilter
4645
};
4746
}
4847

48+
/** Returns a ROFRecord filter that selects ROFs that are trackable.
49+
*
50+
* The returned filter is a function that takes a ROFRecord and returns
51+
* a boolean.
52+
*
53+
* @param items : the items "pointed to" by the ROFRecords (preclusters, ...)
54+
* @param subitems : the subitems "pointed to" by the items (digits, ...)
55+
*
56+
* @param requestStation : @ref isTrackable
57+
* @param moreCandidates : @ref isTrackable
58+
*
59+
* @tparam T1 : the type of the items pointed to by the ROFRecords
60+
* @tparam T2 : the type of the subitems pointed to by the items
61+
*/
62+
template <typename T1, typename T2>
63+
ROFFilter
64+
createTrackableFilter(gsl::span<const T1> items,
65+
gsl::span<const T2> subitems,
66+
std::array<bool, 5> requestStation = {true, true, true, true, true},
67+
bool moreCandidates = false)
68+
{
69+
return [items, subitems, requestStation, moreCandidates](const ROFRecord& rof) {
70+
std::array<int, 10> nofItemsPerChamber = perChamber(items.subspan(rof.getFirstIdx(), rof.getNEntries()), subitems);
71+
return isTrackable(nofItemsPerChamber, requestStation, moreCandidates);
72+
};
73+
}
74+
4975
} // namespace o2::mch
5076

5177
#endif

Detectors/MUON/MCH/Workflow/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ o2_add_library(MCHWorkflow
3030
O2::MCHPreClustering
3131
O2::MCHRawCommon
3232
O2::MCHRawDecoder
33+
O2::MCHROFFiltering
3334
ROOT::TreePlayer
3435
)
3536

Detectors/MUON/MCH/Workflow/src/ClusterFinderOriginalSpec.cxx

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@
3535
#include "Framework/Logger.h"
3636

3737
#include "CommonUtils/ConfigurableParam.h"
38-
#include "DataFormatsMCH/ROFRecord.h"
38+
#include "DataFormatsMCH/Cluster.h"
3939
#include "DataFormatsMCH/Digit.h"
40+
#include "DataFormatsMCH/ROFRecord.h"
4041
#include "MCHBase/Error.h"
4142
#include "MCHBase/ErrorMap.h"
4243
#include "MCHBase/PreCluster.h"
43-
#include "DataFormatsMCH/Cluster.h"
44+
#include "MCHBase/TrackerParam.h"
4445
#include "MCHClustering/ClusterFinderOriginal.h"
46+
#include "MCHClustering/ClusterizerParam.h"
47+
#include "MCHROFFiltering/TrackableFilter.h"
4548

4649
namespace o2
4750
{
@@ -94,11 +97,35 @@ class ClusterFinderOriginalTask
9497
auto& clusters = pc.outputs().make<std::vector<Cluster>>(OutputRef{"clusters"});
9598
auto& usedDigits = pc.outputs().make<std::vector<Digit>>(OutputRef{"clusterdigits"});
9699

100+
// create the trackable ROF filtering if needed
101+
ROFFilter trackable{};
102+
if (ClusterizerParam::Instance().onlyTrackable) {
103+
const auto& trackerParam = TrackerParam::Instance();
104+
std::array<bool, 5> requestStation{
105+
trackerParam.requestStation[0],
106+
trackerParam.requestStation[1],
107+
trackerParam.requestStation[2],
108+
trackerParam.requestStation[3],
109+
trackerParam.requestStation[4]};
110+
trackable = createTrackableFilter(preClusters, digits, requestStation, trackerParam.moreCandidates);
111+
}
112+
97113
clusterROFs.reserve(preClusterROFs.size());
98114
auto& errorMap = mClusterFinder.getErrorMap();
99115
errorMap.clear();
116+
int nFilteredRofs = 0;
117+
int nFilteredPreClusters = 0;
100118
for (const auto& preClusterROF : preClusterROFs) {
101119

120+
// filter out non-trackable ROFs if requested
121+
if (ClusterizerParam::Instance().onlyTrackable && !trackable(preClusterROF)) {
122+
// create an empty cluster ROF
123+
clusterROFs.emplace_back(preClusterROF.getBCData(), clusters.size(), 0, preClusterROF.getBCWidth());
124+
continue;
125+
}
126+
++nFilteredRofs;
127+
nFilteredPreClusters += preClusterROF.getNEntries();
128+
102129
// prepare to clusterize the current ROF
103130
auto clusterOffset = clusters.size();
104131
mClusterFinder.reset();
@@ -137,8 +164,8 @@ class ClusterFinderOriginalTask
137164
});
138165
mErrorMap.add(errorMap);
139166

140-
LOGP(info, "Found {:4d} clusters from {:4d} preclusters in {:2d} ROFs",
141-
clusters.size(), preClusters.size(), preClusterROFs.size());
167+
LOGP(info, "Found {:4d} clusters from {:4d} preclusters (out of {:4d}) in {:2d} filtered ROFs (out of {:2d})",
168+
clusters.size(), nFilteredPreClusters, preClusters.size(), nFilteredRofs, preClusterROFs.size());
142169
}
143170

144171
private:

0 commit comments

Comments
 (0)