ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
Legend Class Reference

slightly more convenient legend class More...

#include <computils.h>

Collaboration diagram for Legend:

Public Member Functions

 Legend ()
 
 Legend (double x1, double x2, double y1, double y2)
 
 Legend (const Legend &legend)
 
 ~Legend ()
 
TLegend * legend ()
 
size_t size () const
 
double TextSize () const
 
int TextFont () const
 
double height () const
 
double width () const
 
void AddEntry (TObject *tobj, const std::string &s, const std::string &type="p")
 
void Draw ()
 

Private Attributes

TLegend * m_leg
 
double m_x [2]
 
double m_y [2]
 
std::vector< TObject * > m_obj
 
std::vector< std::string > m_entries
 
std::vector< std::string > m_type
 

Detailed Description

slightly more convenient legend class

Definition at line 337 of file computils.h.

Constructor & Destructor Documentation

◆ Legend() [1/3]

Legend::Legend ( )
inline

Definition at line 341 of file computils.h.

341  : m_leg(nullptr){
342  m_x[0]=0.0;
343  m_y[0]=0.0;
344  m_x[1]=0.0;
345  m_y[1]=0.0;
346  }

◆ Legend() [2/3]

Legend::Legend ( double  x1,
double  x2,
double  y1,
double  y2 
)
inline

Definition at line 348 of file computils.h.

348  : m_leg(nullptr) {
349  m_x[0]=x1;
350  m_y[0]=y1;
351  m_x[1]=x2;
352  m_y[1]=y2;
353  }

◆ Legend() [3/3]

Legend::Legend ( const Legend legend)
inline

Definition at line 358 of file computils.h.

358  : m_leg(legend.m_leg),
359  m_x{legend.m_x[0], legend.m_x[1]},
360  m_y{legend.m_y[0], legend.m_y[1]} { }

◆ ~Legend()

Legend::~Legend ( )
inline

Definition at line 362 of file computils.h.

362 { }

Member Function Documentation

◆ AddEntry()

void Legend::AddEntry ( TObject *  tobj,
const std::string &  s,
const std::string &  type = "p" 
)
inline

Definition at line 378 of file computils.h.

378  {
379  m_obj.push_back( tobj );
380  m_entries.push_back( s );
381  m_type.push_back( type );
382  }

◆ Draw()

void Legend::Draw ( )
inline

ha ! don't actually create the legend until we want to draw it, then we can determine the size etc automatically

Definition at line 384 of file computils.h.

384  {
385 
388 
389  double y0 = 0;
390 
391  if ( m_y[0]>0.5 ) {
392  y0 = m_y[1] - m_entries.size()*0.05;
393  }
394  else {
395  y0 = m_y[0];
396  m_y[1] = y0 + m_entries.size()*0.05;
397  }
398 
399  m_leg = new TLegend( m_x[0], y0, m_x[1], m_y[1] );
400 
401  m_leg->SetBorderSize(0);
402  m_leg->SetTextFont(42);
403  m_leg->SetTextSize(0.04);
404  m_leg->SetFillStyle(3000);
405  m_leg->SetFillColor(0);
406  m_leg->SetLineColor(0);
407 
408  for ( size_t i=0 ; i<m_entries.size() ; i++ ) {
409  m_leg->AddEntry( m_obj[i], m_entries[i].c_str(), m_type[i].c_str() );
410  }
411 
412  m_leg->Draw();
413  }

◆ height()

double Legend::height ( ) const
inline

Definition at line 374 of file computils.h.

374 { return m_y[1]-m_y[0]; }

◆ legend()

TLegend* Legend::legend ( )
inline

Definition at line 364 of file computils.h.

364 { return m_leg; }

◆ size()

size_t Legend::size ( ) const
inline

Definition at line 366 of file computils.h.

366  {
367  return m_entries.size();
368  }

◆ TextFont()

int Legend::TextFont ( ) const
inline

Definition at line 372 of file computils.h.

372 { return m_leg->GetTextFont(); }

◆ TextSize()

double Legend::TextSize ( ) const
inline

Definition at line 370 of file computils.h.

370 { return m_leg->GetTextSize(); }

◆ width()

double Legend::width ( ) const
inline

Definition at line 376 of file computils.h.

376 { return m_x[1]-m_x[0]; }

Member Data Documentation

◆ m_entries

std::vector<std::string> Legend::m_entries
private

Definition at line 424 of file computils.h.

◆ m_leg

TLegend* Legend::m_leg
private

Definition at line 418 of file computils.h.

◆ m_obj

std::vector<TObject*> Legend::m_obj
private

Definition at line 423 of file computils.h.

◆ m_type

std::vector<std::string> Legend::m_type
private

Definition at line 425 of file computils.h.

◆ m_x

double Legend::m_x[2]
private

Definition at line 420 of file computils.h.

◆ m_y

double Legend::m_y[2]
private

Definition at line 421 of file computils.h.


The documentation for this class was generated from the following file:
Legend::m_x
double m_x[2]
Definition: computils.h:420
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:215
Legend::m_obj
std::vector< TObject * > m_obj
Definition: computils.h:423
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:217
Legend::m_type
std::vector< std::string > m_type
Definition: computils.h:425
Legend::legend
TLegend * legend()
Definition: computils.h:364
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
lumiFormat.i
int i
Definition: lumiFormat.py:85
makeTRTBarrelCans.y2
tuple y2
Definition: makeTRTBarrelCans.py:18
Legend::m_entries
std::vector< std::string > m_entries
Definition: computils.h:424
MuonR4::SegmentFit::ParamDefs::y0
@ y0
Legend::m_y
double m_y[2]
Definition: computils.h:421
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
Legend::m_leg
TLegend * m_leg
Definition: computils.h:418