172 name.Form(
"%s_gx", hist->GetName());
176 xmax = gPad->GetUxmax();
177 xmin = gPad->GetUxmin();
179 hist->GetXaxis()->UnZoom();
180 hOut = hist->ProjectionX(name.Data(), hist->GetYaxis()->FindBin(this->Low), hist->GetYaxis()->FindBin(this->High));
182 hist->GetXaxis()->SetRangeUser(xmin, xmax);
200 xmax = gPad->GetUxmax();
201 xmin = gPad->GetUxmin();
203 hist->GetXaxis()->UnZoom();
204 hOut = hist->ProjectionX(name, hist->GetYaxis()->FindBin(this->Low), hist->GetYaxis()->FindBin(this->High));
206 hist->GetXaxis()->SetRangeUser(xmin, xmax);
222 name.Form(
"%s_gy", hist->GetName());
226 ymax = gPad->GetUymax();
227 ymin = gPad->GetUymin();
229 hist->GetYaxis()->UnZoom();
230 hOut = hist->ProjectionY(name.Data(), hist->GetXaxis()->FindBin(this->Low), hist->GetXaxis()->FindBin(this->High));
232 hist->GetYaxis()->SetRangeUser(ymin, ymax);
250 ymax = gPad->GetUymax();
251 ymin = gPad->GetUymin();
253 hist->GetYaxis()->UnZoom();
254 hOut = hist->ProjectionY(name, hist->GetXaxis()->FindBin(this->Low), hist->GetXaxis()->FindBin(this->High));
256 hist->GetYaxis()->SetRangeUser(ymin, ymax);
292 for (
auto &backgate : back) {
293 int startback = backgate.GetBinLow(hist);
294 int stopback = backgate.GetBinHigh(hist);
295 for (
int i=startback; i<=stopback; ++i) {
297 sumX += hist->GetBinCenter(i);
298 sumX2 += hist->GetBinCenter(i)*hist->GetBinCenter(i);
299 sumXY += hist->GetBinCenter(i)*hist->GetBinContent(i);
300 sumY += hist->GetBinContent(i);
301 sumY2 += hist->GetBinContent(i)*hist->GetBinContent(i);
305 double slope = (nData*sumXY - sumX*sumY)/(nData*sumX2-sumX*sumX);
307 double constant = (sumY*sumX2 - sumX*sumXY)/(nData*sumX2 - sumX*sumX);
309 double sumBackground = 0;
315 for (
int i=startGate; i<= stopGate; ++i) {
316 double background = constant + slope*hist->GetBinCenter(i);
317 sumBackground += background;
318 double Y = hist->GetBinContent(i) - background;
320 sumXY += hist->GetBinCenter(i)*Y;
323 double posX = sumXY/sumY;
324 double area = (double)sumY;
325 double dArea = std::sqrt(area + 2*sumBackground);
357 int startHigh = backHigh.
GetBinLow(hist);
363 for (
int i=startLow; i<=stopLow; ++i) {
365 sumX += hist->GetBinCenter(i);
366 sumX2 += hist->GetBinCenter(i)*hist->GetBinCenter(i);
367 sumXY += hist->GetBinCenter(i)*hist->GetBinContent(i);
368 sumY += hist->GetBinContent(i);
369 sumY2 += hist->GetBinContent(i)*hist->GetBinContent(i);
371 for (
int i=startHigh; i<=stopHigh; ++i) {
373 sumX += hist->GetBinCenter(i);
374 sumX2 += hist->GetBinCenter(i)*hist->GetBinCenter(i);
375 sumXY += hist->GetBinCenter(i)*hist->GetBinContent(i);
376 sumY += hist->GetBinContent(i);
377 sumY2 += hist->GetBinContent(i)*hist->GetBinContent(i);
379 double slope = (nData*sumXY - sumX*sumY)/(nData*sumX2-sumX*sumX);
380 double constant = (sumY*sumX2 - sumX*sumXY)/(nData*sumX2 - sumX*sumX);
382 double sumBackground = 0;
388 for (
int i=startGate; i<= stopGate; ++i) {
389 double background = constant + slope*hist->GetBinCenter(i);
390 sumBackground += background;
391 double Y = hist->GetBinContent(i) - background;
393 sumXY += hist->GetBinCenter(i)*Y;
396 double posX = sumXY/sumY;
397 double area = (double)sumY;
398 double dArea = std::sqrt(area + 2*sumBackground);
446 double backwidth = 0;
448 for (
auto &backgate : back) {
449 backwidth += (backgate.GetHigh()-backgate.GetLow());
450 int startback = backgate.GetBinLow(hist);
451 int stopback = backgate.GetBinHigh(hist);
452 for (
int i=startback; i<=stopback; ++i) {
454 sumX += hist->GetBinCenter(i);
455 sumX2 += hist->GetBinCenter(i)*hist->GetBinCenter(i);
456 sumXY += hist->GetBinCenter(i)*hist->GetBinContent(i);
457 sumY += hist->GetBinContent(i);
458 sumY2 += hist->GetBinContent(i)*hist->GetBinContent(i);
462 double slope = (nData*sumXY - sumX*sumY)/(nData*sumX2-sumX*sumX);
463 double constant = (sumY*sumX2 - sumX*sumXY)/(nData*sumX2 - sumX*sumX);
465 double sumBackground = 0;
472 for (
int i=startGate; i<= stopGate; ++i) {
473 double background = constant + slope*hist->GetBinCenter(i);
474 sumBackground += background;
475 double Y = hist->GetBinContent(i) - background;
477 sumXY += hist->GetBinCenter(i)*Y;
480 double posX = sumXY/sumY;
481 double area = (double)sumY;
482 double dArea = std::sqrt(area + std::pow(peakwidth/backwidth,2)*sumBackground);
624 double back_width = 0;
625 for (
auto &backgate : background) {
626 back += backgate.GetCountsError(hist);
627 back_width += backgate.GetBinWidth(hist);
630 return sqrt(pow(peak, 2) + pow(back*(
double)
GetBinWidth(hist)/back_width, 2));
736 int logy = gPad->GetLogy();
738 y1[0] = gPad->GetUymin();
740 y1[1] = gPad->GetUymax();
743 y1[1] = hist->GetBinContent(hist->FindBin(this->Low));
745 if (y1[1] > 0) y1[1] = TMath::Log10(y1[1]);
747 y1[1] = std::min(gPad->GetUymax(), y1[1]);
754 y2[0] = gPad->GetUymin();
756 y2[1] = gPad->GetUymax();
759 y2[1] = hist->GetBinContent(hist->FindBin(this->High));
761 if (y2[1] > 0) y2[1] = TMath::Log10(y2[1]);
763 y2[1] = std::min(gPad->GetUymax(), y2[1]);
766 if (gPad->GetUxmin() <= x1[0] && x1[0] <= gPad->GetUxmax()) {
768 gPad->PaintPolyLine(2, &x1[0], &y1[0], option);
771 if (gPad->GetUxmin() <= x2[0] && x2[0] <= gPad->GetUxmax()) {
773 gPad->PaintPolyLine(2, &x2[0], &y2[0], option);
778 gPad->PaintBox(x1[0], y1[0], x2[1], y2[1], option);
781 for (
int i=hist->FindBin(this->Low); i<=hist->FindBin(this->High); ++i) {
782 if (hist->GetBinCenter(i) < gPad->GetUxmin() || hist->GetBinCenter(i) > gPad->GetUxmax()) {
continue; }
783 x1[0] = std::max(this->Low, hist->GetBinLowEdge(i));
786 x2[0] = std::min(this->High, hist->GetBinLowEdge(i+1));
789 y1[1] = hist->GetBinContent(i);
790 y2[1] = hist->GetBinContent(i);
793 if (y1[1] > 0) y1[1] = TMath::Log10(y1[1]);
794 if (y2[1] > 0) y2[1] = TMath::Log10(y2[1]);
797 y1[1] = std::min(gPad->GetUymax(), y1[1]);
798 y2[1] = std::min(gPad->GetUymax(), y2[1]);
800 if (y1[1] <= y1[0] || y2[1] <= y2[0]) {
continue; }
802 gPad->PaintBox(x1[0], y1[0], x2[1], y2[1], option);