NuContour Class Reference

#include <NuContour.h>

List of all members.

Public Member Functions

 NuContour ()
 NuContour (const TH2D *hin)
 NuContour (const TGraph *g)
 NuContour (const NuContour &rhs)
NuContouroperator= (const NuContour &rhs)
virtual ~NuContour ()
void Reset ()
void Reset (TH2D *hin)
void Reset (TGraph *g)
void AddExtraHist (TH2D *hin, double crossover)
void Combine (TH2D *correction)
void Combine (TH2D *correction_low, TH2D *correction_high)
void SetGauss (double level)
void SetFC (TH2D *correction)
void ContourStyle (int color, int width=3, int style=1)
void ContourFillStyle (int color, int style=1001)
void DoLin ()
void DoLogLin ()
void DoLog ()
bool IsLin ()
bool IsLogLin ()
bool IsLog ()
TH2D * GetHist (bool nowarn=false)
TGraph * GetGraph (bool nowarn=false)
TAxis * GetXaxis ()
TAxis * GetYaxis ()
void ConvertToGraph ()
void AddCorner (bool upper, bool right)
void CompleteGraph ()
void Draw (TString opt="")
void AddToLegend (TLegend *leg, TString label)
void SetFontAndSize (int textFont, int textSize)
void FixCanvas (TCanvas *c1)
void DrawAxes (int size=-1)
void DispBins (int n)
int DispBins ()
void LogMax (double y)
void LogMin (double y)
double Can2Cont (double bin)
double Cont2Can (double y)

Private Member Functions

TH2D * GetNormal ()
TH2D * GetLogLin ()
TH2D * GetLog ()
TGraph * GetNormalGraph ()
TGraph * GetLogLinGraph ()
TGraph * GetLogGraph ()
void DrawNormal (TString opt="")
void DrawLogLin (TString opt="")
void DrawLog (TString opt="")
void Add (TH2D *surface, TH2D *correction, double scale=1, bool convert=false)
void GenerateLogLin ()
void GenerateLog ()
void GenerateLogLinHist ()
void GenerateLogHist ()
void GenerateLogLinGraph ()
double interpolate (TH2D *h, double x, double y, double def=999.)
void ChooseContour (TH2 *h)
 ClassDef (NuContour, 0)

Static Private Member Functions

static Double_t MinBin (const TH2D &hist)
static void ShiftHist (TH2D *hist, Double_t shift)

Private Attributes

bool lin
bool loglin
bool log
int fillLevel
double contLevel
double neg
TH2D * hist
TH2D * disp_hist
TH2D * hist_high
TGraph * graph
TGraph * disp_graph
double hdivide
double ymid
double ymax
int bmid
int bmax

Static Private Attributes

static int nFillCols = 10
static int usedFills = 0
static Int_t * colFill = 0

Detailed Description

Definition at line 13 of file NuContour.h.


Constructor & Destructor Documentation

NuContour::NuContour (  ) 

Definition at line 28 of file NtupleUtils/HEAD/NuContour.cxx.

References colFill, disp_graph, disp_hist, graph, hist, and hist_high.

00029   : lin(true), loglin(false), log(false), 
00030     fillLevel(-1), contLevel(0), neg(1),
00031     hdivide(9999), ymid(0), bmid(250), bmax(500)
00032 {
00033   if (!colFill) {
00034     colFill = new Int_t[10];
00035     for (int i = 0; i < 10; i++) {
00036       colFill[i] = 0;
00037     }
00038   }
00039   
00040   hist = 0;
00041   disp_hist = 0;
00042   hist_high = 0;
00043   
00044   graph = 0;
00045   disp_graph = 0;
00046 }

NuContour::NuContour ( const TH2D *  hin  ) 

Definition at line 50 of file NtupleUtils/HEAD/NuContour.cxx.

References colFill, disp_graph, disp_hist, graph, hist, and hist_high.

00051   : lin(true), loglin(false), log(false),
00052     fillLevel(-1), contLevel(0),  neg(1),
00053     hdivide(9999), ymid(0), bmid(250), bmax(500)
00054 {
00055   if (!colFill) {
00056     colFill = new Int_t[10];
00057     for (int i = 0; i < 10; i++) {
00058       colFill[i] = 0;
00059     }
00060   }
00061   
00062   hist = new TH2D(*hin);
00063   disp_hist = 0;
00064   hist_high = 0;
00065   
00066   graph = 0;
00067   disp_graph = 0;
00068 }

NuContour::NuContour ( const TGraph *  g  ) 

Definition at line 72 of file NtupleUtils/HEAD/NuContour.cxx.

References colFill, disp_graph, disp_hist, graph, hist, and hist_high.

00073   : lin(true), loglin(false), log(false),
00074     fillLevel(-1), contLevel(0),  neg(1),
00075     hdivide(9999), ymid(0), bmid(250), bmax(500)
00076 {
00077   
00078   if (!colFill) {
00079     colFill = new Int_t[10];
00080     for (int i = 0; i < 10; i++) {
00081       colFill[i] = 0;
00082     }
00083   }
00084   
00085   hist = 0;
00086   disp_hist = 0;
00087   hist_high = 0;
00088   
00089   graph = new TGraph(*g);
00090   disp_graph = 0;
00091 }

NuContour::NuContour ( const NuContour rhs  ) 

Definition at line 95 of file NtupleUtils/HEAD/NuContour.cxx.

References bmax, bmid, contLevel, disp_graph, disp_hist, fillLevel, graph, hdivide, hist, hist_high, lin, log, loglin, neg, Reset(), ymax, and ymid.

00096 {
00097   Reset();
00098   if (rhs.hist) hist = new TH2D(*rhs.hist);
00099   if (rhs.disp_hist) disp_hist =  new TH2D(*rhs.disp_hist);
00100   if (rhs.hist_high) hist_high =  new TH2D(*rhs.hist_high);
00101   if (rhs.graph) graph = new TGraph(*rhs.graph);
00102   if (rhs.disp_graph) disp_graph = new TGraph(*rhs.disp_graph);
00103 
00104   lin = rhs.lin;
00105   loglin = rhs.loglin;
00106   log = rhs.log;
00107   fillLevel = rhs.fillLevel;
00108   contLevel = rhs.contLevel;
00109   neg = rhs.neg;
00110     hdivide = rhs.hdivide;
00111   ymid = rhs.ymid;
00112   ymax = rhs.ymax;
00113   bmid = rhs.bmid;
00114   bmax = rhs.bmax;
00115 }

NuContour::~NuContour (  )  [virtual]

Definition at line 148 of file NtupleUtils/HEAD/NuContour.cxx.

References Reset().

00149 {
00150     Reset();
00151 }


Member Function Documentation

void NuContour::Add ( TH2D *  surface,
TH2D *  correction,
double  scale = 1,
bool  convert = false 
) [private]

Definition at line 317 of file NtupleUtils/HEAD/NuContour.cxx.

References Can2Cont(), and interpolate().

Referenced by Combine(), and SetFC().

00318 {
00319   double xval, yval, val, corr;
00320 
00321   for (int xbin = 1; xbin <= surface->GetNbinsX(); xbin++) {
00322     for (int ybin = 1; ybin <= surface->GetNbinsY(); ybin++) {
00323       val = surface->GetBinContent(xbin, ybin);
00324 
00325       xval = surface->GetXaxis()->GetBinCenter(xbin);
00326       yval = surface->GetYaxis()->GetBinCenter(ybin);
00327       if (convert) yval = Can2Cont(yval);
00328       
00329       corr = interpolate(correction, xval, yval, 0);
00330 
00331       surface->SetBinContent(xbin, ybin, val + scale*corr);
00332     }
00333   }
00334 }

void NuContour::AddCorner ( bool  upper,
bool  right 
)

