/sipmScan/examples/plot_tdc_C.lib |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/sipmScan/examples/mppc.cpp |
---|
0,0 → 1,188 |
#include "TROOT.h" |
#include "TFile.h" |
#include "TBenchmark.h" |
#include "TH1F.h" |
#include "TH2F.h" |
#include "TCanvas.h" |
#include "TStyle.h" |
#include "TPad.h" |
#include "TF1.h" |
#include "TGraph.h" |
#include "TSpectrum.h" |
#include "RTUtil.h" |
#define TDC_BIN (25./1000.) //1 TDC bin in ns |
#define MIKRO_BIN 0.49609/1000. //1 mikro step in mm |
#define HFILL_COLOR 18 |
void mppc(char *fname, char *plopt="t", int nChannels = 1, double fitw=1.0, char *fitf="g") |
{ |
char fullname[256]; |
//get ROOT file with histograms |
char fnameroot[1024]; |
TFile * rootfile; |
TDirectory *dir; |
sprintf(fnameroot, "root/%s.root", fname); |
rootfile = (TFile *) gROOT->FindObject(fname); |
if(rootfile==NULL) rootfile = new TFile(fnameroot); |
if(rootfile==NULL) { |
printf("Cannot open root file %s!!!\n",fnameroot); |
return; |
} |
dir = (TDirectory*) rootfile; |
// set draw style |
gStyle->SetOptStat("ne"); |
gStyle->SetPalette(1, 0); |
gStyle->SetPaperSize(TStyle::kA4); |
gStyle->SetStatBorderSize(1); |
gStyle->SetFrameBorderMode(0); |
gStyle->SetFrameFillColor(0); |
gStyle->SetCanvasBorderMode(0); |
gStyle->SetPadBorderMode(0); |
gStyle->SetPadColor(0); |
gStyle->SetCanvasColor(0); |
gStyle->SetStatColor(0); |
gStyle->SetOptFit(11); |
gStyle->SetOptStat(); |
gStyle->SetPadRightMargin(0.15); |
gStyle->SetPadLeftMargin(0.12); |
//gStyle->SetTitleYOffset(1.4); |
TCanvas *c[16]; |
int cc=-1; |
char hname[256]; |
TH1F *hp1d; TH2F *hp2d; |
// 2d Scan -------------------------------------------------------------------------------------------- |
if( strchr(plopt, '2') != NULL ) { |
c[++cc] = new TCanvas("2D Scan", fname, 650, 400, 600, 600); |
int i=0; |
gPad->SetLogz(); |
sprintf(hname, "h2d%d",i); hp2d = (TH2F *) dir->Get(hname); |
(hp2d->GetYaxis())->SetLabelOffset(0.01); |
hp2d->SetTitle("; X [mm]; Y[mm]"); |
hp2d->DrawCopy("COLZ"); |
sprintf(fullname, "ps/%s_2d.eps", fname); |
c[cc]->SaveAs(fullname); |
} |
// 1d Scan Y ------------------------------------------------------------------------------------------ |
if( strchr(plopt, 'y') != NULL ) { |
c[++cc] = new TCanvas("Y Scan", fname, 250, 200, 600, 600); |
int i=0; |
//gPad->SetLogy(); |
sprintf(hname, "hnhitsy%d",i); hp1d = (TH1F *) dir->Get(hname); |
hp1d->SetTitle("Y Scan; Y; Count"); |
hp1d->DrawCopy(); |
sprintf(fullname, "ps/%s_y.eps", fname); |
c[cc]->SaveAs(fullname); |
} |
// 1d Scan X ------------------------------------------------------------------------------------------ |
if( strchr(plopt, 'x') != NULL ) { |
c[++cc] = new TCanvas("X Scan", fname, 250, 200, 600, 600); |
int i=0; |
//gPad->SetLogy(); |
sprintf(hname, "hnhitsx%d",i); hp1d = (TH1F *) dir->Get(hname); |
hp1d->SetTitle("X Scan; X; Count"); |
hp1d->DrawCopy(); |
sprintf(fullname, "ps/%s_x.eps", fname); |
c[cc]->SaveAs(fullname); |
} |
// Fits of corrected TDCs ----------------------------------------------------------------------------- |
TF1 *fg = new TF1("fg", "gaus"); |
TF1 *fgg = new TF1("fgg", "gaus(0)+gaus(3)"); |
fgg->SetParNames("Constant","Mean","Sigma","Constant2","Mean2","Sigma2"); |
if( strchr(plopt, 'f') != NULL ) { |
c[++cc] = new TCanvas("Corrected TDCs", fname, 50*(cc+1), 0, 600, 850); |
//c[cc]->Divide(2,4); |
c[cc]->Divide(nChannels); |
for(int i=0;i<nChannels;i++) { |
c[cc]->cd(i+1); gPad->SetLogy(); |
sprintf(hname, "hctdc%d",i); hp1d = (TH1F *) dir->Get(hname); |
hp1d->SetTitle("cTDC; TDC [ns]; N"); |
(hp1d->GetXaxis())->SetRangeUser(-40*TDC_BIN,160*TDC_BIN); |
if( hp1d->GetMaximum() < 50 ) continue; |
//(hp1d->GetXaxis())->SetRangeUser(-0.25,0.75); |
if( strcmp(fitf, "g")==0 ) { |
fg->SetParameters(hp1d->GetMaximum(), hp1d->GetBinCenter(hp1d->GetMaximumBin()), 0.05); |
hp1d->Fit(fg, "0ql", "", fg->GetParameter(1)-0.1*fitw, fg->GetParameter(1)+0.05*fitw); |
hp1d->Fit(fg, "ql", "", fg->GetParameter(1)-0.1*fitw, fg->GetParameter(1)+0.05*fitw); |
printf("Ch[%d] Sigma =%6.1lfps\n",i,fg->GetParameter(2)*1000.); |
} |
else if( strcmp(fitf, "gg")==0 ) { |
//fgg->SetParameters(2600.,0*TDC_BIN,2*TDC_BIN, 100.,0*TDC_BIN,10*TDC_BIN); |
fgg->SetParameters(hp1d->GetMaximum(), hp1d->GetBinCenter(hp1d->GetMaximumBin()), 0.03, |
hp1d->GetMaximum(), hp1d->GetBinCenter(hp1d->GetMaximumBin())/10., 0.1); |
hp1d->Fit(fgg, "0ql", "", -50*TDC_BIN, 50*TDC_BIN); |
hp1d->Fit(fgg, "ql", "", fgg->GetParameter(1)-2.5*fitw*fgg->GetParameter(2), |
fgg->GetParameter(1)+3.5*fitw*fgg->GetParameter(2)); |
printf("Ch[%d] Sigma =%6.1lfps\n",i,fgg->GetParameter(2)*1000.); |
/* |
fg->SetRange(-50., 200.); |
fg->SetParameters(fgg->GetParameter(0), fgg->GetParameter(1), fgg->GetParameter(2)); |
fg->SetLineColor(2); |
fg->DrawCopy("LSAME"); |
fg->SetParameters(fgg->GetParameter(3), fgg->GetParameter(4), fgg->GetParameter(5)); |
fg->SetLineColor(3); |
fg->DrawCopy("LSAME"); |
*/ |
} else {printf("Wrong fit function (parameter 4)!!!\n"); return;} |
} |
sprintf(fullname, "ps/%s_cTDC.eps", fname); |
c[cc]->SaveAs(fullname); |
} |
// TDCs ----------------------------------------------------------------------------------------------- |
if( strchr(plopt, 't') != NULL ) { |
c[++cc] = new TCanvas("Raw TDC", fname, 0, 500, 600, 430); |
int i=0; |
gPad->SetLogy(); |
sprintf(hname, "htdc%d",i); hp1d = (TH1F *) dir->Get(hname); |
hp1d->SetTitle("TDC; TDC [ns]; N"); |
(hp1d->GetXaxis())->SetRangeUser(-10,20); |
hp1d->DrawCopy(); |
//if( hp1d->GetMaximum() < 10 ) continue; |
fg->SetParameters(hp1d->GetMaximum(), hp1d->GetBinCenter(hp1d->GetMaximumBin()), 0.25); |
fg->SetLineColor(kRed); |
hp1d->Fit(fg,"0QL", "", fg->GetParameter(1)-0.5, fg->GetParameter(1)+0.5); |
hp1d->Fit(fg,"QL", "", fg->GetParameter(1)-0.8, fg->GetParameter(1)+0.8); |
printf("Ch[%d] RAW Sigma =%6.1lfps\n",i,fg->GetParameter(2)*1000.); |
sprintf(fullname, "ps/%s_TDC.eps", fname); |
c[cc]->SaveAs(fullname); |
} |
//rootfile->Close(); |
} |
/sipmScan/examples/plot_adc_tdc.C |
---|
0,0 → 1,9 |
{ |
TFile *file0 = new TFile("C:/HOME/dino/l2d/root/test.root"); |
//TNtuple *ntuple = (TNtuple*) file0->Get("nt"); |
TCanvas *canvas1 = new TCanvas("canvas1","canvas1",1000,500); |
canvas1->Divide(2); |
canvas1->cd(1); |
htdc->Draw(); |
} |
/sipmScan/examples/plotThresholdScan.C |
---|
0,0 → 1,471 |
#include "TROOT.h" |
#include "TFile.h" |
#include "TBenchmark.h" |
#include "TH1F.h" |
#include "TH2F.h" |
#include "TCanvas.h" |
#include "TStyle.h" |
#include "TPad.h" |
#include "TF1.h" |
#include "TGraph.h" |
#include "TSpectrum.h" |
#include "stdio.h" |
#include "RTUtil.h" |
double getNoise(TH2F*, int, int); |
int plotThreshold(char filename[256] = "test", char plopt[256]="th", int chXstart=0, int chXend=7, int chYstart=0, int chYend=7, bool debug = false) |
{ |
const int c_nChannels = 64; |
const double c_xOffset = 1; // mm |
const double c_yOffset = 0.7; |
int map[8][8]={{32,34,53,55,40,42,61,63}, |
{48,50,37,39,56,58,45,47}, |
{33,35,52,54,41,43,60,62}, |
{49,51,36,38,57,59,44,46}, |
{17,19,4,6,25,27,12,14}, |
{1,3,20,22,9,11,28,30}, |
{16,18,5,7,24,26,13,15}, |
{0,2,21,23,8,10,29,31} |
}; |
char fnameroot[256]; |
TFile* rootfile; |
sprintf(fnameroot, "root/%s.root", filename); |
rootfile = (TFile *) gROOT->FindObject(filename); |
if(rootfile==NULL) rootfile = new TFile(fnameroot); |
if(rootfile==NULL) { |
printf("Cannot open root file %s!!!\n",fnameroot); |
return(0); |
} |
// set draw style |
gStyle->SetOptStat("ne"); |
gStyle->SetPalette(1, 0); |
gStyle->SetPaperSize(TStyle::kA4); |
gStyle->SetStatBorderSize(1); |
gStyle->SetFrameBorderMode(0); |
gStyle->SetFrameFillColor(0); |
gStyle->SetCanvasBorderMode(0); |
gStyle->SetPadBorderMode(0); |
gStyle->SetPadColor(0); |
gStyle->SetCanvasColor(0); |
gStyle->SetStatColor(0); |
gStyle->SetOptFit(11); |
gStyle->SetOptStat(); |
gStyle->SetPadRightMargin(0.15); |
gStyle->SetPadLeftMargin(0.12); |
//gStyle->SetTitleYOffset(1.4); |
if (strstr(plopt, "th") != NULL) { |
TCanvas* canvas1 = new TCanvas("canvas1","",500,500); |
canvas1->cd(); |
TH2F* h_threshold = (TH2F*) rootfile->Get("h_threshold"); |
h_threshold->Draw("colz"); |
} |
if( strstr(plopt, "all") != NULL ) { |
TCanvas *canvas2 = new TCanvas("canvas2","Hits x;;",2000,2000); |
TCanvas *canvas3 = new TCanvas("canvas3","Hits y;;",2000,2000); |
canvas2->Divide(8,8); |
canvas3->Divide(8,8); |
TH1F* h_hitsx; |
TH1F* h_hitsy; |
for(int i=0; i<c_nChannels; i++) { |
canvas2->cd(i+1); |
char hname[128]; |
sprintf(hname, "hnhitsx%d", i); |
h_hitsx = (TH1F*)rootfile->Get(hname); |
h_hitsx->Draw(); |
canvas3->cd(i+1); |
sprintf(hname, "hnhitsy%d", i); |
h_hitsy = (TH1F*)rootfile->Get(hname); |
h_hitsy->Draw(); |
} |
} |
if( strstr(plopt, "x") != NULL ) { |
TCanvas *canvas10 = new TCanvas("canvas10","Ch x;;",500,500); |
TH1F* h_hitsx; |
canvas10->cd(); |
char hname[128]; |
sprintf(hname, "hnhitsx%d", chXstart); |
h_hitsx = (TH1F*)rootfile->Get(hname); |
h_hitsx->Draw(); |
} |
if( strstr(plopt, "y") != NULL ) { |
TCanvas *canvas11 = new TCanvas("canvas11","Ch x;;",500,500); |
TH1F* h_hitsy; |
canvas11->cd(); |
char hname[128]; |
sprintf(hname, "hnhitsy%d", chXstart); |
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 |
*/ |
if (strstr(plopt, "2d") != NULL) { |
int nX = chXend - chXstart + 1; |
int nY = chYend - chYstart + 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 j=chXstart; j<=chXend; j++) { |
//int canvasPosition = nX*(i-chYstart)+(j-chXstart)+1; |
int canvasPosition = nX*(chYend-i)+(j-chXstart)+1; |
if (debug) printf("canvas %d\n",canvasPosition); |
canvas7->cd(canvasPosition); |
char hname[128]; |
int chPosition = map[j][i]; |
sprintf(hname, "h2d%d", chPosition); |
TH2F* h_2d = (TH2F*)rootfile->Get(hname); |
h_2d->Draw("colz"); |
} //x |
} |
// Number of photoelectrons - Poissonian correction |
TCanvas* canvas8 = new TCanvas("canvas8","canvas8", 1000,1000); |
canvas8->cd(); |
gStyle->SetOptStat(0); |
char hname[128]; |
int chPosition = map[1][2]; |
sprintf(hname, "h2d%d", chPosition); |
TH2F* h_2d = (TH2F*)rootfile->Get(hname); |
Int_t binsX = h_2d->GetXaxis()->GetNbins(); |
Int_t minX = h_2d->GetXaxis()->GetFirst(); |
Int_t maxX = h_2d->GetXaxis()->GetLast()+1; |
Int_t binsY = h_2d->GetYaxis()->GetNbins(); |
Int_t minY = h_2d->GetYaxis()->GetFirst(); |
Int_t maxY = h_2d->GetYaxis()->GetLast()+1; |
Double_t xLowUser = h_2d->GetXaxis()->GetBinLowEdge(minX); |
Double_t xUpUser = h_2d->GetXaxis()->GetBinUpEdge(maxX); |
Double_t yLowUser = h_2d->GetYaxis()->GetBinLowEdge(minY); |
Double_t yUpUser = h_2d->GetYaxis()->GetBinUpEdge(maxY); |
if (debug) printf("xLow %f xUp %f\n",xLowUser,xUpUser); |
TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX, xLowUser, xUpUser, binsY, yLowUser, yUpUser); |
double noise = getNoise(h_2d, 1, 89); |
if(debug) printf("Noise = %f\n", noise); |
for(int k=minX; k<=maxX; k++) { |
for(int j=minY; j<=maxY; j++) { |
double signal = h_2d->GetBinContent(k,j); // detected |
//double p = ((signal - noise) > 1) ? (signal-noise) : 1; |
double p = signal - noise; |
p /= 10000.; |
double p0 = 1.0 - p; // events with zero photons |
//double eta = (-log(p0) * p0 ) / (1-p0-0.00001); |
double eta = -log(p0); // constant of the poissonian statistics |
if (debug) printf("p=%f p0=%f log(p0)=%f eta=%f\n",p,p0,log(p0),eta); |
double x = k*(xUpUser-xLowUser)/double(binsX); |
double y = j*(yUpUser-yLowUser)/double(binsY); |
h_corrected->Fill(x+3,y+8, eta); |
} |
} |
h_corrected->SetTitle("n_pe = - ln P(0);x[mm];y[mm]"); |
h_corrected->GetZaxis()->SetRangeUser(-0.05,0.3); |
h_corrected->Draw("colz"); |
// collection efficiency |
int nPoints =0; |
double efficiency=0; |
for (int i=18; i<=58; i++) { |
for (int j=19; j<=59; j++) { |
double signal = h_corrected->GetBinContent(i,j); |
if(debug) printf("signal %f\n",signal); |
efficiency += signal; |
nPoints++; |
} |
} |
printf("Signal sum = %f\n # of points = %d\n",efficiency,nPoints); |
} |
/** Draws the sum of channel signals |
* Each channel is a 2d ('h2d') histogram |
* Suitable for 8x8 chs scan |
*/ |
if( strstr(plopt, "sum") != NULL ) { |
int nX = chXend - chXstart + 1; |
int nY = chYend - chYstart + 1; |
TCanvas* canvas12 = new TCanvas("canvas12","c2",8*200, 8*200); |
canvas12->cd(); |
gStyle->SetOptStat(0); |
// final histogram parameters |
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); |
TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX,xLowUser,xUpUser, binsY,yLowUser,yUpUser); |
TH2F* h[9]; |
// 2d histogram noise subtraction and poisson scaling |
for(int i=chYstart; i<=chYend; 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); |
h[histogram] = (TH2F *) rootfile->Get(hname); |
int noise = getNoise(h[histogram], 1, 170); |
if (debug) printf("noise: %d\n",noise); |
for(int k=minX; k<=maxX; k++) { |
for(int l=minY; l<=maxY; l++) { |
int signal = h[histogram]->GetBinContent(k,l); // detected |
//double p = ((signal - noise) > 0.1) ? (signal-noise) : 0.1; |
double p = signal - noise; |
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 x = k*(xUpUser-xLowUser)/double(binsX); |
double y = l*(yUpUser-yLowUser)/double(binsY); |
h_corrected->Fill(x-c_xOffset, y-c_yOffset, signal); |
} |
} |
} |
} |
h_corrected->SetTitle("SiPM#2 n_p.e.;x[mm];y[mm]"); |
//h_corrected->GetZaxis()->SetRangeUser(-0.05,.30); |
h_corrected->Draw("colz"); |
TCanvas* canvas13 = new TCanvas("canvas13","canvas13",600,300); |
canvas13->Divide(2); |
canvas13->cd(1); |
h[16]->Draw("colz"); |
canvas13->cd(2); |
h[8]->Draw("colz"); |
} |
/** Draws the beam profile and fits it with error function |
* on some background function |
*/ |
if (strstr(plopt, "beam") != NULL) { |
TCanvas* canvas9 = new TCanvas("canvas9","canvas9", 500,500); |
canvas9->cd(); |
char hname[128]; |
sprintf(hname, "hnhitsx%d", 36); |
TH1F* h_laser = (TH1F*)rootfile->Get(hname); |
h_laser->Draw(); |
h_laser->SetStats(1); |
TF1* err = new TF1("err","[0]+[1]*TMath::Erf((x-[2])/[3])",17.2,17.50); |
err->SetParameter(0,2500); |
err->SetParameter(1, h_laser->GetMaximum()); |
err->SetParameter(2, h_laser->GetBinCenter(h_laser->GetMaximumBin())); |
err->SetParameter(3, 0.001); |
h_laser->Fit(err,"qr"); |
h_laser->Fit(err,"lr"); |
double sigma = err->GetParameter(3); |
printf("sigma = %2.0f um, FWHM = %2.0f um\n", sigma*1000, 2.35*sigma*1000); |
} |
if (strstr(plopt, "map") != NULL) { |
for (int i=7; i>=0; i--) { |
//for (int j=7; j>=0; j--) printf("(%d, %d) ", j,i); |
for (int j=7; j>=0; j--) printf("%2d ", map[j][i]); |
printf("\n"); |
} |
} |
return(0); |
} |
/** Function calculates the noise from one channel |
* it runs through the bins along x and returns the average value |
*/ |
double getNoise(TH2F* histogram, int yStart, int yEnd) |
{ |
double noise=0; |
int count=0; |
for(int j=yStart; j<yEnd; j++) { |
double value = histogram->GetBinContent(j,2); |
//if (noise < value) noise = value; |
noise += value; |
count++; |
} |
return (noise/double(count)); |
} |
/sipmScan/examples/plots.cpp |
---|
0,0 → 1,269 |
#include "TROOT.h" |
#include "TFile.h" |
#include "TBenchmark.h" |
#include "TH1F.h" |
#include "TH2F.h" |
#include "TCanvas.h" |
#include "TStyle.h" |
#include "TPad.h" |
#include "TF1.h" |
#include "TGraph.h" |
#include "TSpectrum.h" |
#include "RTUtil.h" |
#define NCH 1 |
#define TDC_BIN (25./1000.) //1 TDC bin in ns |
#define MIKRO_BIN 0.3595/1000. //1 mikro step in mm |
#define HFILL_COLOR 18 |
void plots(char *fname, char *plopt="atc", double fitw=1.0, char *fitf="g") |
{ |
char fullname[256]; |
//get ROOT file with histograms |
char fnameroot[1024]; |
TFile * rootfile; |
TDirectory *dir; |
sprintf(fnameroot, "root/%s.root", fname); |
rootfile = (TFile *) gROOT->FindObject(fname); |
if(rootfile==NULL) rootfile = new TFile(fnameroot); |
if(rootfile==NULL) { |
printf("Cannot open root file %s!!!\n",fnameroot); |
return; |
} |
dir = (TDirectory*) rootfile; |
// set draw style |
gStyle->SetOptStat("ne"); |
gStyle->SetPalette(1, 0); |
gStyle->SetPaperSize(TStyle::kA4); |
gStyle->SetStatBorderSize(1); |
gStyle->SetFrameBorderMode(0); |
gStyle->SetFrameFillColor(0); |
gStyle->SetCanvasBorderMode(0); |
gStyle->SetPadBorderMode(0); |
gStyle->SetPadColor(0); |
gStyle->SetCanvasColor(0); |
gStyle->SetStatColor(0); |
gStyle->SetOptFit(11); |
gStyle->SetPadRightMargin(0.1); |
RTCanvas *c[16]; |
int cc=-1; |
char hname[256]; |
TH1F *hp1d; TH2F *hp2d; |
// ADCs ----------------------------------------------------------------------------------------------- |
if( strchr(plopt, 'a') != NULL ) { |
c[++cc] = new RTCanvas("QDC", fname, 50*(cc+1), 0, 600, 850); |
//c[cc]->Divide(2,4); |
c[cc]->Divide(NCH); |
for(int i=0;i<NCH;i++) { |
c[cc]->cd(i+1); gPad->SetLogy(); |
sprintf(hname, "hadcpos%d",i); hp1d = (TH1F *) dir->Get(hname); |
hp1d->SetTitle("QDC; QDC; N"); |
//(hp1d->GetXaxis())->SetRangeUser(0.,2500.); |
hp1d->DrawCopy(); |
} |
sprintf(fullname, "ps/%s_QDC.eps", fname); |
c[cc]->SaveAs(fullname); |
} |
// Correlation 2d plots ------------------------------------------------------------------------------- |
if( strchr(plopt, 'c') != NULL ) { |
c[++cc] = new RTCanvas("TDCvsQDC", fname, 50*(cc+1), 0, 600, 850); |
//c[cc]->Divide(3,3); |
c[cc]->Divide(NCH); |
for(int i=0;i<NCH;i++) { |
c[cc]->cd(i+1); gPad->SetLogz(); |
sprintf(hname, "hcorpos%d",i); hp2d = (TH2F *) dir->Get(hname); |
hp2d->SetTitle("TDCvsQDC; QDC; TDC [ns]"); |
(hp2d->GetXaxis())->SetRangeUser(0.,500.); |
//hp2d->GetYaxis()->SetRangeUser(-1.5,5.0); |
hp2d->DrawCopy("COLZ"); |
} |
sprintf(fullname, "ps/%s_cor.eps", fname); |
c[cc]->SaveAs(fullname); |
} |
// Fits of corrected TDCs ----------------------------------------------------------------------------- |
TF1 *fg = new TF1("fg", "gaus"); |
TF1 *fgg = new TF1("fgg", "gaus(0)+gaus(3)"); |
fgg->SetParNames("Constant","Mean","Sigma","Constant2","Mean2","Sigma2"); |
if( strchr(plopt, 'f') != NULL ) { |
c[++cc] = new RTCanvas("Corrected TDCs", fname, 50*(cc+1), 0, 600, 850); |
//c[cc]->Divide(2,4); |
c[cc]->Divide(NCH); |
for(int i=0;i<NCH;i++) { |
c[cc]->cd(i+1); gPad->SetLogy(); |
sprintf(hname, "hctdc%d",i); hp1d = (TH1F *) dir->Get(hname); |
hp1d->SetTitle("cTDC; TDC [ns]; N"); |
(hp1d->GetXaxis())->SetRangeUser(-40*TDC_BIN,160*TDC_BIN); |
if( hp1d->GetMaximum() < 50 ) continue; |
//(hp1d->GetXaxis())->SetRangeUser(-0.25,0.75); |
if( strcmp(fitf, "g")==0 ) { |
fg->SetParameters(hp1d->GetMaximum(), hp1d->GetBinCenter(hp1d->GetMaximumBin()), 0.05); |
hp1d->Fit(fg, "0ql", "", fg->GetParameter(1)-0.1*fitw, fg->GetParameter(1)+0.05*fitw); |
hp1d->Fit(fg, "ql", "", fg->GetParameter(1)-0.1*fitw, fg->GetParameter(1)+0.05*fitw); |
printf("Ch[%d] Sigma =%6.1lfps\n",i,fg->GetParameter(2)*1000.); |
} |
else if( strcmp(fitf, "gg")==0 ) { |
//fgg->SetParameters(2600.,0*TDC_BIN,2*TDC_BIN, 100.,0*TDC_BIN,10*TDC_BIN); |
fgg->SetParameters(hp1d->GetMaximum(), hp1d->GetBinCenter(hp1d->GetMaximumBin()), 0.03, |
hp1d->GetMaximum(), hp1d->GetBinCenter(hp1d->GetMaximumBin())/10., 0.1); |
hp1d->Fit(fgg, "0ql", "", -50*TDC_BIN, 50*TDC_BIN); |
hp1d->Fit(fgg, "ql", "", fgg->GetParameter(1)-2.5*fitw*fgg->GetParameter(2), |
fgg->GetParameter(1)+3.5*fitw*fgg->GetParameter(2)); |
printf("Ch[%d] Sigma =%6.1lfps\n",i,fgg->GetParameter(2)*1000.); |
/* |
fg->SetRange(-50., 200.); |
fg->SetParameters(fgg->GetParameter(0), fgg->GetParameter(1), fgg->GetParameter(2)); |
fg->SetLineColor(2); |
fg->DrawCopy("LSAME"); |
fg->SetParameters(fgg->GetParameter(3), fgg->GetParameter(4), fgg->GetParameter(5)); |
fg->SetLineColor(3); |
fg->DrawCopy("LSAME"); |
*/ |
} else {printf("Wrong fit function (parameter 4)!!!\n"); return;} |
} |
sprintf(fullname, "ps/%s_cTDC.eps", fname); |
c[cc]->SaveAs(fullname); |
} |
// TDCs ----------------------------------------------------------------------------------------------- |
if( strchr(plopt, 't') != NULL ) { |
c[++cc] = new RTCanvas("Raw TDC", fname, 50*(cc+1), 0, 600, 850); |
//c[cc]->Divide(2,4); |
c[cc]->Divide(NCH); |
for(int i=0;i<NCH;i++) { |
c[cc]->cd(i+1); gPad->SetLogy(); |
sprintf(hname, "htdcpos%d",i); hp1d = (TH1F *) dir->Get(hname); |
hp1d->SetTitle("TDC; TDC [ns]; N"); |
(hp1d->GetXaxis())->SetRangeUser(-2,5); |
hp1d->DrawCopy(); |
if( hp1d->GetMaximum() < 50 ) continue; |
fg->SetParameters(hp1d->GetMaximum(), hp1d->GetBinCenter(hp1d->GetMaximumBin()), 0.25); |
hp1d->Fit(fg,"0QL", "", fg->GetParameter(1)-0.5, fg->GetParameter(1)+0.25); |
hp1d->Fit(fg,"QL", "", fg->GetParameter(1)-0.5, fg->GetParameter(1)+0.25); |
printf("Ch[%d] RAW Sigma =%6.1lfps\n",i,fg->GetParameter(2)*1000.); |
} |
sprintf(fullname, "ps/%s_TDC.eps", fname); |
c[cc]->SaveAs(fullname); |
} |
// Y scans ----------------------------------------------------------------------------------------------- |
if( strchr(plopt, 'y') != NULL ) { |
c[++cc] = new RTCanvas("Yscans", fname, 50*(cc+1), 0, 600, 850); |
//c[cc]->Divide(2,4); |
c[cc]->Divide(NCH); |
for(int i=0;i<NCH;i++) { |
c[cc]->cd(i+1); //gPad->SetLogy(); |
sprintf(hname, "hnhitsy%d",i); |
hp1d = (TH1F *) dir->Get(hname); |
hp1d->SetTitle("YScan; x; N"); |
//(hp1d->GetXaxis())->SetRangeUser(-80*TDC_BIN,200*TDC_BIN); |
//if(i==0) |
hp1d->DrawCopy(); |
//else hp1d->DrawCopy("SAME"); |
} |
sprintf(fullname, "ps/%s_Ys.eps", fname); |
c[cc]->SaveAs(fullname); |
} |
// X scans ----------------------------------------------------------------------------------------------- |
TF1 *ferf = new TF1("ferf","[0]+[1]*(1+TMath::Erf((x-[2])/[3]))"); |
//int cmap[NCH]={40,1,2,8,4,5,6,41}; |
int cmap[NCH]={1}; |
if( strchr(plopt, 'x') != NULL ) { |
c[++cc] = new RTCanvas("Xscans", fname, 50*(cc+1), 0, 600, 430); |
//c[cc]->Divide(2,4); |
//c[cc]->Divide(NCH); |
/* |
sprintf(hname, "hnhitsx%d",4); hp1d = (TH1F *) dir->Get(hname); |
hp1d->SetTitle("XScan; x; N"); |
ferf->SetParameters(130,1600,43.4,1.0); |
ferf->SetParNames("Offset","Constant","Mean","Sigma"); |
hp1d->Fit(ferf,"QL"); |
*/ |
for(int i=0;i<1;i++) { |
sprintf(hname, "hnhitsx%d",i); hp1d = (TH1F *) dir->Get(hname); |
hp1d->SetTitle("XScan; x; N"); |
hp1d->SetLineColor(cmap[i]); |
(hp1d->GetYaxis())->SetRangeUser(0,hp1d->GetMaximum()*1.2); |
if(i==0) hp1d->DrawCopy(); |
else hp1d->DrawCopy("SAME"); |
// c[cc]->cd(i+1); //gPad->SetLogy(); |
// sprintf(hname, "hnhitsx%d",i); hp1d = (TH1F *) dir->Get(hname); |
// hp1d->SetTitle("XScan; x; N"); |
//(hp1d->GetXaxis())->SetRangeUser(-80*TDC_BIN,200*TDC_BIN); |
// hp1d->DrawCopy(); |
} |
sprintf(fullname, "ps/%s_Xs.eps", fname); |
c[cc]->SaveAs(fullname); |
} |
// tdc vs. MCP OUT tdc ----------------------------------------------------------------------------------- |
if( strchr(plopt, 'm') != NULL ) { |
c[++cc] = new RTCanvas("TDCvsMCPOUT", fname, 50*(cc+1), 0, 400, 850); |
//c[cc]->Divide(2,4); |
c[cc]->Divide(NCH); |
for(int i=0;i<NCH;i++) { |
c[cc]->cd(i+1); gPad->SetLogz(); |
sprintf(hname, "hmcpoutcor%d",i); hp2d = (TH2F *) dir->Get(hname); |
hp2d->SetTitle("TDCvsMCPOUT; MCP OUT TDC [ns]; TDC [ns]"); |
//(hp1d->GetXaxis())->SetRangeUser(-80*TDC_BIN,200*TDC_BIN); |
hp2d->DrawCopy("COLZ"); |
} |
sprintf(fullname, "ps/%s_TDCvsMCPOUT.eps", fname); |
c[cc]->SaveAs(fullname); |
} |
// Charge sharing ----------------------------------------------------------------------------------- |
if( strchr(plopt, 's') != NULL ) { |
c[++cc] = new RTCanvas("ChargeSharing", fname, 50*(cc+1), 0, 600, 850); |
c[cc]->Divide(1,2); |
c[cc]->cd(1); gPad->SetLogz(); |
sprintf(hname, "hshare"); hp2d = (TH2F *) dir->Get(hname); |
hp2d->SetTitle("ChargeSharing; x [mm]; ADC1/(ADC1+ADC2)"); |
hp2d->DrawCopy("COLZ"); |
c[cc]->cd(2); //gPad->SetLogy(); |
TH1F *hprojx = (TH1F*)hp2d->ProjectionX("ProjectionX", 59, 61); |
hprojx->Fit("gaus","QL","", hprojx->GetMean()-hprojx->GetRMS(), hprojx->GetMean()+hprojx->GetRMS()); |
sprintf(fullname, "ps/%s_share.eps", fname); |
c[cc]->SaveAs(fullname); |
} |
//rootfile->Close(); |
} |
/sipmScan/examples/plot_tdc_C.dll |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/sipmScan/examples/plot_tdc_C.exp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/sipmScan/examples/plot_1d_scan.C |
---|
0,0 → 1,15 |
int plot_1d_scan(char * fname="C:/HOME/dino/l2d/root/scan.root"){ |
gStyle->SetPalette(1); |
TFile *file = new TFile(fname); |
TNtuple *ntuple = (TNtuple*) file->Get("nt"); |
TCanvas *canvas = new TCanvas("canvas","canvas1",800,800); |
canvas->Divide(2,2); |
canvas->cd(1)->SetLogz(1); |
// ntuple2->Draw("y>>h1d(100,0,100)","ch==0 && adc>49"); |
ntuple->Draw("x>>h1d(100,0,100)","ch==0 && tdc>150 && tdc<180"); |
//ntuple2->Draw("adc:y>>h0(200,-0.5,199.5,100,0,100)","ch==0","colz"); |
//canvas2->cd(); |
//canvas2->SetLogz(1); |
// ntuple2->Draw("y>>h3(100,0,100)","ch==3 && adc>40"); |
} |
/sipmScan/examples/plot_sipm.C |
---|
0,0 → 1,465 |
#include "TROOT.h" |
#include "TFile.h" |
#include "TBenchmark.h" |
#include "TH1F.h" |
#include "TH2F.h" |
#include "TCanvas.h" |
#include "TStyle.h" |
#include "TPad.h" |
#include "TF1.h" |
#include "TGraph.h" |
#include "TSpectrum.h" |
#include "stdio.h" |
#include "RTUtil.h" |
double getNoise(TH2F*, int, int); |
int plot_sipm(char filename[256] = "test", char plopt[256]="all", int chXstart=0, int chXend=7, int chYstart=0, int chYend=7, bool debug = false) |
{ |
const int c_nChannels = 64; |
const double c_xOffset = 1; // mm |
const double c_yOffset = 0.7; |
int map[8][8]={{32,34,53,55,40,42,61,63}, |
{48,50,37,39,56,58,45,47}, |
{33,35,52,54,41,43,60,62}, |
{49,51,36,38,57,59,44,46}, |
{17,19,4,6,25,27,12,14}, |
{1,3,20,22,9,11,28,30}, |
{16,18,5,7,24,26,13,15}, |
{0,2,21,23,8,10,29,31} |
}; |
char fnameroot[256]; |
TFile* rootfile; |
sprintf(fnameroot, "root/%s.root", filename); |
rootfile = (TFile *) gROOT->FindObject(filename); |
if(rootfile==NULL) rootfile = new TFile(fnameroot); |
if(rootfile==NULL) { |
printf("Cannot open root file %s!!!\n",fnameroot); |
return(0); |
} |
// set draw style |
gStyle->SetOptStat("ne"); |
gStyle->SetPalette(1, 0); |
gStyle->SetPaperSize(TStyle::kA4); |
gStyle->SetStatBorderSize(1); |
gStyle->SetFrameBorderMode(0); |
gStyle->SetFrameFillColor(0); |
gStyle->SetCanvasBorderMode(0); |
gStyle->SetPadBorderMode(0); |
gStyle->SetPadColor(0); |
gStyle->SetCanvasColor(0); |
gStyle->SetStatColor(0); |
gStyle->SetOptFit(11); |
gStyle->SetOptStat(); |
gStyle->SetPadRightMargin(0.15); |
gStyle->SetPadLeftMargin(0.12); |
//gStyle->SetTitleYOffset(1.4); |
if( strstr(plopt, "all") != NULL ) { |
TCanvas *canvas2 = new TCanvas("canvas2","Hits x;;",2000,2000); |
TCanvas *canvas3 = new TCanvas("canvas3","Hits y;;",2000,2000); |
canvas2->Divide(8,8); |
canvas3->Divide(8,8); |
TH1F* h_hitsx; |
TH1F* h_hitsy; |
for(int i=0; i<c_nChannels; i++) { |
canvas2->cd(i+1); |
char hname[128]; |
sprintf(hname, "hnhitsx%d", i); |
h_hitsx = (TH1F*)rootfile->Get(hname); |
h_hitsx->Draw(); |
canvas3->cd(i+1); |
sprintf(hname, "hnhitsy%d", i); |
h_hitsy = (TH1F*)rootfile->Get(hname); |
h_hitsy->Draw(); |
} |
} |
if( strstr(plopt, "x") != NULL ) { |
TCanvas *canvas10 = new TCanvas("canvas10","Ch x;;",500,500); |
TH1F* h_hitsx; |
canvas10->cd(); |
char hname[128]; |
sprintf(hname, "hnhitsx%d", chXstart); |
h_hitsx = (TH1F*)rootfile->Get(hname); |
h_hitsx->Draw(); |
} |
if( strstr(plopt, "y") != NULL ) { |
TCanvas *canvas11 = new TCanvas("canvas11","Ch x;;",500,500); |
TH1F* h_hitsy; |
canvas11->cd(); |
char hname[128]; |
sprintf(hname, "hnhitsy%d", chXstart); |
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 |
*/ |
if (strstr(plopt, "2d") != NULL) { |
int nX = chXend - chXstart + 1; |
int nY = chYend - chYstart + 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 j=chXstart; j<=chXend; j++) { |
//int canvasPosition = nX*(i-chYstart)+(j-chXstart)+1; |
int canvasPosition = nX*(chYend-i)+(j-chXstart)+1; |
if (debug) printf("canvas %d\n",canvasPosition); |
canvas7->cd(canvasPosition); |
char hname[128]; |
int chPosition = map[j][i]; |
sprintf(hname, "h2d%d", chPosition); |
TH2F* h_2d = (TH2F*)rootfile->Get(hname); |
h_2d->Draw("colz"); |
} //x |
} |
// Number of photoelectrons - Poissonian correction |
TCanvas* canvas8 = new TCanvas("canvas8","canvas8", 1000,1000); |
canvas8->cd(); |
gStyle->SetOptStat(0); |
char hname[128]; |
int chPosition = map[1][2]; |
sprintf(hname, "h2d%d", chPosition); |
TH2F* h_2d = (TH2F*)rootfile->Get(hname); |
Int_t binsX = h_2d->GetXaxis()->GetNbins(); |
Int_t minX = h_2d->GetXaxis()->GetFirst(); |
Int_t maxX = h_2d->GetXaxis()->GetLast()+1; |
Int_t binsY = h_2d->GetYaxis()->GetNbins(); |
Int_t minY = h_2d->GetYaxis()->GetFirst(); |
Int_t maxY = h_2d->GetYaxis()->GetLast()+1; |
Double_t xLowUser = h_2d->GetXaxis()->GetBinLowEdge(minX); |
Double_t xUpUser = h_2d->GetXaxis()->GetBinUpEdge(maxX); |
Double_t yLowUser = h_2d->GetYaxis()->GetBinLowEdge(minY); |
Double_t yUpUser = h_2d->GetYaxis()->GetBinUpEdge(maxY); |
if (debug) printf("xLow %f xUp %f\n",xLowUser,xUpUser); |
TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX, xLowUser, xUpUser, binsY, yLowUser, yUpUser); |
double noise = getNoise(h_2d, 1, 89); |
if(debug) printf("Noise = %f\n", noise); |
for(int k=minX; k<=maxX; k++) { |
for(int j=minY; j<=maxY; j++) { |
double signal = h_2d->GetBinContent(k,j); // detected |
//double p = ((signal - noise) > 1) ? (signal-noise) : 1; |
double p = signal - noise; |
p /= 10000.; |
double p0 = 1.0 - p; // events with zero photons |
//double eta = (-log(p0) * p0 ) / (1-p0-0.00001); |
double eta = -log(p0); // constant of the poissonian statistics |
if (debug) printf("p=%f p0=%f log(p0)=%f eta=%f\n",p,p0,log(p0),eta); |
double x = k*(xUpUser-xLowUser)/double(binsX); |
double y = j*(yUpUser-yLowUser)/double(binsY); |
h_corrected->Fill(x+3,y+8, eta); |
} |
} |
h_corrected->SetTitle("n_pe = - ln P(0);x[mm];y[mm]"); |
h_corrected->GetZaxis()->SetRangeUser(-0.05,0.3); |
h_corrected->Draw("colz"); |
// collection efficiency |
int nPoints =0; |
double efficiency=0; |
for (int i=18; i<=58; i++) { |
for (int j=19; j<=59; j++) { |
double signal = h_corrected->GetBinContent(i,j); |
if(debug) printf("signal %f\n",signal); |
efficiency += signal; |
nPoints++; |
} |
} |
printf("Signal sum = %f\n # of points = %d\n",efficiency,nPoints); |
} |
/** Draws the sum of channel signals |
* Each channel is a 2d ('h2d') histogram |
* Suitable for 8x8 chs scan |
*/ |
if( strstr(plopt, "sum") != NULL ) { |
int nX = chXend - chXstart + 1; |
int nY = chYend - chYstart + 1; |
TCanvas* canvas12 = new TCanvas("canvas12","c2",8*200, 8*200); |
canvas12->cd(); |
gStyle->SetOptStat(0); |
// final histogram parameters |
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); |
TH2F* h_corrected = new TH2F("h_corrected","h_corrected",binsX,xLowUser,xUpUser, binsY,yLowUser,yUpUser); |
TH2F* h[9]; |
// 2d histogram noise subtraction and poisson scaling |
for(int i=chYstart; i<=chYend; 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); |
h[histogram] = (TH2F *) rootfile->Get(hname); |
int noise = getNoise(h[histogram], 1, 170); |
if (debug) printf("noise: %d\n",noise); |
for(int k=minX; k<=maxX; k++) { |
for(int l=minY; l<=maxY; l++) { |
int signal = h[histogram]->GetBinContent(k,l); // detected |
//double p = ((signal - noise) > 0.1) ? (signal-noise) : 0.1; |
double p = signal - noise; |
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 x = k*(xUpUser-xLowUser)/double(binsX); |
double y = l*(yUpUser-yLowUser)/double(binsY); |
h_corrected->Fill(x-c_xOffset, y-c_yOffset, signal); |
} |
} |
} |
} |
h_corrected->SetTitle("SiPM#2 n_p.e.;x[mm];y[mm]"); |
//h_corrected->GetZaxis()->SetRangeUser(-0.05,.30); |
h_corrected->Draw("colz"); |
TCanvas* canvas13 = new TCanvas("canvas13","canvas13",600,300); |
canvas13->Divide(2); |
canvas13->cd(1); |
h[16]->Draw("colz"); |
canvas13->cd(2); |
h[8]->Draw("colz"); |
} |
/** Draws the beam profile and fits it with error function |
* on some background function |
*/ |
if (strstr(plopt, "beam") != NULL) { |
TCanvas* canvas9 = new TCanvas("canvas9","canvas9", 500,500); |
canvas9->cd(); |
char hname[128]; |
sprintf(hname, "hnhitsx%d", 36); |
TH1F* h_laser = (TH1F*)rootfile->Get(hname); |
h_laser->Draw(); |
h_laser->SetStats(1); |
TF1* err = new TF1("err","[0]+[1]*TMath::Erf((x-[2])/[3])",17.2,17.50); |
err->SetParameter(0,2500); |
err->SetParameter(1, h_laser->GetMaximum()); |
err->SetParameter(2, h_laser->GetBinCenter(h_laser->GetMaximumBin())); |
err->SetParameter(3, 0.001); |
h_laser->Fit(err,"qr"); |
h_laser->Fit(err,"lr"); |
double sigma = err->GetParameter(3); |
printf("sigma = %2.0f um, FWHM = %2.0f um\n", sigma*1000, 2.35*sigma*1000); |
} |
if (strstr(plopt, "map") != NULL) { |
for (int i=7; i>=0; i--) { |
//for (int j=7; j>=0; j--) printf("(%d, %d) ", j,i); |
for (int j=7; j>=0; j--) printf("%2d ", map[j][i]); |
printf("\n"); |
} |
} |
return(0); |
} |
/** Function calculates the noise from one channel |
* it runs through the bins along x and returns the average value |
*/ |
double getNoise(TH2F* histogram, int yStart, int yEnd) |
{ |
double noise=0; |
int count=0; |
for(int j=yStart; j<yEnd; j++) { |
double value = histogram->GetBinContent(j,2); |
//if (noise < value) noise = value; |
noise += value; |
count++; |
} |
return (noise/double(count)); |
} |
/sipmScan/examples/plot_tdc_C.def |
---|
0,0 → 1,58 |
LIBRARY plot_tdc_C |
EXPORTS |
?G__plot_tdc_C_ACLiC_dictLN_TVectorTlEfloatgR@@3UG__linked_taginfo@@A DATA |
?G__plot_tdc_C_ACLiC_dictLN_TMatrixTBaselEfloatgR@@3UG__linked_taginfo@@A DATA |
?G__plot_tdc_C_ACLiC_dictLN_TVectorTlEdoublegR@@3UG__linked_taginfo@@A DATA |
?G__plot_tdc_C_ACLiC_dictLN_TMatrixTBaselEdoublegR@@3UG__linked_taginfo@@A DATA |
?G__plot_tdc_C_ACLiC_dictLN_iteratorlErandom_access_iterator_tagcOcharcOlongcOcharmUcOcharaNgR@@3UG__linked_taginfo@@A DATA |
?G__plot_tdc_C_ACLiC_dictLN_vectorlEROOTcLcLTSchemaHelpercOallocatorlEROOTcLcLTSchemaHelpergRsPgR@@3UG__linked_taginfo@@A DATA |
?G__plot_tdc_C_ACLiC_dictLN__RanitlEROOTcLcLTSchemaHelpercOlongcOROOTcLcLTSchemaHelpermUcOROOTcLcLTSchemaHelperaNgR@@3UG__linked_taginfo@@A DATA |
?G__plot_tdc_C_ACLiC_dictLN_iteratorlErandom_access_iterator_tagcOROOTcLcLTSchemaHelpercOlongcOROOTcLcLTSchemaHelpermUcOROOTcLcLTSchemaHelperaNgR@@3UG__linked_taginfo@@A DATA |
?G__plot_tdc_C_ACLiC_dictLN_reverse_iteratorlEvectorlEROOTcLcLTSchemaHelpercOallocatorlEROOTcLcLTSchemaHelpergRsPgRcLcLiteratorgR@@3UG__linked_taginfo@@A DATA |
?G__plot_tdc_C_ACLiC_dictLN_reverse_iteratorlEvectorlEROOTcLcLTSchemaHelpercOallocatorlEROOTcLcLTSchemaHelpergRsPgRcLcLconst_iteratorgR@@3UG__linked_taginfo@@A DATA |
?G__plot_tdc_C_ACLiC_dictLN_iteratorlEbidirectional_iterator_tagcOTObjectmUcOlongcOconstsPTObjectmUmUcOconstsPTObjectmUaNgR@@3UG__linked_taginfo@@A DATA |
?strchr@@YAPADPADH@Z |
?strstr@@YAPADPADPBD@Z |
??2TObject@@SAPAXI@Z |
??1TDatime@@UAE@XZ |
??_R0?AVTDatime@@@8 DATA |
?IsA@TDatime@@UBEPAVTClass@@XZ |
?SetCanvasColor@TStyle@@QAEXF@Z |
?SetCanvasBorderMode@TStyle@@QAEXH@Z |
?SetPadColor@TStyle@@QAEXF@Z |
?SetPadBorderMode@TStyle@@QAEXH@Z |
?SetPadBottomMargin@TStyle@@QAEXM@Z |
?SetPadTopMargin@TStyle@@QAEXM@Z |
?SetPadLeftMargin@TStyle@@QAEXM@Z |
?SetPadRightMargin@TStyle@@QAEXM@Z |
?SetFrameFillColor@TStyle@@QAEXF@Z |
?SetFrameBorderMode@TStyle@@QAEXH@Z |
?SetHistFillColor@TStyle@@QAEXF@Z |
?SetStatColor@TStyle@@QAEXH@Z |
?SetStatBorderSize@TStyle@@QAEXF@Z |
?RTSetStyle@@YAXPAVTStyle@@@Z |
??0RTCanvas@@QAE@PAD0HHHH@Z |
?Divide@RTCanvas@@QAEXHH@Z |
?Divide@RTCanvas@@QAEXH@Z |
?cd@RTCanvas@@QAEPAVTPad@@H@Z |
?SaveAs@RTCanvas@@QAEXPBD@Z |
?Update@RTCanvas@@QAEXXZ |
?plot_tdc@@YAHPAD0HHHH@Z |
G__cpp_dllrevplot_tdc_C_ACLiC_dict |
?sizep2memfunc@G__Sizep2memfuncplot_tdc_C_ACLiC_dict@@QAEIXZ |
G__cpp_setup_inheritanceplot_tdc_C_ACLiC_dict |
G__cpp_setup_typetableplot_tdc_C_ACLiC_dict |
G__cpp_setup_memvarplot_tdc_C_ACLiC_dict |
G__cpp_setup_memfuncplot_tdc_C_ACLiC_dict |
G__cpp_setup_globalplot_tdc_C_ACLiC_dict |
G__cpp_setup_funcplot_tdc_C_ACLiC_dict |
G__cpp_reset_tagtableplot_tdc_C_ACLiC_dict |
G__cpp_setup_tagtableplot_tdc_C_ACLiC_dict |
??1G__cpp_setup_initplot_tdc_C_ACLiC_dict@@QAE@XZ |
??0RTCanvas@@QAE@XZ |
G__set_cpp_environmentplot_tdc_C_ACLiC_dict |
??0G__Sizep2memfuncplot_tdc_C_ACLiC_dict@@QAE@XZ |
?G__get_sizep2memfuncplot_tdc_C_ACLiC_dict@@YAIXZ |
G__cpp_setupplot_tdc_C_ACLiC_dict |
??0G__cpp_setup_initplot_tdc_C_ACLiC_dict@@QAE@XZ |
?G__cpp_setup_initializerplot_tdc_C_ACLiC_dict@@3VG__cpp_setup_initplot_tdc_C_ACLiC_dict@@A DATA |
/sipmScan/examples/plot_tdc.C |
---|
0,0 → 1,238 |
#include "TROOT.h" |
#include "TFile.h" |
#include "TBenchmark.h" |
#include "TH1F.h" |
#include "TH2F.h" |
#include "TCanvas.h" |
#include "TStyle.h" |
#include "TPad.h" |
#include "TF1.h" |
#include "TGraph.h" |
#include "TSpectrum.h" |
#include "stdio.h" |
//#include "../RTUtil.h" |
int plot_tdc(char* filename = "test", char *plopt="t", int chXstart=0, int chXend=7, int chYstart=0, int chYend=7) |
{ |
const int c_nChannels = 64; |
char fullname[256]; |
int map[8][8]={{32,34,53,55,40,42,61,63}, |
{48,50,37,39,56,58,45,47}, |
{33,35,52,54,41,43,60,62}, |
{49,51,36,38,57,59,44,46}, |
{17,19,4,6,25,27,12,14}, |
{1,3,20,22,9,11,28,30}, |
{16,18,5,7,24,26,13,15}, |
{0,2,21,23,8,10,29,31} |
}; |
char fnameroot[256]; |
TFile* rootfile; |
sprintf(fnameroot, "root/%s.root", filename); |
rootfile = (TFile *) gROOT->FindObject(filename); |
if(rootfile==NULL) rootfile = new TFile(fnameroot); |
if(rootfile==NULL) { |
printf("Cannot open root file %s!!!\n",fnameroot); |
return(0); |
} |
// set draw style |
gStyle->SetOptStat("ne"); |
gStyle->SetPalette(1, 0); |
gStyle->SetPaperSize(TStyle::kA4); |
gStyle->SetStatBorderSize(1); |
gStyle->SetFrameBorderMode(0); |
gStyle->SetFrameFillColor(0); |
gStyle->SetCanvasBorderMode(0); |
gStyle->SetPadBorderMode(0); |
gStyle->SetPadColor(0); |
gStyle->SetCanvasColor(0); |
gStyle->SetStatColor(0); |
gStyle->SetOptFit(11); |
gStyle->SetOptStat(); |
gStyle->SetPadRightMargin(0.15); |
gStyle->SetPadLeftMargin(0.12); |
//gStyle->SetTitleYOffset(1.4); |
if( strchr(plopt, 't') != NULL ) { |
TCanvas* canvas1 = new TCanvas("canvas1","canvas1",1000,1000); |
TH2F* htdc = (TH2F*) rootfile->Get("htdc"); |
canvas1->cd(); |
htdc->Draw("colz"); |
TH2F* h_correctedTDC = (TH2F*) rootfile->Get("h_correctedTDC"); |
TCanvas* canvas6 = new TCanvas("canvas6","canvas6",500,500); |
canvas6->cd(); |
h_correctedTDC->Draw("colz"); |
TH1D* channelY = htdc->ProjectionX("",54,54); |
channelY->SetStats(0); |
channelY->SetTitle(";TDC [ns];Events"); |
channelY->GetYaxis()->SetTitleOffset(1.7); |
//channelY->GetXaxis()->SetRangeUser(-40,40); |
//channelY->Draw(); |
TF1* f_gaus = new TF1("f_gaus","gaus(0)+gaus(3)",-10,20); |
f_gaus->SetParNames("Constant1","Mean1","Sigma1","Constant2","Mean2","Sigma2"); |
f_gaus->SetParameters(channelY->GetMaximum(), channelY->GetBinCenter(channelY->GetMaximumBin()), 0.5, |
channelY->GetMaximum(), channelY->GetBinCenter(channelY->GetMaximumBin())/10.0, 0.05); |
/*channelY->Fit(f_gaus,"0ql","",f_gaus->GetParameter(1)-0.1,f_gaus->GetParameter(1)+0.05); |
channelY->Fit(f_gaus,"ql","",f_gaus->GetParameter(1)-0.1,f_gaus->GetParameter(1)+0.05); |
channelY->Fit(f_gaus,"0qlr","",-20,20); |
channelY->Fit(f_gaus,"qlr","",f_gaus->GetParameter(1)-2*f_gaus->GetParameter(2), |
f_gaus->GetParameter(1)+2*f_gaus->GetParameter(2));*/ |
} |
if( strchr(plopt, 'all') != NULL ) { |
TCanvas *canvas2 = new TCanvas("canvas2","Hits x;;",2000,2000); |
TCanvas *canvas3 = new TCanvas("canvas3","Hits y;;",2000,2000); |
canvas2->Divide(8,8); |
canvas3->Divide(8,8); |
TH1F* h_hitsx; |
TH1F* h_hitsy; |
for(int i=0; i<64; i++) { |
canvas2->cd(i+1); |
char hname[128]; |
sprintf(hname, "hnhitsx%d", i); |
h_hitsx = (TH1F*)rootfile->Get(hname); |
h_hitsx->Draw(); |
canvas3->cd(i+1); |
sprintf(hname, "hnhitsy%d", i); |
h_hitsy = (TH1F*)rootfile->Get(hname); |
h_hitsy->Draw(); |
} |
} |
if( strchr(plopt, 'x') != NULL ) { |
TCanvas *canvas10 = new TCanvas("canvas10","Ch x;;",500,500); |
TH1F* h_hitsx; |
canvas10->cd(); |
char hname[128]; |
sprintf(hname, "hnhitsx%d", chXstart); |
h_hitsx = (TH1F*)rootfile->Get(hname); |
h_hitsx->Draw(); |
} |
if( strchr(plopt, 'y') != NULL ) { |
TCanvas *canvas11 = new TCanvas("canvas11","Ch x;;",500,500); |
TH1F* h_hitsy; |
canvas11->cd(); |
char hname[128]; |
sprintf(hname, "hnhitsy%d", chXstart); |
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 *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); |
} |
if (strstr(plopt, "2d") != NULL) { |
int nX = chXend - chXstart + 1; |
int nY = chYend - chYstart + 1; |
TCanvas* canvas7 = new TCanvas("canvas7","canvas7", nX*250,nY*250); |
printf("nx %d ny %d\n",nX,nY); |
canvas7->Divide(nX,nY); |
for(int i=chYstart; i<=chYend; i++) { |
for(int j=chXstart; j<=chXend; j++) { |
int canvasPosition = nX*(i-chYstart)+(j-chXstart)+1; |
printf("canvas %d\n",canvasPosition); |
canvas7->cd(canvasPosition); |
char hname[128]; |
int chPosition = map[j][i]; |
sprintf(hname, "h2d%d", chPosition); |
TH2F* h_2d = (TH2F*)rootfile->Get(hname); |
h_2d->Draw("colz"); |
} //x |
} |
/* |
TCanvas* canvas8 = new TCanvas("canvas8","canvas8", 1000,1000); |
char hname[128]; |
int chPosition = map[0][7]; |
sprintf(hname, "h2d%d", chPosition); |
TH2F* h_2d1 = (TH2F*)rootfile->Get(hname); |
chPosition = map[0][8]; |
sprintf(hname, "h2d%d", chPosition); |
TH2F* h_2d2 = (TH2F*)rootfile->Get(hname); |
h_2d1->SetOption("colz"); |
h_2d1->Draw(); |
h_2d2->SetOption("colz"); |
h_2d2->Draw("same");*/ |
} |
if( strstr(plopt, "sum") != NULL ) { |
int nX = chXend - chXstart + 1; |
int nY = chYend - chYstart + 1; |
TCanvas* canvas12 = new TCanvas("canvas12","c2",1000,1000); |
gStyle->SetOptStat(11); |
//c2->Divide(1,4); |
//TVirtualPad *pad=c2->cd(); |
//pad->SetLogz(); |
TH2F* h[64]; |
for(int i=chYstart; i<=chYend; 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); |
h[histogram] = (TH2F *) rootfile->Get(hname); |
if (histogram) h[0]->Add(h[histogram]); |
} |
} |
h[0]->Draw("COLZ"); |
} |
if (strstr(plopt, "beam") != NULL) { |
TCanvas* canvas9 = new TCanvas("canvas9","canvas9", 500,500); |
char hname[128]; |
sprintf(hname, "hnhitsx%d", 36); |
TH1F* h_laser = (TH1F*)rootfile->Get(hname); |
h_laser->Draw(); |
h_laser->SetStats(1); |
TF1* err = new TF1("err","[0]+[1]*TMath::Erf((x-[2])/[3])"); |
err->SetParameters(0,h_laser->GetMaximum(),17.04,0.0001); |
h_laser->Fit(err,"l"); |
} |
return(0); |
} |
/sipmScan/examples/plot_tdc_C.rootmap |
---|
0,0 → 1,0 |
Library.plot_tdc_C: plot_tdc_C libCore.dll libMathCore.dll libRIO.dll libGpad.dll libGraf.dll libHist.dll libHist.dll libMatrix.dll libMathCore.dll libGraf.dll libHist.dll libMatrix.dll libMathCore.dll libRIO.dll libSpectrum.dll libHist.dll libMatrix.dll |
/sipmScan/examples/scan2d.cpp |
---|
0,0 → 1,87 |
#include "stdio.h" |
#include "TROOT.h" |
#include "TFile.h" |
#include "TNtuple.h" |
#include "TH1F.h" |
#include "TH2F.h" |
#include "TF1.h" |
#include "TMath.h" |
#include "TStyle.h" |
#include "TCanvas.h" |
#include "TLine.h" |
#include "zlib/zlib.h" |
int scan2d(char * fname="test", char *plopt="2d", double value=0){ |
char fullname[256]; |
//get ROOT file with histograms |
char fnameroot[1024]; |
TFile * rootfile; |
TDirectory *dir; |
sprintf(fnameroot, "root/%s.root", fname); |
rootfile = (TFile *) gROOT->FindObject(fname); |
if(rootfile==NULL) rootfile = new TFile(fnameroot); |
if(rootfile==NULL) { |
printf("Cannot open root file %s!!!\n",fnameroot); |
return 0; |
} |
dir = (TDirectory*) rootfile; |
// set draw style |
gStyle->SetOptStat("ne"); |
gStyle->SetPalette(1, 0); |
gStyle->SetPaperSize(TStyle::kA4); |
gStyle->SetStatBorderSize(1); |
gStyle->SetFrameBorderMode(0); |
gStyle->SetFrameFillColor(0); |
gStyle->SetCanvasBorderMode(0); |
gStyle->SetPadBorderMode(0); |
gStyle->SetPadColor(0); |
gStyle->SetCanvasColor(0); |
gStyle->SetStatColor(0); |
gStyle->SetOptFit(11); |
gStyle->SetOptStat(); |
gStyle->SetPadRightMargin(0.15); |
gStyle->SetPadLeftMargin(0.12); |
//gStyle->SetTitleYOffset(1.4); |
TCanvas *c; |
int cc=-1; |
char hname[256]; |
TH1F *hp1d; TH2F *hp2d; |
c = new TCanvas("2D Scan", fname, 650, 0, 600, 1200); |
c ->Divide(2,4); |
for (int i=0;i<8;i++){ |
TVirtualPad *pad=c->cd(i%4*2+i/4+1); |
if( strstr(plopt, "2d") != NULL ) { |
pad->SetLogz(); |
pad->SetLogy(0); |
sprintf(hname, "h2d%d",i); hp2d = (TH2F *) dir->Get(hname); |
(hp2d->GetYaxis())->SetLabelOffset(0.01); |
hp2d->SetTitle("; X [mm]; Y[mm]"); |
hp2d->DrawCopy("COLZ"); |
sprintf(fullname, "ps/%s_2d.pdf", fname); |
} |
if( strstr(plopt, "adc") != NULL ) { |
pad->SetLogy(1); |
pad->SetLogz(0); |
sprintf(hname, "hadc%d",i); hp1d = (TH1F *) dir->Get(hname); |
if (value>0) (hp1d->GetXaxis())->SetRangeUser(0,value); |
(hp1d->GetYaxis())->SetLabelOffset(0.01); |
hp1d->SetTitle("; ADC (a.u.); N"); |
hp1d->DrawCopy(); |
sprintf(fullname, "ps/%s_adc.pdf", fname); |
} |
} |
c->SaveAs(fullname); |
return 0; |
} |
/sipmScan/examples/plot_tdc_C.d |
---|
0,0 → 1,76 |
# |
# DO NOT DELETE |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TROOT.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TDirectory.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TNamed.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TObject.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/Rtypes.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/RConfig.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/RVersion.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/DllImport.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/Rtypeinfo.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TGenericClassInfo.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TSchemaHelper.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TStorage.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TVersionCheck.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/Riosfwd.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TBuffer.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TString.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TRefCnt.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TMathBase.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TList.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TSeqCollection.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TCollection.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TIterator.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TDatime.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TUUID.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TFile.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TDirectoryFile.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TUrl.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TBenchmark.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TStopwatch.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TH1F.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TH1.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TAxis.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TAttAxis.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TArrayD.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TArray.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TAttLine.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TAttFill.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TAttMarker.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TArrayC.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TArrayS.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TArrayI.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TArrayF.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/Foption.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TVectorFfwd.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TVectorDfwd.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TH2F.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TH2.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TMatrixFBasefwd.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TMatrixDBasefwd.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TCanvas.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TPad.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TVirtualPad.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TAttPad.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TVirtualX.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TAttText.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/GuiTypes.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/Buttons.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TQObject.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TAttCanvas.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TCanvasImp.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TStyle.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TF1.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TFormula.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TBits.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TObjArray.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TFormulaPrimitive.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/Math/ParamFunctor.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TGraph.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TSpectrum.h RTUtil.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TPaveLabel.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TPave.h |
C:\HOME\dino\l2d\plot_tdc.o: /cygdrive/C\root/include/TBox.h RTUtil.cpp |
C:\HOME\dino\l2d\plot_tdc.C: C:\root\include\cintdictversion.h |
/sipmScan/examples/plot_tdc_64ch.C |
---|
0,0 → 1,30 |
#include "TROOT.h" |
#include "TFile.h" |
#include "TBenchmark.h" |
#include "TH1F.h" |
#include "TH2F.h" |
#include "TCanvas.h" |
#include "TStyle.h" |
#include "TPad.h" |
#include "TF1.h" |
#include "TGraph.h" |
#include "TSpectrum.h" |
#include "RTUtil.h" |
int plot_tdc() |
{ |
TFile *file0 = new TFile("C:/HOME/dino/l2d/root/test.root"); |
//TNtuple *ntuple = (TNtuple*) file0->Get("nt"); |
TCanvas *canvas1 = new TCanvas("canvas1","canvas1",1000,1000); |
TH2F* htdc = (TH2F*) file0->Get("htdc"); |
canvas1->Divide(2,2); |
canvas1->cd(1); |
htdc->Draw(); |
TH1F* h1ch = new TH1F("h1ch","h1ch",256,0,256); |
htdc->ProjectionX("h1ch",33,34,""); |
canvas1->cd(2); |
h1ch->Draw(); |
} |