11 #include "vdt/vdtMath.h" 33 vertexSizeTime_ = conf.
getParameter<
double> (
"vertexSizeTime");
34 coolingFactor_ = conf.
getParameter<
double> (
"coolingFactor");
37 coolingFactor_=-coolingFactor_;
43 uniquetrkweight_ = conf.
getParameter<
double>(
"uniquetrkweight");
49 std::cout <<
"DAClusterizerinZT_vect: mintrkweight = " << mintrkweight_ << std::endl;
50 std::cout <<
"DAClusterizerinZT_vect: uniquetrkweight = " << uniquetrkweight_ << std::endl;
51 std::cout <<
"DAClusterizerinZT_vect: zmerge = " << zmerge_ << std::endl;
52 std::cout <<
"DAClusterizerinZT_vect: tmerge = " << tmerge_ << std::endl;
53 std::cout <<
"DAClusterizerinZT_vect: Tmin = " << minT << std::endl;
54 std::cout <<
"DAClusterizerinZT_vect: Tpurge = " << purgeT << std::endl;
55 std::cout <<
"DAClusterizerinZT_vect: Tstop = " << stopT << std::endl;
56 std::cout <<
"DAClusterizerinZT_vect: vertexSize = " << vertexSize_ << std::endl;
57 std::cout <<
"DAClusterizerinZT_vect: vertexSizeTime = " << vertexSizeTime_ << std::endl;
58 std::cout <<
"DAClusterizerinZT_vect: coolingFactor = " << coolingFactor_ << std::endl;
59 std::cout <<
"DAClusterizerinZT_vect: d0CutOff = " << d0CutOff_ << std::endl;
60 std::cout <<
"DAClusterizerinZT_vect: dzCutOff = " << dzCutOff_ << std::endl;
61 std::cout <<
"DAClusterizerinZT_vect: dtCutoff = " << dtCutOff_ << std::endl;
67 edm::LogWarning(
"DAClusterizerinZT_vectorized") <<
"DAClusterizerInZT: invalid Tmin" << minT
68 <<
" reset do default " << 1. / betamax_;
74 if ((purgeT > minT) || (purgeT == 0)) {
75 edm::LogWarning(
"DAClusterizerinZT_vectorized") <<
"DAClusterizerInZT: invalid Tpurge" << purgeT
76 <<
" set to " << minT;
79 betapurge_ = 1./purgeT;
82 if ((stopT > purgeT) || (stopT == 0)) {
83 edm::LogWarning(
"DAClusterizerinZT_vectorized") <<
"DAClusterizerInZT: invalid Tstop" << stopT
84 <<
" set to " <<
max(1., purgeT);
85 stopT =
max(1., purgeT) ;
93 inline double local_exp(
double const& inp) {
94 return vdt::fast_exp( inp );
97 inline void local_exp_list(
double const *arg_inp,
99 const unsigned arg_arr_size) {
100 for(
unsigned i=0;
i!=arg_arr_size; ++
i ) arg_out[
i]=vdt::fast_exp(arg_inp[
i]);
111 for(
const auto& tk : tracks ) {
112 if (!tk.isValid())
continue;
114 double t_z = tk.stateAtBeamLine().trackStateAtPCA().position().z();
115 double t_t = tk.timeExt();
116 if (std::fabs(t_z) > 1000.)
continue;
117 auto const & t_mom = tk.stateAtBeamLine().trackStateAtPCA().momentum();
129 if (tk.dtErrorExt()>0.3){
139 tk.stateAtBeamLine().transverseImpactParameter();
143 LogTrace(
"DAClusterizerinZT_vectorized") << t_z <<
' ' << t_t <<
' '<< t_dz2 <<
' ' << t_dt2 <<
' '<< t_pi;
144 tks.
addItem(t_z, t_t, t_dz2, t_dt2, &tk, t_pi);
160 double Eik(
double t_z,
double k_z,
double t_dz2,
double t_t,
double k_t,
double t_dt2) {
166 vertex_t & gvertices,
bool useRho0,
const double & rho0)
const {
172 const unsigned int nt = gtracks.
getSize();
173 const unsigned int nv = gvertices.
getSize();
187 Z_init = rho0 * local_exp(-beta * dzCutOff_ * dzCutOff_);
191 auto kernel_calc_exp_arg = [
beta, nv ] (
const unsigned int itrack,
195 const auto track_z = tracks.z_[itrack];
197 const auto botrack_dz2 = -beta*tracks.dz2_[itrack];
198 const auto botrack_dt2 = -beta*tracks.dt2_[itrack];
201 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
202 const auto mult_resz = track_z -
vertices.z_[ivertex];
204 vertices.ei_cache_[ivertex] = botrack_dz2 * ( mult_resz * mult_resz ) + botrack_dt2 * ( mult_rest * mult_rest );
210 double ZTemp = Z_init;
211 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
217 auto kernel_calc_normalization = [
beta, nv ] (
const unsigned int track_num,
220 auto tmp_trk_pi = tks_vec.pi_[track_num];
221 auto o_trk_Z_sum = 1./tks_vec.Z_sum_[track_num];
222 auto o_trk_err_z = tks_vec.dz2_[track_num];
223 auto o_trk_err_t = tks_vec.dt2_[track_num];
224 auto tmp_trk_z = tks_vec.z_[track_num];
225 auto tmp_trk_t = tks_vec.t_[track_num];
229 for (
unsigned int k = 0;
k < nv; ++
k) {
231 y_vec.se_[
k] += tmp_trk_pi*( y_vec.ei_[
k] * o_trk_Z_sum );
232 const auto w = tmp_trk_pi * (y_vec.pk_[
k] * y_vec.ei_[
k] * o_trk_Z_sum);
233 const auto wz = w * o_trk_err_z;
234 const auto wt = w * o_trk_err_t;
237 y_vec.swz_[
k] += wz * tmp_trk_z;
238 y_vec.swt_[
k] += wt * tmp_trk_t;
240 const auto dsz = (tmp_trk_z - y_vec.z[
k]) * o_trk_err_z;
241 const auto dst = (tmp_trk_t - y_vec.t[
k]) * o_trk_err_t;
242 y_vec.szz_[
k] += w * dsz * dsz;
243 y_vec.stt_[
k] += w * dst * dst;
244 y_vec.szt_[
k] += w * dsz * dst;
249 for (
auto ivertex = 0
U; ivertex < nv; ++ivertex) {
250 gvertices.
se_[ivertex] = 0.0;
251 gvertices.
nuz_[ivertex] = 0.0;
252 gvertices.
nut_[ivertex] = 0.0;
253 gvertices.
swz_[ivertex] = 0.0;
254 gvertices.
swt_[ivertex] = 0.0;
255 gvertices.
szz_[ivertex] = 0.0;
256 gvertices.
stt_[ivertex] = 0.0;
257 gvertices.
szt_[ivertex] = 0.0;
262 for (
auto itrack = 0
U; itrack <
nt; ++itrack) {
263 kernel_calc_exp_arg(itrack, gtracks, gvertices);
266 gtracks.
Z_sum_[itrack] = kernel_add_Z(gvertices);
269 sumpi += gtracks.
pi_[itrack];
271 if (gtracks.
Z_sum_[itrack] > 1.e-100){
272 kernel_calc_normalization(itrack, gtracks, gvertices);
277 auto kernel_calc_zt = [ sumpi, nv,
this, useRho0 ] (
vertex_t &
vertices ) ->
double {
282 for (
unsigned int ivertex = 0; ivertex < nv; ++ ivertex ) {
300 edm::LogInfo(
"sumw") <<
"invalid sum of weights in fit: " << endl;
301 if (this->verbose_) {
302 std::cout <<
" a cluster melted away ? pk=" <<
vertices.pk_[ ivertex ] <<
" sumw=" 309 auto osumpi = 1./sumpi;
310 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex )
316 delta += kernel_calc_zt(gvertices);
328 const unsigned int nv = y.
getSize();
333 bool reordering =
true;
334 bool modified =
false;
338 for (
unsigned int k = 0; (
k + 1) < nv;
k++) {
339 if ( y.
z[
k + 1] < y.
z[
k] ) {
340 auto ztemp = y.
z[
k]; y.
z[
k] = y.
z[
k+1]; y.
z[
k+1] = ztemp;
341 auto ttemp = y.
t[
k]; y.
t[
k] = y.
t[
k+1]; y.
t[
k+1] = ttemp;
342 auto ptemp = y.
pk[
k]; y.
pk[
k] = y.
pk[
k+1]; y.
pk[
k+1] = ptemp;
346 modified |= reordering;
364 for(
unsigned int k0 = 1;
k0 < nv;
k0++){
370 double delta_min = 1.;
374 while( ( k1 > 0) && ((y.
z[k] - y.
z[--k1]) < dz ) ){
377 if (
delta < delta_min){
385 while( ((++k1) < nv) && ((y.
z[k1] - y.
z[k]) < dz ) ){
388 if (
delta < delta_min){
394 return (delta_min < 1.);
403 const unsigned int nv = y.
getSize();
409 unsigned int k1_min = 0, k2_min = 0;
410 double delta_min = 0;
412 for (
unsigned int k1 = 0; (k1 + 1) < nv; k1++) {
413 unsigned int k2 = k1;
414 while( (++k2 < nv) && ( std::fabs(y.
z[k2] - y.
z_[k1] ) < zmerge_ ) ){
417 if ( (
delta < delta_min) || (k1_min == k2_min) ){
425 if( (k1_min == k2_min) || (delta_min > 1) ){
430 double rho = y.
pk_[k1_min] + y.
pk_[k2_min];
432 if(verbose_){
std::cout <<
"merging (" << setw(8) <<
fixed << setprecision(4) << y.
z_[k1_min] <<
',' << y.
t_[k1_min] <<
") and (" << y.
z_[k2_min] <<
',' << y.
t_[k2_min] <<
")" <<
" idx=" << k1_min <<
"," << k2_min << std::endl;}
435 y.
z_[k1_min] = (y.
pk_[k1_min] * y.
z_[k1_min] + y.
pk_[k2_min] * y.
z_[k2_min])/rho;
436 y.
t_[k1_min] = (y.
pk_[k1_min] * y.
t_[k1_min] + y.
pk_[k2_min] * y.
t_[k2_min])/rho;
438 y.
z_[k1_min] = 0.5 * (y.
z_[k1_min] + y.
z_[k2_min]);
439 y.
t_[k1_min] = 0.5 * (y.
t_[k1_min] + y.
t_[k2_min]);
451 const unsigned int nv = y.
getSize();
458 unsigned int k0 = nv;
463 std::vector<double> inverse_zsums(nt), arg_cache(nt), eik_cache(nt);
464 double * pinverse_zsums;
467 pinverse_zsums = inverse_zsums.data();
468 parg_cache = arg_cache.data();
469 peik_cache = eik_cache.data();
470 for(
unsigned i = 0;
i <
nt; ++
i) {
474 for (
unsigned int k = 0;
k < nv; ++
k) {
479 const double pmax = y.
pk_[
k] / (y.
pk_[
k] + rho0 * local_exp(-beta * dzCutOff_* dzCutOff_));
480 const double pcut = uniquetrkweight_ * pmax;
481 for(
unsigned i = 0;
i <
nt; ++
i) {
482 const auto track_z = tks.
z_[
i];
484 const auto botrack_dz2 = -beta*tks.
dz2_[
i];
485 const auto botrack_dt2 = -beta*tks.
dt2_[
i];
487 const auto mult_resz = track_z - y.
z_[
k];
489 parg_cache[
i] = botrack_dz2 * ( mult_resz * mult_resz ) + botrack_dt2 * ( mult_rest * mult_rest );
491 local_exp_list(parg_cache, peik_cache, nt);
492 for (
unsigned int i = 0;
i <
nt; ++
i) {
493 const double p = y.
pk_[
k] * peik_cache[
i] * pinverse_zsums[
i];
495 nUnique += ( ( p > pcut ) & ( tks.
pi_[
i] > 0 ) );
498 if ((nUnique < 2) && (sump < sumpmin)) {
508 std::cout <<
"eliminating prototype at " << std::setw(10) << std::setprecision(4) << y.
z_[
k0] <<
"," << y.
t_[
k0]
509 <<
" with sump=" << sumpmin
510 <<
" rho*nt =" << y.
pk_[
k0]*nt
530 const unsigned int nv = y.
getSize();
532 for (
unsigned int k = 0;
k < nv;
k++) {
539 for (
unsigned int i = 0;
i <
nt;
i++) {
542 sumwz += w_z * tks.
z_[
i];
543 sumwt += w_t * tks.
t_[
i];
547 y.
z_[
k] = sumwz / sumw_z;
548 y.
t_[
k] = sumwt / sumw_t;
551 double szz = 0, stt = 0, szt = 0;
552 double nuz = 0, nut = 0;
553 for (
unsigned int i = 0;
i <
nt;
i++) {
556 double w = tks.
pi_[
i];
560 nuz += w * tks.
dz2_[
i];
561 nut += w * tks.
dt2_[
i];
565 double Tc = Tz + Tt +
sqrt(
pow(Tz - Tt, 2) + 4 * szt * szt / nuz / nut);
567 if (Tc > T0) T0 = Tc;
572 std::cout <<
"DAClustrizerInZT_vect.beta0: Tc = " << T0 << std::endl;
574 std::cout <<
"DAClustrizerInZT_vect.beta0: nstep = " << coolingsteps << std::endl;
579 if (T0 > 1. / betamax) {
583 return betamax * coolingFactor_;
591 return Tz + Tt +
sqrt(
pow(Tz - Tt, 2) + 4 * mx);
603 const double twoBeta = 2.0*
beta;
607 std::vector<std::pair<double, unsigned int> > critical;
608 for(
unsigned int k=0;
k<nv;
k++){
609 double Tc= get_Tc(y,
k);
610 if (beta*Tc > threshold){
611 critical.push_back( make_pair(Tc,
k));
614 if (critical.empty())
return false;
617 std::stable_sort(critical.begin(), critical.end(), std::greater<std::pair<double, unsigned int> >() );
622 for(
unsigned int ic=0; ic<critical.size(); ic++){
623 unsigned int k=critical[ic].second;
629 double Mzt = - twoBeta*y.
szt_[
k];
630 const double twoMzt = 2.0*Mzt;
631 double D =
sqrt(
pow(Mtt-Mzz, 2) + twoMzt*twoMzt);
632 double q1 = atan2(-Mtt+Mzz+D, -twoMzt);
633 double l1 = 0.5*(-Mzz-Mtt+
D);
634 double l2 = 0.5*(-Mzz-Mtt-
D);
636 edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, bad eigenvalues! idx=" << k <<
" z= " << y.
z_[
k] <<
" Mzz=" << Mzz <<
" Mtt=" << Mtt <<
" Mzt=" << Mzt << endl;
640 double cq =
cos(qsplit);
641 double sq =
sin(qsplit);
642 if(cq < 0){ cq=-cq; sq=-sq; }
645 double p1=0, z1=0, t1=0, wz1=0, wt1=0;
646 double p2=0, z2=0,
t2=0, wz2=0, wt2=0;
647 for(
unsigned int i=0;
i<
nt; ++
i){
649 double lr = (tks.
z_[
i]-y.
z_[
k]) * cq + (tks.
t[
i] - y.
t_[k]) * sq;
651 double tl = lr < 0 ? 1.: 0.;
657 double t = local_exp(-arg);
662 double p = y.
pk_[
k] * tks.
pi_[
i] * local_exp(-beta * Eik(tks.
z_[i], y.
z_[k], tks.
dz2_[i],
664 double wz = p*tks.
dz2_[
i];
665 double wt = p*tks.
dt2_[
i];
666 p1 += p*tl; z1 += wz*tl*tks.
z_[
i]; t1 += wt*tl*tks.
t_[
i]; wz1 += wz*tl; wt1 += wt*tl;
667 p2 += p*tr; z2 += wz*tr*tks.
z_[
i];
t2 += wt*tr*tks.
t_[
i]; wz2 += wz*tr; wt2 += wt*tr;
671 if(wz1 > 0){z1 /= wz1;}
else {z1 = y.
z_[
k] - epsilonz * cq;
edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, wz1 = " << scientific << wz1 << endl;}
672 if(wt1 > 0){t1 /= wt1;}
else {t1 = y.
t_[
k] - epsilont * sq;
edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, w11 = " << scientific << wt1 << endl;}
673 if(wz2 > 0){z2 /= wz2;}
else {z2 = y.
z_[
k] + epsilonz * cq;
edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, wz2 = " << scientific << wz2 << endl;}
674 if(wt2 > 0){
t2 /= wt2;}
else {
t2 = y.
t_[
k] + epsilont * sq;
edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, wt2 = " << scientific << wt2 << endl;}
676 unsigned int k_min1 =
k, k_min2 =
k;
677 while( (find_nearest(z1, t1, y, k_min1, epsilonz, epsilont) && (k_min1 != k))
678 || (find_nearest(z2,
t2, y, k_min2, epsilonz, epsilont) && (k_min2 !=k)) ){
679 z1 = 0.5*( z1 + y.
z_[
k]); t1 = 0.5*( t1 + y.
t_[
k]);
680 z2 = 0.5*( z2 + y.
z_[
k]);
t2 = 0.5*(
t2 + y.
t_[
k]);
685 if (std::fabs(y.
z_[k] - zdumpcenter_) < zdumpwidth_){
686 std::cout <<
" T= " << std::setw(10) << std::setprecision(1) << 1./beta
687 <<
" Tc= " << critical[ic].first
688 <<
" direction =" << std::setprecision(4) << qsplit
689 <<
" splitting (" << std::setw(8) <<
std::fixed << std::setprecision(4) << y.
z_[
k] <<
"," << y.
t_[
k] <<
")" 690 <<
" --> (" << z1 <<
',' << t1<<
"),(" << z2 <<
',' <<
t2 691 <<
") [" << p1 <<
"," << p2 <<
"]" ;
692 if (std::fabs(z2-z1) > epsilonz || std::fabs(
t2-t1) > epsilont){
702 edm::LogInfo(
"DAClusterizerInZT") <<
"warning swapping z in split qsplit=" << qsplit <<
" cq=" << cq <<
" sq=" << sq << endl;
706 z1 = z2; t1=
t2; p1=
p2;
707 z2 = ztemp;
t2=ttemp; p2=ptemp;
714 if( std::fabs(z2-z1) > epsilonz || std::fabs(
t2-t1) > epsilont){
716 double pk1 = p1*y.
pk_[
k]/(p1+
p2);
717 double pk2 = p2*y.
pk_[
k]/(p1+
p2);
724 for(
unsigned int jc=ic; jc < critical.size(); jc++){
725 if (critical[jc].
second > k ) {critical[jc].second--;}
726 if (critical[jc].
second >= k2) {critical[jc].second++;}
735 for(
unsigned int jc=ic; jc < critical.size(); jc++){
736 if (critical[jc].
second >= k1) {critical[jc].second++;}
741 std::cout <<
"warning ! split rejected, too small." << endl;
753 const unsigned int nv = y.
getSize();
763 std::cout <<
"Before Split "<< std::endl;
768 for (
unsigned int k = 0;
k < nv;
k++) {
770 ( ( (
k == 0) || ( y.
z_[
k - 1] < (y.
z_[
k] - zsep)) ) &&
771 ( ((
k + 1) == nv) || ( y.
z_[
k + 1] > (y.
z_[
k] + zsep)) ) ) )
774 double new_z = y.
z[
k] - epsilonz;
775 double new_t = y.
t[
k] - epsilont;
776 y.
z[
k] = y.
z[
k] + epsilonz;
777 y.
t[
k] = y.
t[
k] + epsilont;
779 double new_pk = 0.5 * y.
pk[
k];
782 y1.
addItem(new_z, new_t, new_pk);
785 else if ( (y1.
getSize() == 0 ) ||
795 y.
z_[
k] = y.
z_[
k] + epsilonz;
796 y.
t_[
k] = y.
t_[
k] + epsilont;
806 std::cout <<
"After split " << std::endl;
814 vector<TransientVertex>
823 if (tks.
getSize() == 0)
return clusters;
834 double beta = beta0(betamax_, tks, y);
836 if ( verbose_)
std::cout <<
"Beta0 is " << beta << std::endl;
840 while ((
update(beta, tks, y,
false, rho0) > 1.
e-6) &&
841 (niter++ < maxIterations_)) {}
845 double betafreeze = betamax_ *
sqrt(coolingFactor_);
847 while (beta < betafreeze) {
849 update(beta, tks,y,
false, rho0);
851 while(
merge(y, beta)){
update(beta, tks, y,
false, rho0);}
853 beta=beta/coolingFactor_;
855 beta=beta/coolingFactor_;
861 while ((
update(beta, tks, y,
false, rho0) > 1.
e-6) &&
862 (niter++ < maxIterations_)) {}
865 if(verbose_){
dump( beta, y, tks, 0); }
873 if(verbose_){
std::cout <<
"last spliting at " << 1./beta << std::endl; }
875 update(beta, tks,y,
false, rho0);
877 while(
merge(y,beta)){
update(beta, tks,y,
false, rho0);}
880 while(
split(beta, tks, y, threshold) && (ntry++<10) ){
882 while((
update(beta, tks,y,
false, rho0)>1.
e-6) && (niter++ < maxIterations_)){}
885 if(verbose_)
dump(beta, y, tks, 2);
888 while(
merge(y,beta)){
update(beta, tks,y,
false, rho0);}
891 std::cout <<
"after final splitting, try " << ntry << std::endl;
892 dump(beta, y, tks, 2);
900 while(
merge(y,beta)){
update(beta, tks,y,
false, rho0);}
905 update(beta, tks,y,
false, rho0);
906 std::cout <<
"dump after 1st merging " << endl;
907 dump(beta, y, tks, 2);
915 for(
unsigned int a=0;
a<10;
a++){
update(beta, tks, y,
true,
a*rho0/10);}
919 while ((
update(beta, tks, y,
true, rho0) > 1.
e-8) && (niter++ < maxIterations_)) {};
922 std::cout <<
"dump after noise-suppression, rho0=" << rho0 <<
" niter = " << niter << endl;
923 dump(beta, y, tks, 2);
929 while (
merge(y, beta)) {
update(beta, tks, y,
true, rho0); }
932 std::cout <<
"dump after merging " << endl;
933 dump(beta, y, tks, 2);
938 while( beta < betapurge_ ){
939 beta =
min( beta/coolingFactor_, betapurge_);
941 while ((
update(beta, tks, y,
false, rho0) > 1.
e-8) && (niter++ < maxIterations_)) {}
946 while (purge(y, tks, rho0, beta)) {
948 while ((
update(beta, tks, y,
true, rho0) > 1.
e-6 ) && (niter++ < maxIterations_)) {
955 update(beta, tks,y,
true, rho0);
956 std::cout <<
" after purging " << std:: endl;
957 dump(beta, y, tks, 2);
962 while( beta < betastop_ ){
963 beta =
min( beta/coolingFactor_, betastop_);
965 while ((
update(beta, tks, y,
true, rho0) > 1.
e-8) && (niter++ < maxIterations_)) {}
971 std::cout <<
"Final result, rho0=" << std::scientific << rho0 << endl;
972 dump(beta, y, tks, 2);
979 double betadummy = 1;
980 while(
merge(y, betadummy) );
983 GlobalError dummyError(0.01, 0, 0.01, 0., 0., 0.01);
986 const unsigned int nv = y.
getSize();
987 for (
unsigned int k = 0;
k < nv;
k++)
990 for (
unsigned int i = 0;
i <
nt;
i++)
991 tks.
Z_sum_[
i] = rho0 * local_exp(-beta * dzCutOff_ * dzCutOff_);
994 for (
unsigned int k = 0;
k < nv;
k++) {
995 for (
unsigned int i = 0;
i <
nt;
i++)
1000 for (
unsigned int k = 0;
k < nv;
k++) {
1003 vector<reco::TransientTrack> vertexTracks;
1004 for (
unsigned int i = 0;
i <
nt;
i++) {
1007 double p = y.
pk_[
k] * local_exp(-beta * Eik(tks.
z_[
i], y.
z_[
k], tks.
dz2_[
i],
1009 if ((tks.
pi_[
i] > 0) && (p > mintrkweight_)) {
1010 vertexTracks.push_back(*(tks.
tt[
i]));
1016 clusters.push_back(v);
1024 const vector<reco::TransientTrack> &
tracks)
const {
1028 std::cout <<
"###################################################" << endl;
1029 std::cout <<
"# vectorized DAClusterizerInZT_vect::clusterize nt=" << tracks.size() << endl;
1030 std::cout <<
"###################################################" << endl;
1034 vector<vector<reco::TransientTrack> >
clusters;
1035 vector<TransientVertex> &&
pv =
vertices(tracks);
1039 std::cout <<
"# DAClusterizerInZT::clusterize pv.size=" << pv.size() << endl;
1048 for (
auto k = pv.begin();
k != pv.end();
k++) {
1049 vector<reco::TransientTrack> aCluster =
k->originalTracks();
1050 if (aCluster.size()>1){
1051 clusters.push_back(aCluster);
1094 const unsigned int nv = y.
getSize();
1097 std::vector< unsigned int > iz;
1098 for(
unsigned int j=0; j<
nt; j++){ iz.push_back(j); }
1099 std::sort(iz.begin(), iz.end(), [tks](
unsigned int a,
unsigned int b){
return tks.
z_[
a]<tks.
z_[
b];} );
1101 std::cout <<
"-----DAClusterizerInZT::dump ----" << nv <<
" clusters " << std::endl;
1104 for (
unsigned int ivertex = 0; ivertex < nv; ++ ivertex) {
1105 if (std::fabs(y.
z_[ivertex]-zdumpcenter_) < zdumpwidth_){
1113 for (
unsigned int ivertex = 0; ivertex < nv; ++ ivertex) {
1114 if (std::fabs(y.
z_[ivertex]-zdumpcenter_) < zdumpwidth_){
1122 for (
unsigned int ivertex = 0; ivertex < nv; ++ ivertex) {
1123 if (std::fabs(y.
z_[ivertex]-zdumpcenter_) < zdumpwidth_){
1129 std::cout <<
"T=" << setw(15) << 1. / beta
1130 <<
" Tmin =" << setw(10) << 1./betamax_
1132 for (
unsigned int ivertex = 0; ivertex < nv; ++ ivertex) {
1133 if (std::fabs(y.
z_[ivertex]-zdumpcenter_) < zdumpwidth_){
1134 double Tc = get_Tc(y, ivertex);
1142 for (
unsigned int ivertex = 0; ivertex < nv; ++ ivertex) {
1143 sumpk += y.
pk_[ivertex];
1144 if (std::fabs(y.
z_[ivertex] - zdumpcenter_) > zdumpwidth_)
continue;
1150 for (
unsigned int ivertex = 0; ivertex < nv; ++ ivertex) {
1151 sumpk += y.
pk_[ivertex];
1152 if (std::fabs(y.
z_[ivertex] - zdumpcenter_) > zdumpwidth_)
continue;
1157 if (verbosity > 0) {
1158 double E = 0,
F = 0;
1161 <<
"---- z +/- dz t +/- dt ip +/-dip pt phi eta weights ----" 1164 for (
unsigned int i0 = 0; i0 <
nt; i0++) {
1165 unsigned int i = iz[i0];
1169 double tz = tks.
z_[
i];
1171 if( std::fabs(tz - zdumpcenter_) > zdumpwidth_)
continue;
1172 std::cout << setw(4) << i <<
")" << setw(8) <<
fixed << setprecision(4)
1173 << tz <<
" +/-" << setw(6) <<
sqrt(1./tks.
dz2_[i]);
1175 if( tks.
dt2_[i] >0){
1177 << tks.
t_[
i] <<
" +/-" << setw(6) <<
sqrt(1./tks.
dt2_[i]);
1193 << tks.
tt[
i]->track().hitPattern().pixelBarrelLayersWithMeasurement();
1195 << tks.
tt[
i]->track().hitPattern().pixelEndcapLayersWithMeasurement();
1197 << tks.
tt[
i]->track().hitPattern().trackerLayersWithMeasurement()
1198 - tks.
tt[
i]->track().hitPattern().pixelLayersWithMeasurement()
1205 tks.
tt[
i]->stateAtBeamLine().transverseImpactParameter();
1207 std::cout <<
" " << setw(6) << setprecision(2)
1208 << tks.
tt[
i]->track().pt() * tks.
tt[
i]->track().charge();
1209 std::cout <<
" " << setw(5) << setprecision(2)
1210 << tks.
tt[
i]->track().phi() <<
" " << setw(5)
1211 << setprecision(2) << tks.
tt[
i]->track().eta();
1214 for (
unsigned int ivertex = 0; ivertex < nv; ++ ivertex) {
1215 if (std::fabs(y.
z_[ivertex]-zdumpcenter_) > zdumpwidth_)
continue;
1217 if ((tks.
pi_[i] > 0) && (tks.
Z_sum_[i] > 0)) {
1219 double p = y.
pk_[ivertex] *
exp(-beta * Eik(tks.
z_[i], y.
z_[ivertex], tks.
dz2_[i],
1222 std::cout << setw(8) << setprecision(3) <<
p;
1226 E += p * Eik(tks.
z_[i], y.
z_[ivertex], tks.
dz2_[i],
1227 tks.
t_[i], y.
t_[ivertex], tks.
dt2_[i] );
1235 std::cout << endl <<
"T=" << 1 / beta <<
" E=" << E <<
" n=" << y.
getSize()
1236 <<
" F= " <<
F << endl <<
"----------" << endl;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
unsigned int insertOrdered(double z, double t, double pk)
std::vector< std::vector< reco::TransientTrack > > clusterize(const std::vector< reco::TransientTrack > &tracks) const override
bool split(const double beta, track_t &t, vertex_t &y, double threshold=1.) const
Sin< T >::type sin(const T &t)
void splitAll(vertex_t &y) const
DAClusterizerInZT_vect(const edm::ParameterSet &conf)
bool merge(vertex_t &y, double &beta) const
void addItem(double new_z, double new_t, double new_dz2, double new_dt2, const reco::TransientTrack *new_tt, double new_pi)
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &tracks, const int verbosity=0) const
void zorder(vertex_t &y) const
U second(std::pair< T, U > const &p)
double get_Tc(const vertex_t &y, int k) const
bool purge(vertex_t &, track_t &, double &, const double) const
auto const T2 &decltype(t1.eta()) t2
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
bool find_nearest(double z, double t, vertex_t &y, unsigned int &k_min, double dz, double dt) const
double BeamWidthX() const
beam width X
void removeItem(unsigned int i)
double update(double beta, track_t >racks, vertex_t &gvertices, bool useRho0, const double &rho0) const
unsigned int getSize() const
DecomposeProduct< arg, typename Div::arg > D
void addItem(double new_z, double new_t, double new_pk)
double BeamWidthY() const
beam width Y
track_t fill(const std::vector< reco::TransientTrack > &tracks) const
unsigned int getSize() const
double beta0(const double betamax, track_t const &tks, vertex_t const &y) const
std::vector< const reco::TransientTrack * > tt
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
void dump(const double beta, const vertex_t &y, const track_t &tks, const int verbosity=0) const
Power< A, B >::type pow(const A &a, const B &b)
def merge(dictlist, TELL=False)