Definition at line 659 of file NtupleUtils/HEAD/NuContour.cxx.

References bmax, disp_graph, graph, IsLog(), ymax, and ymid.

00660 {
00661     double x, y, yd;
00662     if (upper) {
00663         y = ymax;
00664         yd = bmax;
00665     }
00666     else {
00667         if (IsLog())  y = ymid;
00668         else          y = 0;
00669         yd = 0;
00670     }
00671     if (right) x = 1;
00672     else       x = 0;
00673        
00674     disp_graph->SetPoint(disp_graph->GetN(), x, yd);
00675     graph->SetPoint(graph->GetN(), x, y);
00676 }

void NuContour::AddExtraHist ( TH2D *  hin,
double  crossover 
)

Definition at line 192 of file NtupleUtils/HEAD/NuContour.cxx.

References DoLog(), DoLogLin(), hdivide, hist_high, IsLog(), and IsLogLin().

Referenced by Combine().

00193 {
00194     hist_high = new TH2D(*hin);
00195     hdivide = crossover;
00196 /*
00197     cout << "Min of hist = " << MinBin(*hist) << endl;
00198     cout << "Min of hist_high = " << MinBin(*hist_high) << endl;
00199     Double_t diff = MinBin(*hist) - MinBin(*hist_high);
00200     if (diff < 0) {
00201         cout << "Shifting hist_high by " << diff << endl;
00202         ShiftHist(hist_high, diff);
00203     }
00204     else {
00205         cout << "Shifting high by " << -diff << endl;
00206         ShiftHist(hist,     -diff);
00207     }
00208 */
00209     if (IsLogLin()) DoLogLin();
00210     if (IsLog())    DoLog();
00211 }

void NuContour::AddToLegend ( TLegend *  leg,
TString  label 
)

Definition at line 1058 of file NtupleUtils/HEAD/NuContour.cxx.

References disp_graph, fillLevel, GetGraph(), GetHist(), and graph.

01059 {
01060     TString opt;
01061     if (fillLevel >= 0) opt = "bf";
01062     else                opt = "l";
01063 
01064     if (graph || disp_graph) {
01065         leg->AddEntry(GetGraph(), label, opt);
01066     }
01067     else {
01068         leg->AddEntry(GetHist(), label, opt);
01069     }
01070 }

double NuContour::Can2Cont ( double  bin  ) 

Definition at line 1233 of file NtupleUtils/HEAD/NuContour.cxx.

References bmax, bmid, IsLin(), ymax, and ymid.

Referenced by Add(), ConvertToGraph(), GenerateLogHist(), and GenerateLogLinHist().

01234 {
01235 //    if (IsLog()) {
01236 //        return disp_hist->GetYaxis()->GetBinCenter(bin);
01237 //    }
01238     if (IsLin()) return bin;
01239     
01240     double c = TMath::Log10(ymax/ymid)/(bmax-bmid);
01241     double y;
01242     if (bin < bmid) {
01243         y = ymid / bmid * bin;
01244     } 
01245     else {
01246         y = ymid*pow(10, c * (bin - bmid));
01247     }
01248     return y;
01249 }

void NuContour::ChooseContour ( TH2 *  h  )  [private]

Definition at line 1305 of file NtupleUtils/HEAD/NuContour.cxx.

References contLevel, fillLevel, neg, and nFillCols.

Referenced by ContourFillStyle(), ContourStyle(), ConvertToGraph(), SetFC(), and SetGauss().

01306 {   
01307     h->SetContour(fillLevel+1);
01308     
01309     if (fillLevel < 0) {
01310         h->SetContour(1);
01311         h->SetContourLevel(0, neg*contLevel);
01312     }
01313     else {
01314         h->SetContour(nFillCols);
01315         //h->SetContourLevel(0, -999);
01316         for (int i = 0; i < nFillCols; i++) {
01317             if (i >= nFillCols-fillLevel-1)  h->SetContourLevel(i, 0);
01318             else                             h->SetContourLevel(i, 999);
01319         }
01320     }
01321                     
01322 //    
01323 //    else if (fillLevel == 0) {
01324 //        h->SetContour(3);
01325 //        h->SetContourLevel(0, neg*contLevel);
01326 //        h->SetContourLevel(1, neg*contLevel);
01327 //        h->SetContourLevel(2, neg*contLevel);
01328 //        //h->SetContourLevel(3, neg*999.);
01329 //    }
01330 //    else if (fillLevel == 1) {
01331 //        h->SetContour(3);
01332 //        h->SetContourLevel(0, neg*contLevel);
01333 //        h->SetContourLevel(1, neg*contLevel);
01334 //        h->SetContourLevel(2, neg*999.);
01335 //        //h->SetContourLevel(3, neg*999.);
01336 //    }
01337 //    else if (fillLevel == 2) {
01338 //        h->SetContour(3);
01339 //        h->SetContourLevel(0, neg*contLevel);
01340 //        h->SetContourLevel(1, neg*999.);
01341 //        h->SetContourLevel(2, neg*999.);
01342 //        //h->SetContourLevel(3, neg*999.);
01343 //    }
01344 //    
01345     
01346     h->SetDirectory(0);
01347 }

NuContour::ClassDef ( NuContour  ,
 
) [private]
void NuContour::Combine ( TH2D *  correction_low,
TH2D *  correction_high 
)

Definition at line 237 of file NtupleUtils/HEAD/NuContour.cxx.

References Add(), AddExtraHist(), hdivide, hist, hist_high, min, MinBin(), and ShiftHist().

00238 {
00239     double min = 0;
00240     
00241     if (hist) {
00242         min = MinBin(*hist);
00243         ShiftHist(hist, -min);
00244         Add(hist, correction_low);
00245     }
00246     if (hist_high) {
00247         ShiftHist(hist_high, -min);
00248         Add(hist_high, correction_high);
00249         AddExtraHist(hist_high, hdivide);
00250     }
00251 }

void NuContour::Combine ( TH2D *  correction  ) 

Definition at line 215 of file NtupleUtils/HEAD/NuContour.cxx.

References Add(), disp_hist, hist, hist_high, min, MinBin(), and ShiftHist().

00216 {
00217     double min = 0;
00218 
00219     if (hist) {
00220         min = MinBin(*hist);
00221         ShiftHist(hist, -min);
00222         Add(hist, correction);
00223     }
00224     if (hist_high) {
00225         ShiftHist(hist_high, -min);
00226         Add(hist_high, correction);
00227     }
00228     if (disp_hist) {
00229         ShiftHist(disp_hist, -min);
00230         Add(disp_hist, correction, 1, true);
00231     }
00232     
00233 }

void NuContour::CompleteGraph (  ) 

Definition at line 680 of file NtupleUtils/HEAD/NuContour.cxx.

References disp_graph, graph, Msg::kInfo, and MSG.

00681 {
00682     double x, y;
00683     
00684     if (disp_graph) {
00685         disp_graph->GetPoint(0, x, y);
00686         disp_graph->SetPoint(disp_graph->GetN(), x, y);
00687         MSG("NuContour",Msg::kInfo) << "Completing disp_graph at point (" << x << ", " << y << ")" << endl;
00688     }
00689 
00690     if (graph) {
00691         graph->GetPoint(0, x, y);
00692         graph->SetPoint(graph->GetN(), x, y);
00693         MSG("NuContour",Msg::kInfo) << "Completing graph at point (" << x << ", " << y << ")" << endl;
00694     }
00695 
00696 }

double NuContour::Cont2Can ( double  y  ) 

Definition at line 1253 of file NtupleUtils/HEAD/NuContour.cxx.

References bmax, bmid, IsLin(), ymax, and ymid.

Referenced by DrawAxes(), and GenerateLogLinGraph().

