UtilCanvas Namespace Reference

Functions

TCanvas * NewCanvas (std::string cn="", std::string ti="")
TCanvas * NewLetterCanvas (std::string cn="", std::string ti="")
TCanvas * NewNHighCanvas (int NHigh, std::string cn="", std::string ti="")
TCanvas * NewNWideCanvas (int NWide, std::string cn="", std::string ti="")
TCanvas * NewFourByCanvas (std::string cn="", std::string ti="")
TCanvas * NewSixByCanvas (std::string cn="", std::string ti="")
void FixPad (TPad *pad)
void UpdatePad (TPad *pad)
bool PadFilled (TPad *pad)

Function Documentation

void UtilCanvas::FixPad ( TPad *  pad  ) 

Definition at line 60 of file UtilCanvas.cxx.

References UtilHist::HMax(), UtilHist::HMin(), Msg::kSynopsis, and MSG.

Referenced by CamEvd::FillEvent(), and CamEvd::MakeShieldPlot().

00060                                  {
00061   MSG("Util",Msg::kSynopsis) << "UtilCanvas::FixPad" << endl;
00062   if(!pad) return;
00063   static vector<TH1*> histos; histos.clear();
00064 
00065   pad->Modified();
00066   pad->Update();
00067 
00068   TObject *obj = 0;
00069   TIterator *itr2 = pad->GetListOfPrimitives()->MakeIterator();
00070   while ( (obj = itr2->Next()) ) {
00071     TH1* h1 = dynamic_cast<TH1*>(obj);
00072     if(h1) histos.push_back(h1);
00073     TLegend *leg = dynamic_cast<TLegend*>(obj);
00074     if(leg) leg->SetBorderSize(0);
00075     TPaveText *pav = dynamic_cast<TPaveText*>(obj);
00076     if(pav) pav->SetFillStyle(0);
00077     TPad *inpad = dynamic_cast<TPad*>(obj);
00078     if(inpad) UtilCanvas::FixPad(inpad);
00079   }
00080   pad->Modified();
00081 
00082   //Only concerned with 2 or more histograms on same pad
00083   if (histos.size() < 2) {
00084     MSG("Util",Msg::kSynopsis) << "This pad only has " << histos.size()
00085            << " hists, no need to fix" << endl;
00086     return;
00087   }
00088 
00089   double Max = UtilHist::HMax(histos);
00090   double Min = UtilHist::HMin(histos);
00091   double Min0 = UtilHist::HMin(histos, 0);
00092 
00093   //Save a handful of later divide by zero errors
00094   if((Max==0 && Min==0) || Max==Min) return;
00095 
00096   if (pad->GetLogy()) {
00097     MSG("Util",Msg::kSynopsis) << "Correcting for Y Axis Log Scale" << endl;
00098 
00099     //For LogY, a Min<=0 causes ugliness, fix here
00100     if(Min <= 0.0)  Min = Min0;
00101 
00102     double Buf = TMath::Power(Max/Min, 0.05);
00103 
00104     MSG("Util",Msg::kSynopsis) << "For Max = " << Max << ", Min = " << Min
00105            << ", Using Buf = " << Buf << endl;
00106 
00107     Max *= Buf;
00108     Min /= Buf;
00109   }
00110   else {
00111     MSG("Util",Msg::kSynopsis) << "Correcting for Y Axis Linear Scale" << endl;
00112     double Buf = (Max-Min) * 0.05;
00113 
00114     MSG("Util",Msg::kSynopsis) << "For Max = " << Max << ", Min = " << Min
00115            << ", Using Buf = " << Buf << endl;
00116 
00117     Max += Buf;
00118     if(Min<0 || Min>Buf) Min -= Buf;
00119     else Min = 0.0;
00120   }
00121 
00122   histos[0]->GetYaxis()->SetRangeUser(Min, Max);
00123   pad->Modified();
00124 }

TCanvas* UtilCanvas::NewCanvas ( std::string  cn = "",
std::string  ti = "" 
)
TCanvas* UtilCanvas::NewFourByCanvas ( std::string  cn = "",
std::string  ti = "" 
)
TCanvas* UtilCanvas::NewLetterCanvas ( std::string  cn = "",
std::string  ti = "" 
)
TCanvas* UtilCanvas::NewNHighCanvas ( int  NHigh,
std::string  cn = "",
std::string  ti = "" 
)
TCanvas* UtilCanvas::NewNWideCanvas ( int  NWide,
std::string  cn = "",
std::string  ti = "" 
)
TCanvas* UtilCanvas::NewSixByCanvas ( std::string  cn = "",
std::string  ti = "" 
)
bool UtilCanvas::PadFilled ( TPad *  pad  ) 

Definition at line 140 of file UtilCanvas.cxx.

Referenced by CamEvd::DoPrint().

00140                                     {
00141   if(!pad) return false;
00142   TList *tl = pad->GetListOfPrimitives();
00143   TIterator *itr2 = tl->MakeIterator();
00144   TObject *obj = 0;
00145   bool IsFilled = false;
00146   
00147   while ( (obj=itr2->Next()) ) {
00148     TPad* p1 = dynamic_cast<TPad*>(obj);
00149     if(p1) IsFilled = IsFilled || UtilCanvas::PadFilled(p1);
00150     if((dynamic_cast<TH1*>(obj))) IsFilled = true;;
00151   }
00152   return IsFilled;
00153 }

void UtilCanvas::UpdatePad ( TPad *  pad  ) 

Definition at line 126 of file UtilCanvas.cxx.

Referenced by CamEvd::DoTab(), CamEvd::SetPlaneRangeUser(), CamEvd::SetUStripRangeUser(), and CamEvd::SetVStripRangeUser().

00126                                     {
00127   if(!pad) return;
00128   TList *tl = pad->GetListOfPrimitives();
00129   TIterator *itr2 = tl->MakeIterator();
00130   TObject *obj = 0;
00131   
00132   while ( (obj=itr2->Next()) ) {
00133     TPad* p1 = dynamic_cast<TPad*>(obj);
00134     if(p1) p1->Modified();
00135   }
00136   pad->Modified();
00137   pad->Update();
00138 }


Generated on 18 Jan 2018 for loon by  doxygen 1.6.1