//db = TSQLServer::Connect("mysql://jspc29.x-matter.uni-frankfurt.de","radhard","mimosa88");
try
{
- string selectquery = prepareSQLStatement("select `System`, `TempCooling`, COALESCE(`TempChipStart`,-10000) as `TempChipStart`, COALESCE(`TempChipEnd`,-10000) as `TempChipEnd`, `ChipNum`, `RadiationSource`, `Matrix`, `Clock`, `StorePath`, `ChipGen`,COALESCE(`VetoPeak`,-1) as `VetoPeak`,COALESCE(`SeedPeak`,-1) as `SeedPeak`,COALESCE(`SumPeak`,-1) as `SumPeak`,COALESCE(`Gain`,-1) as `Gain`,COALESCE(`Avg.Noise`,-1) as `Avg.Noise`,COALESCE(`Avg.Noise+`,-1) as `Avg.Noise+`,COALESCE(`Avg.Noise-`,-1) as `Avg.Noise-`,COALESCE(`CCE_1`,-1) as `CCE_1`,COALESCE(`CCE_25`,-1) as `CCE_25` from `radhard`.`labbook` WHERE `runnumber`=" + numberToString<>(labbook.runnumber));
+ string selectquery = prepareSQLStatement("select `System`, `TempCooling`, COALESCE(`TempChipStart`,-10000) as `TempChipStart`, COALESCE(`TempChipEnd`,-10000) as `TempChipEnd`, `ChipNum`, `RadiationSource`, `Matrix`, `Clock`, `StorePath`, `ChipGen`,COALESCE(`VetoPeak`,-1) as `VetoPeak`,COALESCE(`SeedPeak`,-1) as `SeedPeak`,COALESCE(`SumPeak`,-1) as `SumPeak`,COALESCE(`Gain`,-1) as `Gain`,COALESCE(`Avg.Noise`,-1) as `Avg.Noise`,COALESCE(`Avg.Noise+`,-1) as `Avg.Noise+`,COALESCE(`Avg.Noise-`,-1) as `Avg.Noise-`,COALESCE(`CCE_1`,-1) as `CCE_1`,COALESCE(`CCE_25`,-1) as `CCE_25`,COALESCE(`Frames_found`,-1) as `Frames_found` from `radhard`.`labbook` WHERE `runnumber`=" + numberToString<>(labbook.runnumber));
res = db->Query(selectquery.c_str());
nrows = res->GetRowCount();
if (nrows > 0)
labbook.NoiseAvgMinusDB = (rowsql->GetField(16) != NULL)?atoi(rowsql->GetField(16)):-1;
labbook.CCE_in_Perc_1DB = (rowsql->GetField(17) != NULL)?atoi(rowsql->GetField(17)):-1;
labbook.CCE_in_Perc_25DB = (rowsql->GetField(18) != NULL)?atoi(rowsql->GetField(18)):-1;
+ labbook.frames_foundDB = (rowsql->GetField(19) != NULL)?atoi(rowsql->GetField(19)):-1;
delete res;
if (labbook.chip.Length() > 0 && labbook.chipGen.Length() > 0) // versuche infos zum Chip aus der ChipDatenbank zu bekommen
{
histogramthresholdCalibrated.calibrated = histogramCalibrated.calibrated;
cout << colorwhite << "calculateCCE():" << endlr;
calculteCCE();
+ if (labbook.source.Contains("Sr90")) {
+ cout << colorwhite << "integrateSr90Spectra():" << endlr;
+ integrateSr90Spectra(histogramthresholdCalibrated.Seed);
+ }
cout << colorwhite << "updateDatabase():" << endlr;
updateDatabase();
cout << colorwhite << "delete MAPS class:" << endlr;
histogramthresholdCalibrated.avgNoise = histogramthreshold.avgNoise * gain;
histogramthresholdCalibrated.avgNoisePlus = histogramthreshold.avgNoisePlus * gain;
histogramthresholdCalibrated.avgNoiseMinus = histogramthreshold.avgNoiseMinus * gain;
+
return 1;
}
}
}
-void Run::constructUpdateString(string *sqlupdatequery, const string databasevaluename, const Float_t value, const int precision=3)
+void Run::constructUpdateString(string *sqlupdatequery, const string databasevaluename, const Double_t value, const int precision=3)
{
// cout << colorred << databasevaluename << " : " << value << endlr;
- if (!isinf(value))
+ if (!std::isinf(value))
{
if (value>0)
{
constructUpdateString(&sqlupdatequery, "CCE_1", CCE_in_Perc_1);
constructUpdateString(&sqlupdatequery, "CCE_25", CCE_in_Perc_25);
constructUpdateString(&sqlupdatequery, "Frames_found", frames_found,100000000);
+ constructUpdateString(&sqlupdatequery, "Sr90IntegralVal", sr90IntegralVal,1000000000);
if (sqlupdatequery.length()>0)
{
return 1;
}
+Bool_t Run::integrateSr90Spectra(TH1F* histogrampointer, Bool_t verbose)
+{
+ Float_t posMaxValHist = histogrampointer->GetXaxis()->GetXmax();
+
+ TH1F* smoothedcurce = (TH1F*)histogrampointer->Clone();
+ smoothedcurce->Smooth(4);
+
+ Int_t rising = 0;
+ Int_t bini =smoothedcurce->GetMaximumBin();
+ Float_t curval = smoothedcurce->GetXaxis()->GetBinCenter(bini);
+ Float_t thresholdbincurcandidate = 0;
+
+ do {
+ curval=smoothedcurce->GetBinContent(bini++);
+ if (curval*0.95 <= smoothedcurce->GetBinContent(bini))
+ {
+ rising++;
+// cout << "rising at " << smoothedcurce->GetXaxis()->GetBinCenter(bini) << " as " << curval << " < " << smoothedcurce->GetBinContent(bini) << endl; // debug
+ }
+ else
+ {
+ rising = 0;
+ thresholdbincurcandidate = bini;
+ }
+ } while (rising < 3 && bini<smoothedcurce->GetNbinsX());
+
+
+
+// histogrampointer->GetXaxis()->SetRange(histogrampointer->GetXaxis()->FindBin(0),histogrampointer->GetXaxis()->FindBin(posMaxValHist));
+// Float_t posNoiseMax= histogrampointer->GetMaximum();
+// histogrampointer->GetXaxis()->SetRange(posNoiseMax,histogrampointer->GetXaxis()->FindBin(posMaxValHist));
+// Float_t posChargeMax= histogrampointer->GetMaximum();
+
+ noisethresholdborder = histogrampointer->GetXaxis()->GetBinUpEdge(thresholdbincurcandidate);
+
+ if (verbose) {
+ cout << " Noise threshold at " << noisethresholdborder;
+ TString histtitle=histogrampointer->GetXaxis()->GetTitle();
+ if (histtitle.Contains("[e]"))
+ {
+ cout << " e" << endl;
+ if (noisethresholdborder > 300) {
+ cout << coloryellow << " This noise threshold seems too high, please check manually the " << histogrampointer->GetName() << " spectrum." << endlr;
+ }
+ }
+ else
+ {
+ cout << " ADU" << endl;
+ if (noisethresholdborder > 75) {
+ cout << coloryellow << " This noise threshold seems too high, please check manually the " << histogrampointer->GetName() << " spectrum." << endlr;
+ }
+ }
+ }
+ sr90IntegralVal = histogrampointer->IntegralAndError(thresholdbincurcandidate,histogrampointer->GetMaximumBin(), sr90IntegralErr);
+ sr90IntegralErr /= sr90IntegralVal/100;
+ cout << " ";
+ if (labbook.frames_foundDB>0 || frames_found>0)
+ {
+ sr90IntegralVal/=(labbook.frames_foundDB>0)?labbook.frames_foundDB:frames_found;
+ cout << "Scaled ";
+ }
+ cout << "Integral is " << Form("%e",sr90IntegralVal) << ", error " << sr90IntegralErr << "%" << endl;
+
+ return 0;
+}
+
Float_t Run::FitPerform(TH1F* histogrampointer, TString fitFuncType, Bool_t verbose)
{
Float_t posMax = 0;
Float_t posMax2 = 0;
Float_t posMaxValHist = histogrampointer->GetXaxis()->GetXmax();
- Float_t noiseborder = 90; // posMaxValHist/10 for USB system, the value is 90
+ Float_t noiseborder = (noisethresholdborder>0)?noisethresholdborder:90; // posMaxValHist/10 for USB system, the value is 90
if (doFits)
{
#include <iomanip>
#include <sstream>
#include "sys/stat.h"
-#include <math.h> /* isinf, sqrt */
+#include <cmath> /* isinf, sqrt */
#include <TSQLServer.h>
#include <TSQLResult.h>
/**
* @brief takes a float value and a precision and appends it to an SQL statement used to update the database
*/
- void constructUpdateString(string*, const string, const Float_t, int);
+ void constructUpdateString(string*, const string, const Double_t, int);
/**
* @brief A structure to hold information about a given sensor, like number of #columns and #rows
Bool_t binSeedSumVeto();
/// noise quantiles: mean value, sigma in postive direction and sigma in negative direction
Double_t noisequantiles[3];
+
TCanvas* plot1DHistogram(TH1F* onehistogram, TString fitFuncType = "landau", TString titlestr = "", TString legendstr = "");
/**
* @brief intern function to calculate and plot fit curve to given histogram
*
- * @param histNtuple histogram pointer to calculate fit to
+ * @param histogrampointer histogram pointer to calculate fit to
* @return peak position of the fit
*
*/
Float_t FitPerform(TH1F*, TString fitFuncType="landau", Bool_t verbose=true);
-
-
+
+ /**
+ * @brief find the border between the noise and the signal in Sr90 runs
+ *
+ * writes the found threshold into the private variable #posNoiseThreshold
+ *
+ * @param histogrampointer pointer to the histogram structure, threshold will be searched in seed spectra
+ * @return true if succesfull
+ *
+ */
+ Bool_t integrateSr90Spectra(TH1F* histogrampointer, Bool_t verbose=true);
+
/**
* @brief rescales all histograms from ADU to electrons */
};
systemparam systemparamUSB {
2800, // maxbin;
- 2800/8,// nbins;
+ 2800/4,// nbins;
25, //vetothreshold
10,
100
Int_t clock = 100;
/// path to the RAW files as seen from system which took the run
TString storepath = "";
+ /// number of frames analyzed for this run
+ Int_t frames_foundDB = -1;
};
/// stores information from the SQL database of a given run
labbooksctruct labbook;
Float_t CCE_in_Perc_25=0;
/// Charge collection efficciency of the seed pixel in percent
Float_t CCE_in_Perc_1=0;
+ /// threshold for integrating the Sr90 spectrum, is set dynamically in @c integrateSr90Spectra()
+ Float_t noisethresholdborder = -1;
+ /// Integral value, after integrating from #noisethresholdborder to maxbin.
+ Double_t sr90IntegralVal = -1;
+ Double_t sr90IntegralErr = -1;
+
+
/// specific string wich encodes the database information of the run
TString runcode="";