31                            const std::string option,
 
   32                            const Double_t    factor = 1.0)
 
   38    const Double_t X1  = 0.0 + gPad->GetLeftMargin();
 
   39    const Double_t X2  = 1.0 - gPad->GetRightMargin();
 
   40    const Double_t Y1  = 0.0 + gPad->GetBottomMargin();
 
   41    const Double_t 
Y2  = 1.0 - gPad->GetTopMargin();
 
   43    const Double_t w   = gPad->XtoPixel(gPad->GetX2());
 
   44    const Double_t h   = gPad->YtoPixel(gPad->GetY1());
 
   46    const Double_t w1  = fabs(gPad->XtoPixel(gPad->GetX2()) - gPad->XtoPixel(gPad->GetX1()));
 
   47    const Double_t h1  = fabs(gPad->YtoPixel(gPad->GetY2()) - gPad->YtoPixel(gPad->GetY1()));
 
   49    const Double_t mw  = 2.0;                                  
 
   50    const Double_t mh  = 0.5;                                  
 
   51    const Double_t eps = 0.015;                                
 
   52    const Double_t ts  = gStyle->GetStatFontSize() * factor;   
 
   53    const Double_t ch  = ts * (w < h ? w : h);                 
 
   55    Double_t W  = (width  + mw) * (ch/w1) * factor;            
 
   56    Double_t H  = (height + mh) * (ch/h1) * factor;            
 
   60    if (fc * W > X2 - X1 - 2*eps) { fc *= (X2 - X1 - 2*eps) / W; }
 
   61    if (fc * H > 
Y2 - Y1 - 2*eps) { fc *= (
Y2 - Y1 - 2*eps) / H; }
 
   68    Double_t x1  = X2 - W - eps;
 
   69    Double_t y1  = 
Y2 - H - eps;
 
   70    Double_t x2  = X2     - eps;
 
   71    Double_t y2  = 
Y2     - eps;
 
   73    if (option.find(
'T') != string::npos && option.find(
'B') == string::npos) {   
 
   78    if (option.find(
'B') != string::npos && option.find(
'T') == string::npos) {   
 
   83    if (option.find(
'R') != string::npos && option.find(
'L') == string::npos) {   
 
   88    if (option.find(
'L') != string::npos && option.find(
'R') == string::npos) {   
 
   93    TLegend* lg = 
new TLegend(x1, y1, x2, y2);
 
   96    lg->SetFillColor(kWhite);
 
   99    lg->SetTextFont(gStyle->GetStatFont());