01254 {
01255     if (IsLin()) return y;
01256     
01257     double c = TMath::Log10(ymax/ymid)/(bmax-bmid);
01258     double bin;
01259     if (y <= ymid) {
01260         bin = y * bmid/ymid;
01261     }
01262     else {
01263         bin = 1/c * TMath::Log10(y/ymid)+bmid;
01264     }
01265     //cout << "Cont2Can(" << y << ") = " << bin << endl;    
01266     return bin;
01267 }

void NuContour::ContourFillStyle ( int  color,
int  style = 1001 
)

Definition at line 378 of file NtupleUtils/HEAD/NuContour.cxx.

References ChooseContour(), colFill, disp_graph, disp_hist, fillLevel, graph, hist, hist_high, Msg::kInfo, MSG, neg, nFillCols, and usedFills.

00379 {
00380  
00381     if (graph || disp_graph) {
00382         fillLevel = 999;
00383         if (graph) {
00384             graph->SetFillColor(color);
00385             graph->SetFillStyle(style);
00386         }
00387         if (disp_graph) {
00388             disp_graph->SetFillColor(color);
00389             disp_graph->SetFillStyle(style);
00390         }
00391     }
00392     else {
00393         neg = -1;
00394         fillLevel = usedFills;
00395         usedFills++;
00396         
00397         MSG("NuContour",Msg::kInfo) << "Setting countour level " << fillLevel <<  " to color " << color << endl;
00398         MSG("NuContour",Msg::kInfo) << "Current palette: " << endl;
00399         colFill[nFillCols-fillLevel-1] = color;
00400         gStyle->SetPalette(nFillCols,colFill);
00401         for (int i = nFillCols - fillLevel - 1; i < nFillCols; i++) {
00402             MSG("NuContour",Msg::kInfo) << "  colFill[" << i << "] = " << colFill[i] << endl;
00403         }
00404         
00405         
00406         if (hist) {
00407             ChooseContour(hist);
00408             hist->SetFillColor(color);
00409             hist->SetFillStyle(style);
00410         }
00411         if (hist_high) {
00412             ChooseContour(hist_high);
00413             hist_high->SetFillColor(color);
00414             hist_high->SetFillStyle(style);
00415         }
00416         if (disp_hist) {
00417             ChooseContour(disp_hist);
00418             disp_hist->SetFillColor(color);
00419             disp_hist->SetFillStyle(style);
00420         }
00421     }
00422     
00423   //ContourStyle(lc, width, style);
00424 }

void NuContour::ContourStyle ( int  color,
int  width = 3,
int  style = 1 
)

Definition at line 338 of file NtupleUtils/HEAD/NuContour.cxx.

References ChooseContour(), disp_graph, disp_hist, graph, hist, hist_high, Msg::kWarning, and MSG.

00339 {
00340     if (graph) {
00341         graph->SetLineWidth(width);
00342         graph->SetLineColor(color);
00343         graph->SetLineStyle(style);
00344     }
00345     if (disp_graph) {
00346         disp_graph->SetLineWidth(width);
00347         disp_graph->SetLineColor(color);
00348         disp_graph->SetLineStyle(style);
00349     }
00350     
00351     if (hist) {
00352         if (style != 1 && !graph && !disp_graph) {
00353             MSG("NuContour",Msg::kWarning) 
00354             << "Line styles other than solid do not come out well on histogram." << endl
00355             << "For better results call ConvertToGraph() on this contour." << endl;
00356         }
00357         
00358         hist->SetLineWidth(width);
00359         hist->SetLineColor(color);
00360         hist->SetLineStyle(style);
00361         ChooseContour(hist);
00362     }
00363     if (hist_high) {
00364         hist_high->SetLineWidth(width);
00365         hist_high->SetLineColor(color);
00366         hist_high->SetLineStyle(style);
00367         ChooseContour(hist_high);
00368     }
00369     if (disp_hist) {
00370         disp_hist->SetLineWidth(width);
00371         disp_hist->SetLineColor(color);
00372         disp_hist->SetLineStyle(style);
00373         ChooseContour(disp_hist);
00374     }
00375 }

void NuContour::ConvertToGraph (  ) 

Definition at line 549 of file NtupleUtils/HEAD/NuContour.cxx.

References Can2Cont(), ChooseContour(), disp_graph, disp_hist, DoLog(), DoLogLin(), graph, hist, hist_high, IsLog(), IsLogLin(), Msg::kInfo, Msg::kWarning, and MSG.

00550 {
00551     if (graph && !hist) {
00552         MSG("NuContour",Msg::kWarning)
00553         << "Already a graph contour -- cannot be converted" << endl;
00554         return;
00555     }
00556     else if (!hist && !disp_hist) {
00557         MSG("NuContour",Msg::kWarning)
00558         << "No histogram -- cannot be converted" << endl;
00559         return;
00560     } 
00561     else if (IsLogLin()) {
00562         MSG("NuContour",Msg::kWarning)
00563         << "Convert to graph not supported for LogLin histograms" << endl;
00564         return;
00565     }
00566     else {
00567         MSG("NuContour",Msg::kInfo)
00568         << "Converting histogram to graph" << endl;
00569     }
00570     
00571     TVirtualPad *curr = gPad;
00572     TCanvas *ctemp = new TCanvas("ctemp","ctemp");
00573     
00574 //    if (hist_high)  {
00575 //        DoLog();
00576 //        disp_hist->Draw("cont list");
00577 //    }
00578 //    else
00579     if (!hist_high) {
00580         hist->Draw("cont list");
00581         
00582         ctemp->Update();
00583         ctemp->Paint();
00584         
00585         TObjArray *contours = (TObjArray*)gROOT->GetListOfSpecials()->At(0);
00586         TList *lcontour1 = (TList*)contours->At(0);
00587         graph = new TGraph();
00588         graph->Merge(lcontour1);
00589 //        TGraph *gc1 = (TGraph*)lcontour1->First();
00590 //        graph = new TGraph(*gc1);
00591         delete ctemp; ctemp = 0;
00592         
00593         if (curr) curr->cd();
00594      
00595         if (IsLog()) DoLog();
00596         if (IsLogLin()) DoLogLin();
00597     }
00598     else {
00599         if (IsLog()) DoLog();
00600         if (IsLogLin()) DoLogLin();
00601         ChooseContour(disp_hist);
00602         disp_hist->Draw("cont list");
00603         
00604         ctemp->Update();
00605         ctemp->Paint();
00606         
00607         TObjArray *contours = (TObjArray*)gROOT->GetListOfSpecials()->At(0);
00608         TList *lcontour1 = (TList*)contours->At(0);
00609         disp_graph = new TGraph();
00610         graph = new TGraph();
00611         disp_graph->Merge(lcontour1);
00612         double px, py, y;
00613         for (int i = 0; i < disp_graph->GetN(); i++) {
00614             disp_graph->GetPoint(i, px, py);
00615             y = Can2Cont(py);
00616             graph->SetPoint(i, px, y);
00617         }
00618         
00619 //        TString name = hist->GetName();
00620 //        name += "_graph";
00621 //        TGraph *gc = new TGraph();
00622 //        gc->SetName(name);
00623 //        TGraph *gci;
00624 //        double px, py, y;
00625 //        int n = 0;
00626 //        
00627 //        for (int i = 0; i < 10; i++) {
00628 //            gci = (TGraph*)lcontour1->At(i);
00629 //            if (!gci) {
00630 //                MSG("NuContour",Msg::kInfo) << "  Merged " << i << " graphs" << endl;
00631 //                break;
00632 //            }
00633 //            for (int j = 0; j < gci->GetN(); j++) {
00634 //                gci->GetPoint(j, px, py);
00635 //                y = Can2Cont(py);
00636 //                gc->SetPoint(n, px, y);
00637 //                n++;
00638 //            }
00639 //        }
00640 //        if (addCorner) gc->SetPoint(n++, 1, ymax);
00641 //        if (n != gc->GetN()) {
00642 //            MSG("NuContour",Msg::kError) << "gc has the wrong number of points.  Should have "
00643 //            << n << " but actually has " << gc->GetN() << endl;
00644 //            assert(false);
00645 //        }
00646 //        graph = new TGraph(*gc);
00647 //
00648 //        if (IsLog()) DoLog();
00649 //        if (IsLogLin()) DoLogLin();
00650 
00651         delete ctemp; ctemp = 0;
00652         
00653         if (curr) curr->cd();
00654         
00655     }
00656 }

