30 for (
int i=0 ;
i<10 ;
i++) {
31 for (
int j=0 ;
j<10 ;
j++) {
32 weight_matrix[
i][
j] = 8.;
53 double a1,a2,a3,b1,b2;
59 int ioktk[
ntrack],nk,nborn_min=0,nborn_max=0;
61 double par[4],tsig[1];
73 int numb_a,numb_b,numb_x;
75 fun=0; chi2s=0; chi2tot=0;
76 matrice DA,DAT,BK,
DB,DBT,
C,CT,
D,DM1,CDM1,CDM1CT,
Z,CDM1Z,YK,Y,
B,
X,XINV,RES2 ;
80 amplu =
new double[
nsamp] ;
97 printf(
" ------> __> valeurs de a1 %f a2 %f a3 %f\n",a1,a2,a3) ;
99 for (i=0 ; i<
ntrack ; i++) {
100 for (j=0 ; j<2 ; j++ ) {
101 bi[
i][
j] = (double)0. ;
102 dbi[
i][
j] = (double)0. ;
103 zi[
i][
j]=(double)0. ;
104 cti[
i][
j]=(double)0. ;
105 dm1i[
i][
j]=(double)0. ;
137 A_CROISS =
cree_mat(numb_a,numb_x) ;
145 for (iter=0 ; iter < 6 ; iter++) {
154 printf(
" Debut de l'iteration numero %d \n",iter) ;
166 printf(
" resultats injectes a iterations %d \n",iter) ;
167 printf(
" parametre a1 = %f \n",a1) ;
168 printf(
" parametre a2 = %f \n",a2) ;
169 printf(
" chi2 du fit chi2s = %f \n",chi2s) ;
171 printf(
" value de nevtmax _______________ %d \n",nevtmax) ;
179 for (nevt=0 ; nevt < nevtmax ; nevt++) {
199 for ( k = 0 ; k < 10 ; k++) {
200 amplu[
k]=adcval[
nevt][
k] ;
201 if (amplu[k] > ampmax[nk] ) {
202 ampmax[nk] = amplu[
k] ;
216 parab(amplu,2,9,par3degre) ;
226 num_fit_min[
nevt] = (double)imax[nk] - (
double)nsmin ;
227 num_fit_max[
nevt] = (double)imax[nk] + (
double)nsmax ;
230 bi[nk][0] = par3degre[0] ;
231 bi[nk][1] = par3degre[1] ;
235 printf(
"---------> depart ampmax[%d]=%f maximum %f tim %f \n",
236 nk,ampmax[nk],bi[nk][0],bi[nk][1]);
248 bi[nk][0] += dbi[nk][0] ;
249 bi[nk][1] += dbi[nk][1] ;
252 printf(
"iter %d valeur de max %f et norma %f poly 3 \n",iter,bi[nk][1],bi[nk][0]) ;
266 ns =nborn_max-nborn_min+1 ;
268 for (k=0 ; k < 10 ; k++){
278 printf(
" CHECK sample %f ampli %f \n",t,amp) ;
286 unsurs1=1./noise_val;
293 nborn_min = (int)num_fit_min[nevt] ;
294 nborn_max = (int)num_fit_max[nevt] ;
295 if(k < nborn_min || k > nborn_max ) continue ;
304 fun = pulseShapepj( tsig , par) ;
307 printf(
" valeur ampli %f et function %f min %d max %d \n",amp,fun,nsmin,nsmax) ;
308 printf(
"min %f max %f \n",num_fit_min[nevt],num_fit_max[nevt]) ;
322 variab = (double)1. + dt/albet ;
324 db1[
k] = unsurs1*fun/b1 ;
326 db2[
k] = unsurs1*fact2*dtsbeta/(albet*variab) ;
327 da1[
k] = unsurs1*fact2*(
log(variab)-dtsbeta/(alpha*variab)) ;
328 da2[
k] = unsurs1*fact2*dtsbeta*dtsbeta/(albet*variab) ;
331 delta[
k] = (amp - fun)*unsurs1 ;
333 printf(
" ------->iter %d valeur de k %d amp %f fun %f delta %f \n",
334 iter,k,amp,fun,delta[k]) ;
335 printf(
" -----> valeur de k %d delta %f da1 %f da2 %f \n",
336 k,delta[k],da1[k],da2[k]) ;
339 chi2 = chi2 + delta[
k]*delta[
k] ;
342 printf(
" CHECK chi2 %f deltachi2 %f sample %d iter %d \n",chi2,delta[k]*delta[k],k, iter) ;
359 for(
int k1=nborn_min ; k1<nborn_max+1 ; k1++) {
363 DA.
coeff[0][0] = da1[k1]*wk1wk2 ;
364 DA.
coeff[1][0] = da2[k1]*wk1wk2 ;
367 DB.
coeff[0][0] = db1[k1]*wk1wk2 ;
368 DB.
coeff[1][0] = db2[k1]*wk1wk2 ;
374 produit_mat_int(DA,DAT,BK) ;
378 produit_mat_int(DA,DBT,C) ;
382 produit_mat_int(DB,DBT,D) ;
388 somme_mat_int_scale(DA,YK,delta2) ;
389 somme_mat_int_scale(DB,Z,delta2) ;
403 printf(
" event rejected because npamp_used = %d \n",ioktk[nk]);
406 chi2s = chi2/(2. + (double)ns + 2.) ;
410 if (nevt==198 || nevt==199){
411 std::cout <<
"adc123 pour l'evt " << nevt <<
" = "<<adcval[
nevt][nborn_min]<<
" = "<<adcval[
nevt][imax[
nevt]]<<
" = "<<adcval[
nevt][nborn_max]<<std::endl;
412 std::cout <<
"chi2s pour l'evt " << nevt <<
" = "<< chi2s<<
" "<< chi2<<
" "<< ns<<
" "<<iter<<std::endl;
413 std::cout <<
"chi2tot " << nevt <<
" = "<< chi2tot<<
" "<<iter<<std::endl;
419 transpose_mat(C,CT) ;
431 cti[nk][0] = CT.
coeff[0][0] ;
432 cti[nk][1] = CT.
coeff[0][1] ;
433 cti[nk][2] = CT.
coeff[1][0] ;
434 cti[nk][3] = CT.
coeff[1][1] ;
437 dm1i[nk][0] = DM1.
coeff[0][0] ;
438 dm1i[nk][1] = DM1.
coeff[0][1] ;
439 dm1i[nk][2] = DM1.
coeff[1][0] ;
440 dm1i[nk][3] = DM1.
coeff[1][1] ;
442 zi[nk][0] = Z.
coeff[0][0] ;
443 zi[nk][1] = Z.
coeff[1][0] ;
447 for( k=0 ; k< numb_a ; k++) {
450 somme_mat_int(BK,B) ;
455 produit_mat(C,DM1,CDM1) ;
459 produit_mat_int(CDM1,CT,CDM1CT);
463 produit_mat_int(CDM1,Z,CDM1Z) ;
474 diff_mat(B,CDM1CT,X) ;
475 inverse_mat(X,XINV) ;
476 diff_mat(Y,CDM1Z,RES2) ;
481 produit_mat(XINV,RES2,A_CROISS) ;
487 for( k=0 ; k< nk+1 ; k++) {
490 ZMCT.
coeff[0][0] = zi[
k][0] - (cti[
k][0]*A_CROISS.
coeff[0][0]+
491 cti[
k][1]*A_CROISS.
coeff[1][0]) ;
492 ZMCT.
coeff[1][0] = zi[
k][1] - (cti[
k][2]*A_CROISS.
coeff[0][0]+
493 cti[
k][3]*A_CROISS.
coeff[1][0]) ;
496 dbi[
k][0] = dm1i[
k][0]*ZMCT.
coeff[0][0] + dm1i[
k][1]*ZMCT.
coeff[1][0] ;
497 dbi[
k][1] = dm1i[
k][2]*ZMCT.
coeff[0][0] + dm1i[
k][3]*ZMCT.
coeff[1][0] ;
500 printf(
" variations de b1= %f et b2= %f \n",dbi[k][0],dbi[k][1]) ;
503 db_i[
k][0] = bi[
k][0]+ dbi[
k][0] ;
504 db_i[
k][1] = bi[
k][1]+ dbi[
k][1] ;
511 a1 += A_CROISS.
coeff[0][0] ;
512 a2 += A_CROISS.
coeff[1][0] ;
516 printf(
" CHECK croiss coef0: %f croiss coef1: %f iter %d \n",fabs(A_CROISS.
coeff[0][0]),fabs(A_CROISS.
coeff[1][0]), iter);
518 if(fabs(A_CROISS.
coeff[0][0]) < 0.001 && fabs(A_CROISS.
coeff[1][0]) < 0.001)
531 printf(
" resultats trouves au bout de %d iterations \n",iter) ;
532 printf(
" parametre a1 = %f \n",a1) ;
533 printf(
" parametre a2 = %f \n",a2) ;
537 std::cout <<
" Final chi2 / NDOF : "<< chi2tot/nevtmax << std::endl;
538 std::cout <<
" Final (alpha,beta) : ("<< a1<<
","<<a2<<
")"<< std::endl;
541 return chi2tot/nevtmax ;
553 double alpha ,
double beta ,
int nevtmaximum) {
558 nevtmax = nevtmaximum ;
564 if(ns >
SDIM2) printf(
"warning: NbOfsamples exceed maximum\n");
571 printf(
" Erreur : produit de matrices de tailles incompatibles \n ");
592 printf(
" Erreur : produit de matrices de tailles incompatibles \n ");
612 printf(
" Erreur : difference de matrices de tailles incompatibles \n ");
635 printf(
" copie nk %d i %d j %d k %d A %e M %e \n ",nk,i,j,k,A.
coeff[i][j],
648 printf(
" Erreur : somme de matrices de tailles incompatibles \n ");
731 printf(
"matrice remplie %e \n",M.
coeff[i][j]) ;
741 printf(
" erreur : affichage d'une matrice vide \n") ;
747 printf(
" MATRICE i= %d j= %d ---> %e \n",i,j,M.
coeff[i][j]) ;
770 printf(
" erreur : affichage d'une matrice vide \n") ;
773 printf(
" MATRICE nk= %d j= %d ---> %e \n",nk,j,M.
coeff[nk][j]) ;
774 printf(
" apres passage d'impression \n") ;
785 printf(
" attention matrice non inversible !!!! %d lignes %d colonnes \n",
810 for ( i=0 ; i<3 ; i++ ) {
811 for ( j=0 ; j<3 ; j++ ) M.
coeff[i][j] = M.
coeff[i][j]/deter ;
815 printf(
" Attention , on ne peut inverser la MATRICE %d \n",A.
nb_lignes) ;
824 double val , val2 , val3 , adfmx[
dimmat] , parfp3[
dimout] ;
826 double deglib,fit3,tm,
h,xki2 ;
827 int i ,nus ,ilow,isup ;
834 for (i=0 ; i<ns ; i++ ){
837 if((adcpj[i] < val3) && (i<imax) ){
840 if(adcpj[i] > val2 ){
845 if(ilow == imax )ilow=ilow-1 ;
846 if(isup-ilow < 3) isup=ilow+3 ;
848 for(i=ilow ; i<=isup ; i++){
850 adfmx[nus]=adcpj[
i] ;
857 if(nus < 4)
return 10000. ;
858 xki2 = f3deg ( nus , parfp3 , maskp3 , adfmx , errpj ) ;
877 double xki2 , dif , difmx , deglib ;
881 deglib=(double)nmxu - 4. ;
882 for ( i=0 ; i<nmxu ; i++ ) {
887 f[
i][3]=f[
i][2]*t[
i] ;
890 for ( k=0 ; k<4 ; k++ ) {
891 for ( l=0 ; l<4 ; l++ ) {
893 for (i=0 ; i<nmxu ; i++ ) {
894 s=s+f[
i][
k]*f[
i][
l]*errpj[
i][
i]*mask[
i] ;
899 for (i=0 ; i<nmxu ; i++ ) {
900 s=s+f[
i][
k]*adcpj[
i]*errpj[
i][
i]*mask[
i] ;
905 inverpj ( 4 , cov , invcov );
906 for ( k=0 ; k<4 ; k++ ) {
908 for ( l=0 ; l<4 ; l++ ) {
909 s=s+bv[
l]*invcov[
l][
k] ;
914 if( parom[3] == 0. ){
923 for (i=0 ; i<nmxu ; i++ ){
925 h= parom[0]+parom[1]*t[
i]+parom[2]*t2+parom[3]*t2*t[
i] ;
926 dif=(adcpj[
i]-
h)*mask[i] ;
932 if(deglib > 0.5) xki2=xki2/deglib ;
934 delta=parom[2]*parom[2]-3.*parom[3]*parom[1] ;
937 tm=-(delta+parom[2])/(3.*parom[3]) ;
938 tmp=(delta-parom[2])/(3.*parom[3]) ;
947 parom[5]= parom[0]+parom[1]*tm+parom[2]*tm*tm+parom[3]*tm*tm*tm ;
966 for( i=0 ; i<
n ; i++ ) {
967 for ( j=0 ; j<
n ; j++ ) {
973 al[0][0] =
sqrt(
g[0][0] ) ;
974 for ( i=1 ; i<
n ; i++ ) {
975 al[
i][0] =
g[0][
i] / al[0][0] ;
976 for ( j=1 ; j<=
i ; j++ ) {
978 for ( k=0 ; k<=j-1 ; k++ ) {
979 s=s+ al[
i][
k] * al[
j][
k] ;
982 if( j < i ) al[
i][
j] = r/al[
j][
j] ;
983 if( j == i ) al[
i][
j] =
sqrt ( r) ;
987 be[0][0] = 1./al[0][0] ;
988 for ( i=1 ; i<
n ; i++ ) {
989 be[
i][
i] = 1. / al[
i][
i] ;
990 for ( j=0 ; j<
i ; j++ ) {
993 for ( k=jj+1 ; k<=
i ; k++ ) {
994 s=s+ be[
i][
k] * al[
k][
jj] ;
1000 for ( i=0 ; i<
n ; i++ ) {
1001 for ( j=0 ; j<
n ; j++ ) {
1003 for ( k=0 ; k<
n ; k++ ) {
1004 s=s+ be[
k][
i] * be[
k][
j] ;
1022 b[0][0]=a[1][1]*a[2][2]-a[2][1]*a[1][2] ;
1023 b[1][1]=a[0][0]*a[2][2]-a[2][0]*a[0][2] ;
1024 b[2][2]=a[0][0]*a[1][1]-a[0][1]*a[1][0] ;
1025 printf(
"a[x][x] %e %e %e %e %e %e %e \n",a[0][0],a[1][1],a[0][1],a[1][0],
1026 a[0][0]*a[1][1],a[0][1]*a[1][0],b[2][2]);
1027 b[0][1]=a[2][1]*a[0][2]-a[0][1]*a[2][2] ;
1028 b[0][2]=a[0][1]*a[1][2]-a[1][1]*a[0][2] ;
1029 b[1][0]=a[1][2]*a[2][0]-a[1][0]*a[2][2] ;
1030 b[1][2]=a[1][0]*a[0][2]-a[0][0]*a[1][2] ;
1031 b[2][0]=a[1][0]*a[2][1]-a[1][1]*a[2][0] ;
1032 b[2][1]=a[0][1]*a[2][0]-a[0][0]*a[2][1] ;
1033 deter=a[0][0]*b[0][0] + a[1][0]*b[0][1] + a[2][0]*b[0][2] ;
1034 printf(
" deter = %e \n",deter) ;
1035 for ( i=0 ; i<3 ; i++ ) {
1036 for ( j=0 ; j<3 ; j++ ) {
1037 printf(
" avant division a[3][3] %d %d %e \n",i,j,a[i][j]) ;
1038 printf(
" avant division b[3][3] %d %d %e %e \n",i,j,b[i][j],deter) ;
1039 b[
i][
j] = b[
i][
j]/deter ;
1040 printf(
" valeur de b[3][3] apres division %d %d %e %e \n",i,j,b[i][j],deter) ;
1051 Double_t
dt, dtsbeta, albet, variab, puiss;
1052 Double_t b1,b2,a1,a2 ;
1065 albet = alpha*
beta ;
1066 if( albet <= 0 )
return( (Double_t)0. );
1070 variab=1.+dt/albet ;
1071 puiss=
pow(variab,alpha);
1072 fitfun=h*puiss*
exp(-dtsbeta) + ped;
1095 alphadt = alpha*
dt ;
1096 exponent = -(alphadt+(
exp(-alphadt)-1.))/beta ;
1097 fitfun = b1*
exp(exponent) ;
1112 expo1 =
exp(-beta*dt) ;
1114 exponent = -(alpha*dt2+(expo1-1.)) ;
1115 fitfun = b1*
exp(exponent) ;
1124 Double_t
dt, dtsbeta, albet, variab, puiss;
1136 albet = alpha*
beta ;
1137 if( albet <= 0 )
return( (Double_t)0. );
1141 variab=1.+dt/albet ;
1142 puiss=
pow(variab,alpha);
1143 fitfun=h*puiss*
exp(-dtsbeta) + ped;
1159 double denom,
dt,amp1,amp2,amp3 ;
1160 double ampmax = 0. ;
1165 for ( k = nmin ; k < nmax ; k++) {
1166 if (ampl[k] > ampmax ) {
1171 amp1 = ampl[imax-1] ;
1173 amp3 = ampl[imax+1] ;
1174 denom=2.*amp2-amp1-amp3 ;
1177 dt =0.5*(amp3-amp1)/denom ;
1187 parout[0] =amp2+(amp3-amp1)*dt*0.25 ;
1188 parout[1] = (double)imax + dt ;
1189 parout[2] = (double)imax ;
1195 Double_t fitval0,fitval;
1198 Double_t b1,b2,alpha2,
t ;
1210 puiss =
pow(fact,alpha) ;
1211 fitval0 = puiss*
exp(-alpha*dt/b2) ;
1218 alpha2dt = dt*alpha2 ;
1219 exponent = -(alpha2dt+(
exp(-alpha2dt)-1.))/beta ;
1220 fitval = b1*fitval0*
exp(exponent) ;
1230 double level = 0.30 ;
1232 double amplitude = 1.00 ;
1234 double amp_max = amplitude;
1237 double t_min = offset-4.50;
1238 double t_max = offset+12.50;
1240 int t_step_max = 3000;
1241 double delta_t = (double)((t_max-t_min)/t_step_max);
1244 int t_amp_half_flag = 0;
1245 double t_amp_half_min = 999.;
1246 double t_amp_half_max = -999.;
1248 for (
int t_step=0; t_step<t_step_max; t_step++){
1250 double t_val = t_min + (double)t_step*delta_t;
1251 double albet = alpha_here*beta_here ;
1255 if( methode == 2 ) {
1256 if( (t_val-offset) > -albet) {
1258 amp = amplitude*TMath::Power( ( 1 + ( dt / (alpha_here*beta_here) ) ) , alpha_here ) * TMath::Exp(-1.0*(dt/beta_here));
1265 if( amp > (amp_max*level) && t_amp_half_flag == 0) {
1266 t_amp_half_flag = 1;
1267 t_amp_half_min = t_val;
1270 if( amp < (amp_max*level) && t_amp_half_flag == 1) {
1271 t_amp_half_flag = 2;
1272 t_amp_half_max = t_val;
1278 double width = (t_amp_half_max - t_amp_half_min);
const double Z[kNumberCalorimeter]
double pulseShapepj(Double_t *, Double_t *)
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 *)
matrice cree_mat_prod(matrice, matrice)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
double f3deg(int, double parom[10], double mask[30], double adcpj[30], double errpj[30][30])
void copie_colonne_mat(matrice, matrice, int)
matrice cree_mat(int, int)
double pulseShapepj2(Double_t *, Double_t *)
void inverse_mat(matrice, matrice)
DecomposeProduct< arg, typename Div::arg > D
void zero_mat_nk(matrice, int)
void fill_mat(matrice, matrice)
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 *)
std::vector< std::vector< double > > tmp
void produit_mat_int(matrice, matrice, matrice)
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)
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
TFParams(int size=10, int size_sh=650)