storepathRAWLinux=Form("/d/garlic/%s/%d",labbook.chipGen.Data(),runnumber); // default empty path
}
savepathresults = storepathOutLinux;
- labbook.posVetoDB = (rowsql->GetField(10) != NULL)?atoi(rowsql->GetField(10)):-1;
- labbook.posSeedDB = (rowsql->GetField(11) != NULL)?atoi(rowsql->GetField(11)):-1;
- labbook.posSumDB = (rowsql->GetField(12) != NULL)?atoi(rowsql->GetField(12)):-1;
- labbook.gainDB = (rowsql->GetField(13) != NULL)?atoi(rowsql->GetField(13)):-1;
- labbook.NoiseAvgDB = (rowsql->GetField(14) != NULL)?atoi(rowsql->GetField(14)):-1;
- labbook.NoiseAvgPlusDB = (rowsql->GetField(15) != NULL)?atoi(rowsql->GetField(15)):-1;
- 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.posVetoDB = (rowsql->GetField(10) != NULL)?atof(rowsql->GetField(10)):-1;
+ labbook.posSeedDB = (rowsql->GetField(11) != NULL)?atof(rowsql->GetField(11)):-1;
+ labbook.posSumDB = (rowsql->GetField(12) != NULL)?atof(rowsql->GetField(12)):-1;
+ labbook.gainDB = (rowsql->GetField(13) != NULL)?atof(rowsql->GetField(13)):-1;
+ labbook.NoiseAvgDB = (rowsql->GetField(14) != NULL)?atof(rowsql->GetField(14)):-1;
+ labbook.NoiseAvgPlusDB = (rowsql->GetField(15) != NULL)?atof(rowsql->GetField(15)):-1;
+ labbook.NoiseAvgMinusDB = (rowsql->GetField(16) != NULL)?atof(rowsql->GetField(16)):-1;
+ labbook.CCE_in_Perc_1DB = (rowsql->GetField(17) != NULL)?atof(rowsql->GetField(17)):-1;
+ labbook.CCE_in_Perc_25DB = (rowsql->GetField(18) != NULL)?atof(rowsql->GetField(18)):-1;
labbook.frames_foundDB = (rowsql->GetField(19) != NULL)?atoi(rowsql->GetField(19)):-1;
// labbook.frames_Analyzed = (rowsql->GetField(20) != NULL)?atoi(rowsql->GetField(20)):-1;
delete res;
cout << "| NoiseAvgMinusDB: " << std::right << colorwhite << labbook.NoiseAvgMinusDB << endlr;
cout << "| CCE_in_Perc_25DB:" << std::right << colorwhite << labbook.CCE_in_Perc_25DB << endlr;
cout << "| CCE_in_Perc_1DB: " << std::right << colorwhite << labbook.CCE_in_Perc_1DB << endlr;
+ cout << "| frames_foundDB : " << std::right << colorwhite << labbook.frames_foundDB << endlr;
cout << "|______________________________ " << endlr;
cout << endlr;
return 0;
return 0;
}
+Bool_t Run::setFixedThresholdValueElectrons(Float_t thresholdValueIne)
+{
+ if (labbook.gainDB > 0) {
+ cout << " Fixed threshold value : " << colorwhite << thresholdValueIne << " e" << colorreset << " <-- only used if RAW files are analyzed, force analysis to make sure" << endl;
+ processed->fFixedThresholdValueInADU = thresholdValueIne / labbook.gainDB;
+ return 0;
+ }
+ else
+ {
+ cout << colorred << "Could not set value for fixed threshold to " << thresholdValueIne << ", no calibration done yet. Please rerun after first analysis." <<endlr;
+ }
+ return 1;
+}
+
+Bool_t Run::setFixedThresholdValueADU(Float_t thresholdValue)
+{
+ cout<<" Fixed threshold value : " << colorwhite << thresholdValue << " ADU" << colorreset << " <-- only used if RAW files are analyzed, force analysis to make sure" << endl;
+ processed->fFixedThresholdValueInADU = thresholdValue;
+ return 0;
+}
+
Bool_t Run::setResultsPath(TString path)
{
cout << "Changing save directory to '" << path << "'" << endl;
calculteCCE();
if (labbook.source.Contains("Sr90")) {
cout << colorwhite << "integrateSr90Spectra():" << endlr;
- integrateSr90Spectra(histogramthresholdCalibrated.Seed);
+ integrateSr90Spectra(&histogramthresholdCalibrated, histogramthresholdCalibrated.Seed);
}
cout << colorwhite << "updateDatabase():" << endlr;
updateDatabase();
constructUpdateString(&sqlupdatequery, "CCE_25", CCE_in_Perc_25);
constructUpdateString(&sqlupdatequery, "Avg.NoiseADC", histogram.avgNoise);
constructUpdateString(&sqlupdatequery, "Frames_found", frames_found,100000000);
- constructUpdateString(&sqlupdatequery, "Sr90IntegralVal", sr90IntegralVal,1000000000);
+ constructUpdateString(&sqlupdatequery, "Sr90IntegralVal", histogramthresholdCalibrated.sr90IntegralVal,1000000000);
if (sqlupdatequery.length()>0)
{
}
// gROOT->SetBatch(kTRUE);
if (labbook.source.Contains("Fe")||labbook.source.Contains("Cd"))
- histogram.posVeto=FitPerform(histogram.Veto, "gaus", true);
- histogram.posSeed=FitPerform(histogram.Seed, "landau", true);
- histogram.posSum=FitPerform(histogram.Sum, "gaus", true);
+ histogram.posVeto=FitPerform(&histogram, histogram.Veto, "gaus", true);
+ histogram.posSeed=FitPerform(&histogram, histogram.Seed, "landau", true);
+ histogram.posSum=FitPerform(&histogram, histogram.Sum, "gaus", true);
if (labbook.source.Contains("Fe")||labbook.source.Contains("Cd"))
- histogramthreshold.posVeto=FitPerform(histogram.Veto, "gaus", false);
- histogramthreshold.posSeed=FitPerform(histogram.Seed, "landau", false);
- histogramthreshold.posSum=FitPerform(histogram.Sum, "gaus", false);
+ histogramthreshold.posVeto=FitPerform(&histogram, histogram.Veto, "gaus", false);
+ histogramthreshold.posSeed=FitPerform(&histogram, histogram.Seed, "landau", false);
+ histogramthreshold.posSum=FitPerform(&histogram, histogram.Sum, "gaus", false);
if (labbook.source.Contains("Fe")||labbook.source.Contains("Cd"))
- histogramfixedthreshold.posVeto=FitPerform(histogramfixedthreshold.Veto, "gaus", false);
- histogramfixedthreshold.posSeed=FitPerform(histogramfixedthreshold.Seed, "landau", false);
- histogramfixedthreshold.posSum=FitPerform(histogramfixedthreshold.Sum, "gaus", false);
+ histogramfixedthreshold.posVeto=FitPerform(&histogramfixedthreshold, histogramfixedthreshold.Veto, "gaus", false);
+ histogramfixedthreshold.posSeed=FitPerform(&histogramfixedthreshold, histogramfixedthreshold.Seed, "landau", false);
+ histogramfixedthreshold.posSum=FitPerform(&histogramfixedthreshold, histogramfixedthreshold.Sum, "gaus", false);
// gROOT->SetBatch(kFALSE);
return 0;
}
if (!error)
{
TString legendEntry = Form("Noise: %.2f + %.2f - %.2f", histogram.avgNoise, histogram.avgNoisePlus, histogram.avgNoiseMinus );
- noisecanvas = plot1DHistogram(histogram.Noise, "landau", "", legendEntry);
+ noisecanvas = plot1DHistogram(&histogram, histogram.Noise, "landau", "", legendEntry);
return 0;
}
return 1;
{
if (!error)
{
- plot1DHistogram(histogram.Seed, "landau");
+ plot1DHistogram(&histogram, histogram.Seed, "landau");
return 0;
}
return 1;
{
if (!error)
{
- plot1DHistogram(histogramthreshold.Seed, "landau");
+ plot1DHistogram(&histogramthreshold, histogramthreshold.Seed, "landau");
return 0;
}
return 1;
{
if (!error)
{
- plot1DHistogram(histogramthresholdCalibrated.Seed, "landau");
+ plot1DHistogram(&histogramthresholdCalibrated, histogramthresholdCalibrated.Seed, "landau");
return 0;
}
return 1;
{
if (!error)
{
- plot1DHistogram(histogram.Sum, "gaus");
+ plot1DHistogram(&histogram, histogram.Sum, "gaus");
return 0;
}
return 1;
{
if (!error)
{
- plot1DHistogram(histogram.Veto, "gaus");
+ plot1DHistogram(&histogram, histogram.Veto, "gaus");
return 0;
}
return 1;
canvas->cd(1);
TPad* firstpart = (TPad*)canvas->GetPad(1);
firstpart->SetGrid();
- FitPerform(xslicetroughcluster,"lorentz", false, &xslicetroughclusterpar[0]);
+ FitPerform(&histogram, xslicetroughcluster,"lorentz", false, &xslicetroughclusterpar[0]);
canvas->cd(2);
TPad* secondpart = (TPad*)canvas->GetPad(2);
secondpart->SetGrid();
- FitPerform(yslicetroughcluster,"lorentz", false, &yslicetroughclusterpar[0]);
+ FitPerform(&histogram, yslicetroughcluster,"lorentz", false, &yslicetroughclusterpar[0]);
canvas->Draw();
return 1;
}
-Bool_t Run::integrateSr90Spectra(TH1F* histogrampointer, Bool_t verbose)
+Bool_t Run::integrateSr90Spectra(histogramstruct* histogramstructpointer, TH1F* histogrampointer, Float_t thresholdborder, 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;
+// Int_t random = random1->Rndm()*100000;
+// TString canvastitle = Form("%s %s sdfasdf", histogrampointer->GetName(), runcode.Data());
+// TString canvasname = Form("%s %s %d dfgsdfgsdfg", histogrampointer->GetName(), runcode.Data(), random);
+// TCanvas* canvas = new TCanvas(canvasname, canvastitle, 900, 700);
+// smoothedcurce->Draw();
- 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());
-
+ Int_t thresholdbincurcandidate = 0;
+ if (thresholdborder < 0)
+ {
+ Int_t rising = 0;
+ Int_t bini =smoothedcurce->GetMaximumBin();
+ Float_t curval = smoothedcurce->GetXaxis()->GetBinCenter(bini);
+// cout << "smoothedcurce->GetXaxis()->GetBinCenter(" << bini << "): " << curval << endl;
+
+ 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());
+ }
+ else
+ {
+ thresholdbincurcandidate = histogrampointer->GetXaxis()->FindBin(thresholdborder);
+ }
// histogrampointer->GetXaxis()->SetRange(histogrampointer->GetXaxis()->FindBin(0),histogrampointer->GetXaxis()->FindBin(posMaxValHist));
// histogrampointer->GetXaxis()->SetRange(posNoiseMax,histogrampointer->GetXaxis()->FindBin(posMaxValHist));
// Float_t posChargeMax= histogrampointer->GetMaximum();
- noisethresholdborder = histogrampointer->GetXaxis()->GetBinUpEdge(thresholdbincurcandidate);
+ histogramstructpointer->noisethresholdborder = histogrampointer->GetXaxis()->GetBinUpEdge(thresholdbincurcandidate);
if (verbose) {
+ cout << " Integrating " << histogrampointer->GetTitle() << endlr;
cout << " Noise threshold at " << noisethresholdborder;
TString histtitle=histogrampointer->GetXaxis()->GetTitle();
if (histtitle.Contains("[e]"))
}
}
}
- sr90IntegralVal = histogrampointer->IntegralAndError(thresholdbincurcandidate,histogrampointer->GetMaximumBin(), sr90IntegralErr);
- sr90IntegralErr /= sr90IntegralVal/100;
+ histogramstructpointer->sr90IntegralVal = histogrampointer->IntegralAndError(thresholdbincurcandidate,histogrampointer->GetNbinsX(), histogramstructpointer->sr90IntegralErr);
+ // cout << "Integrate from bin " << thresholdbincurcandidate << " to " << histogrampointer->GetNbinsX() << endl;
+ histogramstructpointer->sr90IntegralErr /= histogramstructpointer->sr90IntegralVal/100;
+ cout << " Unscaled integral is " << Form("%e",histogramstructpointer->sr90IntegralVal) << ", error " << histogramstructpointer->sr90IntegralErr << "%" << endl;
cout << " ";
if (labbook.frames_foundDB>0 || frames_found>0)
{
- sr90IntegralVal/=(labbook.frames_foundDB>0)?labbook.frames_foundDB:frames_found;
+ histogramstructpointer->sr90IntegralVal/=(labbook.frames_foundDB>0)?labbook.frames_foundDB:frames_found;
cout << "Scaled ";
}
- cout << "Integral is " << Form("%e",sr90IntegralVal) << ", error " << sr90IntegralErr << "%" << endl;
+ cout << "Integral is " << Form("%e",histogramstructpointer->sr90IntegralVal) << ", error " << histogramstructpointer->sr90IntegralErr << "%" << endl;
return 0;
}
-Float_t Run::FitPerform(TH1F* histogrampointer, TString fitFuncType, Bool_t verbose, Double_t* parameters)
+Float_t Run::FitPerform(histogramstruct* histogramstructpointer, TH1F* histogrampointer, TString fitFuncType, Bool_t verbose, Double_t* parameters)
{
Float_t posMax = 0;
Float_t posMax2 = 0;
Float_t posMaxValHist = histogrampointer->GetXaxis()->GetXmax();
- Float_t noiseborder = (noisethresholdborder>0)?noisethresholdborder:90; // posMaxValHist/10 for USB system, the value is 90
+ // posMaxValHist/10 for USB system, the value is 90
+ Float_t noiseborder = 90;
+ if (histogramstructpointer->noisethresholdborder>0)
+ noiseborder = histogramstructpointer->noisethresholdborder;
+ else if (noisethresholdborder > 0)
+ noiseborder = noisethresholdborder;
if (doFits)
{
}
}
-TCanvas* Run::plot1DHistogram(TH1F* onehistogram, TString fitFuncType, TString titlestr, TString legendstr)
+TCanvas* Run::plot1DHistogram(histogramstruct* histogramstructpointer, TH1F* onehistogram, TString fitFuncType, TString titlestr, TString legendstr)
{
if (onehistogram != nullptr)
{
TCanvas* canvas = new TCanvas(canvasname, canvastitle, 900, 700);
onehistogram->SetTitle(titlestr);
onehistogram->Draw();
- Float_t maxValue = FitPerform(onehistogram, fitFuncType);
+ Float_t maxValue = FitPerform(histogramstructpointer, onehistogram, fitFuncType);
plotVerticalLine(onehistogram, maxValue);
TLegend* leg = new TLegend(0.8,0.8,0.89,0.89);//(0.6,0.7,0.89,0.89);
leg->SetFillColor(0);
/// 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 = "");
/**
*
*/
void plotVerticalLine(TH1F* histogrampointer, Float_t xVal);
-
- /**
- * @brief intern function to calculate and plot fit curve to given histogram
- *
- * @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, Double_t* parameters=NULL);
-
- /**
- * @brief find the border between the noise and the signal in Sr90 runs
- *
- * writes the found threshold into the private variable @c Run::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 */
Bool_t rescaleHistograms();
/** @brief Makes a gnuplot file to plot the histogram data created in @c Run::writeAllHistogramsToFile() */
void MakeGnuplotFile();
-
+
/// is set to true if an error occured
Bool_t error = 0;
*/
Bool_t analyzeFrame(Int_t frame);
-
Int_t getClustersize();
Bool_t runAllreadyAnalyzed();
/** @brief Turn on or off the use of common mode noise filter @c MAPS::regetDynNoise() */
Bool_t useCommonModeFilter(Bool_t);
+
+ /** @brief set a threshold value in electrons to use in the histogram Run::histogramfixedthreshold, this value is used in @c MAPS::initMapsRun() */
+ Bool_t setFixedThresholdValueElectrons(Float_t);
+
+ /** @brief set a threshold value in ADU to use in the histogram Run::histogramfixedthreshold, this value is used in @c MAPS::initMapsRun() */
+ Bool_t setFixedThresholdValueADU(Float_t);
/**
* @brief set pathwhere images and data to save to
/// Negative Noise sigma
Float_t avgNoiseMinus = 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;
+
/// set to true, if bins are in electrons, otherwise in ADU
Bool_t calibrated = false;
*/
Bool_t plotClusterDistribution(histogramstruct*);
+ /**
+ * @brief intern function to calculate and plot fit curve to given histogram
+ *
+ * @param histogrampointer histogram pointer to calculate fit to
+ * @return peak position of the fit
+ *
+ */
+ Float_t FitPerform(histogramstruct*, TH1F*, TString fitFuncType="landau", Bool_t verbose=true, Double_t* parameters=NULL);
+
+
+ TCanvas* plot1DHistogram(histogramstruct* histogramstructpointer, TH1F* onehistogram, TString fitFuncType = "landau", TString titlestr = "", TString legendstr = "");
+
///
/** @brief initializes all histograms, set binwidth, bin amount and names
* *
/** @brief initializes the TH2F cluster for the binning for a specific structure of type #Run::histogramstruct one points to*/
void initCluster(histogramstruct*, TString suffix, Float_t xcoord_min_step, Float_t xcoord_abs_min, Float_t xcoord_abs_max, Float_t ycoord_min_step, Float_t ycoord_abs_min, Float_t ycoord_abs_max);
+
+ /**
+ * @brief find the border between the noise and the signal in Sr90 runs
+ *
+ * writes the found threshold into the private variable @c Run::posNoiseThreshold
+ *
+ * @param histogrampointer pointer to the histogram structure, threshold will be searched in seed spectra
+ * @param thresholdborder value from which the integral will be calculated, if not set, the algorithms tries to find the best value
+ * @return true if succesfull
+ *
+ */
+ Bool_t integrateSr90Spectra(histogramstruct* histogramstructpointer, TH1F* histogrampointer, Float_t thresholdborder=-1, Bool_t verbose=true);
+
pixelinfo pixelinfoMi34[32];
/// analyze only half of matrix