int NuContour::DispBins (  )  [inline]

Definition at line 62 of file NuContour.h.

References bmax.

00062 { return bmax; };

void NuContour::DispBins ( int  n  ) 

Definition at line 1092 of file NtupleUtils/HEAD/NuContour.cxx.

References bmax, DoLog(), DoLogLin(), IsLog(), and IsLogLin().

01093 {
01094     bmax = n;
01095     
01096     if (IsLogLin()) DoLogLin();
01097     if (IsLog())    DoLog();
01098 }

void NuContour::DoLin (  ) 

Definition at line 427 of file NtupleUtils/HEAD/NuContour.cxx.

References bmax, bmid, hist, lin, log, and loglin.

00428 {
00429   lin = true;
00430   loglin = false;
00431   log = false;
00432   bmid = bmax;
00433 
00434   hist->GetXaxis()->CenterTitle();
00435   TAxis *a1 = hist->GetYaxis();
00436   //a1->SetLabelSize(0);
00437   //a1->SetTickLength(0);
00438   TGaxis::SetMaxDigits(3);
00439   //a1->SetNoExponent(true);
00440   a1->SetTitleOffset(1.2);
00441   a1->CenterTitle();
00442   a1->SetTitleOffset(1.2);
00443   hist->SetTitle(";sin^{2}(2#bar{#theta});|#Delta#bar{m}^{2}| (10^{-3} eV^{2})");
00444 }

void NuContour::DoLog (  ) 

Definition at line 459 of file NtupleUtils/HEAD/NuContour.cxx.

References bmid, GenerateLog(), lin, log, and loglin.

Referenced by AddExtraHist(), ConvertToGraph(), DispBins(), LogMax(), LogMin(), and Reset().

00460 {
00461   lin = false;
00462   loglin = false;
00463   log = true;
00464   bmid = 0;
00465   GenerateLog();
00466 }

void NuContour::DoLogLin (  ) 

Definition at line 448 of file NtupleUtils/HEAD/NuContour.cxx.

References bmax, bmid, GenerateLogLin(), lin, log, and loglin.

Referenced by AddExtraHist(), ConvertToGraph(), DispBins(), LogMax(), LogMin(), and Reset().

00449 {
00450   lin = false;
00451   loglin = true;
00452   log = false;
00453   bmid = bmax / 2;
00454   GenerateLogLin();
00455 }

void NuContour::Draw ( TString  opt = ""  ) 

Definition at line 700 of file NtupleUtils/HEAD/NuContour.cxx.

References disp_graph, fillLevel, GetGraph(), GetHist(), graph, Msg::kInfo, MSG, and neg.

00701 {
00702     if (graph || disp_graph) {
00703         opt += "l";
00704         if (fillLevel >= 0) opt+="cf";
00705         MSG("NuContour",Msg::kInfo) << "Drawing graph with opt=" << opt <<  endl;
00706         GetGraph()->Draw(opt);
00707     }
00708     else {
00709         opt += "cont3";
00710         if (fillLevel >= 0) { 
00711             opt+="col";
00712         }
00713         MSG("NuContour",Msg::kInfo) << "Drawing histogram with opt=" << opt <<  endl;
00714         TH2D *htemp = new TH2D(*GetHist());
00715         htemp->Scale(neg);
00716         htemp->Draw(opt);
00717     }
00718 }

void NuContour::DrawAxes ( int  size = -1  ) 

Definition at line 872 of file NtupleUtils/HEAD/NuContour.cxx.

References bmax, bmid, Cont2Can(), MuELoss::e, Plot::Format(), GetXaxis(), IsLin(), IsLog(), IsLogLin(), Msg::kInfo, MSG, ymax, and ymid.

