27 for (
int i = 0;
i < 10;
i++) {
28 for (
int j = 0;
j < 10;
j++) {
29 weight_matrix[
i][
j] = 8.;
52 int ioktk[
ntrack], nk, nborn_min = 0, nborn_max = 0;
54 double par[4], tsig[1];
63 double albet, dtsbeta, variab,
alpha,
beta;
66 int numb_a, numb_b, numb_x;
71 matrice DA, DAT, BK,
DB, DBT,
C, CT,
D, DM1, CDM1, CDM1CT,
Z, CDM1Z, YK,
Y,
B,
X, XINV, RES2;
75 amplu =
new double[
nsamp];
92 printf(
" ------> __> valeurs de a1 %f a2 %f a3 %f\n", a1, a2, a3);
94 for (i = 0; i <
ntrack; i++) {
95 for (j = 0; j < 2; j++) {
96 bi[
i][
j] = (double)0.;
97 dbi[
i][
j] = (double)0.;
98 zi[
i][
j] = (double)0.;
99 cti[
i][
j] = (double)0.;
100 dm1i[
i][
j] = (double)0.;
131 A_CROISS =
cree_mat(numb_a, numb_x);
138 for (iter = 0; iter < 6; iter++) {
146 printf(
" Debut de l'iteration numero %d \n", iter);
157 printf(
" resultats injectes a iterations %d \n", iter);
158 printf(
" parametre a1 = %f \n", a1);
159 printf(
" parametre a2 = %f \n", a2);
160 printf(
" chi2 du fit chi2s = %f \n", chi2s);
162 printf(
" value de nevtmax _______________ %d \n", nevtmax);
169 for (nevt = 0; nevt < nevtmax; nevt++) {
187 for (k = 0; k < 10; k++) {
188 amplu[
k] = adcval[
nevt][
k];
189 if (amplu[k] > ampmax[nk]) {
190 ampmax[nk] = amplu[
k];
202 parab(amplu, 2, 9, par3degre);
211 num_fit_min[
nevt] = (double)imax[nk] - (
double)nsmin;
212 num_fit_max[
nevt] = (double)imax[nk] + (
double)nsmax;
214 bi[nk][0] = par3degre[0];
215 bi[nk][1] = par3degre[1];
218 printf(
"---------> depart ampmax[%d]=%f maximum %f tim %f \n", nk, ampmax[nk], bi[nk][0], bi[nk][1]);
227 bi[nk][0] += dbi[nk][0];
228 bi[nk][1] += dbi[nk][1];
231 printf(
"iter %d valeur de max %f et norma %f poly 3 \n", iter, bi[nk][1], bi[nk][0]);
244 ns = nborn_max - nborn_min + 1;
246 for (k = 0; k < 10; k++) {
255 printf(
" CHECK sample %f ampli %f \n", t, amp);
262 unsurs1 = 1. / noise_val;
269 nborn_min = (int)num_fit_min[nevt];
270 nborn_max = (int)num_fit_max[nevt];
271 if (k < nborn_min || k > nborn_max)
280 fun = pulseShapepj(tsig, par);
283 printf(
" valeur ampli %f et function %f min %d max %d \n", amp, fun, nsmin, nsmax);
284 printf(
"min %f max %f \n", num_fit_min[nevt], num_fit_max[nevt]);
296 albet = alpha *
beta;
298 variab = (double)1. + dt / albet;
300 db1[
k] = unsurs1 * fun /
b1;
302 db2[
k] = unsurs1 * fact2 * dtsbeta / (albet * variab);
303 da1[
k] = unsurs1 * fact2 * (
log(variab) - dtsbeta / (alpha * variab));
304 da2[
k] = unsurs1 * fact2 * dtsbeta * dtsbeta / (albet * variab);
307 delta[
k] = (amp - fun) * unsurs1;
309 printf(
" ------->iter %d valeur de k %d amp %f fun %f delta %f \n", iter, k, amp, fun, delta[k]);
310 printf(
" -----> valeur de k %d delta %f da1 %f da2 %f \n", k, delta[k], da1[k], da2[k]);
313 chi2 = chi2 + delta[
k] * delta[
k];
316 printf(
" CHECK chi2 %f deltachi2 %f sample %d iter %d \n", chi2, delta[k] * delta[k], k, iter);
330 for (
int k1 = nborn_min; k1 < nborn_max + 1; k1++) {
334 DA.
coeff[0][0] = da1[k1] * wk1wk2;
335 DA.
coeff[1][0] = da2[k1] * wk1wk2;
338 DB.
coeff[0][0] = db1[k1] * wk1wk2;
339 DB.
coeff[1][0] = db2[k1] * wk1wk2;
345 produit_mat_int(DA, DAT, BK);
349 produit_mat_int(DA, DBT, C);
353 produit_mat_int(DB, DBT, D);
359 somme_mat_int_scale(DA, YK, delta2);
360 somme_mat_int_scale(DB, Z, delta2);
372 printf(
" event rejected because npamp_used = %d \n", ioktk[nk]);
375 chi2s = chi2 / (2. + (double)ns + 2.);
379 if (nevt == 198 || nevt == 199) {
380 std::cout <<
"adc123 pour l'evt " << nevt <<
" = " << adcval[
nevt][nborn_min] <<
" = "
381 << adcval[
nevt][imax[
nevt]] <<
" = " << adcval[
nevt][nborn_max] << std::endl;
382 std::cout <<
"chi2s pour l'evt " << nevt <<
" = " << chi2s <<
" " << chi2 <<
" " << ns <<
" " << iter
384 std::cout <<
"chi2tot " << nevt <<
" = " << chi2tot <<
" " << iter << std::endl;
390 transpose_mat(C, CT);
401 cti[nk][0] = CT.
coeff[0][0];
402 cti[nk][1] = CT.
coeff[0][1];
403 cti[nk][2] = CT.
coeff[1][0];
404 cti[nk][3] = CT.
coeff[1][1];
406 dm1i[nk][0] = DM1.
coeff[0][0];
407 dm1i[nk][1] = DM1.
coeff[0][1];
408 dm1i[nk][2] = DM1.
coeff[1][0];
409 dm1i[nk][3] = DM1.
coeff[1][1];
411 zi[nk][0] = Z.
coeff[0][0];
412 zi[nk][1] = Z.
coeff[1][0];
416 for (k = 0; k < numb_a; k++) {
419 somme_mat_int(BK, B);
423 produit_mat(C, DM1, CDM1);
427 produit_mat_int(CDM1, CT, CDM1CT);
431 produit_mat_int(CDM1, Z, CDM1Z);
439 diff_mat(B, CDM1CT, X);
440 inverse_mat(X, XINV);
441 diff_mat(Y, CDM1Z, RES2);
445 produit_mat(XINV, RES2, A_CROISS);
450 for (k = 0; k < nk + 1; k++) {
452 ZMCT.
coeff[0][0] = zi[
k][0] - (cti[
k][0] * A_CROISS.
coeff[0][0] + cti[
k][1] * A_CROISS.
coeff[1][0]);
453 ZMCT.
coeff[1][0] = zi[
k][1] - (cti[
k][2] * A_CROISS.
coeff[0][0] + cti[
k][3] * A_CROISS.
coeff[1][0]);
456 dbi[
k][0] = dm1i[
k][0] * ZMCT.
coeff[0][0] + dm1i[
k][1] * ZMCT.
coeff[1][0];
457 dbi[
k][1] = dm1i[
k][2] * ZMCT.
coeff[0][0] + dm1i[
k][3] * ZMCT.
coeff[1][0];
460 printf(
" variations de b1= %f et b2= %f \n", dbi[k][0], dbi[k][1]);
463 db_i[
k][0] = bi[
k][0] + dbi[
k][0];
464 db_i[
k][1] = bi[
k][1] + dbi[
k][1];
470 a1 += A_CROISS.
coeff[0][0];
471 a2 += A_CROISS.
coeff[1][0];
474 printf(
" CHECK croiss coef0: %f croiss coef1: %f iter %d \n",
475 fabs(A_CROISS.
coeff[0][0]),
476 fabs(A_CROISS.
coeff[1][0]),
479 if (fabs(A_CROISS.
coeff[0][0]) < 0.001 && fabs(A_CROISS.
coeff[1][0]) < 0.001)
491 printf(
" resultats trouves au bout de %d iterations \n", iter);
492 printf(
" parametre a1 = %f \n", a1);
493 printf(
" parametre a2 = %f \n", a2);
497 std::cout <<
" Final chi2 / NDOF : " << chi2tot / nevtmax << std::endl;
498 std::cout <<
" Final (alpha,beta) : (" << a1 <<
"," << a2 <<
")" << std::endl;
501 return chi2tot / nevtmax;
514 nevtmax = nevtmaximum;
521 printf(
"warning: NbOfsamples exceed maximum\n");
527 printf(
" Erreur : produit de matrices de tailles incompatibles \n ");
547 printf(
" Erreur : produit de matrices de tailles incompatibles \n ");
566 printf(
" Erreur : difference de matrices de tailles incompatibles \n ");
587 printf(
" copie nk %d i %d j %d k %d A %e M %e \n ", nk, i, j, k, A.
coeff[i][j], M.
coeff[nk][k]);
598 printf(
" Erreur : somme de matrices de tailles incompatibles \n ");
683 if (M.
coeff ==
nullptr) {
684 printf(
" erreur : affichage d'une matrice vide \n");
690 printf(
" MATRICE i= %d j= %d ---> %e \n", i, j, M.
coeff[i][j]);
711 if (M.
coeff ==
nullptr) {
712 printf(
" erreur : affichage d'une matrice vide \n");
716 printf(
" MATRICE nk= %d j= %d ---> %e \n", nk, j, M.
coeff[nk][j]);
717 printf(
" apres passage d'impression \n");
750 for (i = 0; i < 3; i++) {
751 for (j = 0; j < 3; j++)
755 printf(
" Attention , on ne peut inverser la MATRICE %d \n", A.
nb_lignes);
761 Double_t
TFParams::polfit(Int_t ns, Int_t imax, Double_t par3d[dimout], Double_t errpj[dimmat][dimmat],
double *adcpj) {
762 double val, val2, val3, adfmx[dimmat], parfp3[dimout];
763 double ius[dimmat] = {0.}, maskp3[dimmat];
764 double deglib, fit3, tm,
h, xki2;
765 int i, nus, ilow, isup;
772 for (i = 0; i < ns; i++) {
773 deglib = deglib + 1.;
775 if ((adcpj[i] < val3) && (i < imax)) {
778 if (adcpj[i] > val2) {
788 for (i = ilow; i <= isup; i++) {
789 adfmx[nus] = adcpj[
i];
798 xki2 = f3deg(nus, parfp3, maskp3, adfmx, errpj);
801 tm = tm + (double)ilow;
808 int nmxu,
double parom[dimout],
double mask[dimmat],
double adcpj[dimmat],
double errpj[dimmat][dimmat]) {
818 double xki2, dif, difmx, deglib;
819 double t[dimmat],
f[dimmat][4];
820 double cov[dimmat][dimmat], bv[4], invcov[dimmat][dimmat],
s ;
822 deglib = (double)nmxu - 4.;
823 for (i = 0; i < nmxu; i++) {
827 f[
i][2] = t[
i] * t[
i];
828 f[
i][3] = f[
i][2] * t[
i];
831 for (k = 0; k < 4; k++) {
832 for (l = 0; l < 4; l++) {
834 for (i = 0; i < nmxu; i++) {
835 s = s + f[
i][
k] * f[
i][
l] * errpj[
i][
i] * mask[
i];
840 for (i = 0; i < nmxu; i++) {
841 s = s + f[
i][
k] * adcpj[
i] * errpj[
i][
i] * mask[
i];
846 inverpj(4, cov, invcov);
847 for (k = 0; k < 4; k++) {
849 for (l = 0; l < 4; l++) {
850 s = s + bv[
l] * invcov[
l][
k];
855 if (parom[3] == 0.) {
864 for (i = 0; i < nmxu; i++) {
866 h = parom[0] + parom[1] * t[
i] + parom[2] * t2 + parom[3] * t2 * t[
i];
867 dif = (adcpj[
i] -
h) * mask[i];
874 xki2 = xki2 / deglib;
876 delta = parom[2] * parom[2] - 3. * parom[3] * parom[1];
879 tm = -(delta + parom[2]) / (3. * parom[3]);
880 tmp = (delta - parom[2]) / (3. * parom[3]);
888 parom[5] = parom[0] + parom[1] * tm + parom[2] * tm * tm + parom[3] * tm * tm * tm;
904 double al[dimmat][dimmat],
be[dimmat][dimmat];
906 for (i = 0; i <
n; i++) {
907 for (j = 0; j <
n; j++) {
913 al[0][0] =
sqrt(
g[0][0]);
914 for (i = 1; i <
n; i++) {
915 al[
i][0] =
g[0][
i] / al[0][0];
916 for (j = 1; j <=
i; j++) {
918 for (k = 0; k <= j - 1; k++) {
919 s = s + al[
i][
k] * al[
j][
k];
923 al[
i][
j] = r / al[
j][
j];
929 be[0][0] = 1. / al[0][0];
930 for (i = 1; i <
n; i++) {
931 be[
i][
i] = 1. / al[
i][
i];
932 for (j = 0; j <
i; j++) {
935 for (k = jj + 1; k <=
i; k++) {
936 s = s + be[
i][
k] * al[
k][
jj];
942 for (i = 0; i <
n; i++) {
943 for (j = 0; j <
n; j++) {
945 for (k = 0; k <
n; k++) {
946 s = s + be[
k][
i] * be[
k][
j];
963 b[0][0] = a[1][1] * a[2][2] - a[2][1] * a[1][2];
964 b[1][1] = a[0][0] * a[2][2] - a[2][0] * a[0][2];
965 b[2][2] = a[0][0] * a[1][1] - a[0][1] * a[1][0];
966 printf(
"a[x][x] %e %e %e %e %e %e %e \n",
974 b[0][1] = a[2][1] * a[0][2] - a[0][1] * a[2][2];
975 b[0][2] = a[0][1] * a[1][2] - a[1][1] * a[0][2];
976 b[1][0] = a[1][2] * a[2][0] - a[1][0] * a[2][2];
977 b[1][2] = a[1][0] * a[0][2] - a[0][0] * a[1][2];
978 b[2][0] = a[1][0] * a[2][1] - a[1][1] * a[2][0];
979 b[2][1] = a[0][1] * a[2][0] - a[0][0] * a[2][1];
980 deter = a[0][0] * b[0][0] + a[1][0] * b[0][1] + a[2][0] * b[0][2];
981 printf(
" deter = %e \n", deter);
982 for (i = 0; i < 3; i++) {
983 for (j = 0; j < 3; j++) {
984 printf(
" avant division a[3][3] %d %d %e \n", i, j, a[i][j]);
985 printf(
" avant division b[3][3] %d %d %e %e \n", i, j, b[i][j], deter);
986 b[
i][
j] = b[
i][
j] / deter;
987 printf(
" valeur de b[3][3] apres division %d %d %e %e \n", i, j, b[i][j], deter);
996 Double_t
dt, dtsbeta, albet, variab, puiss;
1010 albet = alpha *
beta;
1012 return ((Double_t)0.);
1015 dtsbeta = dt /
beta;
1016 variab = 1. + dt / albet;
1017 puiss =
pow(variab, alpha);
1018 fitfun = h * puiss *
exp(-dtsbeta) + ped;
1038 alphadt = alpha *
dt;
1039 exponent = -(alphadt + (
exp(-alphadt) - 1.)) / beta;
1040 fitfun = b1 *
exp(exponent);
1053 expo1 =
exp(-beta * dt);
1055 exponent = -(alpha * dt2 + (expo1 - 1.));
1056 fitfun = b1 *
exp(exponent);
1063 Double_t
dt, dtsbeta, albet, variab, puiss;
1075 albet = alpha *
beta;
1077 return ((Double_t)0.);
1080 dtsbeta = dt /
beta;
1081 variab = 1. + dt / albet;
1082 puiss =
pow(variab, alpha);
1083 fitfun = h * puiss *
exp(-dtsbeta) + ped;
1097 double denom,
dt, amp1, amp2, amp3;
1103 for (k = nmin; k < nmax; k++) {
1104 if (ampl[k] > ampmax) {
1109 amp1 = ampl[imax - 1];
1111 amp3 = ampl[imax + 1];
1112 denom = 2. * amp2 - amp1 - amp3;
1115 dt = 0.5 * (amp3 - amp1) / denom;
1124 parout[0] = amp2 + (amp3 - amp1) * dt * 0.25;
1125 parout[1] = (double)imax + dt;
1126 parout[2] = (double)imax;
1131 Double_t fitval0, fitval;
1134 Double_t
b1,
b2, alpha2,
t;
1146 puiss =
pow(fact, alpha);
1147 fitval0 = puiss *
exp(-alpha * dt / b2);
1152 alpha2dt = dt * alpha2;
1153 exponent = -(alpha2dt + (
exp(-alpha2dt) - 1.)) / beta;
1154 fitval = b1 * fitval0 *
exp(exponent);
1163 double level = 0.30;
1165 double amplitude = 1.00;
1167 double amp_max = amplitude;
1170 double t_min = offset - 4.50;
1171 double t_max = offset + 12.50;
1173 int t_step_max = 3000;
1174 double delta_t = (double)((t_max - t_min) / t_step_max);
1177 int t_amp_half_flag = 0;
1178 double t_amp_half_min = 999.;
1179 double t_amp_half_max = -999.;
1181 for (
int t_step = 0; t_step < t_step_max; t_step++) {
1182 double t_val = t_min + (double)t_step * delta_t;
1183 double albet = alpha_here * beta_here;
1188 if ((t_val - offset) > -albet) {
1189 amp = amplitude * TMath::Power((1 + (dt / (alpha_here * beta_here))), alpha_here) *
1190 TMath::Exp(-1.0 * (dt / beta_here));
1196 if (amp > (amp_max * level) && t_amp_half_flag == 0) {
1197 t_amp_half_flag = 1;
1198 t_amp_half_min = t_val;
1201 if (amp < (amp_max * level) && t_amp_half_flag == 1) {
1202 t_amp_half_flag = 2;
1203 t_amp_half_max = t_val;
1208 double width = (t_amp_half_max - t_amp_half_min);
double pulseShapepj(Double_t *, Double_t *)
static std::vector< std::string > checklist log
Double_t polfit(Int_t ns, Int_t imax, Double_t par3d[dimout], Double_t errpj[dimmat][dimmat], double *)
void print_mat_nk(matrice, int)
double computePulseWidth(int, double, double)
void somme_mat_int_scale(matrice, matrice, double)
void produit_mat(matrice, matrice, matrice)
Exp< T >::type exp(const T &t)
double inverpj(int, double g[dimmat][dimmat], double ginv[dimmat][dimmat])
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
void somme_mat_int(matrice, matrice)
void transpose_mat(matrice, matrice)
void set_const(int, int, int, double, double, int)
double parab(double *, Int_t, Int_t, double *)
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
matrice cree_mat_prod(matrice, matrice)
Quality *__restrict__ uint16_t nmin
void copie_colonne_mat(matrice, matrice, int)
matrice cree_mat(int, int)
double pulseShapepj2(Double_t *, Double_t *)
void inverse_mat(matrice, matrice)
double f3deg(int, double parom[dimout], double mask[dimmat], double adcpj[dimmat], double errpj[dimmat][dimmat])
DecomposeProduct< arg, typename Div::arg > D
void zero_mat_nk(matrice, int)
void fill_mat(matrice, matrice)
double lastShape(Double_t *, Double_t *)
void produit_mat_int(matrice, matrice, matrice)
TFParams(int size=SDIM2, int size_sh=PLSHDIM)
double mixShape(Double_t *, Double_t *)
void diff_mat(matrice, matrice, matrice)
static constexpr float b2
double lastShape2(Double_t *, Double_t *)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
double inv3x3(double a[3][3], double b[3][3])
double fitpj(double **, double *, double **, double noise_val, int debug)
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
static constexpr float b1