| 12,16 → 12,17 |
| #include "TSpectrum.h" |
| #include "stdio.h" |
| #include "THStack.h" |
| #include "TPaveText.h" |
| |
| #include "include/RTUtil.h" |
| |
| double getNoise(TH2F*, int, int); |
| |
| int biasScan(char filename[256] = "test", char plopt[256]="th", int chXstart=0, int chXend=7, int chYstart=0, int chYend=7, bool debug = false) |
| int biasScan(char filename[256] = "test", char plopt[256]="th", int chXstart=0, int chXend=7, double par1=0.0, double par2=0.0, bool debug = false) |
| { |
| const int c_nChannels = 64; |
| const double c_xOffset = 1; // mm |
| const double c_yOffset = 0.7; |
| const double c_xOffset = 0; // mm |
| const double c_yOffset = 0; |
| |
| int map[8][8]={{32,34,53,55,40,42,61,63}, |
| {48,50,37,39,56,58,45,47}, |
| 74,7 → 75,7 |
| TH2D* h_correctedTDC = (TH2D*) h0->Project3D("xz"); |
| //h0->GetZaxis()->SetRangeUser(-5,5); |
| //h0->Project3D("xzo")->Draw("colz"); |
| h_correctedTDC->SetTitle("; t [ns]; Channel"); |
| //h_correctedTDC->SetTitle("; t [ns]; Channel"); |
| h_correctedTDC->Draw("colz"); |
| /* |
| TH1F* tdc1 = new TH1F("tdc1",";TDC [ns];Events",binsZ, minZ, maxZ); |
| 89,7 → 90,7 |
| |
| TH2D* h_timeWalk = (TH2D*) h0->Project3D("zy"); |
| canvas21->cd(2); |
| h_timeWalk->SetTitle(";Threshold [V]; t [ns]"); |
| //h_timeWalk->SetTitle(";Threshold [V]; t [ns]"); |
| h_timeWalk->Draw("colz"); |
| } |
| |
| 137,10 → 138,10 |
| main->cd(); |
| main->Divide(4,4); |
| for(int i=chXstart; i<chXend; i++) { |
| for(int j=chYstart; j<chYend; j++) { |
| for(int j=(int)par1; j<(int)par2; j++) { |
| int channel = map[i][j]; |
| TH1D* h_projection = h_threshold->ProjectionY("",channel+1,channel+1); |
| int canvasPosition = i-chXend+4*(chYend-j)+1; |
| int canvasPosition = i-chXend+4*((int)par2-j)+1; |
| printf(" %d ", canvasPosition); |
| main->cd(canvasPosition); |
| gPad->SetMargin(0.08, 0.08, 0.08, 0.08); |
| 181,7 → 182,28 |
| h_projection->SetMarkerStyle(kFullDotMedium); |
| //h_projection->SetMarkerSize(8); |
| gPad->SetMargin(0.1,0.1,0.1,0.1); |
| |
| |
| TF1* f_linear = new TF1("f_linear", "[0] + [1]*x", par1, par2); |
| f_linear->SetParameter(0, -1); |
| f_linear->SetParameter(1, 0.1); |
| f_linear->SetParNames("p0", "p1"); |
| h_projection->Fit(f_linear,"q"); |
| h_projection->Fit(f_linear,"r"); |
| h_projection->Draw("pe1x0"); |
| |
| double p0 = f_linear->GetParameter(0); |
| double p1 = f_linear->GetParameter(1); |
| printf("p0 %f p1 %f V_b = %f [V]\n", p0, p1, -p0/p1); |
| TPaveText *text = new TPaveText(0.15,0.5,0.35,0.56); |
| text->SetFillColor(0); |
| text->SetBorderSize(0.1); |
| text->SetTextSize(0.030); |
| char string[128]; |
| sprintf(string, "V_b = %2.2f", -p0/p1); |
| text->AddText(string); |
| text->Draw("same"); |
| text->Paint(); |
| } |
| |
| if( strstr(plopt, "all") != NULL ) { |
| 223,167 → 245,8 |
| h_hitsy = (TH1F*)rootfile->Get(hname); |
| h_hitsy->Draw(); |
| } |
| |
| |
| if( strstr(plopt, "share") != NULL ) { |
| /*TCanvas *canvas4 = new TCanvas("canvas1","canvas1",1000,1000); |
| int nChannels = chYend-chYstart+1; |
| int ncols = nChannels/2; |
| printf("nch %d nch\\2 %d\n", nChannels, ncols); |
| canvas4->Divide(2,ncols); |
| TH1F* h_hitsy; |
| for(int i=chYstart; i<=chYend; i++){ |
| canvas4->cd(i-chYstart+1); |
| char hname[128]; |
| int chPosition = map[0][i]; |
| sprintf(hname, "hnhitsy%d", chPosition); |
| h_hitsy = (TH1F*)rootfile->Get(hname); |
| h_hitsy->Draw(); |
| }*/ |
| |
| TCanvas *canvas4 = new TCanvas("canvas4","canvas4",500,500); |
| canvas4->cd(); |
| for(int i=chXstart; i<=chXend; i++) { |
| TH1F* h_hitsx; |
| char hname[128]; |
| int chPosition = map[i][chYstart]; |
| sprintf(hname, "hnhitsx%d", chPosition); |
| h_hitsx = (TH1F*)rootfile->Get(hname); |
| h_hitsx->SetTitle("Scan X;x [mm]; Entries"); |
| h_hitsx->GetYaxis()->SetTitleOffset(1.3); |
| h_hitsx->SetStats(0); |
| if (i == chXstart) |
| h_hitsx->Draw(); |
| else { |
| h_hitsx->SetLineColor(i+1); |
| h_hitsx->Draw("same"); |
| } |
| } |
| //sprintf(fullname, "ps/%s_Yshare.eps", filename); |
| //canvas4->SaveAs(fullname); |
| |
| TCanvas *canvas5 = new TCanvas("canvas5","canvas5",500,500); |
| canvas5->cd(); |
| for(int i=chYstart; i<=chYend; i++) { |
| TH1F* h_hitsy; |
| char hname[128]; |
| int chPosition = map[chXstart][i]; |
| sprintf(hname, "hnhitsy%d", chPosition); |
| h_hitsy = (TH1F*)rootfile->Get(hname); |
| h_hitsy->SetTitle("Scan Y;y [mm]; Entries"); |
| h_hitsy->GetYaxis()->SetTitleOffset(1.3); |
| h_hitsy->SetStats(0); |
| if (i == chYstart) |
| h_hitsy->Draw(); |
| else { |
| h_hitsy->SetLineColor(i+1); |
| h_hitsy->Draw("same"); |
| } |
| } |
| //sprintf(fullname, "ps/%s_Yshare.eps", filename); |
| //canvas5->SaveAs(fullname); |
| } |
| |
| /** Draws the signal from 8 channels in x-row |
| * for one specific y bin, so the background and cross-talk |
| * can be estimated. |
| * Draws also a 2d scan of these channels. |
| */ |
| if (strstr(plopt, "line") != NULL) { |
| TCanvas* canvas6 = new TCanvas("canvas6","canvas6",500,500); |
| canvas6->cd(0); |
| gStyle->SetOptStat(0); |
| |
| TH2F* h0 = (TH2F*) rootfile->Get("h2d0"); |
| Int_t binsX = h0->GetXaxis()->GetNbins(); |
| Int_t minX = h0->GetXaxis()->GetFirst(); |
| Int_t maxX = h0->GetXaxis()->GetLast()+1; |
| Int_t binsY = h0->GetYaxis()->GetNbins(); |
| Int_t minY = h0->GetYaxis()->GetFirst(); |
| Int_t maxY = h0->GetYaxis()->GetLast()+1; |
| Double_t xLowUser = h0->GetXaxis()->GetBinLowEdge(minX); |
| Double_t xUpUser = h0->GetXaxis()->GetBinUpEdge(maxX); |
| Double_t yLowUser = h0->GetYaxis()->GetBinLowEdge(minY); |
| Double_t yUpUser = h0->GetYaxis()->GetBinUpEdge(maxY); |
| if (debug) printf("xLow %f xUp %f\n",xLowUser,xUpUser); |
| |
| //! 1-dimension position in x vs. hits |
| TH2F* h[8]; |
| TH1F* h_line[8]; |
| for(int j=0; j<8; j++) { |
| h_line[j] = new TH1F("h_line", "h_line", binsX, xLowUser, xUpUser); |
| } |
| |
| for(int j=chXstart; j<=chXend; j++) { |
| int chPosition = map[j][chYstart]; |
| char hname[128]; |
| sprintf(hname, "h2d%d", chPosition); |
| int histogram = j; |
| h[histogram] = (TH2F *) rootfile->Get(hname); |
| int noise = getNoise(h[histogram], 1, 160); |
| for(int k=minX; k<=maxX; k++) { |
| int l=chYstart*20+12; |
| //for(int l=12; l<=16; l++) { |
| double signal = h[histogram]->GetBinContent(k,l); |
| //signal -= noise; |
| //signal /= 5*10000.0; |
| double eta = -log(1 - signal); |
| double x = k*(xUpUser-xLowUser)/double(binsX); |
| //double y = l*(yUpUser-yLowUser)/double(binsY); |
| h_line[j]->Fill(x-c_xOffset, signal); |
| //} |
| } |
| if (j == chXstart) { |
| h_line[j]->SetTitle("SiPM#2 w/o noise subtraction;x[mm];Hits"); |
| //h_line[j]->GetYaxis()->SetRangeUser(-0.05, 0.3); |
| //h_line[j]->GetYaxis()->SetRangeUser(-50, 2500); |
| h_line[j]->Draw(""); |
| } |
| else { |
| h_line[j]->SetLineColor(j+1); |
| h_line[j]->Draw("same"); |
| } |
| } |
| |
| |
| //! 2d scan |
| TCanvas* canvas61 = new TCanvas("canvas61","canvas61",8*200,300); |
| canvas61->cd(); |
| TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX,xLowUser,xUpUser, binsY,yLowUser,yUpUser); |
| for(int i=chXstart; i<=chXend; i++) { |
| //int canvasPosition = nX*(i-chYstart)+(j-chXstart)+1; |
| //int canvasPosition = nX*(chYend-i)+chXstart+1; |
| //if (debug) printf("canvas %d\n",canvasPosition); |
| int chPosition = map[i][chYstart]; |
| char hname[128]; |
| sprintf(hname, "h2d%d", chPosition); |
| int histogram = i; |
| h[histogram] = (TH2F *) rootfile->Get(hname); |
| int noise = getNoise(h[histogram], 1, 100); |
| |
| for(int k=minX; k<=maxX; k++) { |
| for(int l=minY; l<=maxY; l++) { |
| int signal = h[histogram]->GetBinContent(k,l); // detected |
| //p /= 10000.; |
| //double p0 = 1.0 - p; // events with zero photons |
| //double eta = (-log(p0) * p0 ) / (1-p0-0.00001); |
| //double eta = -log(p0); |
| //printf("p=%f p0=%f log(p0)=%f eta=%f\n",p,p0,log(p0),eta); |
| //double signal = ((p - noise) > 0.1) ? (p-noise) : 0.1; |
| double p = signal - noise; |
| p /= 10000.0; |
| double eta = -log(1 - p); |
| double x = k*(xUpUser-xLowUser)/double(binsX); |
| double y = l*(yUpUser-yLowUser)/double(binsY); |
| h_corrected->Fill(x-c_xOffset, y-c_yOffset, eta); |
| } |
| } |
| } |
| h_corrected->SetTitle("SiPM#2 n_pe = - ln(P0);x[mm];y[mm]"); |
| h_corrected->GetZaxis()->SetRangeUser(-0.05,0.30); |
| h_corrected->Draw("colz"); |
| |
| } |
| |
| /** Draws the sum of the channels |
| * Each channel is a 2d plot |
| * Intended for the study of 1 channel |
| 391,14 → 254,14 |
| if (strstr(plopt, "2d") != NULL) { |
| |
| int nX = chXend - chXstart + 1; |
| int nY = chYend - chYstart + 1; |
| int nY = (int)par2 - (int)par1 + 1; |
| TCanvas* canvas7 = new TCanvas("canvas7","canvas7", nX*400,nY*400); |
| printf("nx %d ny %d\n",nX,nY); |
| canvas7->Divide(nX,nY); |
| for(int i=chYstart; i<=chYend; i++) { |
| for(int i=(int)par1; i<=(int)par2; i++) { |
| for(int j=chXstart; j<=chXend; j++) { |
| //int canvasPosition = nX*(i-chYstart)+(j-chXstart)+1; |
| int canvasPosition = nX*(chYend-i)+(j-chXstart)+1; |
| int canvasPosition = nX*((int)par2-i)+(j-chXstart)+1; |
| if (debug) printf("canvas %d\n",canvasPosition); |
| canvas7->cd(canvasPosition); |
| char hname[128]; |
| 471,8 → 334,8 |
| * Suitable for 8x8 chs scan |
| */ |
| if( strstr(plopt, "sum") != NULL ) { |
| int nX = chXend - chXstart + 1; |
| int nY = chYend - chYstart + 1; |
| int nX = 7 - 0 + 1; |
| int nY = 7 - 0 + 1; |
| TCanvas* canvas12 = new TCanvas("canvas12","c2",8*200, 8*200); |
| canvas12->cd(); |
| gStyle->SetOptStat(0); |
| 494,12 → 357,12 |
| TH2F* h[9]; |
| |
| // 2d histogram noise subtraction and poisson scaling |
| for(int i=chYstart; i<=chYend; i++) { |
| for(int i=0; i<=7; i++) { |
| for(int j=chXstart; j<=chXend; j++) { |
| int chPosition = map[j][i]; |
| char hname[128]; |
| sprintf(hname, "h2d%d", chPosition); |
| int histogram = nX*(i-chYstart)+(j-chXstart); |
| int histogram = nX*(i-0)+(j-chXstart); |
| h[histogram] = (TH2F *) rootfile->Get(hname); |
| int noise = getNoise(h[histogram], 1, 170); |
| if (debug) printf("noise: %d\n",noise); |