Subversion Repositories f9daq

Rev

Rev 167 | Rev 173 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 167 Rev 172
Line 27... Line 27...
27
   char *cTemp;
27
   char *cTemp;
28
   file_info.fFileTypes = filetypes;
28
   file_info.fFileTypes = filetypes;
29
//   cTemp = new char[1024];
29
//   cTemp = new char[1024];
30
//   sprintf(cTemp, "%s/results", rootdir);
30
//   sprintf(cTemp, "%s/results", rootdir);
31
//   file_info.fIniDir = StrDup(cTemp);
31
//   file_info.fIniDir = StrDup(cTemp);
32
   file_info.fIniDir = StrDup(currentOpenDir);
32
   file_info.fIniDir = StrDup(currentAnalDir);
33
   file_info.fMultipleSelection = kFALSE;
33
   file_info.fMultipleSelection = kFALSE;
34
   new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDOpen, &file_info);
34
   new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDOpen, &file_info);
35
//   delete[] cTemp;
35
//   delete[] cTemp;
36
 
36
 
37
   if(file_info.fFilename != NULL)
37
   if(file_info.fFilename != NULL)
Line 56... Line 56...
56
      resol2d->widgetNE[0]->SetNumber(40);
56
      resol2d->widgetNE[0]->SetNumber(40);
57
      resol2d->widgetNE[1]->SetNumber(40);
57
      resol2d->widgetNE[1]->SetNumber(40);
58
   }
58
   }
59
   else if(analTab->GetCurrent() == 1)  // Relative PDE
59
   else if(analTab->GetCurrent() == 1)  // Relative PDE
60
   {
60
   {
61
      relPde->widgetChBox[1]->SetState(kButtonDown);
61
      relPde->widgetChBox[0]->SetState(kButtonDown);
62
      midPeak->widgetChBox[0]->SetState(kButtonUp);
62
      midPeak->widgetChBox[0]->SetState(kButtonUp);
63
      zeroAngle->widgetNE[0]->SetNumber(0.00);
63
      zeroAngle->widgetNE[0]->SetNumber(0.00);
64
   }
64
   }
65
   else if(analTab->GetCurrent() == 2)  // Breakdown voltage
65
   else if(analTab->GetCurrent() == 2)  // Breakdown voltage
66
   {
66
   {
Line 368... Line 368...
368
            gCanvas = tempAnalysisCanvas->GetCanvas();
368
            gCanvas = tempAnalysisCanvas->GetCanvas();
369
 
369
 
370
         double range[4];
370
         double range[4];
371
         TGraph2D *gScan2D;
371
         TGraph2D *gScan2D;
372
         gScan2D = new TGraph2D();
372
         gScan2D = new TGraph2D();
-
 
373
         gScan2D->SetName("edgescan");
373
         range[0] = TMath::MinElement(nrfiles, surfxy);
374
         range[0] = TMath::MinElement(nrfiles, surfxy);
374
         range[1] = TMath::MaxElement(nrfiles, surfxy);
375
         range[1] = TMath::MaxElement(nrfiles, surfxy);
375
         range[2] = TMath::MinElement(nrfiles, surfz);
376
         range[2] = TMath::MinElement(nrfiles, surfz);
376
         range[3] = TMath::MaxElement(nrfiles, surfz);
377
         range[3] = TMath::MaxElement(nrfiles, surfz);
377
 
378
 
Line 894... Line 895...
894
       
895
       
895
               j++;
896
               j++;
896
               if(j > 50) break;
897
               if(j > 50) break;
897
            }
898
            }
898
 
899
 
899
            if(npeaks > 1)
900
            if( (npeaks > 1) && (nrfit > 1) )
900
            {
901
            {
901
               int bin = histtemp->GetXaxis()->FindBin((int)(meanparam+meansel[sortindex[1]])/2);
902
               int bin = histtemp->GetXaxis()->FindBin((int)(meanparam+meansel[sortindex[1]])/2);
902
               adcpedestal[0] = (meanparam+meansel[sortindex[1]])/2;
903
               adcpedestal[0] = (meanparam+meansel[sortindex[1]])/2;
903
               printf("PhotonMu(): multipeak x = %d, ", adcpedestal[0]);
904
               printf("PhotonMu(): multipeak x = %d, ", adcpedestal[0]);
904
               adcpedestal[1] = histtemp->GetBinContent(bin);
905
               adcpedestal[1] = histtemp->GetBinContent(bin);
Line 991... Line 992...
991
            integralPedestal[i] += (double)m2;
992
            integralPedestal[i] += (double)m2;
992
            printf("PhotonMu(): %lf: Pedestal integral (%d evts) = %lf\n", angle[i], k2, integralPedestal[i]);
993
            printf("PhotonMu(): %lf: Pedestal integral (%d evts) = %lf\n", angle[i], k2, integralPedestal[i]);
993
            if( (angle[i] == zeroAngle->widgetNE[0]->GetNumber()) && (darkhist != i) )
994
            if( (angle[i] == zeroAngle->widgetNE[0]->GetNumber()) && (darkhist != i) )
994
               zeromu = i;
995
               zeromu = i;
995
 
996
 
-
 
997
            // Checking for errors when fitting a histogram
-
 
998
            if(k2 == 0)
-
 
999
            {
-
 
1000
               printf("PhotonMu(): No pedestal entries found. Check the fitting results.\n");
-
 
1001
               muval[i] = -1;
-
 
1002
            }
-
 
1003
            else
996
            muval[i] = -TMath::Log((double)k2/(double)k);
1004
               muval[i] = -TMath::Log((double)k2/(double)k);
997
            printf("PhotonMu(): %lf: muval = %lf\n", angle[i], muval[i]);
1005
            printf("PhotonMu(): %lf: muval = %lf\n", angle[i], muval[i]);
998
 
1006
 
999
            inroot->Close();
1007
            inroot->Close();
1000
            delete inroot;
1008
            delete inroot;
1001
         }
1009
         }
