11 #include "vdt/vdtMath.h"
22 maxIterations_ = 1000;
36 coolingFactor_ = conf.
getParameter<
double>(
"coolingFactor");
39 uniquetrkweight_ = conf.
getParameter<
double>(
"uniquetrkweight");
40 uniquetrkminp_ = conf.
getParameter<
double>(
"uniquetrkminp");
43 convergence_mode_ = conf.
getParameter<
int>(
"convergence_mode");
48 std::cout <<
"DAClusterizerinZ_vect: mintrkweight = " << mintrkweight_ << std::endl;
49 std::cout <<
"DAClusterizerinZ_vect: uniquetrkweight = " << uniquetrkweight_ << std::endl;
50 std::cout <<
"DAClusterizerInZ_vect: uniquetrkminp = " << uniquetrkminp_ << std::endl;
51 std::cout <<
"DAClusterizerinZ_vect: zmerge = " << zmerge_ << std::endl;
52 std::cout <<
"DAClusterizerinZ_vect: Tmin = " << Tmin << std::endl;
53 std::cout <<
"DAClusterizerinZ_vect: Tpurge = " << Tpurge << std::endl;
54 std::cout <<
"DAClusterizerinZ_vect: Tstop = " << Tstop << std::endl;
55 std::cout <<
"DAClusterizerinZ_vect: vertexSize = " << vertexSize_ << std::endl;
56 std::cout <<
"DAClusterizerinZ_vect: coolingFactor = " << coolingFactor_ << std::endl;
57 std::cout <<
"DAClusterizerinZ_vect: d0CutOff = " << d0CutOff_ << std::endl;
58 std::cout <<
"DAClusterizerinZ_vect: dzCutOff = " << dzCutOff_ << std::endl;
59 std::cout <<
"DAClusterizerInZ_vect: zrange = " << sel_zrange_ << std::endl;
60 std::cout <<
"DAClusterizerinZ_vect: convergence mode = " << convergence_mode_ << std::endl;
61 std::cout <<
"DAClusterizerinZ_vect: delta_highT = " << delta_highT_ << std::endl;
62 std::cout <<
"DAClusterizerinZ_vect: delta_lowT = " << delta_lowT_ << std::endl;
63 std::cout <<
"DAClusterizerinZ_vect: DEBUGLEVEL " << DEBUGLEVEL << std::endl;
66 if (convergence_mode_ > 1) {
68 <<
"DAClusterizerInZ_vect: invalid convergence_mode " << convergence_mode_ <<
" reset to default " << 0;
69 convergence_mode_ = 0;
75 <<
"DAClusterizerInZ_vect: invalid Tmin " << Tmin <<
" reset to default " << 1. / betamax_;
80 if ((Tpurge > Tmin) || (Tpurge == 0)) {
82 <<
"DAClusterizerInZ_vect: invalid Tpurge " << Tpurge <<
" set to " <<
Tmin;
85 betapurge_ = 1. / Tpurge;
87 if ((Tstop > Tpurge) || (Tstop == 0)) {
89 <<
"DAClusterizerInZ_vect: invalid Tstop " << Tstop <<
" set to " <<
max(1., Tpurge);
90 Tstop =
max(1., Tpurge);
92 betastop_ = 1. / Tstop;
96 inline double local_exp(
double const& inp) {
return vdt::fast_exp(inp); }
98 inline void local_exp_list_range(
double const* __restrict__ arg_inp,
99 double* __restrict__ arg_out,
102 for (
auto i = kmin;
i != kmax; ++
i)
103 arg_out[
i] = vdt::fast_exp(arg_inp[
i]);
109 if (!(nv == 999999)) {
115 if (!(nt == 999999)) {
138 for (
unsigned int k = 0;
k < nv - 1;
k++) {
141 cout <<
" Z, cluster z-ordering assertion failure z[" <<
k <<
"] =" << v.
zvtx_vec[
k] <<
" z[" <<
k + 1
158 for (
unsigned int i = 0;
i <
nt;
i++) {
161 cout <<
"track vertex range assertion failure" <<
i <<
"/" << nt <<
" kmin,kmax=" << tks.
kmin[
i] <<
", "
162 << tks.
kmax[
i] <<
" nv=" << nv << endl;
165 for (
unsigned int i = 0;
i <
nt;
i++) {
174 for (
auto it = tracks.begin(); it != tracks.end(); it++) {
175 if (!(*it).isValid())
178 double t_z = ((*it).stateAtBeamLine().trackStateAtPCA()).
position().z();
179 if (std::fabs(t_z) > 1000.)
181 auto const& t_mom = (*it).stateAtBeamLine().trackStateAtPCA().momentum();
184 double t_dz2 =
std::pow((*it).track().dzError(), 2)
192 Measurement1D atIP = (*it).stateAtBeamLine().transverseImpactParameter();
196 edm::LogWarning(
"DAClusterizerinZ_vect") <<
"rejected track t_tkwt " << t_tkwt;
205 tks.
osumtkwt = sumtkwt > 0 ? 1. / sumtkwt : 0.;
208 if (DEBUGLEVEL > 0) {
217 inline double Eik(
double t_z,
double k_z,
double t_dz2) {
return std::pow(t_z - k_z, 2) * t_dz2; }
221 const unsigned int nv = gvertices.
getSize();
222 const unsigned int nt = gtracks.
getSize();
225 edm::LogWarning(
"DAClusterizerinZ_vect") <<
"empty cluster list in set_vtx_range";
229 for (
auto itrack = 0U; itrack <
nt; ++itrack) {
230 double zrange =
max(sel_zrange_ /
sqrt(beta * gtracks.
dz2[itrack]), zrange_min_);
232 double zmin = gtracks.
zpca[itrack] - zrange;
233 unsigned int kmin =
min(nv - 1, gtracks.
kmin[itrack]);
235 if (gvertices.
zvtx[kmin] > zmin) {
236 while ((kmin > 0) && (gvertices.
zvtx[kmin - 1] > zmin)) {
240 while ((kmin < (nv - 1)) && (gvertices.
zvtx[kmin] < zmin)) {
245 double zmax = gtracks.
zpca[itrack] + zrange;
246 unsigned int kmax =
min(nv - 1, gtracks.
kmax[itrack] - 1);
249 if (gvertices.
zvtx[kmax] < zmax) {
250 while ((kmax < (nv - 1)) && (gvertices.
zvtx[kmax + 1] < zmax)) {
254 while ((kmax > 0) && (gvertices.
zvtx[kmax] > zmax)) {
260 gtracks.
kmin[itrack] = kmin;
261 gtracks.
kmax[itrack] = kmax + 1;
263 gtracks.
kmin[itrack] =
max(0U,
min(kmin, kmax));
264 gtracks.
kmax[itrack] =
min(nv,
max(kmin, kmax) + 1);
270 const unsigned int nt = gtracks.
getSize();
271 const unsigned int nv = gvertices.
getSize();
272 for (
auto itrack = 0U; itrack <
nt; ++itrack) {
273 gtracks.
kmin[itrack] = 0;
274 gtracks.
kmax[itrack] = nv;
279 double beta,
track_t& gtracks,
vertex_t& gvertices,
const double rho0,
const bool updateTc)
const {
284 const unsigned int nt = gtracks.
getSize();
285 const unsigned int nv = gvertices.
getSize();
290 Z_init = rho0 * local_exp(-beta * dzCutOff_ * dzCutOff_);
294 auto kernel_calc_exp_arg_range = [
beta](
const unsigned int itrack,
297 const unsigned int kmin,
298 const unsigned int kmax) {
299 const double track_z = tracks.zpca[itrack];
300 const double botrack_dz2 = -beta * tracks.dz2[itrack];
303 for (
unsigned int ivertex = kmin; ivertex < kmax; ++ivertex) {
304 auto mult_res = track_z - vertices.zvtx[ivertex];
305 vertices.exp_arg[ivertex] = botrack_dz2 * (mult_res * mult_res);
309 auto kernel_add_Z_range = [Z_init](
310 vertex_t const&
vertices,
const unsigned int kmin,
const unsigned int kmax) ->
double {
311 double ZTemp = Z_init;
312 for (
unsigned int ivertex = kmin; ivertex < kmax; ++ivertex) {
313 ZTemp += vertices.
rho[ivertex] * vertices.
exp[ivertex];
318 auto kernel_calc_normalization_range = [updateTc](
const unsigned int track_num,
321 const unsigned int kmin,
322 const unsigned int kmax) {
323 auto o_trk_sum_Z = tracks.tkwt[track_num] / tracks.sum_Z[track_num];
324 auto o_trk_dz2 = tracks.dz2[track_num];
325 auto tmp_trk_z = tracks.zpca[track_num];
330 for (
unsigned int k = kmin;
k < kmax; ++
k) {
331 vertices.se[
k] += vertices.exp[
k] * o_trk_sum_Z;
332 auto w = vertices.rho[
k] * vertices.exp[
k] * (o_trk_sum_Z * o_trk_dz2);
334 vertices.swz[
k] +=
w * tmp_trk_z;
335 vertices.swE[
k] +=
w * vertices.exp_arg[
k];
340 for (
unsigned int k = kmin;
k < kmax; ++
k) {
341 vertices.se[
k] += vertices.exp[
k] * o_trk_sum_Z;
342 auto w = vertices.rho[
k] * vertices.exp[
k] * (o_trk_sum_Z * o_trk_dz2);
344 vertices.swz[
k] +=
w * tmp_trk_z;
350 for (
auto ivertex = 0U; ivertex < nv; ++ivertex) {
351 gvertices.
se[ivertex] = 0.0;
352 gvertices.
sw[ivertex] = 0.0;
353 gvertices.
swz[ivertex] = 0.0;
354 gvertices.
swE[ivertex] = 0.0;
357 for (
auto ivertex = 0U; ivertex < nv; ++ivertex) {
358 gvertices.
se[ivertex] = 0.0;
359 gvertices.
sw[ivertex] = 0.0;
360 gvertices.
swz[ivertex] = 0.0;
365 for (
auto itrack = 0U; itrack <
nt; ++itrack) {
366 const unsigned int kmin = gtracks.
kmin[itrack];
367 const unsigned int kmax = gtracks.
kmax[itrack];
369 kernel_calc_exp_arg_range(itrack, gtracks, gvertices, kmin, kmax);
370 local_exp_list_range(gvertices.
exp_arg, gvertices.
exp, kmin, kmax);
371 gtracks.
sum_Z[itrack] = kernel_add_Z_range(gvertices, kmin, kmax);
374 gtracks.
sum_Z[itrack] = 0.0;
376 if (gtracks.
sum_Z[itrack] > 1.e-100) {
377 kernel_calc_normalization_range(itrack, gtracks, gvertices, kmin, kmax);
383 auto obeta = -1. /
beta;
384 for (
auto ivertex = 0U; ivertex < nv; ++ivertex) {
385 gvertices.
swE[ivertex] *= obeta;
393 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
394 if (vertices.sw[ivertex] > 0) {
395 auto znew = vertices.swz[ivertex] / vertices.sw[ivertex];
397 delta =
max(
std::abs(vertices.zvtx[ivertex] - znew), delta);
398 vertices.zvtx[ivertex] = znew;
402 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex)
403 vertices.rho[ivertex] = vertices.rho[ivertex] * vertices.se[ivertex] * osumtkwt;
408 double delta = kernel_calc_z(gvertices);
416 unsigned int niter = 0;
418 double delta_max = delta_lowT_;
420 if (convergence_mode_ == 0) {
421 delta_max = delta_max0;
422 }
else if (convergence_mode_ == 1) {
426 set_vtx_range(beta, tks, v);
427 double delta_sum_range = 0;
428 std::vector<double> z0 = v.
zvtx_vec;
430 while (niter++ < maxIterations_) {
431 delta =
update(beta, tks, v, rho0);
432 delta_sum_range +=
delta;
434 if (delta_sum_range > zrange_min_) {
435 for (
unsigned int k = 0;
k < v.
getSize();
k++) {
437 set_vtx_range(beta, tks, v);
445 if (delta < delta_max) {
451 if (DEBUGLEVEL > 0) {
452 std::cout <<
"DAClusterizerInZ_vect.thermalize niter = " << niter <<
" at T = " << 1 / beta
453 <<
" nv = " << v.
getSize() << std::endl;
455 dump(beta, v, tks, 0, rho0);
466 const unsigned int nv = y.
getSize();
472 std::vector<std::pair<double, unsigned int> >
critical;
473 for (
unsigned int k = 0; (
k + 1) < nv;
k++) {
474 if (std::fabs(y.
zvtx[
k + 1] - y.
zvtx[
k]) < zmerge_) {
475 critical.push_back(make_pair(std::fabs(y.
zvtx[
k + 1] - y.
zvtx[
k]),
k));
478 if (critical.empty())
481 std::stable_sort(critical.begin(), critical.end(), std::less<std::pair<double, unsigned int> >());
483 for (
unsigned int ik = 0; ik < critical.size(); ik++) {
484 unsigned int k = critical[ik].second;
485 double rho = y.
rho[
k] + y.
rho[k + 1];
489 if (DEBUGLEVEL > 1) {
490 std::cout <<
"merging " << fixed << setprecision(4) << y.
zvtx[k + 1] <<
" and " << y.
zvtx[
k]
491 <<
" sw = " << y.
sw[
k] + y.
sw[k + 1] << std::endl;
501 y.
sw[
k] += y.
sw[k + 1];
503 set_vtx_range(beta, tks, y);
512 constexpr
double eps = 1.e-100;
514 const unsigned int nv = y.
getSize();
520 std::vector<double> sump_v(nv), arg_cache_v(nv), exp_cache_v(nv), pcut_cache_v(nv);
521 std::vector<int> nUnique_v(nv);
522 double* __restrict__ parg_cache;
523 double* __restrict__ pexp_cache;
524 double* __restrict__ ppcut_cache;
525 double* __restrict__ psump;
526 int* __restrict__ pnUnique;
527 int constexpr nunique_min_ = 2;
529 set_vtx_range(beta, tks, y);
531 parg_cache = arg_cache_v.data();
532 pexp_cache = exp_cache_v.data();
533 ppcut_cache = pcut_cache_v.data();
534 psump = sump_v.data();
535 pnUnique = nUnique_v.data();
537 const auto rhoconst = rho0 * local_exp(-beta * dzCutOff_ * dzCutOff_);
538 for (
unsigned int k = 0;
k < nv;
k++) {
539 const double pmax = y.
rho[
k] / (y.
rho[
k] + rhoconst);
540 ppcut_cache[
k] = uniquetrkweight_ * pmax;
543 for (
unsigned int i = 0;
i <
nt;
i++) {
544 const auto invZ = ((tks.
sum_Z[
i] >
eps) && (tks.
tkwt[
i] > uniquetrkminp_)) ? 1. / tks.
sum_Z[
i] : 0.;
545 const auto track_z = tks.
zpca[
i];
546 const auto botrack_dz2 = -beta * tks.
dz2[
i];
547 const auto kmin = tks.
kmin[
i];
548 const auto kmax = tks.
kmax[
i];
550 for (
unsigned int k = kmin;
k < kmax;
k++) {
551 const auto mult_resz = track_z - y.
zvtx[
k];
552 parg_cache[
k] = botrack_dz2 * (mult_resz * mult_resz);
555 local_exp_list_range(parg_cache, pexp_cache, kmin, kmax);
557 for (
unsigned int k = kmin;
k < kmax;
k++) {
558 const double p = y.
rho[
k] * pexp_cache[
k] * invZ;
560 pnUnique[
k] += (p > ppcut_cache[
k]) ? 1 : 0;
565 unsigned int k0 = nv;
566 for (
unsigned k = 0;
k < nv;
k++) {
567 if ((pnUnique[
k] < nunique_min_) && (psump[
k] < sumpmin)) {
576 if (DEBUGLEVEL > 1) {
577 std::cout <<
"eliminating prototype at " << std::setw(10) << std::setprecision(4) << y.
zvtx[
k0]
578 <<
" with sump=" << sumpmin <<
" rho*nt =" << y.
rho[
k0] * nt << endl;
583 set_vtx_range(beta, tks, y);
594 const unsigned int nv = y.
getSize();
596 for (
unsigned int k = 0;
k < nv;
k++) {
600 for (
unsigned int i = 0;
i <
nt;
i++) {
602 sumwz += w * tks.
zpca[
i];
606 y.
zvtx[
k] = sumwz / sumw;
610 for (
unsigned int i = 0;
i <
nt;
i++) {
616 double Tc = 2. * a /
b;
624 if (DEBUGLEVEL > 0) {
625 std::cout <<
"DAClusterizerInZ_vect.beta0: Tc = " << T0 << std::endl;
626 int coolingsteps = 1 - int(
std::log(T0 * betamax) /
std::log(coolingFactor_));
627 std::cout <<
"DAClusterizerInZ_vect.beta0: nstep = " << coolingsteps << std::endl;
631 if (T0 > 1. / betamax) {
632 int coolingsteps = 1 - int(
std::log(T0 * betamax) /
std::log(coolingFactor_));
634 return betamax *
std::pow(coolingFactor_, coolingsteps);
637 return betamax * coolingFactor_;
646 update(beta, tks, y, 0.,
true);
653 std::vector<std::pair<double, unsigned int> >
critical;
654 for (
unsigned int k = 0;
k < nv;
k++) {
655 double Tc = 2 * y.
swE[
k] / y.
sw[
k];
656 if (beta * Tc > threshold) {
657 critical.push_back(make_pair(Tc,
k));
660 if (critical.empty())
663 std::stable_sort(critical.begin(), critical.end(), std::greater<std::pair<double, unsigned int> >());
668 for (
unsigned int ic = 0; ic < critical.size(); ic++) {
669 unsigned int k = critical[ic].second;
672 double p1 = 0, z1 = 0, w1 = 0;
673 double p2 = 0, z2 = 0,
w2 = 0;
674 for (
unsigned int i = 0;
i <
nt;
i++) {
675 if (tks.
sum_Z[
i] > 1.e-100) {
677 double tl = tks.
zpca[
i] < y.
zvtx[
k] ? 1. : 0.;
682 if (std::fabs(arg) < 20) {
683 double t = local_exp(-arg);
689 double w = p * tks.
dz2[
i];
691 z1 += w * tl * tks.
zpca[
i];
694 z2 += w * tr * tks.
zpca[
i];
711 if ((k > 0) && (z1 < (0.6 * y.
zvtx[k] + 0.4 * y.
zvtx[k - 1]))) {
712 z1 = 0.6 * y.
zvtx[
k] + 0.4 * y.
zvtx[k - 1];
714 if ((k + 1 < nv) && (z2 > (0.6 * y.
zvtx[k] + 0.4 * y.
zvtx[k + 1]))) {
715 z2 = 0.6 * y.
zvtx[
k] + 0.4 * y.
zvtx[k + 1];
720 if (DEBUGLEVEL > 1) {
721 if (std::fabs(y.
zvtx[k] - zdumpcenter_) < zdumpwidth_) {
722 std::cout <<
" T= " << std::setw(8) << 1. / beta <<
" Tc= " << critical[ic].first <<
" splitting "
723 << std::fixed << std::setprecision(4) << y.
zvtx[
k] <<
" --> " << z1 <<
"," << z2 <<
" [" << p1
725 if (std::fabs(z2 - z1) > epsilon) {
735 if ((z2 - z1) > epsilon) {
737 double pk1 = p1 * y.
rho[
k] / (p1 +
p2);
738 double pk2 = p2 * y.
rho[
k] / (p1 +
p2);
748 for (
unsigned int jc = ic; jc < critical.size(); jc++) {
749 if (critical[jc].
second >= k) {
750 critical[jc].second++;
755 std::cout <<
"warning ! split rejected, too small." << endl;
778 clear_vtx_range(tks, y);
781 double beta = beta0(betamax_, tks, y);
784 std::cout <<
"Beta0 is " << beta << std::endl;
787 thermalize(beta, tks, y, delta_highT_);
791 double betafreeze = betamax_ *
sqrt(coolingFactor_);
793 while (beta < betafreeze) {
794 while (
merge(y, tks, beta)) {
795 update(beta, tks, y, rho0,
false);
799 beta = beta / coolingFactor_;
800 thermalize(beta, tks, y, delta_highT_);
806 if (DEBUGLEVEL > 0) {
807 std::cout <<
"DAClusterizerInZ_vect::vertices :"
808 <<
"last round of splitting" << std::endl;
812 set_vtx_range(beta, tks, y);
813 update(beta, tks, y, rho0,
false);
815 while (
merge(y, tks, beta)) {
816 set_vtx_range(beta, tks, y);
817 update(beta, tks, y, rho0,
false);
820 unsigned int ntry = 0;
822 while (
split(beta, tks, y, threshold) && (ntry++ < 10)) {
823 thermalize(beta, tks, y, delta_highT_, rho0);
824 while (
merge(y, tks, beta)) {
825 update(beta, tks, y, rho0,
false);
834 if (DEBUGLEVEL > 0) {
835 std::cout <<
"DAClusterizerInZ_vect::vertices :"
836 <<
"turning on outlier rejection at T=" << 1 / beta << std::endl;
843 for (
unsigned int a = 0;
a < 5;
a++) {
844 update(beta, tks, y,
a * rho0 / 5.);
848 thermalize(beta, tks, y, delta_lowT_, rho0);
852 if (DEBUGLEVEL > 0) {
853 std::cout <<
"DAClusterizerInZ_vect::vertices :"
854 <<
"merging with outlier rejection at T=" << 1 / beta << std::endl;
857 dump(beta, y, tks, 2, rho0);
861 while (
merge(y, tks, beta)) {
862 set_vtx_range(beta, tks, y);
863 update(beta, tks, y, rho0,
false);
868 if (DEBUGLEVEL > 0) {
869 std::cout <<
"DAClusterizerInZ_vect::vertices :"
870 <<
"after merging with outlier rejection at T=" << 1 / beta << std::endl;
873 dump(beta, y, tks, 2, rho0);
877 while (beta < betapurge_) {
878 beta =
min(beta / coolingFactor_, betapurge_);
879 thermalize(beta, tks, y, delta_lowT_, rho0);
884 if (DEBUGLEVEL > 0) {
885 std::cout <<
"DAClusterizerInZ_vect::vertices :"
886 <<
"purging at T=" << 1 / beta << std::endl;
891 while (purge(y, tks, rho0, beta)) {
892 thermalize(beta, tks, y, delta_lowT_, rho0);
897 if (DEBUGLEVEL > 0) {
898 std::cout <<
"DAClusterizerInZ_vect::vertices :"
899 <<
"last cooling T=" << 1 / beta << std::endl;
904 while (beta < betastop_) {
905 beta =
min(beta / coolingFactor_, betastop_);
906 thermalize(beta, tks, y, delta_lowT_, rho0);
911 if (DEBUGLEVEL > 0) {
912 std::cout <<
"DAClusterizerInZ_vect::vertices :"
913 <<
"stop cooling at T=" << 1 / beta << std::endl;
916 dump(beta, y, tks, 2, rho0);
921 set_vtx_range(beta, tks, y);
922 const unsigned int nv = y.
getSize();
923 for (
unsigned int k = 0;
k < nv;
k++) {
930 const auto z_sum_init = rho0 * local_exp(-beta * dzCutOff_ * dzCutOff_);
931 std::vector<std::vector<unsigned int> > vtx_track_indices(nv);
932 for (
unsigned int i = 0;
i <
nt;
i++) {
933 const auto kmin = tks.
kmin[
i];
934 const auto kmax = tks.
kmax[
i];
935 for (
auto k = kmin;
k < kmax;
k++) {
939 local_exp_list_range(y.
exp_arg, y.
exp, kmin, kmax);
941 tks.
sum_Z[
i] = z_sum_init;
942 for (
auto k = kmin;
k < kmax;
k++) {
945 const double invZ = tks.
sum_Z[
i] > 1
e-100 ? 1. / tks.
sum_Z[
i] : 0.0;
947 for (
auto k = kmin;
k < kmax;
k++) {
949 if (p > mintrkweight_) {
951 vtx_track_indices[
k].push_back(
i);
958 GlobalError dummyError(0.01, 0, 0.01, 0., 0., 0.01);
959 for (
unsigned int k = 0;
k < nv;
k++) {
960 if (!vtx_track_indices[
k].
empty()) {
962 vector<reco::TransientTrack> vertexTracks;
963 for (
auto i : vtx_track_indices[
k]) {
964 vertexTracks.push_back(*(tks.
tt[
i]));
967 clusters.push_back(v);
975 const vector<reco::TransientTrack>&
tracks)
const {
976 vector<vector<reco::TransientTrack> >
clusters;
977 vector<TransientVertex>&&
pv =
vertices(tracks);
980 if (DEBUGLEVEL > 0) {
981 std::cout <<
"###################################################" << endl;
982 std::cout <<
"# vectorized DAClusterizerInZ_vect::clusterize nt=" << tracks.size() << endl;
983 std::cout <<
"# DAClusterizerInZ_vect::clusterize pv.size=" << pv.size() << endl;
984 std::cout <<
"###################################################" << endl;
993 vector<reco::TransientTrack> aCluster = pv.begin()->originalTracks();
995 for (
auto k = pv.begin() + 1;
k != pv.end();
k++) {
998 if (aCluster.size() > 1) {
999 clusters.push_back(aCluster);
1003 std::cout <<
" one track cluster at " <<
k->position().z() <<
" suppressed" << std::endl;
1008 for (
unsigned int i = 0;
i <
k->originalTracks().size();
i++) {
1009 aCluster.push_back(
k->originalTracks()[
i]);
1012 clusters.emplace_back(
std::move(aCluster));
1020 const unsigned int nv = y.
getSize();
1025 update(beta, tks_local, y_local, rho0,
true);
1027 std::vector<unsigned int> iz;
1028 for (
unsigned int j = 0;
j <
nt;
j++) {
1031 std::sort(iz.begin(), iz.end(), [tks](
unsigned int a,
unsigned int b) {
return tks.
zpca[
a] < tks.
zpca[
b]; });
1033 std::cout <<
"-----DAClusterizerInZ::dump ----" << nv <<
" clusters " << std::endl;
1035 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1036 if (std::fabs(y.
zvtx[ivertex] - zdumpcenter_) < zdumpwidth_) {
1037 std::cout <<
" " << setw(3) << ivertex <<
" ";
1043 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1044 if (std::fabs(y.
zvtx[ivertex] - zdumpcenter_) < zdumpwidth_) {
1049 <<
"T=" << setw(15) << 1. / beta <<
" Tmin =" << setw(10) << 1. / betamax_
1051 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1052 if (std::fabs(y.
zvtx[ivertex] - zdumpcenter_) < zdumpwidth_) {
1053 double Tc = 2 * y_local.
swE[ivertex] / y_local.
sw[ivertex];
1054 std::cout << setw(8) << fixed << setprecision(1) << Tc;
1061 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1062 sumpk += y.
rho[ivertex];
1063 if (std::fabs(y.
zvtx[ivertex] - zdumpcenter_) > zdumpwidth_)
1065 std::cout << setw(8) << setprecision(4) << fixed << y.
rho[ivertex];
1070 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1071 if (std::fabs(y.
zvtx[ivertex] - zdumpcenter_) > zdumpwidth_)
1073 std::cout << setw(8) << setprecision(1) << fixed << y.
rho[ivertex] *
nt;
1077 if (verbosity > 0) {
1078 double E = 0,
F = 0;
1080 std::cout <<
"---- z +/- dz ip +/-dip pt phi eta weights ----" << endl;
1082 for (
unsigned int i0 = 0; i0 <
nt; i0++) {
1083 unsigned int i = iz[i0];
1084 if (tks.
sum_Z[i] > 0) {
1087 double tz = tks.
zpca[
i];
1089 if (std::fabs(tz - zdumpcenter_) > zdumpwidth_)
1091 std::cout << setw(4) << i <<
")" << setw(8) << fixed << setprecision(4) << tz <<
" +/-" << setw(6)
1093 if ((tks.
tt[i] ==
nullptr)) {
1110 .pixelBarrelLayersWithMeasurement();
1111 std::cout << setw(1) << tks.
tt[
i]->track().hitPattern().pixelEndcapLayersWithMeasurement();
1113 << tks.
tt[
i]->track().hitPattern().trackerLayersWithMeasurement() -
1114 tks.
tt[
i]->track().hitPattern().pixelLayersWithMeasurement()
1121 std::cout <<
" " << setw(6) << setprecision(2) << tks.
tt[
i]->track().pt() * tks.
tt[
i]->track().charge();
1122 std::cout <<
" " << setw(5) << setprecision(2) << tks.
tt[
i]->track().phi() <<
" " << setw(5) << setprecision(2)
1123 << tks.
tt[
i]->track().eta();
1127 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1128 if (std::fabs(y.
zvtx[ivertex] - zdumpcenter_) > zdumpwidth_)
1131 if ((tks.
tkwt[i] > 0) && (tks.
sum_Z[i] > 0)) {
1133 double p = y.
rho[ivertex] * local_exp(-beta * Eik(tks.
zpca[i], y.
zvtx[ivertex], tks.
dz2[i])) / tks.
sum_Z[
i];
1135 std::cout << setw(8) << setprecision(3) <<
p;
1139 E += p * Eik(tks.
zpca[i], y.
zvtx[ivertex], tks.
dz2[i]);
1145 std::cout <<
" ( " << std::setw(3) << tks.
kmin[
i] <<
"," << std::setw(3) << tks.
kmax[
i] - 1 <<
" ) ";
1149 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1150 if (std::fabs(y.
zvtx[ivertex] - zdumpcenter_) < zdumpwidth_) {
1151 std::cout <<
" " << setw(3) << ivertex <<
" ";
1157 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1158 if (std::fabs(y.
zvtx[ivertex] - zdumpcenter_) < zdumpwidth_) {
1164 <<
"T=" << 1 / beta <<
" E=" << E <<
" n=" << y.
getSize() <<
" F= " <<
F << endl
1165 <<
"----------" << endl;
1173 desc.
add<
double>(
"d0CutOff", 3.0);
1174 desc.
add<
double>(
"Tmin", 2.0);
1175 desc.
add<
double>(
"delta_lowT", 0.001);
1176 desc.
add<
double>(
"zmerge", 0.01);
1177 desc.
add<
double>(
"dzCutOff", 3.0);
1178 desc.
add<
double>(
"Tpurge", 2.0);
1179 desc.
add<
int>(
"convergence_mode", 0);
1180 desc.
add<
double>(
"delta_highT", 0.01);
1181 desc.
add<
double>(
"Tstop", 0.5);
1182 desc.
add<
double>(
"coolingFactor", 0.6);
1183 desc.
add<
double>(
"vertexSize", 0.006);
1184 desc.
add<
double>(
"uniquetrkweight", 0.8);
1185 desc.
add<
double>(
"uniquetrkminp", 0.0);
1186 desc.
add<
double>(
"zrange", 4.0);
T getUntrackedParameter(std::string const &, T const &) const
void addItemSorted(double new_zpca, double new_dz2, const reco::TransientTrack *new_tt, double new_tkwt)
static std::vector< std::string > checklist log
void set_vtx_range(double beta, track_t >racks, vertex_t &gvertices) const
void insertItem(unsigned int k, double new_zvtx, double new_rho, track_t &tks)
common ppss p3p6s2 common epss epspn46 common const1 w2
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::vector< double > sw_vec
unsigned int getSize() const
bool split(const double beta, track_t &t, vertex_t &y, double threshold=1.) const
constexpr bool isNotFinite(T x)
std::vector< double > swE_vec
double *__restrict__ sum_Z
void verify(const vertex_t &v, const track_t &tks, unsigned int nv=999999, unsigned int nt=999999) const
static void fillPSetDescription(edm::ParameterSetDescription &desc)
double *__restrict__ tkwt
track_t fill(const std::vector< reco::TransientTrack > &tracks) const
auto const & tracks
cannot be loose
std::vector< const reco::TransientTrack * > tt
std::vector< double > dz2_vec
std::vector< std::vector< reco::TransientTrack > > clusterize(const std::vector< reco::TransientTrack > &tracks) const override
void addItem(double new_zvtx, double new_rho)
std::vector< double > tkwt_vec
U second(std::pair< T, U > const &p)
std::vector< double > se_vec
unsigned int thermalize(double beta, track_t >racks, vertex_t &gvertices, const double delta_max, const double rho0=0.) const
std::vector< unsigned int > kmin
double *__restrict__ zpca
std::vector< unsigned int > kmax
double *__restrict__ exp_arg
void removeItem(unsigned int k, track_t &tks)
double *__restrict__ zvtx
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &tracks) const
Abs< T >::type abs(const T &t)
std::vector< double > zvtx_vec
double BeamWidthX() const
beam width X
void dump(const double beta, const vertex_t &y, const track_t &tks, const int verbosity=0, const double rho0=0.) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< double > rho_vec
std::vector< double > swz_vec
std::vector< double > exp_arg_vec
void clear_vtx_range(track_t >racks, vertex_t &gvertices) const
double beta0(const double betamax, track_t const &tks, vertex_t const &y) const
for(Iditer=Id.begin();Iditer!=Id.end();Iditer++)
std::vector< double > sum_Z_vec
DAClusterizerInZ_vect(const edm::ParameterSet &conf)
void fill(std::map< std::string, TH1 * > &h, const std::string &s, double x)
double update(double beta, track_t >racks, vertex_t &gvertices, const double rho0=0, const bool updateTc=false) const
T getParameter(std::string const &) const
double BeamWidthY() const
beam width Y
bool merge(vertex_t &y, track_t &tks, double &beta) const
static int position[264][3]
std::vector< double > zpca_vec
std::vector< double > exp_vec
unsigned int getSize() const
Log< level::Warning, false > LogWarning
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
bool purge(vertex_t &, track_t &, double &, const double) const
Power< A, B >::type pow(const A &a, const B &b)
tuple dump
OutputFilePath = cms.string('/tmp/zhokin/'), OutputFileExt = cms.string(''),.