00873 {
00874     if (IsLin()) {
00875         double x1 = gPad->GetUxmin();
00876         double y1 = gPad->GetUymax()*1.005;
00877         double x2 = gPad->GetUxmax();
00878         double y2 = gPad->GetY2()*0.999;
00879         
00880         TPave * p1 = new TPave(x1, y1, x2, y2, 0);
00881         //TPave * p1 = new TPave(0.21, 0.93, 0.607, 0.999, 0, "NDC");
00882         p1->SetFillColor(kWhite);
00883         p1->Draw();
00884 
00885         //TMSG("NuContour",Msg::kInfo) << "Not drawing axes for linear plot" << endl;
00886         return;
00887     }
00888 //    if (IsLog()) {
00889 //        MSG("NuContour",Msg::kInfo) << "Not drawing axes for log plot" << endl;
00890 //        return;
00891 //    }        
00892     
00893     double gxmin = gPad->GetUxmin();
00894     double gymin = gPad->GetUymin();
00895     double gxmax = gPad->GetUxmax();
00896     double gymax = gPad->GetUymax();
00897     MSG("NuContour",Msg::kInfo) << "Drawing axes.  Found canvas range x: " << gxmin << " - " << gxmax << ", y: " << gymin << " - " << gymax << endl;
00898     int div_lin = 505;
00899     int div_log = 505;
00900     
00901     
00902     double x1 = gxmin;
00903     double x2 = gxmax;
00904     double y0 = gymin;
00905     double y1 = gymax*bmid/bmax;
00906     double y2 = gymax;
00907     
00908     //cout << "Using y0 = " << y0 << ", y1 = " << y1 << ", y2 = " << y2 << endl;
00909 
00910     if (IsLin()) {
00911         ymid = y2;
00912     }
00913     
00914     TF1 *fLin = new TF1("fLin","x",y0,ymid);
00915     TF1 *fLog = new TF1("fLog","TMath::Log10(x)",ymid,ymax);
00916     // Prevent unused variable warnings
00917     fLin->GetName();
00918     fLog->GetName();
00919     
00920     TGaxis *aLeft_log, *aRight_log, *aLeft_lin, *aRight_lin;
00921     
00922     aLeft_log = new TGaxis(x1, y1, x1, y2, "fLog", div_log,"G");
00923     aRight_log = new TGaxis(x2, y1, x2, y2, "fLog", div_log, "+G");
00924     
00925     aLeft_log->SetLabelSize(0);
00926     aRight_log->SetLabelSize(0);
00927     aRight_log->SetTickSize(0.05);
00928     aLeft_log->SetTickSize(0.05);
00929     
00930     aLeft_log->SetGridLength(.75);
00931     
00932     if (IsLog() || IsLogLin()) {
00933         //cout << "Drawing log axes" << endl;
00934         // Draw Log Axes from bmid to bmax
00935         aLeft_log->Draw();
00936         aRight_log->Draw();
00937     }
00938     
00939     aLeft_lin = new TGaxis(x1, y0, x1, y1, "fLin", div_lin,"");
00940     aRight_lin = new TGaxis(x2, y0, x2, y1, "fLin", div_lin, "+");
00941     
00942     aLeft_lin->SetLabelSize(0);
00943     aRight_lin->SetLabelSize(0);    
00944     aLeft_lin->SetTickSize(0.05);    
00945     aRight_lin->SetTickSize(0.05);    
00946     
00947     aLeft_lin->SetGridLength(.75);    
00948 
00949     
00950     if (IsLin() || IsLogLin()) {
00951         //cout << "Drawing lin axes" << endl;
00952         // Draw Linear Axes from 0 to bmid
00953         TGaxis::SetMaxDigits(2);
00954         aLeft_lin->Draw();
00955         aRight_lin->Draw();    
00956     }
00957     
00958     
00959     double yl, ln, yl_p;
00960     int nlab = 0;
00961     double log_num[99];
00962     
00963     
00964 
00965 //    if (IsLin()) {
00966 //        aLeft_lin->SetLabelFont(GetXaxis()->GetLabelFont());
00967 //        aLeft_lin->SetLabelSize(GetXaxis()->GetLabelSize());
00968 //        TPave * p1 = new TPave(0.21, 0.93, 0.607, 0.999, 0, "NDC");
00969 //        p1->Draw();
00970 //    }
00971     if (IsLogLin()) {
00972         
00973         double scale = 1.e3;
00974         double range = (ymid - y0)*scale;
00975         //cout << "Drawing lin labels" << endl;
00976         int mod = (int)TMath::Log10(range);
00977         if (mod < 1) mod = 1;
00978         double step = (int)(range/mod);
00979         step *= mod / 5.;
00980         for (ln = y0*scale; ln <= ymid*scale; ln += step) {
00981             //cout << "Choosing label #" << nlab << " at " << ln << endl;
00982             log_num[nlab++] = ln;
00983         }
00984     }
00985     
00986     if (IsLog() || IsLogLin()) {
00987         for (ln = 1e-5 ; ln/1e3 <= ymax; ln *= 10) {
00988             if (ln/1e3 > ymid)
00989                 log_num[nlab++] = ln;
00990             if (ln*2/1e3 <= ymax && ln/1e3*2 > ymid) 
00991                 log_num[nlab++] = ln*2;
00992             if (ln*4/1e3 <= ymax && ln/1e3*4 > ymid) 
00993                 log_num[nlab++] = ln*4;
00994         }
00995     }
00996     
00997     TLatex *lab_tex[99];
00998     yl_p = -999;
00999     for (int i = 0; i < nlab; i++) {
01000         yl = Cont2Can(log_num[i]/1e3);
01001         if (!IsLin()) {
01002             if ( yl - yl_p < 0.04*bmax ) {
01003                 if (log_num[i] < ymid) log_num[i] += 2;
01004                 else                   log_num[i] *= 2;
01005                 yl = Cont2Can(log_num[i]/1e3);
01006             }
01007             yl_p = yl;
01008         }
01009         //cout << "Drawing label #" << i << " at " << yl << endl;
01010         lab_tex[i] = new TLatex(x1-0.01, yl, TString::Format("%3g",log_num[i]));
01011         if (size == -1) {
01012             lab_tex[i]->SetTextFont(GetXaxis()->GetLabelFont());
01013             lab_tex[i]->SetTextSize(GetXaxis()->GetLabelSize());
01014         }
01015         else {
01016             lab_tex[i]->SetTextFont(43);
01017             lab_tex[i]->SetTextSize(size);
01018         }
01019         lab_tex[i]->SetTextAlign(32);
01020         lab_tex[i]->Draw();
01021     }
01022     
01023 
01024     // Put in log-lin dividing line
01025     if (IsLogLin()) {
01026       TLine *l1 = new TLine(x1, y1, x2, y1);
01027       l1->SetLineStyle(2);
01028       l1->Draw();
01029 
01030       TLatex *t[99];
01031       int nT = -1;
01032       
01033       t[++nT] = new TLatex(x1+0.08, y1+0.01*y2, "Log");
01034       t[nT]->SetTextAlign(11);
01035       double defsize = t[nT]->GetTextSize();
01036       
01037       t[++nT] = new TLatex(x1+0.08, y1-0.01*y2, "Linear");
01038       t[nT]->SetTextAlign(13);
01039       
01040       
01041       for (int i = 0; i <= nT; i++) {
01042         if (size == -1) {
01043           if (t[i]->GetTextSize() == defsize) {
01044             t[i]->SetTextSize(0.045);
01045           }
01046           t[i]->SetTextFont(42);
01047         }
01048         else {
01049           t[i]->SetTextFont(43);
01050           t[i]->SetTextSize(size);
01051         }
01052         t[i]->Draw();
01053       }
01054     }
01055 }

void NuContour::DrawLog ( TString  opt = ""  )  [private]
void NuContour::DrawLogLin ( TString  opt = ""  )  [private]
void NuContour::DrawNormal ( TString  opt = ""  )  [private]
void NuContour::FixCanvas ( TCanvas *  c1  ) 

Definition at line 862 of file NtupleUtils/HEAD/NuContour.cxx.

00863 {
00864     c1->SetCanvasSize(700,1000);
00865     c1->SetWindowSize(700,1000);    
00866     c1->SetLeftMargin(0.2);
00867     c1->SetRightMargin(0.05);
00868 }

void NuContour::GenerateLog (  )  [private]

Definition at line 734 of file NtupleUtils/HEAD/NuContour.cxx.

References GenerateLogLin().

Referenced by DoLog().

00735 {
00736     GenerateLogLin();
00737 //    if (hist) {
00738 //        GenerateLogHist();
00739 //        
00740 //    }
00741 }

void NuContour::GenerateLogHist (  )  [private]

Definition at line 793 of file NtupleUtils/HEAD/NuContour.cxx.

References Can2Cont(), disp_hist, hdivide, hist, hist_high, interpolate(), n, ymax, and ymid.

00794 {
00795     static int n = -1;
00796     n++;
00797     TString num(n);
00798     disp_hist = new TH2D("hLog"+num,";sin^{2}(2#bar{#theta});|#Delta#bar{m}^{2}| (10^{-3} eV^{2})",
00799                          100, 0, 1,
00800                          500, ymid, ymax);
00801     disp_hist->GetXaxis()->CenterTitle();
00802     disp_hist->GetYaxis()->CenterTitle();
00803     
00804     
00805     TAxis *a1 = disp_hist->GetYaxis();
00806     //a1->SetLabelSize(0);
00807     //a1->SetTickLength(0);
00808     a1->SetTitleOffset(1.2);
00809     
00810     //int old_bx, old_by;
00811     double val;
00812     double x, y;
00813     TH2D * hOld = 0; 
00814     
00815     for (int by = 1; by <= disp_hist->GetNbinsY(); by++) {
00816         y = Can2Cont(by);
00817         
00818         if (hist_high) {
00819             if (y > hdivide) hOld = hist_high;
00820             else             hOld = hist;
00821         }
00822         else {
00823             hOld = hist;
00824         }
00825         
00826         for (int bx = 1; bx <= disp_hist->GetNbinsX(); bx++) {
00827             x = disp_hist->GetBinCenter(bx);
00828             
00829             //old_bx = hOld->GetXaxis()->FindFixBin(x);
00830             //old_by = hOld->GetYaxis()->FindFixBin(y);
00831             //val = hOld->GetBinContent(old_bx, old_by);
00832             val = interpolate(hOld, x, y);
00833             
00834             disp_hist->SetBinContent(bx, by, val);
00835         }
00836     }
00837 }

void NuContour::GenerateLogLin (  )  [private]

Definition at line 722 of file NtupleUtils/HEAD/NuContour.cxx.

References GenerateLogLinGraph(), GenerateLogLinHist(), graph, and hist.

Referenced by DoLogLin(), and GenerateLog().

00723 {
00724     if (hist) {
00725         GenerateLogLinHist();
00726     }
00727     if (graph) {
00728         GenerateLogLinGraph();
00729     }
00730 }

void NuContour::GenerateLogLinGraph (  )  [private]

Definition at line 841 of file NtupleUtils/HEAD/NuContour.cxx.

References Cont2Can(), disp_graph, graph, Msg::kInfo, and MSG.

Referenced by GenerateLogLin().

