/[PAMELA software]/tof/flight/ToFNuclei/src/ToFNuclei.cpp
ViewVC logotype

Diff of /tof/flight/ToFNuclei/src/ToFNuclei.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by pamelats, Mon Mar 2 11:42:51 2009 UTC revision 1.4 by pamelats, Thu Apr 16 13:43:40 2009 UTC
# Line 4  Line 4 
4  // by "Set_Beta" (ToFNuclei.h), the code is used as before.  // by "Set_Beta" (ToFNuclei.h), the code is used as before.
5  // If beta_in was set by the user using "Set_Beta", this beta  // If beta_in was set by the user using "Set_Beta", this beta
6  // is taken for the calculations.  // is taken for the calculations.
 //26-feb-2009: Inserted S115B calibartions from Lucia  
7  //  //
8    //26-feb-2009: Inserted S115B calibrations from Lucia
9    //
10    //02-apr-2009: bug found in some "if" statements for the
11    // "Layercharge" definition, but only important if ADC=4095
12    //
13    //15-apr-2009: small bug found in the calculation of the PMT
14    // charge, the charge for the PMTs 1,9,28.. was calculated
15    // twice, but the final result was OK
16    //
17  //*****************************************************  //*****************************************************
18  #include <ToFNuclei.h>  #include <ToFNuclei.h>
19    
# Line 450  if ((beta_mean > 0.05)  && (beta_mean < Line 458  if ((beta_mean > 0.05)  && (beta_mean <
458    
459           if (adc[pmtadc] < PMTsat[pmtadc]) {           if (adc[pmtadc] < PMTsat[pmtadc]) {
460  //----------------------------------------------------------------------------------------  //----------------------------------------------------------------------------------------
461  if ((pmtadc!=1) && (pmtadc!=9) || (pmtadc!=28) || (pmtadc!=29) || (pmtadc!=34)) {  if ((pmtadc!=1) && (pmtadc!=9) && (pmtadc!=28) && (pmtadc!=29) && (pmtadc!=34)) {
462    
463      for ( Int_t jj=0; jj<9; jj++ ){      for ( Int_t jj=0; jj<9; jj++ ){
464      x1[jj] = A0t[pmtadc][jj]+A1t[pmtadc][jj]*beta_mean+A2t[pmtadc][jj]*beta_mean*beta_mean;      x1[jj] = A0t[pmtadc][jj]+A1t[pmtadc][jj]*beta_mean+A2t[pmtadc][jj]*beta_mean*beta_mean;
# Line 460  if ((pmtadc!=1) && (pmtadc!=9) || (pmtad Line 468  if ((pmtadc!=1) && (pmtadc!=9) || (pmtad
468      TGraph *gr2 = new TGraph(n1,x1,y1);      TGraph *gr2 = new TGraph(n1,x1,y1);
469      TSpline3 *spl2 = new TSpline3("grs",gr2);    // use a cubic spline      TSpline3 *spl2 = new TSpline3("grs",gr2);    // use a cubic spline
470      chelp = spl2->Eval(ym);      chelp = spl2->Eval(ym);
471        if (chelp<0.) chelp=0.0001;  //WM new
472      charge = TMath::Sqrt(chelp);      charge = TMath::Sqrt(chelp);
473      gr2->Delete();      gr2->Delete();
474      spl2->Delete();      spl2->Delete();
# Line 476  if ((pmtadc==1) || (pmtadc==9) || (pmtad Line 485  if ((pmtadc==1) || (pmtadc==9) || (pmtad
485           m = (C0t[pmtadc][jj+1]*C0t[pmtadc][jj+1] - C0t[pmtadc][jj]*C0t[pmtadc][jj]) / (yh - yl);           m = (C0t[pmtadc][jj+1]*C0t[pmtadc][jj+1] - C0t[pmtadc][jj]*C0t[pmtadc][jj]) / (yh - yl);
486           b = (C0t[pmtadc][jj]*C0t[pmtadc][jj]) - m*yl;           b = (C0t[pmtadc][jj]*C0t[pmtadc][jj]) - m*yl;
487           chelp = m*ym + b;           chelp = m*ym + b;
488             if (chelp<0.) chelp=0.0001;  //WM new
489           charge= TMath::Sqrt(chelp);           charge= TMath::Sqrt(chelp);
490           PMTcharge_arr[pmtadc] = charge;           PMTcharge_arr[pmtadc] = charge;
491                               }                               }
# Line 518  if (jj == -1) Layerinfo[ilay] = -1; Line 528  if (jj == -1) Layerinfo[ilay] = -1;
528    
529  if (jj != -1) {  if (jj != -1) {
530  Int_t ih = ihelp_a[ilay] + 2*jj;  Int_t ih = ihelp_a[ilay] + 2*jj;
531    
532    // New WM
533    Int_t igood1=0;
534    Int_t igood2=0;
535    if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih] > 0.)) igood1=1;
536    if ((PMTcharge_arr[ih+1] < 1000.) && (PMTcharge_arr[ih+1] > 0.)) igood2=1;
537    
538    if ((PMTcharge_arr[ih]==0.) && (PMTcharge_arr[ih+1]==0.))  xhelp = 0.;
539    if ((igood1==1)&&(igood2==1)) xhelp = 0.5*(PMTcharge_arr[ih]+PMTcharge_arr[ih+1]) ;
540    if ((igood1==1)&&(igood2==0)) xhelp = PMTcharge_arr[ih];
541    if ((igood2==1)&&(igood1==0)) xhelp = PMTcharge_arr[ih+1];
542    
543    
544    /*
545  if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih+1] < 1000.)) xhelp = 0.5*(PMTcharge_arr[ih]+PMTcharge_arr[ih+1]) ;  if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih+1] < 1000.)) xhelp = 0.5*(PMTcharge_arr[ih]+PMTcharge_arr[ih+1]) ;
546  if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih+1]==1000.))  xhelp = PMTcharge_arr[ih] ;  if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih+1]==1000.))  xhelp = PMTcharge_arr[ih] ;
547  if ((PMTcharge_arr[ih]==1000.) && (PMTcharge_arr[ih+1] < 1000.))  xhelp = PMTcharge_arr[ih+1] ;  if ((PMTcharge_arr[ih]==1000.) && (PMTcharge_arr[ih+1] < 1000.))  xhelp = PMTcharge_arr[ih+1] ;
548    */
549     if (adc[ih] ==  4095) Layerinfo[ilay] = Layerinfo[ilay] + 1;     if (adc[ih] ==  4095) Layerinfo[ilay] = Layerinfo[ilay] + 1;
550     if (adc[ih+1] ==  4095) Layerinfo[ilay] = Layerinfo[ilay] + 1;     if (adc[ih+1] ==  4095) Layerinfo[ilay] = Layerinfo[ilay] + 1;
551     if ((adc[ih] > PMTsat[ih]) && (adc[ih] < 4095)) Layerinfo[ilay] = Layerinfo[ilay] + 10;     if ((adc[ih] > PMTsat[ih]) && (adc[ih] < 4095)) Layerinfo[ilay] = Layerinfo[ilay] + 10;
# Line 893  if ((beta_mean < 0.05)  || (beta_mean > Line 917  if ((beta_mean < 0.05)  || (beta_mean >
917                                                                                    
918           if (adc[pmtadc] < PMTsat[pmtadc]) {           if (adc[pmtadc] < PMTsat[pmtadc]) {
919    
920  if ((pmtadc!=4) && (pmtadc!=8) || (pmtadc!=28) || (pmtadc!=31) || (pmtadc!=34) || (pmtadc!=39) && (pmtadc!=41) || (pmtadc!=46)) {  if ((pmtadc!=4) && (pmtadc!=8) && (pmtadc!=28) && (pmtadc!=31) && (pmtadc!=34) && (pmtadc!=39) && (pmtadc!=41) && (pmtadc!=46)) {
921    
922      for ( Int_t jj=0; jj<9; jj++ ){      for ( Int_t jj=0; jj<9; jj++ ){
923      x1[jj] = A0t[pmtadc][jj]+A1t[pmtadc][jj]*beta_mean+A2t[pmtadc][jj]*beta_mean*beta_mean;      x1[jj] = A0t[pmtadc][jj]+A1t[pmtadc][jj]*beta_mean+A2t[pmtadc][jj]*beta_mean*beta_mean;
# Line 906  if ((pmtadc!=4) && (pmtadc!=8) || (pmtad Line 930  if ((pmtadc!=4) && (pmtadc!=8) || (pmtad
930      TGraph *gr2 = new TGraph(n1,x1,y1);      TGraph *gr2 = new TGraph(n1,x1,y1);
931      TSpline3 *spl2 = new TSpline3("grs",gr2);    // use a cubic spline      TSpline3 *spl2 = new TSpline3("grs",gr2);    // use a cubic spline
932      chelp = spl2->Eval(ym);      chelp = spl2->Eval(ym);
933        if (chelp<0.) chelp=0.0001;  //WM new
934      charge = TMath::Sqrt(chelp);      charge = TMath::Sqrt(chelp);
935    
936      gr2->Delete();      gr2->Delete();
# Line 921  if ((pmtadc==4) && (pmtadc==8) || (pmtad Line 946  if ((pmtadc==4) && (pmtadc==8) || (pmtad
946           m = (C0t[pmtadc][jj+1]*C0t[pmtadc][jj+1] - C0t[pmtadc][jj]*C0t[pmtadc][jj]) / (yh - yl);           m = (C0t[pmtadc][jj+1]*C0t[pmtadc][jj+1] - C0t[pmtadc][jj]*C0t[pmtadc][jj]) / (yh - yl);
947           b = (C0t[pmtadc][jj]*C0t[pmtadc][jj]) - m*yl;           b = (C0t[pmtadc][jj]*C0t[pmtadc][jj]) - m*yl;
948           chelp = m*ym + b;           chelp = m*ym + b;
949             if (chelp<0.) chelp=0.0001;  //WM new
950           charge= TMath::Sqrt(chelp);           charge= TMath::Sqrt(chelp);
951           PMTcharge_arr[pmtadc] = charge;           PMTcharge_arr[pmtadc] = charge;
952                               }                               }
# Line 979  if (jj == -1) Layerinfo[ilay] = -1; Line 1005  if (jj == -1) Layerinfo[ilay] = -1;
1005    
1006  if (jj != -1) {  if (jj != -1) {
1007  Int_t ih = ihelp_a[ilay] + 2*jj;  Int_t ih = ihelp_a[ilay] + 2*jj;
1008    
1009    // New WM
1010    Int_t igood1=0;
1011    Int_t igood2=0;
1012    if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih] > 0.)) igood1=1;
1013    if ((PMTcharge_arr[ih+1] < 1000.) && (PMTcharge_arr[ih+1] > 0.)) igood2=1;
1014    
1015    if ((PMTcharge_arr[ih]==0.) && (PMTcharge_arr[ih+1]==0.))  xhelp = 0.;
1016    if ((igood1==1)&&(igood2==1)) xhelp = 0.5*(PMTcharge_arr[ih]+PMTcharge_arr[ih+1]) ;
1017    if ((igood1==1)&&(igood2==0)) xhelp = PMTcharge_arr[ih];
1018    if ((igood2==1)&&(igood1==0)) xhelp = PMTcharge_arr[ih+1];
1019    
1020    
1021    /*
1022  if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih+1] < 1000.)) xhelp = 0.5*(PMTcharge_arr[ih]+PMTcharge_arr[ih+1]) ;  if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih+1] < 1000.)) xhelp = 0.5*(PMTcharge_arr[ih]+PMTcharge_arr[ih+1]) ;
1023  if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih+1]==1000.))  xhelp = PMTcharge_arr[ih] ;  if ((PMTcharge_arr[ih] < 1000.) && (PMTcharge_arr[ih+1]==1000.))  xhelp = PMTcharge_arr[ih] ;
1024  if ((PMTcharge_arr[ih]==1000.) && (PMTcharge_arr[ih+1] < 1000.))  xhelp = PMTcharge_arr[ih+1] ;  if ((PMTcharge_arr[ih]==1000.) && (PMTcharge_arr[ih+1] < 1000.))  xhelp = PMTcharge_arr[ih+1] ;
1025    */
1026    
1027     if (adc[ih] ==  4095) Layerinfo[ilay] = Layerinfo[ilay] + 1;     if (adc[ih] ==  4095) Layerinfo[ilay] = Layerinfo[ilay] + 1;
1028     if (adc[ih+1] ==  4095) Layerinfo[ilay] = Layerinfo[ilay] + 1;     if (adc[ih+1] ==  4095) Layerinfo[ilay] = Layerinfo[ilay] + 1;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.23