163 const std::array<gsl::span<const o2::itsmft::CompClusterExt>, NLayers>& clus,
164 const gsl::span<const o2::itsmft::PhysTrigger> trig,
165 uint32_t firstTForbit,
167 const ROFOverlapTableN::View& overlapView,
171 const int selectionLayer = overlapView.getClock();
172 int multLayer = std::clamp(multEstConf.cutMultClusLayer, 0,
NLayers - 1);
173 if (doStaggering && rofs[multLayer].
empty()) {
174 LOGP(info,
"FastMultEst multiplicity layer {} has no ROFs, falling back to selection layer {}", multLayer, selectionLayer);
175 multLayer = selectionLayer;
178 const auto multCounts = buildMultiplicityCounts<NLayers>(rofs, clus, doStaggering, multLayer);
179 const int selectionRofCount = doStaggering ?
static_cast<int>(rofs[selectionLayer].size()) :
static_cast<int>(rofs[0].size());
186 const auto& selectionLayerTiming = overlapView.getLayer(selectionLayer);
187 const auto& multLayerTiming = overlapView.getLayer(multLayer);
189 for (
const auto& trigger : trig) {
190 const int selectionRof = findROFForIR(trigger.ir, tfStartIR, selectionLayerTiming);
191 if (selectionRof < 0) {
194 if (multEstConf.cutRandomFraction > 0.f && gRandom->Rndm() < multEstConf.cutRandomFraction) {
197 if (multEstConf.isMultCutRequested()) {
198 const int triggerMultRof = doStaggering ? findROFForIR(trigger.ir, tfStartIR, multLayerTiming) : selectionRof;
199 if (triggerMultRof < 0 || triggerMultRof >=
static_cast<int>(multCounts.size())) {
202 if (!multEstConf.isPassingMultCut(
process(multCounts[triggerMultRof]))) {
206 enableCompatibleROFs<NLayers>(selectionLayer, selectionRof, overlapView, sel);
209 LOGP(info,
"FastMultEst received no physics/TRD triggers, falling back to ROF-driven filtering on layer {}", selectionLayer);
210 for (
int selectionRof = 0; selectionRof < selectionRofCount; ++selectionRof) {
211 if (multEstConf.isMultCutRequested()) {
213 if (!doStaggering || selectionLayer == multLayer) {
214 if (selectionRof <
static_cast<int>(multCounts.size())) {
215 passes = multEstConf.isPassingMultCut(
process(multCounts[selectionRof]));
218 const auto& overlap = overlapView.getOverlap(selectionLayer, multLayer, selectionRof);
219 for (
int rof = overlap.getFirstEntry(); rof < overlap.getEntriesBound(); ++rof) {
220 if (rof <
static_cast<int>(multCounts.size())) {
221 if (multEstConf.isPassingMultCut(
process(multCounts[rof]))) {
232 if (multEstConf.cutRandomFraction > 0.f && gRandom->Rndm() < multEstConf.cutRandomFraction) {
235 enableCompatibleROFs<NLayers>(selectionLayer, selectionRof, overlapView, sel);
239 const auto selView = sel.getView();
241 for (
int irof = 0; irof < selectionRofCount; ++irof) {
242 nsel += selView.isROFEnabled(selectionLayer, irof);
245 if (!trig.empty() && multEstConf.preferTriggered) {
246 LOGP(
debug,
"FastMultEst preferTriggered is ignored in trigger-driven mask mode");
249 LOGP(
debug,
"NSel = {} of {} rofs on layer {} Seeds: before {} after {}", nsel, selectionRofCount, selectionLayer,
lastRandomSeed, gRandom->GetSeed());
int selectROFs(const std::array< gsl::span< const o2::itsmft::ROFRecord >, NLayers > &rofs, const std::array< gsl::span< const o2::itsmft::CompClusterExt >, NLayers > &clus, const gsl::span< const o2::itsmft::PhysTrigger > trig, uint32_t firstTForbit, bool doStaggering, const ROFOverlapTableN::View &overlapView, ROFMaskTableN &sel)