#include <stdio.h>
#include <stdlib.h>
#include <TROOT.h>
#include <TH1D.h>
#include <TH2D.h>
#include <TH3D.h>
#include <TCanvas.h>
#include <TStyle.h>
#include <TSystem.h>
#include <TFile.h>
#include <TDirectory.h>
#include <TPaveText.h>
#include "base.h"
#include "focus.h"
int focus(int runNumber, int save) {
int HAPDnumber; //Number of HAPD: 0, 1, 2 or 3!
int direction, nx, ny;
char name[128];
char pdfname[128];
char buf[256];
float pNoise;
int color[6] = {1,2,4,6,8,9};
char hname[0xF];
int max = 20;
TFile * data[max];
for (int b=0;b<max;b++){
sprintf(buf
,"./meritve/%04d_4_2DX_zOS_%05d.root",runNumber
+b
,(runNumber
-10+b
)*1000);
data[b] = new TFile(buf);
}
const char * serialNumber = getSN();
char * serialNumberTemp = strdup(serialNumber);
char * HAPDserialNumber;
GRID m = mapping();
int vrstaPisave = 82;
TCanvas * c;
TPad * pad1, * pad2, * pad3;
TPad * VirtualPad2[12];
TPaveText * info, * axisName;
TAxis * axis;
TH3D * h;
TH2D * slice[12]; //take the right slice from 3D histogram
TH1D * p[12];
/********** GLOBALNE **********/
gStyle->SetOptStat(0);
//gStyle->SetOptTitle(1);
gStyle->SetTitleFontSize(.15);
for(int HAPDnumber=0;HAPDnumber<4;HAPDnumber++){
HAPDserialNumber = strsep(&serialNumberTemp,",");
if(!strcmp(HAPDserialNumber
,"noserial")) continue;
sprintf(hname
,"hxy%d_0;1",HAPDnumber
);
printf("%s \t %s \n",HAPDserialNumber
,hname
);
h = (TH3D *) data[0]->Get(hname);
/********** SMER MERITVE **********/
h->GetZaxis()->SetRange(1,1);
nx = h->GetNbinsX();
ny = h->GetNbinsY();
if (nx>=ny) direction = 0;
else direction = 1;
printf("Direction = %d\n", direction
);
/********** CANVAS **********/
if (!direction) {
sprintf(buf
,"%04d_%s_px",runNumber
,HAPDserialNumber
);
c = new TCanvas(buf,buf,0,0,2000,2000);
} else {
sprintf(buf
,"%04d_%s_py",runNumber
,HAPDserialNumber
);
c = new TCanvas(buf,buf,0,0,2000,2000);
}
c->Divide(4,5,0,0);
for(int a=0;a<max;a++){
c->cd(a+1);
c->cd(a+1)->SetBorderSize(0);
c->cd(a+1)->SetBorderMode(0);
pad1 = new TPad("pad1","Title",0.05,0.94,0.95,1,0,0);
pad1->SetFillStyle(4000);
pad1->Draw();
pad2 = new TPad("pad2","Graphs",0,0,1,0.95,0,0);
pad2->SetFillStyle(4000);
pad2->Draw();
pad3 = new TPad("pad3","AxisTitle",0.57,0,0.92,0.05,0,0);
pad3->SetFillStyle(4000);
pad3->Draw();
/********** PAD 1 **********/
pad1->cd();
info = new TPaveText(0.2,0,0.8,1,"ndc");
info->SetBorderSize(0);
info->SetFillColor(4000);
info->SetTextSize(1);
info->SetTextAlign(22);
sprintf(name
,"Z = %d stage steps", (runNumber
-10+a
)*1000);
info->AddText(name);
info->Draw();
/********** PAD3 **********/
pad3->cd();
axisName = new TPaveText(0.2,0,0.8,1,"ndc");
axisName->SetBorderSize(0);
axisName->SetFillColor(4000);
axisName->SetTextSize(.7);
axisName->SetTextFont(vrstaPisave);
axisName->SetTextAlign(22);
sprintf(name
,"Incident light position (stage step)");
axisName->AddText(name);
//axisName->Draw();
/********** PAD2 **********/
pad2->cd();
pad2->Divide(1,4,0,0);
if(a) h = (TH3D *) data[a]->Get(hname);
for (int i=4;i<8;i++) {
if (!direction) {
pad2->cd(11 - i+1-4);
VirtualPad2[11 - i-4] = (TPad *)(pad2->cd(11 - i+1-4)); //Tole nastaviš zato, da lahko daš Log skalo
VirtualPad2[11 - i-4]->SetLogy(1);
//VirtualPad2[11 - i]->SetLeftMargin(.05);
//VirtualPad2[11 - i]->SetRightMargin(.05);
//VirtualPad2[11 - i]->SetGrid();
} else {
pad2->cd(i+1-4);
VirtualPad2[i-4] = (TPad *)(pad2->cd(11 - i+1 - 4)); //Tole nastaviš zato, da lahko daš Log skalo
VirtualPad2[i-4]->SetLogy(1);
//VirtualPad2[i]->SetLeftMargin(.05);
//VirtualPad2[i]->SetRightMargin(.05);
//VirtualPad2[i]->SetGrid();
}
for (int j=4;j<8;j++) {
if (!direction) h->GetZaxis()->SetRange(m.koordinatniSistem[j][i]+1,m.koordinatniSistem[j][i]+1);
else h->GetZaxis()->SetRange(m.koordinatniSistem[i][j]+1,m.koordinatniSistem[i][j]+1);
slice[j] = (TH2D *)h->Project3D("pyx");
if (!direction) {
p[j] = slice[j]->ProjectionX(name,i+1-4,i+1-4);
sprintf(name
,"Projection X of row %d",i
);
} else {
p[j] = slice[j]->ProjectionY(name,i+1-4,i+1-4);
sprintf(name
,"Projection Y of column %d",i
);
}
axis = p[j]->GetXaxis();
if(!direction) VirtualPad2[3]->SetBottomMargin(.17);
else VirtualPad2[0]->SetBottomMargin(.17);
p[j]->SetLineWidth(1);
p[j]->SetTitle(name);
p[j]->SetTitleOffset(1.5);
p[j]->GetYaxis()->SetRangeUser(1,10000);
p[j]->GetYaxis()->SetTickLength(0.01);
p[j]->GetYaxis()->SetTitleFont(vrstaPisave);
p[j]->GetYaxis()->SetLabelFont(vrstaPisave);
p[j]->GetYaxis()->SetLabelSize(0.05);
p[j]->GetYaxis()->SetLabelColor(kBlack);
p[j]->GetYaxis()->SetTitle("# events");
p[j]->GetYaxis()->SetNdivisions(0);
p[j]->GetYaxis()->CenterTitle();
p[j]->GetYaxis()->SetTitleSize(0.05);
p[j]->GetYaxis()->SetTitleOffset(.5);
p[j]->GetYaxis()->SetTitleColor(kWhite);
p[j]->GetXaxis()->SetTickLength(0.1);
p[j]->GetXaxis()->SetTitleFont(vrstaPisave);
p[j]->GetXaxis()->SetLabelFont(vrstaPisave);
p[j]->GetXaxis()->SetLabelSize(0.15);
p[j]->GetXaxis()->SetLabelColor(kBlack);
p[j]->GetXaxis()->SetLabelOffset(.05);
p[j]->GetXaxis()->SetTitle("Incident light position (stage step)");
//p[j]->GetXaxis()->SetNdivisions(0);
//p[j]->GetXaxis()->CenterTitle();
p[j]->GetXaxis()->SetTitleSize(0.01);
p[j]->GetXaxis()->SetTitleColor(kWhite); //zato ker ga ne moreš pozicionirat
p[j]->GetXaxis()->SetTitleOffset(.5);
pNoise = noise(p[j]);
for (int k=1;k<=p[j]->GetSize();k++) p[j]->SetBinContent(k,p[j]->GetBinContent(k)-pNoise);
if (j<6) p[j]->SetLineColor(kWhite+color[j]);
else p[j]->SetLineColor(kWhite+color[j-6]);
if (j==4) p[j]->DrawCopy();
else p[j]->DrawCopy("SAME");
}
}
}
c->Modified();
c->Update();
if (save==1){
switch (direction) {
case 0: sprintf(pdfname
,"./meritve/%s_4_2DX_focus1_run%04d_to%04d.pdf",HAPDserialNumber
,runNumber
,runNumber
+max
-1);break;
case 1: sprintf(pdfname
,"./meritve/%s_5_2DY_focus1_run%04d_to%04d.pdf",HAPDserialNumber
,runNumber
,runNumber
+max
-1);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==2){
switch (direction) {
case 0: sprintf(pdfname
,"./meritve/%s_4_2DX_focus1.pdf(",HAPDserialNumber
);break;
case 1: sprintf(pdfname
,"./meritve/%s_5_2DY_focus1.pdf(",HAPDserialNumber
);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==3){
switch (direction) {
case 0: sprintf(pdfname
,"./meritve/%s_4_2DX_focus1.pdf",HAPDserialNumber
);break;
case 1: sprintf(pdfname
,"./meritve/%s_5_2DY_focus1.pdf",HAPDserialNumber
);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==4){
switch (direction) {
case 0: sprintf(pdfname
,"./meritve/%s_4_2DX_focus1.pdf)",HAPDserialNumber
);break;
case 1: sprintf(pdfname
,"./meritve/%s_5_2DY_focus1.pdf)",HAPDserialNumber
);break;
}
c->SaveAs(pdfname,"pdf");
}
}
return 0;
}
int focus2(int runNumber, int save) {
int HAPDnumber; //Number of HAPD: 0, 1, 2 or 3!
int direction, nx, ny;
char name[128];
char pdfname[128];
char buf[256];
float pNoise;
int color[6] = {1,2,4,6,8,9};
char hname[0xF];
int max = 20;
TFile * data[max];
for (int b=0;b<max;b++){
sprintf(buf
,"./meritve/%04d_4_2DX_zOS_%05d.root",runNumber
+b
,(runNumber
-10+b
)*1000);
data[b] = new TFile(buf);
}
const char * serialNumber = getSN();
char * serialNumberTemp = strdup(serialNumber);
char * HAPDserialNumber;
GRID m = mapping();
int vrstaPisave = 82;
TCanvas * c;
TPad * pad2;
TPad * VirtualPad2[max];
TH3D * h;
TH2D * slice[max]; //take the right slice from 3D histogram
TH1D * p[max];
/********** GLOBALNE **********/
gStyle->SetOptStat(0);
//gStyle->SetOptTitle(1);
gStyle->SetTitleFontSize(.15);
int line = 1;
for(int HAPDnumber=0;HAPDnumber<4;HAPDnumber++){
HAPDserialNumber = strsep(&serialNumberTemp,",");
if(!strcmp(HAPDserialNumber
,"noserial")) continue;
sprintf(hname
,"hxy%d_0;1",HAPDnumber
);
printf("%s \t %s \n",HAPDserialNumber
,hname
);
h = (TH3D *) data[0]->Get(hname);
/********** SMER MERITVE **********/
h->GetZaxis()->SetRange(1,1);
nx = h->GetNbinsX();
ny = h->GetNbinsY();
if (nx>=ny) direction = 0;
else direction = 1;
printf("Direction = %d\n", direction
);
/********** CANVAS **********/
if (!direction) {
sprintf(buf
,"%04d_%s_px",runNumber
,HAPDserialNumber
);
c = new TCanvas(buf,buf,0,0,500,2000);
} else {
sprintf(buf
,"%04d_%s_py",runNumber
,HAPDserialNumber
);
c = new TCanvas(buf,buf,0,0,2000,2000);
}
pad2 = new TPad("pad2","Graphs",0,0,1,1,0,0);
pad2->SetFillStyle(4000);
pad2->Draw();
/********** PAD2 **********/
pad2->cd();
pad2->Divide(1,max,0,0);
for (int i=0;i<max;i++) {
if(i) h = (TH3D *) data[i]->Get(hname);
pad2->cd(i+1);
VirtualPad2[i] = (TPad *)(pad2->cd(i+1)); //Tole nastaviš zato, da lahko daš Log skalo
VirtualPad2[i]->SetLogy(1);
//VirtualPad2[i]->SetLeftMargin(.05);
//VirtualPad2[i]->SetRightMargin(.05);
//VirtualPad2[i]->SetGrid();
for (int j=4;j<8;j++) {
if (!direction) h->GetZaxis()->SetRange(m.koordinatniSistem[j][line+4]+1,m.koordinatniSistem[j][line+4]+1);
else h->GetZaxis()->SetRange(m.koordinatniSistem[line+4][j]+1,m.koordinatniSistem[line+4][j]+1);
slice[j] = (TH2D *)h->Project3D("pyx");
if (!direction) {
sprintf(name
,"PX: (%d,%d)",j
,line
+4);
p[j] = slice[j]->ProjectionX(name,line+1,line+1);
sprintf(name
,"Z = %d Projection X of row %d",(runNumber
-10+i
)*1000,line
+4);
} else {
sprintf(name
,"PY: (%d,%d)",line
+4,j
);
p[j] = slice[j]->ProjectionY(name,line+1,line+1);
sprintf(name
,"Z = %d Projection Y of column %d",(runNumber
-10+i
)*1000,line
+4);
}
p[j]->SetLineWidth(1);
p[j]->SetTitle(name);
p[j]->SetTitleOffset(1.5);
p[j]->GetYaxis()->SetRangeUser(1,10000);
p[j]->GetYaxis()->SetTickLength(0.01);
p[j]->GetYaxis()->SetTitleFont(vrstaPisave);
p[j]->GetYaxis()->SetLabelFont(vrstaPisave);
p[j]->GetYaxis()->SetLabelSize(0.05);
p[j]->GetYaxis()->SetLabelColor(kBlack);
p[j]->GetYaxis()->SetTitle("# events");
p[j]->GetYaxis()->SetNdivisions(0);
p[j]->GetYaxis()->CenterTitle();
p[j]->GetYaxis()->SetTitleSize(0.05);
p[j]->GetYaxis()->SetTitleOffset(.5);
p[j]->GetYaxis()->SetTitleColor(kWhite);
p[j]->GetXaxis()->SetTickLength(0.1);
p[j]->GetXaxis()->SetTitleFont(vrstaPisave);
p[j]->GetXaxis()->SetLabelFont(vrstaPisave);
p[j]->GetXaxis()->SetLabelSize(0.15);
p[j]->GetXaxis()->SetLabelColor(kBlack);
p[j]->GetXaxis()->SetLabelOffset(.05);
p[j]->GetXaxis()->SetTitle("Incident light position (stage step)");
//p[j]->GetXaxis()->SetNdivisions(0);
//p[j]->GetXaxis()->CenterTitle();
p[j]->GetXaxis()->SetTitleSize(0.01);
p[j]->GetXaxis()->SetTitleColor(kWhite); //zato ker ga ne moreš pozicionirat
p[j]->GetXaxis()->SetTitleOffset(.5);
pNoise = noise(p[j]);
for (int k=1;k<=p[j]->GetSize();k++) p[j]->SetBinContent(k,p[j]->GetBinContent(k)-pNoise);
if (j<6) p[j]->SetLineColor(kWhite+color[j]);
else p[j]->SetLineColor(kWhite+color[j-6]);
if (j==4) p[j]->DrawCopy();
else p[j]->DrawCopy("SAME");
}
if(i==max-1) VirtualPad2[max-1]->SetBottomMargin(.17);
}
c->Modified();
c->Update();
if (save==1){
switch (direction) {
case 0: sprintf(pdfname
,"./meritve/%s_4_2DX_focus2_run%04d_to%04d.pdf",HAPDserialNumber
,runNumber
,runNumber
+max
-1);break;
case 1: sprintf(pdfname
,"./meritve/%s_5_2DY_focus2_run%04d_to%04d.pdf",HAPDserialNumber
,runNumber
,runNumber
+max
-1);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==2){
switch (direction) {
case 0: sprintf(pdfname
,"./meritve/%s_4_2DX_focus2.pdf(",HAPDserialNumber
);break;
case 1: sprintf(pdfname
,"./meritve/%s_5_2DY_focus2.pdf(",HAPDserialNumber
);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==3){
switch (direction) {
case 0: sprintf(pdfname
,"./meritve/%s_4_2DX_focus2.pdf",HAPDserialNumber
);break;
case 1: sprintf(pdfname
,"./meritve/%s_5_2DY_focus2.pdf",HAPDserialNumber
);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==4){
switch (direction) {
case 0: sprintf(pdfname
,"./meritve/%s_4_2DX_focus2.pdf)",HAPDserialNumber
);break;
case 1: sprintf(pdfname
,"./meritve/%s_5_2DY_focus2.pdf)",HAPDserialNumber
);break;
}
c->SaveAs(pdfname,"pdf");
}
}
return 0;
}
int focus3(int runNumber, int save) {
int HAPDnumber; //Number of HAPD: 0, 1, 2 or 3!
int direction, nx, ny;
char name[128];
char pdfname[128];
char buf[256];
float pNoise;
int color[6] = {1,2,4,6,8,9};
char hname[0xF];
const char * serialNumber = getSN();
char * serialNumberTemp = strdup(serialNumber);
char * HAPDserialNumber;
GRID m = mapping();
int vrstaPisave = 82;
TCanvas * c;
TPad * pad1, * pad2, * pad3;
TPad * VirtualPad2[12];
TPaveText * info, * axisName;
TAxis * axis;
TH3D * h;
TH2D * slice[12]; //take the right slice from 3D histogram
TH1D * p[12];
/********** GLOBALNE **********/
gStyle->SetOptStat(0);
//gStyle->SetOptTitle(1);
gStyle->SetTitleFontSize(.15);
for(int HAPDnumber=0;HAPDnumber<4;HAPDnumber++){
HAPDserialNumber = strsep(&serialNumberTemp,",");
if(!strcmp(HAPDserialNumber
,"noserial")) continue;
sprintf(hname
,"hxy%d_0;1",HAPDnumber
);
printf("%s \t %s \n",HAPDserialNumber
,hname
);
h = (TH3D *) gDirectory->Get(hname);
/********** SMER MERITVE **********/
h->GetZaxis()->SetRange(1,1);
nx = h->GetNbinsX();
ny = h->GetNbinsY();
if (nx>=ny) direction = 0;
else direction = 1;
printf("Direction = %d\n", direction
);
/********** CANVAS **********/
if (!direction) {
sprintf(buf
,"%04d_%s_px",runNumber
,HAPDserialNumber
);
c = new TCanvas(buf,buf,0,0,700,700);
} else {
sprintf(buf
,"%04d_%s_py",runNumber
,HAPDserialNumber
);
c = new TCanvas(buf,buf,0,0,700,700);
}
pad1 = new TPad("pad1","Title",0.05,0.94,0.95,1,0,0);
pad1->SetFillStyle(4000);
pad1->Draw();
pad2 = new TPad("pad2","Graphs",0,0,1,0.95,0,0);
pad2->SetFillStyle(4000);
pad2->Draw();
pad3 = new TPad("pad3","AxisTitle",0.57,0,0.92,0.05,0,0);
pad3->SetFillStyle(4000);
pad3->Draw();
/********** PAD 1 **********/
pad1->cd();
info = new TPaveText(0.2,0,0.8,1,"ndc");
info->SetBorderSize(0);
info->SetFillColor(4000);
info->SetTextSize(1);
info->SetTextAlign(22);
sprintf(name
,"HAPD# %s (center)", HAPDserialNumber
);
info->AddText(name);
info->Draw();
/********** PAD3 **********/
pad3->cd();
axisName = new TPaveText(0.2,0,0.8,1,"ndc");
axisName->SetBorderSize(0);
axisName->SetFillColor(4000);
axisName->SetTextSize(.7);
axisName->SetTextFont(vrstaPisave);
axisName->SetTextAlign(22);
sprintf(name
,"Incident light position (stage step)");
axisName->AddText(name);
//axisName->Draw();
/********** PAD2 **********/
pad2->cd();
pad2->Divide(1,4,0,0);
h = (TH3D *) gDirectory->Get(hname);
for (int i=4;i<8;i++) {
if (!direction) {
pad2->cd(11 - i+1-4);
VirtualPad2[11 - i-4] = (TPad *)(pad2->cd(11 - i+1-4)); //Tole nastaviš zato, da lahko daš Log skalo
VirtualPad2[11 - i-4]->SetLogy(1);
//VirtualPad2[11 - i]->SetLeftMargin(.05);
//VirtualPad2[11 - i]->SetRightMargin(.05);
VirtualPad2[11 - i-4]->SetGrid();
} else {
pad2->cd(i+1-4);
VirtualPad2[i-4] = (TPad *)(pad2->cd(11 - i+1 - 4)); //Tole nastaviš zato, da lahko daš Log skalo
VirtualPad2[i-4]->SetLogy(1);
//VirtualPad2[i]->SetLeftMargin(.05);
//VirtualPad2[i]->SetRightMargin(.05);
VirtualPad2[i-4]->SetGrid();
}
for (int j=4;j<8;j++) {
if (!direction) h->GetZaxis()->SetRange(m.koordinatniSistem[j][i]+1,m.koordinatniSistem[j][i]+1);
else h->GetZaxis()->SetRange(m.koordinatniSistem[i][j]+1,m.koordinatniSistem[i][j]+1);
slice[j] = (TH2D *)h->Project3D("pyx");
if (!direction) {
p[j] = slice[j]->ProjectionX(name,i+1-4,i+1-4);
sprintf(name
,"Projection X of row %d",i
);
} else {
p[j] = slice[j]->ProjectionY(name,i+1-4,i+1-4);
sprintf(name
,"Projection Y of column %d",i
);
}
axis = p[j]->GetXaxis();
if(!direction) VirtualPad2[3]->SetBottomMargin(.17);
else VirtualPad2[0]->SetBottomMargin(.17);
p[j]->SetLineWidth(1);
p[j]->SetTitle(name);
p[j]->SetTitleOffset(1.5);
p[j]->GetYaxis()->SetRangeUser(1,10000);
p[j]->GetYaxis()->SetTickLength(0.01);
p[j]->GetYaxis()->SetTitleFont(vrstaPisave);
p[j]->GetYaxis()->SetLabelFont(vrstaPisave);
p[j]->GetYaxis()->SetLabelSize(0.05);
p[j]->GetYaxis()->SetLabelColor(kBlack);
p[j]->GetYaxis()->SetTitle("# events");
p[j]->GetYaxis()->SetNdivisions(0);
p[j]->GetYaxis()->CenterTitle();
p[j]->GetYaxis()->SetTitleSize(0.05);
p[j]->GetYaxis()->SetTitleOffset(.5);
p[j]->GetYaxis()->SetTitleColor(kWhite);
p[j]->GetXaxis()->SetTickLength(0.1);
p[j]->GetXaxis()->SetTitleFont(vrstaPisave);
p[j]->GetXaxis()->SetLabelFont(vrstaPisave);
p[j]->GetXaxis()->SetLabelSize(0.15);
p[j]->GetXaxis()->SetLabelColor(kBlack);
p[j]->GetXaxis()->SetLabelOffset(.05);
p[j]->GetXaxis()->SetTitle("Incident light position (stage step)");
//p[j]->GetXaxis()->SetNdivisions(0);
//p[j]->GetXaxis()->CenterTitle();
p[j]->GetXaxis()->SetTitleSize(0.01);
p[j]->GetXaxis()->SetTitleColor(kWhite); //zato ker ga ne moreš pozicionirat
p[j]->GetXaxis()->SetTitleOffset(.5);
pNoise = noise(p[j]);
for (int k=1;k<=p[j]->GetSize();k++) p[j]->SetBinContent(k,p[j]->GetBinContent(k)-pNoise);
if (j<6) p[j]->SetLineColor(kWhite+color[j]);
else p[j]->SetLineColor(kWhite+color[j-6]);
if (j==4) p[j]->DrawCopy();
else p[j]->DrawCopy("SAME");
}
}
c->Modified();
c->Update();
if (save==1){
switch (direction) {
case 0: sprintf(pdfname
,"./meritve/%03d_%s_4_2DX_focus3.pdf",runNumber
,HAPDserialNumber
);break;
case 1: sprintf(pdfname
,"./meritve/%03d_%s_5_2DY_focus3.pdf",runNumber
,HAPDserialNumber
);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==2){
switch (direction) {
case 0: sprintf(pdfname
,"./meritve/%s_4_2DX_focus3.pdf(",HAPDserialNumber
);break;
case 1: sprintf(pdfname
,"./meritve/%s_5_2DY_focus3.pdf(",HAPDserialNumber
);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==3){
switch (direction) {
case 0: sprintf(pdfname
,"./meritve/%s_4_2DX_focus3.pdf",HAPDserialNumber
);break;
case 1: sprintf(pdfname
,"./meritve/%s_5_2DY_focus3.pdf",HAPDserialNumber
);break;
}
c->SaveAs(pdfname,"pdf");
} else if (save==4){
switch (direction) {
case 0: sprintf(pdfname
,"./meritve/%s_4_2DX_focus3.pdf)",HAPDserialNumber
);break;
case 1: sprintf(pdfname
,"./meritve/%s_5_2DY_focus3.pdf)",HAPDserialNumber
);break;
}
c->SaveAs(pdfname,"pdf");
}
}
return 0;
}
float noise(TH1D * proj) {
float nBin=proj->GetSize(); //ugotovi koliko binov je v histogramu
float wholeAverage=0; //sem da povprečje celotnega kanala
float noise=0; //sem da povprečn šum
int j=0;
for (int i=1;i<=nBin;i++) wholeAverage+=proj->GetBinContent(i)/nBin;
for (int i=1;i<=nBin;i++) {
if (proj->GetBinContent(i)<1.1*wholeAverage) {
noise+=proj->GetBinContent(i);
j++;
}
}
if(j!=0) return noise/j;
else return 0;
}