11 #include "vdt/vdtMath.h" 33 vertexSizeTime_ = conf.
getParameter<
double> (
"vertexSizeTime");
34 coolingFactor_ = conf.
getParameter<
double> (
"coolingFactor");
37 coolingFactor_=-coolingFactor_;
44 uniquetrkweight_ = conf.
getParameter<
double>(
"uniquetrkweight");
50 std::cout <<
"DAClusterizerinZT_vect: mintrkweight = " << mintrkweight_ << std::endl;
51 std::cout <<
"DAClusterizerinZT_vect: uniquetrkweight = " << uniquetrkweight_ << std::endl;
52 std::cout <<
"DAClusterizerinZT_vect: zmerge = " << zmerge_ << std::endl;
53 std::cout <<
"DAClusterizerinZT_vect: tmerge = " << tmerge_ << std::endl;
54 std::cout <<
"DAClusterizerinZT_vect: Tmin = " << minT << std::endl;
55 std::cout <<
"DAClusterizerinZT_vect: Tpurge = " << purgeT << std::endl;
56 std::cout <<
"DAClusterizerinZT_vect: Tstop = " << stopT << std::endl;
57 std::cout <<
"DAClusterizerinZT_vect: vertexSize = " << vertexSize_ << std::endl;
58 std::cout <<
"DAClusterizerinZT_vect: vertexSizeTime = " << vertexSizeTime_ << std::endl;
59 std::cout <<
"DAClusterizerinZT_vect: coolingFactor = " << coolingFactor_ << std::endl;
60 std::cout <<
"DAClusterizerinZT_vect: d0CutOff = " << d0CutOff_ << std::endl;
61 std::cout <<
"DAClusterizerinZT_vect: dzCutOff = " << dzCutOff_ << std::endl;
62 std::cout <<
"DAClusterizerinZT_vect: dtCutoff = " << dtCutOff_ << std::endl;
68 edm::LogWarning(
"DAClusterizerinZT_vectorized") <<
"DAClusterizerInZT: invalid Tmin" << minT
69 <<
" reset do default " << 1. / betamax_;
75 if ((purgeT > minT) || (purgeT == 0)) {
76 edm::LogWarning(
"DAClusterizerinZT_vectorized") <<
"DAClusterizerInZT: invalid Tpurge" << purgeT
77 <<
" set to " << minT;
80 betapurge_ = 1./purgeT;
83 if ((stopT > purgeT) || (stopT == 0)) {
84 edm::LogWarning(
"DAClusterizerinZT_vectorized") <<
"DAClusterizerInZT: invalid Tstop" << stopT
85 <<
" set to " <<
max(1., purgeT);
86 stopT =
max(1., purgeT) ;
94 inline double local_exp(
double const& inp) {
95 return vdt::fast_exp( inp );
98 inline void local_exp_list(
double const *arg_inp,
100 const unsigned arg_arr_size) {
101 for(
unsigned i=0;
i!=arg_arr_size; ++
i ) arg_out[
i]=vdt::fast_exp(arg_inp[
i]);
112 for(
const auto& tk : tracks ) {
113 if (!tk.isValid())
continue;
115 double t_z = tk.stateAtBeamLine().trackStateAtPCA().position().z();
116 double t_t = tk.timeExt();
117 if (std::fabs(t_z) > 1000.)
continue;
118 if (
std::abs(t_t) > t0Max_)
continue;
119 auto const & t_mom = tk.stateAtBeamLine().trackStateAtPCA().momentum();
131 if (tk.dtErrorExt()>0.3){
141 tk.stateAtBeamLine().transverseImpactParameter();
145 LogTrace(
"DAClusterizerinZT_vectorized") << t_z <<
' ' << t_t <<
' '<< t_dz2 <<
' ' << t_dt2 <<
' '<< t_pi;
146 tks.
addItem(t_z, t_t, t_dz2, t_dt2, &tk, t_pi);
162 double Eik(
double t_z,
double k_z,
double t_dz2,
double t_t,
double k_t,
double t_dt2) {
168 vertex_t & gvertices,
bool useRho0,
const double & rho0)
const {
174 const unsigned int nt = gtracks.
getSize();
175 const unsigned int nv = gvertices.
getSize();
189 Z_init = rho0 * local_exp(-beta * dzCutOff_ * dzCutOff_);
193 auto kernel_calc_exp_arg = [
beta, nv ] (
const unsigned int itrack,
197 const auto track_z = tracks.z_[itrack];
199 const auto botrack_dz2 = -beta*tracks.dz2_[itrack];
200 const auto botrack_dt2 = -beta*tracks.dt2_[itrack];
203 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
204 const auto mult_resz = track_z -
vertices.z_[ivertex];
206 vertices.ei_cache_[ivertex] = botrack_dz2 * ( mult_resz * mult_resz ) + botrack_dt2 * ( mult_rest * mult_rest );
212 double ZTemp = Z_init;
213 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex) {
219 auto kernel_calc_normalization = [ nv ] (
const unsigned int track_num,
222 auto tmp_trk_pi = tks_vec.pi_[track_num];
223 auto o_trk_Z_sum = 1./tks_vec.Z_sum_[track_num];
224 auto o_trk_err_z = tks_vec.dz2_[track_num];
225 auto o_trk_err_t = tks_vec.dt2_[track_num];
226 auto tmp_trk_z = tks_vec.z_[track_num];
227 auto tmp_trk_t = tks_vec.t_[track_num];
231 for (
unsigned int k = 0;
k < nv; ++
k) {
233 y_vec.se_[
k] += tmp_trk_pi*( y_vec.ei_[
k] * o_trk_Z_sum );
234 const auto w = tmp_trk_pi * (y_vec.pk_[
k] * y_vec.ei_[
k] * o_trk_Z_sum);
235 const auto wz = w * o_trk_err_z;
236 const auto wt = w * o_trk_err_t;
239 y_vec.swz_[
k] += wz * tmp_trk_z;
240 y_vec.swt_[
k] += wt * tmp_trk_t;
242 const auto dsz = (tmp_trk_z - y_vec.z[
k]) * o_trk_err_z;
243 const auto dst = (tmp_trk_t - y_vec.t[
k]) * o_trk_err_t;
244 y_vec.szz_[
k] += w * dsz * dsz;
245 y_vec.stt_[
k] += w * dst * dst;
246 y_vec.szt_[
k] += w * dsz * dst;
251 for (
auto ivertex = 0
U; ivertex < nv; ++ivertex) {
252 gvertices.
se_[ivertex] = 0.0;
253 gvertices.
nuz_[ivertex] = 0.0;
254 gvertices.
nut_[ivertex] = 0.0;
255 gvertices.
swz_[ivertex] = 0.0;
256 gvertices.
swt_[ivertex] = 0.0;
257 gvertices.
szz_[ivertex] = 0.0;
258 gvertices.
stt_[ivertex] = 0.0;
259 gvertices.
szt_[ivertex] = 0.0;
264 for (
auto itrack = 0
U; itrack <
nt; ++itrack) {
265 kernel_calc_exp_arg(itrack, gtracks, gvertices);
268 gtracks.
Z_sum_[itrack] = kernel_add_Z(gvertices);
271 sumpi += gtracks.
pi_[itrack];
273 if (gtracks.
Z_sum_[itrack] > 1.e-100){
274 kernel_calc_normalization(itrack, gtracks, gvertices);
279 auto kernel_calc_zt = [ sumpi, nv
288 for (
unsigned int ivertex = 0; ivertex < nv; ++ ivertex ) {
306 edm::LogInfo(
"sumw") <<
"invalid sum of weights in fit: " << endl;
307 if (this->verbose_) {
308 std::cout <<
" a cluster melted away ? pk=" <<
vertices.pk_[ ivertex ] <<
" sumw=" 315 auto osumpi = 1./sumpi;
316 for (
unsigned int ivertex = 0; ivertex < nv; ++ivertex )
322 delta += kernel_calc_zt(gvertices);
334 const unsigned int nv = y.
getSize();
339 bool reordering =
true;
340 bool modified =
false;
344 for (
unsigned int k = 0; (
k + 1) < nv;
k++) {
345 if ( y.
z[
k + 1] < y.
z[
k] ) {
346 auto ztemp = y.
z[
k]; y.
z[
k] = y.
z[
k+1]; y.
z[
k+1] = ztemp;
347 auto ttemp = y.
t[
k]; y.
t[
k] = y.
t[
k+1]; y.
t[
k+1] = ttemp;
348 auto ptemp = y.
pk[
k]; y.
pk[
k] = y.
pk[
k+1]; y.
pk[
k+1] = ptemp;
352 modified |= reordering;
370 for(
unsigned int k0 = 1;
k0 < nv;
k0++){
376 double delta_min = 1.;
380 while( ( k1 > 0) && ((y.
z[k] - y.
z[--k1]) < dz ) ){
383 if (
delta < delta_min){
391 while( ((++k1) < nv) && ((y.
z[k1] - y.
z[k]) < dz ) ){
394 if (
delta < delta_min){
400 return (delta_min < 1.);
409 const unsigned int nv = y.
getSize();
415 unsigned int k1_min = 0, k2_min = 0;
416 double delta_min = 0;
418 for (
unsigned int k1 = 0; (k1 + 1) < nv; k1++) {
419 unsigned int k2 = k1;
420 while( (++k2 < nv) && ( std::fabs(y.
z[k2] - y.
z_[k1] ) < zmerge_ ) ){
423 if ( (
delta < delta_min) || (k1_min == k2_min) ){
431 if( (k1_min == k2_min) || (delta_min > 1) ){
436 double rho = y.
pk_[k1_min] + y.
pk_[k2_min];
438 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;}
441 y.
z_[k1_min] = (y.
pk_[k1_min] * y.
z_[k1_min] + y.
pk_[k2_min] * y.
z_[k2_min])/rho;
442 y.
t_[k1_min] = (y.
pk_[k1_min] * y.
t_[k1_min] + y.
pk_[k2_min] * y.
t_[k2_min])/rho;
444 y.
z_[k1_min] = 0.5 * (y.
z_[k1_min] + y.
z_[k2_min]);
445 y.
t_[k1_min] = 0.5 * (y.
t_[k1_min] + y.
t_[k2_min]);
457 const unsigned int nv = y.
getSize();
464 unsigned int k0 = nv;
469 std::vector<double> inverse_zsums(nt), arg_cache(nt), eik_cache(nt);
470 double * pinverse_zsums;
473 pinverse_zsums = inverse_zsums.data();
474 parg_cache = arg_cache.data();
475 peik_cache = eik_cache.data();
476 for(
unsigned i = 0;
i <
nt; ++
i) {
480 for (
unsigned int k = 0;
k < nv; ++
k) {
485 const double pmax = y.
pk_[
k] / (y.
pk_[
k] + rho0 * local_exp(-beta * dzCutOff_* dzCutOff_));
486 const double pcut = uniquetrkweight_ * pmax;
487 for(
unsigned i = 0;
i <
nt; ++
i) {
488 const auto track_z = tks.
z_[
i];
490 const auto botrack_dz2 = -beta*tks.
dz2_[
i];
491 const auto botrack_dt2 = -beta*tks.
dt2_[
i];
493 const auto mult_resz = track_z - y.
z_[
k];
495 parg_cache[
i] = botrack_dz2 * ( mult_resz * mult_resz ) + botrack_dt2 * ( mult_rest * mult_rest );
497 local_exp_list(parg_cache, peik_cache, nt);
498 for (
unsigned int i = 0;
i <
nt; ++
i) {
499 const double p = y.
pk_[
k] * peik_cache[
i] * pinverse_zsums[
i];
501 nUnique += ( ( p > pcut ) & ( tks.
pi_[
i] > 0 ) );
504 if ((nUnique < 2) && (sump < sumpmin)) {
514 std::cout <<
"eliminating prototype at " << std::setw(10) << std::setprecision(4) << y.
z_[
k0] <<
"," << y.
t_[
k0]
515 <<
" with sump=" << sumpmin
516 <<
" rho*nt =" << y.
pk_[
k0]*nt
536 const unsigned int nv = y.
getSize();
538 for (
unsigned int k = 0;
k < nv;
k++) {
545 for (
unsigned int i = 0;
i <
nt;
i++) {
548 sumwz += w_z * tks.
z_[
i];
549 sumwt += w_t * tks.
t_[
i];
553 y.
z_[
k] = sumwz / sumw_z;
554 y.
t_[
k] = sumwt / sumw_t;
557 double szz = 0, stt = 0, szt = 0;
558 double nuz = 0, nut = 0;
559 for (
unsigned int i = 0;
i <
nt;
i++) {
562 double w = tks.
pi_[
i];
566 nuz += w * tks.
dz2_[
i];
567 nut += w * tks.
dt2_[
i];
571 double Tc = Tz + Tt +
sqrt(
pow(Tz - Tt, 2) + 4 * szt * szt / nuz / nut);
573 if (Tc > T0) T0 = Tc;
578 std::cout <<
"DAClustrizerInZT_vect.beta0: Tc = " << T0 << std::endl;
580 std::cout <<
"DAClustrizerInZT_vect.beta0: nstep = " << coolingsteps << std::endl;
585 if (T0 > 1. / betamax) {
589 return betamax * coolingFactor_;
597 return Tz + Tt +
sqrt(
pow(Tz - Tt, 2) + 4 * mx);
609 const double twoBeta = 2.0*
beta;
613 std::vector<std::pair<double, unsigned int> > critical;
614 for(
unsigned int k=0;
k<nv;
k++){
615 double Tc= get_Tc(y,
k);
616 if (beta*Tc > threshold){
617 critical.push_back( make_pair(Tc,
k));
620 if (critical.empty())
return false;
623 std::stable_sort(critical.begin(), critical.end(), std::greater<std::pair<double, unsigned int> >() );
628 for(
unsigned int ic=0; ic<critical.size(); ic++){
629 unsigned int k=critical[ic].second;
635 double Mzt = - twoBeta*y.
szt_[
k];
636 const double twoMzt = 2.0*Mzt;
637 double D =
sqrt(
pow(Mtt-Mzz, 2) + twoMzt*twoMzt);
638 double q1 = atan2(-Mtt+Mzz+D, -twoMzt);
639 double l1 = 0.5*(-Mzz-Mtt+
D);
640 double l2 = 0.5*(-Mzz-Mtt-
D);
642 edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, bad eigenvalues! idx=" << k <<
" z= " << y.
z_[
k] <<
" Mzz=" << Mzz <<
" Mtt=" << Mtt <<
" Mzt=" << Mzt << endl;
646 double cq =
cos(qsplit);
647 double sq =
sin(qsplit);
648 if(cq < 0){ cq=-cq; sq=-sq; }
651 double p1=0, z1=0, t1=0, wz1=0, wt1=0;
652 double p2=0, z2=0, t2=0, wz2=0, wt2=0;
653 for(
unsigned int i=0;
i<
nt; ++
i){
655 double lr = (tks.
z_[
i]-y.
z_[
k]) * cq + (tks.
t[
i] - y.
t_[k]) * sq;
657 double tl = lr < 0 ? 1.: 0.;
663 double t = local_exp(-arg);
668 double p = y.
pk_[
k] * tks.
pi_[
i] * local_exp(-beta * Eik(tks.
z_[i], y.
z_[k], tks.
dz2_[i],
670 double wz = p*tks.
dz2_[
i];
671 double wt = p*tks.
dt2_[
i];
672 p1 += p*tl; z1 += wz*tl*tks.
z_[
i]; t1 += wt*tl*tks.
t_[
i]; wz1 += wz*tl; wt1 += wt*tl;
673 p2 += p*tr; z2 += wz*tr*tks.
z_[
i]; t2 += wt*tr*tks.
t_[
i]; wz2 += wz*tr; wt2 += wt*tr;
677 if(wz1 > 0){z1 /= wz1;}
else {z1 = y.
z_[
k] - epsilonz * cq;
edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, wz1 = " << scientific << wz1 << endl;}
678 if(wt1 > 0){t1 /= wt1;}
else {t1 = y.
t_[
k] - epsilont * sq;
edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, w11 = " << scientific << wt1 << endl;}
679 if(wz2 > 0){z2 /= wz2;}
else {z2 = y.
z_[
k] + epsilonz * cq;
edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, wz2 = " << scientific << wz2 << endl;}
680 if(wt2 > 0){t2 /= wt2;}
else {t2 = y.
t_[
k] + epsilont * sq;
edm::LogWarning(
"DAClusterizerInZT_vect") <<
"warning, wt2 = " << scientific << wt2 << endl;}
682 unsigned int k_min1 =
k, k_min2 =
k;
684 while( ((find_nearest(z1, t1, y, k_min1, epsilonz, epsilont) && (k_min1 != k))
685 || (find_nearest(z2,t2, y, k_min2, epsilonz, epsilont) && (k_min2 !=k))) && (
std::abs(z2-z1)>spliteps ||
std::abs(t2-t1)>spliteps) ){
686 z1 = 0.5*( z1 + y.
z_[
k]); t1 = 0.5*( t1 + y.
t_[
k]);
687 z2 = 0.5*( z2 + y.
z_[
k]); t2 = 0.5*( t2 + y.
t_[
k]);
692 if (std::fabs(y.
z_[k] - zdumpcenter_) < zdumpwidth_){
693 std::cout <<
" T= " << std::setw(10) << std::setprecision(1) << 1./beta
694 <<
" Tc= " << critical[ic].first
695 <<
" direction =" << std::setprecision(4) << qsplit
696 <<
" splitting (" << std::setw(8) <<
std::fixed << std::setprecision(4) << y.
z_[
k] <<
"," << y.
t_[
k] <<
")" 697 <<
" --> (" << z1 <<
',' << t1<<
"),(" << z2 <<
',' << t2
698 <<
") [" << p1 <<
"," << p2 <<
"]" ;
699 if (std::fabs(z2-z1) > epsilonz || std::fabs(t2-t1) > epsilont){
709 edm::LogInfo(
"DAClusterizerInZT") <<
"warning swapping z in split qsplit=" << qsplit <<
" cq=" << cq <<
" sq=" << sq << endl;
713 z1 = z2; t1=t2; p1=
p2;
714 z2 = ztemp; t2=ttemp; p2=ptemp;
721 if( std::fabs(z2-z1) > epsilonz || std::fabs(t2-t1) > epsilont){
723 double pk1 = p1*y.
pk_[
k]/(p1+
p2);
724 double pk2 = p2*y.
pk_[
k]/(p1+
p2);
731 for(
unsigned int jc=ic; jc < critical.size(); jc++){
732 if (critical[jc].
second > k ) {critical[jc].second--;}
733 if (critical[jc].
second >= k2) {critical[jc].second++;}
742 for(
unsigned int jc=ic; jc < critical.size(); jc++){
743 if (critical[jc].
second >= k1) {critical[jc].second++;}
748 std::cout <<
"warning ! split rejected, too small." << endl;
760 const unsigned int nv = y.
getSize();
770 std::cout <<
"Before Split "<< std::endl;
775 for (
unsigned int k = 0;
k < nv;
k++) {
777 ( ( (
k == 0) || ( y.
z_[
k - 1] < (y.
z_[
k] - zsep)) ) &&
778 ( ((
k + 1) == nv) || ( y.
z_[
k + 1] > (y.
z_[
k] + zsep)) ) ) )
781 double new_z = y.
z[
k] - epsilonz;
782 double new_t = y.
t[
k] - epsilont;
783 y.
z[
k] = y.
z[
k] + epsilonz;
784 y.
t[
k] = y.
t[
k] + epsilont;
786 double new_pk = 0.5 * y.
pk[
k];
789 y1.
addItem(new_z, new_t, new_pk);
792 else if ( (y1.
getSize() == 0 ) ||
802 y.
z_[
k] = y.
z_[
k] + epsilonz;
803 y.
t_[
k] = y.
t_[
k] + epsilont;
813 std::cout <<
"After split " << std::endl;
821 vector<TransientVertex>
830 if (tks.
getSize() == 0)
return clusters;
841 double beta = beta0(betamax_, tks, y);
843 if ( verbose_)
std::cout <<
"Beta0 is " << beta << std::endl;
847 while ((
update(beta, tks, y,
false, rho0) > 1.
e-6) &&
848 (niter++ < maxIterations_)) {}
852 double betafreeze = betamax_ *
sqrt(coolingFactor_);
854 while (beta < betafreeze) {
856 update(beta, tks,y,
false, rho0);
858 while(
merge(y, beta)){
update(beta, tks, y,
false, rho0);}
860 beta=beta/coolingFactor_;
862 beta=beta/coolingFactor_;
868 while ((
update(beta, tks, y,
false, rho0) > 1.
e-6) &&
869 (niter++ < maxIterations_)) {}
872 if(verbose_){
dump( beta, y, tks, 0); }
880 if(verbose_){
std::cout <<
"last spliting at " << 1./beta << std::endl; }
882 update(beta, tks,y,
false, rho0);
884 while(
merge(y,beta)){
update(beta, tks,y,
false, rho0);}
887 while(
split(beta, tks, y, threshold) && (ntry++<10) ){
889 while((
update(beta, tks,y,
false, rho0)>1.
e-6) && (niter++ < maxIterations_)){}
892 if(verbose_)
dump(beta, y, tks, 2);
895 while(
merge(y,beta)){
update(beta, tks,y,
false, rho0);}
898 std::cout <<
"after final splitting, try " << ntry << std::endl;
899 dump(beta, y, tks, 2);
907 while(
merge(y,beta)){
update(beta, tks,y,
false, rho0);}
912 update(beta, tks,y,
false, rho0);
913 std::cout <<
"dump after 1st merging " << endl;
914 dump(beta, y, tks, 2);
922 for(
unsigned int a=0;
a<10;
a++){
update(beta, tks, y,
true,
a*rho0/10);}
926 while ((
update(beta, tks, y,
true, rho0) > 1.
e-8) && (niter++ < maxIterations_)) {};
929 std::cout <<
"dump after noise-suppression, rho0=" << rho0 <<
" niter = " << niter << endl;
930 dump(beta, y, tks, 2);
936 while (
merge(y, beta)) {
update(beta, tks, y,
true, rho0); }
939 std::cout <<
"dump after merging " << endl;
940 dump(beta, y, tks, 2);
945 while( beta < betapurge_ ){
946 beta =
min( beta/coolingFactor_, betapurge_);
948 while ((
update(beta, tks, y,
false, rho0) > 1.
e-8) && (niter++ < maxIterations_)) {}
953 while (purge(y, tks, rho0, beta)) {
955 while ((
update(beta, tks, y,
true, rho0) > 1.
e-6 ) && (niter++ < maxIterations_)) {
962 update(beta, tks,y,
true, rho0);
963 std::cout <<
" after purging " << std:: endl;
964 dump(beta, y, tks, 2);
969 while( beta < betastop_ ){
970 beta =
min( beta/coolingFactor_, betastop_);
972 while ((
update(beta, tks, y,
true, rho0) > 1.
e-8) && (niter++ < maxIterations_)) {}
978 std::cout <<
"Final result, rho0=" << std::scientific << rho0 << endl;
979 dump(beta, y, tks, 2);
986 double betadummy = 1;
987 while(
merge(y, betadummy) );
990 GlobalError dummyError(0.01, 0, 0.01, 0., 0., 0.01);
993 const unsigned int nv = y.
getSize();
994 for (
unsigned int k = 0;
k < nv;
k++)
997 for (
unsigned int i = 0;
i <
nt;
i++)
998 tks.
Z_sum_[
i] = rho0 * local_exp(-beta * dzCutOff_ * dzCutOff_);
1001 for (
unsigned int k = 0;
k < nv;
k++) {
1002 for (
unsigned int i = 0;
i <
nt;
i++)
1007 for (
unsigned int k = 0;
k < nv;
k++) {
1010 vector<reco::TransientTrack> vertexTracks;
1011 for (
unsigned int i = 0;
i <
nt;
i++) {
1014 double p = y.
pk_[
k] * local_exp(-beta * Eik(tks.
z_[
i], y.
z_[
k], tks.
dz2_[
i],
1016 if ((tks.
pi_[
i] > 0) && (p > mintrkweight_)) {
1017 vertexTracks.push_back(*(tks.
tt[
i]));
1023 clusters.push_back(v);
1031 const vector<reco::TransientTrack> &
tracks)
const {
1035 std::cout <<
"###################################################" << endl;
1036 std::cout <<
"# vectorized DAClusterizerInZT_vect::clusterize nt=" << tracks.size() << endl;
1037 std::cout <<
"###################################################" << endl;
1041 vector<vector<reco::TransientTrack> >
clusters;
1042 vector<TransientVertex> &&
pv =
vertices(tracks);
1046 std::cout <<
"# DAClusterizerInZT::clusterize pv.size=" << pv.size() << endl;
1055 for (
auto k = pv.begin();
k != pv.end();
k++) {
1056 vector<reco::TransientTrack> aCluster =
k->originalTracks();
1057 if (aCluster.size()>1){
1058 clusters.push_back(aCluster);
1101 const unsigned int nv = y.
getSize();
1104 std::vector< unsigned int > iz;
1105 for(
unsigned int j=0; j<
nt; j++){ iz.push_back(j); }
1106 std::sort(iz.begin(), iz.end(), [tks](
unsigned int a,
unsigned int b){
return tks.
z_[
a]<tks.
z_[
b];} );
1108 std::cout <<
"-----DAClusterizerInZT::dump ----" << nv <<
" clusters " << std::endl;
1111 for (
unsigned int ivertex = 0; ivertex < nv; ++ ivertex) {
1112 if (std::fabs(y.
z_[ivertex]-zdumpcenter_) < zdumpwidth_){
1120 for (
unsigned int ivertex = 0; ivertex < nv; ++ ivertex) {
1121 if (std::fabs(y.
z_[ivertex]-zdumpcenter_) < zdumpwidth_){
1129 for (
unsigned int ivertex = 0; ivertex < nv; ++ ivertex) {
1130 if (std::fabs(y.
z_[ivertex]-zdumpcenter_) < zdumpwidth_){
1136 std::cout <<
"T=" << setw(15) << 1. / beta
1137 <<
" Tmin =" << setw(10) << 1./betamax_
1139 for (
unsigned int ivertex = 0; ivertex < nv; ++ ivertex) {
1140 if (std::fabs(y.
z_[ivertex]-zdumpcenter_) < zdumpwidth_){
1141 double Tc = get_Tc(y, ivertex);
1149 for (
unsigned int ivertex = 0; ivertex < nv; ++ ivertex) {
1150 sumpk += y.
pk_[ivertex];
1151 if (std::fabs(y.
z_[ivertex] - zdumpcenter_) > zdumpwidth_)
continue;
1157 for (
unsigned int ivertex = 0; ivertex < nv; ++ ivertex) {
1158 sumpk += y.
pk_[ivertex];
1159 if (std::fabs(y.
z_[ivertex] - zdumpcenter_) > zdumpwidth_)
continue;
1164 if (verbosity > 0) {
1165 double E = 0,
F = 0;
1168 <<
"---- z +/- dz t +/- dt ip +/-dip pt phi eta weights ----" 1171 for (
unsigned int i0 = 0; i0 <
nt; i0++) {
1172 unsigned int i = iz[i0];
1176 double tz = tks.
z_[
i];
1178 if( std::fabs(tz - zdumpcenter_) > zdumpwidth_)
continue;
1179 std::cout << setw(4) << i <<
")" << setw(8) <<
fixed << setprecision(4)
1180 << tz <<
" +/-" << setw(6) <<
sqrt(1./tks.
dz2_[i]);
1182 if( tks.
dt2_[i] >0){
1184 << tks.
t_[
i] <<
" +/-" << setw(6) <<
sqrt(1./tks.
dt2_[i]);
1200 << tks.
tt[
i]->track().hitPattern().pixelBarrelLayersWithMeasurement();
1202 << tks.
tt[
i]->track().hitPattern().pixelEndcapLayersWithMeasurement();
1204 << tks.
tt[
i]->track().hitPattern().trackerLayersWithMeasurement()
1205 - tks.
tt[
i]->track().hitPattern().pixelLayersWithMeasurement()
1212 tks.
tt[
i]->stateAtBeamLine().transverseImpactParameter();
1214 std::cout <<
" " << setw(6) << setprecision(2)
1215 << tks.
tt[
i]->track().pt() * tks.
tt[
i]->track().charge();
1216 std::cout <<
" " << setw(5) << setprecision(2)
1217 << tks.
tt[
i]->track().phi() <<
" " << setw(5)
1218 << setprecision(2) << tks.
tt[
i]->track().eta();
1221 for (
unsigned int ivertex = 0; ivertex < nv; ++ ivertex) {
1222 if (std::fabs(y.
z_[ivertex]-zdumpcenter_) > zdumpwidth_)
continue;
1224 if ((tks.
pi_[i] > 0) && (tks.
Z_sum_[i] > 0)) {
1226 double p = y.
pk_[ivertex] *
exp(-beta * Eik(tks.
z_[i], y.
z_[ivertex], tks.
dz2_[i],
1229 std::cout << setw(8) << setprecision(3) <<
p;
1233 E += p * Eik(tks.
z_[i], y.
z_[ivertex], tks.
dz2_[i],
1234 tks.
t_[i], y.
t_[ivertex], tks.
dt2_[i] );
1242 std::cout << endl <<
"T=" << 1 / beta <<
" E=" << E <<
" n=" << y.
getSize()
1243 <<
" 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)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::vector< std::vector< reco::TransientTrack > > clusterize(const std::vector< reco::TransientTrack > &tracks) const override
constexpr bool isNotFinite(T x)
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
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)