ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/GeneralToolBox.C
(Generate patch)

Comparing UserCode/cbrown/Development/Plotting/Modules/GeneralToolBox.C (file contents):
Revision 1.22 by fronga, Tue Nov 13 13:27:37 2012 UTC vs.
Revision 1.23 by buchmann, Thu Nov 22 09:01:30 2012 UTC

# Line 1803 | Line 1803 | string removefunnystring(string name) {
1803    return name;
1804   }
1805  
1806 + TPolyLine* GetFitUncertaintyShape(TH1F *histo, string fitname, float low, float high) {
1807 +  TF1 *fit = (TF1*)histo->GetFunction(fitname.c_str());
1808 +  if(!fit) {
1809 +    cout << "CANNOT PRODUCE FIT UNCERTAINTY AS THERE IS NO FIT CALLED " << fitname << " IN " << histo->GetName() << endl;
1810 +    return NULL;
1811 +  }
1812 +  
1813 +  int nPoints=1000;
1814 +  
1815 +  double x[nPoints+1];
1816 +  double y[nPoints];
1817 +  
1818 +  float par1=fit->GetParameter(0);
1819 +  float dpar1=fit->GetParError(0);
1820 +  float par2=fit->GetParameter(1);
1821 +  float dpar2=fit->GetParError(1);
1822 +    
1823 +  float x0=histo->GetBinLowEdge(1);
1824 +  float x1=histo->GetBinLowEdge(histo->GetNbinsX())+histo->GetBinWidth(histo->GetNbinsX());
1825 +  float step=(x1-x0)/(nPoints/2.0 -1);
1826 +  for(int i=0;i<nPoints/2.0;i++) {
1827 +    x[i]=x0+i*step;
1828 +    y[i]=(par1+x[i]*par2)    -    sqrt(dpar1*dpar1+dpar2*dpar2*x[i]*x[i]);
1829 +    x[nPoints-1-i]=x[i];
1830 +    y[nPoints-1-i]=(par1+x[i]*par2)    +    sqrt(dpar1*dpar1+dpar2*dpar2*x[i]*x[i]);
1831 +    if(y[i]<low) y[i]=low;
1832 +    if(y[i]>high) y[i]=high;
1833 +    if(y[nPoints-1-i]<low) y[nPoints-1-i]=low;
1834 +    if(y[nPoints-1-i]>high) y[nPoints-1-i]=high;
1835 +  }
1836 +  
1837 +  x[nPoints]=x[0];
1838 +  y[nPoints]=y[0];
1839 +  
1840 +  TPolyLine *l = new TPolyLine(nPoints+1,x,y);
1841 +  l->SetFillColor(TColor::GetColor("#5858FA"));
1842 +  l->SetLineWidth(2);
1843 +  return l;
1844 + }
1845 +
1846   stringstream all_bugs;
1847  
1848   void bug_tracker(string function, int line, string description) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines