From: Benjamin Linnik Date: Fri, 13 Dec 2013 21:49:54 +0000 (+0100) Subject: newCOMBI: cleaned up ChargeSpektrum.c code X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=ddc2808905b56a1a1d5355deed9a0f70579f6175;p=radhard.git newCOMBI: cleaned up ChargeSpektrum.c code --- diff --git a/newCOMBI/ChargeSpektrum.c b/newCOMBI/ChargeSpektrum.c index 001eba4..2abfe7c 100755 --- a/newCOMBI/ChargeSpektrum.c +++ b/newCOMBI/ChargeSpektrum.c @@ -76,6 +76,8 @@ struct laborbook LaborBuch(Int_t inputRun); struct laborbook LaborBuchSQL(Int_t inputRun); Int_t* ReadRunList(Int_t* numberRuns); struct noise Noise(Int_t inputRun); +Int_t GetMaxBin(TString system); + void ChargeSpektrum() { @@ -92,10 +94,10 @@ void ChargeSpektrum() noiseHisto[lauf]=Noise(runList[lauf]); arrayHisto[lauf]=GenerateHisto(runList[lauf]); } - + Double_t w = 600; Double_t h = 600; - TCanvas * c1 = new TCanvas("c", "c", w, h); + TCanvas * c1 = new TCanvas("c", "Seed spectra", w, h); c1->SetWindowSize(w + (w - c1->GetWw()), h + (h - c1->GetWh())); arrayHisto[0].Seed->Draw(""); @@ -104,71 +106,77 @@ void ChargeSpektrum() arrayHisto[lauf].Seed->Draw("same"); } - TString ergebnisfile="ergebnisfile.dat"; + TString ergebnisfile= "ergebnisfile.dat"; + TString header; + TString outline; fstream* fout = new fstream(ergebnisfile,ios::out); for(Int_t lauf=0;laufclose(); + + for(Int_t lauf=0;laufopen(ergebnisfile,ios::out); + + header ="runnumber\trad source\tmatrix\ttemp cooling\ttemp chip\trad dose\tpos. seed\tpos. sum\tpos. veto\tquantiles\n"; + outline=header+Form("%i", arrayHisto[lauf].inputRun)+"\t"+arrayHisto[lauf].laborbookdata.source+"\t"+arrayHisto[lauf].laborbookdata.matrix+"\t"+Form("%.2f",arrayHisto[lauf].laborbookdata.temp)+"\t"+Form("%.2f",arrayHisto[lauf].laborbookdata.tempSens)+"\t"+arrayHisto[lauf].laborbookdata.radDose+"\t"+Form("%.2f", arrayHisto[lauf].posSeed)+"\t"+Form("%.2f", arrayHisto[lauf].posSum)+"\t"+Form("%.2f", arrayHisto[lauf].posVeto)+"\t"+Form("%.2f", noiseHisto[lauf].quantiles); + + *fout<close(); + } /* - * 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<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<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); - + // get a pointer to the tree TTree* hitNtuple = (TTree*) f->Get("hit"); UInt_t frame; UInt_t hits; UInt_t seedPixel[10000]; - Float_t pixel[25][10000]; + Float_t pixel[NUMPIXELS][10000]; - - hitNtuple->SetBranchAddress ("frame" , &frame); hitNtuple->SetBranchAddress ("hits" , &hits); hitNtuple->SetBranchAddress ("pixel" , seedPixel ); // hitNtuple->SetBranchAddress ( "p13" , pixel ); - - - for(int i=0;i<25;i++) { hitNtuple->SetBranchAddress( Form("p%i",i+1) , &pixel[i][0] ); } + // fill ttree with pixel branchs fields + for(int i=0;iSetBranchAddress( Form("p%i",i+1) , &pixel[i][0] ); } // fHitTree = new TTree("hit", "hit"); @@ -225,26 +209,19 @@ struct histogram GenerateHisto(Int_t inputRun) // fHitTree->SetBranchAddress("hits" , &fFrameInfo.hits ); // fHitTree->SetBranchAddress("pixel" , &fFrameInfo.pixel[0] ); - // loop over all hits to fill histogram Int_t nentries = hitNtuple->GetEntries(); -// cout<<"TEST4 Run:"<GetEntry(cnt); - -// cout << cnt << " " << laborbookdata.inputRun << " " << tempsamirvar << " " ; -// cout<GetEntry(cnt); // get + // take only frames with less then 10 hits if (hits<10) { for(unsigned int i=0; i "<GetEntry((Int_t) frame); // if (frameCounts > 1) @@ -255,29 +232,30 @@ struct histogram GenerateHisto(Int_t inputRun) histNtuple->Fill(pixel[12][i]); // histogram with the summed pixels -// Double_t pixelSum = 0; -// for (Int_t i=0; iFill(pixelSum); + Float_t pixelSum = 0; + for (Int_t j=0; jFill(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 - }} +// histogram with the single pixel and with "veto trigger" +// for the "histNtupleVeto" take only hits where only the seed pixel contains charge + Float_t notSeedSum = 0; + for (Int_t j=0; j<12; j++) + notSeedSum += pixel[j][i]; + for (Int_t j=13; j VETO_THRESHOLD) + continue; +// meanNotSeedSum+=notSeedSum; +// nhits++; + histNtupleVeto->Fill(pixel[12][i]); // histogram with the single pixel + } + } } TCanvas* c1 = new TCanvas(); - c1->SetTitle(Form("Seed%i",inputRun)); + c1->SetTitle(Form("Spectra %i",inputRun)); c1->Divide(2,2); c1->cd(1); histNtuple->Draw(""); @@ -310,6 +288,7 @@ struct histogram GenerateHisto(Int_t inputRun) 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->SetTitle("All spectra"); histNtupleSame->Draw(""); histNtupleSame->SetMaximum(1.05*maxY); histNtupleSumSame->Draw("same"); @@ -317,7 +296,6 @@ struct histogram GenerateHisto(Int_t inputRun) histNtupleSumSame->SetLineColor(1); histNtupleVetoSame->SetLineColor(2); - struct histogram arrayHisto; arrayHisto.Seed=(TH1F*)histNtuple->Clone(Form("hist%i",inputRun)); @@ -328,7 +306,7 @@ struct histogram GenerateHisto(Int_t inputRun) arrayHisto.posSum=posSum; arrayHisto.posVeto=posVeto; // cout<<"TEST1"<Draw(""); if (DRAW_FITS) { @@ -384,37 +353,51 @@ Float_t FitPerform(TH1F* histNtuple, Int_t inputRun) 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(); + 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; } + + +Int_t GetMaxBin(TString system) +{ + if(system=="USB") + { + return 800; + } + else + { + return 8000; + } +} + struct noise Noise(Int_t inputRun) { // Read Laborbook, save it in the struct laborbookdata @@ -509,7 +492,7 @@ struct laborbook LaborBuch(Int_t inputRun) } } -// cout<<"Run:"<