1002
 
1010
 
1003
         // Update the progress bar
1011
         // Update the progress bar
1004
         progVal = (float)(90.00/nrfiles)*i;
1012
         progVal = (float)(90.00/nrfiles)*i;
1005
         analysisProgress->widgetPB->SetPosition(progVal);
1013
         analysisProgress->widgetPB->SetPosition(progVal);
1006
         gVirtualX->Update(1);
1014
         gVirtualX->Update(1);
1007
      }
1015
      }
1008
 
1016
 
1009
      printf("PhotonMu(): %d files were selected.\n", nrfiles);
1017
      printf("PhotonMu(): %d files were selected.\n", nrfiles);
1010
 
1018
 
1011
      printf("PhotonMu(): angle\tmu\trelative PDE\n");
1019
      printf("PhotonMu(): angle\tmu\trelative PDE\n");
1012
      m = 0;
1020
      m = 0;
1013
     
1021
     
1014
      // Set the 0 degree muval, reuse meansel[1]
1022
      // Set the 0 degree muval, reuse meansel[1]
1015
      meansel[1] = muval[zeromu];
1023
      meansel[1] = muval[zeromu];
Line 1018... Line 1026...
1018
      // TODO - point estimation still not working correctly!
1026
      // TODO - point estimation still not working correctly!
1019
      for(int i = 0; i < (int)nrfiles; i++)
1027
      for(int i = 0; i < (int)nrfiles; i++)
