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 185 public TAttLine,
public TAttFill
284 :
TNamed(
"sysErrGraph",
"Data"),
383 fData =
static_cast<Graph*
>(other.
fData->Clone());
387 fCommon.SetName(other.GetName());
392 while ((common = static_cast<HolderCommon*>(nextC()))) {
399 while ((p2p = static_cast<HolderP2P*>(nextP()))) {
428 if (&other ==
this)
return *
this;
430 other.TNamed::Copy(*
this);
431 other.TAttMarker::Copy(*
this);
432 other.TAttLine::Copy(*
this);
433 other.TAttFill::Copy(*
this);
440 fData =
static_cast<Graph*
>(other.
fData->Clone());
462 while ((common = static_cast<HolderCommon*>(nextC())))
467 while ((p2p = static_cast<HolderP2P*>(nextP())))
504 gROOT->IndentLevel();
505 std::cout << GetName() <<
": " << GetTitle() << std::endl;
509 if (opt.IsNull())
return;
511 Bool_t all = opt.Contains(
"ALL");
512 Bool_t keys = all || opt.Contains(
"KEY");
513 Bool_t qual = all || opt.Contains(
"QUAL");
514 Bool_t sys = all || opt.Contains(
"SYS");
515 Bool_t cmn = sys || opt.Contains(
"COMMON");
516 Bool_t p2p = sys || opt.Contains(
"P2P");
517 Bool_t poi = all || opt.Contains(
"XY");
518 Bool_t attr = all || opt.Contains(
"ATTR");
519 Bool_t sum = opt.Contains(
"SUM");
521 gROOT->IncreaseDirLevel();
523 gROOT->IndentLevel();
524 std::cout <<
"Key/value pairs: " << std::endl;
525 gROOT->IncreaseDirLevel();
528 while ((kv = nextKV())) {
529 gROOT->IndentLevel();
530 std::cout <<
'"' << kv->GetName() <<
'"' <<
"\t" 531 <<
'"' << kv->GetTitle() <<
'"' <<
"\n";
533 gROOT->IndentLevel();
534 std::cout <<
"\"XTitle\"\t\"" <<
fXTitle <<
"\"\n";
535 gROOT->IndentLevel();
536 std::cout <<
"\"YTitle\"\t\"" <<
fYTitle <<
"\"\n";
538 gROOT->DecreaseDirLevel();
541 gROOT->IndentLevel();
542 std::cout <<
"Qualifier pairs: " << std::endl;
543 gROOT->IncreaseDirLevel();
546 while ((q = nextQ())) {
547 gROOT->IndentLevel();
548 std::cout <<
'"' << q->GetName() <<
'"' <<
"\t" 549 <<
'"' << q->GetTitle() <<
'"' <<
"\n";
552 gROOT->DecreaseDirLevel();
555 gROOT->IndentLevel();
556 Printf(
" [option: %3d line (c/s/w):%3d/%1d/%2d fill (c/s):%3d/%4d marker (c/s/s):%3d/%2d/%f]",
557 fDataOption, GetLineColor(), GetLineStyle(), GetLineWidth(),
558 GetFillColor(), GetFillStyle(),
559 GetMarkerColor(), GetMarkerStyle(), GetMarkerSize());
560 gROOT->IndentLevel();
561 Printf(
" [sum title: %s " 562 "option: %3d line (c/s/w):%3d/%1d/%2d fill (c/s):%3d/%4d",
569 gROOT->IndentLevel();
570 Printf(
" [common sum title: %s " 571 "option: %3d line (c/s/w):%3d/%1d/%2d fill (c/s):%3d/%4d",
582 gROOT->IndentLevel();
583 std::cout <<
"Commons: " << std::endl;
584 gROOT->IncreaseDirLevel();
587 while ((c = nextC())) {
588 gROOT->IndentLevel();
592 gROOT->DecreaseDirLevel();
596 gROOT->IndentLevel();
597 std::cout <<
"Point-to-point: " << std::endl;
598 gROOT->IncreaseDirLevel();
601 while ((p = nextP())) {
602 gROOT->IndentLevel();
606 gROOT->DecreaseDirLevel();
610 gROOT->IndentLevel();
611 std::cout <<
"Points: " << std::endl;
612 gROOT->IncreaseDirLevel();
614 hs.Form(
" %3s: %9s %9s %9s -> %9s %9s %9s",
615 "#",
"X",
"-dX",
"+dX",
"Y",
"-stat",
"+stat");
616 gROOT->IndentLevel();
619 hs.Form(
" %9s %9s",
"-sys",
"+sys");
625 while ((p = static_cast<HolderP2P*>(nextP()))) {
627 const char* post = (rel ?
"%" :
" ");
629 if (nm.Length() > 7) {
630 nm.Remove(4,nm.Length()-4);
633 hs.Form(
" -%8s%s +%8s%s", nm.Data(), post, nm.Data(), post);
637 std::cout << std::endl;
639 gROOT->IndentLevel();
645 s.Form(
" %3d: %+8f -%7f +%7f -> %+8f -%7f +%7f",
651 sSum.Form(
" -%7f +%7f", eyl, eyh);
658 while ((p = static_cast<HolderP2P*>(nextP()))) {
660 Double_t fac = (rel ? (TMath::Abs(y) > 1e-9 ? 100/y : 0) : 1);
661 const char* post = (rel ?
"%" :
" ");
662 s.Form(
" -%7f%s +%7f%s",
664 fac * p->
GetYUp(i) , post);
669 std::cout << std::endl;
671 gROOT->DecreaseDirLevel();
673 gROOT->DecreaseDirLevel();
795 Bool_t clear = opt.Contains(
"CLEAR");
796 Bool_t axis = opt.Contains(
"AXIS");
806 fDrawn->Draw(axis ?
"A" :
"");
834 Axis_t min=0, Axis_t max=0)
838 Bool_t clear = dOpt.Contains(
"CLEAR");
839 Bool_t axis = dOpt.Contains(
"AXIS");
848 !
fDrawn->GetListOfGraphs() ||
849 !
fDrawn->GetListOfGraphs()->First())
850 return TFitResultPtr(-1);
852 Graph* g =
static_cast<Graph*
>(
fDrawn->GetListOfGraphs()->First());
856 Bool_t noStore = fOpt.Contains(
"N");
857 Bool_t noDraw = fOpt.Contains(
"0");
858 Bool_t range = fOpt.Contains(
"R");
860 TFitResultPtr r = g->Fit(f1, fOpt.Data(),
"", min, max);
865 if (min < max && !range) f1->SetRange(min, max);
866 fDrawn->GetListOfFunctions()->Add(f1);
870 if (!noStore && !noDraw) {
871 fDrawn->Draw(axis ?
"A" :
"");
901 TFitResultPtr
Fit(
const char* formula,
903 Axis_t min=0, Axis_t max=0)
906 Bool_t linear = fname.Contains(
"++");
908 if (linear) f1 =
new TF1(formula,formula,min,max);
910 f1 =
static_cast<TF1*
>(gROOT->GetFunction(formula));
911 if (!f1) Warning(
"Fit",
"Unknown function %s", formula);
915 return Fit(f1, fitOption, drawOption, min, max);
944 while ((cmn = static_cast<HolderCommon*>(cNext()))) {
959 while ((p2p = static_cast<HolderP2P*>(pNext()))) {
961 (TMath::Abs(y) < 1e-9) ? 0 : 1/y : 1/g);
977 while ((cmn = static_cast<HolderCommon*>(cNext()))) {
990 while ((p2p = static_cast<HolderP2P*>(pNext()))) {
992 (TMath::Abs(y) < 1e-9) ? 0 : 1/y :
1016 TList sharedC; sharedC.SetOwner();
1018 TIter oNext(others);
1030 while ((other = static_cast<GraphSysErr*>(oNext()))) {
1032 nX = TMath::Max(nX,n);
1041 while ((cmn = static_cast<HolderCommon*>(cNext()))) {
1049 while ((p2p = static_cast<HolderP2P*>(pNext()))) {
1050 sharedP.Add(p2p->Clone());
1061 TObjLink* cur = sharedC.FirstLink();
1068 Info(
"Average",
"Common systematic %s not found in %s",
1069 o->GetTitle(), other->GetName());
1070 other->
Print(
"sys");
1071 TObjLink* keep = cur->Next();
1072 TObject* obj = sharedC.Remove(cur);
1075 if (obj)
delete obj;
1082 cur = sharedP.FirstLink();
1089 Info(
"Average",
"P2P systematic %s not found in %s",
1090 o->GetTitle(), other->GetName());
1091 TObjLink* keep = cur->Next();
1092 TObject* obj = sharedP.Remove(cur);
1095 if (obj)
delete obj;
1106 TIter nextC(&sharedC);
1108 while ((com = static_cast<HolderCommon*>(nextC()))) {
1121 while ((other = static_cast<GraphSysErr*>(oNext()))) {
1124 Error(
"Average",
"This should NOT happen");
1125 other->
Print(
"sys");
1136 if (nonSh || !sep) {
1156 TIter nextP(&sharedP);
1160 while ((p2p = static_cast<HolderP2P*>(nextP()))) {
1166 Info(
"Average",
"Shared point-to-point error %s", p->GetTitle());
1173 while ((other = static_cast<GraphSysErr*>(oNext())) && off < 64) {
1176 Error(
"Average",
"This should NOT happen");
1179 mask |= ((op->GetUniqueID() & 0x3F) << off);
1186 "Some shared point-to-point errors could not be encoded " 1187 "becasue we have too many (%d>%d) input graphs",
1188 others->GetEntries(), 64/dOf);
1211 while ((other = static_cast<GraphSysErr*>(oNext()))) {
1215 while ((p2p = static_cast<HolderP2P*>(oNextP())) && off < 64) {
1230 mask = &(mp2p[pId]);
1233 *mask |= ((p2p->GetUniqueID() & 0x3F) << off);
1239 "Some shared point-to-point errors could not be encoded " 1240 "becasue we have too many (%d>%d) input graphs",
1241 others->GetEntries(), 64/dOf);
1267 while ((other = static_cast<GraphSysErr*>(oNext()))) {
1268 for (
Int_t i = other->GetUniqueID(); i < other->
GetN(); i++) {
1269 if (other->
GetX(i) <= x) {
1273 if (other->
GetX(i) < nextX) {
1275 nextX = other->
GetX(i);
1287 if (nextX >= xMax) {
1292 if (cnt >= xa.GetSize()) {
1293 Warning(
"Average",
"increasing size of X cache");
1306 }
while (cnt < 1000);
1317 for (
Int_t i = 0; i < cnt; i++) {
1321 Double_t nexl = TMath::Abs(xi - (i == 0 ? xa[i+1] : xa[i-1]))/2;
1322 Double_t nexh = TMath::Abs(xi - (i + 1 == cnt ? xa[i-1] : xa[i+1]))/2;
1323 Double_t exl = TMath::Min(texl, nexl);
1324 Double_t exh = TMath::Min(texh, nexh);
1348 TArrayI ai1(others->GetEntries());
1349 TArrayI ai2(others->GetEntries());
1350 TArrayD ax(others->GetEntries());
1351 while ((other = static_cast<GraphSysErr*>(oNext()))) {
1357 Double_t y, eyl, eyh, wyl, wyh, syl, syh;
1360 if (fret < -1) { j++;
continue; }
1362 y = other->
GetYandError(fret,cmn,stat,quad,nosqrt,eyl, eyh, wyl, wyh);
1372 eyl1,eyh1,wyl1,wyh1);
1374 eyl2,eyh2,wyl2,wyh2);
1381 y = y1 + ax[j] * (y2-y1);
1382 eyl = eyl1 + ax[j] * (eyh1-eyl1);
1383 eyh = eyh2 + ax[j] * (eyh2-eyl2);
1384 wyl = wyl1 + ax[j] * (wyh1-wyl1);
1385 wyh = wyh2 + ax[j] * (wyh2-wyl2);
1386 syl = syl1 + ax[j] * (syh1-syl1);
1387 syh = syh2 + ax[j] * (syh2-syl2);
1390 centroid.
Add(y, wyl, wyh);
1391 error.
Add(y, eyl, eyh);
1392 stats.
Add(y, syl, syh);
1428 for (
Int_t j = 1; j < mp2p.GetSize(); j++) {
1430 if (mask == 0)
continue;
1434 Warning(
"Average",
"No target point-to-point error at %d for id=%d",
1452 while ((other = static_cast<GraphSysErr*>(oNext()))) {
1453 if (ai1[k] == -1 && ai2[k] == -1) {
1460 Int_t sid = ((rem >> dOf*k) & 0x3f);
1471 Warning(
"Average",
"Couldn't find point-to-point error %d (%s)" 1472 "in graph %d (%s) - should not happen",
1473 sid, tp2p->GetTitle(), k, other->GetName());
1479 if (ai1[k] == ai2[k]) {
1481 sy = other->
GetY(ai1[k]);
1489 sy = sy1 + ax[k] * (sy2-sy1);
1490 seyl = sp2p->
GetYDown(ai1[k],ai2[k],ax[k]);
1491 seyh = sp2p->
GetYUp(ai1[k],ai2[k],ax[k]);
1495 sc.
Add(sy, seyl, seyh);
1508 while ((other = static_cast<GraphSysErr*>(oNext())))
1529 if (last < 0) last =
GetN()-1;
1532 TString opts(option); opts.ToLower();
1533 Bool_t cmn = opts.Contains(
"comm");
1534 Bool_t stat = opts.Contains(
"stat");
1535 Bool_t quad = opts.Contains(
"quad");
1537 for (
Short_t i = first; i <= last; i++) {
1550 if (prv > x1) x1 -= (prv-x1)/2;
1551 if (nxt < x2) x2 -= (x2-nxt)/2;
1553 if (wdt < 0)
continue;
1555 err2 += TMath::Power(eym*wdt,2);
1557 error = TMath::Sqrt(err2);
1588 if (!denom->
FindYandError(x,
false,
true,
true,
false, dY, dEyl, dEyh))
1590 if (TMath::Abs(dY) < 1e-9)
1593 nY = num->
GetYandError(i,
false,
true,
true,
false,nEyl, nEyh);
1641 while ((comN = static_cast<HolderCommon*>(nextNC()))) {
1657 eyl = TMath::Min(nEyl, dEyl);
1658 eyh = TMath::Min(nEyh, dEyh);
1661 eyl = TMath::Max(nEyl, dEyl);
1662 eyh = TMath::Max(nEyh, dEyh);
1665 eyl = TMath::Sqrt(TMath::Abs(dEyl*dEyl-nEyl*nEyl));
1666 eyh = TMath::Sqrt(TMath::Abs(dEyh*dEyh-nEyh*nEyh));
1668 const char* post = (rel ?
"%" :
"");
1672 ::Info(
"Ratio",
"Cancelling the common systematic error %s " 1673 "between numerator (-%f%s +%f%s) " 1674 "and denominator (-%f%s +%f%s): -%f%s + %f%s",
1676 pfc*nEyl, post, pfc*nEyh, post,
1677 pfc*dEyl, post, pfc*dEyh, post,
1678 pfc*eyl, post, pfc*eyh, post);
1687 "Common numerator systematic %s will be added to blob",
1706 while ((comD = static_cast<HolderCommon*>(nextDC()))) {
1707 if (comD->TestBit(
kUsedBit))
continue;
1711 "Common denominator systematic %s will be added to blob",
1717 ::Info(
"Ratio",
"Propagating common sysmatic %s to ratio",
1756 while ((p2pN = static_cast<HolderP2P*>(nextNP()))) {
1770 mask = ((p2pD->GetUniqueID() & 0xFF) << 16);
1776 ::Info(
"Ratio",
"Cancelling the p2p systamtic error %s " 1777 "between numerator and denominator",
1788 mask |= (((p2pN->GetUniqueID() & 0xFF) << 8) |
1793 shared[sCnt] = mask;
1801 while ((p2pD = static_cast<HolderP2P*>(nextDP()))) {
1812 Int_t mask = (((p2pD->GetUniqueID() & 0xFF) << 16) |
1816 shared[sCnt] = mask;
1830 for (
Int_t i = 0; i < num->
GetN(); i++) {
1843 ::Warning(
"Ratio",
"Next point %d (%f) not found in denominator",
1854 dY = den->
GetYandError(di,cmn,stat,quad,nosqrt,dEyl,dEyh);
1866 dY = y1 + daX * (y2 - y1);
1867 dEyl = eyl1 + daX * (eyl2 - eyl1);
1868 dEyh = eyh1 + daX * (eyh2 - eyh1);
1876 Double_t rY = (dY != 0 ? nY/dY : 0);
1884 if (TMath::Abs(rY) > 1.e-9) {
1892 sEyl = TMath::Sqrt(rY*rY*(snEyl*snEyl/nY/nY+sdEyl*sdEyl/dY/dY));
1893 sEyh = TMath::Sqrt(rY*rY*(snEyh*snEyh/nY/nY+sdEyh*sdEyh/dY/dY));
1904 Double_t rdEyl = (dY != 0 ? dEyl/dY : 0);
1905 Double_t rdEyh = (dY != 0 ? dEyh/dY : 0);
1912 eyl = TMath::Max(nEyl, dEyl);
1913 eyh = TMath::Max(nEyh, dEyh);
1920 eyl = TMath::Min(nEyl, dEyl);
1921 eyh = TMath::Min(nEyh, dEyh);
1927 Double_t rnEyl = (nY != 0 ? nEyl/nY : 0);
1928 Double_t rnEyh = (nY != 0 ? nEyh/nY : 0);
1929 Double_t rdEyl = (dY != 0 ? dEyl/dY : 0);
1930 Double_t rdEyh = (dY != 0 ? dEyh/dY : 0);
1931 Double_t reyl = TMath::Sqrt(rnEyl*rnEyl+rdEyl*rdEyl);
1932 Double_t reyh = TMath::Sqrt(rnEyh*rnEyh+rdEyh*rdEyh);
1950 for (
Int_t im = 0; im < shared.GetSize(); im++) {
1951 Int_t mask = shared[im];
1952 if (mask <= 0)
break;
1953 Int_t rId = ((mask >> 0) & 0xFF);
1954 Int_t nId = ((mask >> 8) & 0xFF);
1955 Int_t dId = ((mask >> 16) & 0xFF);
1956 if (nId == 0 && dId == 0) {
1957 ::Warning(
"Ratio",
"Both numerator and denominator IDs are 0");
1968 Double_t lfc = (crel ? (TMath::Abs(dY) > 1e-9 ? 1/dY : 0) : 1);
1969 pdEyl = pD->
GetYDown(di1, di2, daX) * lfc;
1970 pdEyh = pD->
GetYUp (di1, di2, daX) * lfc;
1974 Double_t lfc = (crel ? (TMath::Abs(nY) > 1e-9 ? 1/nY : 0) : 1);
1976 pnEyh = pN->
GetYUp (i) * lfc;
1982 Double_t lfc = (!crel ? (TMath::Abs(dY) > 1e-9 ? 1/dY : 0) : 1);
1988 else if (dId == 0) {
2001 peyl = TMath::Min(nEyl, dEyl) * lfc;
2002 peyh = TMath::Min(nEyh, dEyh) * lfc;
2005 peyl = TMath::Min(nEyl, dEyl) * lfc;
2006 peyh = TMath::Min(nEyh, dEyh) * lfc;
2009 peyl = TMath::Sqrt(TMath::Abs(pnEyl*pnEyl-pdEyl*pdEyl)) * lfc;
2010 peyh = TMath::Sqrt(TMath::Abs(pnEyh*pnEyh-pdEyh*pdEyh)) * lfc;
2016 lfc = (rel ? 1 : rY);
2017 ret->
SetSysError(rId, cnt, 0, 0, lfc*peyl, lfc*peyh);
2029 ::Warning(
"",
"No common points found");
2045 while ((oe = nextC())) {
2050 while ((oe = nextP())) {
2091 if (cnt <= 0)
return -1;
2097 if (a1e2.GetSum() <= 0 && a2e2.GetSum()) {
2098 ::Warning(
"ChisquareTest",
"No errors");
2105 for (
Int_t i = 0; i < cnt; i++) {
2109 dfMax = TMath::Max(dfMax, TMath::Abs(sr1-sr2));
2114 z = dfMax * TMath::Sqrt(se1 * se2 / (se1 + se2));
2115 return TMath::KolmogorovProb(z);
2144 for (
Int_t i = 0; i < g1->
GetN(); i++) {
2152 if (!
NextPoint(i, g1, g2, x, y1, e1yl, e1yh, y2, e2yl, e2yh)) {
2153 ::Warning(
"ChisquareTest",
"Next point - %d %f not found", i, x);
2157 Double_t e1y2 = TMath::Power(TMath::Max(e1yl,e1yh), 2);
2158 Double_t e2y2 = TMath::Power(TMath::Max(e2yl,e2yh), 2);
2168 ::Warning(
"CacheGraphs",
"No common points found");
2216 if (cnt <= 0)
return -1;
2220 if (type ==
kModelModel && (a1e2.GetSum() <= 0 && a2e2.GetSum())) {
2221 ::Warning(
"ChisquareTest",
"No errors");
2229 for (
Int_t i = 0; i < ndf; i++) {
2233 Double_t delta = s2 * a1y[i] - s1 * a2y[i];
2234 chi2 += delta * delta / sum;
2238 Double_t v1 = s2 * a1y[i] - s1 * a2e2[i];
2239 Double_t v2 = v1 * v1 + 4 * s2 * s2 * a1y[i] * a2e2[i];
2240 Double_t pp = (v1 + v2) / (2 * s2 * s2);
2245 chi2 += d1 * d1 / p1;
2246 if (a2e2[i] > 0) chi2 += d2 * d2 / a2e2[i];
2251 Double_t delta = s2 * a1y[i] - s1 * a2y[i];
2252 chi2 += delta * delta /
sigma;
2257 chi2 += delta * delta / a1e2[i];
2261 ::Warning(
"ChisquareTest",
"Should not happen");
2279 if (i < 0 || i >=
GetN())
return;
2280 fData->RemovePoint(i);
2283 while ((p2p = static_cast<HolderP2P*>(next()))) {
2284 p2p->
fGraph->RemovePoint(i);
2296 if (i == j && !reflect)
return;
2300 while ((p2p = static_cast<HolderP2P*>(next()))) {
2336 while ((cmn = static_cast<HolderCommon*>(cNext()))) {
2341 Error(
"Symmetrice",
"Common error %s not found in %s",
2342 cmn->GetTitle(), cpy->GetName());
2353 if (cmn->
fEyl <= 0 && cmn->
fEyh <= 0) {
2360 if (!cpy)
return false;
2368 for (
Int_t i = 0; i < n; i++) {
2369 if (used[i] >= 0 && used[i] != i) {
2410 y2 = cpy->
GetYandError(j,
true,
false,
true,
false,eyl2,eyh2);
2420 cpy->
FindYandError(-x1,
true,
true,
true,
false,y2,eyl2,eyh2,seyl2,seyh2);
2425 if ((eyh1+eyl1) > 1e-9 && (eyh2+eyl2) > 1e-9) {
2426 Double_t s1 = 2 * eyl1 * eyh1 / (eyh1 + eyl1);
2427 Double_t sp1 = (eyh1 - eyl1) / (eyh1 + eyl1);
2428 Double_t w1 = .5 * TMath::Power(s1+y1*sp1, 3) / s1;
2429 Double_t s2 = 2 * eyl2 * eyh2 / (eyh2 + eyl2);
2430 Double_t sp2 = (eyh2 - eyl2) / (eyh2 + eyl2);
2431 Double_t w2 = .5 * TMath::Power(s2+y2*sp2, 3) / s2;
2435 newY = (y1*w1+y2*w2) / sumW;
2436 newV = TMath::Sqrt((w1*w1*s1*s1+w2*w2*s2*s2) / sumW / sumW);
2439 Double_t seyl = TMath::Sqrt(seyl1*seyl1+seyl2*seyl2);
2440 Double_t seyh = TMath::Sqrt(seyh1*seyh1+seyh2*seyh2);
2464 Bool_t load = opt.Contains(
"load"); opt.ReplaceAll(
"load",
"");
2466 TPRegexp regex(
"func=([a-zA-z][a-zA-Z0-9_]*)");
2469 if (toks->GetEntriesFast() > 1)
2470 funcName = toks->At(1)->GetName();
2471 if (toks->GetEntriesFast() > 0)
2472 opt.ReplaceAll(toks->At(0)->GetName(),
"");
2478 if (!funcName.IsNull())
2479 out <<
"TObject* " << funcName <<
"(Option_t* o=\"\")\n";
2482 out <<
" // Load class\n" 2483 <<
" if (!gROOT->GetClass(\"GraphSysErr\"))\n" 2484 <<
" gROOT->LoadMacro(\"GraphSysErr.C+\");\n";
2485 out <<
" GraphSysErr* g = new GraphSysErr(\"" 2486 << GetName() <<
"\",\"" << GetTitle() <<
"\"," 2487 <<
GetN() <<
");\n";
2489 out <<
" // Point options\n" 2490 <<
" g->SetMarkerStyle(" << GetMarkerStyle() <<
");\n" 2491 <<
" g->SetMarkerColor(" << GetMarkerColor() <<
");\n" 2492 <<
" g->SetMarkerSize(" << GetMarkerSize() <<
");\n" 2493 <<
" g->SetLineStyle(" << GetLineStyle() <<
");\n" 2494 <<
" g->SetLineColor(" << GetLineColor() <<
");\n" 2495 <<
" g->SetLineWidth(" << GetLineWidth() <<
");\n" 2496 <<
" g->SetFillStyle(" << GetFillStyle() <<
");\n" 2497 <<
" g->SetFillColor(" << GetFillColor() <<
");\n" 2498 <<
" g->SetXTitle(\"" <<
fXTitle <<
"\");\n" 2499 <<
" g->SetYTitle(\"" <<
fYTitle <<
"\");\n" 2501 <<
" // Sum options\n" 2502 <<
" g->SetSumOption(" <<
fSumOption <<
");\n" 2503 <<
" g->SetSumTitle(\"" <<
fSumTitle <<
"\");\n" 2504 <<
" g->SetSumLineStyle(" <<
fSumLine.GetLineStyle() <<
");\n" 2505 <<
" g->SetSumLineColor(" <<
fSumLine.GetLineColor() <<
");\n" 2506 <<
" g->SetSumLineWidth(" <<
fSumLine.GetLineWidth() <<
");\n" 2507 <<
" g->SetSumFillStyle(" <<
fSumFill.GetFillStyle() <<
");\n" 2508 <<
" g->SetSumFillColor(" <<
fSumFill.GetFillColor() <<
");\n" 2511 <<
" g->SetCommonSumLineStyle(" <<
fCommonSumLine.GetLineStyle()<<
");\n" 2512 <<
" g->SetCommonSumLineColor(" <<
fCommonSumLine.GetLineColor()<<
");\n" 2513 <<
" g->SetCommonSumLineWidth(" <<
fCommonSumLine.GetLineWidth()<<
");\n" 2514 <<
" g->SetCommonSumFillStyle(" <<
fCommonSumFill.GetFillStyle()<<
");\n" 2515 <<
" g->SetCommonSumFillColor(" <<
fCommonSumFill.GetFillColor()<<
");\n" 2516 <<
" // Stat options\n" 2520 while ((cmn = static_cast<HolderCommon*>(nextC())))
2524 while ((p2p = static_cast<HolderP2P*>(nextP())))
2527 out <<
" // " << n <<
" points\n";
2529 for (
Int_t i = 0; i < n; i++) {
2531 out <<
" g->SetPoint(" << i <<
',' <<
GetX(i) <<
',' << y <<
");\n" 2532 <<
" g->SetPointError(" << i <<
',' <<
GetErrorXLeft(i) <<
',' 2534 <<
" g->SetStatError(" << i <<
',' 2538 while ((p2p = static_cast<HolderP2P*>(nextP()))) {
2539 Int_t id = p2p->GetUniqueID();
2541 out <<
" g->SetSysError(" <<
id <<
',' << i <<
',' 2548 out <<
" if (o && o[0] != '\\0') {\n" 2549 <<
" g->Draw(o);\n";
2551 out <<
" if (g->GetMulti() && g->GetMulti()->GetHistogram()) {\n" 2552 <<
" g->GetMulti()->GetHistogram()->SetMinimum(" 2553 <<
fDrawn->GetHistogram()->GetMinimum() <<
");\n" 2554 <<
" g->GetMulti()->GetHistogram()->SetMaximum(" 2555 <<
fDrawn->GetHistogram()->GetMaximum() <<
");" 2559 if (!funcName.IsNull()) out <<
" return g;\n";
2569 std::ofstream out(fileName);
2571 funcName.ReplaceAll(
".C",
"");
2573 <<
"// Generated by GraphSysErr.C\n" 2619 Bool_t header = opt.Contains(
"h");
2620 Bool_t sysNames = opt.Contains(
"s");
2621 Bool_t comment = opt.Contains(
"c");
2631 while ((q = nextQ())) {
2633 if (k.EqualTo(
"RE") || k.EqualTo(
"title", TString::kIgnoreCase))
2635 out <<
FormatKey(
"qual") << q->GetName() <<
" : " 2636 << q->GetTitle() << std::endl;
2639 if (!hasTitle && title)
2640 out <<
FormatKey(
"qual") <<
"RE : " << GetTitle() << std::endl;
2643 const char* fill =
"<please fill in>";
2647 out <<
FormatKey(
"xheader") << xTit <<
"\n" 2648 <<
FormatKey(
"yheader") << yTit << std::endl;
2653 while ((holderCommon = static_cast<HolderCommon*>(nextC()))) {
2659 out <<
":" << holderCommon->GetTitle() << std::endl;
2663 out <<
FormatKey(
"data") <<
" x : y" << std::endl;
2665 for (
Int_t i = 0; i < n; i++) {
2669 out <<
"*dataend:\n" 2670 <<
"# End of dataset\n" << std::endl;
2680 if (val.IsNull()) {val = fill;
return; }
2681 if (!val.Contains(
"#") && !val.Contains(
"\\"))
return;
2683 if (val[0] !=
'$') val.Prepend(
"$");
2684 if (val[val.Length()-1]!=
'$') val.Append(
"$");
2685 val.ReplaceAll(
"#",
"\\");
2701 static void Export(
const TSeqCollection* col,
2706 if (col->GetEntries() < 1)
return;
2711 Bool_t alsoTop = opt.Contains(
"h");
2712 Bool_t alsoCmt = opt.Contains(
"c");
2713 Bool_t alsoNme = opt.Contains(
"s");
2714 Bool_t alsoTit = opt.Contains(
"t");
2728 TIter nextCheck(col);
2730 while ((o = nextCheck())) {
2731 if (!o->IsA()->InheritsFrom(GraphSysErr::Class()))
continue;
2735 nPoints = first->
GetN();
2739 if (gse->
GetN() != nPoints) {
2740 Int_t nTmp = TMath::Min(gse->
GetN(), nPoints);
2741 ::Warning(
"Export",
"Incompatible number of points %d in %s" 2742 "using only %d of them",
2743 gse->
GetN(), gse->GetName(), nTmp);
2748 for (
Int_t i = 0; i < nPoints; i++) {
2755 if (TMath::Abs(x1-xT) > tol ||
2756 (exl1 > tol && TMath::Abs(exl1-exlT) > tol) ||
2757 (exh1 > tol && TMath::Abs(exh1-exhT) > tol)) {
2758 ::Warning(
"Export",
"X--coordinate of %s @ point %d: %f (+%f,-%f) " 2759 "incompatible [%f (+%f,-%f)]",
2760 gse->GetTitle(), i, xT, exhT, exlT, x1, exh1, exl1);
2772 while ((q = nextQ())) {
2778 TIter nextCmn(&(gse->
fCommon));
2780 while ((oCmn = nextCmn())) {
2781 if (commons.FindObject(oCmn->GetTitle()))
continue;
2782 TObjString* cmn =
new TObjString(oCmn->GetTitle());
2783 if (gse == first) cmn->SetUniqueID(gse->
FindId(oCmn->GetTitle()));
2791 TIter nextCmn(&(commons));
2793 while ((oCmn = nextCmn())) {
2794 TString oNme(oCmn->GetName());
2800 TIter nextG(&toExport);
2801 while ((gse = static_cast<GraphSysErr*>(nextG()))) {
2817 if ((ecl1 > tol && TMath::Abs(ecl1-eclT) > tol) ||
2818 (ech1 > tol && TMath::Abs(ech1-echT) > tol)) {
2827 #if INCOMPAT_CMN_AS_QUAL 2831 oCmn->SetBit(BIT(14), found);
2835 if (found)
continue;
2840 while ((gse = static_cast<GraphSysErr*>(nextG()))) {
2848 std::stringstream s;
2850 val = s.str().c_str();
2864 ::Error(
"Export",
"No points to write");
2867 if (toExport.GetEntries() <= 0) {
2868 ::Error(
"Export",
"No graphs to export");
2872 ::Error(
"Export",
"Didn't get the first graph");
2882 TIter nextQ(&quals);
2884 while ((ql = static_cast<TList*>(nextQ()))) {
2886 if (k.EqualTo(
"RE") || k.EqualTo(
"title", TString::kIgnoreCase))
2888 out <<
FormatKey(
"qual") << ql->GetName();
2889 for (
Int_t i = 0; i < toExport.GetEntries(); i++) {
2892 if (qv) v = qv->GetName();
2897 if (!hasTitle && alsoTit) {
2899 for (
Int_t i = 0; i < toExport.GetEntries(); i++)
2900 out <<
": " << toExport.At(i)->GetTitle();
2906 const char* fill =
"<please fill in>";
2907 const char* fields[] = {
"xheader",
"yheader", 0 };
2908 const char** pfld = fields;
2911 TIter nextSpec(&toExport);
2913 while ((gse = static_cast<GraphSysErr*>(nextSpec()))) {
2915 if ((*pfld)[0] ==
'x') val = gse->
fXTitle;
2916 else if ((*pfld)[0] ==
'y') val = gse->
fYTitle;
2918 out << (one ?
"" :
":") << val;
2919 if ((*pfld)[0] ==
'x')
break;
2927 TIter nextC(&commons);
2928 while ((oCmn = nextC())) {
2932 #if INCOMPAT_CMN_AS_QUAL 2933 if (!oCmn->TestBit(BIT(14))) {
2935 "Common systematic error \"%s\" represented by qual",
2937 out <<
"- : " << tit << std::endl;
2945 out <<
" : "<< tit << std::endl;
2947 out << tit << std::flush;
2948 TIter next(&toExport);
2949 while ((gse = static_cast<GraphSysErr*>(next()))) {
2957 out <<
":" << tit << std::endl;
2962 out <<
FormatKey(
"data") << data << std::endl;
2963 for (
Int_t i = 0; i < nPoints; i++) {
2964 TIter next(&toExport);
2966 while ((gse = static_cast<GraphSysErr*>(next()))) {
2972 out <<
"*dataend:\n" 2973 <<
"# End of dataset\n" << std::endl;
2995 std::ifstream in(fileName.Data());
2997 ::Warning(
"Import",
"Failed to open \"%s\"", fileName.Data());
3008 int cur = in.tellg();
3010 in.seekg(cur, in.beg);
3011 if (!(g =
Import(in, sub, &nIdx)))
break;
3013 ::Info(
"Import",
"Imported %d of %d", sub, nIdx);
3014 g->SetName(Form(
"ds_%d_%d",
id, sub-1));
3015 if (!first) first = g;
3019 }
while(sub < nIdx);
3021 }
while (!in.eof());
3061 if (line.IsNull())
continue;
3062 if (line[0] ==
'#')
continue;
3063 if (line[0] ==
'*') {
3064 Int_t colon = line.Index(
":");
3065 if (colon == kNPOS)
continue;
3066 Int_t len = line.Length()-colon-1;
3067 TString value = line(colon+1,len);
3069 last = line(1,colon-1);
3071 ::Info(
"Import",
"Got a key '%s' -> '%s'", last.Data(), value.Data());
3073 if (last.BeginsWith(
"dataset", TString::kIgnoreCase)) {
3078 else if (last.BeginsWith(
"dataend", TString::kIgnoreCase)) {
3087 else if (last.BeginsWith(
"qual", TString::kIgnoreCase)) {
3091 quals.Add(
new TObjString(value));
3093 else if (last.BeginsWith(
"xheader", TString::kIgnoreCase))
3095 else if (last.BeginsWith(
"yheader", TString::kIgnoreCase))
3097 else if (last.BeginsWith(
"dserror", TString::kIgnoreCase)) {
3100 ::Info(
"Import",
"Got common error line: '%s'", line.Data());
3101 TObjArray* tokens = value.Tokenize(
":");
3105 if (rel) { el /= 100.; eh /= 100.; }
3116 else if (last.BeginsWith(
"data", TString::kIgnoreCase)) {
3118 ::Info(
"Import",
"Got start of data line: '%s'", line.Data());
3121 TObjArray* tokens = value.Tokenize(
":");
3123 *nIdx = tokens->GetEntriesFast();
3126 if (tokens->GetEntriesFast() > 2 && idx < 1) {
3128 ::Warning(
"Import",
"Can only import one data set at a time, " 3129 "selecting the %d column", idx);
3131 else if (idx >= 1 && idx >= tokens->GetEntriesFast()) {
3132 ::Warning(
"Import",
"column %d not available for this data set",
3143 ::Info(
"Import",
"Got pair line '%s' (%s -> %s)", line.Data(),
3144 last.Data(), value.Data());
3145 keys.Add(
new TNamed(last, value));
3151 ::Info(
"Import",
"Got a possible contiuation line '%s'", line.Data());
3158 ::Info(
"Import",
"Got some other line: '%s'", line.Data());
3160 TNamed* ptr =
static_cast<TNamed*
>(keys.FindObject(last));
3166 if (!tt.EndsWith(
" ") && !tt.EndsWith(
"\t") && !tt.EndsWith(
"\n"))
3180 if (idx < 1) idx = 1;
3183 ::Info(
"Import",
"Got a data line: '%s'", line.Data());
3185 if (tokens->GetEntriesFast() < idx+1) {
3186 ::Warning(
"Import",
"Too few columns %d<%0d in line: %s",
3187 tokens->GetEntriesFast(), idx+1, line.Data());
3191 TString& xCol =
static_cast<TObjString*
>(tokens->At(0))->String();
3192 TString& yCol =
static_cast<TObjString*
>(tokens->At(idx))->String();
3194 ::Info(
"Import",
"xColumn: '%s', yColumn: '%s'",
3195 xCol.Data(), yCol.Data());
3201 Int_t chop = yCol.Last(
'(');
3202 if (chop != kNPOS) {
3203 yCol.Remove(chop, yCol.Length()-chop);
3207 ::Info(
"Import",
"xColumn: '%s', yColumn: '%s'",
3208 xCol.Data(), yCol.Data());
3210 if (xCol.IsNull()) {
3211 ::Warning(
"Import",
"Empty X column in line: %s", line.Data());
3215 if (yCol.IsNull()) {
3216 ::Warning(
"Import",
"Empty Y column in line: %s", line.Data());
3223 ::Warning(
"Import",
"Failed to import X value in line: %s",line.Data());
3229 ::Warning(
"Import",
"Failed to import X value in line: %s",line.Data());
3241 Int_t lparen = yFull.Index(
"(");
3242 Int_t rparen = yFull.Index(
")");
3243 if (lparen == rparen) {
3247 TString rem = yFull(lparen+1, rparen-lparen-1);
3249 ::Info(
"Import",
"Got systematic errors: '%s'", rem.Data());
3253 for (
Int_t i = 0; i < stok->GetEntriesFast(); i++) {
3255 if (!t.BeginsWith(
"SYS=",TString::kIgnoreCase)) {
3256 ::Warning(
"Import",
"Ignoring unknown spec %s (@ %d) in %s",
3257 t.Data(), i, rem.Data());
3261 if (t[t.Length()-1] ==
',') t.Remove(t.Length()-1,1);
3268 Int_t colon = t.Index(
":");
3269 TString nam(Form(
"sys%d", isys));
3270 if (colon != kNPOS) nam = t(colon+1, t.Length()-colon-1);
3281 if (p->
IsRelative()) { el /= 100.; eh /= 100.; }
3288 }
while (!in.eof());
3292 if (!rxtit.IsNull()) ret->
SetXTitle(rxtit);
3293 if (!rytit.IsNull()) ret->
SetYTitle(rytit);
3296 TIter nextQ(&quals);
3298 while ((qual = nextQ())) {
3308 k.EqualTo(
"title", TString::kIgnoreCase))) {
3315 while ((pair = nextK())) {
3316 ret->
SetKey(pair->GetName(),pair->GetTitle());
3318 if (!hasTitle && (k.EqualTo(
"location"))) {
3323 if (!hasTitle) ret->
SetTitle(
"Title");
3371 TString name(Form(
"common_%08x",
id));
3397 TString name(Form(
"p2p_%08x",
id));
3430 while ((holder = static_cast<Holder*>(nextC()))) {
3431 if (tit.EqualTo(holder->GetTitle()))
return holder->GetUniqueID();
3435 while ((holder = static_cast<Holder*>(nextP()))) {
3436 if (tit.EqualTo(holder->GetTitle()))
return holder->GetUniqueID();
3460 fData->SetPoint(i, x, y);
3482 fData->SetPointError(i, exl, exh,
3483 fData->GetErrorYlow(i),
3484 fData->GetErrorYhigh(i));
3520 eyl *=
fData->GetY()[i];
3521 eyh *=
fData->GetY()[i];
3523 fData->SetPointError(i,
3524 fData->GetErrorXlow(i),
3525 fData->GetErrorXhigh(i),
3563 h->
Set(i,
fData, exl, exh, eyl, eyh);
3578 TNamed::SetTitle(name);
3647 return fData->GetErrorYhigh(point);
3656 return fData->GetErrorYlow(point);
3688 return h->
GetX(point);
3700 return h->
GetY(point);
3735 if (h)
return h->
GetYUp(point);
3765 return h->GetTitle();
3778 return h->GetFillStyle();
3791 return h->GetLineStyle();
3804 return h->GetFillColor();
3817 return h->GetLineColor();
3830 return h->GetLineWidth();
3952 return c->
GetYUp(rel ? 100 : 1);
3990 GetMinMax(option, ymin, ymax, xmin, xmax, imin, imax);
4008 TString opt(option); opt.ToUpper();
4009 Bool_t cmn = opt.Contains(
"COMMON");
4010 Bool_t stat = opt.Contains(
"STAT");
4011 Bool_t quad = opt.Contains(
"QUAD");
4012 Bool_t noerr = opt.Contains(
"Y");
4013 quad = !opt.Contains(
"DIRECT");
4060 for (
Int_t i = start+dir; i != lim; i +=
dir) {
4066 if (y-eyl > ymax/2)
continue;
4067 if (y+eyh < ymax/2)
break;
4068 if (i1 < 0) i1 = i2 = i;
4084 return FWHM(el, eh, xl, xh);
4100 GetMinMax(
"quad stat", ymin, ymax, xmin, xmax, imin, imax);
4101 if (ymin > ymax/2) {
4102 Warning(
"FWHM",
"Half of ymax=%f is out of reach [%f,%f]",
4103 ymax/2, ymin, ymax);
4108 Int_t li1, li2, ri1, ri2;
4110 FindFwhm(imax, -1, ymax,
false,
true,
true, li1, li2);
4112 FindFwhm(imax, +1, ymax,
false,
true,
true, ri1, ri2);
4116 if (li1 < 0 && li2 < 0) {
4118 if (ri1 < 0 && ri2 < 0) {
4119 Warning(
"FWHM",
"No left and right point found");
4129 if (ri1 < 0 && ri2 < 0) {
4131 if (li1 < 0 && li2 < 0) {
4132 Warning(
"FWHM",
"No right and left point found");
4161 if (el < 1e-9 && eh < 1e-9) {
4199 Double_t meanX=TMath::Infinity(), stdDev, n;
4224 return MeanX(error, cmn, stat, quad);
4247 Double_t meanX=TMath::Infinity(), stdDev, eStdDev, n;
4249 error = stdDev/TMath::Sqrt(2)/n;
4280 Double_t meanX, stdDev, eStdDev, n;
4282 Double_t sd2 = stdDev*stdDev - meanX*meanX;
4283 stdDev = TMath::Sqrt(sd2 - mean*mean);
4284 error = stdDev/TMath::Sqrt(2)/n;
4337 sumE2 += TMath::Max(e2yl,e2yh);
4339 if (meanX == TMath::Infinity())
4341 Double_t sd2 = TMath::Abs(sumXXY/sumY-meanX*meanX);
4342 stdDevX = TMath::Sqrt(sd2);
4343 Double_t eff = sumE2 > 0 ? sumY*sumY/sumE2 : sumY;
4344 n = TMath::Sqrt(eff);
4363 h->SetLineColor(color);
4375 h->SetLineStyle(style);
4387 h->SetLineWidth(width);
4399 h->SetFillColor(color);
4411 h->SetFillStyle(style);
4592 fMap->SetName(
"keys");
4599 if (k.EqualTo(
"experiment",TString::kIgnoreCase)) {
4604 SetKey(
"laboratory", lab.Data(), replace);
4605 SetKey(
"accelerator", acc.Data(), replace);
4606 SetKey(
"detector", exp.Data(), replace);
4609 if (k.EqualTo(
"comment", TString::kIgnoreCase)) {
4612 if (!l.IsNull() && !a.IsNull())
4613 v.Remove(0, l.Length()+1+a.Length()+1);
4619 TObjLink* cur =
fMap->FirstLink();
4620 TObjLink* last =
fMap->LastLink();
4622 if (!k.EqualTo(cur->GetObject()->GetName())) {
4626 TObjLink* tmp = cur->Next();
4643 if (!
fMap)
return 0;
4646 return o->GetTitle();
4668 Bool_t all = opt.Contains(
"a");
4670 Bool_t header = opt.Contains(
"h");
4671 Bool_t qual = opt.Contains(
"q");
4672 Bool_t repl = opt.Contains(
"r");
4678 while ((kv = nextKV())) {
4681 if (file && !(key.EqualTo(
"reference") ||
4682 key.EqualTo(
"laboratory") ||
4683 key.EqualTo(
"accelerator")||
4684 key.EqualTo(
"detector") ||
4685 key.EqualTo(
"abstract") ||
4686 key.EqualTo(
"author") ||
4687 key.EqualTo(
"doi") ||
4688 key.EqualTo(
"inspireId") ||
4689 key.EqualTo(
"cdsId") ||
4690 key.EqualTo(
"durhamId") ||
4691 key.EqualTo(
"title") ||
4692 key.EqualTo(
"status")))
continue;
4693 if (header && !(key.EqualTo(
"location") ||
4694 key.EqualTo(
"reackey") ||
4695 key.EqualTo(
"obskey") ||
4696 key.EqualTo(
"dscomment")))
continue;
4698 SetKey(kv->GetName(), kv->GetTitle(), repl);
4701 if (!all && !qual)
return;
4705 while ((qv = nextQ())) {
4707 if (!test || test[0] ==
'\0')
4714 SetMarkerColor(f->GetMarkerColor());
4715 SetMarkerStyle(f->GetMarkerStyle());
4716 SetMarkerSize(f->GetMarkerSize());
4717 SetLineColor(f->GetLineColor());
4718 SetLineStyle(f->GetLineStyle());
4719 SetLineWidth(f->GetLineWidth());
4720 SetFillColor(f->GetFillColor());
4721 SetFillStyle(f->GetFillStyle());
4768 if (key.EqualTo(value)) val =
"";
4773 Warning(
"AddQualifier",
"Dataset already has qualifier \"%s\"",
4806 return o->GetTitle();
4845 y =
GetYandError(ret, cmn, stat, quad, nosqrt, eyl, eyh);
4867 y = y1 + ax * (y2 - y1);
4868 eyl = eyl1 + ax * (eyl2 - eyl1);
4869 eyh = eyh1 + ax * (eyh2 - eyh1);
4872 seyl = seyl1 + ax * (seyl2 - seyl1);
4873 seyh = seyh1 + ax * (seyh2 - seyh1);
4902 return FindYandError(x, cmn, stat, quad, nosqrt, y, eyl, eyh, seyl, seyh);
4933 : fX(x), fEl(el), fEh(eh)
4952 if (fEl * fEh == 0)
return 0;
4953 return 2 * fEl * fEh / (fEl +
fEh);
4967 if (TMath::Abs(fEh + fEl) < 1e-9)
return 1;
4968 return (fEh - fEl) / (fEh +
fEl);
4970 Double_t
Svar(Double_t guess=0)
const 4984 Double_t
V()
const {
return fEl *
fEh; }
5001 virtual Double_t
Low()
const {
return fX - 3 *
fEl; }
5007 virtual Double_t
High()
const {
return fX + 3 *
fEh; }
5015 Printf(
"%10.8f -%10.8f +%10.8f", fX, fEl, fEh);
5041 Result(Double_t x=0, Double_t el=0, Double_t eh=0,
5042 Double_t chi2=0, Double_t low=0, Double_t high=0)
5053 Double_t
Low()
const {
return fLower; }
5059 Double_t
High()
const {
return fUpper; }
5067 Printf(
"%10.8f -%10.8f +%10.8f %5.2f",
fX,
fEl,
fEh, fChi2);
5078 : fData(
"GraphSysErr::Combiner::Observation"), fResult(0)
5117 void Add(Double_t x, Double_t el, Double_t eh)
5122 new (fData[fData.GetEntries()])
Observation(x,el,eh);
5133 while ((r = static_cast<Observation*>(next())))
5185 Double_t var =
VarTerm(guess, r);
5186 if (var <= 0)
return -1000;
5188 return TMath::Power(guess - r.
fX, 2) / var;
5199 Double_t
F(Double_t guess,
5200 Double_t chi2)
const 5202 if (fData.GetEntries() == 1)
return 1;
5207 while ((r = static_cast<Observation*>(next())))
5228 if (fData.GetEntries() == 1) {
5230 return (sign < 0 ? o->
fEl : o->
fEh);
5234 Double_t delta = 0.1 * sign * s;
5237 for (
UShort_t i = 0; i < nIter; i++) {
5239 Double_t got =
F(best + sign * s, chi2);
5241 if (TMath::Abs(got-1) < 1e-7)
5246 Double_t guess =
F(best + sign * s + delta, chi2);
5249 if ((got - 1) * (guess - 1) > 0) {
5250 if ((got - 1) / (guess - 1) < 1)
5258 s += sign * delta * (1 - got) / (guess - got);
5277 if (fData.GetEntries() == 1)
5278 return static_cast<Observation*>(fData[0])->fX;
5279 Double_t x = (highest+lowest)/2;
5280 Double_t oldX = -1e33;
5282 for (
UShort_t i = 0; i < nIter; i++) {
5285 Double_t offset = 0;
5290 while ((r = static_cast<Observation*>(next()))) {
5291 Double_t w =
StepW(x, *r);
5296 x = (TMath::Abs(sumw) > 1e-9) ? (sum - offset) / sumw : 0;
5298 if (TMath::Abs(x - oldX) < (highest-lowest) * 1e-9)
break;
5312 Double_t lowest = +1e33;
5313 Double_t highest = -1e33;
5314 Double_t sumLow = 0;
5315 Double_t sumHigh = 0;
5320 while ((r = static_cast<Observation*>(next()))) {
5321 lowest = TMath::Min(r->
Low(), lowest);
5322 highest = TMath::Max(r->
High(), highest);
5323 if (r->
fEl > 1e-10) sumLow += 1./TMath::Power(r->
fEl, 2);
5324 if (r->
fEh > 1e-10) sumHigh += 1./TMath::Power(r->
fEh, 2);
5327 Double_t sLow = sumLow > 1e-10 ? 1. / TMath::Sqrt(sumLow) : 0;
5328 Double_t sHigh = sumHigh > 1e-10 ? 1. / TMath::Sqrt(sumHigh) : 0;
5331 Double_t bestX =
X(nIter, lowest, highest);
5332 Double_t bestChi2 =
F(bestX, 0);
5333 Double_t bestLow = TMath::Abs(
E(nIter,-1,bestX,bestChi2,sLow));
5334 Double_t bestHigh = TMath::Abs(
E(nIter,+1,bestX,bestChi2,sHigh));
5336 fResult =
new Result(bestX, bestLow, bestHigh, bestChi2, lowest, highest);
5357 TF1* f =
new TF1(Form(
"f%02d", j),
Wrapper(), r.
Low(), r.
High(), 3);
5358 f->SetParNames(
"x",
"#sigma^{-}",
"#sigma^{+}");
5359 f->SetParameters(r.
fX, r.
fEl, r.
fEh);
5360 f->SetLineStyle((j%3)+2);
5361 f->SetLineColor(kBlack);
5374 Double_t m = f->GetParameter(0);
5375 TLine* l =
new TLine(m-f->GetParameter(1), 1,
5376 m+f->GetParameter(2), 1);
5377 l->SetLineColor(f->GetLineColor());
5378 l->SetLineStyle(f->GetLineStyle());
5379 l->SetLineWidth(f->GetLineWidth());
5384 if (!fResult)
return;
5386 TList fs; fs.SetOwner(
false);
5390 while ((r = static_cast<Observation*>(next()))) {
5391 TF1* f =
MakeF(*r, j);
5392 f->SetRange(fResult->
Low(), fResult->
High());
5393 fs.Add(f, j == 0 ?
"" :
"same");
5397 TF1* fr =
MakeF(*fResult, j);
5398 fr->SetLineColor(kRed+2);
5399 fr->SetLineStyle(1);
5405 while((o = nextD())) { o->Draw(j == 0 ?
"" :
"same"); j++; }
5407 static_cast<TF1*
>(fs.First())->GetHistogram()
5408 ->GetYaxis()->SetRangeUser(-.1, 5.1);
5454 Double_t ret = s / TMath::Power(t,3);
5481 return TMath::Power(r.
Svar(guess),2);
5510 if (TMath::Abs(d) < 1e-10)
return 0;
5512 Double_t ret = TMath::Power(d/t, 2);
5525 return L(xp[0], pp[0], pp[1], pp[2]);
5555 return TMath::Power(v + r.
fX * vp, 2) / (2 * v + r.
fX * vp);
5572 return v / TMath::Power(v+r.
Vprime()*(guess - r.
fX), 2);
5589 return 0.5 * vp * TMath::Power((guess-r.
fX)/(r.
V()+vp*(guess-r.
fX)),2);
5606 return r.
V() + r.
Vprime() * (guess - r.
fX);
5632 return TMath::Power(d,2) / (v+vp*d);
5644 return L(xp[0], pp[0], pp[1], pp[2]);
5679 SetLineColor(h->GetLineColor());
5680 SetLineStyle(h->GetLineStyle());
5681 SetLineWidth(h->GetLineWidth());
5682 SetFillColor(h->GetFillColor());
5683 SetFillStyle(h->GetFillStyle());
5715 fRelative(other.fRelative),
5716 fOption(other.fOption)
5718 SetUniqueID(other.GetUniqueID());
5729 if (&other ==
this)
return *
this;
5731 other.TNamed::Copy(*
this);
5732 other.TAttLine::Copy(*
this);
5733 other.TAttFill::Copy(*
this);
5738 SetUniqueID(other.GetUniqueID());
5752 virtual Graph* StackError(Graph* g,
Bool_t ignoreErr,
Bool_t quad)
const = 0;
5762 virtual void SumError(Graph* g,
Int_t i,
Bool_t ignoreErr,
5783 gROOT->IndentLevel();
5784 Printf(
"%s/%s %s(ID # %d%s)", GetName(), GetTitle(),
5788 if (!opt.Contains(
"ATTR", TString::kIgnoreCase))
return;
5789 gROOT->IndentLevel();
5790 Printf(
" [option: %3d line (c/s/w):%3d/%1d/%2d fill (c/s):%3d/%4d]",
5791 fOption, GetLineColor(), GetLineStyle(), GetLineWidth(),
5792 GetFillColor(), GetFillStyle());
5803 if (opt < 0) opt = fOption;
5807 case kNone: xMode = 0;
break;
5808 case kRect:
case kBox: xMode = 3;
break;
5854 Info(
"",
"old: +%f/-%f this: +%f/-%f -> +%f/-%f",
5855 curEyl, curEyh, eyl, eyh, eyl + curEyl, eyh + curEyh);
5856 exl = TMath::Max(exl, curExl);
5857 exh = TMath::Max(exh, curExh);
5864 case 1: exl = exh = 0;
break;
5866 if (exl <= 0) exl = gStyle->GetErrorX()/2;
5867 if (exh <= 0) exh = gStyle->GetErrorX()/2;
5880 this->TAttLine::Copy(*g);
5881 this->TAttFill::Copy(*g);
5882 g->SetMarkerColor(0);
5883 g->SetMarkerStyle(0);
5884 g->SetMarkerSize(0);
5919 :
Holder(name, title, rel, opt, id),
5922 fGraph =
new Graph();
5923 fGraph->SetName(name);
5924 fGraph->SetTitle(title);
5937 fGraph =
static_cast<Graph*
>(other.
fGraph->Clone());
5950 if (&other ==
this)
return *
this;
5953 if (fGraph)
delete fGraph;
5956 fGraph =
static_cast<Graph*
>(other.
fGraph->Clone());
5976 Set(point, g, ex, ex, ey, ey);
5991 if (!fGraph)
return;
5993 if (point >= g->GetN())
return;
5996 fGraph->SetPoint(point, x, y);
5997 if (fRelative) { ey1 *= y; ey2 *= y; }
5998 fGraph->SetPointError(point, ex1, ex2, ey1, ey2);
6015 if (!fGraph)
return 0;
6016 return fGraph->GetErrorX(point);
6027 if (!fGraph)
return 0;
6028 return fGraph->GetErrorXlow(point);
6039 if (!fGraph)
return 0;
6040 return fGraph->GetErrorXhigh(point);
6051 if (!fGraph)
return 0;
6052 return fGraph->GetErrorY(point);
6065 if (!fGraph)
return 0;
6066 if (i1 == i2)
return GetYDown(i1);
6069 return e1 + ax * (e2-e1);
6080 if (!fGraph)
return 0;
6081 return fGraph->GetErrorYlow(point);
6094 if (!fGraph)
return 0;
6095 if (i1 == i2)
return GetYUp(i1);
6098 return e1 + ax * (e2-e1);
6109 if (!fGraph)
return 0;
6110 return fGraph->GetErrorYhigh(point);
6141 Double_t exlO = fGraph->GetErrorXlow(i);
6142 Double_t exhO = fGraph->GetErrorXhigh(i);
6143 Double_t eylO = fGraph->GetErrorYlow(i);
6144 Double_t eyhO = fGraph->GetErrorYhigh(i);
6147 if (exl <= 0) exlO = exl;
6148 if (exh <= 0) exhO = exh;
6152 ignoreErr, quad, sqOld,
6153 exlO, exhO, eylO, eyhO);
6155 Info(GetTitle(),
"quad: %s this: +%f/-%f, old: +%f/-%f -> +%f/-%f",
6156 (quad ?
"true" :
"false"), oyl, oyh, eyl, eyh, eylO, eyhO);
6186 AddError(i, xMode, ignoreErr, quad,
true, exl, exh, eyl, eyh);
6188 Info(GetTitle(),
"old= +%f/-%f -> +%f/-%f", oldEyl, oldEyh, eyl, eyh);
6201 Graph* ga =
new Graph(g->GetN());
6202 for (
Int_t i = 0; i < g->GetN(); i++) {
6206 Double_t exh = g->GetErrorXhigh(i);
6208 Double_t eyh = g->GetErrorYhigh(i);
6209 StackPointError(i, XMode(), ignoreErr, quad, exl, exh, eyl, eyh);
6211 ga->SetPoint(i, x, y);
6212 ga->SetPointError(i, exl,exh,eyl,eyh);
6215 ga->SetTitle(GetTitle());
6216 ga->SetName(Form(
"stack_%08x", GetUniqueID()));
6237 AddError(i, xMode, ignoreErr, quad,
false, exl, exh, eyl, eyh);
6251 Double_t exl = (g ? g->GetErrorXlow(i) : 0);
6252 Double_t exh = (g ? g->GetErrorXhigh(i) : 0);
6253 Double_t eyl = (g ? g->GetErrorYlow(i) : 0);
6254 Double_t eyh = (g ? g->GetErrorYhigh(i) : 0);
6255 SumPointError(i, XMode(opt), ignoreErr, quad, exl, exh, eyl, eyh);
6256 g->SetPointError(i, exl,exh,eyl,eyh);
6261 if (option[0] ==
'd' || option[0] ==
'D')
6262 out <<
" // Point-2-Point systematic " << GetTitle() <<
"\n" 6264 <<
" Int_t id = g->DeclarePoint2Point(\"" << GetTitle() <<
"\"," 6266 <<
" g->SetSysLineColor(id," << GetLineColor() <<
");\n" 6267 <<
" g->SetSysLineStyle(id," << GetLineStyle() <<
");\n" 6268 <<
" g->SetSysLineWidth(id," << GetLineWidth() <<
");\n" 6269 <<
" g->SetSysFillColor(id," << GetFillColor() <<
");\n" 6270 <<
" g->SetSysFillStyle(id," << GetFillStyle() <<
");\n" 6275 gROOT->IndentLevel();
6276 Printf(
"%s/%s (ID # %d, %d points)", GetName(), GetTitle(), GetUniqueID(),
6277 (fGraph ? fGraph->GetN() : -1));
6279 if (!opt.Contains(
"ATTR", TString::kIgnoreCase))
return;
6280 gROOT->IndentLevel();
6281 Printf(
" [option: %3d line (c/s/w):%3d/%1d/%2d fill (c/s):%3d/%4d]",
6282 fOption, GetLineColor(), GetLineStyle(), GetLineWidth(),
6283 GetFillColor(), GetFillStyle());
6305 :
Holder(), fEyl(0), fEyh(0)
6319 :
Holder(name, title, rel, opt, id), fEyl(0), fEyh(0)
6342 if (&other ==
this)
return *
this;
6379 return (fRelative ? y : 1) * fEyl;
6390 return (fRelative ? y : 1) * fEyh;
6428 if (exlO <= 0) exlO = gStyle->GetErrorX()/2;
6429 if (exhO <= 0) exhO = gStyle->GetErrorX()/2;
6431 DoAdd(xMode, exl, exh, eyl, eyh,
6432 ignoreErr, quad, sqOld,
6433 exlO, exhO, eylO, eyhO);
6451 Double_t exl = (g ? g->GetErrorXlow(0) : 0);
6452 Double_t exh = (g ? g->GetErrorXhigh(0) : 0);
6453 Double_t eyl = (g ? g->GetErrorYlow(0) : 0);
6454 Double_t eyh = (g ? g->GetErrorYhigh(0) : 0);
6455 AddError(y, XMode(),
false, quad, quad, exl, exh, eyl, eyh);
6457 Graph* r =
new Graph(1);
6458 r->SetPoint(0, x, y);
6459 r->SetPointError(0, exl, exh, eyl, eyh);
6462 r->SetTitle(GetTitle());
6463 r->SetName(Form(
"bar_%08x", GetUniqueID()));
6488 AddError(y, xMode, ignoreErr, quad,
true, exl, exh, eyl, eyh);
6502 Graph* ga =
new Graph(g->GetN());
6503 for (
Int_t i = 0; i < g->GetN(); i++) {
6507 Double_t exh = g->GetErrorXhigh(i);
6509 Double_t eyh = g->GetErrorYhigh(i);
6510 StackPointError(y, XMode(), ignoreErr, quad, exl, exh, eyl, eyh);
6511 ga->SetPoint(i, x, y);
6512 ga->SetPointError(i, exl,exh,eyl,eyh);
6515 ga->SetTitle(GetTitle());
6516 ga->SetName(Form(
"stack_%08x", GetUniqueID()));
6537 AddError(y, xMode, ignoreErr, quad,
false, exl, exh, eyl, eyh);
6551 Double_t y = (g ? g->GetY()[i] : 0);
6552 Double_t exl = (g ? g->GetErrorXlow(i) : 0);
6553 Double_t exh = (g ? g->GetErrorXhigh(i) : 0);
6554 Double_t eyl = (g ? g->GetErrorYlow(i) : 0);
6555 Double_t eyh = (g ? g->GetErrorYhigh(i) : 0);
6556 SumPointError(y, XMode(opt), ignoreErr, quad, exl, exl, eyl, eyh);
6557 g->SetPointError(i, exl,exh,eyl,eyh);
6562 if (option[0] ==
'd' || option[0] ==
'D')
6563 out <<
" // Common systematic " << GetTitle() <<
"\n" 6565 <<
" Int_t id = g->DefineCommon(\"" << GetTitle() <<
"\"," 6566 << fRelative <<
',' << fEyl <<
',' << fEyh <<
',' 6567 << fOption <<
");\n" 6568 <<
" g->SetSysLineColor(id," << GetLineColor() <<
")\n;" 6569 <<
" g->SetSysLineStyle(id," << GetLineStyle() <<
")\n;" 6570 <<
" g->SetSysLineWidth(id," << GetLineWidth() <<
")\n;" 6571 <<
" g->SetSysFillColor(id," << GetFillColor() <<
")\n;" 6572 <<
" g->SetSysFillStyle(id," << GetFillStyle() <<
")\n;" 6579 const char* pst = (rel ?
"%" :
"");
6580 gROOT->IndentLevel();
6581 Printf(
"%s/%s (ID # %d) -%f%s +%f%s",
6582 GetName(), GetTitle(), GetUniqueID(),
6583 fac*fEyl, pst, fac*fEyh, pst);
6585 if (!opt.Contains(
"ATTR", TString::kIgnoreCase))
return;
6586 gROOT->IndentLevel();
6587 Printf(
" [option: %3d line (c/s/w):%3d/%1d/%2d fill (c/s):%3d/%4d]",
6588 fOption, GetLineColor(), GetLineStyle(), GetLineWidth(),
6589 GetFillColor(), GetFillStyle());
6622 return GetYandError(i, cmn, stat, quad, nosqrt, eyl, eyh, wyl, wyh);
6663 eyl = (stat ? wyl : 0);
6664 eyh = (stat ? wyh : 0);
6681 while ((hc = static_cast<HolderCommon*>(nextC()))) {
6682 if (hc->TestBit(
kUsedBit))
continue;
6684 hc->
SumPointError(y, xMode,
false, quad, exl, exh, wyl, wyh);
6686 hc->
SumPointError(y, xMode,
false, quad, exl, exh, eyl, eyh);
6691 while ((hp = static_cast<HolderP2P*>(nextP()))) {
6692 if (hp->TestBit(
kUsedBit))
continue;
6694 hp->
SumPointError(i, xMode,
false, quad, exl, exh, wyl, wyh);
6696 hp->
SumPointError(i, xMode,
false, quad, exl, exh, eyl, eyh);
6698 if (quad && !nosqrt) {
6699 eyl = TMath::Sqrt(eyl);
6700 eyh = TMath::Sqrt(eyh);
6701 wyl = TMath::Sqrt(wyl);
6702 wyh = TMath::Sqrt(wyh);
6761 Double_t tens = TMath::Power(10, expo - p + 1);
6764 if (n < TMath::Power(10, p-1)) {
6767 tens = TMath::Power(10, expo - p + 1);
6771 if (TMath::Abs((n+1) * tens) <= TMath::Abs(n * tens))
6775 if (n >= TMath::Power(10,p)) {
6782 return (neg ? -1 : 1)*n;
6790 Double_t tmpExl = g->GetErrorXlow(i);
6791 Double_t tmpExh = g->GetErrorXhigh(i);
6792 Double_t tmpEyl = g->GetErrorYlow(i);
6793 Double_t tmpEyh = g->GetErrorYhigh(i);
6800 g->SetPoint(i, s*g->GetX()[j], g->GetY()[j]);
6802 g->GetErrorXlow(j), g->GetErrorXhigh(j),
6803 g->GetErrorYlow(j), g->GetErrorYhigh(j));
6804 g->SetPoint(j, s*tmpX, tmpY);
6805 g->SetPointError(j, tmpExl, tmpExh, tmpEyl, tmpEyh);
6813 TString tmp(Form(
"*%s:", key));
6814 return Form(
"%-12s", tmp.Data());
6828 TObjArray* tokens = value.Tokenize(
":");
6829 Int_t iVal = TMath::Min(
Int_t(idx),tokens->GetEntriesFast()-1);
6830 if (iVal < 0)
return val;
6831 TString tmp = tokens->At(iVal)->GetName();
6847 const char* name,
const char* val)
6849 TObject* oqv = quals.FindObject(name);
6858 else qv =
static_cast<TList*
>(oqv);
6860 qv->AddAt(
new TObjString(val), idx);
6871 StoreQual(quals, idx, q->GetName(), q->GetTitle());
6886 const char* fill =
"<please fill in>")
const 6892 while ((obj = nextK())) {
6894 if (!k.EqualTo(which))
continue;
6896 if (alsoKey) out <<
FormatKey(obj->GetName());
6897 out << obj->GetTitle() << std::endl;
6903 out << fill << std::endl;
6919 Bool_t alsoComment=
false,
6920 Int_t nsign=-1)
const 6923 out <<
"# Generated by GraphSysErr\n" 6926 <<
"# http://hepdata.cedar.ac.uk/resource/sample.input\n" 6927 <<
"# http://hepdata.cedar.ac.uk/submittingdata\n" 6929 <<
"# Please fill in missing fields\n";
6933 UserGroup_t* u =
gSystem->GetUserInfo();
6935 const char* lab =
GetKey(
"laboratory");
6936 const char* accel =
GetKey(
"accelerator");
6937 const char* exper =
GetKey(
"detector");
6938 const char* abs =
GetKey(
"abstract");
6939 const char* months[] = {
"JAN",
"FEB",
"MAR",
"APR",
6940 "MAY",
"JUN",
"JUL",
"AUG",
6941 "SEP",
"OCT",
"NOV",
"DEC"};
6943 out <<
"*reference: <journal/archive ref> : <year>" << std::endl;
6945 ExportKey(out,
"reference",
true,
"<reference>");
6947 ExportKey(out,
"author",
true,
"<Last name of first author in CAPS>");
6948 ExportKey(out,
"doi",
true,
"<DOI number>");
6949 ExportKey(out,
"inspireId",
true,
"<inSpire ID>");
6950 ExportKey(out,
"cdsId",
true,
"<CDS ID>");
6951 ExportKey(out,
"durhamId",
true,
"<fill in on submission>");
6952 ExportKey(out,
"title",
true,
"<Title of paper>");
6954 out <<
FormatKey(
"status") <<
"Encoded " 6955 << std::setw(2) << now.GetDay() <<
' '<< months[now.GetMonth()-1]<<
' ' 6956 << std::setw(4) << now.GetYear() <<
" by "<< u->fRealName.Data()<<
"\n" 6957 <<
FormatKey(
"experiment") << (lab ? lab :
"<lab>") <<
'-' 6958 << (accel ? accel :
"<accelerator>") <<
'-' 6959 << (exper ? exper :
"<experiment>") <<
'\n' 6960 <<
FormatKey(
"detector") << (exper ? exper :
"<experiment>") <<
'\n' 6961 <<
FormatKey(
"comment") << (lab ? lab :
"<lab>") <<
'-' 6962 << (accel ? accel :
"<accelerator>") <<
". " 6963 << (abs ? abs :
"<abstract>") <<
"\n" 6966 out <<
"# Start of dataset\n";
6967 if (nsign >= 0) out <<
"# Using " << nsign <<
" significant digits\n";
6968 out <<
FormatKey(
"dataset") << std::endl;
6970 const char* fields[] = {
"location",
6976 const char** pfld = fields;
7004 Int_t p = o.precision();
7011 e = TMath::Min(le,he);
7012 l = lm*TMath::Power(10,le);
7013 h = hm*TMath::Power(10,he);
7018 if (TMath::Abs(h-l) < 1e-12)
7019 o << (nopm ?
"" :
"+- ") << TMath::Abs(l) << (rel ?
" PCT" :
"");
7021 o <<
"+" << h <<
",-" << l << (rel ?
" PCT" :
"");
7040 Int_t nsign=0)
const 7042 Int_t p = out.precision();
7054 exl = mxl*TMath::Power(10, pxl);
7055 exh = mxh*TMath::Power(10, pxh);
7056 Int_t mp = TMath::Min(pxl,pxh);
7058 ppp = TMath::Ceil(TMath::Log10(TMath::Abs(x)))-mp;
7062 if (TMath::Abs(exl) < 1e-10 && TMath::Abs(exh) < 1e-10) {
7063 if (nsign <= 0) out <<
' ' << x;
7067 Double_t xx = mx*TMath::Power(10,px);
7069 out.precision(nsign);
7074 if (TMath::Abs(exh-exl) < 1e-10) {
7076 out <<
' ' << x-exl <<
" TO " << x+exh;
7080 out <<
' ' << x <<
' ';
7082 out <<
'+' << exh <<
",-" << exl;
7092 Double_t fy = (statRel ? (y == 0 ? 0 : 100./y) : 1);
7096 std::stringstream tmp;
7101 tmp <<
" (" << std::flush;
7105 while ((holderP2P = static_cast<HolderP2P*>(nextP()))) {
7107 fy = (rel ? (y == 0 ? 0 : 100./y) : 1);
7108 if (!first) tmp <<
',';
7112 le = TMath::Min(le,
ExportError(tmp, esl, esh,
true, rel, nsign));
7114 tmp <<
':' << holderP2P->GetTitle() << std::flush;
7120 Int_t nY = TMath::Ceil(TMath::Log10(TMath::Abs(y)))-le;
7127 out << tmp.str() <<
';';
7151 Double_t n = TMath::Floor(100*tmp/tens+.00001);
7152 Int_t next = int(n/10) % 10;
7155 return TMath::Ceil(n/100);
7158 return TMath::Floor(n/100);
7159 Int_t nnext = int(n) % 10;
7162 return TMath::Ceil(n/100);
7163 Int_t last = int(n/100) % 10;
7166 return TMath::Floor(n/100);
7168 return TMath::Ceil(n/100);
7182 if (idx >= c->GetEntriesFast()) {
7184 ::Error(
"Token",
"Token %d does not exist in array", idx);
7189 return static_cast<TObjString*
>(c->At(idx))->String();
7207 if (tmp.Contains(
"PCT", TString::kIgnoreCase) || tmp.Contains(
"%"))
7209 if (tmp.BeginsWith(
"+-") || tmp.BeginsWith(
"-+")) {
7210 el = eh = tmp.Atof();
7215 for (
Int_t i = 0; i < tokens->GetEntriesFast(); i++) {
7217 if (t.IsNull())
continue;
7221 if (t[0] !=
'-' && t[0] !=
'+') {
7223 el = eh = TMath::Abs(v);
7229 ::Warning(
"ImportError",
7230 "Lower error already set to %f, chosing the maximum of " 7231 "(%f,%f) -> %f", el, el, -v, max);
7240 ::Warning(
"ImportError",
7241 "Lower error already set to %f, chosing the maximum of " 7242 "(%f,%f) -> %f", eh, eh, v, max);
7272 rel = s.Contains(
"PCT");
7274 if (tok->GetEntriesFast() >= 4 &&
7275 Token(tok,2).EqualTo(
"TO", TString::kIgnoreCase) &&
7276 Token(tok,1).Contains(
"BIN", TString::kIgnoreCase)) {
7277 v =
Token(tok,0).Atof();
7280 s1.ReplaceAll(
"BIN=",
"");
7288 else if (tok->GetEntriesFast() >= 3 &&
7289 Token(tok,1).EqualTo(
"TO", TString::kIgnoreCase)) {
7297 v =
Token(tok,0).Atof();
7298 if (tok->GetEntriesFast() >= 2 &&
7299 (
Token(tok,1).BeginsWith(
"+-") ||
7300 Token(tok,1).BeginsWith(
"-+"))) {
7302 if (t.Length() > 2) {
7309 el = eh =
Token(tok,2).Atof();
7313 for (
Int_t i = 1; i < tok->GetEntriesFast(); i++) {
7317 if (m !=
'+' && m !=
'-')
continue;
7318 if (t.Length() == 1) t =
Token(tok, ++i);
7321 if (m ==
'-') el = t.Atof();
7344 printf(
"%20s Point %3d %f,%f -> ",
"",
7345 i,g->GetEYlow()[i],g->GetEYhigh()[i]);
7347 g->GetEYlow()[i] = TMath::Sqrt(g->GetEYlow()[i]);
7348 g->GetEYhigh()[i] = TMath::Sqrt(g->GetEYhigh()[i]);
7351 Printf(
"%f,%f", g->GetEYlow()[i], g->GetEYhigh()[i]);
7360 for (
Int_t i = 0; i < g->GetN(); i++)
7378 case kNormal: ret =
"";
break;
7379 case kNoTick: ret =
"Z0";
break;
7380 case kArrow: ret =
">0";
break;
7381 case kRect: ret =
"20";
break;
7382 case kBox: ret =
"50";
break;
7383 case kFill: ret =
"30";
break;
7384 case kCurve: ret =
"40";
break;
7385 case kHat: ret =
"[]0";
break;
7386 case kBar: ret =
"||0";
break;
7387 case kNone: ret =
"XP";
break;
7388 case kLine: ret =
"CX";
break;
7401 fData->SetName(Form(
"%s_data", fName.Data()));
7402 fData->SetTitle(GetTitle());
7428 for (
Int_t i=0; i < n; i++) {
7485 Warning(
"MakeMulti",
"No data defined");
7493 Bool_t cmn = opt.Contains(
"COMMON");
7494 Bool_t combine = opt.Contains(
"COMBINED");
7495 Bool_t stat = opt.Contains(
"STAT");
7496 Bool_t quad = opt.Contains(
"QUAD");
7497 combine = !opt.Contains(
"STACK");
7498 quad = !opt.Contains(
"DIRECT");
7499 Bool_t split = opt.Contains(
"SPLIT");
7500 Int_t xpos = (opt.Contains(
"WEST") ? -1 : 1);
7501 Int_t ypos = (opt.Contains(
"MIN") ? -1 :
7502 opt.Contains(
"MAX") ? 1 : 0);
7506 Double_t dx = TMath::Max(gStyle->GetErrorX(),0.0001F);
7508 Warning(
"MakeMulti",
"Nothing to do (n=%d)", n);
7514 if (opt.Contains(
"XBASE=")) {
7515 Int_t idx = opt.Index(
"XBASE=")+6;
7516 TString tmp = opt(idx,opt.Length()-idx);
7520 xBase = ((xpos < 0 ?
7522 fData->GetX()[n-1] +
fData->GetEXhigh()[n-1])
7526 for (
Int_t i = 0; i < n; i++) {
7528 yBase = (ypos < 0 ? TMath::Min(yBase, y) :
7529 ypos > 0 ? TMath::Max(yBase, y) : yBase + y);
7531 if (ypos == 0) yBase /= n;
7535 drawn.SetOwner(
false);
7547 while ((h = static_cast<Holder*>(next()))) {
7548 Graph* g = h->
StackError(prev, (!stat ? prev ==
fData :
false), quad);
7558 while ((h = static_cast<Holder*>(next()))) {
7559 Graph* g = h->
StackError(prev, (!stat ? prev ==
fData :
false), quad);
7569 Graph* g =
static_cast<Graph*
>(
fData->Clone(
"error"));
7572 for (
Int_t i = 0; i < n; i++) {
7574 g->SetPointError(i, g->GetEXlow()[i],
7575 g->GetEXhigh()[i],0,0);
7579 g->GetEYlow()[i] *= g->GetEYlow()[i];
7581 g->GetEYhigh()[i] *= g->GetEYhigh()[i];
7587 while ((h = static_cast<Holder*>(nextC()))) {
7593 while ((h = static_cast<Holder*>(nextP())))
7601 g->SetMarkerStyle(0);
7602 g->SetMarkerSize(0);
7603 g->SetMarkerColor(0);
7613 while ((hc = static_cast<HolderCommon*>(nextC()))) {
7614 Graph* g = hc->
BarError(prev, quad && !split, xBase, yBase);
7616 Warning(
"MakeMulti",
"Got no graph for common error %s",
7623 if (split) xBase += xpos * 1.2 * dx;
7630 TObjLink* f = drawn.FirstLink();
7632 while (f && f->GetObject()) {
7633 if (f->GetObject() == prev) {
7642 prev = (split ? 0 : g);
7647 if (
fCommon.GetEntries() > 0) {
7648 Graph* g =
new Graph(1);
7649 g->SetPoint(0, xBase, yBase);