CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TFParams.cc
Go to the documentation of this file.
1 
14 #include <malloc.h>
15 #include "TMatrixD.h"
16 #include "TMath.h"
17 
18 #include <iostream>
19 #include <time.h>
20 
21 
22 //ClassImp(TFParams)
23 
24 using namespace std;
25 
26 TFParams::TFParams( int size, int size_sh ) {
27 
28  //int sdim = size;
29  //int plshdim = size_sh;
30 
31 for (int i=0 ; i<10 ; i++) {
32  for (int j=0 ; j<10 ; j++) {
33  weight_matrix[i][j] = 8.;
34  }
35  }
36 
37 }
38 
39 double TFParams::fitpj(double **adcval , double *parout , double **db_i, double noise_val, int debug)
40 {
41 
42 #define dimn 10
43 #define dimin 10
44 #define plshdim 300
45 #define nsamp 10
46 #define ntrack 500
47  //#define debug debug1
48 
49  // ******************************************************************
50  // * Definitions of variables used in the routine
51  // ******************************************************************
52 
53 
54  double a1,a2,a3,a1i,a2i,a3i,b1,b2;
55  int iter,nevt;
56  double errpj[dimmat][dimmat] ;
57  double bi[ntrack][2],dbi[ntrack][2];
58  double zi[ntrack][2] ;
59  double par3degre[3] ;
60  int ioktk[ntrack],iokchi2[ntrack],nk,nborn_min=0,nborn_max=0;
61  double cti[ntrack][6],dm1i[ntrack][4];
62  double aiter[10][3];
63  double par[4],tsig[1];
64  double amp,delta[nsamp],delta2,fun;
65  double num_fit_min[ntrack],num_fit_max[ntrack] ;
66  int i,j,k,imax[ntrack];
67 
68  double noise_initialvalue,one_over_noisesq ;
69  double ampmax[ntrack],dt,t;
70  double chi2, chi2s, da1[nsamp], da2[nsamp], db1[nsamp], db2[nsamp] ;
71  double chi2tot;
72  double fact1,fact2,expo;
73  double albet,dtsbeta,variab,alpha,beta,puiss ;
74  double unsurs1 ,unsurs2 ;
75  double fit3 ;
76  int numb_a,numb_b,numb_ab,numb_b2,numb_x,ndimi,ndimj ;
77 
78  fun=0; chi2s=0; chi2tot=0;
79  matrice DA,DAT,BK,DB,DBT,C,CT,D,DM1,CDM1,CDM1CT,Z,CDM1Z,YK,Y,B,X,XINV,RES2 ;
80  matrice A_CROISS,ZMCT ;
81 
82  double *amplu ;
83  amplu = new double[nsamp] ;
84 
85  parout[0] = 0. ;
86  parout[1] = 0. ;
87  parout[2] = 0. ;
88 
89  //
90  // Define Error Matrix
91  //
92 
93  noise_initialvalue = noise_val ;
94  one_over_noisesq=1./(noise_initialvalue * noise_initialvalue) ;
95  for ( i=0 ; i<dimmat ; i++ ) {
96  for ( j=0 ; j<dimmat ; j++ ) {
97  errpj[i][j] = 0. ;
98  }
99  errpj[i][i]=one_over_noisesq ;
100  }
101 
102  //
103  // Initialisation of fit parameters
104  //
105 
106  a1 = a1ini ;
107  a2 = a2ini ;
108  a3 = a3ini ;
109  if( METHODE==2) {
110  a2 = a3ini ; // for lastshape BETA is the third parameter ( ... ! )
111  }
112  a1i = a1 ;
113  a2i = a2 ;
114  a3i = a3 ;
115  if (debug==1){
116  printf(" ------> __> valeurs de a1 %f a2 %f a3 %f\n",a1,a2,a3) ;
117  }
118  for (i=0 ; i<ntrack ; i++) {
119  iokchi2[i]=1 ;
120  for (j=0 ; j<2 ; j++ ) {
121  bi[i][j] = (double)0. ;
122  dbi[i][j] = (double)0. ;
123  zi[i][j]=(double)0. ;
124  cti[i][j]=(double)0. ;
125  dm1i[i][j]=(double)0. ;
126  }
127  }
128 
129  ndimi = 2 ;
130  ndimj = 2 ;
131  numb_a = 2 ;
132 
133 
134  //
135  // Matrices initialisation
136  //
137 
138  numb_x = 1 ;
139  numb_b = 2 ;
140  numb_ab = numb_a*numb_b ;
141  numb_b2 = numb_b*numb_b ;
142  DA = cree_mat(numb_a,numb_x) ;
143  DAT = cree_mat(numb_x,numb_a) ;
144  BK = cree_mat_prod(DA,DAT) ;
145  DB = cree_mat(numb_b,numb_x) ;
146  DBT = cree_mat(numb_x,numb_b) ;
147  C = cree_mat(numb_a,numb_b) ;
148  CT = cree_mat(numb_b,numb_a) ;
149  D = cree_mat_prod(DB,DBT) ;
150  DM1 = cree_mat_prod(DB,DBT) ;
151  CDM1 = cree_mat_prod(C,DM1) ;
152  CDM1CT = cree_mat_prod(CDM1,CT) ;
153  Z = cree_mat(numb_b,numb_x) ;
154  CDM1Z =cree_mat_prod(CDM1,Z) ;
155  YK =cree_mat(numb_a,numb_x) ;
156  Y =cree_mat(numb_a,numb_x) ;
157  B = cree_mat_prod(DA,DAT) ;
158  X = cree_mat_prod(DA,DAT) ;
159  XINV = cree_mat_prod(DA,DAT) ;
160  RES2=cree_mat(numb_a,numb_x) ;
161  A_CROISS = cree_mat(numb_a,numb_x) ;
162  ZMCT = cree_mat(numb_b,numb_x) ;
163 
164 
166  // First Loop on iterations //
168 
169  for (iter=0 ; iter < 6 ; iter++) {
170 
171  chi2tot=0;
172 
173  //
174  // Set zeros for general matrices
175  //
176 
177  if (debug==1){
178  printf(" Debut de l'iteration numero %d \n",iter) ;
179  }
180  zero_mat(CDM1Z) ;
181  zero_mat(Y) ;
182  zero_mat(CDM1CT) ;
183  zero_mat(B) ;
184  zero_mat(X) ;
185  zero_mat(CDM1) ;
186 
187 
188  nk = -1 ;
189  aiter[iter][0] = a1 ;
190  aiter[iter][1] = a2 ;
191  if (debug==1){
192  printf( " resultats injectes a iterations %d \n",iter) ;
193  printf( " parametre a1 = %f \n",a1) ;
194  printf( " parametre a2 = %f \n",a2) ;
195  printf( " chi2 du fit chi2s = %f \n",chi2s) ;
196 
197  printf(" value de nevtmax _______________ %d \n",nevtmax) ;
198  }
199 
200 
202  // Loop on events //
204 
205  for (nevt=0 ; nevt < nevtmax ; nevt++) {
206 
207  // B1 = BI[nk,1] est la normalisation du signal
208  // B2 = BI[nk,2] ewst le dephasage par rapport a une
209  // fonction centree en zero
210  // Nous choisissons ici de demarrer avec les resultats
211  // de l'ajustement parabolique mais il faudra bien
212  // entendu verifier que cela ne biaise pas le resultat !
213  // mise a zero des matrices utilisees dans la boucle
214 
215 
216  zero_mat(Z) ;
217  zero_mat(YK) ;
218  zero_mat(BK) ;
219  zero_mat(C) ;
220  zero_mat(D) ;
221 
222  nk=nevt ;
223  ampmax[nk] = 0. ;
224  imax[nk] = 0 ;
225  for ( k = 0 ; k < 10 ; k++) {
226  amplu[k]=adcval[nevt][k] ;
227  if (amplu[k] > ampmax[nk] ) {
228  ampmax[nk] = amplu[k] ;
229  imax[nk] = k ;
230  }
231  }
232 
233 
234  if( iter == 0 ) {
235 
236  // start with degree 3 polynomial ....
237  //fit3 =polfit(ns ,imax[nk] ,par3degre ,errpj ,amplu ) ;
238  // std::cout << "Poly Fit Param :"<< par3degre[0] <<" "<< par3degre[1]<< std::endl;
239 
240  // start with parabol
241  //fit3 = parab(amplu,4,12,par3degre) ;
242  fit3 = parab(amplu,2,9,par3degre) ;
243  //std::cout << "Parab Fit Param :"<< par3degre[0] <<" "<< par3degre[1]<< std::endl;
244 
245 
246  // start with basic initial values
247  //par3degre[0]= ampmax+ampmax/10. ;
248  //par3degre[1]= (double)imax[nk]+0.1 ;
249  //bi[nk][0] = ampmax[nk] ;
250  //bi[nk][1] = (double)imax[nk] ;
251 
252  num_fit_min[nevt] = (double)imax[nk] - (double)nsmin ;
253  num_fit_max[nevt] = (double)imax[nk] + (double)nsmax ;
254 
255 
256  bi[nk][0] = par3degre[0] ;
257  bi[nk][1] = par3degre[1] ;
258 
259 
260  if (debug==1){
261  printf("---------> depart ampmax[%d]=%f maximum %f tim %f \n",
262  nk,ampmax[nk],bi[nk][0],bi[nk][1]);
263  }
264 
265  } else {
266 
267 
268  // in other iterations :
269  // increment bi[][] parameters with bdi[][]
270  // calculated in previous
271  // iteration
272 
273 
274  bi[nk][0] += dbi[nk][0] ;
275  bi[nk][1] += dbi[nk][1] ;
276 
277  if (debug==1){
278  printf("iter %d valeur de max %f et norma %f poly 3 \n",iter,bi[nk][1],bi[nk][0]) ;
279  }
280  }
281 
282  b1 = bi[nk][0] ;
283  b2 = bi[nk][1] ;
284 
285 
287  // Loop on samples //
289 
290  chi2 = 0. ;
291  ioktk[nk] = 0 ;
292  ns =nborn_max-nborn_min+1 ;
293 
294  for (k=0 ; k < 10 ; k++){
295 
296  //
297  // calculation of fonction used to fit
298  //
299 
300  dt =(double)k - b2 ;
301  t = (double)k ;
302  amp = amplu[k] ;
303  if (debug==1){
304  printf(" CHECK sample %f ampli %f \n",t,amp) ;
305  }
306  //unsurs1 = 1./sig_err ;
307  //unsurs2 = 1./(sig_err*sig_err) ;
308  //unsurs1 = 0.1 ;
309  //unsurs2 = 0.01 ;
310 
311 
312  unsurs1=1./noise_val;
313  unsurs2=(1./noise_val)*(1./noise_val);
314 
315  //
316  // Pulse shape function used: pulseShapepj
317  //
318 
319  nborn_min = (int)num_fit_min[nevt] ;
320  nborn_max = (int)num_fit_max[nevt] ;
321  if(k < nborn_min || k > nborn_max ) continue ;
322  tsig[0] =(double)k ;
323 
324 
325  if(METHODE==2) {
326  par[0]= b1 ;
327  par[1] = b2 ;
328  par[2] = a1 ;
329  par[3] = a2 ;
330  fun = pulseShapepj( tsig , par) ;
331  }
332  if (debug==1){
333  printf(" valeur ampli %f et function %f min %d max %d \n",amp,fun,nsmin,nsmax) ;
334  printf("min %f max %f \n",num_fit_min[nevt],num_fit_max[nevt]) ;
335  }
336 
337  // we need to determine a1,a2 which are global parameters
338  // and b1, b2 which are parameters for each individual signal:
339  // b1, b2 = amplitude and time event by event
340  // a1, a2 = alpha and beta global
341  // we first begin to calculate the derivatives used in the following calculation
342 
343  if(METHODE==2){
344  alpha = a1 ;
345  beta = a2 ;
346  albet=alpha*beta;
347  if(dt > -albet) {
348  variab = (double)1. + dt/albet ;
349  dtsbeta = dt/beta ;
350  expo = exp(-dtsbeta) ;
351  puiss = pow(variab,alpha) ;
352  fact1 = puiss*expo ;
353  db1[k] = unsurs1*fun/b1 ;
354  fact2 = fun ;
355  db2[k] = unsurs1*fact2*dtsbeta/(albet*variab) ;
356  da1[k] = unsurs1*fact2*(log(variab)-dtsbeta/(alpha*variab)) ;
357  da2[k] = unsurs1*fact2*dtsbeta*dtsbeta/(albet*variab) ;
358  }
359  }
360  delta[k] = (amp - fun)*unsurs1 ;
361  if (debug==1){
362  printf(" ------->iter %d valeur de k %d amp %f fun %f delta %f \n",
363  iter,k,amp,fun,delta[k]) ;
364  printf(" -----> valeur de k %d delta %f da1 %f da2 %f \n",
365  k,delta[k],da1[k],da2[k]) ;
366  }
367 
368  chi2 = chi2 + delta[k]*delta[k] ;
369 
370  if (debug==1){
371  printf(" CHECK chi2 %f deltachi2 %f sample %d iter %d \n",chi2,delta[k]*delta[k],k, iter) ;
372  }
373 
374  }
375 
376 
378  // End Loop on samples //
380 
381 
382  double wk1wk2 ;
383 
385  // Start Loop on samples //
387 
388  for(int k1=nborn_min ; k1<nborn_max+1 ; k1++) {
389  wk1wk2 = 1. ;
390  int k2 = k1 ;
391 
392  DA.coeff[0][0] = da1[k1]*wk1wk2 ;
393  DA.coeff[1][0] = da2[k1]*wk1wk2 ;
394  DAT.coeff[0][0]= da1[k2] ;
395  DAT.coeff[0][1]= da2[k2] ;
396  DB.coeff[0][0] = db1[k1]*wk1wk2 ;
397  DB.coeff[1][0] = db2[k1]*wk1wk2 ;
398  DBT.coeff[0][0]= db1[k2] ;
399  DBT.coeff[0][1]= db2[k2] ;
400 
401  // Compute derivative matrix : matrix b[2][2]
402 
403  produit_mat_int(DA,DAT,BK) ;
404 
405  // Compute matrix c[2][2]
406 
407  produit_mat_int(DA,DBT,C) ;
408 
409  // Compute matrix d[2][2]
410 
411  produit_mat_int(DB,DBT,D) ;
412 
413  // Compute matrix y[3] and z[2] depending of delta (amp-fun)
414 
415  delta2 = delta[k2] ;
416 
417  somme_mat_int_scale(DA,YK,delta2) ;
418  somme_mat_int_scale(DB,Z,delta2) ;
419 
420  ioktk[nk]++ ;
421 
422  }
423 
425  // End Loop on samples //
427 
428 
429  // Remove events with a bad shape
430 
431  if(ioktk[nk] < 4 ) {
432  printf(" event rejected because npamp_used = %d \n",ioktk[nk]);
433  continue ;
434  }
435  chi2s = chi2/(2. + (double)ns + 2.) ;
436  chi2tot+=chi2s;
437 
438  if (debug==1){
439  if (nevt==198 || nevt==199){
440  std::cout << "adc123 pour l'evt " << nevt <<" = "<<adcval[nevt][nborn_min]<<" = "<<adcval[nevt][imax[nevt]]<<" = "<<adcval[nevt][nborn_max]<<std::endl;
441  std::cout << "chi2s pour l'evt " << nevt <<" = "<< chi2s<<" "<< chi2<<" "<< ns<<" "<<iter<<std::endl;
442  std::cout << "chi2tot " << nevt <<" = "<< chi2tot<<" "<<iter<<std::endl;
443  }
444  }
445 
446  // Transpose matrix C ---> CT
447 
448  transpose_mat(C,CT) ;
449 
450  // Calculate DM1 (inverse of D matrix 2x2)
451 
452  inverse_mat(D,DM1) ;
453 
454 
455  // Set matrix product c*d in memory in order to compute variations
456  // of parameters B at the end of the iteration loop
457  // the variations of parameters b are dependant of the variations of
458  // parameters da[1],da[2]
459 
460  cti[nk][0] = CT.coeff[0][0] ;
461  cti[nk][1] = CT.coeff[0][1] ;
462  cti[nk][2] = CT.coeff[1][0] ;
463  cti[nk][3] = CT.coeff[1][1] ;
464 
465 
466  dm1i[nk][0] = DM1.coeff[0][0] ;
467  dm1i[nk][1] = DM1.coeff[0][1] ;
468  dm1i[nk][2] = DM1.coeff[1][0] ;
469  dm1i[nk][3] = DM1.coeff[1][1] ;
470 
471  zi[nk][0] = Z.coeff[0][0] ;
472  zi[nk][1] = Z.coeff[1][0] ;
473 
474  // Sum the matrix b and y after every event
475 
476  for( k=0 ; k< numb_a ; k++) {
477  Y.coeff[k][0] += YK.coeff[k][0] ;
478  }
479  somme_mat_int(BK,B) ;
480 
481 
482  // Calculate c(d-1)
483 
484  produit_mat(C,DM1,CDM1) ;
485 
486  // Compute c(d-1)ct
487 
488  produit_mat_int(CDM1,CT,CDM1CT);
489 
490  // Compute c(d-1)z
491 
492  produit_mat_int(CDM1,Z,CDM1Z) ;
493 
494 
495  }
497  // End Loop on events //
499 
500 
501  // Compute b-cdm1ct
502 
503  diff_mat(B,CDM1CT,X) ;
504  inverse_mat(X,XINV) ;
505  diff_mat(Y,CDM1Z,RES2) ;
506 
507 
508  // Calculation is now easy for da[0] da[1]
509 
510  produit_mat(XINV,RES2,A_CROISS) ;
511 
512 
513  // A la fin, on peut iterer en mesurant l'accroissement a apporter
514  // des parametres globaux par la formule db[i] = dm1(z-ct*da[i])
515 
516  for( k=0 ; k< nk+1 ; k++) {
517 
518  if(METHODE ==2 ) {
519  ZMCT.coeff[0][0] = zi[k][0] - (cti[k][0]*A_CROISS.coeff[0][0]+
520  cti[k][1]*A_CROISS.coeff[1][0]) ;
521  ZMCT.coeff[1][0] = zi[k][1] - (cti[k][2]*A_CROISS.coeff[0][0]+
522  cti[k][3]*A_CROISS.coeff[1][0]) ;
523  }
524 
525  dbi[k][0] = dm1i[k][0]*ZMCT.coeff[0][0] + dm1i[k][1]*ZMCT.coeff[1][0] ;
526  dbi[k][1] = dm1i[k][2]*ZMCT.coeff[0][0] + dm1i[k][3]*ZMCT.coeff[1][0] ;
527  if (debug==1){
528  if( k < 100 ){
529  printf(" variations de b1= %f et b2= %f \n",dbi[k][0],dbi[k][1]) ;
530  }
531  }
532  db_i[k][0] = bi[k][0]+ dbi[k][0] ;
533  db_i[k][1] = bi[k][1]+ dbi[k][1] ;
534  }
535 
536 
537  // dbi[0] et dbi[1] mesurent les variations a apporter aux
538  // parametres du signal
539 
540  a1 += A_CROISS.coeff[0][0] ;
541  a2 += A_CROISS.coeff[1][0] ;
542 
543 
544  if (debug==1){
545  printf(" CHECK croiss coef0: %f croiss coef1: %f iter %d \n",fabs(A_CROISS.coeff[0][0]),fabs(A_CROISS.coeff[1][0]), iter);
546  }
547  if(fabs(A_CROISS.coeff[0][0]) < 0.001 && fabs(A_CROISS.coeff[1][0]) < 0.001)
548  break;
549 
550  }
551 
553  // End Loop on iterations //
555 
556  parout[0] = a1 ;
557  parout[1] = a2 ;
558  parout[2] = a3 ;
559  if (debug==1){
560  printf( " resultats trouves au bout de %d iterations \n",iter) ;
561  printf( " parametre a1 = %f \n",a1) ;
562  printf( " parametre a2 = %f \n",a2) ;
563  }
564 
565  if (debug==1){
566  std::cout << " Final chi2 / NDOF : "<< chi2tot/nevtmax << std::endl;
567  std::cout << " Final (alpha,beta) : ("<< a1<<","<<a2<<")"<< std::endl;
568  }
569 
570  return chi2tot/nevtmax ;
571 
572 }
573 
575 // End Fitpj //
577 
578 
579 
580 /**************************************************************************/
581 void TFParams::set_const( int n_samples, int sample_min, int sample_max ,
582  double alpha ,double beta ,int nevtmaximum) {
583 /*------------------------------------------------------------------------*/
584  ns = n_samples;
585  nsmin = sample_min ;
586  nsmax = sample_max ;
587  nevtmax = nevtmaximum ;
588  a1ini = alpha ;
589  a2ini = 0.0 ;
590  a3ini = beta ;
591  step_shape = .04;
592  METHODE = 2;
593  if(ns > SDIM2) printf("warning: NbOfsamples exceed maximum\n");
594 }
596 {
597  int i,j,k ;
598 // resultat du produit A*B = M
599  if(A.nb_colonnes != B.nb_lignes) {
600  printf( " Erreur : produit de matrices de tailles incompatibles \n ");
601  M.coeff = NULL ;
602  return ;
603  }
604  M.nb_lignes = A.nb_lignes ;
605  M.nb_colonnes = B.nb_colonnes ;
606  zero_mat(M) ;
607  for(i=0 ; i< M.nb_lignes; i++) {
608  for(j=0 ; j< M.nb_colonnes ; j++) {
609  for(k=0 ; k< A.nb_colonnes; k++){
610  M.coeff[i][j] += A.coeff[i][k]*B.coeff[k][j] ;
611  }
612  }
613  }
614  return ;
615 }
616 
618 {
619  int i,j,k ;
620  if(A.nb_colonnes != B.nb_lignes) {
621  printf( " Erreur : produit de matrices de tailles incompatibles \n ");
622  M.coeff = NULL ;
623  return ;
624  }
625  M.nb_lignes = A.nb_lignes ;
626  M.nb_colonnes = B.nb_colonnes ;
627  for(i=0 ; i< M.nb_lignes; i++) {
628  for(j=0 ; j< M.nb_colonnes ; j++) {
629  for(k=0 ; k< A.nb_colonnes; k++){
630  M.coeff[i][j] += A.coeff[i][k]*B.coeff[k][j] ;
631  }
632  }
633  }
634  return ;
635 }
637 {
638  int i,j ;
639 //resultat de la difference A-B = M
640  if(A.nb_lignes != B.nb_lignes) {
641  printf( " Erreur : difference de matrices de tailles incompatibles \n ");
642  M.coeff = NULL ;
643  return ;
644  }
645  M.nb_lignes = A.nb_lignes ;
646  M.nb_colonnes = A.nb_colonnes ;
647  for(i=0 ; i< M.nb_lignes; i++) {
648  for(j=0 ; j < M.nb_colonnes ; j++) {
649  M.coeff[i][j] = A.coeff[i][j] - B.coeff[i][j] ;
650  }
651  }
652  return ;
653 
654 }
656 {
657  int i,j ;
658  int k ;
659  /* resultat de la copie de A dans un vecteur colonne M */
660  k = 0 ;
661  for(i=0 ; i< A.nb_lignes; i++) {
662  for(j=0 ; j < A.nb_colonnes ; j++) {
663  M.coeff[nk][k] = A.coeff[i][j] ;
664  printf(" copie nk %d i %d j %d k %d A %e M %e \n ",nk,i,j,k,A.coeff[i][j],
665  M.coeff[nk][k]);
666  k++ ;
667  }
668  }
669  return ;
670 }
671 
673 {
674  int i,j;
675  /* resultat de la somme integree M += A */
676  if(A.nb_lignes != M.nb_lignes) {
677  printf( " Erreur : somme de matrices de tailles incompatibles \n ");
678  M.coeff = NULL ;
679  return ;
680  }
681  M.nb_lignes = A.nb_lignes ;
682  M.nb_colonnes = A.nb_colonnes ;
683  for(i=0 ; i< M.nb_lignes; i++) {
684  for(j=0 ; j< M.nb_colonnes ; j++)
685  M.coeff[i][j] += A.coeff[i][j] ;
686  }
687  return ;
688 }
690 {
691  int i,j ;
692  M.nb_lignes = A.nb_lignes ;
693  M.nb_colonnes = A.nb_colonnes ;
694  for(i=0 ; i< M.nb_lignes; i++) {
695  for(j=0 ; j< M.nb_colonnes ; j++) M.coeff[i][j] += A.coeff[i][j]*delta ;
696  }
697  return ;
698 }
700 {
701  int i,j;
702 // resultat de la transposition = matrice M
703  for(i=0 ; i< A.nb_lignes; i++) {
704  for(j=0 ; j< A.nb_colonnes ; j++) {
705  M.coeff[j][i] = A.coeff[i][j] ;
706  }
707  }
708  return ;
709 }
711 {
712  int i,j;
713  matrice M ; /* resultat de la creation */
714 
715  M.nb_lignes = A.nb_lignes ;
716  M.nb_colonnes = B.nb_colonnes ;
717  M.coeff = (double**)malloc(M.nb_lignes*sizeof(double*)) ;
718  for(i=0 ; i< M.nb_lignes; i++)
719  M.coeff[i]=(double*)calloc(M.nb_colonnes,sizeof(double));
720  for(i=0 ; i< M.nb_lignes; i++) {
721 
722  for(j=0 ; j< M.nb_colonnes ; j++) {
723  M.coeff[i][j] = 0. ;
724  }
725  }
726  //printf(" creation de matrice ----> nlignes %d ncolonnes %d \n",
727 // M.nb_lignes,M.nb_colonnes) ;
728  return (M) ;
729 }
730 matrice cree_mat(int n_lignes,int n_colonnes)
731 {
732  int i,j;
733  matrice M ; /* resultat de la creation */
734 
735  M.nb_lignes = n_lignes ;
736  M.nb_colonnes = n_colonnes ;
737  M.coeff = (double**)malloc(M.nb_lignes*sizeof(double*)) ;
738  for(i=0 ; i< M.nb_lignes; i++)
739  M.coeff[i]=(double*)calloc(M.nb_colonnes,sizeof(double));
740  for(i=0 ; i< M.nb_lignes; i++) {
741  for(j=0 ; j< M.nb_colonnes ; j++) {
742  M.coeff[i][j] = 0. ;
743  }
744  }
745  //printf(" creation de matrice ---> nlignes %d ncolonnes %d \n",
746  // M.nb_lignes,M.nb_colonnes) ;
747  return (M) ;
748 }
749 
751 {
752  int i,j;
753  /* on remplit la matrice M avec la matrice A */
754 
755  M.nb_lignes = A.nb_lignes ;
756  M.nb_colonnes = A.nb_colonnes ;
757  for(i=0 ; i< M.nb_lignes; i++) {
758  for(j=0 ; j< M.nb_colonnes ; j++) {
759  M.coeff[i][j] = A.coeff[i][j] ;
760  printf("matrice remplie %e \n",M.coeff[i][j]) ;
761  }
762  }
763  return ;
764 }
766 {
767  int i,j ;
768  if( M.coeff == NULL)
769  printf(" erreur : affichage d'une matrice vide \n") ;
770  printf(" m_nli %d M_ncol %d \n",M.nb_lignes,M.nb_colonnes) ;
771  for(i=0 ; i< M.nb_lignes; i++) {
772  for(j=0 ; j< M.nb_colonnes ; j++)
773  printf(" MATRICE i= %d j= %d ---> %e \n",i,j,M.coeff[i][j]) ;
774  }
775  //printf(" apres passage d'impression \n") ;
776  return ;
777 }
779 {
780  int i,j ;
781  for(i=0 ; i< M.nb_lignes; i++) {
782  for(j=0 ; j< M.nb_colonnes ; j++) M.coeff[i][j]=0. ;
783  }
784  return ;
785 }
787 {
788  int j ;
789  for(j=0 ; j< M.nb_colonnes ; j++) M.coeff[nk][j]=0. ;
790  return ;
791 }
793 {
794  int j ;
795  if( M.coeff == NULL)
796  printf(" erreur : affichage d'une matrice vide \n") ;
797  printf(" nk = %d m_nli %d M_ncol %d \n",nk,M.nb_lignes,M.nb_colonnes) ;
798  for(j=0 ; j< M.nb_colonnes ; j++)
799  printf(" MATRICE nk= %d j= %d ---> %e \n",nk,j,M.coeff[nk][j]) ;
800  printf(" apres passage d'impression \n") ;
801  return ;
802 }
804 {
805 /* A[ligne][colonne] B[ligne][colonne] */
806 int i , j ;
807 double deter=0. ;
808 /* M est la matrice inverse de A */
809 
810  if(A.nb_lignes != A.nb_colonnes) {
811  printf( " attention matrice non inversible !!!! %d lignes %d colonnes \n",
812  A.nb_lignes,A.nb_colonnes) ;
813  return ;
814  }
815  zero_mat(M) ;
816  if(A.nb_lignes == 2) {
817  deter = A.coeff[0][0]*A.coeff[1][1] - A.coeff[0][1]*A.coeff[1][0] ;
818  M.coeff[0][0] = A.coeff[1][1]/deter ;
819  M.coeff[0][1] = -A.coeff[0][1]/deter ;
820  M.coeff[1][0] = -A.coeff[1][0]/deter ;
821  M.coeff[1][1] = A.coeff[0][0]/deter ;
822  }
823  else if(A.nb_lignes == 3) {
824  M.coeff[0][0]=A.coeff[1][1]*A.coeff[2][2]-A.coeff[2][1]*A.coeff[1][2] ;
825  M.coeff[1][1]=A.coeff[0][0]*A.coeff[2][2]-A.coeff[2][0]*A.coeff[0][2] ;
826 
827  M.coeff[2][2]=A.coeff[0][0]*A.coeff[1][1]-A.coeff[0][1]*A.coeff[1][0] ;
828  M.coeff[0][1]=A.coeff[2][1]*A.coeff[0][2]-A.coeff[0][1]*A.coeff[2][2] ;
829  M.coeff[0][2]=A.coeff[0][1]*A.coeff[1][2]-A.coeff[1][1]*A.coeff[0][2] ;
830  M.coeff[1][0]=A.coeff[1][2]*A.coeff[2][0]-A.coeff[1][0]*A.coeff[2][2] ;
831  M.coeff[1][2]=A.coeff[1][0]*A.coeff[0][2]-A.coeff[0][0]*A.coeff[1][2] ;
832  M.coeff[2][0]=A.coeff[1][0]*A.coeff[2][1]-A.coeff[1][1]*A.coeff[2][0] ;
833  M.coeff[2][1]=A.coeff[0][1]*A.coeff[2][0]-A.coeff[0][0]*A.coeff[2][1] ;
834  deter=A.coeff[0][0]*M.coeff[0][0]+A.coeff[1][0]*M.coeff[0][1]
835  +A.coeff[2][0]*M.coeff[0][2] ;
836  for ( i=0 ; i<3 ; i++ ) {
837  for ( j=0 ; j<3 ; j++ ) M.coeff[i][j] = M.coeff[i][j]/deter ;
838  }
839  }
840  else {
841  printf(" Attention , on ne peut inverser la MATRICE %d \n",A.nb_lignes) ;
842  return ;
843  }
844 
845  return ;
846 }
847 Double_t TFParams::polfit(Int_t ns ,Int_t imax , Double_t par3d[dimout] ,
848  Double_t errpj[dimmat][dimmat] ,double *adcpj )
849  {
850  double val , val2 , val3 , adfmx[dimmat] , parfp3[dimout] ;
851  double ius[dimmat], maskp3[dimmat] ;
852  double deglib,fit3,tm,h,xki2 ;
853  int i ,nus ,ilow,isup ;
854  val=adcpj[imax] ;
855  val2=val/2. ;
856  val3=val/3. ;
857  ilow=0 ;
858  isup=ns ;
859  deglib=-4. ;
860  for (i=0 ; i<ns ; i++ ){
861  deglib=deglib+1. ;
862  ius[i] = 1. ;
863  if((adcpj[i] < val3) && (i<imax) ){
864  ilow=i ;
865  }
866  if(adcpj[i] > val2 ){
867  isup=i ;
868  }
869  }
870  ilow=ilow+1 ;
871  if(ilow == imax )ilow=ilow-1 ;
872  if(isup-ilow < 3) isup=ilow+3 ;
873  nus=0 ;
874  for(i=ilow ; i<=isup ; i++){
875 
876  adfmx[nus]=adcpj[i] ;
877  maskp3[nus] =0. ;
878  if(ius[i] == 1) {
879  maskp3[nus]=1. ;
880  nus=nus+1 ;
881  }
882  }
883  if(nus < 4) return 10000. ;
884  xki2 = f3deg ( nus , parfp3 , maskp3 , adfmx , errpj ) ;
885  tm= parfp3[4] ;
886  h=parfp3[5] ;
887  tm=tm+(double)ilow ;
888  par3d[0] = h ;
889  par3d[1] = tm ;
890  fit3 = xki2 ;
891  return fit3 ;
892 }
893 double TFParams::f3deg ( int nmxu , double parom[dimout] , double mask[dimmat] , double adcpj[dimmat] , double errpj[dimmat][dimmat] ) {
894 /* */
895 /* fit 3rd degree polynomial */
896 /* nmxu = nb of samples in sample data array adcpj[]
897  parom values of parameters
898  errpj inverse of the error matrix
899  fplo3dg uses only the diagonal terms of errpj[][]
900 */
901  int i , k , l , iworst ;
902  double h , t2 , tm , delta , tmp ;
903  double xki2 , dif , difmx , deglib ;
904  double t[dimmat] , f[dimmat][4] ;
905  double cov[dimmat][dimmat] , bv[4] , invcov[dimmat][dimmat] , s , deter ;
906 
907  deglib=(double)nmxu - 4. ;
908  for ( i=0 ; i<nmxu ; i++ ) {
909  t[i]=i ;
910  f[i][0]=1. ;
911  f[i][1]=t[i] ;
912  f[i][2]=t[i]*t[i] ;
913  f[i][3]=f[i][2]*t[i] ;
914  }
915 /* computation of covariance matrix */
916  for ( k=0 ; k<4 ; k++ ) {
917  for ( l=0 ; l<4 ; l++ ) {
918  s=0. ;
919  for (i=0 ; i<nmxu ; i++ ) {
920  s=s+f[i][k]*f[i][l]*errpj[i][i]*mask[i] ;
921  }
922  cov[k][l]=s ;
923  }
924  s=0. ;
925  for (i=0 ; i<nmxu ; i++ ) {
926  s=s+f[i][k]*adcpj[i]*errpj[i][i]*mask[i] ;
927  }
928  bv[k]=s ;
929  }
930 /* parameters */
931  deter = inverpj ( 4 , cov , invcov );
932  for ( k=0 ; k<4 ; k++ ) {
933  s=0. ;
934  for ( l=0 ; l<4 ; l++ ) {
935  s=s+bv[l]*invcov[l][k] ;
936  }
937  parom[k]=s ;
938  }
939 
940  if( parom[3] == 0. ){
941  parom[4] = -1000.;
942  parom[5] = -1000.;
943  parom[6] = -1000.;
944  return 1000000.;
945  }
946 /* worst hit and ki2 */
947  xki2=0. ;
948  difmx=0. ;
949  for (i=0 ; i<nmxu ; i++ ){
950  t2=t[i]*t[i] ;
951  h= parom[0]+parom[1]*t[i]+parom[2]*t2+parom[3]*t2*t[i] ;
952  dif=(adcpj[i]-h)*mask[i] ;
953  if(dif > difmx) {
954  iworst=i ;
955  difmx=dif ;
956  }
957  }
958  if(deglib > 0.5) xki2=xki2/deglib ;
959 /* amplitude and maximum position */
960  delta=parom[2]*parom[2]-3.*parom[3]*parom[1] ;
961  if(delta > 0.){
962  delta=sqrt(delta) ;
963  tm=-(delta+parom[2])/(3.*parom[3]) ;
964  tmp=(delta-parom[2])/(3.*parom[3]) ;
965  }
966  else{
967  parom[4] = -1000.;
968  parom[5] = -1000.;
969  parom[6] = -1000.;
970  return xki2 ;
971  }
972  parom[4]= tm ;
973  parom[5]= parom[0]+parom[1]*tm+parom[2]*tm*tm+parom[3]*tm*tm*tm ;
974  parom[6]= tmp ;
975  // printf("par --------> %f %f %f %f \n",parom[3],parom[2],parom[1],parom[0]);
976 
977  return xki2 ;
978 }
979 /*------------------------------------------------------------------*/
980 
981 double TFParams::inverpj(int n,double g[dimmat][dimmat],double ginv[dimmat][dimmat] )
982 {
983 /* */
984 /* inversion d une matrice symetrique definie positive de taille n */
985 /* J.P. Pansart Novembre 99 */
986 /* */
987 int i , j , k , jj ;
988 double r , s ;
989 double deter=0 ;
990 double al[dimmat][dimmat] , be[dimmat][dimmat] ;
991 /* initialisation */
992  for( i=0 ; i<n ; i++ ) {
993  for ( j=0 ; j<n ; j++ ) {
994  al[i][j] = 0. ;
995  be[i][j] = 0. ;
996  }
997  }
998 /* decomposition en vecteurs sur une base orthonormee */
999  al[0][0] = sqrt( g[0][0] ) ;
1000  for ( i=1 ; i<n ; i++ ) {
1001  al[i][0] = g[0][i] / al[0][0] ;
1002  for ( j=1 ; j<=i ; j++ ) {
1003  s=0. ;
1004  for ( k=0 ; k<=j-1 ; k++ ) {
1005  s=s+ al[i][k] * al[j][k] ;
1006  }
1007  r= g[i][j] - s ;
1008  if( j < i ) al[i][j] = r/al[j][j] ;
1009  if( j == i ) al[i][j] = sqrt ( r) ;
1010  }
1011  }
1012 /* inversion de la matrice al */
1013  be[0][0] = 1./al[0][0] ;
1014  for ( i=1 ; i<n ; i++ ) {
1015  be[i][i] = 1. / al[i][i] ;
1016  for ( j=0 ; j<i ; j++ ) {
1017  jj=i-j-1 ;
1018  s=0. ;
1019  for ( k=jj+1 ; k<=i ; k++ ) {
1020  s=s+ be[i][k] * al[k][jj] ;
1021  }
1022  be[i][jj]=-s/al[jj][jj] ;
1023  }
1024  }
1025 /* calcul de la matrice ginv */
1026  for ( i=0 ; i<n ; i++ ) {
1027  for ( j=0 ; j<n ; j++ ) {
1028  s=0. ;
1029  for ( k=0 ; k<n ; k++ ) {
1030  s=s+ be[k][i] * be[k][j] ;
1031  }
1032  ginv[i][j]=s ;
1033  // if (debug==1){
1034  //printf("valeur de la matrice %d %d %f \n",i,j,ginv[i][j]) ;
1035  //}
1036  }
1037  }
1038  return deter ;
1039 }
1040 /* */
1041 /* inversion d une matrice 3x3 */
1042 /* */
1043 double TFParams::inv3x3(double a[3][3] , double b[3][3] )
1044 {
1045 /* a[ligne][colonne] b[ligne][colonne] */
1046 int i , j ;
1047 double deter=0. ;
1048  b[0][0]=a[1][1]*a[2][2]-a[2][1]*a[1][2] ;
1049  b[1][1]=a[0][0]*a[2][2]-a[2][0]*a[0][2] ;
1050  b[2][2]=a[0][0]*a[1][1]-a[0][1]*a[1][0] ;
1051  printf("a[x][x] %e %e %e %e %e %e %e \n",a[0][0],a[1][1],a[0][1],a[1][0],
1052  a[0][0]*a[1][1],a[0][1]*a[1][0],b[2][2]);
1053  b[0][1]=a[2][1]*a[0][2]-a[0][1]*a[2][2] ;
1054  b[0][2]=a[0][1]*a[1][2]-a[1][1]*a[0][2] ;
1055  b[1][0]=a[1][2]*a[2][0]-a[1][0]*a[2][2] ;
1056  b[1][2]=a[1][0]*a[0][2]-a[0][0]*a[1][2] ;
1057  b[2][0]=a[1][0]*a[2][1]-a[1][1]*a[2][0] ;
1058  b[2][1]=a[0][1]*a[2][0]-a[0][0]*a[2][1] ;
1059  deter=a[0][0]*b[0][0] + a[1][0]*b[0][1] + a[2][0]*b[0][2] ;
1060  printf(" deter = %e \n",deter) ;
1061  for ( i=0 ; i<3 ; i++ ) {
1062  for ( j=0 ; j<3 ; j++ ) {
1063  printf(" avant division a[3][3] %d %d %e \n",i,j,a[i][j]) ;
1064  printf(" avant division b[3][3] %d %d %e %e \n",i,j,b[i][j],deter) ;
1065  b[i][j] = b[i][j]/deter ;
1066  printf(" valeur de b[3][3] apres division %d %d %e %e \n",i,j,b[i][j],deter) ;
1067  }
1068  }
1069  return deter ;
1070 }
1071 
1072 double TFParams::pulseShapepj( Double_t *x, Double_t *par )
1073 {
1074 
1075  Double_t fitfun;
1076  Double_t ped, h, tm, alpha, beta;
1077  Double_t dt, dtsbeta, albet, variab, puiss ;
1078  Double_t b1,b2,a1,a2 ;
1079  b1 = par[0] ;
1080  b2 = par[1] ;
1081  a1 = par[2] ;
1082  a2 = par[3] ;
1083 
1084  ped = 0. ;
1085  h = b1 ;
1086  tm = b2 ;
1087  alpha = a1 ;
1088  beta = a2 ;
1089  dt= x[0] - tm ;
1090  //printf(" par %f %f %f %f dt = %f albet = %f",b1,b2,a1,a2,dt,albet) ;
1091  albet = alpha*beta ;
1092  if( albet <= 0 )return( (Double_t)0. );
1093 
1094  if(dt > -albet) {
1095  dtsbeta=dt/beta ;
1096  variab=1.+dt/albet ;
1097  puiss=pow(variab,alpha);
1098  fitfun=h*puiss*exp(-dtsbeta) + ped;
1099  //printf(" dt = %f h = %f puiss = %f exp(-dtsbeta) %f \n",dt,h,puiss,
1100  // exp(-dtsbeta)) ;
1101  }
1102  else {
1103  fitfun = ped;
1104  }
1105 
1106  return fitfun;
1107 }
1108 
1109 double TFParams::lastShape( Double_t *x, Double_t *par )
1110 {
1111 
1112  Double_t fitfun;
1113  Double_t alpha, beta;
1114  Double_t dt,alphadt,exponent ;
1115  Double_t b1,b2 ;
1116  b1 = par[0] ;
1117  b2 = par[1] ;
1118  alpha = par[2] ;
1119  beta = par[3] ;
1120  dt= x[0] - b2 ;
1121  alphadt = alpha*dt ;
1122  exponent = -(alphadt+(exp(-alphadt)-1.))/beta ;
1123  fitfun = b1*exp(exponent) ;
1124  return fitfun;
1125 }
1126 double TFParams::lastShape2( Double_t *x, Double_t *par )
1127 {
1128 
1129  Double_t fitfun;
1130  Double_t alpha, beta;
1131  Double_t dt,expo1,dt2,exponent ;
1132  Double_t b1,b2 ;
1133  b1 = par[0] ;
1134  b2 = par[1] ;
1135  alpha = par[2] ;
1136  beta = par[3] ;
1137  dt= x[0] - b2 ;
1138  expo1 = exp(-beta*dt) ;
1139  dt2 = dt*dt ;
1140  exponent = -(alpha*dt2+(expo1-1.)) ;
1141  fitfun = b1*exp(exponent) ;
1142  return fitfun;
1143 }
1144 
1145 Double_t TFParams::pulseShapepj2( Double_t *x, Double_t *par )
1146 {
1147 
1148  Double_t fitfun;
1149  Double_t ped, h, tm, alpha, beta;
1150  Double_t dt, dtsbeta, albet, variab, puiss;
1151  Double_t b1,b2,a1,a2 ;
1152  b1 = par[0] ;
1153  b2 = par[1] ;
1154  a1 = par[2] ;
1155  a2 = par[3] ;
1156  ped = 0. ;
1157  h = b1 ;
1158  tm = b2 ;
1159  alpha = a1 ;
1160  beta = a2 ;
1161  dt= x[0] ;
1162  albet = alpha*beta ;
1163  if( albet <= 0 )return( (Double_t)0. );
1164 
1165  if(dt > -albet) {
1166  dtsbeta=dt/beta ;
1167  variab=1.+dt/albet ;
1168  puiss=pow(variab,alpha);
1169  fitfun=h*puiss*exp(-dtsbeta) + ped;
1170  }
1171  else {
1172  fitfun = ped;
1173  }
1174 
1175  /* printf( "fitfun %f %f %f %f, %f %f %f\n", ped, h, tm, alpha, beta, *x, fitfun ); */
1176 
1177  return fitfun;
1178 }
1179 
1180 double TFParams::parab(Double_t ampl[nsamp],Int_t nmin,Int_t nmax,Double_t parout[3])
1181 {
1182 /* Now we calculate the parabolic adjustement in order to get */
1183 /* maximum and time max */
1184 
1185  double denom,dt,amp1,amp2,amp3 ;
1186  double ampmax = 0. ;
1187  int imax = 0 ;
1188  int k ;
1189 /*
1190  */
1191  for ( k = nmin ; k < nmax ; k++) {
1192  if (ampl[k] > ampmax ) {
1193  ampmax = ampl[k] ;
1194  imax = k ;
1195  }
1196  }
1197  amp1 = ampl[imax-1] ;
1198  amp2 = ampl[imax] ;
1199  amp3 = ampl[imax+1] ;
1200  denom=2.*amp2-amp1-amp3 ;
1201 /* */
1202  if(denom>0.){
1203  dt =0.5*(amp3-amp1)/denom ;
1204  }
1205  else {
1206  //printf("denom =%f\n",denom) ;
1207  dt=0.5 ;
1208  }
1209 /* */
1210 /* ampmax correspond au maximum d'amplitude parabolique et dt */
1211 /* decalage en temps par rapport au sample maximum soit k + dt */
1212 
1213  parout[0] =amp2+(amp3-amp1)*dt*0.25 ;
1214  parout[1] = (double)imax + dt ;
1215  parout[2] = (double)imax ;
1216 return denom ;
1217 }
1218 
1219 double TFParams::mixShape( Double_t *x, Double_t *par )
1220 {
1221  Double_t fitval0,fitval;
1222  Double_t alpha,beta,fact,puiss;
1223  Double_t dt,alpha2dt,exponent ;
1224  Double_t b1,b2,alpha2,t ;
1225  b1 = par[0] ;
1226  b2 = par[1] ;
1227  alpha = par[2] ;
1228  alpha2 = par[3] ;
1229  beta = par[4] ;
1230 //
1231  t = x[0] ;
1232  dt= x[0]-b2 ;
1233 //
1234  if(t>0.) {
1235  fact = t/b2 ;
1236  puiss = pow(fact,alpha) ;
1237  fitval0 = puiss*exp(-alpha*dt/b2) ;
1238  }
1239  else
1240  {
1241  fitval0=1. ;
1242  }
1243  dt = x[0] - b2 ;
1244  alpha2dt = dt*alpha2 ;
1245  exponent = -(alpha2dt+(exp(-alpha2dt)-1.))/beta ;
1246  fitval = b1*fitval0*exp(exponent) ;
1247  return fitval;
1248 }
1249 //=========================
1250 // Method computePulseWidth
1251 //=========================
1252 double TFParams::computePulseWidth( int methode , double alpha_here , double beta_here){
1253 
1254 // level of amplitude where we calculate the width ( level = 0.5 if at 50 % )
1255 // (level = 0.3 if at 30 % )
1256  double level = 0.30 ;
1257 // fixed parameters
1258  double amplitude = 1.00 ;
1259  double offset = 7.00;
1260  double amp_max = amplitude;
1261 
1262 // steps in time
1263  double t_min = offset-4.50;
1264  double t_max = offset+12.50;
1265 
1266  int t_step_max = 3000;
1267  double delta_t = (double)((t_max-t_min)/t_step_max);
1268 
1269 // Loop over time ( Loop 2 --> get width )
1270  int t_amp_half_flag = 0;
1271  double t_amp_half_min = 999.;
1272  double t_amp_half_max = -999.;
1273 
1274  for (int t_step=0; t_step<t_step_max; t_step++){
1275 
1276  double t_val = t_min + (double)t_step*delta_t;
1277  double albet = alpha_here*beta_here ;
1278  double dt = t_val-offset ;
1279  double amp =0;
1280 
1281  if( methode == 2 ) { // electronic function
1282  if( (t_val-offset) > -albet) {
1283 
1284  amp = amplitude*TMath::Power( ( 1 + ( dt / (alpha_here*beta_here) ) ) , alpha_here ) * TMath::Exp(-1.0*(dt/beta_here));
1285  } else {
1286 
1287  amp = 1. ;
1288  }
1289  }
1290 
1291  if( amp > (amp_max*level) && t_amp_half_flag == 0) {
1292  t_amp_half_flag = 1;
1293  t_amp_half_min = t_val;
1294  }
1295 
1296  if( amp < (amp_max*level) && t_amp_half_flag == 1) {
1297  t_amp_half_flag = 2;
1298  t_amp_half_max = t_val;
1299  }
1300 
1301  }
1302 
1303 // Compute Width
1304  double width = (t_amp_half_max - t_amp_half_min);
1305 
1306  return width;
1307 }
1308 
1309 
const double Z[kNumberCalorimeter]
double pulseShapepj(Double_t *, Double_t *)
Definition: TFParams.cc:1072
const double beta
dbl * delta
Definition: mlp_gen.cc:36
float dt
Definition: AMPTWrapper.h:126
int i
Definition: DBlmapReader.cc:9
float alpha
Definition: AMPTWrapper.h:95
double_binary B
Definition: DDStreamer.cc:235
Double_t polfit(Int_t ns, Int_t imax, Double_t par3d[dimout], Double_t errpj[dimmat][dimmat], double *)
Definition: TFParams.cc:847
#define dimmat
Definition: TFParams.h:42
void print_mat_nk(matrice, int)
Definition: TFParams.cc:792
double computePulseWidth(int, double, double)
Definition: TFParams.cc:1252
#define X(str)
Definition: MuonsGrabber.cc:49
void somme_mat_int_scale(matrice, matrice, double)
Definition: TFParams.cc:689
void zero_mat(matrice)
Definition: TFParams.cc:778
#define NULL
Definition: scimark2.h:8
void produit_mat(matrice, matrice, matrice)
Definition: TFParams.cc:595
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
double inverpj(int, double g[dimmat][dimmat], double ginv[dimmat][dimmat])
Definition: TFParams.cc:981
#define nsamp
double ** coeff
Definition: TFParams.h:34
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
Definition: Activities.doc:4
void somme_mat_int(matrice, matrice)
Definition: TFParams.cc:672
return((rh^lh)&mask)
#define SDIM2
Definition: TFParams.h:26
void print_mat(matrice)
Definition: TFParams.cc:765
void transpose_mat(matrice, matrice)
Definition: TFParams.cc:699
void set_const(int, int, int, double, double, int)
Definition: TFParams.cc:581
double parab(double *, Int_t, Int_t, double *)
Definition: TFParams.cc:1180
T sqrt(T t)
Definition: SSEVec.h:28
int j
Definition: DBlmapReader.cc:9
matrice cree_mat_prod(matrice, matrice)
Definition: TFParams.cc:710
double f[11][100]
int nb_lignes
Definition: TFParams.h:32
unsigned int offset(bool)
void copie_colonne_mat(matrice, matrice, int)
Definition: TFParams.cc:655
int k[5][pyjets_maxn]
matrice cree_mat(int, int)
Definition: TFParams.cc:730
double pulseShapepj2(Double_t *, Double_t *)
Definition: TFParams.cc:1145
void inverse_mat(matrice, matrice)
Definition: TFParams.cc:803
double f3deg(int, double parom[dimout], double mask[dimmat], double adcpj[dimmat], double errpj[dimmat][dimmat])
Definition: TFParams.cc:893
Log< T >::type log(const T &t)
Definition: Log.h:22
void zero_mat_nk(matrice, int)
Definition: TFParams.cc:786
void fill_mat(matrice, matrice)
Definition: TFParams.cc:750
double b
Definition: hdecay.h:120
int nb_colonnes
Definition: TFParams.h:33
double lastShape(Double_t *, Double_t *)
Definition: TFParams.cc:1109
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
double a
Definition: hdecay.h:121
void produit_mat_int(matrice, matrice, matrice)
Definition: TFParams.cc:617
TFParams(int size=SDIM2, int size_sh=PLSHDIM)
Definition: TFParams.cc:26
tuple cout
Definition: gather_cfg.py:41
tuple level
Definition: testEve_cfg.py:34
double mixShape(Double_t *, Double_t *)
Definition: TFParams.cc:1219
string s
Definition: asciidump.py:422
void diff_mat(matrice, matrice, matrice)
Definition: TFParams.cc:636
#define ntrack
double lastShape2(Double_t *, Double_t *)
Definition: TFParams.cc:1126
#define debug
Definition: MEtoEDMFormat.h:34
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
double inv3x3(double a[3][3], double b[3][3])
Definition: TFParams.cc:1043
double fitpj(double **, double *, double **, double noise_val, int debug)
Definition: TFParams.cc:39
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
#define dimout
Definition: TFParams.h:43
const double par[8 *NPar][4]