27 for (
int i = 0;
i < 10;
i++) {
28 for (
int j = 0;
j < 10;
j++) {
29 weight_matrix[
i][
j] = 8.;
46 double a1,
a2, a3, b1, b2;
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;
336 DAT.
coeff[0][0] = da1[k2];
337 DAT.
coeff[0][1] = da2[k2];
338 DB.
coeff[0][0] = db1[k1] * wk1wk2;
339 DB.
coeff[1][0] = db2[k1] * wk1wk2;
340 DBT.
coeff[0][0] = db1[k2];
341 DBT.
coeff[0][1] = db2[k2];
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 ");
676 printf(
"matrice remplie %e \n", M.
coeff[i][j]);
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");
715 printf(
" MATRICE nk= %d j= %d ---> %e \n", nk, j, M.
coeff[nk][j]);
716 printf(
" apres passage d'impression \n");
726 printf(
" attention matrice non inversible !!!! %d lignes %d colonnes \n", A.
nb_lignes, A.
nb_colonnes);
748 for (i = 0; i < 3; i++) {
749 for (j = 0; j < 3; j++)
753 printf(
" Attention , on ne peut inverser la MATRICE %d \n", A.
nb_lignes);
762 double deglib, fit3, tm,
h, xki2;
763 int i, nus, ilow, isup;
770 for (i = 0; i < ns; i++) {
771 deglib = deglib + 1.;
773 if ((adcpj[i] < val3) && (i < imax)) {
776 if (adcpj[i] > val2) {
786 for (i = ilow; i <= isup; i++) {
787 adfmx[nus] = adcpj[
i];
796 xki2 = f3deg(nus, parfp3, maskp3, adfmx, errpj);
799 tm = tm + (double)ilow;
806 int nmxu,
double parom[
dimout],
double mask[
dimmat],
double adcpj[dimmat],
double errpj[dimmat][dimmat]) {
816 double xki2, dif, difmx, deglib;
820 deglib = (double)nmxu - 4.;
821 for (i = 0; i < nmxu; i++) {
825 f[
i][2] = t[
i] * t[
i];
826 f[
i][3] = f[
i][2] * t[
i];
829 for (k = 0; k < 4; k++) {
830 for (l = 0; l < 4; l++) {
832 for (i = 0; i < nmxu; i++) {
833 s = s + f[
i][
k] * f[
i][
l] * errpj[
i][
i] * mask[
i];
838 for (i = 0; i < nmxu; i++) {
839 s = s + f[
i][
k] * adcpj[
i] * errpj[
i][
i] * mask[
i];
844 inverpj(4, cov, invcov);
845 for (k = 0; k < 4; k++) {
847 for (l = 0; l < 4; l++) {
848 s = s + bv[
l] * invcov[
l][
k];
853 if (parom[3] == 0.) {
862 for (i = 0; i < nmxu; i++) {
864 h = parom[0] + parom[1] * t[
i] + parom[2] * t2 + parom[3] * t2 * t[
i];
865 dif = (adcpj[
i] -
h) * mask[i];
872 xki2 = xki2 / deglib;
874 delta = parom[2] * parom[2] - 3. * parom[3] * parom[1];
877 tm = -(delta + parom[2]) / (3. * parom[3]);
878 tmp = (delta - parom[2]) / (3. * parom[3]);
886 parom[5] = parom[0] + parom[1] * tm + parom[2] * tm * tm + parom[3] * tm * tm * tm;
904 for (i = 0; i <
n; i++) {
905 for (j = 0; j <
n; j++) {
911 al[0][0] =
sqrt(
g[0][0]);
912 for (i = 1; i <
n; i++) {
913 al[
i][0] =
g[0][
i] / al[0][0];
914 for (j = 1; j <=
i; j++) {
916 for (k = 0; k <= j - 1; k++) {
917 s = s + al[
i][
k] * al[
j][
k];
921 al[
i][
j] = r / al[
j][
j];
927 be[0][0] = 1. / al[0][0];
928 for (i = 1; i <
n; i++) {
929 be[
i][
i] = 1. / al[
i][
i];
930 for (j = 0; j <
i; j++) {
933 for (k = jj + 1; k <=
i; k++) {
934 s = s + be[
i][
k] * al[
k][
jj];
940 for (i = 0; i <
n; i++) {
941 for (j = 0; j <
n; j++) {
943 for (k = 0; k <
n; k++) {
944 s = s + be[
k][
i] * be[
k][
j];
961 b[0][0] = a[1][1] * a[2][2] - a[2][1] * a[1][2];
962 b[1][1] = a[0][0] * a[2][2] - a[2][0] * a[0][2];
963 b[2][2] = a[0][0] * a[1][1] - a[0][1] * a[1][0];
964 printf(
"a[x][x] %e %e %e %e %e %e %e \n",
972 b[0][1] = a[2][1] * a[0][2] - a[0][1] * a[2][2];
973 b[0][2] = a[0][1] * a[1][2] - a[1][1] * a[0][2];
974 b[1][0] = a[1][2] * a[2][0] - a[1][0] * a[2][2];
975 b[1][2] = a[1][0] * a[0][2] - a[0][0] * a[1][2];
976 b[2][0] = a[1][0] * a[2][1] - a[1][1] * a[2][0];
977 b[2][1] = a[0][1] * a[2][0] - a[0][0] * a[2][1];
978 deter = a[0][0] * b[0][0] + a[1][0] * b[0][1] + a[2][0] * b[0][2];
979 printf(
" deter = %e \n", deter);
980 for (i = 0; i < 3; i++) {
981 for (j = 0; j < 3; j++) {
982 printf(
" avant division a[3][3] %d %d %e \n", i, j, a[i][j]);
983 printf(
" avant division b[3][3] %d %d %e %e \n", i, j, b[i][j], deter);
984 b[
i][
j] = b[
i][
j] / deter;
985 printf(
" valeur de b[3][3] apres division %d %d %e %e \n", i, j, b[i][j], deter);
994 Double_t
dt, dtsbeta, albet, variab, puiss;
995 Double_t b1, b2, a1,
a2;
1008 albet = alpha *
beta;
1010 return ((Double_t)0.);
1013 dtsbeta = dt /
beta;
1014 variab = 1. + dt / albet;
1015 puiss =
pow(variab, alpha);
1016 fitfun = h * puiss *
exp(-dtsbeta) + ped;
1036 alphadt = alpha *
dt;
1037 exponent = -(alphadt + (
exp(-alphadt) - 1.)) / beta;
1038 fitfun = b1 *
exp(exponent);
1051 expo1 =
exp(-beta * dt);
1053 exponent = -(alpha * dt2 + (expo1 - 1.));
1054 fitfun = b1 *
exp(exponent);
1061 Double_t
dt, dtsbeta, albet, variab, puiss;
1062 Double_t b1, a1,
a2;
1073 albet = alpha *
beta;
1075 return ((Double_t)0.);
1078 dtsbeta = dt /
beta;
1079 variab = 1. + dt / albet;
1080 puiss =
pow(variab, alpha);
1081 fitfun = h * puiss *
exp(-dtsbeta) + ped;
1095 double denom,
dt, amp1, amp2, amp3;
1101 for (k = nmin; k < nmax; k++) {
1102 if (ampl[k] > ampmax) {
1107 amp1 = ampl[imax - 1];
1109 amp3 = ampl[imax + 1];
1110 denom = 2. * amp2 - amp1 - amp3;
1113 dt = 0.5 * (amp3 - amp1) / denom;
1122 parout[0] = amp2 + (amp3 - amp1) * dt * 0.25;
1123 parout[1] = (double)imax + dt;
1124 parout[2] = (double)imax;
1129 Double_t fitval0, fitval;
1132 Double_t b1, b2, alpha2,
t;
1144 puiss =
pow(fact, alpha);
1145 fitval0 = puiss *
exp(-alpha * dt / b2);
1150 alpha2dt = dt * alpha2;
1151 exponent = -(alpha2dt + (
exp(-alpha2dt) - 1.)) / beta;
1152 fitval = b1 * fitval0 *
exp(exponent);
1161 double level = 0.30;
1168 double t_min = offset - 4.50;
1169 double t_max = offset + 12.50;
1171 int t_step_max = 3000;
1172 double delta_t = (double)((t_max - t_min) / t_step_max);
1175 int t_amp_half_flag = 0;
1176 double t_amp_half_min = 999.;
1177 double t_amp_half_max = -999.;
1179 for (
int t_step = 0; t_step < t_step_max; t_step++) {
1180 double t_val = t_min + (double)t_step * delta_t;
1181 double albet = alpha_here * beta_here;
1186 if ((t_val - offset) > -albet) {
1187 amp = amplitude * TMath::Power((1 + (dt / (alpha_here * beta_here))), alpha_here) *
1188 TMath::Exp(-1.0 * (dt / beta_here));
1194 if (amp > (amp_max * level) && t_amp_half_flag == 0) {
1195 t_amp_half_flag = 1;
1196 t_amp_half_min = t_val;
1199 if (amp < (amp_max * level) && t_amp_half_flag == 1) {
1200 t_amp_half_flag = 2;
1201 t_amp_half_max = t_val;
1206 double width = (t_amp_half_max - t_amp_half_min);
double pulseShapepj(Double_t *, Double_t *)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void fill_mat(matrice A, matrice M)
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)
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)
double inverpj(int, double g[30][30], double ginv[30][30])
void transpose_mat(matrice, matrice)
void set_const(int, int, int, double, double, int)
double parab(double *, Int_t, Int_t, double *)
double f3deg(int, double parom[10], double mask[30], double adcpj[30], double errpj[30][30])
static const std::string B
void copie_colonne_mat(matrice, matrice, int)
double pulseShapepj2(Double_t *, Double_t *)
void inverse_mat(matrice, matrice)
matrice cree_mat(int n_lignes, int n_colonnes)
DecomposeProduct< arg, typename Div::arg > D
void zero_mat_nk(matrice, int)
Double_t polfit(Int_t ns, Int_t imax, Double_t par3d[10], Double_t errpj[30][30], double *)
double lastShape(Double_t *, Double_t *)
void produit_mat_int(matrice, matrice, matrice)
matrice cree_mat_prod(matrice A, matrice B)
alpha
zGenParticlesMatch = cms.InputTag(""),
double mixShape(Double_t *, Double_t *)
void diff_mat(matrice, matrice, matrice)
double lastShape2(Double_t *, Double_t *)
double inv3x3(double a[3][3], double b[3][3])
double fitpj(double **, double *, double **, double noise_val, int debug)
Power< A, B >::type pow(const A &a, const B &b)
TFParams(int size=10, int size_sh=650)