00842 {
00843     if (graph == disp_graph) {
00844         MSG("NuContour",Msg::kInfo) << "Converting disp_graph has precednece -- no conversion" << endl;        
00845     }
00846     //cout << "Converting graph to disp_graph" << endl;
00847     disp_graph = new TGraph(*graph);
00848     TString name = graph->GetName();
00849     disp_graph->SetName(name+"LL");
00850     double px, py, y;
00851     
00852     for (int i = 0; i < disp_graph->GetN(); i++) {
00853         disp_graph->GetPoint(i, px, py);
00854         y = Cont2Can(py);
00855 
00856         disp_graph->SetPoint(i, px, y);
00857     }        
00858 }

void NuContour::GenerateLogLinHist (  )  [private]

Definition at line 745 of file NtupleUtils/HEAD/NuContour.cxx.

References bmax, Can2Cont(), disp_hist, hdivide, hist, hist_high, interpolate(), and n.

Referenced by GenerateLogLin().

00746 {
00747     static int n = -1;
00748     n++;
00749     TString num(n);
00750     disp_hist = new TH2D("hCombo"+num,";sin^{2}(2#bar{#theta});|#Delta#bar{m}^{2}| (10^{-3} eV^{2})",
00751                       500, 0, 1,
00752                       bmax, 0, bmax);
00753     disp_hist->GetXaxis()->CenterTitle();
00754     disp_hist->GetYaxis()->CenterTitle();
00755 
00756     
00757     TAxis *a1 = disp_hist->GetYaxis();
00758     a1->SetLabelSize(0);
00759     a1->SetTickLength(0);
00760     a1->SetTitleOffset(1.2);
00761     
00762     //int old_bx, old_by;
00763     double val;
00764     double x, y;
00765     TH2D * hOld = 0; 
00766     
00767     for (int by = 1; by <= disp_hist->GetNbinsY(); by++) {
00768         y = Can2Cont(by);
00769         
00770         if (hist_high) {
00771             if (y > hdivide) hOld = hist_high;
00772             else             hOld = hist;
00773         }
00774         else {
00775             hOld = hist;
00776         }
00777         
00778         for (int bx = 1; bx <= disp_hist->GetNbinsX(); bx++) {
00779             x = disp_hist->GetBinCenter(bx);
00780             
00781             //old_bx = hOld->GetXaxis()->FindFixBin(x);
00782             //old_by = hOld->GetYaxis()->FindFixBin(y);
00783             //val = hOld->GetBinContent(old_bx, old_by);
00784             val = interpolate(hOld, x, y);
00785             
00786             disp_hist->SetBinContent(bx, by, val);
00787         }
00788     }
00789 }

TGraph * NuContour::GetGraph ( bool  nowarn = false  ) 

Definition at line 500 of file NtupleUtils/HEAD/NuContour.cxx.

References disp_graph, graph, IsLin(), IsLog(), IsLogLin(), Msg::kError, Msg::kWarning, and MSG.

Referenced by AddToLegend(), Draw(), GetXaxis(), and GetYaxis().

00501 {
00502     if (!graph && !disp_graph) {
00503         if (!nowarn) {
00504             MSG("NuContour",Msg::kWarning)
00505             << "Graph not defined for this contour." << endl;
00506         }
00507         return 0;
00508     }
00509     if (IsLin()) {
00510         //cout << "GetGraph returning graph" << endl;
00511         return graph;
00512     }
00513     else if (IsLogLin() || IsLog()) {
00514         //cout << "GetGraph returning disp_graph" << endl;
00515         return disp_graph;
00516     }
00517     else {
00518         MSG("NuContour",Msg::kError)
00519         << "Contour is in undefined mode.  This shouldn't happen." << endl;
00520         return 0;
00521     }
00522 }

TH2D * NuContour::GetHist ( bool  nowarn = false  ) 

Definition at line 470 of file NtupleUtils/HEAD/NuContour.cxx.

References disp_hist, hist, IsLin(), IsLog(), IsLogLin(), Msg::kError, Msg::kWarning, and MSG.

Referenced by AddToLegend(), Draw(), GetXaxis(), and GetYaxis().

00471 {
00472     if (!hist) {
00473         if (!nowarn) {
00474             MSG("NuContour",Msg::kWarning)
00475             << "Histogram not defined for this contour." << endl;
00476         }
00477         return 0;
00478     }
00479     if (IsLin())         {
00480         //cout << "GetHist returning hist" << endl;        
00481         return hist;
00482     }
00483     else if (IsLogLin()) {
00484         //cout << "GetHist returning disp_hist (loglin)" << endl;       
00485         return disp_hist;
00486     }
00487     else if (IsLog()) {
00488         //cout << "GetHist returning disp_hist (log)" << endl;       
00489         return disp_hist;
00490     }
00491     else {
00492         MSG("NuContour",Msg::kError)
00493         << "Contour is in undefined mode.  This shouldn't happen." << endl;
00494         return 0;
00495     }
00496 }

TH2D* NuContour::GetLog (  )  [private]
TGraph* NuContour::GetLogGraph (  )  [private]
TH2D* NuContour::GetLogLin (  )  [private]
TGraph* NuContour::GetLogLinGraph (  )  [private]
TH2D* NuContour::GetNormal (  )  [private]
TGraph* NuContour::GetNormalGraph (  )  [private]
TAxis * NuContour::GetXaxis (  ) 

Definition at line 526 of file NtupleUtils/HEAD/NuContour.cxx.

References GetGraph(), and GetHist().

Referenced by DrawAxes(), and SetFontAndSize().

00527 {
00528     if (GetHist()) {
00529         return GetHist()->GetXaxis();
00530     }
00531     else {
00532         return GetGraph()->GetHistogram()->GetXaxis();
00533     }
00534 }

TAxis * NuContour::GetYaxis (  ) 

Definition at line 538 of file NtupleUtils/HEAD/NuContour.cxx.

References GetGraph(), and GetHist().

Referenced by SetFontAndSize().

00539 {
00540     if (GetHist(true)) {
00541         return GetHist()->GetYaxis();
00542     }
00543     else {
00544         return GetGraph()->GetHistogram()->GetYaxis();
00545     }
00546 }

double NuContour::interpolate ( TH2D *  h,
double  x,
double  y,
double  def = 999. 
) [private]

Definition at line 1119 of file NtupleUtils/HEAD/NuContour.cxx.

References Msg::kWarning, and MAXMSG.

Referenced by Add(), GenerateLogHist(), and GenerateLogLinHist().

