21 inline void memset(T* dest, T
i,
size_t num) {
22 const size_t tsize =
sizeof(T);
23 unsigned int lastBin = 0;
25 while (lastBin + 1 < num) {
26 unsigned int l = lastBin + 1;
27 l = lastBin + l + 1 > num ? num - lastBin - 1 : l;
28 memcpy(dest + lastBin + 1, dest, l * tsize);
36 vector<THitI>* indicesBuf,
38 vector<L1StsHit>* hits2,
39 vector<L1HitPoint>* pointsBuf,
44 const vector<unsigned char>* vSFlag,
45 const vector<unsigned char>* vSFlagB) {
47 fFirstHitInBin.assign(fN + 2, 0);
53 #pragma omp parallel for schedule(dynamic, 250) firstprivate(xs, ys)
55 for (
THitI x = 0;
x < Nelements;
x++) {
59 if (!L1Algo::GetFUsed((*vSFlag)[hit.
f] | (*vSFlagB)[hit.
b])) {
62 const THitI& bin = GetBinBounded(xs, ys, hit.
t_reco);
64 fHitsInBin[
x] = fFirstHitInBin[bin + 1];
68 fFirstHitInBin[bin + 1]++;
74 for (
unsigned int k = 1; k < fN + 2; k = kk) {
77 #pragma omp parallel for //schedule(guided)
79 for (
unsigned int i = kk - 1;
i < fN + 2;
i += kk) {
80 fFirstHitInBin[
i] = fFirstHitInBin[
i - k] + fFirstHitInBin[
i];
85 for (
int k = kk >> 1; k > 1; k = kk) {
88 #pragma omp parallel for //schedule(guided)
90 for (
unsigned int i = k - 1;
i < fN + 2 - kk;
i += k) {
91 fFirstHitInBin[
i + kk] = fFirstHitInBin[
i] + fFirstHitInBin[
i + kk];
96 #pragma omp parallel for schedule(dynamic, 250) firstprivate(xs, ys)
98 for (
THitI x = 0;
x < Nelements;
x++) {
101 if (!L1Algo::GetFUsed((*vSFlag)[hit.
f] | (*vSFlagB)[hit.
b])) {
105 const THitI& bin = GetBinBounded(xs, ys, hit.
t_reco);
109 const THitI& index1 = fHitsInBin[
x] + fFirstHitInBin[bin];
111 (*hits2)[index1 + NHitsOnStation] =
hits[
x];
112 (*indicesBuf)[index1 + NHitsOnStation] = indices[
x];
113 (*pointsBuf)[index1 + NHitsOnStation] =
points[
x];
118 NHitsOnStation += fFirstHitInBin[fN + 1];
124 fNThreads = NThreads * 1;
129 int binsGrid = 600000;
131 fFirstHitInBin.resize(binsGrid, 0);
132 fHitsInBin.resize(binsGrid, 0);
156 fStepYInv = 1.f / sy;
157 fStepZInv = 1.f / sz;
158 fStepTInv = 1.f / st;
160 fYMinOverStep = yMin * fStepYInv;
161 fZMinOverStep = zMin * fStepZInv;
162 fTMinOverStep = tMin * fStepTInv;
164 fNy = (yMax * fStepYInv - fYMinOverStep + 1.f);
165 fNz = (zMax * fStepZInv - fZMinOverStep + 1.f);
166 fNt = (tMax * fStepTInv - fTMinOverStep + 1.f);
169 fN = fNy * fNz * fNt;
171 fBinInGrid = (((fN) / fNThreads) + 1);
187 fFirstHitInBin.assign(fN + 2, 0);
190 #pragma omp parallel for firstprivate(xs, ys)
196 fHitsInBin[
x] = fFirstHitInBin[GetBinBounded(xs, ys, (
hits)[
x].t_reco) + 1];
200 fFirstHitInBin[GetBinBounded(xs, ys, (
hits)[
x].t_reco) + 1]++;
206 for (
unsigned int k = 1; k < fN + 2; k = kk) {
209 #pragma omp parallel for //schedule(guided)
211 for (
unsigned int i = kk - 1;
i < fN + 2;
i += kk) {
212 fFirstHitInBin[
i] = fFirstHitInBin[
i - k] + fFirstHitInBin[
i];
217 for (
unsigned int k = kk >> 1; k > 1; k = kk) {
220 #pragma omp parallel for //schedule(guided)
222 for (
unsigned int i = k - 1;
i < fN + 2 - kk;
i += k) {
223 fFirstHitInBin[
i + kk] = fFirstHitInBin[
i] + fFirstHitInBin[
i + kk];
228 #pragma omp parallel for firstprivate(xs, ys)
234 const THitI& bin = GetBinBounded(xs, ys, (hits1)[
x].t_reco);
238 const THitI& index1 = fHitsInBin[
x] + fFirstHitInBin[bin];
240 (hitsBuf1)[index1] =
hits[
x];
243 (indices1)[index1] =
x + n;