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
12 changes: 11 additions & 1 deletion Detectors/MUON/MCH/Base/include/MCHBase/Trackable.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,21 @@ bool isTrackable(std::array<int, 10> itemsPerChamber,
/** Return the number of items per chamber.
*
* @tparam T the type of items : implementation exists so far
* only for mch::Digit (clusters and pre-clusters to come next)
* for deIds (int) and mch::Digit
*/
template <typename T>
std::array<int, 10> perChamber(gsl::span<const T> items);

/** Return the number of items per chamber.
*
* @tparam T1 the type of items : implementation exists so far
* for mch::PreCluster
* @tparam T2 the type of subitems pointed to by items,
* e.g. mch::Digit attached to mch::PreCluster
*/
template <typename T1, typename T2>
std::array<int, 10> perChamber(gsl::span<const T1> items, gsl::span<const T2> subitems);

/** Return the number of items per station (1 station==2 chambers). */
template <typename T>
std::array<int, 5> perStation(gsl::span<const T> items)
Expand Down
22 changes: 22 additions & 0 deletions Detectors/MUON/MCH/Base/src/Trackable.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
// or submit itself to any jurisdiction.

#include "MCHBase/Trackable.h"

#include "DataFormatsMCH/Digit.h"
#include "MCHBase/PreCluster.h"

namespace o2::mch
{
Expand Down Expand Up @@ -59,7 +61,27 @@ std::array<int, 10> perChamber(gsl::span<const Digit> digits)
for (const auto& digit : digits) {
nofDigits[digit.getDetID() / 100 - 1]++;
}
// do not count isolated digits (at least 2 are required for a cluster)
for (auto i = 0; i < 10; ++i) {
if (nofDigits[i] == 1) {
nofDigits[i] = 0;
}
}
return nofDigits;
}

/** Specialization of perChamber for PreClusters */
template <>
std::array<int, 10> perChamber(gsl::span<const PreCluster> preclusters, gsl::span<const Digit> digits)
{
std::array<int, 10> nofPreclusters{};
for (const auto& precluster : preclusters) {
// only consider preclusters made of at least 2 digits
if (precluster.nDigits > 1) {
nofPreclusters[digits[precluster.firstDigit].getDetID() / 100 - 1]++;
}
}
return nofPreclusters;
}

} // namespace o2::mch
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ struct ClusterizerParam : public o2::conf::ConfigurableParamHelper<ClusterizerPa

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

bool onlyTrackable = true; ///< clusterize only ROFs that match the trackable condition @see MCHROFFiltering/TrackableFilter

O2ParamDef(ClusterizerParam, "MCHClustering");
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ namespace o2::mch
*
* @tparam : the type of the items pointed to by the ROFRecords
*/

template <typename T>
ROFFilter
createTrackableFilter(gsl::span<const T> items,
Expand All @@ -46,6 +45,33 @@ ROFFilter
};
}

/** Returns a ROFRecord filter that selects ROFs that are trackable.
*
* The returned filter is a function that takes a ROFRecord and returns
* a boolean.
*
* @param items : the items "pointed to" by the ROFRecords (preclusters, ...)
* @param subitems : the subitems "pointed to" by the items (digits, ...)
*
* @param requestStation : @ref isTrackable
* @param moreCandidates : @ref isTrackable
*
* @tparam T1 : the type of the items pointed to by the ROFRecords
* @tparam T2 : the type of the subitems pointed to by the items
*/
template <typename T1, typename T2>
ROFFilter
createTrackableFilter(gsl::span<const T1> items,
gsl::span<const T2> subitems,
std::array<bool, 5> requestStation = {true, true, true, true, true},
bool moreCandidates = false)
{
return [items, subitems, requestStation, moreCandidates](const ROFRecord& rof) {
std::array<int, 10> nofItemsPerChamber = perChamber(items.subspan(rof.getFirstIdx(), rof.getNEntries()), subitems);
return isTrackable(nofItemsPerChamber, requestStation, moreCandidates);
};
}

} // namespace o2::mch

#endif
1 change: 1 addition & 0 deletions Detectors/MUON/MCH/Workflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ o2_add_library(MCHWorkflow
O2::MCHPreClustering
O2::MCHRawCommon
O2::MCHRawDecoder
O2::MCHROFFiltering
ROOT::TreePlayer
)

Expand Down
35 changes: 31 additions & 4 deletions Detectors/MUON/MCH/Workflow/src/ClusterFinderOriginalSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@
#include "Framework/Logger.h"

#include "CommonUtils/ConfigurableParam.h"
#include "DataFormatsMCH/ROFRecord.h"
#include "DataFormatsMCH/Cluster.h"
#include "DataFormatsMCH/Digit.h"
#include "DataFormatsMCH/ROFRecord.h"
#include "MCHBase/Error.h"
#include "MCHBase/ErrorMap.h"
#include "MCHBase/PreCluster.h"
#include "DataFormatsMCH/Cluster.h"
#include "MCHBase/TrackerParam.h"
#include "MCHClustering/ClusterFinderOriginal.h"
#include "MCHClustering/ClusterizerParam.h"
#include "MCHROFFiltering/TrackableFilter.h"

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

// create the trackable ROF filtering if needed
ROFFilter trackable{};
if (ClusterizerParam::Instance().onlyTrackable) {
const auto& trackerParam = TrackerParam::Instance();
std::array<bool, 5> requestStation{
trackerParam.requestStation[0],
trackerParam.requestStation[1],
trackerParam.requestStation[2],
trackerParam.requestStation[3],
trackerParam.requestStation[4]};
trackable = createTrackableFilter(preClusters, digits, requestStation, trackerParam.moreCandidates);
}

clusterROFs.reserve(preClusterROFs.size());
auto& errorMap = mClusterFinder.getErrorMap();
errorMap.clear();
int nFilteredRofs = 0;
int nFilteredPreClusters = 0;
for (const auto& preClusterROF : preClusterROFs) {

// filter out non-trackable ROFs if requested
if (ClusterizerParam::Instance().onlyTrackable && !trackable(preClusterROF)) {
// create an empty cluster ROF
clusterROFs.emplace_back(preClusterROF.getBCData(), clusters.size(), 0, preClusterROF.getBCWidth());
continue;
}
++nFilteredRofs;
nFilteredPreClusters += preClusterROF.getNEntries();

// prepare to clusterize the current ROF
auto clusterOffset = clusters.size();
mClusterFinder.reset();
Expand Down Expand Up @@ -137,8 +164,8 @@ class ClusterFinderOriginalTask
});
mErrorMap.add(errorMap);

LOGP(info, "Found {:4d} clusters from {:4d} preclusters in {:2d} ROFs",
clusters.size(), preClusters.size(), preClusterROFs.size());
LOGP(info, "Found {:4d} clusters from {:4d} preclusters (out of {:4d}) in {:2d} filtered ROFs (out of {:2d})",
clusters.size(), nFilteredPreClusters, preClusters.size(), nFilteredRofs, preClusterROFs.size());
}

private:
Expand Down
Loading