12 #include <cuda_runtime.h>
38 constexpr
float nSigma2 = 25.f;
47 uint32_t
const *__restrict__
nCells,
68 printf(
"number of found cells %d, found tuples %d with total hits %d out of %d %d\n",
91 printf(
"Tuples overflow\n");
93 printf(
"Cells overflow\n");
95 printf(
"cellNeighbors overflow\n");
97 printf(
"cellTracks overflow\n");
104 if (thisCell.outerNeighbors().full())
105 printf(
"OuterNeighbors overflow %d in %d\n",
idx, thisCell.layerPairId());
106 if (thisCell.tracks().full())
107 printf(
"Tracks overflow %d in %d\n",
idx, thisCell.layerPairId());
108 if (thisCell.isKilled())
110 if (thisCell.unused())
112 if (0 ==
hitToTuple->size(thisCell.inner_hit_id()) && 0 ==
hitToTuple->size(thisCell.outer_hit_id()))
118 printf(
"OuterHitOfCell overflow %d\n",
idx);
128 if (!thisCell.isKilled())
131 for (
auto it : thisCell.tracks())
151 if (thisCell.tracks().size() < 2)
159 for (
auto it : thisCell.tracks()) {
167 for (
auto it : thisCell.tracks()) {
189 if (thisCell.tracks().size() < 2)
194 uint16_t im = tkNotFound;
207 int ntr = thisCell.tracks().size();
208 for (
int i = 0;
i < ntr; ++
i) {
209 auto it = thisCell.tracks()[
i];
210 auto qi =
tracks->quality(it);
213 auto opi =
tracks->stateAtBS.state(it)(2);
214 auto e2opi =
tracks->stateAtBS.covariance(it)(9);
215 auto cti =
tracks->stateAtBS.state(it)(3);
216 auto e2cti =
tracks->stateAtBS.covariance(it)(12);
217 for (
auto j =
i + 1;
j < ntr; ++
j) {
218 auto jt = thisCell.tracks()[
j];
219 auto qj =
tracks->quality(jt);
226 auto opj =
tracks->stateAtBS.state(jt)(2);
227 auto ctj =
tracks->stateAtBS.state(jt)(3);
228 auto dct = nSigma2 * (
tracks->stateAtBS.covariance(jt)(12) + e2cti);
229 if ((cti - ctj) * (cti - ctj) > dct)
231 auto dop = nSigma2 * (
tracks->stateAtBS.covariance(jt)(9) + e2opi);
232 if ((opi - opj) * (opi - opj) > dop)
234 if ((qj < qi) || (qj == qi &&
score(it) <
score(jt)))
245 for (
auto it : thisCell.tracks()) {
246 if (
tracks->quality(it) > maxQual)
247 maxQual =
tracks->quality(it);
250 if (maxQual <=
loose)
254 for (
auto it : thisCell.tracks()) {
261 if (tkNotFound == im)
265 for (
auto it : thisCell.tracks()) {
276 uint32_t
const *__restrict__
nCells,
281 float CAThetaCutBarrel,
282 float CAThetaCutForward,
283 float dcaCutInnerTriplet,
284 float dcaCutOuterTriplet) {
285 auto const &
hh = *
hhp;
291 if (0 == (firstCellIndex +
first)) {
297 auto cellIndex =
idx;
299 auto innerHitId = thisCell.inner_hit_id();
303 auto ri = thisCell.inner_r(
hh);
304 auto zi = thisCell.inner_z(
hh);
306 auto ro = thisCell.outer_r(
hh);
307 auto zo = thisCell.outer_z(
hh);
311 auto otherCell =
__ldg(vi +
j);
312 auto &oc =
cells[otherCell];
313 auto r1 = oc.inner_r(
hh);
314 auto z1 = oc.inner_z(
hh);
315 bool aligned = GPUCACell::areAlignedRZ(
323 isBarrel ? CAThetaCutBarrel : CAThetaCutForward);
324 if (aligned && thisCell.dcaCut(
hh,
327 : dcaCutOuterTriplet,
330 thisCell.setUsedBit(1);
344 unsigned int minHitsPerNtuplet) {
346 auto const &
hh = *
hhp;
351 if (thisCell.isKilled())
354 if (thisCell.outerNeighbors().empty())
356 auto pid = thisCell.layerPairId();
357 auto doit = minHitsPerNtuplet > 3 ? pid < 3 : pid < 8 || pid > 12;
374 if (!thisCell.tracks().empty())
375 thisCell.setUsedBit(2);
391 printf(
"wrong mult %d %d\n", it,
nhits);
409 printf(
"wrong mult %d %d\n", it,
nhits);
437 for (
int i = 0;
i < 5; ++
i) {
442 printf(
"NaN in fit %d size %d chi2 %f\n", it,
tuples->size(it),
tracks->chi2(it));
451 auto roughLog = [](
float x) {
460 uint32_t
lsb = 1 < 21;
464 int ex =
int(
z.i >> 2) - 127;
468 const float frac[4] = {0.160497f, 0.452172f, 0.694562f, 0.901964f};
473 float pt = std::min<float>(
tracks->pt(it),
cuts.chi2MaxPt);
476 #ifdef NTUPLE_FIT_DEBUG
477 printf(
"Bad chi2 %d size %d pt %f eta %f chi2 %f\n",
573 __global__ void kernel_countSharedHit(
int *__restrict__ nshared,
609 __global__ void kernel_markSharedHit(
int const *__restrict__ nshared,
627 if (nshared[
idx] > 2)
666 auto opi =
tracks.stateAtBS.state(it)(2);
667 auto e2opi =
tracks.stateAtBS.covariance(it)(9);
668 auto cti =
tracks.stateAtBS.state(it)(3);
669 auto e2cti =
tracks.stateAtBS.covariance(it)(12);
676 auto opj =
tracks.stateAtBS.state(jt)(2);
677 auto ctj =
tracks.stateAtBS.state(jt)(3);
678 auto dct = nSigma2 * (
tracks.stateAtBS.covariance(jt)(12) + e2cti);
679 if ((cti - ctj) * (cti - ctj) > dct)
681 auto dop = nSigma2 * (
tracks.stateAtBS.covariance(jt)(9) + e2opi);
682 if ((opi - opj) * (opi - opj) > dop)
685 if (
nhj < nhi || (
nhj == nhi && (qj < qi || (qj == qi &&
score(it, nhi) <
score(jt,
nhj)))))
712 auto const &
hh = *
hhp;
741 if (idx < l1end and nh >
nmin)
772 uint16_t im = tkNotFound;
796 if (tkNotFound == im)
832 uint16_t im = tkNotFound;
843 if (tkNotFound == im)
870 printf(
"TK: %d %d %d %f %f %f %f %f %f %f %d %d %d %d %d\n",
893 "||Counters | nEvents | nHits | nCells | nTuples | nFitTacks | nLooseTracks | nGoodTracks | nUsedHits | "
896 "nEmptyCells | nZeroTrackCells ||\n");
897 printf(
"Counters Raw %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld\n",
910 printf(
"Counters Norm %lld || %.1f| %.1f| %.1f| %.1f| %.1f| %.1f| %.1f| %.1f| %.1f| %.3f| %.3f||\n",
912 c.nHits /
double(
c.nEvents),
913 c.nCells /
double(
c.nEvents),
914 c.nTuples /
double(
c.nEvents),
915 c.nFitTracks /
double(
c.nEvents),
916 c.nLooseTracks /
double(
c.nEvents),
917 c.nGoodTracks /
double(
c.nEvents),
918 c.nUsedHits /
double(
c.nEvents),
919 c.nDupHits /
double(
c.nEvents),
920 c.nKilledCells /
double(
c.nEvents),
921 c.nEmptyCells /
double(
c.nCells),
922 c.nZeroTrackCells /
double(
c.nCells));