26 # include <TLinearFitter.h> 53 TList* ring =
static_cast<TList*
>(p->FindObject(Form(
"FMD%d%c",d,r)));
55 Error(
"DrawELossPoisson",
"List FMD%d%c not found in %s",d,r,p->GetName());
59 TH2* corr =
static_cast<TH2D*
>(ring->FindObject(
"elossVsPoisson"));
61 Error(
"DrawRingELossPoisson",
"Histogram esdEloss not found in FMD%d%c",
65 TPad* pad =
static_cast<TPad*
>(gPad);
70 pad->SetPad(pad->GetXlowNDC(), pad->GetYlowNDC(), .99,
71 pad->GetYlowNDC()+pad->GetHNDC());
72 pad->SetRightMargin(0.15);
75 if (xmax < 0) xmax = corr->GetXaxis()->GetXmax();
76 corr->GetXaxis()->SetRangeUser(xmin,xmax);
77 corr->GetYaxis()->SetRangeUser(xmin,xmax);
78 corr->SetTitle(Form(
"FMD%d%c",d,r));
82 if (corr->GetEntries() <= 0)
return 0;
86 Double_t rxy = corr->GetCorrelationFactor();
91 Double_t cxy = corr->GetCovariance();
98 if (TMath::Abs(cxy) < 1e-6)
return 0;
100 TMath::Sqrt(TMath::Power(sy2-delta*sx2,2) +
105 TF1* f =
new TF1(
"f",
"[0]+[1]*x", xmin, xmax);
106 f->SetParameters(alpha, beta);
111 TLine* l =
new TLine(xmin,xmin,xmax,xmax);
114 l->SetLineColor(kBlack);
119 Info(
"",
"FMD%d%c correlation coefficient: %9.5f%% " 120 "line y = %f + %f * x", d, r, 100*rxy, alpha, beta);
123 Double_t x = pad->GetLeftMargin()+.01;
124 Double_t y = 1-pad->GetTopMargin()-.01;
125 TLatex* ltx =
new TLatex(x, y, Form(
"FMD%d%c", d, r));
127 ltx->SetTextAlign(13);
128 ltx->SetTextSize(0.08);
131 ltx->SetTextSize(0.06);
132 ltx->DrawLatex(x,y,
"Deming regression: y=#alpha+#beta x");
135 ltx->SetTextSize(0.05);
136 ltx->DrawLatex(x, y, Form(
"#alpha=%5.3f", alpha));
138 ltx->DrawLatex(x, y, Form(
"#beta= %5.3f", beta));
140 TLinearFitter*
fitter =
new TLinearFitter(1);
141 fitter->SetFormula(
"1 ++ x");
142 for (
Int_t i = 1; i <= corr->GetNbinsX(); i++) {
143 x = corr->GetXaxis()->GetBinCenter(i);
144 if (x < xmin || x > xmax)
continue;
145 for (
Int_t j = 1; j <= corr->GetNbinsY(); j++) {
146 y = corr->GetYaxis()->GetBinCenter(j);
147 if (y < xmin || y > xmax)
continue;
149 if (c < .1)
continue;
150 fitter->AddPoint(&x, y, c);
155 fitter->EvalRobust();
159 for (
Int_t i = 0; i < 2; i++) {
160 std::cout << i <<
"\t" 161 << fitter->GetParName(i) <<
"\t" 162 << fitter->GetParameter(i) <<
"\t";
164 std::cout << fitter->GetParError(i);
165 std::cout << std::endl;
167 Double_t chi2 = fitter->GetChisquare();
168 Int_t ndf = (fitter->GetNpoints() -
169 fitter->GetNumberFreeParameters() );
170 std::cout <<
"chi2/ndf: " << chi2 <<
'/' << ndf
171 <<
'=' << chi2 / ndf << std::endl;
176 return corr->GetCorrelationFactor();
194 const char* folder=
"ForwardResults",
198 gStyle->SetPalette(1);
199 gStyle->SetOptFit(0);
200 gStyle->SetOptStat(0);
201 gStyle->SetOptTitle(0);
202 gStyle->SetTitleW(.4);
203 gStyle->SetTitleH(.1);
204 gStyle->SetTitleX(.4);
206 gStyle->SetTitleColor(0);
207 gStyle->SetTitleStyle(0);
208 gStyle->SetTitleBorderSize(0);
212 Error(
"DrawELossPoisson",
"failed to open %s",
filename);
216 TList* forward =
static_cast<TList*
>(file->Get(folder));
218 Error(
"DrawELossPoisson",
"List %s not found in %s", folder,
filename);
222 TList* dc =
static_cast<TList*
>(forward->FindObject(
"fmdDensityCalculator"));
224 Error(
"DrawELossPoisson",
"List fmdDensityCalculator not found in Forward");
228 TCanvas*
c =
new TCanvas(
"elossVsPoisson",
229 "N_ch from ELoss versus from Poisson", 900, 700);
233 c->SetHighLightColor(0);
234 c->Divide(3, 2, 0, 0);
243 TVirtualPad* p = c->cd(4);
244 p->SetTopMargin(0.05);
245 p->SetRightMargin(0.10);
246 p->SetLeftMargin(0.15);
247 p->SetBottomMargin(0.15);
250 TH1D* hc =
new TH1D(
"corrs",
"Correlation factors", 5, .5, 5.5);
251 hc->SetFillColor(kRed+1);
252 hc->SetFillStyle(3001);
255 hc->GetXaxis()->SetBinLabel(1,
"FMD1i"); hc->SetBinContent(1,corrs[0]);
256 hc->GetXaxis()->SetBinLabel(2,
"FMD2i"); hc->SetBinContent(2,corrs[1]);
257 hc->GetXaxis()->SetBinLabel(3,
"FMD2o"); hc->SetBinContent(3,corrs[2]);
258 hc->GetXaxis()->SetBinLabel(4,
"FMD3i"); hc->SetBinContent(4,corrs[3]);
259 hc->GetXaxis()->SetBinLabel(5,
"FMD3o"); hc->SetBinContent(5,corrs[4]);
260 hc->GetXaxis()->SetLabelSize(0.08);
261 hc->GetYaxis()->SetTitle(
"r");
262 hc->SetMarkerSize(1.5);
263 hc->Draw(
"text hist");
268 c->SaveAs(
"elossVsPoisson.png");
Double_t DrawRingELossPoisson(TList *p, UShort_t d, Char_t r, Double_t xmin, Double_t xmax)
void DrawELossPoisson(const char *filename="forward.root", const char *folder="ForwardResults", Double_t xmax=-1, Double_t xmin=-1)
TFile * file
TList with histograms for a given trigger.