From: Benjamin Linnik Date: Tue, 12 Nov 2013 16:43:32 +0000 (+0100) Subject: newCOMBI: added SQL labbook support, CSV support is commented out, but still preserved X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=9ff34993c29feaa5c10a9fbb8a4f3a850e50ceb5;p=radhard.git newCOMBI: added SQL labbook support, CSV support is commented out, but still preserved --- diff --git a/newCOMBI/ChargeSpektrum.c b/newCOMBI/ChargeSpektrum.c index e5c4b1c..e214027 100755 --- a/newCOMBI/ChargeSpektrum.c +++ b/newCOMBI/ChargeSpektrum.c @@ -3,9 +3,15 @@ #include #include #include + +// mySQL Anbindung +#include +#include +#include + #include "CSVRow.h" //#ifdef __CINT__ -#include "CSVRow.C" // bad C-style... but root wants it this way... no correct separation of declaration and implementation possible. +#include "CSVRow.C" // bad C-style... but root wants it this way... no correct separation of declaration and implementation possible. #include "TFile.h" #include "TTree.h" @@ -29,7 +35,7 @@ #define NUMPIXELS 25 -#define VETO_THRESHOLD 20 +#define VETO_THRESHOLD 10 #define FIT_FUNC "gaus" #define DRAW_FITS true @@ -37,466 +43,527 @@ #define DATAPATH "/d/salt/data_recovered/maps/DennisDoering/root/Analysedata/" struct laborbook { - Int_t inputRun; - TString system; - Float_t temp; - Float_t tempSens; - TString chip; - TString source; - TString matrix; - TString radDose; + Int_t inputRun; + TString system; + Float_t temp; + Float_t tempSens; + TString chip; + TString source; + TString matrix; + TString radDose; }; struct histogram { - TH1F* Seed; - TH1F* Sum; - TH1F* Veto; - Int_t inputRun; - Float_t posSeed; - Float_t posSum; - Float_t posVeto; - struct laborbook laborbookdata; + TH1F* Seed; + TH1F* Sum; + TH1F* Veto; + Int_t inputRun; + Float_t posSeed; + Float_t posSum; + Float_t posVeto; + struct laborbook laborbookdata; }; struct noise { - TH1F* noiseHisto; - Int_t inputRun; - Double_t quantiles; - struct laborbook laborbookdata; + TH1F* noiseHisto; + Int_t inputRun; + Double_t quantiles; + struct laborbook laborbookdata; }; struct histogram GenerateHisto(Int_t inputRun); Float_t FitPerform(TH1F*, Int_t); struct laborbook LaborBuch(Int_t inputRun); +struct laborbook LaborBuchSQL(Int_t inputRun); Int_t* ReadRunList(Int_t* numberRuns); struct noise Noise(Int_t inputRun); void ChargeSpektrum() { - - Int_t numberRuns=0; - ReadRunList(&numberRuns); - Int_t* runList=new Int_t[numberRuns]; - runList=ReadRunList(&numberRuns); - - - struct histogram* arrayHisto = new struct histogram[numberRuns]; - struct noise* noiseHisto = new struct noise[numberRuns]; - for(Int_t lauf=0;laufSetWindowSize(w + (w - c1->GetWw()), h + (h - c1->GetWh())); - - arrayHisto[0].Seed->Draw(""); - for(Int_t lauf=1;laufDraw("same"); - } - - TString ergebnisfile="ergebnisfile.dat"; - fstream* fout = new fstream(ergebnisfile,ios::out); - for(Int_t lauf=0;laufclose(); - -/* -cout<SetWindowSize(w + (w - c1->GetWw()), h + (h - c1->GetWh())); - - arrayHisto.Seed->Draw(""); - double xmin = arrayHisto.Seed->GetXaxis()->GetXmin(); -double xmax = arrayHisto.Seed->GetXaxis()->GetXmax(); -double factor = 1640./406.; -arrayHisto.Seed->GetXaxis()->SetLimits(xmin*factor,xmax*factor); - arrayHisto2.Seed->Draw("same"); - double xmin2 = arrayHisto2.Seed->GetXaxis()->GetXmin(); -double xmax2 = arrayHisto2.Seed->GetXaxis()->GetXmax(); -//double factor = 1640./400.; -double factor2 = 1640./6352.; -arrayHisto2.Seed->GetXaxis()->SetLimits(xmin2*factor2,xmax2*factor2); - //arrayHisto.Sum->Draw("same"); - //arrayHisto.Veto->Draw("same"); - cout<Draw(""); + for(Int_t lauf=1;laufDraw("same"); + } + + TString ergebnisfile="ergebnisfile.dat"; + fstream* fout = new fstream(ergebnisfile,ios::out); + for(Int_t lauf=0;laufclose(); + + /* + * c *out<SetWindowSize(w + (w - c1->GetWw()), h + (h - c1->GetWh())); + * + * arrayHisto.Seed->Draw(""); + * double xmin = arrayHisto.Seed->GetXaxis()->GetXmin(); + * double xmax = arrayHisto.Seed->GetXaxis()->GetXmax(); + * double factor = 1640./406.; + * arrayHisto.Seed->GetXaxis()->SetLimits(xmin*factor,xmax*factor); + * arrayHisto2.Seed->Draw("same"); + * double xmin2 = arrayHisto2.Seed->GetXaxis()->GetXmin(); + * double xmax2 = arrayHisto2.Seed->GetXaxis()->GetXmax(); + * //double factor = 1640./400.; + * double factor2 = 1640./6352.; + * arrayHisto2.Seed->GetXaxis()->SetLimits(xmin2*factor2,xmax2*factor2); + * //arrayHisto.Sum->Draw("same"); + * //arrayHisto.Veto->Draw("same"); + * cout<IsZombie()) - { - // if we cannot open the file, print an error messageForm("hist%i",nHistNtuple) and return immediatly - printf("Error: cannot open %s\n", path.Data()); - exit(0); - } - - // get a pointer to the tree - TNtuple* hitNtuple = (TNtuple*) f->Get("hit"); - //TNtuple* hitsNtuple = (TNtuple*) f->Get("hits"); - - // one array element and one branch for each pixel - Float_t pixel[NUMPIXELS]; - TBranch* pixelBranch[NUMPIXELS]; - for (Int_t cnt=0; cntSetBranchAddress(Form("p%i",cnt+1), &pixel[cnt], &pixelBranch[cnt]); - } - UInt_t frame; - TBranch* frameBranch; - hitNtuple->SetBranchAddress("frame", &frame, &frameBranch); - UInt_t seedPixel; - TBranch* seedPixelBranch; - hitNtuple->SetBranchAddress("pixel", &seedPixel, &seedPixelBranch); - - // loop over all hits to fill histogram - Int_t nentries = hitNtuple->GetEntries(); - - for (Int_t cnt=0; cntGetEntry(cnt); - - // take only frames with a maximum of one hit - // hitsNtuple->GetEntry((Int_t) frame); - // if (frameCounts > 1) - // continue; - - - // histogram with the single pixel - histNtuple->Fill(pixel[12]); - - // histogram with the summed pixels - Double_t pixelSum = 0; - for (Int_t i=0; iFill(pixelSum); - - // histogram with the single pixel and with "veto trigger" - // for the "histNtupleVeto" take only hits where only the seed pixel contains charge - Double_t notSeedSum = 0; - for (Int_t i=0; i<12; i++) - notSeedSum += pixel[i]; - for (Int_t i=13; i VETO_THRESHOLD) - continue; - // meanNotSeedSum+=notSeedSum; - // nhits++; - histNtupleVeto->Fill(pixel[12]); // histogram with the single pixel - - } - TCanvas* c1 = new TCanvas(); - c1->SetTitle(Form("Seed%i",inputRun)); - c1->Divide(2,2); - c1->cd(1); - histNtuple->Draw(""); - Float_t posSeed=FitPerform(histNtuple, inputRun); - c1->cd(2); - histNtupleSum->Draw(""); - Float_t posSum=FitPerform(histNtupleSum, inputRun); - c1->cd(3); - histNtupleVeto->Draw(""); - Float_t posVeto=FitPerform(histNtupleVeto, inputRun); - c1->cd(4); - //Evaluate the histogram with the largest y to plot all complete in one histogram - Float_t maxY = 0; - Int_t thismax; - thismax = histNtuple->GetMaximum(); - if (thismax > maxY) - { - maxY = thismax; - } - thismax = histNtupleSum->GetMaximum(); - if (thismax > maxY) - { - maxY = thismax; - } - thismax = histNtupleVeto->GetMaximum(); - if (thismax > maxY) - { - maxY = thismax; - } - TH1F* histNtupleSame= (TH1F*)histNtuple->Clone(Form("Samehist%i",inputRun)); - TH1F* histNtupleSumSame= (TH1F*)histNtupleSum->Clone(Form("SamehistSum%i",inputRun)); - TH1F* histNtupleVetoSame= (TH1F*)histNtupleVeto->Clone(Form("SamehistVeto%i",inputRun)); - histNtupleSame->Draw(""); - histNtupleSame->SetMaximum(1.05*maxY); - histNtupleSumSame->Draw("same"); - histNtupleVetoSame->Draw("same"); - histNtupleSumSame->SetLineColor(1); - histNtupleVetoSame->SetLineColor(2); - - - - struct histogram arrayHisto; - arrayHisto.Seed=(TH1F*)histNtuple->Clone(Form("hist%i",inputRun)); - arrayHisto.Sum=(TH1F*)histNtupleSum->Clone(Form("histSum%i",inputRun)); - arrayHisto.Veto=(TH1F*)histNtupleVeto->Clone(Form("histVeto%i",inputRun)); - arrayHisto.inputRun=inputRun; - arrayHisto.posSeed=posSeed; - arrayHisto.posSum=posSum; - arrayHisto.posVeto=posVeto; - arrayHisto.laborbookdata=laborbookdata; -return arrayHisto; + + cout<IsZombie()) + { + // if we cannot open the file, print an error messageForm("hist%i",nHistNtuple) and return immediatly + printf("Error: cannot open %s\n", path.Data()); + exit(0); + } + + // get a pointer to the tree + TNtuple* hitNtuple = (TNtuple*) f->Get("hit"); + //TNtuple* hitsNtuple = (TNtuple*) f->Get("hits"); + + // one array element and one branch for each pixel + Float_t pixel[NUMPIXELS]; + TBranch* pixelBranch[NUMPIXELS]; + for (Int_t cnt=0; cntSetBranchAddress(Form("p%i",cnt+1), &pixel[cnt], &pixelBranch[cnt]); + } + UInt_t frame; + TBranch* frameBranch; + hitNtuple->SetBranchAddress("frame", &frame, &frameBranch); + UInt_t seedPixel; + TBranch* seedPixelBranch; + hitNtuple->SetBranchAddress("pixel", &seedPixel, &seedPixelBranch); + + // loop over all hits to fill histogram + Int_t nentries = hitNtuple->GetEntries(); + + for (Int_t cnt=0; cntGetEntry(cnt); + + // take only frames with a maximum of one hit + // hitsNtuple->GetEntry((Int_t) frame); + // if (frameCounts > 1) + // continue; + + + // histogram with the single pixel + histNtuple->Fill(pixel[12]); + + // histogram with the summed pixels + Double_t pixelSum = 0; + for (Int_t i=0; iFill(pixelSum); + + // histogram with the single pixel and with "veto trigger" + // for the "histNtupleVeto" take only hits where only the seed pixel contains charge + Double_t notSeedSum = 0; + for (Int_t i=0; i<12; i++) + notSeedSum += pixel[i]; + for (Int_t i=13; i VETO_THRESHOLD) + continue; + // meanNotSeedSum+=notSeedSum; + // nhits++; + histNtupleVeto->Fill(pixel[12]); // histogram with the single pixel + + } + TCanvas* c1 = new TCanvas(); + c1->SetTitle(Form("Seed%i",inputRun)); + c1->Divide(2,2); + c1->cd(1); + histNtuple->Draw(""); + Float_t posSeed=FitPerform(histNtuple, inputRun); + c1->cd(2); + histNtupleSum->Draw(""); + Float_t posSum=FitPerform(histNtupleSum, inputRun); + c1->cd(3); + histNtupleVeto->Draw(""); + Float_t posVeto=FitPerform(histNtupleVeto, inputRun); + c1->cd(4); + //Evaluate the histogram with the largest y to plot all complete in one histogram + Float_t maxY = 0; + Int_t thismax; + thismax = histNtuple->GetMaximum(); + if (thismax > maxY) + { + maxY = thismax; + } + thismax = histNtupleSum->GetMaximum(); + if (thismax > maxY) + { + maxY = thismax; + } + thismax = histNtupleVeto->GetMaximum(); + if (thismax > maxY) + { + maxY = thismax; + } + TH1F* histNtupleSame= (TH1F*)histNtuple->Clone(Form("Samehist%i",inputRun)); + TH1F* histNtupleSumSame= (TH1F*)histNtupleSum->Clone(Form("SamehistSum%i",inputRun)); + TH1F* histNtupleVetoSame= (TH1F*)histNtupleVeto->Clone(Form("SamehistVeto%i",inputRun)); + histNtupleSame->Draw(""); + histNtupleSame->SetMaximum(1.05*maxY); + histNtupleSumSame->Draw("same"); + histNtupleVetoSame->Draw("same"); + histNtupleSumSame->SetLineColor(1); + histNtupleVetoSame->SetLineColor(2); + + + + struct histogram arrayHisto; + arrayHisto.Seed=(TH1F*)histNtuple->Clone(Form("hist%i",inputRun)); + arrayHisto.Sum=(TH1F*)histNtupleSum->Clone(Form("histSum%i",inputRun)); + arrayHisto.Veto=(TH1F*)histNtupleVeto->Clone(Form("histVeto%i",inputRun)); + arrayHisto.inputRun=inputRun; + arrayHisto.posSeed=posSeed; + arrayHisto.posSum=posSum; + arrayHisto.posVeto=posVeto; + arrayHisto.laborbookdata=laborbookdata; + return arrayHisto; } Float_t FitPerform(TH1F* histNtuple, Int_t inputRun) { - Float_t posMax = 0; - // Read Laborbook, save it in the struct laborbookdata - struct laborbook laborbookdata; - laborbookdata=LaborBuch(inputRun); - - Int_t maxBin; - - if(laborbookdata.system=="USB") - { - maxBin=800; - - } - else - { - maxBin=8000; - - } -histNtuple->Draw(""); -if (DRAW_FITS) - { - - histNtuple->GetXaxis()->SetRange(histNtuple->GetXaxis()->FindBin(maxBin/10),histNtuple->GetXaxis()->FindBin(maxBin)); // look only for maxima with x greater than 20 - Int_t xValMax = histNtuple->GetBinCenter(histNtuple->GetMaximumBin()); - TF1* fitFunc = new TF1("fitFunc",FIT_FUNC,0,maxBin); - if (TString(FIT_FUNC)=="gaus") - { - histNtuple->Fit(fitFunc, "N,Q,W", "", xValMax-100, xValMax+100); - posMax = fitFunc->GetParameter(1); - fitFunc->DrawCopy("same"); - TString legendEntry = TString(Form("Run %i: %.1f ",inputRun,posMax)); - TLegend* leg = new TLegend(0.5,0.5,0.89,0.89);//(0.6,0.7,0.89,0.89); -// leg->SetHeader();//"Legend Title"); - leg->SetFillStyle(0); - leg->AddEntry((TObject*) 0, legendEntry, ""); - leg->SetTextSize(0.05); - leg->Draw(); - - } - else if (TString(FIT_FUNC)=="landau") - { - Float_t fitMax1 = 1000; - Float_t fitMax2 = 1000; - Float_t fitMax3 = 1000; - Float_t minFitMax = 1000; - Float_t maxFitMax = 1000; - - histNtuple->Fit(fitFunc, "N,Q,W", "", 20, maxBin); - fitMax1 = fitFunc->GetParameter(1); - fitFunc->DrawCopy("same"); - histNtuple->Fit(fitFunc, "N,Q,W", "", 20, fitMax1); - fitMax2 = fitFunc->GetParameter(1); - fitFunc->SetLineColor(kBlue); - fitFunc->SetLineStyle(2); // dashed - fitFunc->DrawCopy("same"); - histNtuple->Fit(fitFunc, "N,Q,W", "", fitMax1, maxBin); - fitMax3 = fitFunc->GetParameter(1); - fitFunc->SetLineColor(kGreen); - fitFunc->DrawCopy("same"); - fitFunc->SetLineStyle(1); // normal for the following fits - - // Sort the three fits and save error estimation - minFitMax = TMath::Min(TMath::Min(fitMax1,fitMax2),fitMax3); - maxFitMax = TMath::Max(TMath::Max(fitMax1,fitMax2),fitMax3); - posMax = fitMax1 + fitMax2 + fitMax3 - minFitMax - maxFitMax; - //fitLandauErrorLeft.push_back(posMax - minFitMax); - //fitLandauErrorRight.push_back(maxFitMax - posMax); - - TString legendEntry = TString(Form("Run %i: %.1f %.1f %.1f",inputRun,posMax,minFitMax,maxFitMax )); - TLegend* leg = new TLegend(0.5,0.5,0.89,0.89);//(0.6,0.7,0.89,0.89); -// leg->SetHeader();//"Legend Title"); - leg->SetFillStyle(0); - leg->AddEntry((TObject*) 0, legendEntry, ""); - leg->SetTextSize(0.05); - leg->Draw(); - - } - } - -return posMax; + Float_t posMax = 0; + // Read Laborbook, save it in the struct laborbookdata + struct laborbook laborbookdata; + laborbookdata=LaborBuchSQL(inputRun); + + Int_t maxBin; + + if(laborbookdata.system=="USB") + { + maxBin=800; + } + else + { + maxBin=8000; + + } + histNtuple->Draw(""); + if (DRAW_FITS) + { + + histNtuple->GetXaxis()->SetRange(histNtuple->GetXaxis()->FindBin(maxBin/10),histNtuple->GetXaxis()->FindBin(maxBin)); // look only for maxima with x greater than 20 + Int_t xValMax = histNtuple->GetBinCenter(histNtuple->GetMaximumBin()); + TF1* fitFunc = new TF1("fitFunc",FIT_FUNC,0,maxBin); + if (TString(FIT_FUNC)=="gaus") + { + histNtuple->Fit(fitFunc, "N,Q,W", "", xValMax-100, xValMax+100); + posMax = fitFunc->GetParameter(1); + fitFunc->DrawCopy("same"); + TString legendEntry = TString(Form("Run %i: %.1f ",inputRun,posMax)); + TLegend* leg = new TLegend(0.5,0.5,0.89,0.89);//(0.6,0.7,0.89,0.89); + // leg->SetHeader();//"Legend Title"); + leg->SetFillStyle(0); + leg->AddEntry((TObject*) 0, legendEntry, ""); + leg->SetTextSize(0.05); + leg->Draw(); + + } + else if (TString(FIT_FUNC)=="landau") + { + Float_t fitMax1 = 1000; + Float_t fitMax2 = 1000; + Float_t fitMax3 = 1000; + Float_t minFitMax = 1000; + Float_t maxFitMax = 1000; + + histNtuple->Fit(fitFunc, "N,Q,W", "", 20, maxBin); + fitMax1 = fitFunc->GetParameter(1); + fitFunc->DrawCopy("same"); + histNtuple->Fit(fitFunc, "N,Q,W", "", 20, fitMax1); + fitMax2 = fitFunc->GetParameter(1); + fitFunc->SetLineColor(kBlue); + fitFunc->SetLineStyle(2); // dashed + fitFunc->DrawCopy("same"); + histNtuple->Fit(fitFunc, "N,Q,W", "", fitMax1, maxBin); + fitMax3 = fitFunc->GetParameter(1); + fitFunc->SetLineColor(kGreen); + fitFunc->DrawCopy("same"); + fitFunc->SetLineStyle(1); // normal for the following fits + + // Sort the three fits and save error estimation + minFitMax = TMath::Min(TMath::Min(fitMax1,fitMax2),fitMax3); + maxFitMax = TMath::Max(TMath::Max(fitMax1,fitMax2),fitMax3); + posMax = fitMax1 + fitMax2 + fitMax3 - minFitMax - maxFitMax; + //fitLandauErrorLeft.push_back(posMax - minFitMax); + //fitLandauErrorRight.push_back(maxFitMax - posMax); + + TString legendEntry = TString(Form("Run %i: %.1f %.1f %.1f",inputRun,posMax,minFitMax,maxFitMax )); + TLegend* leg = new TLegend(0.5,0.5,0.89,0.89);//(0.6,0.7,0.89,0.89); + // leg->SetHeader();//"Legend Title"); + leg->SetFillStyle(0); + leg->AddEntry((TObject*) 0, legendEntry, ""); + leg->SetTextSize(0.05); + leg->Draw(); + + } + } + + return posMax; } struct noise Noise(Int_t inputRun) { - // Read Laborbook, save it in the struct laborbookdata - struct laborbook laborbookdata; - laborbookdata=LaborBuch(inputRun); - TString path = TString(DATAPATH) + Form("%i_0.root", inputRun); - TFile* f = TFile::Open(path); - if (f->IsZombie()) - { - // if we cannot open the file, print an error messageForm("hist%i",nHistNtuple) and return immediatly - printf("Error: cannot open %s\n", path.Data()); - exit(0); - } - // get a pointer to the tree - TNtuple* noiseNtuple = (TNtuple*) f->Get("noise"); - - Float_t noise; - TBranch* noiseBranch; - noiseNtuple->SetBranchAddress("noise", &noise, &noiseBranch); - // create histogram - TH1F* histNoise = new TH1F(Form("Noise%i",inputRun), "Noise title", 100, 0, 10); - - Int_t nentries_N = noiseNtuple->GetEntries(); - for (Int_t cnt=0; cntGetEntry(cnt); - histNoise->Fill(noise); - } - - // get median and error estimation - Double_t const probabilities[] = {0.3415/2, 0.5, 1-0.3415/2}; // sigma/2 from gaus to the left and to the right //{0.17, 0.5, 1-0.17}; - Double_t quantiles[3]; - histNoise->GetQuantiles( 3, quantiles, probabilities); - // noiseLowest17percent.push_back((Float_t) quantiles[0]); // left error bar (lowest 17% noise values are below this quantile) - // noiseMedian.push_back((Float_t) quantiles[1]); // median of the noise distribution - // noiseHighest17percent.push_back((Float_t) quantiles[2]); // right error bar (highest 17% noise values are higher than this quantile) - cout << "q1: " << quantiles[1] - quantiles[0] << "\tq2: " << quantiles[1] << "\tq3: " << quantiles[2] - quantiles[1] << endl; - - - TCanvas* cNoise = new TCanvas(); - cNoise->SetTitle(Form("Noise%i",inputRun)); - histNoise->Draw(); - TString legendEntry = TString(Form("Run %i: %.3f %.3f %.3f",inputRun,quantiles[1],quantiles[1] - quantiles[0],quantiles[2] - quantiles[1] )); - TLegend* leg = new TLegend(0.5,0.5,0.89,0.89);//(0.6,0.7,0.89,0.89); - leg->SetFillStyle(0); - leg->AddEntry((TObject*) 0, legendEntry, ""); - leg->SetTextSize(0.03); - leg->Draw(); - struct noise noiseHisto; - noiseHisto.noiseHisto=(TH1F*)histNoise->Clone(Form("NoiseX%i",inputRun)); - noiseHisto.inputRun=inputRun; - noiseHisto.quantiles=quantiles[1]; - noiseHisto.laborbookdata=laborbookdata; - //------------------------------------------------- -return noiseHisto; + // Read Laborbook, save it in the struct laborbookdata + struct laborbook laborbookdata; + laborbookdata=LaborBuchSQL(inputRun); + TString path = TString(DATAPATH) + Form("%i_0.root", inputRun); + TFile* f = TFile::Open(path); + if (f->IsZombie()) + { + // if we cannot open the file, print an error messageForm("hist%i",nHistNtuple) and return immediatly + printf("Error: cannot open %s\n", path.Data()); + exit(0); + } + // get a pointer to the tree + TNtuple* noiseNtuple = (TNtuple*) f->Get("noise"); + + Float_t noise; + TBranch* noiseBranch; + noiseNtuple->SetBranchAddress("noise", &noise, &noiseBranch); + // create histogram + TH1F* histNoise = new TH1F(Form("Noise%i",inputRun), "Noise title", 100, 0, 10); + + Int_t nentries_N = noiseNtuple->GetEntries(); + for (Int_t cnt=0; cntGetEntry(cnt); + histNoise->Fill(noise); + } + + // get median and error estimation + Double_t const probabilities[] = {0.3415/2, 0.5, 1-0.3415/2}; // sigma/2 from gaus to the left and to the right //{0.17, 0.5, 1-0.17}; + Double_t quantiles[3]; + histNoise->GetQuantiles( 3, quantiles, probabilities); + // noiseLowest17percent.push_back((Float_t) quantiles[0]); // left error bar (lowest 17% noise values are below this quantile) + // noiseMedian.push_back((Float_t) quantiles[1]); // median of the noise distribution + // noiseHighest17percent.push_back((Float_t) quantiles[2]); // right error bar (highest 17% noise values are higher than this quantile) + cout << "q1: " << quantiles[1] - quantiles[0] << "\tq2: " << quantiles[1] << "\tq3: " << quantiles[2] - quantiles[1] << endl; + + + TCanvas* cNoise = new TCanvas(); + cNoise->SetTitle(Form("Noise%i",inputRun)); + histNoise->Draw(); + TString legendEntry = TString(Form("Run %i: %.3f %.3f %.3f",inputRun,quantiles[1],quantiles[1] - quantiles[0],quantiles[2] - quantiles[1] )); + TLegend* leg = new TLegend(0.5,0.5,0.89,0.89);//(0.6,0.7,0.89,0.89); + leg->SetFillStyle(0); + leg->AddEntry((TObject*) 0, legendEntry, ""); + leg->SetTextSize(0.03); + leg->Draw(); + struct noise noiseHisto; + noiseHisto.noiseHisto=(TH1F*)histNoise->Clone(Form("NoiseX%i",inputRun)); + noiseHisto.inputRun=inputRun; + noiseHisto.quantiles=quantiles[1]; + noiseHisto.laborbookdata=laborbookdata; + //------------------------------------------------- + return noiseHisto; } struct laborbook LaborBuch(Int_t inputRun) { - std::string system; - Float_t temperature; // desired temperature - Float_t tempSens; // actual temperature - std::string chip; // chip number (eg. 1-6) - std::string source; - std::string matrix; - std::string radDose; - - std::ifstream file("LaborbuchMi34.txt"); - CSVRow row; - file >> row; - while (file >> row) - { + std::string system; + Float_t temperature; // desired temperature + Float_t tempSens; // actual temperature + std::string chip; // chip number (eg. 1-6) + std::string source; + std::string matrix; + std::string radDose; + + std::ifstream file("LaborbuchMi34.txt"); + CSVRow row; + file >> row; + while (file >> row) + { + + try + { + Int_t runLabor; + runLabor=atoi(row[COLRUNNO].c_str()); + //cout<ServerInfo()); + + TSQLRow *rowsql; + TSQLResult *res; try - { - Int_t runLabor; - runLabor=atoi(row[COLRUNNO].c_str()); - //cout<Query(sqlquery); + + int nrows = res->GetRowCount(); + // printf("\nGot %d rows in result\n", nrows); + + if (nrows > 0) + { + rowsql = res->Next(); + + system = std::string(rowsql->GetField(0)); + temperature = atof(rowsql->GetField(1)); + tempSens = atof(rowsql->GetField(2)); + chip = std::string(rowsql->GetField(4)); + source = std::string(rowsql->GetField(5)); + matrix = std::string(rowsql->GetField(6)); + radDose = std::string(rowsql->GetField(7)); + + } + } catch(...) - { - cout << "Error while reading laboratory book (run number " << inputRun << ")!\n"; + { + cout << "Error while reading laboratory book (run number " << inputRun << ")!\n"; } - } - - cout<<"Run:"<> row) - { + Int_t* runList=new Int_t[1000]; - try - { - - - - runList[runLauf]=atoi(row[0].c_str()); - - runLauf++; - } - catch(...) - { - cout << "File ended"; + std::ifstream file("runlist.txt"); + CSVRow row; + Int_t runLauf=0; + while (file >> row) + { + + try + { + + + + runList[runLauf]=atoi(row[0].c_str()); + + runLauf++; + } + catch(...) + { + cout << "File ended"; + } } - } - *numberRuns=runLauf; - return runList; + *numberRuns=runLauf; + return runList; } \ No newline at end of file