#include <Plot.h>
Public Member Functions | |
| Hist (const std::string fpath, const std::string block="block") | |
| virtual | ~Hist () |
| bool | Set (const std::string fpath, const std::string block="block") |
| TH1 * | Get (const std::string hpath) |
| void | SetProtons (double protons) |
| TGraphAsymmErrors * | SetLH (const std::string lpath, const std::string hpath) |
| TH1 * | operator-> () const |
| TH1 * | GetHist (std::string option="") const |
| double | GetEntries (std::string option="") const |
| double | GetProtons () const |
| const DataBlock & | GetBlock () const |
| const std::map< int, std::pair< Plot::Band, Plot::Band > > & | GetErrorBand () const |
| void | Rebin (int rebin, std::string option="") |
| void | Rebin (TH1 *h, std::string option="") |
| void | NormalizeOnWidth (std::string option="") |
| TH1 * | Scale (const Hist &other, std::string option) |
| TCanvas * | Draw (std::string option, std::string cname="") |
| void | SetErrorStyle (int color=-1, int style=1001) |
| TPaveStats * | MoveStat (float x, float y, float w, float h, std::string option="") |
| TH1 * | GetRatio (const Hist &other, std::string option="", double min_=1.0, double max_=0.0, double factor=0.05) const |
Private Member Functions | |
| TGraphAsymmErrors * | ComputeError () |
| std::pair< TH1 *, DataBlock > | Read (const std::string &hpath) |
| TH1 * | CreateRatio (TH1 *hC, TH1 *hO, const std::string &option, double nmin) const |
| double * | Create (int size) |
| void | ClearError () |
Private Attributes | |
| std::string | fBlokPath |
| std::string | fFilePath |
| std::string | fHistPath |
| std::string | fHistPathL |
| std::string | fHistPathH |
| TH1 * | fHist |
| TH1 * | fHistL |
| TH1 * | fHistH |
| DataBlock | fBlock |
| int | fErrorColor |
| int | fErrorStyle |
| TGraphAsymmErrors * | fAGraph |
| std::map< int, std::pair< Band, Band > > | fError |
| std::map< int, TBox * > | fBox |
| std::vector< double * > | fArray |
|
||||||||||||
|
Definition at line 353 of file Plot.cxx. References Set(). 00354 :fBlokPath(), 00355 fFilePath(), 00356 fHistPath(), 00357 fHistPathL(), 00358 fHistPathH(), 00359 fHist(0), 00360 fHistL(0), 00361 fHistH(0), 00362 fBlock(), 00363 fErrorColor(-1), 00364 fErrorStyle(1001), 00365 fAGraph(0), 00366 fError(), 00367 fArray() 00368 { 00369 Set(fpath, block); 00370 }
|
|
|
Definition at line 373 of file Plot.cxx. References ClearError(). 00374 {
00375 if(fHist) delete fHist;
00376 if(fHistL) delete fHistL;
00377 if(fHistH) delete fHistH;
00378
00379 ClearError();
00380 }
|
|
|
Definition at line 1312 of file Plot.cxx. References fAGraph, fArray, fBox, and fError. Referenced by ComputeError(), and ~Hist(). 01313 {
01314 if(fAGraph)
01315 {
01316 delete fAGraph;
01317 fAGraph = 0;
01318 }
01319
01320 for(vector<double *>::iterator it = fArray.begin(); it != fArray.end(); ++it)
01321 {
01322 double *a = *it;
01323 if(a)
01324 {
01325 delete [] a;
01326 }
01327 }
01328
01329 for(map<int, TBox *>::iterator it = fBox.begin(); it != fBox.end(); ++it)
01330 {
01331 TBox *box = it -> second;
01332 if(box) delete box;
01333 }
01334
01335 fArray.clear();
01336 fError.clear();
01337 fBox.clear();
01338 }
|
|
|
Definition at line 450 of file Plot.cxx. References ClearError(), Create(), fAGraph, fBox, fError, Plot::Band::High(), and Plot::Band::Low(). Referenced by Rebin(), and Scale(). 00451 {
00452 TH1 *hC = fHist;
00453 TH1 *hL = fHistL;
00454 TH1 *hH = fHistH;
00455
00456 if(!hC || !hL || !hH)
00457 {
00458 return 0;
00459 }
00460
00461 ClearError();
00462
00463 const int nbin = hC -> GetNbinsX();
00464
00465 if(hL -> GetNbinsX() != nbin || hH -> GetNbinsX() != nbin)
00466 {
00467 cerr << "Error::Compute - mismatched number of bins" << endl;
00468 return 0;
00469 }
00470
00471 int npoint = 0;
00472 for(int ibin = 1; ibin <= nbin; ++ibin)
00473 {
00474 if(hC -> GetBinContent(ibin) > 0)
00475 {
00476 ++npoint;
00477 }
00478 }
00479
00480 double* x = Create(npoint);
00481 double* y = Create(npoint);
00482 double* exl = Create(npoint);
00483 double* exh = Create(npoint);
00484 double* eyl = Create(npoint);
00485 double* eyh = Create(npoint);
00486
00487 npoint = 0;
00488 for(int ibin = 1; ibin <= nbin; ++ibin)
00489 {
00490 if(!(hC -> GetBinContent(ibin) > 0))
00491 {
00492 continue;
00493 }
00494
00495 const double xc = hC -> GetXaxis() -> GetBinCenter(ibin);
00496 const double xl = hC -> GetXaxis() -> GetBinLowEdge(ibin);
00497 const double xh = hC -> GetXaxis() -> GetBinUpEdge(ibin);
00498
00499 const double yc = hC -> GetBinContent(ibin);
00500 const double yl = hL -> GetBinContent(ibin);
00501 const double yh = hH -> GetBinContent(ibin);
00502
00503 if(yl > yh)
00504 {
00505 cerr << "Error::Compute - low value " << yl << " larger than high value " << yh<< endl;
00506 continue;
00507 }
00508
00509 if(yc < yl || yh < yc)
00510 {
00511 cerr << "Error::Compute - low and/or high error have wrong limit" << yh << endl;
00512 continue;
00513 }
00514
00515 const double error_stat = std::sqrt(yc);
00516 const double error_low = error_stat + yc - yl;
00517 const double error_high = error_stat + yh - yc;
00518
00519 //cout << "yc - yl = " << yc << " - " << yl << " = " << yc - yl << endl;
00520 //cout << "yh - yc = " << yh << " - " << yc << " = " << yh - yc << endl;
00521
00522 x[npoint] = xc;
00523 y[npoint] = yc;
00524
00525 exl[npoint] = xc - xl;
00526 exh[npoint] = xh - xc;
00527
00528 eyl[npoint] = error_low;
00529 eyh[npoint] = error_high;
00530
00531 ++npoint;
00532
00533 const Band xb(ibin, xc, xl, xh);
00534 const Band yb(ibin, yc, yl - error_stat, yh + error_stat);
00535
00536 const pair<Band, Band> np(xb, yb);
00537
00538 if(!fError.insert(map<int, pair<Band, Band> >::value_type(ibin, np)).second)
00539 {
00540 cerr << "Error::Compute - bin " << ibin << " already exists" << endl;
00541 }
00542
00543 TBox *box = new TBox(xb.Low(), yb.Low(), xb.High(), yb.High());
00544
00545 if(!fBox.insert(map<int, TBox *>::value_type(ibin, box)).second)
00546 {
00547 cerr << "Error::Compute - bin " << ibin << " already exists" << endl;
00548 }
00549
00550
00551 if(error_low > error_high)
00552 {
00553 hC -> SetBinError(ibin, error_low);
00554 }
00555 else
00556 {
00557 hC -> SetBinError(ibin, error_high);
00558 }
00559 }
00560
00561 fAGraph = new TGraphAsymmErrors(npoint, x, y, exl, exh, eyl, eyh);
00562
00563 return fAGraph;
00564 }
|
|
|
Definition at line 1291 of file Plot.cxx. References fArray. Referenced by ComputeError(). 01292 {
01293 if(size < 1)
01294 {
01295 cerr << "Error::Create - can not create zero size array" << endl;
01296 return 0;
01297 }
01298
01299 double *a = new double[size];
01300
01301 for(int i = 0; i < size; ++i)
01302 {
01303 a[i] = 0.0;
01304 }
01305
01306 fArray.push_back(a);
01307
01308 return a;
01309 }
|
|
||||||||||||||||||||
|
Definition at line 1239 of file Plot.cxx. References Anp::Hist1d< T >::Fill(), Anp::Hist1d< T >::Merge(), option, and Anp::Hist1d< T >::Reset(). Referenced by GetRatio(). 01240 {
01241 if(!hC || !hO)
01242 {
01243 return 0;
01244 }
01245
01246 const int nbin = hC -> GetNbinsX();
01247
01248 if(hC -> GetNbinsX() != nbin)
01249 {
01250 cerr << "Plot::CreateRatio - mismatched number of bins" << endl;
01251 return 0;
01252 }
01253
01254 TH1 *hR = 0;
01255
01256 if(option.find("merge") != string::npos)
01257 {
01258 Anp::Hist1d<double> hist(*hO);
01259
01260 hist.Merge(nmin);
01261 hist.Reset();
01262 hist.Fill(*hC);
01263 hist.Merge(nmin);
01264
01265 hR = Anp::CreateTH1<double>(hist, "hR");
01266 }
01267 else
01268 {
01269 hR = dynamic_cast<TH1 *>(hC -> Clone("hR"));
01270
01271 if(!hR)
01272 {
01273 cerr << "Plot::CreateRatio - failed to clone histogram" << endl;
01274 return 0;
01275 }
01276 }
01277
01278 if(hR)
01279 {
01280 hR -> Reset();
01281 hR -> SetDirectory(0);
01282 hR -> SetStats(false);
01283 hR -> GetXaxis() -> SetTitle(hO -> GetXaxis() -> GetTitle());
01284 hR -> GetXaxis() -> CenterTitle();
01285 }
01286
01287 return hR;
01288 }
|
|
||||||||||||
|
Definition at line 879 of file Plot.cxx. References fBox, fErrorColor, fErrorStyle, fHist, and option. 00880 {
00881 if(!fHist)
00882 {
00883 return 0;
00884 }
00885
00886 TCanvas *canvas = 0;
00887
00888 if(!cname.empty())
00889 {
00890 canvas = new TCanvas(cname.c_str(), cname.c_str(), 0, 0, 650, 400);
00891 canvas -> cd();
00892
00893 if(cname.find("grid") != string::npos) canvas -> SetGrid();
00894 if(cname.find("log") != string::npos) canvas -> SetLogy();
00895
00896 canvas -> Draw();
00897 }
00898
00899 fHist -> Draw(option.c_str());
00900
00901 if(option.find("E") != string::npos)
00902 {
00903 TH1 *hc = dynamic_cast<TH1 *> (fHist -> Clone("hc"));
00904 hc -> SetDirectory(0);
00905 hc -> Draw("same HIST");
00906 }
00907
00908 if(fErrorColor > 0 && fErrorStyle > 0)
00909 {
00910 const int bmin = fHist -> GetXaxis() -> GetFirst();
00911 const int bmax = fHist -> GetXaxis() -> GetLast();
00912
00913 for(map<int, TBox *>::const_iterator it = fBox.begin(); it != fBox.end(); ++it)
00914 {
00915 const int ibin = it -> first;
00916
00917 if(ibin < bmin || ibin > bmax)
00918 {
00919 continue;
00920 }
00921
00922 TBox *box = it -> second;
00923 if(!box)
00924 {
00925 continue;
00926 }
00927
00928 box -> SetFillColor(fErrorColor);
00929 box -> SetFillStyle(fErrorStyle);
00930 box -> Draw();
00931 }
00932 }
00933
00934 gPad -> Modified();
00935 gPad -> Update();
00936
00937 return canvas;
00938 }
|
|
|
Definition at line 413 of file Plot.cxx. References fBlock, fHist, fHistPath, and Anp::Draw::Read(). 00414 {
00415 pair<TH1 *, DataBlock> result = Hist::Read(hpath);
00416
00417 if(!result.first) return 0;
00418
00419 fHistPath = hpath;
00420 fHist = result.first;
00421 fBlock = result.second;
00422
00423 return fHist;
00424 }
|
|
|
Definition at line 624 of file Plot.cxx. 00625 {
00626 return fBlock;
00627 }
|
|
|
Definition at line 573 of file Plot.cxx. References option. Referenced by Scale(). 00574 {
00575 TH1 *h = fHist;
00576
00577 if(option.find("l") != string::npos)
00578 {
00579 h = fHistL;
00580 }
00581 else if(option.find("h") != string::npos)
00582 {
00583 h = fHistH;
00584 }
00585
00586 if(!h)
00587 {
00588 return 0.0;
00589 }
00590
00591 long double area = 0.0;
00592
00593 int lbin = 1, hbin = h -> GetNbinsX();
00594
00595 if(option.find("u") != string::npos)
00596 {
00597 --lbin;
00598 }
00599 if(option.find("o") != string::npos)
00600 {
00601 ++hbin;
00602 }
00603
00604 for(int ibin = lbin; ibin <= hbin; ++ibin)
00605 {
00606 const long double value = h -> GetBinContent(ibin);
00607
00608 if(value > 0.0)
00609 {
00610 area += value;
00611 }
00612 }
00613
00614 return static_cast<double>(area);
00615 }
|
|
|
Definition at line 630 of file Plot.cxx. Referenced by Plot::GetChi2(). 00631 {
00632 return fError;
00633 }
|
|
|
Definition at line 997 of file Plot.cxx. References option. Referenced by Plot::GetChi2(), and GetRatio(). 00998 {
00999 TH1 *h = fHist;
01000
01001 if(option.find("l") != string::npos)
01002 {
01003 h = fHistL;
01004 }
01005 else if(option.find("h") != string::npos)
01006 {
01007 h = fHistH;
01008 }
01009
01010 return h;
01011 }
|
|
|
Definition at line 618 of file Plot.cxx. References fBlock, and DataBlock::GetProtonsOut(). Referenced by Scale(). 00619 {
00620 return fBlock.GetProtonsOut();
00621 }
|
|
||||||||||||||||||||||||
|
Definition at line 1014 of file Plot.cxx. References CreateRatio(), fHist, Anp::Hist1d< T >::Fill(), GetHist(), option, and Anp::Hist1d< T >::Reset(). 01016 {
01017 //
01018 // Divide OTHER histogram by THIS histogram with error bars
01019 //
01020
01021 if(!fHist || !other.GetHist())
01022 {
01023 cerr << "Error::GetRatio - invalid histogram pointer(s)" << endl;
01024 return 0;
01025 }
01026
01027 TH1 *hC = fHist;
01028 TH1 *hL = fHistL;
01029 TH1 *hH = fHistH;
01030 TH1 *hO = other.GetHist();
01031
01032 const int nbin = hC -> GetNbinsX();
01033 const double nmin = 1000;
01034
01035 if(hC -> GetNbinsX() != nbin)
01036 {
01037 cerr << "Error::GetRatio - mismatched number of bins" << endl;
01038 return 0;
01039 }
01040
01041 TH1 *hR = CreateRatio(hC, hO, option, nmin);
01042 if(!hR)
01043 {
01044 cerr << "Error::GetRatio - failed to create ratio histogram" << endl;
01045 return 0;
01046 }
01047 else if(option.find("merge") != string::npos)
01048 {
01049 if(hL && hH)
01050 {
01051 Anp::Hist1d<double> histL(*hR);
01052 Anp::Hist1d<double> histH(*hR);
01053
01054 histL.Reset();
01055 histH.Reset();
01056
01057 histL.Fill(*hL);
01058 histH.Fill(*hH);
01059
01060 hL = Anp::CreateTH1<double>(histL, "hL");
01061 hH = Anp::CreateTH1<double>(histH, "hH");
01062 }
01063
01064 Anp::Hist1d<double> histC(*hR);
01065 Anp::Hist1d<double> histO(*hR);
01066
01067 histC.Reset();
01068 histO.Reset();
01069
01070 histC.Fill(*hC);
01071 histO.Fill(*hO);
01072
01073 hC = Anp::CreateTH1<double>(histC, "hC");
01074 hO = Anp::CreateTH1<double>(histO, "hO");
01075 }
01076
01077 double miny = -1.0, maxy = -1.0;
01078
01079 const int rbin = hR -> GetNbinsX();
01080
01081 for(int ibin = 1; ibin <= rbin; ++ibin)
01082 {
01083 const double valueC = hC -> GetBinContent(ibin);
01084 const double valueO = hO -> GetBinContent(ibin);
01085
01086 if(!(valueC > 0) || !(valueO > 0))
01087 {
01088 continue;
01089 }
01090
01091 if(std::fabs(hC ->GetBinLowEdge(ibin)-hO->GetBinLowEdge(ibin)) > 0.00001*hC->GetBinWidth(ibin))
01092 {
01093 cerr << "Hist::GetRatio - invalid lower bin edge for hC and hO" << endl;
01094 continue;
01095 }
01096
01097 double errorC = std::sqrt(valueC);
01098 double errorO = std::sqrt(valueO);
01099
01100 if(hH && hL)
01101 {
01102 if(std::fabs(hC -> GetBinLowEdge(ibin) - hH -> GetBinLowEdge(ibin)) >
01103 0.00001*hC -> GetBinWidth(ibin) ||
01104 std::fabs(hC -> GetBinLowEdge(ibin) - hL -> GetBinLowEdge(ibin)) >
01105 0.00001*hC -> GetBinWidth(ibin))
01106 {
01107 cerr << "Hist::GetRatio - invalid lower bin edge for hC and hL or hH" << endl;
01108 continue;
01109 }
01110
01111 const double errorH = hH -> GetBinContent(ibin) - valueC;
01112 const double errorL = valueC - hL -> GetBinContent(ibin);
01113
01114 //cout << "errorH = " << errorH << endl;
01115 //cout << "errorL = " << errorL << endl;
01116
01117 assert(!(errorH < 0.0) && !(errorL < 0.0) && "Negative errors");
01118
01119 errorC = std::sqrt(valueC);
01120
01121 if(errorH > errorL)
01122 {
01123 errorC += errorH;
01124 }
01125 else
01126 {
01127 errorC += errorL;
01128 }
01129 }
01130
01131 const double ratio = valueO/valueC;
01132 const double error = ratio*(errorO/valueO + errorC/valueC);
01133
01134 hR -> SetBinContent(ibin, ratio);
01135 hR -> SetBinError(ibin, error);
01136
01137 if(maxy < 0.0)
01138 {
01139 miny = ratio - error;
01140 maxy = ratio + error;
01141 }
01142 else
01143 {
01144 miny = std::min<double>(miny, ratio - error);
01145 maxy = std::max<double>(maxy, ratio + error);
01146 }
01147 }
01148
01149 if(maxy > 0.0)
01150 {
01151 const double span = std::fabs(maxy) + std::fabs(miny);
01152 hR -> GetYaxis() -> SetRangeUser(miny - span*factor, maxy + span*factor);
01153 }
01154
01155 if(min_ < max_)
01156 {
01157 hR -> GetYaxis() -> SetRangeUser(min_, max_);
01158 }
01159
01160 if(option.find("L") != string::npos)
01161 {
01162 TLine *line = 0;
01163
01164 if(min_ < max_)
01165 {
01166 line = new TLine(min_, 1.0, max_, 1.0);
01167 }
01168 else
01169 {
01170 line = new TLine(hR -> GetXaxis() -> GetXmin(), 1.0, hR -> GetXaxis() -> GetXmax(), 1.0);
01171 }
01172
01173 line -> SetLineWidth(1);
01174 hR -> GetListOfFunctions() -> Add(line);
01175 }
01176
01177 if(option.find("merge") != string::npos)
01178 {
01179 if(hO) delete hO;
01180 if(hC) delete hC;
01181 if(hL) delete hL;
01182 if(hH) delete hH;
01183 }
01184
01185 return hR;
01186 }
|
|
||||||||||||||||||||||||
|
Definition at line 948 of file Plot.cxx. 00949 {
00950 if(!fHist || !gPad)
00951 {
00952 return 0;
00953 }
00954
00955 gPad -> Modified();
00956 gPad -> Update();
00957
00958 TPaveStats* stat = dynamic_cast<TPaveStats *> (fHist -> FindObject("stats"));
00959 if(!stat)
00960 {
00961 if(option.find("V") != string::npos)
00962 {
00963 cerr << "Hist::Move - no statistics box is present" << endl;
00964 }
00965 return 0;
00966 }
00967
00968 int color = fHist -> GetLineColor();
00969 if(option.find("M") != string::npos)
00970 {
00971 color = fHist -> GetMarkerColor();
00972 }
00973
00974 stat -> SetStatFormat("6.3f");
00975 stat -> SetTextColor(color);
00976 stat -> SetLineColor(color);
00977 //stat -> SetOptStat(1111110);
00978
00979 if(option.find("V") != string::npos)
00980 {
00981 cout << "Hist::Move - left lower corner = (" << x << ", " << y << ") and "
00982 << "right upper corner = (" << x + w << ", " << y + h << ")" << endl;
00983 }
00984
00985 stat -> SetX1NDC(x);
00986 stat -> SetY1NDC(y);
00987 stat -> SetX2NDC(x + w);
00988 stat -> SetY2NDC(y + h);
00989
00990 gPad -> Modified();
00991 gPad -> Update();
00992
00993 return stat;
00994 }
|
|
|
Definition at line 777 of file Plot.cxx. References fHist, fHistH, fHistL, and option. 00778 {
00779 if(!fHist)
00780 {
00781 return;
00782 }
00783
00784 bool do_error = true;
00785 if(option.find("no_error") != string::npos)
00786 {
00787 do_error = false;
00788 }
00789
00790 for(int ibin = 1; ibin <= fHist -> GetNbinsX(); ++ibin)
00791 {
00792 const double value = fHist -> GetBinContent(ibin);
00793 const double error = fHist -> GetBinError(ibin);
00794 const double width = fHist -> GetBinWidth(ibin);
00795
00796 if(!(width > 0.0)) continue;
00797
00798 fHist -> SetBinContent(ibin, value/width);
00799 if(do_error) fHist -> SetBinError(ibin, error/width);
00800
00801 if(fHistL)
00802 {
00803 const double valueL = fHistL -> GetBinContent(ibin);
00804 const double errorL = fHistL -> GetBinError(ibin);
00805
00806 fHistL -> SetBinContent(ibin, valueL/width);
00807 if(do_error) fHistL -> SetBinError(ibin, errorL/width);
00808 }
00809
00810 if(fHistH)
00811 {
00812 const double valueH = fHistH -> GetBinContent(ibin);
00813 const double errorH = fHistH -> GetBinError(ibin);
00814
00815 fHistH -> SetBinContent(ibin, valueH/width);
00816 if(do_error) fHistH -> SetBinError(ibin, errorH/width);
00817 }
00818 }
00819 }
|
|
|
Definition at line 567 of file Plot.cxx. 00568 {
00569 return fHist;
00570 }
|
|
|
Definition at line 1189 of file Plot.cxx. References fBlokPath, and fFilePath. 01190 {
01191 pair<TH1 *, DataBlock> result;
01192 result.first = 0;
01193
01194 if(fFilePath.size() < 6)
01195 {
01196 return result;
01197 }
01198
01199 TFile file(fFilePath.c_str(), "READ");
01200 if(!file.IsOpen())
01201 {
01202 cerr << "Hist::Read - Failed to open ROOT file " << fFilePath << endl;
01203 return result;
01204 }
01205
01206 TH1 *h = dynamic_cast<TH1 *>(file.Get(hpath.c_str()));
01207 if(!h)
01208 {
01209 cerr << "Plot::Read - failed to find histogram " << hpath << endl;
01210 return result;
01211 }
01212
01213 h = dynamic_cast<TH1 *>(h -> Clone());
01214 if(h)
01215 {
01216 h -> SetDirectory(0);
01217 }
01218 else
01219 {
01220 cerr << "Hist::Read - failed to clone TH1" << endl;
01221 }
01222
01223 result.first = h;
01224
01225 DataBlock *block = dynamic_cast<DataBlock *>(file.Get(fBlokPath.c_str()));
01226 if(block)
01227 {
01228 result.second = *block;
01229 }
01230 else
01231 {
01232 cout << "Plot::Read - failed to find DataBlock in " << file.GetName() << endl;
01233 }
01234
01235 return result;
01236 }
|
|
||||||||||||
|
Definition at line 692 of file Plot.cxx. References fHist, fHistH, fHistL, Nav::GetName(), and option. 00693 {
00694 if(!h || !fHist)
00695 {
00696 return;
00697 }
00698
00699 if(h -> GetNbinsX() < fHist -> GetNbinsX())
00700 {
00701 cerr << "Hist::Rebin - number of bins is too small" << endl;
00702 return;
00703 }
00704
00705 string xtitle, ytitle;
00706 if(fHist -> GetXaxis() -> GetTitle()) xtitle = fHist -> GetXaxis() -> GetTitle();
00707 if(fHist -> GetYaxis() -> GetTitle()) ytitle = fHist -> GetYaxis() -> GetTitle();
00708
00709 Anp::Hist1d<double> hC(*h);
00710
00711 TH1 *hC_ = Anp::CreateTH1<double>(hC, fHist -> GetName());
00712
00713 // set initial small non-zero bin content
00714 if(option.find("no-init") == string::npos)
00715 {
00716 for(int ibin = 0; ibin <= hC_ -> GetNbinsX(); ++ibin)
00717 {
00718 hC_ -> SetBinContent(ibin, 1.0e-6);
00719 hC_ -> SetBinError(ibin, 1.0);
00720 }
00721 }
00722
00723 // refill new histogram
00724 for(int ibin = 0; ibin <= fHist -> GetNbinsX(); ++ibin)
00725 {
00726 if(fHist -> GetBinContent(ibin) > 0.0)
00727 {
00728 hC_ -> SetBinContent(ibin, fHist -> GetBinContent(ibin));
00729 hC_ -> SetBinError (ibin, fHist -> GetBinError(ibin));
00730 }
00731 }
00732
00733 delete fHist; fHist = hC_;
00734
00735 if(!xtitle.empty()) fHist -> GetXaxis() -> SetTitle(xtitle.c_str());
00736 if(!ytitle.empty()) fHist -> GetYaxis() -> SetTitle(ytitle.c_str());
00737
00738 fHist -> GetXaxis() -> CenterTitle();
00739 fHist -> GetYaxis() -> CenterTitle();
00740
00741 if(fHistL && fHistH)
00742 {
00743 Anp::Hist1d<double> hL(*h);
00744 Anp::Hist1d<double> hH(*h);
00745
00746 TH1 *hL_ = Anp::CreateTH1<double>(hL, fHistL -> GetName());
00747 TH1 *hH_ = Anp::CreateTH1<double>(hH, fHistH -> GetName());
00748
00749 // set initial small non-zero bin content
00750 for(int ibin = 0; ibin <= hC_ -> GetNbinsX(); ++ibin)
00751 {
00752 hL_ -> SetBinContent(ibin, 1.0e-6);
00753 hH_ -> SetBinContent(ibin, 1.0e-6);
00754
00755 hL_ -> SetBinError(ibin, 1.0);
00756 hH_ -> SetBinError(ibin, 1.0);
00757 }
00758
00759 // refill new histograms
00760 for(int ibin = 0; ibin <= fHist -> GetNbinsX(); ++ibin)
00761 {
00762 hL_ -> SetBinContent(ibin, fHistL -> GetBinContent(ibin));
00763 hL_ -> SetBinError (ibin, fHistL -> GetBinError(ibin));
00764
00765 hH_ -> SetBinContent(ibin, fHistH -> GetBinContent(ibin));
00766 hH_ -> SetBinError (ibin, fHistH -> GetBinError(ibin));
00767 }
00768
00769 delete fHistL; fHistL = hL_;
00770 delete fHistH; fHistH = hH_;
00771
00772 Hist::ComputeError();
00773 }
00774 }
|
|
||||||||||||
|
Definition at line 636 of file Plot.cxx. References ComputeError(), fHist, fHistH, fHistL, Nav::GetName(), option, and Anp::Hist1d< T >::Rebin(). 00637 {
00638 if(!fHist || ngroup < 2)
00639 {
00640 return;
00641 }
00642
00643 if(option.find("TH1") != string::npos)
00644 {
00645 fHist -> Rebin(ngroup);
00646
00647 if(fHistL && fHistH)
00648 {
00649 fHistL -> Rebin(ngroup);
00650 fHistH -> Rebin(ngroup);
00651
00652 ComputeError();
00653 }
00654 }
00655 else
00656 {
00657 string xtitle, ytitle;
00658 if(fHist -> GetXaxis() -> GetTitle()) xtitle = fHist -> GetXaxis() -> GetTitle();
00659 if(fHist -> GetYaxis() -> GetTitle()) ytitle = fHist -> GetYaxis() -> GetTitle();
00660
00661 Anp::Hist1d<double> hC(*fHist);
00662 hC.Rebin(ngroup);
00663 TH1 *hC_ = Anp::CreateTH1<double>(hC, fHist -> GetName());
00664 delete fHist; fHist = hC_;
00665
00666 if(!xtitle.empty()) fHist -> GetXaxis() -> SetTitle(xtitle.c_str());
00667 if(!ytitle.empty()) fHist -> GetYaxis() -> SetTitle(ytitle.c_str());
00668
00669 fHist -> GetXaxis() -> CenterTitle();
00670 fHist -> GetYaxis() -> CenterTitle();
00671
00672 if(fHistL && fHistH)
00673 {
00674 Anp::Hist1d<double> hL(*fHistL);
00675 Anp::Hist1d<double> hH(*fHistH);
00676
00677 hL.Rebin(ngroup);
00678 hH.Rebin(ngroup);
00679
00680 TH1 *hL_ = Anp::CreateTH1<double>(hL, fHistL -> GetName());
00681 TH1 *hH_ = Anp::CreateTH1<double>(hH, fHistH -> GetName());
00682
00683 delete fHistL; fHistL = hL_;
00684 delete fHistH; fHistH = hH_;
00685
00686 ComputeError();
00687 }
00688 }
00689 }
|
|
||||||||||||
|
Definition at line 822 of file Plot.cxx. References ComputeError(), fHist, fHistH, fHistL, GetEntries(), GetProtons(), and option. 00823 {
00824 if(!fHist)
00825 {
00826 return 0;
00827 }
00828
00829 const double area = GetEntries("uo");
00830
00831 double scale = 1.0;
00832
00833 if(option.find("area") != string::npos)
00834 {
00835 if(area > 0.0)
00836 {
00837 scale = 1.0/area;
00838 }
00839 }
00840 else if(option.find("ent") != string::npos)
00841 {
00842 const double area_other = other.GetEntries("");
00843 if(area > 0.0 && area_other > 0.0)
00844 {
00845 scale = area_other/area;
00846 }
00847 }
00848 else if(option.find("pot") != string::npos)
00849 {
00850 if(Hist::GetProtons() > 0.0 && other.GetProtons() > 0.0)
00851 {
00852 scale = other.GetProtons()/Hist::GetProtons();
00853 }
00854 }
00855
00856 const double entries = GetEntries("uo");
00857 const double entriesl = GetEntries("l uo");
00858 const double entriesh = GetEntries("h uo");
00859
00860 fHist -> Scale(scale);
00861
00862 if(fHistL) fHistL -> Scale(scale);
00863 if(fHistH) fHistH -> Scale(scale);
00864
00865 if(option.find("area") == string::npos)
00866 {
00867 fHist -> SetEntries(entries * scale);
00868
00869 if(fHistL) fHistL -> SetEntries(entriesl * scale);
00870 if(fHistH) fHistH -> SetEntries(entriesh * scale);
00871 }
00872
00873 ComputeError();
00874
00875 return fHist;
00876 }
|
|
||||||||||||
|
Definition at line 383 of file Plot.cxx. References fBlokPath, and fFilePath. Referenced by Hist(). 00384 {
00385 if(fpath.size() < 6)
00386 {
00387 return false;
00388 }
00389
00390 TFile file(fpath.c_str(), "READ");
00391 if(!file.IsOpen())
00392 {
00393 cerr << "Failed to open ROOT file " << fpath << endl;
00394 return false;
00395 }
00396
00397 fBlokPath = block;
00398 fFilePath = fpath;
00399
00400 return true;
00401 }
|
|
||||||||||||
|
Definition at line 941 of file Plot.cxx. References fErrorColor, and fErrorStyle. 00942 {
00943 fErrorColor = color;
00944 fErrorStyle = style;
00945 }
|
|
||||||||||||
|
Definition at line 427 of file Plot.cxx. References fHistH, fHistL, fHistPathH, fHistPathL, and Anp::Draw::Read(). 00428 {
00429 pair<TH1 *, DataBlock> lresult = Hist::Read(lpath);
00430 pair<TH1 *, DataBlock> hresult = Hist::Read(hpath);
00431
00432 if(!lresult.first || !hresult.first)
00433 {
00434 return 0;
00435 }
00436
00437 if(fHistL) delete fHistL;
00438 if(fHistH) delete fHistH;
00439
00440 fHistPathL = lpath;
00441 fHistPathH = hpath;
00442
00443 fHistL = lresult.first;
00444 fHistH = hresult.first;
00445
00446 return Hist::ComputeError();
00447 }
|
|
|
Definition at line 404 of file Plot.cxx. References fBlock, and DataBlock::SetProtons(). 00405 {
00406 if(protons > 0.0)
00407 {
00408 fBlock.SetProtons(protons);
00409 }
00410 }
|
|
|
Definition at line 156 of file Plot.h. Referenced by ClearError(), and ComputeError(). |
|
|
Definition at line 160 of file Plot.h. Referenced by ClearError(), and Create(). |
|
|
Definition at line 151 of file Plot.h. Referenced by Get(), GetProtons(), and SetProtons(). |
|
|
|
|
|
Definition at line 159 of file Plot.h. Referenced by ClearError(), ComputeError(), and Draw(). |
|
|
Definition at line 158 of file Plot.h. Referenced by ClearError(), and ComputeError(). |
|
|
Definition at line 153 of file Plot.h. Referenced by Draw(), and SetErrorStyle(). |
|
|
Definition at line 154 of file Plot.h. Referenced by Draw(), and SetErrorStyle(). |
|
|
|
|
|
Definition at line 147 of file Plot.h. Referenced by Draw(), Get(), GetRatio(), MoveStat(), NormalizeOnWidth(), Rebin(), and Scale(). |
|
|
Definition at line 149 of file Plot.h. Referenced by NormalizeOnWidth(), Rebin(), Scale(), and SetLH(). |
|
|
Definition at line 148 of file Plot.h. Referenced by NormalizeOnWidth(), Rebin(), Scale(), and SetLH(). |
|
|
Definition at line 143 of file Plot.h. Referenced by Get(). |
|
|
Definition at line 145 of file Plot.h. Referenced by SetLH(). |
|
|
Definition at line 144 of file Plot.h. Referenced by SetLH(). |
1.3.9.1