01120 {
01121    // Given a point P(x,y), Interpolate approximates the value via bilinear 
01122    // interpolation based on the four nearest bin centers 
01123    // see Wikipedia, Bilinear Interpolation 
01124    // Andy Mastbaum 10/8/2008 
01125    // vaguely based on R.Raja 6-Sep-2008 
01126 
01127    Double_t f=0; 
01128    Double_t x1=0,x2=0,y1=0,y2=0; 
01129    Double_t dx,dy; 
01130    
01131    TAxis *fXaxis = h->GetXaxis();
01132    TAxis *fYaxis = h->GetYaxis();
01133 
01134    Int_t bin_x = fXaxis->FindBin(x); 
01135    Int_t bin_y = fYaxis->FindBin(y); 
01136     
01137     if (bin_x < 1) {
01138         bin_x = 1;
01139         x = fXaxis->GetBinLowEdge(bin_x);
01140         MAXMSG("NuContour",Msg::kWarning, 5) << "Below x range, extending lowest x value" << endl;
01141     }
01142     if (bin_y < 1) {
01143         bin_y = 1;
01144         y = fYaxis->GetBinLowEdge(bin_y);
01145         MAXMSG("NuContour",Msg::kWarning, 5) << "Below y range, extending lowest y value" << endl;
01146     }
01147     if (bin_x>h->GetNbinsX()) {
01148         bin_x = h->GetNbinsX();
01149         x = fXaxis->GetBinLowEdge(bin_x+1);
01150         MAXMSG("NuContour",Msg::kWarning, 5) << "Above x range, extending highest x value" << endl;
01151     }
01152     if ( bin_y>h->GetNbinsY()) {
01153         bin_y = h->GetNbinsY();
01154         y = fYaxis->GetBinLowEdge(bin_y+1);
01155         MAXMSG("NuContour",Msg::kWarning, 5) << "Above y range, extending highest y value" << endl;
01156     }
01157     
01158     
01159 //    if(bin_x<1 || bin_x>h->GetNbinsX() || bin_y<1 || bin_y>h->GetNbinsY()) {
01160 //     MAXMSG("NuContour",Msg::kWarning,5) 
01161 //       << "Cannot interpolate outside histogram domain, using default value " 
01162 //       << def << endl;
01163 //      return def;     
01164 //   }
01165 
01166    Int_t quadrant = 0; // CCW from UR 1,2,3,4 
01167    // which quadrant of the bin (bin_P) are we in? 
01168    dx = fXaxis->GetBinUpEdge(bin_x)-x; 
01169    dy = fYaxis->GetBinUpEdge(bin_y)-y; 
01170    if (dx<=fXaxis->GetBinWidth(bin_x)/2 && dy<=fYaxis->GetBinWidth(bin_y)/2) 
01171      quadrant = 1; // upper right 
01172    if (dx>fXaxis->GetBinWidth(bin_x)/2 && dy<=fYaxis->GetBinWidth(bin_y)/2) 
01173      quadrant = 2; // upper left 
01174    if (dx>fXaxis->GetBinWidth(bin_x)/2 && dy>fYaxis->GetBinWidth(bin_y)/2) 
01175      quadrant = 3; // lower left 
01176    if (dx<=fXaxis->GetBinWidth(bin_x)/2 && dy>fYaxis->GetBinWidth(bin_y)/2) 
01177      quadrant = 4; // lower right 
01178 
01179    switch(quadrant) { 
01180    case 1: 
01181       x1 = fXaxis->GetBinCenter(bin_x); 
01182       y1 = fYaxis->GetBinCenter(bin_y); 
01183       x2 = fXaxis->GetBinCenter(bin_x+1); 
01184       y2 = fYaxis->GetBinCenter(bin_y+1); 
01185       break; 
01186    case 2: 
01187       x1 = fXaxis->GetBinCenter(bin_x-1); 
01188       y1 = fYaxis->GetBinCenter(bin_y); 
01189       x2 = fXaxis->GetBinCenter(bin_x); 
01190       y2 = fYaxis->GetBinCenter(bin_y+1); 
01191       break; 
01192    case 3: 
01193       x1 = fXaxis->GetBinCenter(bin_x-1); 
01194       y1 = fYaxis->GetBinCenter(bin_y-1); 
01195       x2 = fXaxis->GetBinCenter(bin_x); 
01196       y2 = fYaxis->GetBinCenter(bin_y); 
01197       break; 
01198    case 4: 
01199       x1 = fXaxis->GetBinCenter(bin_x); 
01200       y1 = fYaxis->GetBinCenter(bin_y-1); 
01201       x2 = fXaxis->GetBinCenter(bin_x+1); 
01202       y2 = fYaxis->GetBinCenter(bin_y); 
01203       break; 
01204    } 
01205 
01206    Int_t bin_x1 = fXaxis->FindBin(x1);
01207    if(bin_x1<1) bin_x1=1;
01208    Int_t bin_x2 = fXaxis->FindBin(x2);
01209    if(bin_x2>h->GetNbinsX()) bin_x2=h->GetNbinsX();
01210    Int_t bin_y1 = fYaxis->FindBin(y1);
01211    if(bin_y1<1) bin_y1=1;
01212    Int_t bin_y2 = fYaxis->FindBin(y2);
01213    if(bin_y2>h->GetNbinsY()) bin_y2=h->GetNbinsY();
01214 
01215    Int_t bin_q22 = h->GetBin(bin_x2,bin_y2);
01216    Int_t bin_q12 = h->GetBin(bin_x1,bin_y2);
01217    Int_t bin_q11 = h->GetBin(bin_x1,bin_y1);
01218    Int_t bin_q21 = h->GetBin(bin_x2,bin_y1);
01219    Double_t q11 = h->GetBinContent(bin_q11); 
01220    Double_t q12 = h->GetBinContent(bin_q12); 
01221    Double_t q21 = h->GetBinContent(bin_q21); 
01222    Double_t q22 = h->GetBinContent(bin_q22); 
01223    Double_t d = 1.0*(x2-x1)*(y2-y1);
01224 
01225    f = 1.0*q11/d*(x2-x)*(y2-y)+1.0*q21/d*(x-x1)*(y2-y)+1.0*q12/d*(x2-x)*(y-y1)+1.0*q22/d*(x-x1)*(y-y1);
01226    return f; 
01227 
01228 }

bool NuContour::IsLin (  )  [inline]

Definition at line 41 of file NuContour.h.

References lin.

Referenced by Can2Cont(), Cont2Can(), DrawAxes(), GetGraph(), and GetHist().

00041 { return lin; };

bool NuContour::IsLog (  )  [inline]

Definition at line 43 of file NuContour.h.

References log.

Referenced by AddCorner(), AddExtraHist(), ConvertToGraph(), DispBins(), DrawAxes(), GetGraph(), GetHist(), LogMax(), LogMin(), and Reset().

00043 { return log; };

bool NuContour::IsLogLin (  )  [inline]

Definition at line 42 of file NuContour.h.

References loglin.

Referenced by AddExtraHist(), ConvertToGraph(), DispBins(), DrawAxes(), GetGraph(), GetHist(), LogMax(), LogMin(), and Reset().

00042 { return loglin; };

void NuContour::LogMax ( double  y  ) 

Definition at line 1101 of file NtupleUtils/HEAD/NuContour.cxx.

References DoLog(), DoLogLin(), IsLog(), IsLogLin(), and ymax.

01102 {
01103     ymax = y;
01104     if (IsLogLin()) DoLogLin();
01105     if (IsLog())    DoLog();
01106 }

void NuContour::LogMin ( double  y  ) 

Definition at line 1110 of file NtupleUtils/HEAD/NuContour.cxx.

References DoLog(), DoLogLin(), IsLog(), IsLogLin(), and ymid.

01111 {
01112     ymid = y;
01113     if (IsLogLin()) DoLogLin();
01114     if (IsLog())    DoLog();
01115 }

Double_t NuContour::MinBin ( const TH2D &  hist  )  [static, private]

Definition at line 1273 of file NtupleUtils/HEAD/NuContour.cxx.

References minimum.

Referenced by Combine(), SetFC(), and SetGauss().

01274 {
01275     Double_t minimum = -1.;
01276     for(Int_t x = 1; x <= hist.GetNbinsX(); x++) {
01277         for(Int_t y = 1; y <= hist.GetNbinsY(); y++) {
01278             
01279             Double_t val = hist.GetBinContent(x, y);
01280             if (x == 1 && y == 1) {
01281                 minimum = val;
01282             } else {
01283                 minimum = TMath::Min(minimum, val);
01284             }
01285         }
01286     }
01287     
01288     return minimum;
01289 }

NuContour & NuContour::operator= ( const NuContour rhs  ) 

Definition at line 119 of file NtupleUtils/HEAD/NuContour.cxx.

References bmax, bmid, contLevel, disp_graph, disp_hist, fillLevel, graph, hdivide, hist, hist_high, lin, log, loglin, neg, Reset(), ymax, and ymid.

