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* arg_inp,
double* arg_out,
const unsigned arg_arr_size) {
107 for (
unsigned 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,
113 const unsigned int kmin,
114 const unsigned int kmax) {
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);
758 double* pinverse_zsums;
761 pinverse_zsums = inverse_zsums.data();
762 parg_cache = arg_cache.data();
763 peik_cache = eik_cache.data();
764 for (
unsigned i = 0;
i <
nt; ++
i) {
768 for (
unsigned int k = 0;
k < nv; ++
k) {
772 const double pmax = y.pk_ptr[
k] / (y.pk_ptr[
k] + rho0 * local_exp(-
beta * dzCutOff_ * dzCutOff_));
773 const double pcut = uniquetrkweight_ * pmax;
774 for (
unsigned i = 0;
i <
nt; ++
i) {
775 const auto track_z = tks.
z_ptr[
i];
780 const auto mult_resz = track_z - y.z_ptr[
k];
781 const auto mult_rest =
track_t - y.t_ptr[
k];
782 parg_cache[
i] = botrack_dz2 * (mult_resz * mult_resz) + botrack_dt2 * (mult_rest * mult_rest);
784 local_exp_list(parg_cache, peik_cache,
nt);
785 for (
unsigned int i = 0;
i <
nt; ++
i) {
786 const double p = y.pk_ptr[
k] * peik_cache[
i] * pinverse_zsums[
i];
788 nUnique += ((
p > pcut) & (tks.
pi_ptr[
i] > 0));
791 if ((nUnique < 2) && (sump < sumpmin)) {
800 if (DEBUGLEVEL > 1) {
801 std::cout <<
"eliminating prototype at " << std::setw(10) << std::setprecision(4) << y.z_ptr[
k0] <<
","
802 << y.t_ptr[
k0] <<
" with sump=" << sumpmin <<
" rho*nt =" << y.pk_ptr[
k0] *
nt << endl;
805 y.removeItem(
k0, tks);
806 set_vtx_range(
beta, tks, y);
817 const unsigned int nv = y.getSize();
819 for (
unsigned int k = 0;
k < nv;
k++) {
825 for (
unsigned int i = 0;
i <
nt;
i++) {
828 sumwz += w_z * tks.
z_ptr[
i];
829 sumwt += w_t * tks.
t_ptr[
i];
833 y.z_ptr[
k] = sumwz / sumw_z;
834 y.t_ptr[
k] = sumwt / sumw_t;
837 double szz = 0, stt = 0, szt = 0;
838 double nuz = 0, nut = 0;
839 for (
unsigned int i = 0;
i <
nt;
i++) {
849 double Tz = szz / nuz;
854 Tc = Tz + Tt +
sqrt(
pow(Tz - Tt, 2) + 4 * szt * szt / nuz / nut);
864 if (DEBUGLEVEL > 0) {
865 std::cout <<
"DAClusterizerInZT_vect.beta0: Tc = " << T0 << std::endl;
867 std::cout <<
"DAClusterizerInZT_vect.beta0: nstep = " << coolingsteps << std::endl;
871 if (T0 > 1. / betamax) {
873 return betamax *
std::pow(coolingFactor_, coolingsteps);
876 return betamax * coolingFactor_;
881 double Tz = y.szz_ptr[
k] / y.nuz_ptr[
k];
883 if (y.nut_ptr[
k] > 0) {
884 Tt = y.stt_ptr[
k] / y.nut_ptr[
k];
885 double mx = y.szt_ptr[
k] / y.nuz_ptr[
k] * y.szt_ptr[
k] / y.nut_ptr[
k];
886 return Tz + Tt +
sqrt(
pow(Tz - Tt, 2) + 4 * mx);
896 constexpr
double epsilonz = 1
e-3;
897 constexpr
double epsilont = 1
e-2;
898 unsigned int nv = y.getSize();
899 const double twoBeta = 2.0 *
beta;
903 std::vector<std::pair<double, unsigned int> >
critical;
904 for (
unsigned int k = 0;
k < nv;
k++) {
905 double Tc = get_Tc(y,
k);
913 std::stable_sort(
critical.begin(),
critical.end(), std::greater<std::pair<double, unsigned int> >());
918 for (
unsigned int ic = 0; ic <
critical.size(); ic++) {
923 double Mzz = y.nuz_ptr[
k] - twoBeta * y.szz_ptr[
k];
924 double Mtt = y.nut_ptr[
k] - twoBeta * y.stt_ptr[
k];
925 double Mzt = -twoBeta * y.szt_ptr[
k];
926 const double twoMzt = 2.0 * Mzt;
927 double D =
sqrt(
pow(Mtt - Mzz, 2) + twoMzt * twoMzt);
928 double q1 = atan2(-Mtt + Mzz +
D, -twoMzt);
929 double l1 = 0.5 * (-Mzz - Mtt +
D);
930 double l2 = 0.5 * (-Mzz - Mtt -
D);
932 edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, bad eigenvalues! idx=" <<
k <<
" z= " << y.z_ptr[
k]
933 <<
" Mzz=" << Mzz <<
" Mtt=" << Mtt <<
" Mzt=" << Mzt << endl;
937 double cq =
cos(qsplit);
938 double sq =
sin(qsplit);
945 double p1 = 0, z1 = 0,
t1 = 0, wz1 = 0, wt1 = 0;
946 double p2 = 0,
z2 = 0,
t2 = 0, wz2 = 0, wt2 = 0;
947 for (
unsigned int i = 0;
i <
nt; ++
i) {
949 double lr = (tks.
z_ptr[
i] - y.z_ptr[
k]) * cq + (tks.
t[
i] - y.t_ptr[
k]) * sq;
951 double tl = lr < 0 ? 1. : 0.;
957 double t = local_exp(-
arg);
969 z1 += wz * tl * tks.
z_ptr[
i];
984 z1 = y.z_ptr[
k] - epsilonz * cq;
985 edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, wz1 = " << scientific << wz1 << endl;
990 t1 = y.t_ptr[
k] - epsilont * sq;
991 edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, wt1 = " << scientific << wt1 << endl;
996 z2 = y.z_ptr[
k] + epsilonz * cq;
997 edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, wz2 = " << scientific << wz2 << endl;
1002 t2 = y.t_ptr[
k] + epsilont * sq;
1003 edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, wt2 = " << scientific << wt2 << endl;
1006 unsigned int k_min1 =
k, k_min2 =
k;
1007 constexpr
double spliteps = 1
e-8;
1008 while (((find_nearest(z1,
t1, y, k_min1, epsilonz, epsilont) && (k_min1 !=
k)) ||
1009 (find_nearest(
z2,
t2, y, k_min2, epsilonz, epsilont) && (k_min2 !=
k))) &&
1011 z1 = 0.5 * (z1 + y.z_ptr[
k]);
1012 t1 = 0.5 * (
t1 + y.t_ptr[
k]);
1013 z2 = 0.5 * (
z2 + y.z_ptr[
k]);
1014 t2 = 0.5 * (
t2 + y.t_ptr[
k]);
1019 if (DEBUGLEVEL > 1) {
1020 if (std::fabs(y.z_ptr[
k] - zdumpcenter_) < zdumpwidth_) {
1021 std::cout <<
" T= " << std::setw(10) << std::setprecision(1) << 1. /
beta <<
" Tc= " <<
critical[ic].first
1022 <<
" direction =" << std::setprecision(4) << qsplit <<
" splitting (" << std::setw(8) <<
std::fixed
1023 << std::setprecision(4) << y.z_ptr[
k] <<
"," << y.t_ptr[
k] <<
")"
1024 <<
" --> (" << z1 <<
',' <<
t1 <<
"),(" <<
z2 <<
',' <<
t2 <<
") [" <<
p1 <<
"," <<
p2 <<
"]";
1025 if (std::fabs(
z2 - z1) > epsilonz || std::fabs(
t2 -
t1) > epsilont) {
1035 edm::LogInfo(
"DAClusterizerInZT") <<
"warning swapping z in split qsplit=" << qsplit <<
" cq=" << cq
1036 <<
" sq=" << sq << endl;
1049 if (std::fabs(
z2 - z1) > epsilonz || std::fabs(
t2 -
t1) > epsilont) {
1051 double pk1 =
p1 * y.pk_ptr[
k] / (
p1 +
p2);
1052 double pk2 =
p2 * y.pk_ptr[
k] / (
p1 +
p2);
1055 y.removeItem(
k, tks);
1056 unsigned int k2 = y.insertOrdered(
z2,
t2, pk2, tks);
1060 std::cout <<
"unexpected z-ordering in split" << std::endl;
1066 for (
unsigned int jc = ic; jc <
critical.size(); jc++) {
1077 unsigned int k1 = y.insertOrdered(z1,
t1, pk1, tks);
1081 for (
unsigned int jc = ic; jc <
critical.size(); jc++) {
1089 std::cout <<
"warning ! split rejected, too small." << endl;
1111 y.addItem(0, 0, 1.0);
1112 clear_vtx_range(tks, y);
1115 double beta = beta0(betamax_, tks, y);
1121 thermalize(
beta, tks, y, delta_highT_, 0.);
1125 double betafreeze = betamax_ *
sqrt(coolingFactor_);
1127 while (
beta < betafreeze) {
1131 set_vtx_range(
beta, tks, y);
1137 thermalize(
beta, tks, y, delta_highT_, 0.);
1143 if (DEBUGLEVEL > 0) {
1144 std::cout <<
"DAClusterizerInZT_vect::vertices :"
1145 <<
"merging at T=" << 1 /
beta << std::endl;
1150 set_vtx_range(
beta, tks, y);
1155 set_vtx_range(
beta, tks, y);
1161 if (DEBUGLEVEL > 0) {
1162 std::cout <<
"DAClusterizerInZT_vect::vertices :"
1163 <<
"splitting/merging at T=" << 1 /
beta << std::endl;
1167 unsigned int ntry = 0;
1170 thermalize(
beta, tks, y, delta_highT_, 0.);
1174 set_vtx_range(
beta, tks, y);
1188 if (DEBUGLEVEL > 0) {
1189 std::cout <<
"DAClusterizerInZT_vect::vertices :"
1190 <<
"turning on outlier rejection at T=" << 1 /
beta << std::endl;
1195 if (dzCutOff_ > 0) {
1197 for (
unsigned int a = 0;
a < 5;
a++) {
1202 thermalize(
beta, tks, y, delta_lowT_, rho0);
1206 if (DEBUGLEVEL > 0) {
1207 std::cout <<
"DAClusterizerInZT_vect::vertices :"
1208 <<
"merging with outlier rejection at T=" << 1 /
beta << std::endl;
1217 set_vtx_range(
beta, tks, y);
1222 if (DEBUGLEVEL > 0) {
1223 std::cout <<
"DAClusterizerInZT_vect::vertices :"
1224 <<
"after merging with outlier rejection at T=" << 1 /
beta << std::endl;
1231 while (
beta < betapurge_) {
1233 thermalize(
beta, tks, y, delta_lowT_, rho0);
1238 if (DEBUGLEVEL > 0) {
1239 std::cout <<
"DAClusterizerInZT_vect::vertices :"
1240 <<
"purging at T=" << 1 /
beta << std::endl;
1245 while (purge(y, tks, rho0,
beta)) {
1246 thermalize(
beta, tks, y, delta_lowT_, rho0);
1248 set_vtx_range(
beta, tks, y);
1254 if (DEBUGLEVEL > 0) {
1255 std::cout <<
"DAClusterizerInZT_vect::vertices :"
1256 <<
"last cooling T=" << 1 /
beta << std::endl;
1261 while (
beta < betastop_) {
1263 thermalize(
beta, tks, y, delta_lowT_, rho0);
1265 set_vtx_range(
beta, tks, y);
1271 if (DEBUGLEVEL > 0) {
1272 std::cout <<
"DAClusterizerInZT_vect::vertices :"
1273 <<
"stop cooling at T=" << 1 /
beta << std::endl;
1281 double betadummy = 1;
1282 while (
merge(y, tks, betadummy))
1286 GlobalError dummyError(0.01, 0, 0.01, 0., 0., 0.01);
1289 const unsigned int nv = y.getSize();
1290 for (
unsigned int k = 0;
k < nv;
k++)
1296 for (
unsigned int i = 0;
i <
nt;
i++)
1297 tks.
Z_sum_ptr[
i] = rho0 * local_exp(-
beta * dzCutOff_ * dzCutOff_);
1300 for (
unsigned int k = 0;
k < nv;
k++) {
1301 for (
unsigned int i = 0;
i <
nt;
i++)
1307 for (
unsigned int k = 0;
k < nv;
k++) {
1310 vector<reco::TransientTrack> vertexTracks;
1311 for (
unsigned int i = 0;
i <
nt;
i++) {
1317 if ((tks.
pi_ptr[
i] > 0) && (
p > mintrkweight_)) {
1318 vertexTracks.push_back(*(tks.
tt[
i]));
1331 const vector<reco::TransientTrack>&
tracks)
const {
1332 vector<vector<reco::TransientTrack> >
clusters;
1336 if (DEBUGLEVEL > 0) {
1337 std::cout <<
"###################################################" << endl;
1338 std::cout <<
"# vectorized DAClusterizerInZT_vect::clusterize nt=" <<
tracks.size() << endl;
1339 std::cout <<
"# DAClusterizerInZT_vect::clusterize pv.size=" <<
pv.size() << endl;
1340 std::cout <<
"###################################################" << endl;
1349 for (
auto k =
pv.begin();
k !=
pv.end();
k++) {
1350 vector<reco::TransientTrack> aCluster =
k->originalTracks();
1351 if (aCluster.size() > 1) {
1361 const unsigned int nv = y.getSize();
1364 std::vector<unsigned int> iz;
1365 for (
unsigned int j = 0;
j <
nt;
j++) {
1368 std::sort(iz.begin(), iz.end(), [tks](
unsigned int a,
unsigned int b) {
return tks.
z_ptr[
a] < tks.
z_ptr[
b]; });
1370 std::cout <<
"-----DAClusterizerInZT::dump ----" << nv <<
" clusters " << std::endl;
1373 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1374 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) < zdumpwidth_) {
1382 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1383 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) < zdumpwidth_) {
1391 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1392 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) < zdumpwidth_) {
1398 std::cout <<
"T=" << setw(15) << 1. /
beta <<
" Tmin =" << setw(10) << 1. / betamax_
1400 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1401 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) < zdumpwidth_) {
1402 double Tc = get_Tc(y, ivertex);
1410 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1411 sumpk += y.pk_ptr[ivertex];
1412 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) > zdumpwidth_)
1414 std::cout << setw(8) << setprecision(4) <<
fixed << y.pk_ptr[ivertex];
1419 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1420 sumpk += y.pk_ptr[ivertex];
1421 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) > zdumpwidth_)
1423 std::cout << setw(8) << setprecision(1) <<
fixed << y.pk_ptr[ivertex] *
nt;
1428 double E = 0,
F = 0;
1430 std::cout <<
"---- z +/- dz t +/- dt ip +/-dip pt phi eta weights ----"
1433 for (
unsigned int i0 = 0; i0 <
nt; i0++) {
1434 unsigned int i = iz[i0];
1438 double tz = tks.
z_ptr[
i];
1440 if (std::fabs(tz - zdumpcenter_) > zdumpwidth_)
1442 std::cout << setw(4) <<
i <<
")" << setw(8) <<
fixed << setprecision(4) << tz <<
" +/-" << setw(6)
1466 .pixelBarrelLayersWithMeasurement();
1467 std::cout << setw(1) << tks.
tt[
i]->track().hitPattern().pixelEndcapLayersWithMeasurement();
1469 << tks.
tt[
i]->track().hitPattern().trackerLayersWithMeasurement() -
1470 tks.
tt[
i]->track().hitPattern().pixelLayersWithMeasurement()
1476 std::cout << setw(8) <<
IP.value() <<
"+/-" << setw(6) <<
IP.error();
1477 std::cout <<
" " << setw(6) << setprecision(2) << tks.
tt[
i]->track().pt() * tks.
tt[
i]->track().charge();
1478 std::cout <<
" " << setw(5) << setprecision(2) << tks.
tt[
i]->track().phi() <<
" " << setw(5) << setprecision(2)
1479 << tks.
tt[
i]->track().eta();
1482 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1483 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) > zdumpwidth_)
1493 if ((ivertex >= tks.
kmin[
i]) && (ivertex < tks.
kmax[
i])) {
1495 std::cout << setw(8) << setprecision(3) <<
p;
1505 }
else if (
p > 0.0001) {
1506 std::cout <<
"X" << setw(6) << setprecision(3) <<
p <<
"X";
1515 std::cout <<
" ( " << std::setw(3) << tks.
kmin[
i] <<
"," << std::setw(3) << tks.
kmax[
i] - 1 <<
" ) ";
1519 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1520 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) < zdumpwidth_) {
1521 std::cout <<
" " << setw(3) << ivertex <<
" ";
1527 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
1528 if (std::fabs(y.z_ptr[ivertex] - zdumpcenter_) < zdumpwidth_) {
1534 <<
"T=" << 1 /
beta <<
" E=" << E <<
" n=" << y.getSize() <<
" F= " <<
F << endl
1535 <<
"----------" << endl;