*
*/
#include <fstream>
+#include <iostream>
+#include <iomanip>
+using namespace std;
Int_t* ReadRunList();
Int_t ReadRunList(std::vector<int>*);
* Call #writeObservableToFile() in #ChargeSpectrum.c to create a file with all the TH1F histogram data
*
*/
+/** @brief Prints a line with fixed width in the summary table */
+template<typename varType> string printTableElement(varType t1, varType t2, const int precision=1);
+
Bool_t writeObservableToFile();
/** @brief A vector able to hold pointer of type #Run::histogramstruct
*
vector<HistogramType*> compareHistogramClassVector;
vector<HistogramType*> compareHistogramClassVector2;
vector<HistogramType*> compareHistogramClassVector3;
+/** @brief Prints a summary table with all the analyzed run data */
+Bool_t printSummaryTable(vector<HistogramType*>*);
+/** @brief Tests if all runs in vector are from same type, calibrated or not calibrated */
+Bool_t testifMixingCalibration(vector<HistogramType*>*);
+/** @brief Turns a value into a string with fixed precision */
+string to_str_w_prec(const Float_t a_value, int precision = 1);
vector<TH1F*> compareHistogramVector;
TString ownpath = "";
return plotAllRuns(&compareHistogramClassVector);
}
+Bool_t testifMixingCalibration(vector<HistogramType*>* ptCompareHistogramClassVector) {
+ if ( !ptCompareHistogramClassVector->size() )
+ {
+ cout << colorwhite << ptCompareHistogramClassVector->size() << endl;
+ cout << colorred << "plotCompareHistograms(): No plots to compare, please push them into the vector: CompareHistogramClassVector" << endlr;
+ return 1;
+ }
+ Bool_t calibrated = true;
+ Bool_t uncalibrated = true;
+ for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++)
+ {
+ calibrated = calibrated && ptCompareHistogramClassVector->at(histogrami)->iscalibrated;
+ uncalibrated = uncalibrated && !ptCompareHistogramClassVector->at(histogrami)->iscalibrated;
+ // cout << colorcyan << ptCompareHistogramClassVector->at(histogrami)->histogramdescription << endlr;
+ }
+ // cout << "Calibrated " << (calibrated?"Yes":"No") << endl;
+ // cout << "Uncalibrated " << (uncalibrated?"Yes":"No") << endl;
+ if ( !(calibrated != uncalibrated)) // XOR operator !=
+ {
+ cout << colorred << "plotCompareHistograms(): Mixing of calibrated and uncalibrated histograms when comparing plots. Aborting." << endlr;
+ return 1;
+ }
+ return 0;
+}
Bool_t plotAllRuns(vector<HistogramType*>* ptCompareHistogramClassVector)
{
if (numberRuns>0)
{
- if ( !ptCompareHistogramClassVector->size() )
- {
- cout << colorwhite << ptCompareHistogramClassVector->size() << endl;
- cout << colorred << "plotCompareHistograms(): No plots to compare, please push them into the vector: CompareHistogramClassVector" << endlr;
- return 1;
- }
- Bool_t calibrated = true;
- Bool_t uncalibrated = true;
- for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++)
- {
- calibrated = calibrated && ptCompareHistogramClassVector->at(histogrami)->iscalibrated;
- uncalibrated = uncalibrated && !ptCompareHistogramClassVector->at(histogrami)->iscalibrated;
- // cout << colorcyan << ptCompareHistogramClassVector->at(histogrami)->histogramdescription << endlr;
- }
- // cout << "Calibrated " << (calibrated?"Yes":"No") << endl;
- // cout << "Uncalibrated " << (uncalibrated?"Yes":"No") << endl;
- if ( !(calibrated != uncalibrated)) // XOR operator !=
- {
- cout << colorred << "plotCompareHistograms(): Mixing of calibrated and uncalibrated histograms when comparing plots. Aborting." << endlr;
- return 1;
- }
+ if (testifMixingCalibration(ptCompareHistogramClassVector)) return 1;
// legend entries
Float_t height = ptCompareHistogramClassVector->size() * 0.04;
curhistogramclone = (TH1F*) curhistogramclassp->Seed->Clone();
// curhistogramclone->SetLineColor(rootcolors[histogrami]);
curhistogramclone->Draw("SAME");
- legendEntry = Form("%d %s", curhistogramclassp->runnumber, curhistogramclone->GetTitle());
+ legendEntry = Form("%d %s", curhistogramclassp->labbook->runnumber, curhistogramclone->GetTitle());
leg1->AddEntry(curhistogramclone, legendEntry, "l");
leg1->Draw("SAME");
lastbin1 = (curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1))>lastbin1)?curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1)):lastbin1;
curhistogramclone = (TH1F*) curhistogramclassp->Noise->Clone();
// curhistogramclone->SetLineColor(rootcolors[histogrami]);
curhistogramclone->Draw("SAME");
- legendEntry = Form("%d Noise: %.2f + %.2f - %.2f",curhistogramclassp->runnumber, curhistogramclassp->avgNoise, curhistogramclassp->avgNoisePlus, curhistogramclassp->avgNoiseMinus);
+ legendEntry = Form("%d Noise: %.2f + %.2f - %.2f",curhistogramclassp->labbook->runnumber, curhistogramclassp->avgNoise, curhistogramclassp->avgNoisePlus, curhistogramclassp->avgNoiseMinus);
leg2->AddEntry(curhistogramclone, legendEntry, "l");
leg2->Draw();
}
return 1;
}
+Bool_t printSummaryTable(vector<HistogramType*>* ptCompareHistogramClassVector)
+{
+ if (ptCompareHistogramClassVector->size()>0)
+ {
+ if (testifMixingCalibration(ptCompareHistogramClassVector)) return 1;
+ const int width = 15;
+ cout << endlr << colorwhite << right << setw(width*9) << setfill('=') << " " << endl;
+ cout << left << setw(width*1) << setfill(' ') << "Cut type: "<< left << setw(width*8) << setfill(' ') << ptCompareHistogramClassVector->at(0)->histogramdescription << endl;
+
+ cout << left << setw(width-5) << setfill(' ') << "Runnumber";
+ cout << left << setw(width-10) << setfill(' ') << "Mtrx";
+ Float_t printradion = 0;
+ for (vector<HistogramType*>::iterator curHistogramClass = ptCompareHistogramClassVector->begin(); curHistogramClass != ptCompareHistogramClassVector->end(); curHistogramClass++)
+ printradion += (*curHistogramClass)->labbook->radDoseIon;
+ if (printradion != 0) cout << left << setw(width-5) << setfill(' ') << "Rad. ion";
+ Float_t printradnonion = 0;
+ for (vector<HistogramType*>::iterator curHistogramClass = ptCompareHistogramClassVector->begin(); curHistogramClass != ptCompareHistogramClassVector->end(); curHistogramClass++)
+ printradnonion += (*curHistogramClass)->labbook->radDoseNonIon;
+ if (printradnonion != 0) cout << left << setw(width-5) << setfill(' ') << "Rad. non-ion";
+ Float_t printCCE = 0;
+ for (vector<HistogramType*>::iterator curHistogramClass = ptCompareHistogramClassVector->begin(); curHistogramClass != ptCompareHistogramClassVector->end(); curHistogramClass++) {
+ printCCE += (*curHistogramClass)->CCE_in_Perc_1; printCCE += (*curHistogramClass)->CCE_in_Perc_25;
+ }
+ if (printCCE != 0) cout << left << setw(width) << setfill(' ') << "CCE_1";
+ if (printCCE != 0) cout << left << setw(width) << setfill(' ') << "CCE_25";
+ Float_t printStoN = 0;
+ for (vector<HistogramType*>::iterator curHistogramClass = ptCompareHistogramClassVector->begin(); curHistogramClass != ptCompareHistogramClassVector->end(); curHistogramClass++)
+ printStoN += (*curHistogramClass)->StoN;
+ if (printStoN != 0) cout << left << setw(width) << setfill(' ') << "S/N";
+ Float_t printIntegral = 0;
+ for (vector<HistogramType*>::iterator curHistogramClass = ptCompareHistogramClassVector->begin(); curHistogramClass != ptCompareHistogramClassVector->end(); curHistogramClass++)
+ printIntegral += (*curHistogramClass)->sr90IntegralVal;
+ if (printIntegral != 0) cout << left << setw(width) << setfill(' ') << "Integral";
+ cout << left << setw(width) << setfill(' ') << "Noise";
+ cout << endl;
+ for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++)
+ {
+ HistogramType* curhistogramclassp = ptCompareHistogramClassVector->at(histogrami);
+ cout << left << setw(width-5) << setfill(' ') << curhistogramclassp->labbook->runnumber;
+ cout << left << setw(width-10) << setfill(' ') << curhistogramclassp->labbook->matrix;
+ if (printradion != 0) cout << left << setw(width-5) << setfill(' ') << curhistogramclassp->labbook->radDoseIon;
+ if (printradnonion != 0) cout << left << setw(width-5) << setfill(' ') << curhistogramclassp->labbook->radDoseNonIon;
+ if (printCCE != 0) cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->CCE_in_Perc_1,ptCompareHistogramClassVector->at(0)->CCE_in_Perc_1);
+ if (printCCE != 0) cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->CCE_in_Perc_25,ptCompareHistogramClassVector->at(0)->CCE_in_Perc_25);
+ if (printStoN != 0) cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->StoN,ptCompareHistogramClassVector->at(0)->StoN);
+ if (printIntegral != 0) cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->sr90IntegralVal,ptCompareHistogramClassVector->at(0)->sr90IntegralVal);
+ cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->avgNoise,ptCompareHistogramClassVector->at(0)->avgNoise);
+ cout << "" << endl;
+ }
+ cout << right << setw(width*9) << setfill('=') << " " << endl;
+ }
+ return 0;
+}
+
+template<typename varType> string printTableElement(varType t1, varType t2, const int precision)
+{
+ float percentage = t1/t2*100.0;
+ string value = to_str_w_prec(t1, precision) + " (" + to_str_w_prec(percentage,0) + "%)";
+ return value;
+}
+
+string to_str_w_prec(const Float_t a_value, const int precision)
+{
+ std::ostringstream out;
+ if (abs(a_value) > 1) {
+ out << std::fixed << std::setprecision(precision) << a_value;
+ } else {
+ out << std::scientific << std::setprecision(precision) << a_value << std::fixed; out.setf(ios_base::fixed);
+ }
+ return out.str();
+}
+
}
-HistogramType::HistogramType(TString suffix, systemparam* gotsystempar, sensorinfostruct* gotsensorinfo, TString gothumanreadablestr, Int_t gotrunnumber, Int_t gotcolor, Int_t gotstyle ) {
+HistogramType::HistogramType(TString suffix, systemparam* gotsystempar, sensorinfostruct* gotsensorinfo, TString gothumanreadablestr, labbooksctruct* plabbook, Int_t gotcolor, Int_t gotstyle ) {
histogramdescription = suffix;
humanreadablestr = gothumanreadablestr;
cursystempar = gotsystempar;
- runnumber = gotrunnumber;
+ labbook = plabbook;
cursensorinfo = gotsensorinfo;
initHistograms(gotcolor, gotstyle);
};
}
void HistogramType::initHistogram(TH1F* &histogrampointer, TString prefix, Int_t color, Int_t style) {
- histogrampointer=new TH1F(Form("%d %s",runnumber, prefix.Data()), Form("%d %s, %s",runnumber,prefix.Data(), humanreadablestr.Data()), cursystempar->nbins, 0, cursystempar->maxbin);
+ histogrampointer=new TH1F(Form("%d %s",labbook->runnumber, prefix.Data()), Form("%d %s, %s",labbook->runnumber,prefix.Data(), humanreadablestr.Data()), cursystempar->nbins, 0, cursystempar->maxbin);
histogrampointer->SetLineStyle(style);
histogrampointer->SetLineColor(color);
histogrampointer->SetStats(kTRUE);
return 1;
}
gain = gotgain;
-
- calibrated = new HistogramType(histogramdescription+" calibrated", cursystempar, cursensorinfo, isthresholdclustertype, color, style);
+ calibrated = new HistogramType(histogramdescription+" calibrated", cursystempar, cursensorinfo, humanreadablestr, labbook, color, style);
if (Seed != 0) calibrateHistogram(calibrated->Seed, Seed);
if (Sum != 0) calibrateHistogram(calibrated->Sum, Sum);
if (Veto != 0) calibrateHistogram(calibrated->Veto, Veto);
calibrated->avgNoisePlus = avgNoisePlus * gain;
calibrated->avgNoiseMinus = avgNoiseMinus * gain;
calibrated->sr90IntegralVal = sr90IntegralVal * gain;
+ calibrated->StoN = StoN;
+ calibrated->CCE_in_Perc_1 = CCE_in_Perc_1;
+ calibrated->CCE_in_Perc_25 = CCE_in_Perc_25;
calibrated->iscalibrated = true;
leg->AddEntry((TObject*) 0, legendEntry, "");
leg->SetTextSize(0.05);
// leg->Draw();
-
+//
}
else if (fitFuncType=="landau")
{
~HistogramType(void);
/** @brief constructor */
- HistogramType(TString suffix, systemparam* gotsystempar, sensorinfostruct* gotsensorinfo, TString gothumanreadablestr="", Int_t gotrunnumber=0, Int_t gotcolor=0, Int_t gotstyle=0);
+ HistogramType(TString suffix, systemparam* gotsystempar, sensorinfostruct* gotsensorinfo, TString gothumanreadablestr="", labbooksctruct* plabbook=0, Int_t gotcolor=0, Int_t gotstyle=0);
//*****************
// TH HISTOGRAMS
//*****************
/// A string representing the current run database information in a human readable format
TString humanreadablestr="";
- /// Runnumber provided by Run.c from the database, used for names of histograms
- Int_t runnumber = 0;
/// type in here what the histogram is intended for or how it is calculated, will be added to filenames
TString histogramdescription = "";
/// The gain used to rescale the histograms
Float_t CCE_in_Perc_1=0;
/// Signal to noise ratio
Float_t StoN=0;
+ /// stores information from the SQL database of a given run
+ labbooksctruct* labbook;
//*****************
// METHODS APPLYABLE TO HISTOGRAMS
cout << colorwhite << "init Histogram classes:" << endlr;
// default histogram class, no special cuts applied
- histogram = new HistogramType("", &cursystemparam, &cursensorinfo, humanreadablestr, labbook.runnumber, rootcolors[plotStyle], rootlinestyle[plotStyle] );
+ histogram = new HistogramType("", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, rootcolors[plotStyle], rootlinestyle[plotStyle] );
HistogramClassVector.push_back(histogram);
// dynamical cluster threshold cut
- histogramthreshold = new HistogramType(" Threshold", &cursystemparam, &cursensorinfo, humanreadablestr, labbook.runnumber, rootcolors[plotStyle], rootlinestyle[plotStyle] );
+ histogramthreshold = new HistogramType(" Threshold", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, rootcolors[plotStyle], rootlinestyle[plotStyle] );
HistogramClassVector.push_back(histogramthreshold);
// fixed threshold cut
- histogramfixedthreshold = new HistogramType(" fixed Threshold", &cursystemparam, &cursensorinfo, humanreadablestr, labbook.runnumber, rootcolors[plotStyle], rootlinestyle[plotStyle] );
+ histogramfixedthreshold = new HistogramType(" fixed Threshold", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, rootcolors[plotStyle], rootlinestyle[plotStyle] );
HistogramClassVector.push_back(histogramfixedthreshold);
debugDBreadout();
#include "help.h"
-
#define SERVERPATH "mysql://jspc29.x-matter.uni-frankfurt.de"
#define SERVERUSER "radhard"
#define SERVERPWD "mimosa88"
*/
Bool_t setDynamicalNoiseMode(TString mode);
- /**
- * @brief provides information from the SQL database
- */
- struct labbooksctruct
- {
- /// runnumber for which the data is provided
- Int_t runnumber = 0;
- /// system, "USB" or "PXI"
- TString system = "";
- /// temperature the run supposed to run with in °C
- Float_t temp = -272;
- /// actual temperature the chip had when meausurement started in °C
- Float_t tempSens = -272;
- /// number of chip/sensor used
- TString chip = "";
- /// generation of the sensor
- TString chipGen = "";
- /// the radioactive source the chip was radiated with during measurement
- TString source = "";
- /// submatrix for which the measurement was done
- TString matrix = "";
- /// ionizing radiation dose of the measured chip in MRad
- Float_t radDoseIon = -1;
- /// non-ionizing radiation dose of the chip in \f$ 10^{10} \frac{\text{neq}}{\text{cm}^2} \f$
- Float_t radDoseNonIon = -1;
- /// position of th seed peak found in the database in ADU for this specific run
- Float_t posSeedDB = -1;
- /// position of th sum peak found in the database in ADU for this specific run
- Float_t posSumDB = -1;
- /// position of th veto peak found in the database in ADU for this specific run
- Float_t posVetoDB = -1;
- /// gain found in db
- Float_t gainDB = -1;
- /// average noise found in db
- Float_t NoiseAvgDB = -1;
- /// Positive noise error found in db
- Float_t NoiseAvgPlusDB = -1;
- /// Negative noise error found in db
- Float_t NoiseAvgMinusDB = -1;
- /// Charge collection efficciency of the cluster in percent found in db
- Float_t CCE_in_Perc_25DB=-1;
- /// Charge collection efficciency of the seed pixel in percent found in db
- Float_t CCE_in_Perc_1DB=-1;
- /// Signal to Noise ratio
- Float_t StoN=-1;
- /// Integral value
- Float_t Sr90IntegralVal=-1;
- /// the resistivity of the epitexial layer of the chip
- Int_t resistivity = -1;
- /// Thickness of epitexial layer in micro meters
- Int_t epi_thickness = -1;
- /// clock rate at wich the chip was measured in MHz
- 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;
const TString colorreset = "\033[0m";
const TString endlr = "\033[0m\n";
+/**
+ * @brief stores information from the SQL database
+ */
+struct labbooksctruct
+{
+ /// runnumber for which the data is provided
+ Int_t runnumber = 0;
+ /// system, "USB" or "PXI"
+ TString system = "";
+ /// temperature the run supposed to run with in °C
+ Float_t temp = -272;
+ /// actual temperature the chip had when meausurement started in °C
+ Float_t tempSens = -272;
+ /// number of chip/sensor used
+ TString chip = "";
+ /// generation of the sensor
+ TString chipGen = "";
+ /// the radioactive source the chip was radiated with during measurement
+ TString source = "";
+ /// submatrix for which the measurement was done
+ TString matrix = "";
+ /// ionizing radiation dose of the measured chip in MRad
+ Float_t radDoseIon = -1;
+ /// non-ionizing radiation dose of the chip in \f$ 10^{10} \frac{\text{neq}}{\text{cm}^2} \f$
+ Float_t radDoseNonIon = -1;
+ /// position of th seed peak found in the database in ADU for this specific run
+ Float_t posSeedDB = -1;
+ /// position of th sum peak found in the database in ADU for this specific run
+ Float_t posSumDB = -1;
+ /// position of th veto peak found in the database in ADU for this specific run
+ Float_t posVetoDB = -1;
+ /// gain found in db
+ Float_t gainDB = -1;
+ /// average noise found in db
+ Float_t NoiseAvgDB = -1;
+ /// Positive noise error found in db
+ Float_t NoiseAvgPlusDB = -1;
+ /// Negative noise error found in db
+ Float_t NoiseAvgMinusDB = -1;
+ /// Charge collection efficciency of the cluster in percent found in db
+ Float_t CCE_in_Perc_25DB=-1;
+ /// Charge collection efficciency of the seed pixel in percent found in db
+ Float_t CCE_in_Perc_1DB=-1;
+ /// Signal to Noise ratio
+ Float_t StoN=-1;
+ /// Integral value
+ Float_t Sr90IntegralVal=-1;
+ /// the resistivity of the epitexial layer of the chip
+ Int_t resistivity = -1;
+ /// Thickness of epitexial layer in micro meters
+ Int_t epi_thickness = -1;
+ /// clock rate at wich the chip was measured in MHz
+ 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;
+};
+
void preparecanvas() {
// TCanvas* canvas = new TCanvas("Canvas1", 700, 500);
// histogram->SetTitle(titlestr);