00120 {
00121   // Check for self assignment
00122   if (this == &rhs) return *this;
00123 
00124   Reset();
00125   if (rhs.hist) hist = new TH2D(*rhs.hist);
00126   if (rhs.disp_hist) disp_hist =  new TH2D(*rhs.disp_hist);
00127   if (rhs.hist_high) hist_high =  new TH2D(*rhs.hist_high);
00128   if (rhs.graph) graph = new TGraph(*rhs.graph);
00129   if (rhs.disp_graph) disp_graph = new TGraph(*rhs.disp_graph);
00130   
00131   lin = rhs.lin;
00132   loglin = rhs.loglin;
00133   log = rhs.log;
00134   fillLevel = rhs.fillLevel;
00135   contLevel = rhs.contLevel;
00136   neg = rhs.neg;
00137   hdivide = rhs.hdivide;
00138   ymid = rhs.ymid;
00139   ymax = rhs.ymax;
00140   bmid = rhs.bmid;
00141   bmax = rhs.bmax;
00142   
00143   return *this;
00144 }

void NuContour::Reset ( TGraph *  g  ) 

Definition at line 183 of file NtupleUtils/HEAD/NuContour.cxx.

References DoLog(), DoLogLin(), graph, IsLog(), IsLogLin(), and Reset().

00184 {
00185     Reset();
00186     graph = new TGraph(*g);
00187     if (IsLogLin()) DoLogLin();
00188     if (IsLog())    DoLog();
00189 }

void NuContour::Reset ( TH2D *  hin  ) 

Definition at line 174 of file NtupleUtils/HEAD/NuContour.cxx.

References DoLog(), DoLogLin(), hist, IsLog(), IsLogLin(), and Reset().

00175 {
00176     Reset();
00177     hist = new TH2D(*hin);
00178     if (IsLogLin()) DoLogLin();
00179     if (IsLog())    DoLog();
00180 }

void NuContour::Reset (  ) 

Definition at line 155 of file NtupleUtils/HEAD/NuContour.cxx.

References disp_graph, disp_hist, graph, hist, and hist_high.

Referenced by NuContour(), operator=(), Reset(), and ~NuContour().

00156 {
00157     /*
00158     if (hist) delete hist;
00159     if (disp_hist) delete disp_hist;
00160     if (hist_high) delete hist_high;
00161     if (graph) delete graph;
00162     if (disp_graph) delete disp_graph;
00163     */
00164     
00165     hist = 0;
00166     disp_hist = 0;
00167     hist_high = 0;
00168     graph = 0;
00169     disp_graph = 0; 
00170     
00171 }

void NuContour::SetFC ( TH2D *  correction  ) 

Definition at line 279 of file NtupleUtils/HEAD/NuContour.cxx.

References Add(), ChooseContour(), contLevel, disp_hist, hist, hist_high, min, MinBin(), and ShiftHist().

00280 {
00281    double min = 0;
00282    contLevel = 0;
00283 
00284    if (hist) {
00285         min = MinBin(*hist);
00286         ShiftHist(hist, -min);
00287         Add(hist, correction, -1);
00288         ChooseContour(hist);
00289     }
00290     if (hist_high) {
00291         ShiftHist(hist_high, -min);
00292         Add(hist_high, correction, -1);
00293         ChooseContour(hist_high);
00294     }
00295     if (disp_hist) {
00296         ShiftHist(disp_hist, -min);
00297         Add(disp_hist, correction, -1, true);
00298         ChooseContour(disp_hist);
00299     }
00300     
00301 }

void NuContour::SetFontAndSize ( int  textFont,
int  textSize 
)

Definition at line 1074 of file NtupleUtils/HEAD/NuContour.cxx.

References GetXaxis(), and GetYaxis().

01075 {
01076     GetXaxis()->SetLabelFont(textFont);
01077     GetXaxis()->SetTitleFont(textFont);
01078     GetYaxis()->SetLabelFont(textFont);
01079     GetYaxis()->SetTitleFont(textFont);
01080     
01081     GetXaxis()->SetLabelSize(textSize);
01082     GetXaxis()->SetTitleSize(textSize);
01083     GetYaxis()->SetLabelSize(textSize);
01084     GetYaxis()->SetTitleSize(textSize);
01085     
01086     // Offsets that work well for typical fonts/sizes
01087     GetXaxis()->SetTitleOffset(1.2);        
01088     GetYaxis()->SetTitleOffset(1.42);        
01089 }

void NuContour::SetGauss ( double  level  ) 

Definition at line 255 of file NtupleUtils/HEAD/NuContour.cxx.

References ChooseContour(), contLevel, disp_hist, hist, hist_high, min, MinBin(), and ShiftHist().

00256 {
00257     double min = 0;
00258     contLevel = 0;
00259     
00260     if (hist) {
00261         min = MinBin(*hist);
00262         ShiftHist(hist, -min-level);
00263         ChooseContour(hist);
00264     }
00265     if (hist_high) {
00266         ShiftHist(hist_high, -min-level);
00267         ChooseContour(hist_high);
00268     }
00269     if (disp_hist) {
00270         ShiftHist(disp_hist, -min-level);
00271         ChooseContour(disp_hist);
00272     }
00273 }

void NuContour::ShiftHist ( TH2D *  hist,
Double_t  shift 
) [static, private]

Definition at line 1293 of file NtupleUtils/HEAD/NuContour.cxx.

Referenced by Combine(), SetFC(), and SetGauss().

01294 {
01295     for(Int_t x = 1; x <= hist->GetNbinsX(); x++) {
01296         for(Int_t y = 1; y <= hist->GetNbinsY(); y++) {
01297             Double_t val = hist->GetBinContent(x, y);
01298             hist->SetBinContent(x, y, val + shift);
01299         }
01300     }
01301 }


Member Data Documentation

int NuContour::bmax [private]
int NuContour::bmid [private]

Definition at line 121 of file NuContour.h.

Referenced by Can2Cont(), Cont2Can(), DoLin(), DoLog(), DoLogLin(), DrawAxes(), NuContour(), and operator=().

Int_t * NuContour::colFill = 0 [static, private]

Definition at line 108 of file NuContour.h.

Referenced by ContourFillStyle(), and NuContour().

double NuContour::contLevel [private]

Definition at line 103 of file NuContour.h.

Referenced by ChooseContour(), NuContour(), operator=(), SetFC(), and SetGauss().

TGraph* NuContour::disp_graph [private]
TH2D* NuContour::disp_hist [private]
int NuContour::fillLevel [private]

Definition at line 102 of file NuContour.h.

Referenced by AddToLegend(), ChooseContour(), ContourFillStyle(), Draw(), NuContour(), and operator=().

TGraph* NuContour::graph [private]
double NuContour::hdivide [private]
TH2D* NuContour::hist [private]
TH2D* NuContour::hist_high [private]
bool NuContour::lin [private]

Definition at line 98 of file NuContour.h.

Referenced by DoLin(), DoLog(), DoLogLin(), IsLin(), NuContour(), and operator=().

bool NuContour::log [private]

Definition at line 100 of file NuContour.h.

Referenced by DoLin(), DoLog(), DoLogLin(), IsLog(), NuContour(), and operator=().

bool NuContour::loglin [private]

Definition at line 99 of file NuContour.h.

Referenced by DoLin(), DoLog(), DoLogLin(), IsLogLin(), NuContour(), and operator=().

double NuContour::neg [private]

Definition at line 104 of file NuContour.h.

Referenced by ChooseContour(), ContourFillStyle(), Draw(), NuContour(), and operator=().

int NuContour::nFillCols = 10 [static, private]

Definition at line 106 of file NuContour.h.

Referenced by ChooseContour(), and ContourFillStyle().

int NuContour::usedFills = 0 [static, private]

Definition at line 107 of file NuContour.h.

Referenced by ContourFillStyle().

double NuContour::ymax [private]
double NuContour::ymid [private]

The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1