1020
      {
1028
      {
1021
         // Estimate next point and check error (5 point least square fit estimation)
1029
         // Estimate next point and check error (5 point least square fit estimation)
1022
         if( ((i > 4) && (m == i)) || ((i > 5) && (m < i)) )
1030
         if( ((i > 4) && (m == i)) || ((i > 5) && (m < i)) )
1023
         {
1031
         {
1024
            // Set exclude signal to false
1032
            // Set exclude signal to false
1025
            exclude = false;
1033
            exclude = false;
1026
 
1034
 
1027
            // Get next point values (if zero value -> need to add the dark hist value again)
1035
            // Get next point values (if zero value -> need to add the dark hist value again)
1028
            pointest[10] = angle[i];
1036
            pointest[10] = angle[i];
Line 1031... Line 1039...
1031
            // Check if next point has larger error than acceptable (if yes, set exclude signal to true), reuse meansel[0]
1039
            // Check if next point has larger error than acceptable (if yes, set exclude signal to true), reuse meansel[0]
1032
            meansel[0] = PointEstimate(5, pointest);    // PointEstimate only works with very small step size
1040
            meansel[0] = PointEstimate(5, pointest);    // PointEstimate only works with very small step size
1033
            if(meansel[0] > accError->widgetNE[0]->GetNumber())
1041
            if(meansel[0] > accError->widgetNE[0]->GetNumber())
1034
            {
1042
            {
1035
               printf("PhotonMu(): Point (%lf, %lf) excluded due to error: %lf\n", pointest[10], pointest[11], meansel[0]);
1043
               printf("PhotonMu(): Point (%lf, %lf) excluded due to error: %lf\n", pointest[10], pointest[11], meansel[0]);
1036
               exclude = true;
1044
               exclude = true;
1037
            }
1045
            }
1038
 
1046
 
1039
            // Value with 0 angle and dark histogram are always needed, so should not be excluded
1047
            // Value with 0 angle and dark histogram are always needed, so should not be excluded
1040
            if(i == darkhist)
1048
            if(i == darkhist)
1041
               exclude = false;
1049
               exclude = false;
-
 
1050
 
-
 
1051
            // Wrong fit
-
 
1052
            if(muval[i] == -1)
-
 
1053
               exclude = true;
1042
 
1054
 
1043
            // If nothing excluded, pass the points in pointest variable like in a FIFO
1055
            // If nothing excluded, pass the points in pointest variable like in a FIFO
1044
            if(!exclude)
1056
            if(!exclude)
1045
            {
1057
            {
1046
               for(int j = 0; j < 10; j++)
1058
               for(int j = 0; j < 10; j++)
Line 1058... Line 1070...
1058
         else
1070
         else
1059
         {
1071
         {
1060
            // First 5 points act as estimator points for next one
1072
            // First 5 points act as estimator points for next one
1061
            pointest[2*m] = angle[i];
1073
            pointest[2*m] = angle[i];
1062
            pointest[2*m+1] = muval[i];
1074
            pointest[2*m+1] = muval[i];
1063
         }
1075
         }
1064
 
1076
 
1065
         // Run only if we have a dark run histogram and middle pedestal peak estimation
1077
         // Run only if we have a dark run histogram and middle pedestal peak estimation
1066
         if( (darkhist != -1) && midPeak->widgetChBox[0]->IsDown() )
1078
         if( (darkhist != -1) && midPeak->widgetChBox[0]->IsDown() )
1067
         {
1079
         {
1068
            if(DBGSIG) printf("PhotonMu(): m = %d, i = %d: muval = %lf, ", m, i, muval[i]);
1080
            if(DBGSIG) printf("PhotonMu(): m = %d, i = %d: muval = %lf, ", m, i, muval[i]);
Line 1097... Line 1109...
1097
         printf("PhotonMu(): %lf\t%lf\t%lf\n", angle[i], muval[i], pdeval[i]);
1109
         printf("PhotonMu(): %lf\t%lf\t%lf\n", angle[i], muval[i], pdeval[i]);
1098
      }
1110
      }
1099
 
1111
 
1100
      // Check for range of values to plot
1112
      // Check for range of values to plot
1101
      double plotMax = 0.;
1113
      double plotMax = 0.;
1102
      for(int i = 0; i < (int)nrfiles; i++)
1114
      for(int i = 0; i < (int)nrfiles; i++)
1103
      {
1115
      {
1104
         plotMax = TMath::Max(plotMax, muval[i]);
1116
         plotMax = TMath::Max(plotMax, muval[i]);
1105
         plotMax = TMath::Max(plotMax, pdeval[i]);
1117
         plotMax = TMath::Max(plotMax, pdeval[i]);
1106
      }
1118
      }
1107
      if(plotMax <= 0.)
1119
      if(plotMax <= 0.)
Line 1308... Line 1320...
1308
               j+=3;
1320
               j+=3;
1309
            }
1321
            }
1310
            TMath::Sort(nrfit, meansel, sortindex, kFALSE);
1322
            TMath::Sort(nrfit, meansel, sortindex, kFALSE);
1311
 
1323
 
1312
            fittingfunc->Draw("SAME");
1324
            fittingfunc->Draw("SAME");
1313
            analysisCanvas->GetCanvas()->Modified();
1325
            analysisCanvas->GetCanvas()->Modified();
1314
            analysisCanvas->GetCanvas()->Update();
1326
            analysisCanvas->GetCanvas()->Update();
1315
 
1327
 
1316
            meanparam = meansel[sortindex[0]];
1328
            meanparam = meansel[sortindex[0]];
1317
            meanparamerr = meanselerr[sortindex[0]];
1329
            meanparamerr = meanselerr[sortindex[0]];
1318
            paramsigma = sigmasel[sortindex[0]];
1330
            paramsigma = sigmasel[sortindex[0]];
1319
 
1331
 
Line 1738... Line 1750...
1738
         gCanvas = tempAnalysisCanvas->GetCanvas();
1750
         gCanvas = tempAnalysisCanvas->GetCanvas();
1739
 
1751
 
1740
      double range[4];
1752
      double range[4];
1741
      TGraph2D *gScan2D;
1753
      TGraph2D *gScan2D;
1742
      gScan2D = new TGraph2D();
1754
      gScan2D = new TGraph2D();
-
 
1755
      gScan2D->SetName("surfscan");
1743
      range[0] = TMath::MinElement(nrfiles, surfx);
1756
      range[0] = TMath::MinElement(nrfiles, surfx);
1744
      range[1] = TMath::MaxElement(nrfiles, surfx);
1757
      range[1] = TMath::MaxElement(nrfiles, surfx);
1745
      range[2] = TMath::MinElement(nrfiles, surfy);
1758
      range[2] = TMath::MinElement(nrfiles, surfy);
1746
      range[3] = TMath::MaxElement(nrfiles, surfy);
1759
      range[3] = TMath::MaxElement(nrfiles, surfy);
1747
 
1760
 
Line 1840... Line 1853...
1840
      }
1853
      }
1841
      else if(edit == 1)
1854
      else if(edit == 1)
1842
      {
1855
      {
1843
         gCanvas->Modified();
1856
         gCanvas->Modified();
1844
         gCanvas->Update();
1857
         gCanvas->Update();
-
 
1858
 
-
 
1859
         UpdateIntegrateSurface(-1);
1845
      }
1860
      }
1846
   }
1861
   }
1847
}
1862
}