1 double PIF_errOld(
double *x,
double *par) {
2 return par[0]*TMath::Erf(par[2]*(x[0]-par[1]))+par[3];
6 TF1* errScurveOld(TH1 *h) {
10 int ibin(-1), jbin(-1);
11 double hmax(h->GetMaximum());
12 for (
int i = STARTBIN; i <= h->GetNbinsX(); ++i) {
13 if (h->GetBinContent(i) > 0) {
20 for (
int i = STARTBIN; i < h->GetNbinsX(); ++i) {
21 if (h->GetBinContent(i) > 0.9*hmax && h->GetBinContent(i+1) > 0.9*hmax) {
27 double lo = h->GetBinLowEdge(1);
29 for (
int i = 3; i < h->GetNbinsX(); ++i) {
30 if (h->GetBinContent(i-2) < 1 && h->GetBinContent(i-1) < 1 && h->GetBinContent(i) < 1) {
31 lo = h->GetBinLowEdge(i-2);
36 double hi = h->FindLastBinAbove(0.9*h->GetMaximum());
40 TF1* f = (TF1*)gROOT->FindObject(
"PIF_err_old");
42 f =
new TF1(
"PIF_err_old", PIF_errOld, h->GetBinLowEdge(1), h->GetBinLowEdge(h->GetNbinsX()+1), 4);
43 f->SetParNames(
"p0",
"p1",
"p2",
"p3");
49 cout <<
"initializing to " << 0.5*h1->GetMaximum() << endl;
50 f->SetParameter(0, 0.5*h1->GetMaximum());
51 f->SetParameter(1, 30.);
52 f->SetParameter(2, .2);
53 f->SetParameter(3, 0.5*h1->GetMaximum());
60 void fitScurve(
int idx = 0,
double p0 = -1.,
double p1 = -1.,
double p2 = -1.,
double p3 = -1) {
61 TFile *file = TFile::Open(
"roc/pxar.root");
63 TH1D *h(0), *h0(0), *h1(0);
71 h = (TH1D*)file->Get(Form(
"Scurves/scurveVcal_Vcal_c%d_r%d_C0_V0", col, row));
73 h0 = (TH1D*)h->Clone(
"h0");
74 h1 = (TH1D*)h->Clone(
"h1");
79 f = fPIF->errScurve(h0);
80 if (p0 > 0.) f->SetParameter(0, p0);
81 if (p1 > 0.) f->SetParameter(1, p1);
82 if (p2 > 0.) f->SetParameter(2, p2);
83 if (p3 > 0.) f->SetParameter(3, p3);
86 f->SetLineColor(kRed);
90 double fSigma = 1./(TMath::Sqrt(2.)/f->GetParameter(1));
91 cout <<
"==> " << fSigma << endl;
95 f1 = errScurveOld(h1);
96 if (p0 > 0.) f1->SetParameter(0, p0);
97 if (p1 > 0.) f1->SetParameter(1, p1);
98 if (p2 > 0.) f1->SetParameter(2, p2);
99 if (p3 > 0.) f1->SetParameter(3, p3);
102 f1->SetLineColor(kBlue);
105 f1->FixParameter(3, 0.5*h1->GetMaximum());
108 double sig = 1./(TMath::Sqrt(2.)*f1->GetParameter(2));
109 cout <<
"==> " << sig << endl;
116 TFile *f0 = TFile::Open(
"roc/pxar-v20.root");
117 TH1D *h0 = (TH1D*)f0->Get(
"Scurves/dist_sig_scurveVcal_Vcal_C0_V0");
119 TFile *f1 = TFile::Open(
"roc/pxar-v10.root");
120 TH1D *h1 = (TH1D*)f1->Get(
"Scurves/dist_sig_scurveVcal_Vcal_C0_V0");
122 TFile *f2 = TFile::Open(
"roc/pxar-v30.root");
123 TH1D *h2 = (TH1D*)f2->Get(
"Scurves/dist_sig_scurveVcal_Vcal_C0_V0");
125 TFile *f3 = TFile::Open(
"roc/pxar-v40.root");
126 TH1D *h3 = (TH1D*)f3->Get(
"Scurves/dist_sig_scurveVcal_Vcal_C0_V0");
128 TFile *f4 = TFile::Open(
"roc/pxar-v50.root");
129 TH1D *h4 = (TH1D*)f4->Get(
"Scurves/dist_sig_scurveVcal_Vcal_C0_V0");
131 h4->SetLineColor(kOrange);
134 h0->SetLineColor(kRed);
135 h0->Draw(
"samehist");
136 tl.SetTextColor(kRed);
137 tl.DrawLatex(0.20, 0.75,
"ntrig = 5");
139 h1->SetLineColor(kCyan);
140 h1->Draw(
"samehist");
141 tl.SetTextColor(kCyan);
142 tl.DrawLatex(0.20, 0.70,
"ntrig = 10");
144 h2->SetLineColor(kBlue);
145 h2->Draw(
"samehist");
146 tl.SetTextColor(kBlue);
147 tl.DrawLatex(0.20, 0.65,
"ntrig = 20");
149 h3->SetLineColor(kBlack);
150 h3->Draw(
"samehist");
151 tl.SetTextColor(kBlack);
152 tl.DrawLatex(0.20, 0.60,
"ntrig = 50");
154 tl.SetTextColor(kOrange);
155 tl.DrawLatex(0.20, 0.55,
"ntrig = 100");
157 gStyle->SetOptStat(0);
158 gStyle->SetOptTitle(0);
164 void compare(
string f1name =
"roc/pxar-v0.root",
string f2name =
"roc/pxar-v1.root") {
166 TFile *f1 = TFile::Open(f1name.c_str());
167 TH2D *h1 = (TH2D*)f1->Get(
"Scurves/sig_scurveVcal_Vcal_C0_V0");
169 TFile *f2 = TFile::Open(f2name.c_str());
170 TH2D *h2 = (TH2D*)f2->Get(
"Scurves/sig_scurveVcal_Vcal_C0_V0");
173 TH2D *h3 = (TH2D*)h1->Clone(
"h3"); h3->Reset();
175 TH1D *h4 =
new TH1D(
"h4",
"", 100, -1., 1.);
178 for (
int ix = 0; ix < h1->GetNbinsX(); ++ix) {
179 for (
int iy = 0; iy < h1->GetNbinsY(); ++iy) {
180 v1 = h1->GetBinContent(ix+1, iy+1);
181 v2 = h2->GetBinContent(ix+1, iy+1);
182 h3->SetBinContent(ix+1, iy+1, v1-v2);