13 # include <TAttMarker.h> 14 # include <TAttLine.h> 15 # include <TAttFill.h> 17 # define GraphSysErr_C 22 # include <TGraphErrors.h> 23 # include <TGraphAsymmErrors.h> 24 # include <TMultiGraph.h> 27 # include <TFitResultPtr.h> 33 # include <TBrowser.h> 34 # include <TPRegexp.h> 35 # include <TClonesArray.h> 36 # include <TArrayL64.h> 39 # include <TObjString.h> 45 # define INCOMPAT_CMN_AS_QUAL 1 50 class TGraphAsymmErrors;
175 public TAttLine,
public TAttFill
274 : TNamed(
"sysErrGraph",
"Data"),
312 : TNamed(name,title),
373 fData =
static_cast<Graph*
>(other.
fData->Clone());
377 fCommon.SetName(other.GetName());
382 while ((common = static_cast<HolderCommon*>(nextC()))) {
389 while ((p2p = static_cast<HolderP2P*>(nextP()))) {
418 if (&other ==
this)
return *
this;
420 other.TNamed::Copy(*
this);
421 other.TAttMarker::Copy(*
this);
422 other.TAttLine::Copy(*
this);
423 other.TAttFill::Copy(*
this);
430 fData =
static_cast<Graph*
>(other.
fData->Clone());
452 while ((common = static_cast<HolderCommon*>(nextC())))
457 while ((p2p = static_cast<HolderP2P*>(nextP())))
463 fMap =
static_cast<TList*
>(other.
fMap->Clone());
483 virtual void ls(Option_t* option=
"")
const 492 virtual void Print(Option_t* option=
"R")
const 494 gROOT->IndentLevel();
495 std::cout << GetName() <<
": " << GetTitle() << std::endl;
499 if (opt.IsNull())
return;
501 Bool_t all = opt.Contains(
"ALL");
502 Bool_t keys = all || opt.Contains(
"KEY");
503 Bool_t qual = all || opt.Contains(
"QUAL");
504 Bool_t sys = all || opt.Contains(
"SYS");
505 Bool_t cmn = sys || opt.Contains(
"COMMON");
506 Bool_t p2p = sys || opt.Contains(
"P2P");
507 Bool_t poi = all || opt.Contains(
"XY");
508 Bool_t attr = all || opt.Contains(
"ATTR");
509 Bool_t sum = opt.Contains(
"SUM");
511 gROOT->IncreaseDirLevel();
513 gROOT->IndentLevel();
514 std::cout <<
"Key/value pairs: " << std::endl;
515 gROOT->IncreaseDirLevel();
518 while ((kv = nextKV())) {
519 gROOT->IndentLevel();
520 std::cout <<
'"' << kv->GetName() <<
'"' <<
"\t" 521 <<
'"' << kv->GetTitle() <<
'"' <<
"\n";
523 gROOT->IndentLevel();
524 std::cout <<
"\"XTitle\"\t\"" <<
fXTitle <<
"\"\n";
525 gROOT->IndentLevel();
526 std::cout <<
"\"YTitle\"\t\"" <<
fYTitle <<
"\"\n";
528 gROOT->DecreaseDirLevel();
531 gROOT->IndentLevel();
532 std::cout <<
"Qualifier pairs: " << std::endl;
533 gROOT->IncreaseDirLevel();
536 while ((q = nextQ())) {
537 gROOT->IndentLevel();
538 std::cout <<
'"' << q->GetName() <<
'"' <<
"\t" 539 <<
'"' << q->GetTitle() <<
'"' <<
"\n";
542 gROOT->DecreaseDirLevel();
545 gROOT->IndentLevel();
546 Printf(
" [option: %3d line (c/s/w):%3d/%1d/%2d fill (c/s):%3d/%4d marker (c/s/s):%3d/%2d/%f]",
547 fDataOption, GetLineColor(), GetLineStyle(), GetLineWidth(),
548 GetFillColor(), GetFillStyle(),
549 GetMarkerColor(), GetMarkerStyle(), GetMarkerSize());
550 gROOT->IndentLevel();
551 Printf(
" [sum title: %s " 552 "option: %3d line (c/s/w):%3d/%1d/%2d fill (c/s):%3d/%4d",
559 gROOT->IndentLevel();
560 Printf(
" [common sum title: %s " 561 "option: %3d line (c/s/w):%3d/%1d/%2d fill (c/s):%3d/%4d",
572 gROOT->IndentLevel();
573 std::cout <<
"Commons: " << std::endl;
574 gROOT->IncreaseDirLevel();
577 while ((c = nextC())) {
578 gROOT->IndentLevel();
582 gROOT->DecreaseDirLevel();
586 gROOT->IndentLevel();
587 std::cout <<
"Point-to-point: " << std::endl;
588 gROOT->IncreaseDirLevel();
591 while ((p = nextP())) {
592 gROOT->IndentLevel();
596 gROOT->DecreaseDirLevel();
600 gROOT->IndentLevel();
601 std::cout <<
"Points: " << std::endl;
602 gROOT->IncreaseDirLevel();
604 hs.Form(
" %3s: %9s %9s %9s -> %9s %9s %9s",
605 "#",
"X",
"-dX",
"+dX",
"Y",
"-stat",
"+stat");
606 gROOT->IndentLevel();
609 hs.Form(
" %9s %9s",
"-sys",
"+sys");
615 while ((p = static_cast<HolderP2P*>(nextP()))) {
617 const char* post = (rel ?
"%" :
" ");
618 TString nm(p->GetTitle());
619 if (nm.Length() > 7) {
620 nm.Remove(4,nm.Length()-4);
623 hs.Form(
" -%8s%s +%8s%s", nm.Data(), post, nm.Data(), post);
627 std::cout << std::endl;
628 for (Int_t i = 0; i <
GetN(); i++) {
629 gROOT->IndentLevel();
630 Double_t eyl, eyh, wyl, wyh;
632 Double_t y =
GetYandError(i,
false,
false,
true,
false,eyl,eyh,wyl,wyh);
635 s.Form(
" %3d: %+8f -%7f +%7f -> %+8f -%7f +%7f",
641 sSum.Form(
" -%7f +%7f", eyl, eyh);
648 while ((p = static_cast<HolderP2P*>(nextP()))) {
650 Double_t fac = (rel ? (TMath::Abs(y) > 1e-9 ? 100/y : 0) : 1);
651 const char* post = (rel ?
"%" :
" ");
652 s.Form(
" -%7f%s +%7f%s",
654 fac * p->
GetYUp(i) , post);
659 std::cout << std::endl;
661 gROOT->DecreaseDirLevel();
663 gROOT->DecreaseDirLevel();
785 Bool_t clear = opt.Contains(
"CLEAR");
786 Bool_t axis = opt.Contains(
"AXIS");
796 fDrawn->Draw(axis ?
"A" :
"");
823 TFitResultPtr
Fit(TF1* f1, Option_t* fitOption, Option_t* drawOption,
824 Axis_t min=0, Axis_t max=0)
826 TString dOpt(drawOption);
828 Bool_t clear = dOpt.Contains(
"CLEAR");
829 Bool_t axis = dOpt.Contains(
"AXIS");
838 !
fDrawn->GetListOfGraphs() ||
839 !
fDrawn->GetListOfGraphs()->First())
840 return TFitResultPtr(-1);
842 Graph* g =
static_cast<Graph*
>(
fDrawn->GetListOfGraphs()->First());
844 TString fOpt(fitOption);
846 Bool_t noStore = fOpt.Contains(
"N");
847 Bool_t noDraw = fOpt.Contains(
"0");
848 Bool_t range = fOpt.Contains(
"R");
850 TFitResultPtr r = g->Fit(f1, fOpt.Data(),
"", min, max);
855 if (min < max && !range) f1->SetRange(min, max);
856 fDrawn->GetListOfFunctions()->Add(f1);
860 if (!noStore && !noDraw) {
861 fDrawn->Draw(axis ?
"A" :
"");
891 TFitResultPtr
Fit(
const char* formula,
892 Option_t* fitOption, Option_t* drawOption,
893 Axis_t min=0, Axis_t max=0)
895 TString fname(formula);
896 Bool_t linear = fname.Contains(
"++");
898 if (linear) f1 =
new TF1(formula,formula,min,max);
900 f1 =
static_cast<TF1*
>(gROOT->GetFunction(formula));
901 if (!f1) Warning(
"Fit",
"Unknown function %s", formula);
905 return Fit(f1, fitOption, drawOption, min, max);
934 while ((cmn = static_cast<HolderCommon*>(cNext()))) {
940 for (Int_t i = 0; i <
GetN(); i++) {
941 Double_t x =
GetX(i);
942 Double_t y =
GetY(i);
943 Double_t g = f->Eval(x);
949 while ((p2p = static_cast<HolderP2P*>(pNext()))) {
951 (TMath::Abs(y) < 1e-9) ? 0 : 1/y : 1/g);
967 while ((cmn = static_cast<HolderCommon*>(cNext()))) {
973 for (Int_t i = 0; i <
GetN(); i++) {
974 Double_t y =
GetY(i);
980 while ((p2p = static_cast<HolderP2P*>(pNext()))) {
982 (TMath::Abs(y) < 1e-9) ? 0 : 1/y :
1003 Int_t
Average(
const TCollection* others, Bool_t sep=
true)
1005 const Double_t tol = 1e-9;
1006 TList sharedC; sharedC.SetOwner();
1008 TIter oNext(others);
1010 Double_t xMin = +1e9;
1011 Double_t xMax = -1e9;
1013 Bool_t first =
true;
1014 Bool_t nonSh =
false;
1020 while ((other = static_cast<GraphSysErr*>(oNext()))) {
1021 Int_t n = other->
GetN();
1022 nX = TMath::Max(nX,n);
1031 while ((cmn = static_cast<HolderCommon*>(cNext()))) {
1039 while ((p2p = static_cast<HolderP2P*>(pNext()))) {
1040 sharedP.Add(p2p->Clone());
1051 TObjLink* cur = sharedC.FirstLink();
1058 Info(
"Average",
"Common systematic %s not found in %s",
1059 o->GetTitle(), other->GetName());
1060 other->
Print(
"sys");
1061 TObjLink* keep = cur->Next();
1062 TObject* obj = sharedC.Remove(cur);
1065 if (obj)
delete obj;
1072 cur = sharedP.FirstLink();
1079 Info(
"Average",
"P2P systematic %s not found in %s",
1080 o->GetTitle(), other->GetName());
1081 TObjLink* keep = cur->Next();
1082 TObject* obj = sharedP.Remove(cur);
1085 if (obj)
delete obj;
1096 TIter nextC(&sharedC);
1098 while ((com = static_cast<HolderCommon*>(nextC()))) {
1111 while ((other = static_cast<GraphSysErr*>(oNext()))) {
1114 Error(
"Average",
"This should NOT happen");
1115 other->
Print(
"sys");
1126 if (nonSh || !sep) {
1146 TIter nextP(&sharedP);
1150 while ((p2p = static_cast<HolderP2P*>(nextP()))) {
1156 Info(
"Average",
"Shared point-to-point error %s", p->GetTitle());
1163 while ((other = static_cast<GraphSysErr*>(oNext())) && off < 64) {
1166 Error(
"Average",
"This should NOT happen");
1169 mask |= ((op->GetUniqueID() & 0x3F) << off);
1176 "Some shared point-to-point errors could not be encoded " 1177 "becasue we have too many (%d>%d) input graphs",
1178 others->GetEntries(), 64/dOf);
1201 while ((other = static_cast<GraphSysErr*>(oNext()))) {
1205 while ((p2p = static_cast<HolderP2P*>(oNextP())) && off < 64) {
1220 mask = &(mp2p[pId]);
1223 *mask |= ((p2p->GetUniqueID() & 0x3F) << off);
1229 "Some shared point-to-point errors could not be encoded " 1230 "becasue we have too many (%d>%d) input graphs",
1231 others->GetEntries(), 64/dOf);
1245 Double_t oldX = xMin;
1253 Double_t nextX = xMax;
1257 while ((other = static_cast<GraphSysErr*>(oNext()))) {
1258 for (Int_t i = other->GetUniqueID(); i < other->
GetN(); i++) {
1259 if (other->
GetX(i) <= x) {
1263 if (other->
GetX(i) < nextX) {
1265 nextX = other->
GetX(i);
1277 if (nextX >= xMax) {
1282 if (cnt >= xa.GetSize()) {
1283 Warning(
"Average",
"increasing size of X cache");
1292 Double_t dx = texh*2;
1296 }
while (cnt < 1000);
1307 for (Int_t i = 0; i < cnt; i++) {
1308 Double_t xi = xa[i];
1309 Double_t texl = exla[i];
1310 Double_t texh = exha[i];
1311 Double_t nexl = TMath::Abs(xi - (i == 0 ? xa[i+1] : xa[i-1]))/2;
1312 Double_t nexh = TMath::Abs(xi - (i + 1 == cnt ? xa[i-1] : xa[i+1]))/2;
1313 Double_t exl = TMath::Min(texl, nexl);
1314 Double_t exh = TMath::Min(texh, nexh);
1338 TArrayI ai1(others->GetEntries());
1339 TArrayI ai2(others->GetEntries());
1340 TArrayD ax(others->GetEntries());
1341 while ((other = static_cast<GraphSysErr*>(oNext()))) {
1343 Bool_t stat =
false;
1345 Bool_t nosqrt =
false;
1347 Double_t y, eyl, eyh, wyl, wyh, syl, syh;
1349 Int_t fret = other->
FindPoint(xi, ai1[j], ai2[j]);
1350 if (fret < -1) { j++;
continue; }
1352 y = other->
GetYandError(fret,cmn,stat,quad,nosqrt,eyl, eyh, wyl, wyh);
1357 Double_t eyl1, eyh1, wyl1, wyh1;
1358 Double_t eyl2, eyh2, wyl2, wyh2;
1359 Double_t x1 = other->
GetX(ai1[j]);
1360 Double_t x2 = other->
GetX(ai2[j]);
1361 Double_t y1 = other->
GetYandError(ai1[j],cmn,stat,quad,nosqrt,
1362 eyl1,eyh1,wyl1,wyh1);
1363 Double_t y2 = other->
GetYandError(ai2[j],cmn,stat,quad,nosqrt,
1364 eyl2,eyh2,wyl2,wyh2);
1369 Double_t dx = (x2-x1);
1371 y = y1 + ax[j] * (y2-y1);
1372 eyl = eyl1 + ax[j] * (eyh1-eyl1);
1373 eyh = eyh2 + ax[j] * (eyh2-eyl2);
1374 wyl = wyl1 + ax[j] * (wyh1-wyl1);
1375 wyh = wyh2 + ax[j] * (wyh2-wyl2);
1376 syl = syl1 + ax[j] * (syh1-syl1);
1377 syh = syh2 + ax[j] * (syh2-syl2);
1380 centroid.
Add(y, wyl, wyh);
1381 error.
Add(y, eyl, eyh);
1382 stats.
Add(y, syl, syh);
1418 for (Int_t j = 1; j < mp2p.GetSize(); j++) {
1419 Long64_t mask = mp2p[j];
1420 if (mask == 0)
continue;
1424 Warning(
"Average",
"No target point-to-point error at %d for id=%d",
1430 Long64_t rem = mask;
1442 while ((other = static_cast<GraphSysErr*>(oNext()))) {
1443 if (ai1[k] == -1 && ai2[k] == -1) {
1450 Int_t sid = ((rem >> dOf*k) & 0x3f);
1461 Warning(
"Average",
"Couldn't find point-to-point error %d (%s)" 1462 "in graph %d (%s) - should not happen",
1463 sid, tp2p->GetTitle(), k, other->GetName());
1469 if (ai1[k] == ai2[k]) {
1471 sy = other->
GetY(ai1[k]);
1477 Double_t sy1 = other->
GetY(ai1[k]);
1478 Double_t sy2 = other->
GetY(ai2[k]);
1479 sy = sy1 + ax[k] * (sy2-sy1);
1480 seyl = sp2p->
GetYDown(ai1[k],ai2[k],ax[k]);
1481 seyh = sp2p->
GetYUp(ai1[k],ai2[k],ax[k]);
1485 sc.
Add(sy, seyl, seyh);
1498 while ((other = static_cast<GraphSysErr*>(oNext())))
1515 Option_t* option=
"quad sum stat",
1519 if (last < 0) last =
GetN()-1;
1522 TString opts(option); opts.ToLower();
1523 Bool_t cmn = opts.Contains(
"comm");
1524 Bool_t stat = opts.Contains(
"stat");
1525 Bool_t quad = opts.Contains(
"quad");
1527 for (Short_t i = first; i <= last; i++) {
1529 Double_t y =
GetYandError(i, cmn, stat, quad,
false, eyl, eyh);
1530 Double_t eym = (eyh+eyl)/2;
1531 Double_t x =
GetX(i);
1534 Double_t x1 = x - exl;
1535 Double_t x2 = x + exr;
1540 if (prv > x1) x1 -= (prv-x1)/2;
1541 if (nxt < x2) x2 -= (x2-nxt)/2;
1542 Double_t wdt = (x2-x1);
1543 if (wdt < 0)
continue;
1545 err2 += TMath::Power(eym*wdt,2);
1547 error = TMath::Sqrt(err2);
1578 if (!denom->
FindYandError(x,
false,
true,
true,
false, dY, dEyl, dEyh))
1580 if (TMath::Abs(dY) < 1e-9)
1583 nY = num->
GetYandError(i,
false,
true,
true,
false,nEyl, nEyh);
1610 Bool_t emax = (flags &
kMax);
1611 Bool_t cmin = (flags &
kMin);
1612 Bool_t cmax = (flags &
kMax);
1614 Bool_t cancc = (flags &
kCancel);
1631 while ((comN = static_cast<HolderCommon*>(nextNC()))) {
1634 Double_t eyh = comN->
GetYUp(1);
1635 Int_t idD = den->
FindId(comN->GetTitle());
1643 Double_t dEyh = comD->
GetYUp(1);
1645 Double_t nEyh = comN->
GetYUp(1);
1647 eyl = TMath::Min(nEyl, dEyl);
1648 eyh = TMath::Min(nEyh, dEyh);
1651 eyl = TMath::Max(nEyl, dEyl);
1652 eyh = TMath::Max(nEyh, dEyh);
1655 eyl = TMath::Sqrt(TMath::Abs(dEyl*dEyl-nEyl*nEyl));
1656 eyh = TMath::Sqrt(TMath::Abs(dEyh*dEyh-nEyh*nEyh));
1658 const char* post = (rel ?
"%" :
"");
1659 Double_t pfc = (rel ? 100 : 1);
1662 ::Info(
"Ratio",
"Cancelling the common systematic error %s " 1663 "between numerator (-%f%s +%f%s) " 1664 "and denominator (-%f%s +%f%s): -%f%s + %f%s",
1666 pfc*nEyl, post, pfc*nEyh, post,
1667 pfc*dEyl, post, pfc*dEyh, post,
1668 pfc*eyl, post, pfc*eyh, post);
1677 "Common numerator systematic %s will be added to blob",
1696 while ((comD = static_cast<HolderCommon*>(nextDC()))) {
1697 if (comD->TestBit(
kUsedBit))
continue;
1701 "Common denominator systematic %s will be added to blob",
1707 ::Info(
"Ratio",
"Propagating common sysmatic %s to ratio",
1746 while ((p2pN = static_cast<HolderP2P*>(nextNP()))) {
1748 Int_t idD = den->
FindId(p2pN->GetTitle());
1750 Bool_t same = !p2pD ?
false : rel == p2pD->
IsRelative();
1760 mask = ((p2pD->GetUniqueID() & 0xFF) << 16);
1766 ::Info(
"Ratio",
"Cancelling the p2p systamtic error %s " 1767 "between numerator and denominator",
1778 mask |= (((p2pN->GetUniqueID() & 0xFF) << 8) |
1783 shared[sCnt] = mask;
1791 while ((p2pD = static_cast<HolderP2P*>(nextDP()))) {
1802 Int_t mask = (((p2pD->GetUniqueID() & 0xFF) << 16) |
1806 shared[sCnt] = mask;
1820 for (Int_t i = 0; i < num->
GetN(); i++) {
1821 Double_t x = num->
GetX(i);
1822 Double_t nY = num->
GetY(i);
1829 Int_t di = den->
FindPoint(x, di1, di2, fac);
1833 ::Warning(
"Ratio",
"Next point %d (%f) not found in denominator",
1838 Bool_t stat =
false;
1840 Bool_t nosqrt =
false;
1844 dY = den->
GetYandError(di,cmn,stat,quad,nosqrt,dEyl,dEyh);
1848 Double_t eyl1, eyl2, eyh1, eyh2;
1849 Double_t x1 = den->
GetX(di1);
1850 Double_t x2 = den->
GetX(di2);
1851 Double_t y1 = den->
GetYandError(di1,cmn,stat,quad,nosqrt,eyl1,eyh1);
1852 Double_t y2 = den->
GetYandError(di2,cmn,stat,quad,nosqrt,eyl2,eyh2);
1854 Double_t dx = (x2-x1);
1856 dY = y1 + daX * (y2 - y1);
1857 dEyl = eyl1 + daX * (eyl2 - eyl1);
1858 dEyh = eyh1 + daX * (eyh2 - eyh1);
1866 Double_t rY = (dY != 0 ? nY/dY : 0);
1874 if (TMath::Abs(rY) > 1.e-9) {
1882 sEyl = TMath::Sqrt(rY*rY*(snEyl*snEyl/nY/nY+sdEyl*sdEyl/dY/dY));
1883 sEyh = TMath::Sqrt(rY*rY*(snEyh*snEyh/nY/nY+sdEyh*sdEyh/dY/dY));
1890 Double_t eyl = 0, eyh = 0;
1894 Double_t rdEyl = (dY != 0 ? dEyl/dY : 0);
1895 Double_t rdEyh = (dY != 0 ? dEyh/dY : 0);
1902 eyl = TMath::Max(nEyl, dEyl);
1903 eyh = TMath::Max(nEyh, dEyh);
1910 eyl = TMath::Min(nEyl, dEyl);
1911 eyh = TMath::Min(nEyh, dEyh);
1917 Double_t rnEyl = (nY != 0 ? nEyl/nY : 0);
1918 Double_t rnEyh = (nY != 0 ? nEyh/nY : 0);
1919 Double_t rdEyl = (dY != 0 ? dEyl/dY : 0);
1920 Double_t rdEyh = (dY != 0 ? dEyh/dY : 0);
1921 Double_t reyl = TMath::Sqrt(rnEyl*rnEyl+rdEyl*rdEyl);
1922 Double_t reyh = TMath::Sqrt(rnEyh*rnEyh+rdEyh*rdEyh);
1940 for (Int_t im = 0; im < shared.GetSize(); im++) {
1941 Int_t mask = shared[im];
1942 if (mask <= 0)
break;
1943 Int_t rId = ((mask >> 0) & 0xFF);
1944 Int_t nId = ((mask >> 8) & 0xFF);
1945 Int_t dId = ((mask >> 16) & 0xFF);
1946 if (nId == 0 && dId == 0) {
1947 ::Warning(
"Ratio",
"Both numerator and denominator IDs are 0");
1958 Double_t lfc = (crel ? (TMath::Abs(dY) > 1e-9 ? 1/dY : 0) : 1);
1959 pdEyl = pD->
GetYDown(di1, di2, daX) * lfc;
1960 pdEyh = pD->
GetYUp (di1, di2, daX) * lfc;
1964 Double_t lfc = (crel ? (TMath::Abs(nY) > 1e-9 ? 1/nY : 0) : 1);
1966 pnEyh = pN->
GetYUp (i) * lfc;
1972 Double_t lfc = (!crel ? (TMath::Abs(dY) > 1e-9 ? 1/dY : 0) : 1);
1978 else if (dId == 0) {
1991 peyl = TMath::Min(nEyl, dEyl) * lfc;
1992 peyh = TMath::Min(nEyh, dEyh) * lfc;
1995 peyl = TMath::Min(nEyl, dEyl) * lfc;
1996 peyh = TMath::Min(nEyh, dEyh) * lfc;
1999 peyl = TMath::Sqrt(TMath::Abs(pnEyl*pnEyl-pdEyl*pdEyl)) * lfc;
2000 peyh = TMath::Sqrt(TMath::Abs(pnEyh*pnEyh-pdEyh*pdEyh)) * lfc;
2006 lfc = (rel ? 1 : rY);
2007 ret->
SetSysError(rId, cnt, 0, 0, lfc*peyl, lfc*peyh);
2019 ::Warning(
"",
"No common points found");
2035 while ((oe = nextC())) {
2040 while ((oe = nextP())) {
2080 Int_t cnt =
CacheGraphs(g1, g2, a1y, a2y, a1e2, a2e2);
2081 if (cnt <= 0)
return -1;
2083 Double_t s1 = a1y.GetSum();
2084 Double_t s2 = a2y.GetSum();
2085 Double_t sw1 = a1e2.GetSum();
2086 Double_t sw2 = a2e2.GetSum();
2087 if (a1e2.GetSum() <= 0 && a2e2.GetSum()) {
2088 ::Warning(
"ChisquareTest",
"No errors");
2095 for (Int_t i = 0; i < cnt; i++) {
2099 dfMax = TMath::Max(dfMax, TMath::Abs(sr1-sr2));
2102 Double_t se1 = s1 * s1 / sw1;
2103 Double_t se2 = s2 * s2 / sw2;
2104 z = dfMax * TMath::Sqrt(se1 * se2 / (se1 + se2));
2105 return TMath::KolmogorovProb(z);
2129 Int_t n = g1->
GetN();
2134 for (Int_t i = 0; i < g1->
GetN(); i++) {
2142 if (!
NextPoint(i, g1, g2, x, y1, e1yl, e1yh, y2, e2yl, e2yh)) {
2143 ::Warning(
"ChisquareTest",
"Next point - %d %f not found", i, x);
2147 Double_t e1y2 = TMath::Power(TMath::Max(e1yl,e1yh), 2);
2148 Double_t e2y2 = TMath::Power(TMath::Max(e2yl,e2yh), 2);
2158 ::Warning(
"CacheGraphs",
"No common points found");
2205 Int_t cnt =
CacheGraphs(g1, g2, a1y, a2y, a1e2, a2e2);
2206 if (cnt <= 0)
return -1;
2208 Double_t s1 = a1y.GetSum();
2209 Double_t s2 = a2y.GetSum();
2210 if (type ==
kModelModel && (a1e2.GetSum() <= 0 && a2e2.GetSum())) {
2211 ::Warning(
"ChisquareTest",
"No errors");
2218 Double_t s = s1 + s2;
2219 for (Int_t i = 0; i < ndf; i++) {
2222 Double_t sum = a1y[i]+a2y[i];
2223 Double_t delta = s2 * a1y[i] - s1 * a2y[i];
2224 chi2 += delta * delta / sum;
2228 Double_t v1 = s2 * a1y[i] - s1 * a2e2[i];
2229 Double_t v2 = v1 * v1 + 4 * s2 * s2 * a1y[i] * a2e2[i];
2230 Double_t pp = (v1 + v2) / (2 * s2 * s2);
2231 Double_t p1 = pp * s1;
2232 Double_t p2 = pp * s2;
2233 Double_t d1 = a1y[i] - p1;
2234 Double_t d2 = a1y[i] - p2;
2235 chi2 += d1 * d1 / p1;
2236 if (a2e2[i] > 0) chi2 += d2 * d2 / a2e2[i];
2240 Double_t sigma = s1 * s1 * a2e2[i] + s2 * s2 * a1e2[i];
2241 Double_t delta = s2 * a1y[i] - s1 * a2y[i];
2242 chi2 += delta * delta / sigma;
2246 Double_t delta = a2y[i] - a1y[i];
2247 chi2 += delta * delta / a1e2[i];
2251 ::Warning(
"ChisquareTest",
"Should not happen");
2269 if (i < 0 || i >=
GetN())
return;
2270 fData->RemovePoint(i);
2273 while ((p2p = static_cast<HolderP2P*>(next()))) {
2274 p2p->
fGraph->RemovePoint(i);
2286 if (i == j && !reflect)
return;
2290 while ((p2p = static_cast<HolderP2P*>(next()))) {
2304 for (Int_t i = 0; i <
GetN()/2; i++) {
2326 while ((cmn = static_cast<HolderCommon*>(cNext()))) {
2327 Int_t oId = cpy->
FindId(cmn->GetTitle());
2331 Error(
"Symmetrice",
"Common error %s not found in %s",
2332 cmn->GetTitle(), cpy->GetName());
2343 if (cmn->
fEyl <= 0 && cmn->
fEyh <= 0) {
2350 if (!cpy)
return false;
2354 Int_t n = other->
GetN();
2358 for (Int_t i = 0; i < n; i++) {
2359 if (used[i] >= 0 && used[i] != i) {
2372 Double_t eyl1, eyh1;
2377 Double_t y1 = cpy->
GetYandError(i,
true,
false,
true,
false,eyl1,eyh1);
2378 Double_t x1 = cpy->
GetX(i);
2400 y2 = cpy->
GetYandError(j,
true,
false,
true,
false,eyl2,eyh2);
2410 cpy->
FindYandError(-x1,
true,
true,
true,
false,y2,eyl2,eyh2,seyl2,seyh2);
2413 Double_t newY = (y1+y2) / 2;
2415 if ((eyh1+eyl1) > 1e-9 && (eyh2+eyl2) > 1e-9) {
2416 Double_t s1 = 2 * eyl1 * eyh1 / (eyh1 + eyl1);
2417 Double_t sp1 = (eyh1 - eyl1) / (eyh1 + eyl1);
2418 Double_t w1 = .5 * TMath::Power(s1+y1*sp1, 3) / s1;
2419 Double_t s2 = 2 * eyl2 * eyh2 / (eyh2 + eyl2);
2420 Double_t sp2 = (eyh2 - eyl2) / (eyh2 + eyl2);
2421 Double_t w2 = .5 * TMath::Power(s2+y2*sp2, 3) / s2;
2424 Double_t sumW = (w1+w2);
2425 newY = (y1*w1+y2*w2) / sumW;
2426 newV = TMath::Sqrt((w1*w1*s1*s1+w2*w2*s2*s2) / sumW / sumW);
2429 Double_t seyl = TMath::Sqrt(seyl1*seyl1+seyl2*seyl2);
2430 Double_t seyh = TMath::Sqrt(seyh1*seyh1+seyh2*seyh2);
2452 TString opt(option);
2454 Bool_t load = opt.Contains(
"load"); opt.ReplaceAll(
"load",
"");
2456 TPRegexp regex(
"func=([a-zA-z][a-zA-Z0-9_]*)");
2457 TObjArray* toks = regex.MatchS(opt);
2459 if (toks->GetEntriesFast() > 1)
2460 funcName = toks->At(1)->GetName();
2461 if (toks->GetEntriesFast() > 0)
2462 opt.ReplaceAll(toks->At(0)->GetName(),
"");
2468 if (!funcName.IsNull())
2469 out <<
"TObject* " << funcName <<
"(Option_t* o=\"\")\n";
2472 out <<
" // Load class\n" 2473 <<
" if (!gROOT->GetClass(\"GraphSysErr\"))\n" 2474 <<
" gROOT->LoadMacro(\"GraphSysErr.C+\");\n";
2475 out <<
" GraphSysErr* g = new GraphSysErr(\"" 2476 << GetName() <<
"\",\"" << GetTitle() <<
"\"," 2477 <<
GetN() <<
");\n";
2479 out <<
" // Point options\n" 2480 <<
" g->SetMarkerStyle(" << GetMarkerStyle() <<
");\n" 2481 <<
" g->SetMarkerColor(" << GetMarkerColor() <<
");\n" 2482 <<
" g->SetMarkerSize(" << GetMarkerSize() <<
");\n" 2483 <<
" g->SetLineStyle(" << GetLineStyle() <<
");\n" 2484 <<
" g->SetLineColor(" << GetLineColor() <<
");\n" 2485 <<
" g->SetLineWidth(" << GetLineWidth() <<
");\n" 2486 <<
" g->SetFillStyle(" << GetFillStyle() <<
");\n" 2487 <<
" g->SetFillColor(" << GetFillColor() <<
");\n" 2488 <<
" g->SetXTitle(\"" <<
fXTitle <<
"\");\n" 2489 <<
" g->SetYTitle(\"" <<
fYTitle <<
"\");\n" 2491 <<
" // Sum options\n" 2492 <<
" g->SetSumOption(" <<
fSumOption <<
");\n" 2493 <<
" g->SetSumTitle(\"" <<
fSumTitle <<
"\");\n" 2494 <<
" g->SetSumLineStyle(" <<
fSumLine.GetLineStyle() <<
");\n" 2495 <<
" g->SetSumLineColor(" <<
fSumLine.GetLineColor() <<
");\n" 2496 <<
" g->SetSumLineWidth(" <<
fSumLine.GetLineWidth() <<
");\n" 2497 <<
" g->SetSumFillStyle(" <<
fSumFill.GetFillStyle() <<
");\n" 2498 <<
" g->SetSumFillColor(" <<
fSumFill.GetFillColor() <<
");\n" 2501 <<
" g->SetCommonSumLineStyle(" <<
fCommonSumLine.GetLineStyle()<<
");\n" 2502 <<
" g->SetCommonSumLineColor(" <<
fCommonSumLine.GetLineColor()<<
");\n" 2503 <<
" g->SetCommonSumLineWidth(" <<
fCommonSumLine.GetLineWidth()<<
");\n" 2504 <<
" g->SetCommonSumFillStyle(" <<
fCommonSumFill.GetFillStyle()<<
");\n" 2505 <<
" g->SetCommonSumFillColor(" <<
fCommonSumFill.GetFillColor()<<
");\n" 2506 <<
" // Stat options\n" 2510 while ((cmn = static_cast<HolderCommon*>(nextC())))
2514 while ((p2p = static_cast<HolderP2P*>(nextP())))
2517 out <<
" // " << n <<
" points\n";
2519 for (Int_t i = 0; i < n; i++) {
2520 Double_t y =
GetY(i);
2521 out <<
" g->SetPoint(" << i <<
',' <<
GetX(i) <<
',' << y <<
");\n" 2522 <<
" g->SetPointError(" << i <<
',' <<
GetErrorXLeft(i) <<
',' 2524 <<
" g->SetStatError(" << i <<
',' 2528 while ((p2p = static_cast<HolderP2P*>(nextP()))) {
2529 Int_t
id = p2p->GetUniqueID();
2531 out <<
" g->SetSysError(" <<
id <<
',' << i <<
',' 2538 out <<
" if (o && o[0] != '\\0') {\n" 2539 <<
" g->Draw(o);\n";
2541 out <<
" if (g->GetMulti() && g->GetMulti()->GetHistogram()) {\n" 2542 <<
" g->GetMulti()->GetHistogram()->SetMinimum(" 2543 <<
fDrawn->GetHistogram()->GetMinimum() <<
");\n" 2544 <<
" g->GetMulti()->GetHistogram()->SetMaximum(" 2545 <<
fDrawn->GetHistogram()->GetMaximum() <<
");" 2549 if (!funcName.IsNull()) out <<
" return g;\n";
2559 std::ofstream out(fileName);
2560 TString funcName(fileName);
2561 funcName.ReplaceAll(
".C",
"");
2563 <<
"// Generated by GraphSysErr.C\n" 2603 Option_t* option=
"",
2607 TString opt(option);
2609 Bool_t header = opt.Contains(
"h");
2610 Bool_t sysNames = opt.Contains(
"s");
2611 Bool_t comment = opt.Contains(
"c");
2612 Bool_t title = opt.Contains(
"t");
2617 Bool_t hasTitle =
false;
2621 while ((q = nextQ())) {
2622 TString k(q->GetName());
2623 if (k.EqualTo(
"RE") || k.EqualTo(
"title", TString::kIgnoreCase))
2625 out <<
FormatKey(
"qual") << q->GetName() <<
" : " 2626 << q->GetTitle() << std::endl;
2629 if (!hasTitle && title)
2630 out <<
FormatKey(
"qual") <<
"RE : " << GetTitle() << std::endl;
2633 const char* fill =
"<please fill in>";
2637 out <<
FormatKey(
"xheader") << xTit <<
"\n" 2638 <<
FormatKey(
"yheader") << yTit << std::endl;
2643 while ((holderCommon = static_cast<HolderCommon*>(nextC()))) {
2645 Double_t up = holderCommon->
GetYUp(rel ? 100 : 1);
2646 Double_t down = holderCommon->
GetYDown(rel ? 100 : 1);
2649 out <<
":" << holderCommon->GetTitle() << std::endl;
2653 out <<
FormatKey(
"data") <<
" x : y" << std::endl;
2655 for (Int_t i = 0; i < n; i++) {
2659 out <<
"*dataend:\n" 2660 <<
"# End of dataset\n" << std::endl;
2670 if (val.IsNull()) {val = fill;
return; }
2671 if (!val.Contains(
"#") && !val.Contains(
"\\"))
return;
2673 if (val[0] !=
'$') val.Prepend(
"$");
2674 if (val[val.Length()-1]!=
'$') val.Append(
"$");
2675 val.ReplaceAll(
"#",
"\\");
2691 static void Export(
const TSeqCollection* col,
2693 Option_t* option=
"H",
2696 if (col->GetEntries() < 1)
return;
2699 TString opt(option);
2701 Bool_t alsoTop = opt.Contains(
"h");
2702 Bool_t alsoCmt = opt.Contains(
"c");
2703 Bool_t alsoNme = opt.Contains(
"s");
2704 Bool_t alsoTit = opt.Contains(
"t");
2707 const Double_t tol = 1e-10;
2718 TIter nextCheck(col);
2720 while ((o = nextCheck())) {
2721 if (!o->IsA()->InheritsFrom(GraphSysErr::Class()))
continue;
2725 nPoints = first->
GetN();
2729 if (gse->
GetN() != nPoints) {
2730 Int_t nTmp = TMath::Min(gse->
GetN(), nPoints);
2731 ::Warning(
"Export",
"Incompatible number of points %d in %s" 2732 "using only %d of them",
2733 gse->
GetN(), gse->GetName(), nTmp);
2738 for (Int_t i = 0; i < nPoints; i++) {
2739 Double_t x1 = first->
GetX(i);
2740 Double_t exl1 = first->
fData->GetErrorXlow(i);
2741 Double_t exh1 = first->
fData->GetErrorXhigh(i);
2742 Double_t xT = gse->
GetX(i);
2743 Double_t exlT = gse->
fData->GetErrorXlow(i);
2744 Double_t exhT = gse->
fData->GetErrorXhigh(i);
2745 if (TMath::Abs(x1-xT) > tol ||
2746 (exl1 > tol && TMath::Abs(exl1-exlT) > tol) ||
2747 (exh1 > tol && TMath::Abs(exh1-exhT) > tol)) {
2748 ::Warning(
"Export",
"X--coordinate of %s @ point %d: %f (+%f,-%f) " 2749 "incompatible [%f (+%f,-%f)]",
2750 gse->GetTitle(), i, xT, exhT, exlT, x1, exh1, exl1);
2762 while ((q = nextQ())) {
2768 TIter nextCmn(&(gse->
fCommon));
2770 while ((oCmn = nextCmn())) {
2771 if (commons.FindObject(oCmn->GetTitle()))
continue;
2772 TObjString* cmn =
new TObjString(oCmn->GetTitle());
2773 if (gse == first) cmn->SetUniqueID(gse->
FindId(oCmn->GetTitle()));
2781 TIter nextCmn(&(commons));
2783 while ((oCmn = nextCmn())) {
2784 TString oNme(oCmn->GetName());
2785 Bool_t found =
true;
2790 TIter nextG(&toExport);
2791 while ((gse = static_cast<GraphSysErr*>(nextG()))) {
2793 Int_t gseId = first->
FindId(oNme);
2807 if ((ecl1 > tol && TMath::Abs(ecl1-eclT) > tol) ||
2808 (ech1 > tol && TMath::Abs(ech1-echT) > tol)) {
2817 #if INCOMPAT_CMN_AS_QUAL 2821 oCmn->SetBit(BIT(14), found);
2825 if (found)
continue;
2830 while ((gse = static_cast<GraphSysErr*>(nextG()))) {
2831 Int_t gseId = first->
FindId(oNme);
2838 std::stringstream s;
2840 val = s.str().c_str();
2854 ::Error(
"Export",
"No points to write");
2857 if (toExport.GetEntries() <= 0) {
2858 ::Error(
"Export",
"No graphs to export");
2862 ::Error(
"Export",
"Didn't get the first graph");
2871 Bool_t hasTitle =
false;
2872 TIter nextQ(&quals);
2874 while ((ql = static_cast<TList*>(nextQ()))) {
2875 TString k(ql->GetName());
2876 if (k.EqualTo(
"RE") || k.EqualTo(
"title", TString::kIgnoreCase))
2878 out <<
FormatKey(
"qual") << ql->GetName();
2879 for (Int_t i = 0; i < toExport.GetEntries(); i++) {
2880 TObject* qv = ql->At(i);
2882 if (qv) v = qv->GetName();
2887 if (!hasTitle && alsoTit) {
2889 for (Int_t i = 0; i < toExport.GetEntries(); i++)
2890 out <<
": " << toExport.At(i)->GetTitle();
2896 const char* fill =
"<please fill in>";
2897 const char* fields[] = {
"xheader",
"yheader", 0 };
2898 const char** pfld = fields;
2901 TIter nextSpec(&toExport);
2903 while ((gse = static_cast<GraphSysErr*>(nextSpec()))) {
2905 if ((*pfld)[0] ==
'x') val = gse->
fXTitle;
2906 else if ((*pfld)[0] ==
'y') val = gse->
fYTitle;
2908 out << (one ?
"" :
":") << val;
2909 if ((*pfld)[0] ==
'x')
break;
2917 TIter nextC(&commons);
2918 while ((oCmn = nextC())) {
2919 TString tit(oCmn->GetName());
2922 #if INCOMPAT_CMN_AS_QUAL 2923 if (!oCmn->TestBit(BIT(14))) {
2925 "Common systematic error \"%s\" represented by qual",
2927 out <<
"- : " << tit << std::endl;
2930 UInt_t
id = first->
FindId(oCmn->GetName());
2935 out <<
" : "<< tit << std::endl;
2937 out << tit << std::flush;
2938 TIter next(&toExport);
2939 while ((gse = static_cast<GraphSysErr*>(next()))) {
2940 UInt_t
id = gse->
FindId(oCmn->GetName());
2947 out <<
":" << tit << std::endl;
2952 out <<
FormatKey(
"data") << data << std::endl;
2953 for (Int_t i = 0; i < nPoints; i++) {
2954 TIter next(&toExport);
2956 while ((gse = static_cast<GraphSysErr*>(next()))) {
2962 out <<
"*dataend:\n" 2963 <<
"# End of dataset\n" << std::endl;
2983 static TSeqCollection*
Import(
const TString& fileName)
2985 std::ifstream in(fileName.Data());
2987 ::Warning(
"Import",
"Failed to open \"%s\"", fileName.Data());
2990 TList* ret =
new TList;
2997 UShort_t nIdx = 256;
2998 int cur = in.tellg();
3000 in.seekg(cur, in.beg);
3001 if (!(g =
Import(in, sub, &nIdx)))
break;
3003 ::Info(
"Import",
"Imported %d of %d", sub, nIdx);
3004 g->SetName(Form(
"ds_%d_%d",
id, sub-1));
3005 if (!first) first = g;
3009 }
while(sub < nIdx);
3011 }
while (!in.eof());
3038 Bool_t inSet =
false;
3039 Bool_t inData =
false;
3050 tmp = line.Strip(TString::kBoth,
' '); line = tmp;
3051 if (line.IsNull())
continue;
3052 if (line[0] ==
'#')
continue;
3053 if (line[0] ==
'*') {
3054 Int_t colon = line.Index(
":");
3055 if (colon == kNPOS)
continue;
3056 Int_t len = line.Length()-colon-1;
3057 TString value = line(colon+1,len);
3058 tmp = value.Strip(TString::kBoth,
' '); value = tmp;
3059 last = line(1,colon-1);
3061 ::Info(
"Import",
"Got a key '%s' -> '%s'", last.Data(), value.Data());
3063 if (last.BeginsWith(
"dataset", TString::kIgnoreCase)) {
3068 else if (last.BeginsWith(
"dataend", TString::kIgnoreCase)) {
3077 else if (last.BeginsWith(
"qual", TString::kIgnoreCase)) {
3081 quals.Add(
new TObjString(value));
3083 else if (last.BeginsWith(
"xheader", TString::kIgnoreCase))
3085 else if (last.BeginsWith(
"yheader", TString::kIgnoreCase))
3087 else if (last.BeginsWith(
"dserror", TString::kIgnoreCase)) {
3090 ::Info(
"Import",
"Got common error line: '%s'", line.Data());
3091 TObjArray* tokens = value.Tokenize(
":");
3092 Double_t el = 0, eh = 0;
3095 if (rel) { el /= 100.; eh /= 100.; }
3096 TString& tnam =
Token(tokens, 1);
3097 TString nam = tnam.Strip(TString::kBoth,
' ');
3106 else if (last.BeginsWith(
"data", TString::kIgnoreCase)) {
3108 ::Info(
"Import",
"Got start of data line: '%s'", line.Data());
3111 TObjArray* tokens = value.Tokenize(
":");
3113 *nIdx = tokens->GetEntriesFast();
3116 if (tokens->GetEntriesFast() > 2 && idx < 1) {
3118 ::Warning(
"Import",
"Can only import one data set at a time, " 3119 "selecting the %d column", idx);
3121 else if (idx >= 1 && idx >= tokens->GetEntriesFast()) {
3122 ::Warning(
"Import",
"column %d not available for this data set",
3133 ::Info(
"Import",
"Got pair line '%s' (%s -> %s)", line.Data(),
3134 last.Data(), value.Data());
3135 keys.Add(
new TNamed(last, value));
3141 ::Info(
"Import",
"Got a possible contiuation line '%s'", line.Data());
3148 ::Info(
"Import",
"Got some other line: '%s'", line.Data());
3150 TNamed* ptr =
static_cast<TNamed*
>(keys.FindObject(last));
3155 TString tt(ptr->GetTitle());
3156 if (!tt.EndsWith(
" ") && !tt.EndsWith(
"\t") && !tt.EndsWith(
"\n"))
3170 if (idx < 1) idx = 1;
3173 ::Info(
"Import",
"Got a data line: '%s'", line.Data());
3174 TObjArray* tokens = line.Tokenize(
";");
3175 if (tokens->GetEntriesFast() < idx+1) {
3176 ::Warning(
"Import",
"Too few columns %d<%0d in line: %s",
3177 tokens->GetEntriesFast(), idx+1, line.Data());
3181 TString& xCol =
static_cast<TObjString*
>(tokens->At(0))->String();
3182 TString& yCol =
static_cast<TObjString*
>(tokens->At(idx))->String();
3184 ::Info(
"Import",
"xColumn: '%s', yColumn: '%s'",
3185 xCol.Data(), yCol.Data());
3187 tmp = xCol.Strip(TString::kBoth,
' '); xCol = tmp;
3188 tmp = yCol.Strip(TString::kBoth,
' '); yCol = tmp;
3189 TString yFull = yCol;
3191 Int_t chop = yCol.Last(
'(');
3192 if (chop != kNPOS) {
3193 yCol.Remove(chop, yCol.Length()-chop);
3194 yCol.Remove(TString::kBoth,
' ');
3197 ::Info(
"Import",
"xColumn: '%s', yColumn: '%s'",
3198 xCol.Data(), yCol.Data());
3200 if (xCol.IsNull()) {
3201 ::Warning(
"Import",
"Empty X column in line: %s", line.Data());
3205 if (yCol.IsNull()) {
3206 ::Warning(
"Import",
"Empty Y column in line: %s", line.Data());
3211 Double_t x = 0, exl = 0, exh = 0;
3213 ::Warning(
"Import",
"Failed to import X value in line: %s",line.Data());
3217 Double_t y = 0, eyl = 0, eyh = 0;
3219 ::Warning(
"Import",
"Failed to import X value in line: %s",line.Data());
3231 Int_t lparen = yFull.Index(
"(");
3232 Int_t rparen = yFull.Index(
")");
3233 if (lparen == rparen) {
3237 TString rem = yFull(lparen+1, rparen-lparen-1);
3239 ::Info(
"Import",
"Got systematic errors: '%s'", rem.Data());
3241 TObjArray* stok = rem.Tokenize(
"D");
3243 for (Int_t i = 0; i < stok->GetEntriesFast(); i++) {
3244 TString t =
Token(stok,i);
3245 if (!t.BeginsWith(
"SYS=",TString::kIgnoreCase)) {
3246 ::Warning(
"Import",
"Ignoring unknown spec %s (@ %d) in %s",
3247 t.Data(), i, rem.Data());
3251 if (t[t.Length()-1] ==
',') t.Remove(t.Length()-1,1);
3252 tmp = t.Strip(TString::kBoth,
' '); t = tmp;
3254 Double_t el = 0, eh = 0;
3258 Int_t colon = t.Index(
":");
3259 TString nam(Form(
"sys%d", isys));
3260 if (colon != kNPOS) nam = t(colon+1, t.Length()-colon-1);
3262 UInt_t
id = ret->
FindId(nam);
3271 if (p->
IsRelative()) { el /= 100.; eh /= 100.; }
3278 }
while (!in.eof());
3282 if (!rxtit.IsNull()) ret->
SetXTitle(rxtit);
3283 if (!rytit.IsNull()) ret->
SetYTitle(rytit);
3285 Bool_t hasTitle =
false;
3286 TIter nextQ(&quals);
3288 while ((qual = nextQ())) {
3298 k.EqualTo(
"title", TString::kIgnoreCase))) {
3305 while ((pair = nextK())) {
3306 ret->
SetKey(pair->GetName(),pair->GetTitle());
3307 TString k = pair->GetName();
3308 if (!hasTitle && (k.EqualTo(
"location"))) {
3313 if (!hasTitle) ret->
SetTitle(
"Title");
3357 Double_t eyl, Double_t eyh,
3361 TString name(Form(
"common_%08x",
id));
3387 TString name(Form(
"p2p_%08x",
id));
3420 while ((holder = static_cast<Holder*>(nextC()))) {
3421 if (tit.EqualTo(holder->GetTitle()))
return holder->GetUniqueID();
3425 while ((holder = static_cast<Holder*>(nextP()))) {
3426 if (tit.EqualTo(holder->GetTitle()))
return holder->GetUniqueID();
3450 fData->SetPoint(i, x, y);
3472 fData->SetPointError(i, exl, exh,
3473 fData->GetErrorYlow(i),
3474 fData->GetErrorYhigh(i));
3510 eyl *=
fData->GetY()[i];
3511 eyh *=
fData->GetY()[i];
3513 fData->SetPointError(i,
3514 fData->GetErrorXlow(i),
3515 fData->GetErrorXhigh(i),
3549 Double_t eyl, Double_t eyh)
3553 h->
Set(i,
fData, exl, exh, eyl, eyh);
3568 TNamed::SetTitle(name);
3623 Double_t
GetY(Int_t point)
const {
return fData->GetY()[point]; }
3637 return fData->GetErrorYhigh(point);
3646 return fData->GetErrorYlow(point);
3678 return h->
GetX(point);
3690 return h->
GetY(point);
3725 if (h)
return h->
GetYUp(point);
3755 return h->GetTitle();
3768 return h->GetFillStyle();
3781 return h->GetLineStyle();
3794 return h->GetFillColor();
3807 return h->GetLineColor();
3820 return h->GetLineWidth();
3942 return c->
GetYUp(rel ? 100 : 1);
3976 Double_t& ymin, Double_t& ymax)
const 3978 Double_t xmin, xmax;
3980 GetMinMax(option, ymin, ymax, xmin, xmax, imin, imax);
3994 Double_t& ymin, Double_t& ymax,
3995 Double_t& xmin, Double_t& xmax,
3996 Int_t& imin, Int_t& imax)
const 3998 TString opt(option); opt.ToUpper();
3999 Bool_t cmn = opt.Contains(
"COMMON");
4000 Bool_t stat = opt.Contains(
"STAT");
4001 Bool_t quad = opt.Contains(
"QUAD");
4002 Bool_t noerr = opt.Contains(
"Y");
4003 quad = !opt.Contains(
"DIRECT");
4011 for (Int_t i = 0; i <
GetN(); i++) {
4014 Double_t y = noerr ?
GetY(i) :
GetYandError(i, cmn, stat, quad,
false, eyl, eyh);
4015 Double_t yl = y - eyl;
4016 Double_t yh = y + eyh;
4045 Bool_t cmn, Bool_t stat, Bool_t quad,
4046 Int_t& i1, Int_t& i2)
const 4048 Int_t lim = (dir < 0) ? -1 :
GetN();
4050 for (Int_t i = start+dir; i != lim; i += dir) {
4052 Double_t y =
GetYandError(i, cmn, stat, quad,
false, eyl, eyh);
4056 if (y-eyl > ymax/2)
continue;
4057 if (y+eyh < ymax/2)
break;
4058 if (i1 < 0) i1 = i2 = i;
4071 Double_t
FWHM(Double_t& el, Double_t& eh)
const 4074 return FWHM(el, eh, xl, xh);
4086 Double_t
FWHM(Double_t& el, Double_t& eh, Double_t& xl, Double_t& xh)
const 4088 Double_t ymin, ymax, xmin, xmax;
4090 GetMinMax(
"quad stat", ymin, ymax, xmin, xmax, imin, imax);
4091 if (ymin > ymax/2) {
4092 Warning(
"FWHM",
"Half of ymax=%f is out of reach [%f,%f]",
4093 ymax/2, ymin, ymax);
4098 Int_t li1, li2, ri1, ri2;
4100 FindFwhm(imax, -1, ymax,
false,
true,
true, li1, li2);
4102 FindFwhm(imax, +1, ymax,
false,
true,
true, ri1, ri2);
4106 if (li1 < 0 && li2 < 0) {
4108 if (ri1 < 0 && ri2 < 0) {
4109 Warning(
"FWHM",
"No left and right point found");
4119 if (ri1 < 0 && ri2 < 0) {
4121 if (li1 < 0 && li2 < 0) {
4122 Warning(
"FWHM",
"No right and left point found");
4151 if (el < 1e-9 && eh < 1e-9) {
4164 Double_t fwhm = (xh - xl);
4187 Bool_t quad=
true)
const 4189 Double_t meanX=TMath::Infinity(), stdDev, n;
4211 Bool_t quad=
true)
const 4214 return MeanX(error, cmn, stat, quad);
4235 Bool_t quad=
true)
const 4237 Double_t meanX=TMath::Infinity(), stdDev, eStdDev, n;
4239 error = stdDev/TMath::Sqrt(2)/n;
4259 Bool_t quad=
true)
const 4268 Bool_t quad=
true)
const 4270 Double_t meanX, stdDev, eStdDev, n;
4272 Double_t sd2 = stdDev*stdDev - meanX*meanX;
4273 stdDev = TMath::Sqrt(sd2 - mean*mean);
4274 error = stdDev/TMath::Sqrt(2)/n;
4313 Bool_t quad=
true)
const 4317 Double_t sumXXY = 0;
4319 for (Int_t i = 0; i <
GetN(); i++) {
4320 Double_t e2yl, e2yh;
4321 Double_t x =
GetX(i);
4322 Double_t y =
GetYandError(i,cmn,stat,quad,
true,e2yl,e2yh);
4327 sumE2 += TMath::Max(e2yl,e2yh);
4329 if (meanX == TMath::Infinity())
4331 Double_t sd2 = TMath::Abs(sumXXY/sumY-meanX*meanX);
4332 stdDevX = TMath::Sqrt(sd2);
4333 Double_t eff = sumE2 > 0 ? sumY*sumY/sumE2 : sumY;
4334 n = TMath::Sqrt(eff);
4353 h->SetLineColor(color);
4365 h->SetLineStyle(style);
4377 h->SetLineWidth(width);
4389 h->SetFillColor(color);
4401 h->SetFillStyle(style);
4577 void SetKey(
const char* key,
const char* value, Bool_t replace=
false)
4582 fMap->SetName(
"keys");
4587 TString t = v.Strip(TString::kBoth);
4589 if (k.EqualTo(
"experiment",TString::kIgnoreCase)) {
4590 TObjArray* l = v.Tokenize(
"-");
4591 t =
Token(l, 0); TString lab = t.Strip(TString::kBoth);
4592 t =
Token(l, 1); TString acc = t.Strip(TString::kBoth);
4593 t =
Token(l, 2); TString exp = t.Strip(TString::kBoth);
4594 SetKey(
"laboratory", lab.Data(), replace);
4595 SetKey(
"accelerator", acc.Data(), replace);
4596 SetKey(
"detector", exp.Data(), replace);
4599 if (k.EqualTo(
"comment", TString::kIgnoreCase)) {
4600 TString l(
GetKey(
"laboratory"));
4601 TString a(
GetKey(
"accelerator"));
4602 if (!l.IsNull() && !a.IsNull())
4603 v.Remove(0, l.Length()+1+a.Length()+1);
4604 t = v.Strip(TString::kBoth);
4605 fMap->Add(
new TNamed(
"abstract", t.Data()));
4609 TObjLink* cur =
fMap->FirstLink();
4610 TObjLink* last =
fMap->LastLink();
4612 if (!k.EqualTo(cur->GetObject()->GetName())) {
4616 TObjLink* tmp = cur->Next();
4621 fMap->Add(
new TNamed(k, v));
4633 if (!
fMap)
return 0;
4634 TObject* o =
fMap->FindObject(key);
4636 return o->GetTitle();
4655 TString opt(option);
4658 Bool_t all = opt.Contains(
"a");
4659 Bool_t file = opt.Contains(
"f");
4660 Bool_t header = opt.Contains(
"h");
4661 Bool_t qual = opt.Contains(
"q");
4662 Bool_t repl = opt.Contains(
"r");
4665 TList* map = g->
fMap;
4668 while ((kv = nextKV())) {
4670 TString key = kv->GetName();
4671 if (file && !(key.EqualTo(
"reference") ||
4672 key.EqualTo(
"laboratory") ||
4673 key.EqualTo(
"accelerator")||
4674 key.EqualTo(
"detector") ||
4675 key.EqualTo(
"abstract") ||
4676 key.EqualTo(
"author") ||
4677 key.EqualTo(
"doi") ||
4678 key.EqualTo(
"inspireId") ||
4679 key.EqualTo(
"cdsId") ||
4680 key.EqualTo(
"durhamId") ||
4681 key.EqualTo(
"title") ||
4682 key.EqualTo(
"status")))
continue;
4683 if (header && !(key.EqualTo(
"location") ||
4684 key.EqualTo(
"reackey") ||
4685 key.EqualTo(
"obskey") ||
4686 key.EqualTo(
"dscomment")))
continue;
4688 SetKey(kv->GetName(), kv->GetTitle(), repl);
4691 if (!all && !qual)
return;
4695 while ((qv = nextQ())) {
4697 if (!test || test[0] ==
'\0')
4704 SetMarkerColor(f->GetMarkerColor());
4705 SetMarkerStyle(f->GetMarkerStyle());
4706 SetMarkerSize(f->GetMarkerSize());
4707 SetLineColor(f->GetLineColor());
4708 SetLineStyle(f->GetLineStyle());
4709 SetLineWidth(f->GetLineWidth());
4710 SetFillColor(f->GetFillColor());
4711 SetFillStyle(f->GetFillStyle());
4750 Bool_t replace=
false)
4758 if (key.EqualTo(value)) val =
"";
4760 TString k = key.Strip(TString::kBoth,
' ');
4763 Warning(
"AddQualifier",
"Dataset already has qualifier \"%s\"",
4765 if (replace)
static_cast<TNamed*
>(o)->
SetTitle(value);
4796 return o->GetTitle();
4824 Double_t& seyh)
const 4835 y =
GetYandError(ret, cmn, stat, quad, nosqrt, eyl, eyh);
4844 Double_t eyl1, eyl2, eyh1, eyh2;
4845 Double_t x1 =
fData->GetX()[i1];
4846 Double_t x2 =
fData->GetX()[i2];
4847 Double_t y1 =
GetYandError(i1, cmn, stat, quad, nosqrt, eyl1, eyh1);
4848 Double_t y2 =
GetYandError(i2, cmn, stat, quad, nosqrt, eyl2, eyh2);
4855 Double_t dx = (x2-x1);
4856 Double_t ax = (x-x1)/dx;
4857 y = y1 + ax * (y2 - y1);
4858 eyl = eyl1 + ax * (eyl2 - eyl1);
4859 eyh = eyh1 + ax * (eyh2 - eyh1);
4862 seyl = seyl1 + ax * (seyl2 - seyl1);
4863 seyh = seyh1 + ax * (seyh2 - seyh1);
4888 Double_t& eyh)
const 4892 return FindYandError(x, cmn, stat, quad, nosqrt, y, eyl, eyh, seyl, seyh);
4923 : fX(x), fEl(el), fEh(eh)
4942 if (fEl * fEh == 0)
return 0;
4943 return 2 * fEl * fEh / (fEl +
fEh);
4957 if (TMath::Abs(fEh + fEl) < 1e-9)
return 1;
4958 return (fEh - fEl) / (fEh +
fEl);
4960 Double_t
Svar(Double_t guess=0)
const 4974 Double_t
V()
const {
return fEl *
fEh; }
4991 virtual Double_t
Low()
const {
return fX - 3 *
fEl; }
4997 virtual Double_t
High()
const {
return fX + 3 *
fEh; }
5003 virtual void Print(Option_t* option=
"")
const 5005 Printf(
"%10.8f -%10.8f +%10.8f", fX, fEl, fEh);
5031 Result(Double_t x=0, Double_t el=0, Double_t eh=0,
5032 Double_t chi2=0, Double_t low=0, Double_t high=0)
5043 Double_t
Low()
const {
return fLower; }
5049 Double_t
High()
const {
return fUpper; }
5055 virtual void Print(Option_t* option=
"")
const 5057 Printf(
"%10.8f -%10.8f +%10.8f %5.2f",
fX,
fEl,
fEh, fChi2);
5068 : fData(
"GraphSysErr::Combiner::Observation"), fResult(0)
5107 void Add(Double_t x, Double_t el, Double_t eh)
5112 new (fData[fData.GetEntries()])
Observation(x,el,eh);
5123 while ((r = static_cast<Observation*>(next())))
5175 Double_t var =
VarTerm(guess, r);
5176 if (var <= 0)
return -1000;
5178 return TMath::Power(guess - r.
fX, 2) / var;
5189 Double_t
F(Double_t guess,
5190 Double_t chi2)
const 5192 if (fData.GetEntries() == 1)
return 1;
5197 while ((r = static_cast<Observation*>(next())))
5212 Double_t
E(UShort_t nIter,
5218 if (fData.GetEntries() == 1) {
5220 return (sign < 0 ? o->
fEl : o->
fEh);
5224 Double_t delta = 0.1 * sign * s;
5227 for (UShort_t i = 0; i < nIter; i++) {
5229 Double_t got =
F(best + sign * s, chi2);
5231 if (TMath::Abs(got-1) < 1e-7)
5236 Double_t guess =
F(best + sign * s + delta, chi2);
5239 if ((got - 1) * (guess - 1) > 0) {
5240 if ((got - 1) / (guess - 1) < 1)
5248 s += sign * delta * (1 - got) / (guess - got);
5262 Double_t
X(UShort_t nIter,
5267 if (fData.GetEntries() == 1)
5268 return static_cast<Observation*>(fData[0])->fX;
5269 Double_t x = (highest+lowest)/2;
5270 Double_t oldX = -1e33;
5272 for (UShort_t i = 0; i < nIter; i++) {
5275 Double_t offset = 0;
5280 while ((r = static_cast<Observation*>(next()))) {
5281 Double_t w =
StepW(x, *r);
5286 x = (TMath::Abs(sumw) > 1e-9) ? (sum - offset) / sumw : 0;
5288 if (TMath::Abs(x - oldX) < (highest-lowest) * 1e-9)
break;
5302 Double_t lowest = +1e33;
5303 Double_t highest = -1e33;
5304 Double_t sumLow = 0;
5305 Double_t sumHigh = 0;
5310 while ((r = static_cast<Observation*>(next()))) {
5311 lowest = TMath::Min(r->
Low(), lowest);
5312 highest = TMath::Max(r->
High(), highest);
5313 if (r->
fEl > 1e-10) sumLow += 1./TMath::Power(r->
fEl, 2);
5314 if (r->
fEh > 1e-10) sumHigh += 1./TMath::Power(r->
fEh, 2);
5317 Double_t sLow = sumLow > 1e-10 ? 1. / TMath::Sqrt(sumLow) : 0;
5318 Double_t sHigh = sumHigh > 1e-10 ? 1. / TMath::Sqrt(sumHigh) : 0;
5321 Double_t bestX =
X(nIter, lowest, highest);
5322 Double_t bestChi2 =
F(bestX, 0);
5323 Double_t bestLow = TMath::Abs(
E(nIter,-1,bestX,bestChi2,sLow));
5324 Double_t bestHigh = TMath::Abs(
E(nIter,+1,bestX,bestChi2,sHigh));
5326 fResult =
new Result(bestX, bestLow, bestHigh, bestChi2, lowest, highest);
5347 TF1* f =
new TF1(Form(
"f%02d", j),
Wrapper(), r.
Low(), r.
High(), 3);
5348 f->SetParNames(
"x",
"#sigma^{-}",
"#sigma^{+}");
5349 f->SetParameters(r.
fX, r.
fEl, r.
fEh);
5350 f->SetLineStyle((j%3)+2);
5351 f->SetLineColor(kBlack);
5364 Double_t m = f->GetParameter(0);
5365 TLine* l =
new TLine(m-f->GetParameter(1), 1,
5366 m+f->GetParameter(2), 1);
5367 l->SetLineColor(f->GetLineColor());
5368 l->SetLineStyle(f->GetLineStyle());
5369 l->SetLineWidth(f->GetLineWidth());
5374 if (!fResult)
return;
5376 TList fs; fs.SetOwner(
false);
5380 while ((r = static_cast<Observation*>(next()))) {
5381 TF1* f =
MakeF(*r, j);
5382 f->SetRange(fResult->
Low(), fResult->
High());
5383 fs.Add(f, j == 0 ?
"" :
"same");
5387 TF1* fr =
MakeF(*fResult, j);
5388 fr->SetLineColor(kRed+2);
5389 fr->SetLineStyle(1);
5395 while((o = nextD())) { o->Draw(j == 0 ?
"" :
"same"); j++; }
5397 static_cast<TF1*
>(fs.First())->GetHistogram()
5398 ->GetYaxis()->SetRangeUser(-.1, 5.1);
5425 Double_t w =
StepW(0,r);
5443 Double_t t = r.
Svar(guess);
5444 Double_t ret = s / TMath::Power(t,3);
5471 return TMath::Power(r.
Svar(guess),2);
5495 static Double_t
L(Double_t guess, Double_t x, Double_t el, Double_t eh)
5498 Double_t d = (guess-x);
5499 Double_t t = tmp.
Svar(guess);
5500 if (TMath::Abs(d) < 1e-10)
return 0;
5502 Double_t ret = TMath::Power(d/t, 2);
5513 static Double_t
WrapL(Double_t* xp, Double_t* pp)
5515 return L(xp[0], pp[0], pp[1], pp[2]);
5544 Double_t vp = r.
Vprime();
5545 return TMath::Power(v + r.
fX * vp, 2) / (2 * v + r.
fX * vp);
5562 return v / TMath::Power(v+r.
Vprime()*(guess - r.
fX), 2);
5578 Double_t vp = r.
Vprime();
5579 return 0.5 * vp * TMath::Power((guess-r.
fX)/(r.
V()+vp*(guess-r.
fX)),2);
5596 return r.
V() + r.
Vprime() * (guess - r.
fX);
5617 static Double_t
L(Double_t guess, Double_t x, Double_t el, Double_t eh)
5619 Double_t d = (guess-x);
5620 Double_t v = eh * el;
5621 Double_t vp = eh - el;
5622 return TMath::Power(d,2) / (v+vp*d);
5632 static Double_t
WrapL(Double_t* xp, Double_t* pp)
5634 return L(xp[0], pp[0], pp[1], pp[2]);
5649 struct Holder :
public TNamed, TAttLine, TAttFill
5669 SetLineColor(h->GetLineColor());
5670 SetLineStyle(h->GetLineStyle());
5671 SetLineWidth(h->GetLineWidth());
5672 SetFillColor(h->GetFillColor());
5673 SetFillStyle(h->GetFillStyle());
5686 Holder(
const char* name,
const char* title, Bool_t rel,
5687 UInt_t option, UInt_t
id)
5688 : TNamed(name, title),
5705 fRelative(other.fRelative),
5706 fOption(other.fOption)
5708 SetUniqueID(other.GetUniqueID());
5719 if (&other ==
this)
return *
this;
5721 other.TNamed::Copy(*
this);
5722 other.TAttLine::Copy(*
this);
5723 other.TAttFill::Copy(*
this);
5728 SetUniqueID(other.GetUniqueID());
5742 virtual Graph* StackError(Graph* g, Bool_t ignoreErr, Bool_t quad)
const = 0;
5752 virtual void SumError(Graph* g, Int_t i, Bool_t ignoreErr,
5753 Bool_t quad, UInt_t opt)
const = 0;
5771 virtual void Print(Option_t* option=
"")
const 5773 gROOT->IndentLevel();
5774 Printf(
"%s/%s %s(ID # %d%s)", GetName(), GetTitle(),
5777 TString opt(option);
5778 if (!opt.Contains(
"ATTR", TString::kIgnoreCase))
return;
5779 gROOT->IndentLevel();
5780 Printf(
" [option: %3d line (c/s/w):%3d/%1d/%2d fill (c/s):%3d/%4d]",
5781 fOption, GetLineColor(), GetLineStyle(), GetLineWidth(),
5782 GetFillColor(), GetFillStyle());
5785 virtual void ls(Option_t* option)
const 5793 if (opt < 0) opt = fOption;
5797 case kNone: xMode = 0;
break;
5798 case kRect:
case kBox: xMode = 3;
break;
5829 Double_t& eyh)
const 5844 Info(
"",
"old: +%f/-%f this: +%f/-%f -> +%f/-%f",
5845 curEyl, curEyh, eyl, eyh, eyl + curEyl, eyh + curEyh);
5846 exl = TMath::Max(exl, curExl);
5847 exh = TMath::Max(exh, curExh);
5854 case 1: exl = exh = 0;
break;
5856 if (exl <= 0) exl = gStyle->GetErrorX()/2;
5857 if (exh <= 0) exh = gStyle->GetErrorX()/2;
5870 this->TAttLine::Copy(*g);
5871 this->TAttFill::Copy(*g);
5872 g->SetMarkerColor(0);
5873 g->SetMarkerStyle(0);
5874 g->SetMarkerSize(0);
5908 UInt_t opt, UInt_t
id)
5909 :
Holder(name, title, rel, opt, id),
5912 fGraph =
new Graph();
5913 fGraph->SetName(name);
5914 fGraph->SetTitle(title);
5915 SetAttributes(fGraph);
5927 fGraph =
static_cast<Graph*
>(other.
fGraph->Clone());
5929 if (fGraph) SetAttributes(fGraph);
5940 if (&other ==
this)
return *
this;
5943 if (fGraph)
delete fGraph;
5946 fGraph =
static_cast<Graph*
>(other.
fGraph->Clone());
5947 if (fGraph) SetAttributes(fGraph);
5964 void Set(Int_t point, Graph* g, Double_t ex, Double_t ey)
5966 Set(point, g, ex, ex, ey, ey);
5978 void Set(Int_t point, Graph* g, Double_t ex1, Double_t ex2,
5979 Double_t ey1, Double_t ey2)
5981 if (!fGraph)
return;
5983 if (point >= g->GetN())
return;
5984 Double_t x = g->GetX()[point];
5985 Double_t y = g->GetY()[point];
5986 fGraph->SetPoint(point, x, y);
5987 if (fRelative) { ey1 *= y; ey2 *= y; }
5988 fGraph->SetPointError(point, ex1, ex2, ey1, ey2);
6005 if (!fGraph)
return 0;
6006 return fGraph->GetErrorX(point);
6017 if (!fGraph)
return 0;
6018 return fGraph->GetErrorXlow(point);
6029 if (!fGraph)
return 0;
6030 return fGraph->GetErrorXhigh(point);
6041 if (!fGraph)
return 0;
6042 return fGraph->GetErrorY(point);
6053 Double_t
GetYDown(Int_t i1, Int_t i2, Double_t ax)
const 6055 if (!fGraph)
return 0;
6056 if (i1 == i2)
return GetYDown(i1);
6057 Double_t e1 = GetYDown(i1);
6058 Double_t e2 = GetYDown(i2);
6059 return e1 + ax * (e2-e1);
6070 if (!fGraph)
return 0;
6071 return fGraph->GetErrorYlow(point);
6082 Double_t
GetYUp(Int_t i1, Int_t i2, Double_t ax)
const 6084 if (!fGraph)
return 0;
6085 if (i1 == i2)
return GetYUp(i1);
6086 Double_t e1 = GetYUp(i1);
6087 Double_t e2 = GetYUp(i2);
6088 return e1 + ax * (e2-e1);
6099 if (!fGraph)
return 0;
6100 return fGraph->GetErrorYhigh(point);
6129 Double_t& eyh)
const 6131 Double_t exlO = fGraph->GetErrorXlow(i);
6132 Double_t exhO = fGraph->GetErrorXhigh(i);
6133 Double_t eylO = fGraph->GetErrorYlow(i);
6134 Double_t eyhO = fGraph->GetErrorYhigh(i);
6135 Double_t oyl = eylO;
6136 Double_t oyh = eyhO;
6137 if (exl <= 0) exlO = exl;
6138 if (exh <= 0) exhO = exh;
6142 ignoreErr, quad, sqOld,
6143 exlO, exhO, eylO, eyhO);
6145 Info(GetTitle(),
"quad: %s this: +%f/-%f, old: +%f/-%f -> +%f/-%f",
6146 (quad ?
"true" :
"false"), oyl, oyh, eyl, eyh, eylO, eyhO);
6172 Double_t& eyh)
const 6174 Double_t oldEyl = eyl;
6175 Double_t oldEyh = eyh;
6176 AddError(i, xMode, ignoreErr, quad,
true, exl, exh, eyl, eyh);
6178 Info(GetTitle(),
"old= +%f/-%f -> +%f/-%f", oldEyl, oldEyh, eyl, eyh);
6191 Graph* ga =
new Graph(g->GetN());
6192 for (Int_t i = 0; i < g->GetN(); i++) {
6193 Double_t x = g->GetX()[i];
6194 Double_t y = g->GetY()[i];
6195 Double_t exl = g->GetErrorXlow(i);
6196 Double_t exh = g->GetErrorXhigh(i);
6197 Double_t eyl = g->GetErrorYlow(i);
6198 Double_t eyh = g->GetErrorYhigh(i);
6199 StackPointError(i, XMode(), ignoreErr, quad, exl, exh, eyl, eyh);
6201 ga->SetPoint(i, x, y);
6202 ga->SetPointError(i, exl,exh,eyl,eyh);
6205 ga->SetTitle(GetTitle());
6206 ga->SetName(Form(
"stack_%08x", GetUniqueID()));
6225 Double_t& eyh)
const 6227 AddError(i, xMode, ignoreErr, quad,
false, exl, exh, eyl, eyh);
6239 Bool_t quad, UInt_t opt)
const 6241 Double_t exl = (g ? g->GetErrorXlow(i) : 0);
6242 Double_t exh = (g ? g->GetErrorXhigh(i) : 0);
6243 Double_t eyl = (g ? g->GetErrorYlow(i) : 0);
6244 Double_t eyh = (g ? g->GetErrorYhigh(i) : 0);
6245 SumPointError(i, XMode(opt), ignoreErr, quad, exl, exh, eyl, eyh);
6246 g->SetPointError(i, exl,exh,eyl,eyh);
6251 if (option[0] ==
'd' || option[0] ==
'D')
6252 out <<
" // Point-2-Point systematic " << GetTitle() <<
"\n" 6254 <<
" Int_t id = g->DeclarePoint2Point(\"" << GetTitle() <<
"\"," 6256 <<
" g->SetSysLineColor(id," << GetLineColor() <<
");\n" 6257 <<
" g->SetSysLineStyle(id," << GetLineStyle() <<
");\n" 6258 <<
" g->SetSysLineWidth(id," << GetLineWidth() <<
");\n" 6259 <<
" g->SetSysFillColor(id," << GetFillColor() <<
");\n" 6260 <<
" g->SetSysFillStyle(id," << GetFillStyle() <<
");\n" 6263 virtual void Print(Option_t* option=
"")
const 6265 gROOT->IndentLevel();
6266 Printf(
"%s/%s (ID # %d, %d points)", GetName(), GetTitle(), GetUniqueID(),
6267 (fGraph ? fGraph->GetN() : -1));
6268 TString opt(option);
6269 if (!opt.Contains(
"ATTR", TString::kIgnoreCase))
return;
6270 gROOT->IndentLevel();
6271 Printf(
" [option: %3d line (c/s/w):%3d/%1d/%2d fill (c/s):%3d/%4d]",
6272 fOption, GetLineColor(), GetLineStyle(), GetLineWidth(),
6273 GetFillColor(), GetFillStyle());
6295 :
Holder(), fEyl(0), fEyh(0)
6308 UInt_t opt, UInt_t
id)
6309 :
Holder(name, title, rel, opt, id), fEyl(0), fEyh(0)
6332 if (&other ==
this)
return *
this;
6355 void Set(Double_t eyl, Double_t eyh)
6369 return (fRelative ? y : 1) * fEyl;
6380 return (fRelative ? y : 1) * fEyh;
6410 Double_t& eyh)
const 6414 Double_t exlO = exl;
6415 Double_t exhO = exh;
6416 Double_t eylO = GetYDown(y);
6417 Double_t eyhO = GetYUp(y);
6418 if (exlO <= 0) exlO = gStyle->GetErrorX()/2;
6419 if (exhO <= 0) exhO = gStyle->GetErrorX()/2;
6421 DoAdd(xMode, exl, exh, eyl, eyh,
6422 ignoreErr, quad, sqOld,
6423 exlO, exhO, eylO, eyhO);
6439 Graph*
BarError(Graph* g, Bool_t quad, Double_t x, Double_t y)
const 6441 Double_t exl = (g ? g->GetErrorXlow(0) : 0);
6442 Double_t exh = (g ? g->GetErrorXhigh(0) : 0);
6443 Double_t eyl = (g ? g->GetErrorYlow(0) : 0);
6444 Double_t eyh = (g ? g->GetErrorYhigh(0) : 0);
6445 AddError(y, XMode(),
false, quad, quad, exl, exh, eyl, eyh);
6447 Graph* r =
new Graph(1);
6448 r->SetPoint(0, x, y);
6449 r->SetPointError(0, exl, exh, eyl, eyh);
6452 r->SetTitle(GetTitle());
6453 r->SetName(Form(
"bar_%08x", GetUniqueID()));
6476 Double_t& eyh)
const 6478 AddError(y, xMode, ignoreErr, quad,
true, exl, exh, eyl, eyh);
6492 Graph* ga =
new Graph(g->GetN());
6493 for (Int_t i = 0; i < g->GetN(); i++) {
6494 Double_t x = g->GetX()[i];
6495 Double_t y = g->GetY()[i];
6496 Double_t exl = g->GetErrorXlow(i);
6497 Double_t exh = g->GetErrorXhigh(i);
6498 Double_t eyl = g->GetErrorYlow(i);
6499 Double_t eyh = g->GetErrorYhigh(i);
6500 StackPointError(y, XMode(), ignoreErr, quad, exl, exh, eyl, eyh);
6501 ga->SetPoint(i, x, y);
6502 ga->SetPointError(i, exl,exh,eyl,eyh);
6505 ga->SetTitle(GetTitle());
6506 ga->SetName(Form(
"stack_%08x", GetUniqueID()));
6525 Double_t& eyh)
const 6527 AddError(y, xMode, ignoreErr, quad,
false, exl, exh, eyl, eyh);
6538 void SumError(Graph* g, Int_t i, Bool_t ignoreErr, Bool_t quad,
6541 Double_t y = (g ? g->GetY()[i] : 0);
6542 Double_t exl = (g ? g->GetErrorXlow(i) : 0);
6543 Double_t exh = (g ? g->GetErrorXhigh(i) : 0);
6544 Double_t eyl = (g ? g->GetErrorYlow(i) : 0);
6545 Double_t eyh = (g ? g->GetErrorYhigh(i) : 0);
6546 SumPointError(y, XMode(opt), ignoreErr, quad, exl, exl, eyl, eyh);
6547 g->SetPointError(i, exl,exh,eyl,eyh);
6552 if (option[0] ==
'd' || option[0] ==
'D')
6553 out <<
" // Common systematic " << GetTitle() <<
"\n" 6555 <<
" Int_t id = g->DefineCommon(\"" << GetTitle() <<
"\"," 6556 << fRelative <<
',' << fEyl <<
',' << fEyh <<
',' 6557 << fOption <<
");\n" 6558 <<
" g->SetSysLineColor(id," << GetLineColor() <<
")\n;" 6559 <<
" g->SetSysLineStyle(id," << GetLineStyle() <<
")\n;" 6560 <<
" g->SetSysLineWidth(id," << GetLineWidth() <<
")\n;" 6561 <<
" g->SetSysFillColor(id," << GetFillColor() <<
")\n;" 6562 <<
" g->SetSysFillStyle(id," << GetFillStyle() <<
")\n;" 6565 virtual void Print(Option_t* option=
"")
const 6568 Double_t fac = (rel ? 100 : 1);
6569 const char* pst = (rel ?
"%" :
"");
6570 gROOT->IndentLevel();
6571 Printf(
"%s/%s (ID # %d) -%f%s +%f%s",
6572 GetName(), GetTitle(), GetUniqueID(),
6573 fac*fEyl, pst, fac*fEyh, pst);
6574 TString opt(option);
6575 if (!opt.Contains(
"ATTR", TString::kIgnoreCase))
return;
6576 gROOT->IndentLevel();
6577 Printf(
" [option: %3d line (c/s/w):%3d/%1d/%2d fill (c/s):%3d/%4d]",
6578 fOption, GetLineColor(), GetLineStyle(), GetLineWidth(),
6579 GetFillColor(), GetFillStyle());
6608 Double_t& eyh)
const 6612 return GetYandError(i, cmn, stat, quad, nosqrt, eyl, eyh, wyl, wyh);
6641 Double_t& wyh)
const 6644 Int_t n =
fData->GetN();
6650 Double_t y =
fData->GetY()[i];
6653 eyl = (stat ? wyl : 0);
6654 eyh = (stat ? wyh : 0);
6671 while ((hc = static_cast<HolderCommon*>(nextC()))) {
6672 if (hc->TestBit(
kUsedBit))
continue;
6674 hc->
SumPointError(y, xMode,
false, quad, exl, exh, wyl, wyh);
6676 hc->
SumPointError(y, xMode,
false, quad, exl, exh, eyl, eyh);
6681 while ((hp = static_cast<HolderP2P*>(nextP()))) {
6682 if (hp->TestBit(
kUsedBit))
continue;
6684 hp->
SumPointError(i, xMode,
false, quad, exl, exh, wyl, wyh);
6686 hp->
SumPointError(i, xMode,
false, quad, exl, exh, eyl, eyh);
6688 if (quad && !nosqrt) {
6689 eyl = TMath::Sqrt(eyl);
6690 eyh = TMath::Sqrt(eyh);
6691 wyl = TMath::Sqrt(wyl);
6692 wyh = TMath::Sqrt(wyh);
6739 static Double_t
Round(Double_t v, Int_t p, Int_t& rexpo)
6748 Bool_t neg = (v < 0);
6749 Double_t tmp = TMath::Abs(v);
6750 Int_t expo = Int_t(TMath::Log10(tmp));
6751 Double_t tens = TMath::Power(10, expo - p + 1);
6752 Double_t n =
RoundN(tens, tmp);
6754 if (n < TMath::Power(10, p-1)) {
6757 tens = TMath::Power(10, expo - p + 1);
6761 if (TMath::Abs((n+1) * tens) <= TMath::Abs(n * tens))
6765 if (n >= TMath::Power(10,p)) {
6772 return (neg ? -1 : 1)*n;
6775 static void SwapPoints(Graph* g, Int_t i, Int_t j, Bool_t reflect)
6777 Double_t s = (reflect ? -1 : 1);
6778 Double_t tmpX = g->GetX()[i];
6779 Double_t tmpY = g->GetY()[i];
6780 Double_t tmpExl = g->GetErrorXlow(i);
6781 Double_t tmpExh = g->GetErrorXhigh(i);
6782 Double_t tmpEyl = g->GetErrorYlow(i);
6783 Double_t tmpEyh = g->GetErrorYhigh(i);
6786 Double_t tmp = tmpExl;
6790 g->SetPoint(i, s*g->GetX()[j], g->GetY()[j]);
6792 g->GetErrorXlow(j), g->GetErrorXhigh(j),
6793 g->GetErrorYlow(j), g->GetErrorYhigh(j));
6794 g->SetPoint(j, s*tmpX, tmpY);
6795 g->SetPointError(j, tmpExl, tmpExh, tmpEyl, tmpEyh);
6803 TString tmp(Form(
"*%s:", key));
6804 return Form(
"%-12s", tmp.Data());
6818 TObjArray* tokens = value.Tokenize(
":");
6819 Int_t iVal = TMath::Min(Int_t(idx),tokens->GetEntriesFast()-1);
6820 if (iVal < 0)
return val;
6821 TString tmp = tokens->At(iVal)->GetName();
6822 val = tmp.Strip(TString::kBoth,
' ');
6837 const char* name,
const char* val)
6839 TObject* oqv = quals.FindObject(name);
6848 else qv =
static_cast<TList*
>(oqv);
6850 qv->AddAt(
new TObjString(val), idx);
6861 StoreQual(quals, idx, q->GetName(), q->GetTitle());
6875 Bool_t alsoKey =
true,
6876 const char* fill =
"<please fill in>")
const 6878 Bool_t gotit =
false;
6882 while ((obj = nextK())) {
6883 TString k(obj->GetName());
6884 if (!k.EqualTo(which))
continue;
6886 if (alsoKey) out <<
FormatKey(obj->GetName());
6887 out << obj->GetTitle() << std::endl;
6893 out << fill << std::endl;
6908 Bool_t alsoTop=
false,
6909 Bool_t alsoComment=
false,
6910 Int_t nsign=-1)
const 6913 out <<
"# Generated by GraphSysErr\n" 6916 <<
"# http://hepdata.cedar.ac.uk/resource/sample.input\n" 6917 <<
"# http://hepdata.cedar.ac.uk/submittingdata\n" 6919 <<
"# Please fill in missing fields\n";
6923 UserGroup_t* u = gSystem->GetUserInfo();
6924 TString ref =
GetKey(
"reference");
6925 const char* lab =
GetKey(
"laboratory");
6926 const char* accel =
GetKey(
"accelerator");
6927 const char* exper =
GetKey(
"detector");
6928 const char* abs =
GetKey(
"abstract");
6929 const char* months[] = {
"JAN",
"FEB",
"MAR",
"APR",
6930 "MAY",
"JUN",
"JUL",
"AUG",
6931 "SEP",
"OCT",
"NOV",
"DEC"};
6933 out <<
"*reference: <journal/archive ref> : <year>" << std::endl;
6935 ExportKey(out,
"reference",
true,
"<reference>");
6937 ExportKey(out,
"author",
true,
"<Last name of first author in CAPS>");
6938 ExportKey(out,
"doi",
true,
"<DOI number>");
6939 ExportKey(out,
"inspireId",
true,
"<inSpire ID>");
6940 ExportKey(out,
"cdsId",
true,
"<CDS ID>");
6941 ExportKey(out,
"durhamId",
true,
"<fill in on submission>");
6942 ExportKey(out,
"title",
true,
"<Title of paper>");
6944 out <<
FormatKey(
"status") <<
"Encoded " 6945 << std::setw(2) << now.GetDay() <<
' '<< months[now.GetMonth()-1]<<
' ' 6946 << std::setw(4) << now.GetYear() <<
" by "<< u->fRealName.Data()<<
"\n" 6947 <<
FormatKey(
"experiment") << (lab ? lab :
"<lab>") <<
'-' 6948 << (accel ? accel :
"<accelerator>") <<
'-' 6949 << (exper ? exper :
"<experiment>") <<
'\n' 6950 <<
FormatKey(
"detector") << (exper ? exper :
"<experiment>") <<
'\n' 6951 <<
FormatKey(
"comment") << (lab ? lab :
"<lab>") <<
'-' 6952 << (accel ? accel :
"<accelerator>") <<
". " 6953 << (abs ? abs :
"<abstract>") <<
"\n" 6956 out <<
"# Start of dataset\n";
6957 if (nsign >= 0) out <<
"# Using " << nsign <<
" significant digits\n";
6958 out <<
FormatKey(
"dataset") << std::endl;
6960 const char* fields[] = {
"location",
6966 const char** pfld = fields;
6994 Int_t p = o.precision();
6999 Double_t lm =
Round(l, nsign, le);
7000 Double_t hm =
Round(h, nsign, he);
7001 e = TMath::Min(le,he);
7002 l = lm*TMath::Power(10,le);
7003 h = hm*TMath::Power(10,he);
7008 if (TMath::Abs(h-l) < 1e-12)
7009 o << (nopm ?
"" :
"+- ") << TMath::Abs(l) << (rel ?
" PCT" :
"");
7011 o <<
"+" << h <<
",-" << l << (rel ?
" PCT" :
"");
7029 Bool_t sysName=
true,
7030 Int_t nsign=0)
const 7032 Int_t p = out.precision();
7035 Double_t x =
GetX(i);
7036 Double_t exl =
fData->GetErrorXlow(i);
7037 Double_t exh =
fData->GetErrorXhigh(i);
7042 Double_t mxl =
Round(exl,nsign,pxl);
7043 Double_t mxh =
Round(exh,nsign,pxh);
7044 exl = mxl*TMath::Power(10, pxl);
7045 exh = mxh*TMath::Power(10, pxh);
7046 Int_t mp = TMath::Min(pxl,pxh);
7048 ppp = TMath::Ceil(TMath::Log10(TMath::Abs(x)))-mp;
7052 if (TMath::Abs(exl) < 1e-10 && TMath::Abs(exh) < 1e-10) {
7053 if (nsign <= 0) out <<
' ' << x;
7056 Double_t mx =
Round(x, nsign, px);
7057 Double_t xx = mx*TMath::Power(10,px);
7059 out.precision(nsign);
7064 if (TMath::Abs(exh-exl) < 1e-10) {
7066 out <<
' ' << x-exl <<
" TO " << x+exh;
7070 out <<
' ' << x <<
' ';
7072 out <<
'+' << exh <<
",-" << exl;
7081 Double_t y =
GetY(i);
7082 Double_t fy = (statRel ? (y == 0 ? 0 : 100./y) : 1);
7086 std::stringstream tmp;
7088 Int_t le =
ExportError(tmp, eyl, eyh,
false, statRel, nsign);
7091 tmp <<
" (" << std::flush;
7094 Bool_t first =
true;
7095 while ((holderP2P = static_cast<HolderP2P*>(nextP()))) {
7097 fy = (rel ? (y == 0 ? 0 : 100./y) : 1);
7098 if (!first) tmp <<
',';
7099 Double_t esh = holderP2P->
GetYUp(i)*fy;
7100 Double_t esl = holderP2P->
GetYDown(i)*fy;
7102 le = TMath::Min(le,
ExportError(tmp, esl, esh,
true, rel, nsign));
7104 tmp <<
':' << holderP2P->GetTitle() << std::flush;
7110 Int_t nY = TMath::Ceil(TMath::Log10(TMath::Abs(y)))-le;
7117 out << tmp.str() <<
';';
7138 static Double_t
RoundN(Double_t tens, Double_t tmp)
7141 Double_t n = TMath::Floor(100*tmp/tens+.00001);
7142 Int_t next = int(n/10) % 10;
7145 return TMath::Ceil(n/100);
7148 return TMath::Floor(n/100);
7149 Int_t nnext = int(n) % 10;
7152 return TMath::Ceil(n/100);
7153 Int_t last = int(n/100) % 10;
7156 return TMath::Floor(n/100);
7158 return TMath::Ceil(n/100);
7169 static TString&
Token(TObjArray* c, UShort_t idx, Bool_t verbose=
true)
7171 static TString empty(
"");
7172 if (idx >= c->GetEntriesFast()) {
7174 ::Error(
"Token",
"Token %d does not exist in array", idx);
7179 return static_cast<TObjString*
>(c->At(idx))->String();
7192 Double_t& el, Double_t& eh, Bool_t& rel)
7197 if (tmp.Contains(
"PCT", TString::kIgnoreCase) || tmp.Contains(
"%"))
7199 if (tmp.BeginsWith(
"+-") || tmp.BeginsWith(
"-+")) {
7200 el = eh = tmp.Atof();
7204 TObjArray* tokens = tmp.Tokenize(
",");
7205 for (Int_t i = 0; i < tokens->GetEntriesFast(); i++) {
7206 TString& t =
Token(tokens, i);
7207 if (t.IsNull())
continue;
7208 t.Remove(TString::kBoth,
' ');
7209 Double_t v = t.Atof();
7211 if (t[0] !=
'-' && t[0] !=
'+') {
7213 el = eh = TMath::Abs(v);
7218 Double_t max = TMath::Max(el, -v);
7219 ::Warning(
"ImportError",
7220 "Lower error already set to %f, chosing the maximum of " 7221 "(%f,%f) -> %f", el, el, -v, max);
7229 Double_t max = TMath::Max(eh, v);
7230 ::Warning(
"ImportError",
7231 "Lower error already set to %f, chosing the maximum of " 7232 "(%f,%f) -> %f", eh, eh, v, max);
7262 rel = s.Contains(
"PCT");
7263 TObjArray* tok = s.Tokenize(
" ,");
7264 if (tok->GetEntriesFast() >= 4 &&
7265 Token(tok,2).EqualTo(
"TO", TString::kIgnoreCase) &&
7266 Token(tok,1).Contains(
"BIN", TString::kIgnoreCase)) {
7267 v =
Token(tok,0).Atof();
7268 TString tmp =
Token(tok,1);
7269 TString s1 = tmp.Strip(TString::kBoth,
'(');
7270 s1.ReplaceAll(
"BIN=",
"");
7271 Double_t v1 = s1.Atof();
7273 s1 = tmp.Strip(TString::kBoth,
')');
7274 Double_t v2 = s1.Atof();
7278 else if (tok->GetEntriesFast() >= 3 &&
7279 Token(tok,1).EqualTo(
"TO", TString::kIgnoreCase)) {
7280 Double_t v1 =
Token(tok,0).Atof();
7281 Double_t v2 =
Token(tok,2).Atof();
7287 v =
Token(tok,0).Atof();
7288 if (tok->GetEntriesFast() >= 2 &&
7289 (
Token(tok,1).BeginsWith(
"+-") ||
7290 Token(tok,1).BeginsWith(
"-+"))) {
7291 TString t =
Token(tok,1);
7292 if (t.Length() > 2) {
7299 el = eh =
Token(tok,2).Atof();
7303 for (Int_t i = 1; i < tok->GetEntriesFast(); i++) {
7304 TString t =
Token(tok, i);
7307 if (m !=
'+' && m !=
'-')
continue;
7308 if (t.Length() == 1) t =
Token(tok, ++i);
7311 if (m ==
'-') el = t.Atof();
7334 printf(
"%20s Point %3d %f,%f -> ",
"",
7335 i,g->GetEYlow()[i],g->GetEYhigh()[i]);
7337 g->GetEYlow()[i] = TMath::Sqrt(g->GetEYlow()[i]);
7338 g->GetEYhigh()[i] = TMath::Sqrt(g->GetEYhigh()[i]);
7341 Printf(
"%f,%f", g->GetEYlow()[i], g->GetEYhigh()[i]);
7350 for (Int_t i = 0; i < g->GetN(); i++)
7368 case kNormal: ret =
"";
break;
7369 case kNoTick: ret =
"Z0";
break;
7370 case kArrow: ret =
">0";
break;
7371 case kRect: ret =
"20";
break;
7372 case kBox: ret =
"50";
break;
7373 case kFill: ret =
"30";
break;
7374 case kCurve: ret =
"40";
break;
7375 case kHat: ret =
"[]0";
break;
7376 case kBar: ret =
"||0";
break;
7377 case kNone: ret =
"XP";
break;
7378 case kLine: ret =
"CX";
break;
7391 fData->SetName(Form(
"%s_data", fName.Data()));
7392 fData->SetTitle(GetTitle());
7404 Int_t
FindPoint(Double_t x, Int_t& i1, Int_t& i2, Double_t fac=1)
const 7417 const Double_t tol = 1e-9;
7418 for (Int_t i=0; i < n; i++) {
7475 Warning(
"MakeMulti",
"No data defined");
7480 TString opt(option);
7483 Bool_t cmn = opt.Contains(
"COMMON");
7484 Bool_t combine = opt.Contains(
"COMBINED");
7485 Bool_t stat = opt.Contains(
"STAT");
7486 Bool_t quad = opt.Contains(
"QUAD");
7487 combine = !opt.Contains(
"STACK");
7488 quad = !opt.Contains(
"DIRECT");
7489 Bool_t split = opt.Contains(
"SPLIT");
7490 Int_t xpos = (opt.Contains(
"WEST") ? -1 : 1);
7491 Int_t ypos = (opt.Contains(
"MIN") ? -1 :
7492 opt.Contains(
"MAX") ? 1 : 0);
7495 Int_t n =
fData->GetN();
7496 Double_t dx = TMath::Max(gStyle->GetErrorX(),0.0001F);
7498 Warning(
"MakeMulti",
"Nothing to do (n=%d)", n);
7504 if (opt.Contains(
"XBASE=")) {
7505 Int_t idx = opt.Index(
"XBASE=")+6;
7506 TString tmp = opt(idx,opt.Length()-idx);
7510 xBase = ((xpos < 0 ?
7512 fData->GetX()[n-1] +
fData->GetEXhigh()[n-1])
7515 Double_t yBase =
fData->GetY()[0];
7516 for (Int_t i = 0; i < n; i++) {
7517 Double_t y =
fData->GetY()[i];
7518 yBase = (ypos < 0 ? TMath::Min(yBase, y) :
7519 ypos > 0 ? TMath::Max(yBase, y) : yBase + y);
7521 if (ypos == 0) yBase /= n;
7525 drawn.SetOwner(
false);
7537 while ((h = static_cast<Holder*>(next()))) {
7538 Graph* g = h->
StackError(prev, (!stat ? prev ==
fData :
false), quad);
7548 while ((h = static_cast<Holder*>(next()))) {
7549 Graph* g = h->
StackError(prev, (!stat ? prev ==
fData :
false), quad);
7559 Graph* g =
static_cast<Graph*
>(
fData->Clone(
"error"));
7562 for (Int_t i = 0; i < n; i++) {
7564 g->SetPointError(i, g->GetEXlow()[i],
7565 g->GetEXhigh()[i],0,0);
7569 g->GetEYlow()[i] *= g->GetEYlow()[i];
7571 g->GetEYhigh()[i] *= g->GetEYhigh()[i];
7577 while ((h = static_cast<Holder*>(nextC()))) {
7583 while ((h = static_cast<Holder*>(nextP())))
7591 g->SetMarkerStyle(0);
7592 g->SetMarkerSize(0);
7593 g->SetMarkerColor(0);
7603 while ((hc = static_cast<HolderCommon*>(nextC()))) {
7604 Graph* g = hc->
BarError(prev, quad && !split, xBase, yBase);
7606 Warning(
"MakeMulti",
"Got no graph for common error %s",
7613 if (split) xBase += xpos * 1.2 * dx;
7620 TObjLink* f = drawn.FirstLink();
7622 while (f && f->GetObject()) {
7623 if (f->GetObject() == prev) {
7632 prev = (split ? 0 : g);
7637 if (
fCommon.GetEntries() > 0) {
7638 Graph* g =
new Graph(1);
7639 g->SetPoint(0, xBase, yBase);
7644 while ((hc = static_cast<HolderCommon*>(nextC()))) {
7646 false, quad, exl, exh, eyl, eyh);
7648 g->SetPointError(0, exl, exh, eyl, eyh);
7651 g->SetMarkerStyle(0);
7652 g->SetMarkerSize(0);
7653 g->SetMarkerColor(0);
7661 this->TAttLine::Copy(*
fData);
7662 this->TAttFill::Copy(*
fData);
7663 this->TAttMarker::Copy(*
fData);
7667 dopt.Append(
" p same");
7673 drawn.AddLast(
fData->Clone(
"data"), dopt.Data());
7677 TGraph* g =
new TGraph(
fData->GetN());
7679 g->SetTitle(
fData->GetTitle());
7680 this->TAttLine::Copy(*g);
7681 this->TAttFill::Copy(*g);
7682 this->TAttMarker::Copy(*g);
7683 for (Int_t i = 0; i <
fData->GetN(); i++)
7684 g->SetPoint(i,
fData->GetX()[i],
fData->GetY()[i]);
7685 drawn.AddLast(g, dopt.Data());
7689 TMultiGraph* ret =
new TMultiGraph(
"drawn", GetTitle());
7690 TIter nextG(&drawn);
7692 while ((gg = static_cast<TGraph*>(nextG()))) {
7694 Printf(
"%-20s:%-20s %20s " 7695 "(line:%3d/%d/%d, marker:%3d/%2d/%4f, fill:%3d/%4d)",
7696 gg->GetName(), gg->GetTitle(), nextG.GetOption(),
7697 gg->GetLineColor(), gg->GetLineStyle(), gg->GetLineWidth(),
7698 gg->GetMarkerColor(), gg->GetMarkerStyle(), gg->GetMarkerSize(),
7699 gg->GetFillColor(), gg->GetFillStyle());
7700 ret->Add(gg, nextG.GetOption());
7721 while ((o = next())) {
7722 if (o->GetUniqueID() != id)
continue;
7738 while ((o = next())) {
7739 if (o->GetUniqueID() != id)
continue;
7755 bool verb=
false)
const 7758 Int_t
id =
FindId(o->GetTitle());
7761 Warning(
"FindCompat[C]",
"Syst.unc. '%s' not found in %s",
7762 o->GetTitle(), GetName());
7768 Warning(
"FindCompat[C]",
"Syst.unc. '%s' (%d) is not a common",
7774 Warning(
"FindCompat[C]",
"Inconsistent value type (%s) of '%s' (%d)",
7779 Double_t ltol = 0.01;
7780 Double_t x1, x2, test;
7783 test = TMath::Abs(x2-x1) / (1+TMath::Min(TMath::Abs(x1), TMath::Abs(x2)));
7786 Warning(
"FindCompat[C]",
"Lower value %10f of '%s' (%d) " 7787 "incompatible with %10f (|%f|>%f [%g])",
7797 test = TMath::Abs(x2-x1) / (1+TMath::Min(TMath::Abs(x1), TMath::Abs(x2)));
7800 Warning(
"FindCompat[C]",
"Upper value %10f of '%s' (%d) " 7801 "incompatible with %10f (|%f|>%f [%g])",
7823 Int_t
id =
FindId(o->GetTitle());
7826 Warning(
"FindCompat[P]",
"Syst.unc. '%s' not found in %s",
7827 o->GetTitle(), GetName());
7833 Warning(
"FindCompat[P]",
"Syst.unc. '%s' (%d) is not point-to-point",
7839 Warning(
"FindCompat[P]",
"Inconsistent value type (%s) of '%s' (%d)",
7859 while ((o = nextC())) {
7860 if (o->GetUniqueID() != id)
continue;
7861 return static_cast<Holder*
>(o);
static Double_t L(Double_t guess, Double_t x, Double_t el, Double_t eh)
Return the likely-hood function value at :
static Double_t WrapL(Double_t *xp, Double_t *pp)
Wrap likely-hood function for ROOT.
virtual ~Observation()
Virtual destructor.
virtual void SumError(Graph *g, Int_t i, Bool_t ignoreErr, Bool_t quad, UInt_t opt) const =0
Sum errors at point.
static void StoreQual(TList &quals, Int_t idx, TObject *q)
Store a qualifier in a table.
Result(Double_t x=0, Double_t el=0, Double_t eh=0, Double_t chi2=0, Double_t low=0, Double_t high=0)
The final result.
TAttLine fCommonSumLine
Attributes of summed errors.
void SavePrimitive(std::ostream &out, Option_t *option="")
void Set(Int_t point, Graph *g, Double_t ex1, Double_t ex2, Double_t ey1, Double_t ey2)
Set errors at point.
void SumPointError(Int_t i, UShort_t xMode, Bool_t ignoreErr, Bool_t quad, Double_t &exl, Double_t &exh, Double_t &eyl, Double_t &eyh) const
Sum up point errors.
void Export(std::ostream &out=std::cout, Option_t *option="", Int_t nsign=2)
Dump on stream a table suitable (After some editing) for uploading to the Durham database.
TAttFill fSumFill
Attributes of summed errors.
Width_t GetCommonSumLineWidth() const
Get line width of sum systematic uncertainty.
Result * Calculate(UShort_t nIter=50)
Do the calculation.
Double_t VarTerm(Double_t guess, const Observation &r) const
Calculate the contribution variance to the with the guess .
void AddError(Double_t y, UShort_t xMode, Bool_t ignoreErr, Bool_t quad, Bool_t sqOld, Double_t &exl, Double_t &exh, Double_t &eyl, Double_t &eyh) const
Add errors together at point.
UInt_t GetCommonSumOption() const
Width_t GetSumLineWidth() const
Get line width of sum systematic uncertainty.
void Print(Option_t *option="") const
Print content of the list.
void SetSysLineColor(Int_t id, Color_t color)
Set the line color of the systematice error identified by ID.
void SetYTitle(const char *title)
Set title on y axis.
static void StoreQual(TList &quals, Int_t idx, const char *name, const char *val)
Store a qualifier in a table.
std::ostream & ExportKey(std::ostream &out, const char *which, Bool_t alsoKey=true, const char *fill="<please fill in>") const
Export all values of a key.
Double_t GetSysErrorXLeft(Int_t id, Int_t point) const
Double_t GetSysErrorY(Int_t id, Int_t point) const
static Double_t ChisquareTest(const GraphSysErr *g1, const GraphSysErr *g2, Int_t &ndf, EChi2Type type)
Calculate the test of equivilance between two graphs.
Double_t(* Wrapper_t)(Double_t *, Double_t *)
void Draw(Option_t *option="")
Draw this data.
void SetSysLineStyle(Int_t id, Style_t style)
Set the line style of the systematice error identified by ID.
void Draw(Option_t *option="")
TMultiGraph * fDrawn
The drawn graphs.
Double_t GetStatErrorUp(Int_t point) const
Double_t GetYandError(Int_t i, Bool_t cmn, Bool_t stat, Bool_t quad, Bool_t nosqrt, Double_t &eyl, Double_t &eyh) const
Get the point value and low and high errors.
void SetStatError(Int_t i, Double_t eyl, Double_t eyh)
void SavePrimitive(std::ostream &out, Option_t *option="")
const char * GetXTitle() const
Get name of X axis.
TList * fQualifiers
List of qualifiers.
Double_t GetYDown(Double_t y=0) const
Get the down error.
void SetSysOption(Int_t id, EDrawOption_t opt)
Set the draw option for a specific systematic error.
void GetMinMax(Option_t *option, Double_t &ymin, Double_t &ymax, Double_t &xmin, Double_t &xmax, Int_t &imin, Int_t &imax) const
Get minimum and maximum.
void SetKey(const char *key, const char *value, Bool_t replace=false)
Set a key/value pair.
Double_t GetSysErrorYUp(Int_t id, Int_t point) const
Color_t GetSysLineColor(Int_t id) const
Get line color of systematic uncertainty.
void SetPointError(Int_t i, Double_t ex)
Set the X error (bin width) of the ith point.
Double_t GetYUp(Int_t i1, Int_t i2, Double_t ax) const
Get the errors upwards along Y between points i1 and i2.
const char * GetYTitle() const
Get name of Y axis.
Graph * BarError(Graph *g, Bool_t quad, Double_t x, Double_t y) const
Make a graph for showing next to data.
Double_t StandardDeviationX(Bool_t cmn=false, Bool_t stat=true, Bool_t quad=true) const
Calculate the standard deviatin along X.
virtual Bool_t IsRelative() const
Check if this is a relative error.
void SetSysFillStyle(Int_t id, Style_t style)
Set the fill style of the systematice error identified by ID.
static Int_t CacheGraphs(const GraphSysErr *g1, const GraphSysErr *g2, TArrayD &a1y, TArrayD &a2y, TArrayD &a1e2, TArrayD &a2e2)
Get the Y and error values for the two passed graphs.
virtual Double_t Low() const
Lower bound.
UInt_t FindId(const char *title) const
Find the ID of an error with the given title.
Double_t StepOffset(Double_t, const Observation &) const
Calculate the bias.
void SetSysLineWidth(Int_t id, Width_t width)
Set the line width of the systematice error identified by ID.
virtual Double_t StepOffset(Double_t guess, const Observation &r) const =0
Calculate the bias.
virtual void Print(Option_t *option="") const
void SetSysError(Int_t id, Double_t eyl, Double_t eyh)
Double_t GetErrorXRight(Int_t p) const
void Add(const Observation &r)
Add an obervation.
HolderCommon * FindCompat(const HolderCommon *o, Double_t tol=1e-6, bool verb=false) const
Find an error in this graph that is compatible with the passed error.
const char * GetQualifier(const char *name) const
Get qualifier.
void SetCommonSumLineColor(Color_t color)
Set the line color of the sumtematice error identified by ID.
TAttLine fSumLine
Attributes of summed errors.
std::ostream & ExportPoint(std::ostream &out, Int_t i, Bool_t alsoX=true, Bool_t sysName=true, Int_t nsign=0) const
Export a single point.
Observation(Double_t x=0, Double_t el=0, Double_t eh=0)
Create a single obersvation.
Wrapper_t Wrapper() const
Return function pointer to wrapper.
Width_t GetSysLineWidth(Int_t id) const
Get line width of systematic uncertainty.
TList fCommon
List of common errors.
void AddQualifier(const TString &key, const TString &value, Bool_t replace=false)
Adds a qualifier.
void SwapPoints(Int_t i, Int_t j, Bool_t reflect=false)
Swap two points.
void RemoveQualifier(const TString &key)
Remove a qualifier.
void SumPointError(Double_t y, UShort_t xMode, Bool_t ignoreErr, Bool_t quad, Double_t &exl, Double_t &exh, Double_t &eyl, Double_t &eyh) const
Sum up point errors.
Double_t StandardDeviationX(Double_t &error, Bool_t cmn=false, Bool_t stat=true, Bool_t quad=true) const
Calculate the standard deviatin along X.
const char * GetSysTitle(Int_t id) const
Get title of systematic error.
Double_t StepOffset(Double_t guess, const Observation &r) const
Calculate the bias.
Double_t MeanX(Double_t &error, Bool_t cmn=false, Bool_t stat=true, Bool_t quad=true) const
Calculate the mean along X.
void SetSumLineStyle(Style_t style)
Set the line style of the sumtematice error identified by ID.
virtual Double_t High() const
Upper bound.
UInt_t GetSumOption() const
Double_t GetYandError(Int_t i, Bool_t cmn, Bool_t stat, Bool_t quad, Bool_t nosqrt, Double_t &eyl, Double_t &eyh, Double_t &wyl, Double_t &wyh) const
Get the point value and low and high errors.
void SetCommonSumOption(EDrawOption_t opt)
Set the draw option for summed errors.
Double_t S() const
Calculate.
Double_t GetY(Int_t point) const
Double_t GetStatErrorDown(Int_t point) const
HolderCommon(const HolderCommon &other)
Copy CTOR.
static TString & Token(TObjArray *c, UShort_t idx, Bool_t verbose=true)
Get the ith token from the array of tokens c.
void RemoveSysError(Int_t id)
Int_t Average(const TCollection *others, Bool_t sep=true)
Average one or more graphs.
An experimental observation.
GraphSysErr(const GraphSysErr &other)
Copy CTOR.
Double_t E(UShort_t nIter, Int_t sign, Double_t best, Double_t chi2, Double_t s)
Try to find best error.
Double_t GetSysErrorXRight(Int_t id, Int_t point) const
void CopyAttr(const GraphSysErr *f)
Double_t VarTerm(Double_t guess, const Observation &r) const
Calculate the contribution variance to the with the guess .
virtual void Print(Option_t *option="") const
void StackPointError(Int_t i, UShort_t xMode, Bool_t ignoreErr, Bool_t quad, Double_t &exl, Double_t &exh, Double_t &eyl, Double_t &eyh) const
Stack up point errors.
static TSeqCollection * Import(const TString &fileName)
Import all data sets from a Durham input formatted file.
void SqrtPoint(Graph *g, Int_t i)
Take the square root of the errors at point.
Base class to hold systematic errors.
Style_t GetCommonSumFillStyle() const
Get fill style of sum systematic uncertainty.
void SetStatError(Int_t i, Double_t ey)
Set the statistical error on the ith data point.
void SetCommonSumTitle(const char *title)
Set the title uses for summed errors.
Graph * StackError(Graph *g, Bool_t ignoreErr, Bool_t quad) const
Create new graph with stacked errors.
Double_t V() const
Calculate.
TGraphAsymmErrors Graph
A short-hand type definition.
void MakeDataGraph(Int_t n)
Make our data graph.
static Bool_t ImportPoint(const TString &s, Double_t &v, Double_t &el, Double_t &eh, Bool_t &rel)
Service function to import a point value (X or Y) with errors.
TGraphAsymmErrors * fGraph
Our data.
Double_t GetErrorXLeft(Int_t p) const
TGraphAsymmErrors * fData
Our data points.
void SetPoint(Int_t i, Double_t x, Double_t y)
Set the ith data point.
void StatisticsX(Double_t &meanX, Double_t &stdDevX, Double_t &n, Bool_t cmn=false, Bool_t stat=true, Bool_t quad=true) const
Calculates the statistics of X.
static void SwapPoints(Graph *g, Int_t i, Int_t j, Bool_t reflect)
Color_t GetSumFillColor() const
Get fill color of sum systematic uncertainty.
GraphSysErr(Int_t n)
CTOR with number of points.
static Bool_t NextPoint(Int_t i, const GraphSysErr *num, const GraphSysErr *denom, Double_t &x, Double_t &dY, Double_t &dEyl, Double_t &dEyh, Double_t &nY, Double_t &nEyl, Double_t &nEyh)
Find the next point and for ratio.
Style_t GetSumLineStyle() const
Get line style of sum systematic uncertainty.
void SetTitle(const char *name)
Set the title of the data.
ERatioOption
Options for ratios.
UInt_t DefineCommon(const char *title, Bool_t relative, Double_t ey, EDrawOption_t option=kFill)
Define a common systematic error.
Double_t GetYUp(Int_t point) const
Get errors upward along Y at point.
std::ostream & ExportHeader(std::ostream &out, Bool_t alsoTop=false, Bool_t alsoComment=false, Int_t nsign=-1) const
Export data set header, and possibly file header too.
EChi2Type
Types of comparisons.
void SumError(Graph *g, Int_t i, Bool_t ignoreErr, Bool_t quad, UInt_t opt) const
Sum errors at point.
void Save(const char *fileName)
Save to a ROOT script.
virtual void Print(Option_t *option="") const
Print to standard output.
TFitResultPtr Fit(const char *formula, Option_t *fitOption, Option_t *drawOption, Axis_t min=0, Axis_t max=0)
Fit a function to the data.
static Double_t KolomogorovTest(const GraphSysErr *g1, const GraphSysErr *g2, Double_t &z)
Perform a Kolomogorov-Smironov test.
static Bool_t ImportError(const TString &s, Double_t &el, Double_t &eh, Bool_t &rel)
Import errors from a string.
Double_t StandardDeviationXMean(Double_t mean, Double_t &error, Bool_t cmn=false, Bool_t stat=true, Bool_t quad=true) const
This class defines an (X,Y) with any number of error sources.
UInt_t DeclarePoint2Point(const char *title, Bool_t relative, EDrawOption_t option=kBar)
Delcare a point-to-point systematic error.
void AddError(Int_t i, UShort_t xMode, Bool_t ignoreErr, Bool_t quad, Bool_t sqOld, Double_t &exl, Double_t &exh, Double_t &eyl, Double_t &eyh) const
Add errors together at point.
static Double_t KolomogorovTest(const GraphSysErr *g1, const GraphSysErr *g2)
Perform a Kolomogorov-Smironov test.
void Set(Double_t eyl, Double_t eyh)
Set error.
virtual Double_t StepW(Double_t guess, const Observation &r) const =0
Calculate the weight based on a guess of best .
void SetStatRelative(Bool_t rel)
Set whether statistical errors should be considered relative.
Int_t FindPoint(Double_t x, Int_t &i1, Int_t &i2, Double_t fac=1) const
Find point (or possibly two points) that match X.
HolderP2P * FindCompat(const HolderP2P *o, Bool_t verb=false) const
Find an error in this graph that is compatible with the passed error.
Double_t fEyl
Down errors.
void GetMinMax(Option_t *option, Double_t &ymin, Double_t &ymax) const
Get minimum and maximum.
HolderP2P & operator=(const HolderP2P &other)
Assignement operator.
void SumError(Graph *g, Int_t i, Bool_t ignoreErr, Bool_t quad, UInt_t opt) const
Sum errors at point.
static Double_t Round(Double_t v, Int_t p, Int_t &rexpo)
Round number v to n significant digits.
void SetDataOption(EDrawOption_t opt)
Set the draw option for the data and statistical errors.
GraphSysErr & operator=(const GraphSysErr &other)
Assignment operator.
virtual UInt_t GetDOption() const
Style_t GetSumFillStyle() const
Get fill style of sum systematic uncertainty.
UShort_t XMode(Int_t opt=-1) const
GraphSysErr(const char *name, const char *title, Int_t n=0)
Constructor with name, title, and optional pre-allocated size.
Style_t GetSysLineStyle(Int_t id) const
Get line style of systematic uncertainty.
virtual Double_t W(const Observation &r) const =0
Calculate the weight.
Double_t fLower
Lower bound to use.
virtual void Print(Option_t *option="R") const
Print this.
TString fSumTitle
Title on summed errors.
Double_t MeanX(Bool_t cmn=false, Bool_t stat=true, Bool_t quad=true) const
Calculate the mean along X.
Double_t GetCommonErrorYUp(Int_t id) const
Get the common systematic error.
void SavePrimitive(std::ostream &out, Option_t *option="")
HolderCommon * FindCommon(UInt_t id) const
Find a common error graph.
void SetSysFillColor(Int_t id, Color_t color)
Set the fill color of the systematice error identified by ID.
TLine * MakeL(TF1 *f) const
Make a line that represents the best found errors.
virtual ~GraphSysErr()
DTOR.
Graph * StackError(Graph *g, Bool_t ignoreErr, Bool_t quad) const
Create new graph with stacked errors.
static void EscapeLtx(TString &val, const TString &fill="")
Utility to escape out TLatex stuff, and put '$...$' around LaTeX.
static Double_t ChisquareTest(const GraphSysErr *g1, const GraphSysErr *g2, EChi2Type type=kExperimentTruth)
Calculate the test of equivilance between two graphs.
Double_t FWHM(Double_t &el, Double_t &eh) const
Calculate the full-width at half-maximum.
virtual void Print(Option_t *option="") const
Double_t W(const Observation &r) const
Calculate the weight.
Double_t Low() const
Lower bound.
TAttFill fCommonSumFill
Attributes of summed errors.
static Int_t ExportError(std::ostream &o, Double_t low, Double_t high, Bool_t nopm, Bool_t rel, Int_t nsign)
Export an error.
TF1 * MakeF(const Observation &r, Int_t j) const
Make a function that represents to Log-likehood for a given observation.
static Double_t RoundN(Double_t tens, Double_t tmp)
Round number.
virtual ~Combiner()
Virtual destructor.
void SqrtGraph(Graph *g)
Take the square root of the errors.
Double_t GetXLeft(Int_t point) const
Get errors to the left along X at point.
void SetSumFillStyle(Style_t style)
Set the fill style of the sumtematice error identified by ID.
virtual Wrapper_t Wrapper() const =0
Return function pointer to wrapper.
Double_t Svar(Double_t guess=0) const
void Scale(TF1 *f, Double_t s=1)
Scale graph by a constant.
TMultiGraph * GetMulti(Option_t *option="")
Get last drawn multigraph or create a new one.
A combiner that uses a linear approximation.
virtual Graph * StackError(Graph *g, Bool_t ignoreErr, Bool_t quad) const =0
Create new graph with stacked errors.
const char * GetKey(const char *key) const
Get (first) value of a key.
void SetSumOption(EDrawOption_t opt)
Set the draw option for summed errors.
HolderP2P(const char *name, const char *title, Bool_t rel, UInt_t opt, UInt_t id)
CTOR with name and title.
Double_t ChiTerm(Double_t guess, const Observation &r) const
Calculate the contribution variance to the with the guess .
HolderCommon(const char *name, const char *title, Bool_t rel, UInt_t opt, UInt_t id)
CTOR with name and title.
void SetSumLineWidth(Width_t width)
Set the line width of the sumtematice error identified by ID.
Double_t Integral(Double_t &error, Option_t *option="quad sum stat", UShort_t first=0, Short_t last=-1)
Calculate the intergral and error on integral of the graph.
Bool_t FindYandError(Double_t x, Bool_t cmn, Bool_t stat, Bool_t quad, Bool_t nosqrt, Double_t &y, Double_t &eyl, Double_t &eyh) const
Find Y value and errors corresponding X.
Double_t High() const
Upper bound.
void SetAttributes(Graph *g) const
Set attributes.
Bool_t fRelative
Relative error flag.
virtual void SetDOption(EDrawOption_t opt)
Set the draw option.
Double_t X(UShort_t nIter, Double_t lowest, Double_t highest)
Find best estimate of .
Bool_t IsCommon(Int_t id) const
virtual Double_t VarTerm(Double_t guess, const Observation &r) const =0
Calculate the contribution variance to the with the guess .
static void Export(const TSeqCollection *col, std::ostream &out, Option_t *option="H", Int_t nsign=0)
Export a set of data sets to a single table.
UInt_t DefineCommon(const char *title, Bool_t relative, Double_t eyl, Double_t eyh, EDrawOption_t option=kRect)
Define a common systematic error.
Bool_t fStatRelative
Whether statistical errors are relative.
void SetSumTitle(const char *title)
Set the title uses for summed errors.
HolderCommon & operator=(const HolderCommon &other)
Assignment operator.
virtual void Browse(TBrowser *b)
Browse this object.
Double_t StepW(Double_t guess, const Observation &r) const
Calculate the weight based on a guess of best .
Bool_t Symmetrize(GraphSysErr *other)
Symmetrice the other graph and store result here.
void SetSysError(Int_t id, Int_t i, Double_t ex, Double_t ey)
Set the systematic error identified by id on the ith data point.
void ClearUsed() const
Clear bit we set during the processing.
void SetPointError(Int_t i, Double_t exl, Double_t exh)
Set the X error (bin width) of the ith point.
Double_t GetCommonErrorYDown(Int_t id) const
Get the common systematic error.
Style_t GetCommonSumLineStyle() const
Get line style of sum systematic uncertainty.
TFitResultPtr Fit(TF1 *f1, Option_t *fitOption, Option_t *drawOption, Axis_t min=0, Axis_t max=0)
Fit a function to the data.
void SetSysError(Int_t id, Int_t i, Double_t exl, Double_t exh, Double_t eyl, Double_t eyh)
Set the systematic error identified by id on the ith data point.
Style_t GetSysFillStyle(Int_t id) const
Get fill style of systematic uncertainty.
Holder * Find(UInt_t id) const
Find any error.
Double_t W(const Observation &r) const
Calculate the weight.
void SetSysTitle(Int_t id, const char *name)
Set the systematic error title.
HolderP2P(const HolderP2P &other)
Copy CTOR.
Double_t GetX(Int_t point) const
Get symmetric errors along X at point.
void SetCommonSumLineStyle(Style_t style)
Set the line style of the sumtematice error identified by ID.
Double_t fUpper
Upper bound to use.
Color_t GetCommonSumLineColor() const
Get line color of sum systematic uncertainty.
Double_t F(Double_t guess, Double_t chi2) const
Calculate the where is current guess at the observation.
Double_t FWHM(Double_t &el, Double_t &eh, Double_t &xl, Double_t &xh) const
Calculate the full-width at half-maximum.
Double_t GetXRight(Int_t point) const
Get errors to the right along X at point.
Holder(const char *name, const char *title, Bool_t rel, UInt_t option, UInt_t id)
CTOR with name and title.
void Add(Double_t x, Double_t el, Double_t eh)
Add an observation.
Double_t GetYDown(Int_t i1, Int_t i2, Double_t ax) const
Get the errors downwards along Y between points i1 and i2.
static const char * FormatKey(const char *key)
Color_t GetCommonSumFillColor() const
Get fill color of sum systematic uncertainty.
Double_t GetYUp(Double_t y=0) const
Get the up error.
void StackPointError(Double_t y, UShort_t xMode, Bool_t ignoreErr, Bool_t quad, Double_t &exl, Double_t &exh, Double_t &eyl, Double_t &eyh) const
Stack up point errors.
Double_t GetSysErrorX(Int_t id, Int_t point) const
static const char * ExtractField(const TString &value, Int_t idx)
Extract a field from a string.
void Scale(Double_t s)
Scale graph by a constant.
const char * GetSumTitle() const
Get title of summed systematic error.
void Set(Double_t ey)
Set symmetric error.
Color_t GetSumLineColor() const
Get line color of sum systematic uncertainty.
Holder(const Holder &other)
Copy constructorr.
const char * FormatOption(UInt_t opt)
Parse options.
Bool_t IsStatRelative() const
Check if statistical errors are relative.
Double_t Vprime() const
Calculate.
GraphSysErr()
Default CTOR - use only for I/O.
void SetSumFillColor(Color_t color)
Set the fill color of the sumtematice error identified by ID.
EDrawOption_t
Drawing options.
void RemovePoint(Int_t i)
Remove a point from the graph.
Double_t fChi2
The final .
void SetCommonSumFillStyle(Style_t style)
Set the fill style of the sumtematice error identified by ID.
static GraphSysErr * Ratio(const GraphSysErr *num, const GraphSysErr *den, UInt_t flags=kRatioDefault, Double_t fac=1)
Take the ratio of 2 graphs.
TMultiGraph * MakeMulti(Option_t *option)
Make our stack.
void DoAdd(UShort_t xMode, Double_t curExl, Double_t curExh, Double_t curEyl, Double_t curEyh, Bool_t ignoreErr, Bool_t quad, Bool_t sqOld, Double_t &exl, Double_t &exh, Double_t &eyl, Double_t &eyh) const
Do add errors.
Double_t GetYDown(Int_t point) const
Get errors downward along Y at point.
void Set(Int_t point, Graph *g, Double_t ex, Double_t ey)
Set errors at point.
Double_t GetSysErrorYDown(Int_t id, Int_t point) const
Double_t GetX(Int_t p) const
HolderP2P * FindP2P(UInt_t id) const
Find a point-2-point error graph.
void FindFwhm(Int_t start, Int_t dir, Double_t ymax, Bool_t cmn, Bool_t stat, Bool_t quad, Int_t &i1, Int_t &i2) const
Find the full-width at half-maximum.
TList fPoint2Point
List of graphs.
const char * GetCommonSumTitle() const
Get title of summed systematic error.
Holder & operator=(const Holder &other)
Assignment operator.
void SetCommonSumLineWidth(Width_t width)
Set the line width of the sumtematice error identified by ID.
Bool_t FindYandError(Double_t x, Bool_t cmn, Bool_t stat, Bool_t quad, Bool_t nosqrt, Double_t &y, Double_t &eyl, Double_t &eyh, Double_t &seyl, Double_t &seyh) const
Find Y value and errors corresponding X.
Double_t GetY(Int_t point) const
Get symmetric errors along Y at point.
Bool_t IsRelative(Int_t id) const
Check if an error is relative.
static GraphSysErr * Import(std::istream &in, UShort_t idx=0, UShort_t *nIdx=0)
Import data from input formatted Durham database file.
Wrapper_t Wrapper() const
Return function pointer to wrapper.
void Clear(Option_t *option="")
Clear the internal data.
A combiner that uses a linear variance approximation.
Color_t GetSysFillColor(Int_t id) const
Get fill color of systematic uncertainty.
void SetSumLineColor(Color_t color)
Set the line color of the sumtematice error identified by ID.
void CopyKeys(const GraphSysErr *g, Option_t *option="fr")
Copy key/value and qualifiers from one graph to this graph.
Double_t GetStatError(Int_t point) const
virtual void Print(Option_t *option="") const
Print to standard output.
void SetXTitle(const char *title)
Set title on X axis.
Double_t Sprime() const
Calculate.
Double_t StepW(Double_t guess, const Observation &r) const
Calculate the weight based on a guess of best .
void SetCommonSumFillColor(Color_t color)
Set the fill color of the sumtematice error identified by ID.
A holder for Point-to-Point systematic errors.
virtual Bool_t IsFolder() const
Say that this should be shown as a folder.
virtual void ls(Option_t *option) const
static Double_t L(Double_t guess, Double_t x, Double_t el, Double_t eh)
Return the likely-hood function value at :
GraphSysErr * Reflect(Double_t x0=0) const
Make a copy of the graph, and reflect around x0.
static Double_t WrapL(Double_t *xp, Double_t *pp)
Wrap likely-hood function for ROOT.
TString fCommonSumTitle
Title on summed errors.
virtual void ls(Option_t *option="") const
List the content.