11 #include "vdt/vdtMath.h"
24 maxIterations_ = 1000;
37 vertexSizeTime_ = conf.
getParameter<
double>(
"vertexSizeTime");
38 coolingFactor_ = conf.
getParameter<
double>(
"coolingFactor");
43 uniquetrkweight_ = conf.
getParameter<
double>(
"uniquetrkweight");
48 convergence_mode_ = conf.
getParameter<
int>(
"convergence_mode");
53 std::cout <<
"DAClusterizerInZT_vect: mintrkweight = " << mintrkweight_ << std::endl;
54 std::cout <<
"DAClusterizerInZT_vect: uniquetrkweight = " << uniquetrkweight_ << std::endl;
55 std::cout <<
"DAClusterizerInZT_vect: zmerge = " << zmerge_ << std::endl;
56 std::cout <<
"DAClusterizerInZT_vect: tmerge = " << tmerge_ << std::endl;
57 std::cout <<
"DAClusterizerInZT_vect: Tmin = " << minT << std::endl;
58 std::cout <<
"DAClusterizerInZT_vect: Tpurge = " << purgeT << std::endl;
59 std::cout <<
"DAClusterizerInZT_vect: Tstop = " << stopT << std::endl;
60 std::cout <<
"DAClusterizerInZT_vect: vertexSize = " << vertexSize_ << std::endl;
61 std::cout <<
"DAClusterizerInZT_vect: vertexSizeTime = " << vertexSizeTime_ << std::endl;
62 std::cout <<
"DAClusterizerInZT_vect: coolingFactor = " << coolingFactor_ << std::endl;
63 std::cout <<
"DAClusterizerInZT_vect: d0CutOff = " << d0CutOff_ << std::endl;
64 std::cout <<
"DAClusterizerInZT_vect: dzCutOff = " << dzCutOff_ << std::endl;
65 std::cout <<
"DAClusterizerInZT_vect: dtCutoff = " << dtCutOff_ << std::endl;
66 std::cout <<
"DAClusterizerInZT_vect: zrange = " << sel_zrange_ << std::endl;
67 std::cout <<
"DAClusterizerinZT_vect: convergence mode = " << convergence_mode_ << std::endl;
68 std::cout <<
"DAClusterizerinZT_vect: delta_highT = " << delta_highT_ << std::endl;
69 std::cout <<
"DAClusterizerinZT_vect: delta_lowT = " << delta_lowT_ << std::endl;
72 std::cout <<
"DAClusterizerinZT_vect: DEBUGLEVEL " << DEBUGLEVEL << std::endl;
75 if (convergence_mode_ > 1) {
77 <<
"DAClusterizerInZT_vect: invalid convergence_mode" << convergence_mode_ <<
" reset to default " << 0;
78 convergence_mode_ = 0;
83 <<
"DAClusterizerInZT_vect: invalid Tmin" << minT <<
" reset to default " << 1. / betamax_;
88 if ((purgeT > minT) || (purgeT == 0)) {
90 <<
"DAClusterizerInZT_vect: invalid Tpurge" << purgeT <<
" set to " << minT;
93 betapurge_ = 1. / purgeT;
95 if ((stopT > purgeT) || (stopT == 0)) {
97 <<
"DAClusterizerInZT_vect: invalid Tstop" << stopT <<
" set to " <<
max(1., purgeT);
98 stopT =
max(1., purgeT);
100 betastop_ = 1. / stopT;
104 inline double local_exp(
double const& inp) {
return vdt::fast_exp(inp); }
106 inline void local_exp_list(
double const* __restrict__ arg_inp,
double* __restrict__ arg_out,
const int arg_arr_size) {
107 for (
auto i = 0;
i != arg_arr_size; ++
i)
108 arg_out[
i] = vdt::fast_exp(arg_inp[
i]);
111 inline void local_exp_list_range(
double const* __restrict__ arg_inp,
112 double* __restrict__ arg_out,
115 for (
auto i = kmin;
i != kmax; ++
i)
116 arg_out[
i] = vdt::fast_exp(arg_inp[
i]);
144 assert(
v.ei_cache.size() == nv);
156 assert(
v.ei_cache_ptr == &
v.ei_cache.front());
157 assert(
v.swz_ptr == &
v.swz.front());
158 assert(
v.swt_ptr == &
v.swt.front());
160 assert(
v.nuz_ptr == &
v.nuz.front());
161 assert(
v.nut_ptr == &
v.nut.front());
162 assert(
v.szz_ptr == &
v.szz.front());
163 assert(
v.stt_ptr == &
v.stt.front());
164 assert(
v.szt_ptr == &
v.szt.front());
165 assert(
v.sumw_ptr == &
v.sumw.front());
168 assert(
v.dt2_ptr == &
v.dt2.front());
171 for (
unsigned int k = 0;
k < nv - 1;
k++) {
172 if (
v.z[
k] <=
v.z[
k + 1])
174 cout <<
" ZT, cluster z-ordering assertion failure z[" <<
k <<
"] =" <<
v.z[
k] <<
" z[" <<
k + 1
175 <<
"] =" <<
v.z[
k + 1] << endl;
201 for (
unsigned int i = 0;
i <
nt;
i++) {
204 cout <<
"track vertex range assertion failure" <<
i <<
"/" <<
nt <<
" kmin,kmax=" << tks.
kmin[
i] <<
", "
205 << tks.
kmax[
i] <<
" nv=" << nv << endl;
208 for (
unsigned int i = 0;
i <
nt;
i++) {
217 for (
const auto& tk :
tracks) {
221 double t_z = tk.stateAtBeamLine().trackStateAtPCA().position().z();
222 double t_t = tk.timeExt();
224 if (std::fabs(
t_z) > 1000.)
231 auto const& t_mom = tk.stateAtBeamLine().trackStateAtPCA().momentum();
234 double t_dz2 =
std::pow(tk.track().dzError(), 2)
240 std::cout <<
"DAClusterizerInZT_vect.fill rejected track t_dz2 " << t_dz2 << std::endl;
247 if ((tk.dtErrorExt() > 0.3) || (
std::abs(t_t) > t0Max_)) {
252 std::cout <<
"DAClusterizerInZT_vect.fill rejected track t_dt2 " << t_dt2 << std::endl;
262 std::cout <<
"DAClusterizerInZT_vect.fill rejected track t_pu " << t_pi << std::endl;
267 tks.
addItem(
t_z, t_t, t_dz2, t_dt2, &tk, t_pi);
271 if (DEBUGLEVEL > 0) {
280 inline double Eik(
double t_z,
double k_z,
double t_dz2,
double t_t,
double k_t,
double t_dt2) {
286 const unsigned int nv = gvertices.
getSize();
287 const unsigned int nt = gtracks.
getSize();
290 edm::LogWarning(
"DAClusterizerinZT_vect") <<
"empty cluster list in set_vtx_range";
294 for (
auto itrack = 0
U; itrack <
nt; ++itrack) {
298 unsigned int kmin =
min(nv - 1, gtracks.
kmin[itrack]);
301 while ((kmin > 0) && (gvertices.
z_ptr[kmin - 1] >
zmin)) {
305 while ((kmin < (nv - 1)) && (gvertices.
z_ptr[kmin] <
zmin)) {
311 unsigned int kmax =
min(nv - 1, gtracks.
kmax[itrack] - 1);
315 while ((kmax < (nv - 1)) && (gvertices.
z_ptr[kmax + 1] <
zmax)) {
319 while ((kmax > 0) && (gvertices.
z_ptr[kmax] >
zmax)) {
325 gtracks.
kmin[itrack] = kmin;
326 gtracks.
kmax[itrack] = kmax + 1;
329 gtracks.
kmax[itrack] =
min(nv,
max(kmin, kmax) + 1);
333 if (gtracks.
kmin[itrack] >= gtracks.
kmax[itrack]) {
334 cout <<
"set_vtx_range trk = " << itrack <<
" kmin,kmax=" << kmin <<
"," << kmax
335 <<
" gtrack.kmin,kmax = " << gtracks.
kmin[itrack] <<
"," << gtracks.
kmax[itrack] <<
" zrange = " <<
zrange
343 const unsigned int nt = gtracks.
getSize();
344 const unsigned int nv = gvertices.
getSize();
345 for (
auto itrack = 0
U; itrack <
nt; ++itrack) {
346 gtracks.
kmin[itrack] = 0;
347 gtracks.
kmax[itrack] = nv;
356 const unsigned int nt = gtracks.
getSize();
357 const unsigned int nv = gvertices.
getSize();
369 Z_init = rho0 * local_exp(-
beta * dzCutOff_ * dzCutOff_);
374 auto kernel_calc_exp_arg_range = [
beta](
const unsigned int itrack,
377 const unsigned int kmin,
378 const unsigned int kmax) {
379 const auto track_z =
tracks.z_ptr[itrack];
381 const auto botrack_dz2 = -
beta *
tracks.dz2_ptr[itrack];
383 const auto botrack_dt2 = -
beta *
tracks.dt2_ptr[itrack];
386 for (
unsigned int ivertex = kmin; ivertex < kmax; ++ivertex) {
387 const auto mult_resz = track_z -
vertices.z_ptr[ivertex];
393 vertices.ei_cache_ptr[ivertex] = botrack_dz2 * (mult_resz * mult_resz) + botrack_dt2 * (mult_rest * mult_rest);
397 auto kernel_add_Z_range = [Z_init](
398 vertex_t const&
vertices,
const unsigned int kmin,
const unsigned int kmax) ->
double {
399 double ZTemp = Z_init;
400 for (
unsigned int ivertex = kmin; ivertex < kmax; ++ivertex) {
406 auto kernel_calc_normalization_range = [](
const unsigned int track_num,
409 const unsigned int kmin,
410 const unsigned int kmax) {
411 auto tmp_trk_pi = tks_vec.pi_ptr[track_num];
412 auto o_trk_Z_sum = 1. / tks_vec.Z_sum_ptr[track_num];
413 auto o_trk_err_z = tks_vec.dz2_ptr[track_num];
414 auto o_trk_err_t = tks_vec.dt2_ptr[track_num];
415 auto tmp_trk_z = tks_vec.z_ptr[track_num];
416 auto tmp_trk_t = tks_vec.t_ptr[track_num];
419 for (
unsigned int k = kmin;
k < kmax; ++
k) {
421 y_vec.se_ptr[
k] += tmp_trk_pi * (y_vec.ei_ptr[
k] * o_trk_Z_sum);
422 const auto w = tmp_trk_pi * (y_vec.pk_ptr[
k] * y_vec.ei_ptr[
k] * o_trk_Z_sum);
423 const auto wz =
w * o_trk_err_z;
424 const auto wt =
w * o_trk_err_t;
426 y_vec.sumw_ptr[
k] +=
w;
428 y_vec.nuz_ptr[
k] += wz;
429 y_vec.nut_ptr[
k] += wt;
430 y_vec.swz_ptr[
k] += wz * tmp_trk_z;
431 y_vec.swt_ptr[
k] += wt * tmp_trk_t;
433 const auto dsz = (tmp_trk_z - y_vec.z_ptr[
k]) * o_trk_err_z;
434 const auto dst = (tmp_trk_t - y_vec.t_ptr[
k]) * o_trk_err_t;
435 y_vec.szz_ptr[
k] +=
w * dsz * dsz;
437 y_vec.szt_ptr[
k] +=
w * dsz *
dst;
441 for (
auto ivertex = 0
U; ivertex < nv; ++ivertex) {
442 gvertices.
se_ptr[ivertex] = 0.0;
443 gvertices.
nuz_ptr[ivertex] = 0.0;
444 gvertices.
nut_ptr[ivertex] = 0.0;
445 gvertices.
swz_ptr[ivertex] = 0.0;
446 gvertices.
swt_ptr[ivertex] = 0.0;
447 gvertices.
szz_ptr[ivertex] = 0.0;
448 gvertices.
stt_ptr[ivertex] = 0.0;
449 gvertices.
szt_ptr[ivertex] = 0.0;
456 for (
auto itrack = 0
U; itrack <
nt; ++itrack) {
457 unsigned int kmin = gtracks.
kmin[itrack];
458 unsigned int kmax = gtracks.
kmax[itrack];
461 assert((kmin < kmax) && (kmax <= nv));
465 kernel_calc_exp_arg_range(itrack, gtracks, gvertices, kmin, kmax);
468 gtracks.
Z_sum_ptr[itrack] = kernel_add_Z_range(gvertices, kmin, kmax);
472 sumpi += gtracks.
pi_ptr[itrack];
474 if (gtracks.
Z_sum_ptr[itrack] > 1.e-100) {
475 kernel_calc_normalization_range(itrack, gtracks, gvertices, kmin, kmax);
484 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
485 if (
vertices.nuz_ptr[ivertex] > 0.) {
491 if (
vertices.nut_ptr[ivertex] > 0.) {
510 if ((
vertices.nut_ptr[ivertex] <= 0.) && (
vertices.nuz_ptr[ivertex] <= 0.)) {
511 edm::LogInfo(
"sumw") <<
"invalid sum of weights in fit: " << endl;
514 <<
" sumw(z,t) =" <<
vertices.nuz_ptr[ivertex] <<
"," <<
vertices.nut_ptr[ivertex] << endl;
520 auto osumpi = 1. / sumpi;
521 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
528 delta += kernel_calc_zt(gvertices);
530 if (zorder(gvertices)) {
531 set_vtx_range(
beta, gtracks, gvertices);
539 const unsigned int nv = y.getSize();
545 assert(y.pk.size() == nv);
551 bool reordering =
true;
552 bool modified =
false;
556 for (
unsigned int k = 0; (
k + 1) < nv;
k++) {
557 if (y.z[
k + 1] < y.z[
k]) {
565 auto dt2temp = y.dt2[
k];
566 y.dt2[
k] = y.dt2[
k + 1];
567 y.dt2[
k + 1] = dt2temp;
569 auto ptemp = y.pk[
k];
570 y.pk[
k] = y.pk[
k + 1];
575 modified |= reordering;
587 double z,
double t,
vertex_t& y,
unsigned int& k_min,
double dz,
double dt)
const {
593 unsigned int nv = y.getSize();
601 for (
unsigned int k0 = 1;
k0 < nv;
k0++) {
607 double delta_min = 1.;
611 while ((k1 > 0) && ((y.z[
k] - y.z[--k1]) <
dz)) {
613 if (
delta < delta_min) {
621 while (((++k1) < nv) && ((y.z[k1] - y.z[
k]) <
dz)) {
623 if (
delta < delta_min) {
629 return (delta_min < 1.);
634 unsigned int niter = 0;
636 double delta_max = delta_lowT_;
638 if (convergence_mode_ == 0) {
639 delta_max = delta_max0;
640 }
else if (convergence_mode_ == 1) {
645 set_vtx_range(
beta, tks,
v);
647 double delta_sum_range = 0;
648 std::vector<double>
z0 =
v.z;
650 while (niter++ < maxIterations_) {
652 delta_sum_range +=
delta;
654 if (delta_sum_range > zrange_min_) {
655 for (
unsigned int k = 0;
k <
v.getSize();
k++) {
658 set_vtx_range(
beta, tks,
v);
666 if (
delta < delta_max) {
672 if (DEBUGLEVEL > 0) {
673 std::cout <<
"DAClusterizerInZT_vect.thermalize niter = " << niter <<
" at T = " << 1 /
beta
674 <<
" nv = " <<
v.getSize() << std::endl;
686 const unsigned int nv = y.getSize();
692 unsigned int k1_min = 0, k2_min = 0;
693 double delta_min = 0;
695 for (
unsigned int k1 = 0; (k1 + 1) < nv; k1++) {
696 unsigned int k2 = k1;
697 while ((++k2 < nv) && (std::fabs(y.z[k2] - y.z_ptr[k1]) < zmerge_)) {
699 std::pow((y.z_ptr[k2] - y.z_ptr[k1]) / zmerge_, 2) +
std::pow((y.t_ptr[k2] - y.t_ptr[k1]) / tmerge_, 2);
700 if ((
delta < delta_min) || (k1_min == k2_min)) {
708 if ((k1_min == k2_min) || (delta_min > 1)) {
712 double rho = y.pk_ptr[k1_min] + y.pk_ptr[k2_min];
715 assert((k1_min < nv) && (k2_min < nv));
716 if (DEBUGLEVEL > 1) {
717 std::cout <<
"merging (" << setw(8) <<
fixed << setprecision(4) << y.z_ptr[k1_min] <<
',' << y.t_ptr[k1_min]
718 <<
") and (" << y.z_ptr[k2_min] <<
',' << y.t_ptr[k2_min] <<
")"
719 <<
" idx=" << k1_min <<
"," << k2_min << std::endl;
724 y.z_ptr[k1_min] = (y.pk_ptr[k1_min] * y.z_ptr[k1_min] + y.pk_ptr[k2_min] * y.z_ptr[k2_min]) / rho;
725 y.t_ptr[k1_min] = (y.pk_ptr[k1_min] * y.t_ptr[k1_min] + y.pk_ptr[k2_min] * y.t_ptr[k2_min]) / rho;
727 y.dt2_ptr[k1_min] = (y.pk_ptr[k1_min] * y.dt2_ptr[k1_min] + y.pk_ptr[k2_min] * y.dt2_ptr[k2_min]) / rho;
730 y.z_ptr[k1_min] = 0.5 * (y.z_ptr[k1_min] + y.z_ptr[k2_min]);
731 y.t_ptr[k1_min] = 0.5 * (y.t_ptr[k1_min] + y.t_ptr[k2_min]);
733 y.pk_ptr[k1_min] = rho;
734 y.removeItem(k2_min, tks);
737 set_vtx_range(
beta, tks, y);
743 constexpr
double eps = 1.e-100;
745 const unsigned int nv = y.getSize();
752 unsigned int k0 = nv;
757 std::vector<double> inverse_zsums(
nt), arg_cache(
nt), eik_cache(
nt), pcut_cache(
nt);
758 double* __restrict__ pinverse_zsums;
759 double* __restrict__ parg_cache;
760 double* __restrict__ peik_cache;
761 double* __restrict__ ppcut_cache;
762 pinverse_zsums = inverse_zsums.data();
763 parg_cache = arg_cache.data();
764 peik_cache = eik_cache.data();
765 ppcut_cache = pcut_cache.data();
766 for (
unsigned i = 0;
i <
nt; ++
i) {
769 const auto rhoconst = rho0 * local_exp(-
beta * dzCutOff_ * dzCutOff_);
770 for (
unsigned int k = 0;
k < nv; ++
k) {
771 const double pmax = y.pk_ptr[
k] / (y.pk_ptr[
k] + rhoconst);
772 ppcut_cache[
k] = uniquetrkweight_ * pmax;
775 for (
unsigned int k = 0;
k < nv; ++
k) {
776 for (
unsigned i = 0;
i <
nt; ++
i) {
777 const auto track_z = tks.
z_ptr[
i];
782 const auto mult_resz = track_z - y.z_ptr[
k];
783 const auto mult_rest =
track_t - y.t_ptr[
k];
784 parg_cache[
i] = botrack_dz2 * (mult_resz * mult_resz) + botrack_dt2 * (mult_rest * mult_rest);
786 local_exp_list(parg_cache, peik_cache,
nt);
790 for (
unsigned int i = 0;
i <
nt; ++
i) {
791 const auto p = y.pk_ptr[
k] * peik_cache[
i] * pinverse_zsums[
i];
793 nUnique += ((
p > ppcut_cache[
k]) & (tks.
pi_ptr[
i] > 0)) ? 1 : 0;
796 if ((nUnique < 2) && (sump < sumpmin)) {
805 if (DEBUGLEVEL > 1) {
806 std::cout <<
"eliminating prototype at " << std::setw(10) << std::setprecision(4) << y.z_ptr[
k0] <<
","
807 << y.t_ptr[
k0] <<
" with sump=" << sumpmin <<
" rho*nt =" << y.pk_ptr[
k0] *
nt << endl;
810 y.removeItem(
k0, tks);
811 set_vtx_range(
beta, tks, y);
822 const unsigned int nv = y.getSize();
824 for (
unsigned int k = 0;
k < nv;
k++) {
830 for (
unsigned int i = 0;
i <
nt;
i++) {
833 sumwz += w_z * tks.
z_ptr[
i];
834 sumwt += w_t * tks.
t_ptr[
i];
838 y.z_ptr[
k] = sumwz / sumw_z;
839 y.t_ptr[
k] = sumwt / sumw_t;
842 double szz = 0, stt = 0, szt = 0;
843 double nuz = 0, nut = 0;
844 for (
unsigned int i = 0;
i <
nt;
i++) {
854 double Tz = szz / nuz;
859 Tc = Tz + Tt +
sqrt(
pow(Tz - Tt, 2) + 4 * szt * szt / nuz / nut);
869 if (DEBUGLEVEL > 0) {
870 std::cout <<
"DAClusterizerInZT_vect.beta0: Tc = " << T0 << std::endl;
872 std::cout <<
"DAClusterizerInZT_vect.beta0: nstep = " << coolingsteps << std::endl;
876 if (T0 > 1. / betamax) {
878 return betamax *
std::pow(coolingFactor_, coolingsteps);
881 return betamax * coolingFactor_;
886 double Tz = y.szz_ptr[
k] / y.nuz_ptr[
k];
888 if (y.nut_ptr[
k] > 0) {
889 Tt = y.stt_ptr[
k] / y.nut_ptr[
k];
890 double mx = y.szt_ptr[
k] / y.nuz_ptr[
k] * y.szt_ptr[
k] / y.nut_ptr[
k];
891 return Tz + Tt +
sqrt(
pow(Tz - Tt, 2) + 4 * mx);
901 constexpr
double epsilonz = 1
e-3;
902 constexpr
double epsilont = 1
e-2;
903 unsigned int nv = y.getSize();
904 const double twoBeta = 2.0 *
beta;
908 std::vector<std::pair<double, unsigned int> >
critical;
909 for (
unsigned int k = 0;
k < nv;
k++) {
910 double Tc = get_Tc(y,
k);
918 std::stable_sort(
critical.begin(),
critical.end(), std::greater<std::pair<double, unsigned int> >());
923 for (
unsigned int ic = 0; ic <
critical.size(); ic++) {
928 double Mzz = y.nuz_ptr[
k] - twoBeta * y.szz_ptr[
k];
929 double Mtt = y.nut_ptr[
k] - twoBeta * y.stt_ptr[
k];
930 double Mzt = -twoBeta * y.szt_ptr[
k];
931 const double twoMzt = 2.0 * Mzt;
932 double D =
sqrt(
pow(Mtt - Mzz, 2) + twoMzt * twoMzt);
933 double q1 = atan2(-Mtt + Mzz +
D, -twoMzt);
934 double l1 = 0.5 * (-Mzz - Mtt +
D);
935 double l2 = 0.5 * (-Mzz - Mtt -
D);
937 edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, bad eigenvalues! idx=" <<
k <<
" z= " << y.z_ptr[
k]
938 <<
" Mzz=" << Mzz <<
" Mtt=" << Mtt <<
" Mzt=" << Mzt << endl;
942 double cq =
cos(qsplit);
943 double sq =
sin(qsplit);
950 double p1 = 0, z1 = 0,
t1 = 0, wz1 = 0, wt1 = 0;
951 double p2 = 0,
z2 = 0,
t2 = 0, wz2 = 0, wt2 = 0;
952 for (
unsigned int i = 0;
i <
nt; ++
i) {
954 double lr = (tks.
z_ptr[
i] - y.z_ptr[
k]) * cq + (tks.
t[
i] - y.t_ptr[
k]) * sq;
956 double tl = lr < 0 ? 1. : 0.;
962 double t = local_exp(-
arg);
974 z1 += wz * tl * tks.
z_ptr[
i];
989 z1 = y.z_ptr[
k] - epsilonz * cq;
990 edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, wz1 = " << scientific << wz1 << endl;
995 t1 = y.t_ptr[
k] - epsilont * sq;
996 edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, wt1 = " << scientific << wt1 << endl;
1001 z2 = y.z_ptr[
k] + epsilonz * cq;
1002 edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, wz2 = " << scientific << wz2 << endl;
1007 t2 = y.t_ptr[
k] + epsilont * sq;
1008 edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, wt2 = " << scientific << wt2 << endl;
1011 unsigned int k_min1 =
k, k_min2 =
k;
1012 constexpr
double spliteps = 1
e-8;
1013 while (((find_nearest(z1,
t1, y, k_min1, epsilonz, epsilont) && (k_min1 !=
k)) ||
1014 (find_nearest(
z2,
t2, y, k_min2, epsilonz, epsilont) && (k_min2 !=
k))) &&
1016 z1 = 0.5 * (z1 + y.z_ptr[
k]);
1017 t1 = 0.5 * (
t1 + y.t_ptr[
k]);
1018 z2 = 0.5 * (
z2 + y.z_ptr[
k]);
1019 t2 = 0.5 * (
t2 + y.t_ptr[
k]);
1024 if (DEBUGLEVEL > 1) {
1025 if (std::fabs(y.z_ptr[
k] - zdumpcenter_) < zdumpwidth_) {
1026 std::cout <<
" T= " << std::setw(10) << std::setprecision(1) << 1. /
beta <<
" Tc= " <<
critical[ic].first
1027 <<
" direction =" << std::setprecision(4) << qsplit <<
" splitting (" << std::setw(8) <<
std::fixed
1028 << std::setprecision(4) << y.z_ptr[
k] <<
"," << y.t_ptr[
k] <<
")"
1029 <<
" --> (" << z1 <<
',' <<
t1 <<
"),(" <<
z2 <<
',' <<
t2 <<
") [" <<
p1 <<
"," <<
p2 <<
"]";
1030 if (std::fabs(
z2 - z1) > epsilonz || std::fabs(
t2 -
t1) > epsilont) {
1040 edm::LogInfo(
"DAClusterizerInZT") <<
"warning swapping z in split qsplit=" << qsplit <<
" cq=" << cq
1041 <<
" sq=" << sq << endl;
1054 if (std::fabs(
z2 - z1) > epsilonz || std::fabs(
t2 -
t1) > epsilont) {
1056 double pk1 =
p1 * y.pk_ptr[
k] / (
p1 +
p2);
1057 double pk2 =
p2 * y.pk_ptr[
k] / (
p1 +
p2);
1060 y.removeItem(
k, tks);
1061 unsigned int k2 = y.insertOrdered(
z2,
t2, pk2, tks);
1065 std::cout <<
"unexpected z-ordering in split" << std::endl;
1071 for (
unsigned int jc = ic; jc <
critical.size(); jc++) {
1082 unsigned int k1 = y.insertOrdered(z1,
t1, pk1, tks);
1086 for (
unsigned int jc = ic; jc <
critical.size(); jc++) {
1094 std::cout <<
"warning ! split rejected, too small." << endl;
1116 y.addItem(0, 0, 1.0);
1117 clear_vtx_range(tks, y);
1120 double beta = beta0(betamax_, tks, y);
1126 thermalize(
beta, tks, y, delta_highT_, 0.);
1130 double betafreeze = betamax_ *
sqrt(coolingFactor_);
1132 while (
beta < betafreeze) {
1136 set_vtx_range(
beta, tks, y);
1142 thermalize(
beta, tks, y, delta_highT_, 0.);
1148 if (DEBUGLEVEL > 0) {
1149 std::cout <<
"DAClusterizerInZT_vect::vertices :"
1150 <<
"merging at T=" << 1 /
beta << std::endl;
1155 set_vtx_range(
beta, tks, y);
1160 set_vtx_range(
beta, tks, y);
1166 if (DEBUGLEVEL > 0) {
1167 std::cout <<
"DAClusterizerInZT_vect::vertices :"
1168 <<
"splitting/merging at T=" << 1 /
beta << std::endl;
1172 unsigned int ntry = 0;
1175 thermalize(
beta, tks, y, delta_highT_, 0.);
1179 set_vtx_range(
beta, tks, y);
1193 if (DEBUGLEVEL > 0) {
1194 std::cout <<
"DAClusterizerInZT_vect::vertices :"
1195 <<
"turning on outlier rejection at T=" << 1 /
beta << std::endl;
1200 if (dzCutOff_ > 0) {
1202 for (
unsigned int a = 0;
a < 5;
a++) {
1207 thermalize(
beta, tks, y, delta_lowT_, rho0);
1211 if (DEBUGLEVEL > 0) {
1212 std::cout <<
"DAClusterizerInZT_vect::vertices :"
1213 <<
"merging with outlier rejection at T=" << 1 /
beta << std::endl;
1222 set_vtx_range(
beta, tks, y);
1227 if (DEBUGLEVEL > 0) {
1228 std::cout <<
"DAClusterizerInZT_vect::vertices :"
1229 <<
"after merging with outlier rejection at T=" << 1 /
beta << std::endl;
1236 while (
beta < betapurge_) {
1238 thermalize(
beta, tks, y, delta_lowT_, rho0);
1243 if (DEBUGLEVEL > 0) {
1244 std::cout <<
"DAClusterizerInZT_vect::vertices :"
1245 <<
"purging at T=" << 1 /
beta << std::endl;
1250 while (purge(y, tks, rho0,
beta)) {
1251 thermalize(
beta, tks, y, delta_lowT_, rho0);
1253 set_vtx_range(
beta, tks, y);
1259 if (DEBUGLEVEL > 0) {
1260 std::cout <<
"DAClusterizerInZT_vect::vertices :"
1261 <<
"last cooling T=" << 1 /
beta << std::endl;
1266 while (
beta < betastop_) {
1268 thermalize(
beta, tks, y, delta_lowT_, rho0);
1270 set_vtx_range(
beta, tks, y);
1276 if (DEBUGLEVEL > 0) {
1277 std::cout <<
"DAClusterizerInZT_vect::vertices :"
1278 <<
"stop cooling at T=" << 1 /
beta << std::endl;
1286 double betadummy = 1;
1287 while (
merge(y, tks, betadummy))
1291 GlobalError dummyError(0.01, 0, 0.01, 0., 0., 0.01);
1294 const unsigned int nv = y.getSize();
1295 for (
unsigned int k = 0;
k < nv;
k++)
1301 const auto z_sum_init = rho0 * local_exp(-
beta * dzCutOff_ * dzCutOff_);
1302 for (
unsigned int i = 0;
i <
nt;
i++)
1306 for (
unsigned int k = 0;
k < nv;
k++) {
1307 for (
unsigned int i = 0;
i <
nt;
i++)
1313 for (
unsigned int k = 0;
k < nv;
k++) {
1316 vector<reco::TransientTrack> vertexTracks;
1317 for (
unsigned int i = 0;
i <
nt;
i++) {
1323 if ((tks.
pi_ptr[
i] > 0) && (
p > mintrkweight_)) {
1324 vertexTracks.push_back(*(tks.
tt[
i]));
1337 const vector<reco::TransientTrack>&
tracks)
const {
1338 vector<vector<reco::TransientTrack> >
clusters;
1342 if (DEBUGLEVEL > 0) {
1343 std::cout <<
"###################################################" << endl;
1344 std::cout <<
"# vectorized DAClusterizerInZT_vect::clusterize nt=" <<
tracks.size() << endl;
1345 std::cout <<
"# DAClusterizerInZT_vect::clusterize pv.size=" <<
pv.size() << endl;
1346 std::cout <<
"###################################################" << endl;
1355 for (
auto k =
pv.begin();
k !=
pv.end();
k++) {
1356 vector<reco::TransientTrack> aCluster =
k->originalTracks();
1357 if (aCluster.size() > 1) {
1367 const unsigned int nv = y.getSize();
1370 std::vector<unsigned int> iz;
1371 for (
unsigned int j = 0;
j <
nt;
j++) {
1374 std::sort(iz.begin(), iz.end(), [tks](
unsigned int a,
unsigned int b) {
return tks.
z_ptr[
a] < tks.
z_ptr[
b]; });
1376 std::cout <<
"-----DAClusterizerInZT::dump ----" << nv <<
" clusters " << std::endl;
1379 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1380 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) < zdumpwidth_) {
1388 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1389 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) < zdumpwidth_) {
1397 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1398 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) < zdumpwidth_) {
1404 std::cout <<
"T=" << setw(15) << 1. /
beta <<
" Tmin =" << setw(10) << 1. / betamax_
1406 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1407 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) < zdumpwidth_) {
1408 double Tc = get_Tc(y, ivertex);
1416 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1417 sumpk += y.pk_ptr[ivertex];
1418 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) > zdumpwidth_)
1420 std::cout << setw(8) << setprecision(4) <<
fixed << y.pk_ptr[ivertex];
1425 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1426 sumpk += y.pk_ptr[ivertex];
1427 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) > zdumpwidth_)
1429 std::cout << setw(8) << setprecision(1) <<
fixed << y.pk_ptr[ivertex] *
nt;
1434 double E = 0,
F = 0;
1436 std::cout <<
"---- z +/- dz t +/- dt ip +/-dip pt phi eta weights ----"
1439 for (
unsigned int i0 = 0; i0 <
nt; i0++) {
1440 unsigned int i = iz[i0];
1444 double tz = tks.
z_ptr[
i];
1446 if (std::fabs(tz - zdumpcenter_) > zdumpwidth_)
1448 std::cout << setw(4) <<
i <<
")" << setw(8) <<
fixed << setprecision(4) << tz <<
" +/-" << setw(6)
1472 .pixelBarrelLayersWithMeasurement();
1473 std::cout << setw(1) << tks.
tt[
i]->track().hitPattern().pixelEndcapLayersWithMeasurement();
1475 << tks.
tt[
i]->track().hitPattern().trackerLayersWithMeasurement() -
1476 tks.
tt[
i]->track().hitPattern().pixelLayersWithMeasurement()
1482 std::cout << setw(8) <<
IP.value() <<
"+/-" << setw(6) <<
IP.error();
1483 std::cout <<
" " << setw(6) << setprecision(2) << tks.
tt[
i]->track().pt() * tks.
tt[
i]->track().charge();
1484 std::cout <<
" " << setw(5) << setprecision(2) << tks.
tt[
i]->track().phi() <<
" " << setw(5) << setprecision(2)
1485 << tks.
tt[
i]->track().eta();
1488 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1489 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) > zdumpwidth_)
1500 if ((ivertex >= tks.
kmin[
i]) && (ivertex < tks.
kmax[
i])) {
1502 std::cout << setw(8) << setprecision(3) <<
p;
1512 }
else if (
p > 0.0001) {
1513 std::cout <<
"X" << setw(6) << setprecision(3) <<
p <<
"X";
1522 std::cout <<
" ( " << std::setw(3) << tks.
kmin[
i] <<
"," << std::setw(3) << tks.
kmax[
i] - 1 <<
" ) ";
1526 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1527 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) < zdumpwidth_) {
1528 std::cout <<
" " << setw(3) << ivertex <<
" ";
1534 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1535 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) < zdumpwidth_) {
1541 <<
"T=" << 1 /
beta <<
" E=" << E <<
" n=" << y.getSize() <<
" F= " <<
F << endl
1542 <<
"----------" << endl;