31 gRandom->SetSeed(std::time(
nullptr) % 0xffff);
59 float mat[3] = {0},
b[2] = {0};
61 for (
int il = conf.firstLayer; il <= conf.lastLayer; il++) {
64 float err2i = 1. / ncl[il];
65 float m2n = nch * err2i;
66 mat[0] += err2i * conf.accCorr[il] * conf.accCorr[il];
68 mat[1] += conf.accCorr[il] * m2n;
69 b[0] += conf.accCorr[il];
75 float det = mat[0] * mat[2] - mat[1] * mat[1];
79 float detI = 1. / det;
80 mult = detI * (
b[0] * mat[2] -
b[1] * mat[1]);
82 cov[0] = mat[2] * detI;
83 cov[2] = mat[0] * detI;
84 cov[1] = -mat[1] * detI;
86 for (
int il = conf.firstLayer; il <= conf.lastLayer; il++) {
90 chi2 += diff * diff / ncl[il];
110 float w2sum = 0., wnsum = 0., wsum = 0.;
112 for (
int il = conf.firstLayer; il <= conf.lastLayer; il++) {
115 w2sum += conf.accCorr[il] * conf.accCorr[il] * nchInv;
116 wnsum += ncl[il] * nchInv * conf.accCorr[il];
117 wsum += conf.accCorr[il];
127 auto w2sumI = 1. / w2sum;
129 cov[0] = wnsum * w2sumI;
134 for (
int il = conf.firstLayer; il <= conf.lastLayer; il++) {
137 float diff = noise - estNoise;
138 chi2 += diff * diff / estNoise;
145int FastMultEst::selectROFs(
const gsl::span<const o2::itsmft::ROFRecord> rofs,
const gsl::span<const o2::itsmft::CompClusterExt> clus,
146 const gsl::span<const o2::itsmft::PhysTrigger> trig, std::vector<bool>& sel)
148 int nrof = rofs.size(), nsel = 0;
151 sel.resize(nrof,
true);
153 if (multEstConf.isMultCutRequested()) {
154 for (uint32_t irof = 0; irof < nrof; irof++) {
155 nsel += sel[irof] = multEstConf.isPassingMultCut(
process(rofs[irof].getROFData(clus)));
160 using IdNT = std::pair<int, int>;
161 if (multEstConf.cutRandomFraction > 0.) {
162 int ntrig = trig.size(), currTrig = 0;
163 if (multEstConf.preferTriggered) {
165 std::vector<IdNT> nTrigROF;
166 nTrigROF.reserve(nrof);
167 for (uint32_t irof = 0; irof < nrof; irof++) {
169 if (nsel && gRandom->Rndm() < multEstConf.cutRandomFraction) {
172 auto irROF = rofs[irof].getBCData();
173 while (currTrig < ntrig && trig[currTrig].
ir < irROF) {
176 auto& trof = nTrigROF.emplace_back(irof, 0);
177 irROF += alpParams.roFrameLengthInBC;
178 while (currTrig < ntrig && trig[currTrig].
ir < irROF) {
185 sort(nTrigROF.begin(), nTrigROF.end(), [](
const IdNT&
a,
const IdNT&
b) { return a.second > b.second; });
186 auto last = nTrigROF.begin() + nsel;
187 sort(nTrigROF.begin(), last, [](
const IdNT&
a,
const IdNT&
b) { return a.first < b.first; });
189 for (
int i = nsel;
i <
int(nTrigROF.size());
i++) {
190 sel[nTrigROF[
i].first] =
false;
193 for (
int irof = 0; irof < nrof; irof++) {
195 float sr = gRandom->Rndm();
196 if (gRandom->Rndm() < multEstConf.cutRandomFraction) {
204 LOGP(
debug,
"NSel = {} of {} rofs Seeds: before {} after {}", nsel, nrof,
lastRandomSeed, gRandom->GetSeed());
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
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
std::array< int, NLayers > nClPerLayer
state of the gRandom before
float processNoiseFree(const std::array< int, NLayers > ncl)
void fillNClPerLayer(const gsl::span< const o2::itsmft::CompClusterExt > &clusters)
float processNoiseImposed(const std::array< int, NLayers > ncl)
uint32_t lastRandomSeed
number of layers actually used
int selectROFs(const gsl::span< const o2::itsmft::ROFRecord > rofs, const gsl::span< const o2::itsmft::CompClusterExt > clus, const gsl::span< const o2::itsmft::PhysTrigger > trig, std::vector< uint8_t > &sel)
float cov[3]
estimated or imposed noise per chip
float noisePerChip
estimated signal clusters multipliciy at reference (1st?) layer
float chi2
covariance matrix of estimation
static constexpr int NLayers
o2::InteractionRecord ir(0, 0)
std::vector< Cluster > clusters