35 if (bcFromTFStart < 0) {
42void enableCompatibleROFs(
int baseLayer,
47 sel.setROFEnabled(baseLayer, baseRof);
49 if (
layer == baseLayer) {
52 const auto& overlap = overlapView.getOverlap(baseLayer,
layer, baseRof);
53 if (overlap.getEntries() > 0) {
54 sel.setROFsEnabled(
layer, overlap.getFirstEntry(), overlap.getEntries());
60std::vector<int> buildMultiplicityCounts(
const std::array<gsl::span<const o2::itsmft::ROFRecord>, NLayers>& rofs,
61 const std::array<gsl::span<const o2::itsmft::CompClusterExt>, NLayers>& clus,
65 std::vector<int> multCounts;
67 multCounts.resize(rofs[multLayer].
size());
68 for (
size_t iRof = 0; iRof < rofs[multLayer].size(); ++iRof) {
69 multCounts[iRof] = rofs[multLayer][iRof].getNEntries();
75 multCounts.resize(rofs[0].
size(), 0);
76 for (
size_t iRof = 0; iRof < rofs[0].size(); ++iRof) {
77 for (
const auto& cluster : rofs[0][iRof].getROFData(clus[0])) {
78 if (chipMapping.
getLayer(cluster.getSensorID()) == multLayer) {
97 gRandom->SetSeed(std::time(
nullptr) % 0xffff);
111 while (
clusters[
i].getSensorID() < nchAcc) {
115 if (lr == targetLayer) {
128 const int layer = std::clamp(conf.cutMultClusLayer, 0,
NLayers - 1);
129 const float acc = conf.accCorr[
layer];
148 const int layer = std::clamp(conf.cutMultClusLayer, 0,
NLayers - 1);
149 const float acc = conf.accCorr[
layer];
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 = multEstConf.isMultCutRequested() ? std::clamp(multEstConf.cutMultClusLayer, 0,
NLayers - 1) : overlapView.getClock();
172 const auto multCounts = buildMultiplicityCounts<NLayers>(rofs, clus, doStaggering, selectionLayer);
173 const int selectionRofCount = doStaggering ?
static_cast<int>(rofs[selectionLayer].size()) :
static_cast<int>(rofs[0].size());
180 int entry = 0, priority = 0;
182 std::vector<ROFStatus> selROFs;
183 selROFs.reserve(selectionRofCount);
184 bool selmult = multEstConf.isMultCutRequested();
185 for (
int selectionRof = 0; selectionRof < selectionRofCount; ++selectionRof) {
186 selROFs.emplace_back(selectionRof, (selmult && !multEstConf.isPassingMultCut(
process(multCounts[selectionRof]))) ? -1 : 0);
188 if (!trig.empty() && multEstConf.preferTriggered) {
189 const auto& selectionLayerTiming = overlapView.getLayer(selectionLayer);
190 for (
const auto& trigger : trig) {
191 const int selectionRof = findROFForIR(trigger.ir, tfStartIR, selectionLayerTiming);
192 if (selectionRof < 0 || selROFs[selectionRof].priority < 0) {
195 selROFs[selectionRof].priority++;
197 sort(selROFs.begin(), selROFs.end(), [](
const ROFStatus&
a,
const ROFStatus&
b) { return a.priority > b.priority; });
200 for (
auto& rof : selROFs) {
201 if (rof.priority >= 0 && (multEstConf.cutRandomFraction <= 0.f || (gRandom->Rndm() > multEstConf.cutRandomFraction))) {
202 enableCompatibleROFs<NLayers>(selectionLayer, rof.entry, overlapView, sel);
206 LOGP(
debug,
"NSel = {} of {} rofs on layer {} Seeds: before {} after {}", nsel, selectionRofCount, selectionLayer,
lastRandomSeed, gRandom->GetSeed());
Fast multiplicity estimator for ITS.
static const FastMultEstConfig & Instance()
static constexpr int getNChipsPerLr(int l)
compose FEEid for given stave (ru) relative to layer and link, see documentation in the constructor
static constexpr int getNChips()
number of chips per barrel
static constexpr int getLayer(int chipSW)
GLboolean GLboolean GLboolean b
GLenum GLuint GLint GLint layer
GLboolean GLboolean GLboolean GLboolean a
int64_t differenceInBC(const InteractionRecord &other) const
FastMultEst()
state of the gRandom before
ROFMaskTable< NLayers > ROFMaskTableN
float processNoiseFree(int nClusters)
int countClustersOnLayer(const gsl::span< const o2::itsmft::CompClusterExt > &clusters) const
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)
float process(int nClusters)
int nLayersUsed
retained for compatibility; set to zero in single-layer mode
uint32_t lastRandomSeed
number of layers used by estimator (0/1 in single-layer mode)
float cov[3]
imposed noise per chip (when enabled by configuration)
float noisePerChip
estimated signal clusters multiplicity on the selected multiplicity layer
float chi2
retained for compatibility; set to zero in single-layer mode
static constexpr int NLayers
float processNoiseImposed(int nClusters)
o2::InteractionRecord ir(0, 0)
std::vector< Cluster > clusters